From 75b1326104de72bf50839e5dfbd53c63fcd82a90 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Wed, 23 Jul 2025 15:12:20 +0200 Subject: [PATCH 1/3] Don't generate 3 band resistor when it can't represent the value --- LabelGenerator.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/LabelGenerator.py b/LabelGenerator.py index e5f23e0..0ca2722 100755 --- a/LabelGenerator.py +++ b/LabelGenerator.py @@ -347,6 +347,8 @@ def draw_resistor_colorcode( num_codes: int, tolerance_value: Optional[float], ) -> None: + if num_codes == 3 and value.ohms_val % 10: + return resistance_values: List[int] = [] for i in range(num_codes-1): From 23e2937546258ed9b11be38c271d77b5e3bb45cd Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Wed, 23 Jul 2025 18:07:36 +0200 Subject: [PATCH 2/3] Make accuracy check more generic --- LabelGenerator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LabelGenerator.py b/LabelGenerator.py index 0ca2722..b703fe5 100755 --- a/LabelGenerator.py +++ b/LabelGenerator.py @@ -347,7 +347,7 @@ def draw_resistor_colorcode( num_codes: int, tolerance_value: Optional[float], ) -> None: - if num_codes == 3 and value.ohms_val % 10: + if value.ohms_val % (10 ** (4 - num_codes)): return resistance_values: List[int] = [] From e567e7c507c1947cbbaa3f9abb3a08d110fcb80b Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Thu, 24 Jul 2025 18:00:32 +0200 Subject: [PATCH 3/3] Add comment --- LabelGenerator.py | 1 + 1 file changed, 1 insertion(+) diff --git a/LabelGenerator.py b/LabelGenerator.py index b703fe5..90332b8 100755 --- a/LabelGenerator.py +++ b/LabelGenerator.py @@ -347,6 +347,7 @@ def draw_resistor_colorcode( num_codes: int, tolerance_value: Optional[float], ) -> None: + # Only display resistors that can accurately represent the given value if value.ohms_val % (10 ** (4 - num_codes)): return