Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added methods to quickly generate common series #25

Merged
merged 5 commits into from
Mar 18, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions LabelGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ def __init__(
num_stickers_vertical=8,
)

E12 = [ 1.0, 1.2, 1.5, 1.8, 2.2, 2.7, 3.3, 3.9, 4.7, 5.6, 6.8, 8.2 ]
Finomnis marked this conversation as resolved.
Show resolved Hide resolved

# 1.1, 1.3, and 1.6 are commonly ommitted from the resistor E24 series
E24 = [ 1.0, 1.2, 1.5, 1.8, 2.0, 2.2, 2.4, 2.7, 3.0, 3.3, 3.6, 3.9, 4.3, 4.7, 5.1, 5.6, 6.2, 6.8, 7.5, 8.2, 9.1]
E24_ALL = [ 1.0, 1.1, 1.2, 1.3, 1.5, 1.6, 1.8, 2.0, 2.2, 2.4, 2.7, 3.0, 3.3, 3.6, 3.9, 4.3, 4.7, 5.1, 5.6, 6.2, 6.8, 7.5, 8.2, 9.1 ]

class StickerRect:
def __init__(self, c: Canvas, layout: PaperConfig, row: int, column: int, mirror: bool):
Expand Down Expand Up @@ -602,6 +607,19 @@ def render_outlines(c: Canvas, layout: PaperConfig) -> None:
c.setLineWidth(0)
c.roundRect(rect.left, rect.bottom, rect.width, rect.height, rect.corner)

def generate_decade(
series: List[float], # the base series of resistor values
power: int # the power of 10 to scale the series by
) -> List[float]:
scalar = 10 ** power
return [scalar * x for x in series]

def generate_decades(
Finomnis marked this conversation as resolved.
Show resolved Hide resolved
series: List[float],
first_decade: int,
last_decade: int
) -> ResistorList:
return [generate_decade(series, x) for x in range(first_decade, last_decade)]

def main() -> None:

Expand Down Expand Up @@ -632,6 +650,12 @@ def main() -> None:
[9100000000, 9200000000, 3300000000],
]

# ############################################################################
# Alternatively, The E12, E24, and E24_ALL constants can be passed to the
# generate_decades function to create typical resistor value sets.
Finomnis marked this conversation as resolved.
Show resolved Hide resolved
# ############################################################################
# resistor_values: ResistorList = [ 0, 0.01 ] + generate_decades(E24, 0, 6)

# ############################################################################
# Further configuration options
#
Expand Down
Loading