Skip to content
This repository has been archived by the owner on Oct 2, 2020. It is now read-only.

Commit

Permalink
transformer: introduce naming helpers & fix footprint
Browse files Browse the repository at this point in the history
  • Loading branch information
hvraven committed Aug 18, 2019
1 parent c17d6a8 commit e93cca5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 26 deletions.
8 changes: 3 additions & 5 deletions schlib/autogen/Transformer/definitions/block.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
Block_FL:
reference: TR
name: "{series}-{va_rating}-{voltage}"
manufacturer: Block
series: FL
description: "{va_rating}VA, 2x{voltage}, Dual Primary, Dual Secondary, Print Transformer"
keywords: "{va_rating}VA PCB transformer"
datasheet: "https://www.block.eu/fileadmin/Blaetterkatalog_und_ebook/eBook.pdf#page=278"
dots: bottom
primary: 2
secondary:
- dot: bottom
- dot: bottom
secondary: 2
core: true
footprint_library: "Transformer_THT.pretty"
footprint_library: "Transformer_THT"
variants:
power_rating:
- va_rating: 2
Expand Down
30 changes: 11 additions & 19 deletions schlib/autogen/Transformer/definitions/breve.yaml
Original file line number Diff line number Diff line change
@@ -1,39 +1,33 @@
Breve_TEZ:
manufacturer: Breve
name: "{series}{va_rating}-D-{secs}"
description: "TEZ{va_rating}/D/{secs}, {va_rating}VA, Cast Resin Transformer"
name: "{series}{va_rating}-D-{secondaries}"
description: "TEZ{va_rating}/D/{secondaries}, {va_rating}VA, Cast Resin Transformer"
keywords: "{va_rating}VA PCB Transformer Single Primary"
datasheet: "https://www.breve.pl/pdf/ANG/TEZ_ang.pdf"
core: true
series: TEZ
footprint_library: "Transformer_THT.pretty"
footprint_library: "Transformer_THT"
footprint: "Transformer_{manufacturer}_{series}-{fp_size}"
definitions:
package_small: &tez_small
primary: [1, 5]
variants:
- secs: 1
secondary: [7, 9]
- secs: 2
secondary: [[6, 7], [9, 10]]
- secondary: [7, 9]
- secondary: [[6, 7], [9, 10]]
package_large: &tez_large
primary: [1, 7]
variants:
- secs: 1
secondary: [9, 13]
- secs: 2
secondary: [[8, 9], [13, 14]]
- secondary: [9, 13]
- secondary: [[8, 9], [13, 14]]
variants:
- va_rating: "0,5"
fp_size: "22x24"
primary:
- dot: top
pins: [1, 4]
variants:
- secs: 1
secondary: [6, 7]
- secs: 2
secondary: [[5, 6], [7,8]]
- secondary: [6, 7]
- secondary: [[5, 6], [7,8]]
- va_rating: "1,5"
fp_size: "28x33"
<<: *tez_small
Expand All @@ -59,10 +53,8 @@ Breve_TEZ:
fp_size: "44x52"
primary: [1, 6]
variants:
- secs: 1
secondary: [8, 11]
- secs: 2
secondary: [[7, 8], [11, 12]]
- secondary: [8, 11]
- secondary: [[7, 8], [11, 12]]
- va_rating: "16,0"
fp_size: "47x57"
<<: *tez_large
Expand Down
22 changes: 20 additions & 2 deletions schlib/autogen/Transformer/transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def generate_transformer(generator, config):
if config.get("core"):
drawing.append(draw_core(height))

translate = drawing_sep % 200 / 2
translate = ((max(config["primaries"], config["secondaries"]) - 1)
* (drawing_sep % 200) / 2)
drawing.translate(dict(
x=0, y=translate))

Expand All @@ -81,7 +82,9 @@ def generate_transformer(generator, config):
fontsize=fontsize,
alignment_vertical=SymbolField.FieldAlignment.CENTER
)
symbol.setDefaultFootprint(value=config["footprint"].format(**config))
symbol.setDefaultFootprint(value=(
config["footprint_library"] + ":" + config["footprint"]
).format(**config))

for alias in config.get("aliases", []):
name = alias["name"]
Expand Down Expand Up @@ -256,6 +259,7 @@ def expand_definition(name, config):
last_used_pin = max(max(*prim["pins"]) for prim in exp["primary"])
exp["secondary"] = expand_coil_definition(exp, exp["secondary"],
pin_start=last_used_pin)
exp.update(add_naming_helpers(exp))

return expanded

Expand All @@ -280,6 +284,20 @@ def expand_coil_definition(config, coil_config, pin_start=1):
out.append(coil_conf)
return out

def add_naming_helpers(config):
"""inject extra entries usefull for constructing names"""
counting_dict = {
1: "single",
2: "dual",
3: "triple"
}
return dict(
primaries=len(config["primary"]),
secondaries=len(config["secondary"]),
text_primaries=counting_dict[len(config["primary"])],
text_secondaries=counting_dict[len(config["secondary"])],
)

def build_symbols(file_path):
defs = []
for path in Path("definitions").glob("*.yaml"):
Expand Down

0 comments on commit e93cca5

Please sign in to comment.