From 1ed127e3b324bad221a58bbc953a5a725ed4f21f Mon Sep 17 00:00:00 2001 From: jaseg Date: Sun, 7 Jul 2024 21:55:17 +0200 Subject: protoboard: improve permanent breadboard rendering --- gerbonara/cad/protoboard.py | 52 ++++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 19 deletions(-) (limited to 'gerbonara') diff --git a/gerbonara/cad/protoboard.py b/gerbonara/cad/protoboard.py index 364dc70..4bb21ad 100644 --- a/gerbonara/cad/protoboard.py +++ b/gerbonara/cad/protoboard.py @@ -223,31 +223,35 @@ def numeric(start=1): return gen -def alphabetic(case='upper'): +def alphabetic(case='upper', alphabet=None): if case not in ('lower', 'upper'): raise ValueError('case must be one of "lower" or "upper".') - index = string.ascii_lowercase if case == 'lower' else string.ascii_uppercase + if alphabet is None: + index = string.ascii_lowercase if case == 'lower' else string.ascii_uppercase + else: + index = alphabet + n = len(index) def gen(): - nonlocal index + nonlocal index, n for i in itertools.count(): - if i<26: + if i 0: # include one power rail pitch unit for the space between adjacent tiles. w += 2*self.power_rail_space + (2*self.num_power_rails-1) * self.power_rail_pitch @@ -440,6 +444,8 @@ class BreadboardArea: if self.num_power_rails == 2 and best_layout.count('P') >= 2: power_rail_labels = ['-', '+'] * best_layout.count('P') + else: + power_rail_labels = [e for _, e in zip(best_layout, alphabetic(alphabet='ZXYWVU')())] signal_labels = alphabetic()() # yes, twice. line_ap = CircleAperture(self.power_trace_width, unit=self.unit) @@ -454,7 +460,7 @@ class BreadboardArea: le_line = [Line(*start, *end, aperture=line_ap, unit=self.unit)] yield Graphics(0, 0, top_silk=le_line, bottom_silk=le_line, unit=self.unit) - label = power_rail_labels.pop() + label = power_rail_labels.pop(0) elif e == 'H': label = next(signal_labels) @@ -464,16 +470,24 @@ class BreadboardArea: if label: tx1, ty1 = start tx2, ty2 = end + if self.horizontal: - pass + tx1 -= self.pitch_y/2 + tx2 += self.pitch_y/2 + + yield Text(tx1, ty1, label, self.font_size, self.font_stroke, 'right', 'middle', unit=self.unit) + yield Text(tx1, ty1, label, self.font_size, self.font_stroke, 'right', 'middle', unit=self.unit, flip=True) + yield Text(tx2, ty2, label, self.font_size, self.font_stroke, 'left', 'middle', unit=self.unit) + yield Text(tx2, ty2, label, self.font_size, self.font_stroke, 'left', 'middle', unit=self.unit, flip=True) + else: ty1 -= self.pitch_y/2 ty2 += self.pitch_y/2 - yield Text(tx1, ty1, label, self.font_size, self.font_stroke, 'center', 'top', unit=self.unit) - yield Text(tx1, ty1, label, self.font_size, self.font_stroke, 'center', 'top', unit=self.unit, flip=True) - yield Text(tx2, ty2, label, self.font_size, self.font_stroke, 'center', 'bottom', unit=self.unit) - yield Text(tx2, ty2, label, self.font_size, self.font_stroke, 'center', 'bottom', unit=self.unit, flip=True) + yield Text(tx1, ty1, label, self.font_size, self.font_stroke, 'center', 'top', unit=self.unit) + yield Text(tx1, ty1, label, self.font_size, self.font_stroke, 'center', 'top', unit=self.unit, flip=True) + yield Text(tx2, ty2, label, self.font_size, self.font_stroke, 'center', 'bottom', unit=self.unit) + yield Text(tx2, ty2, label, self.font_size, self.font_stroke, 'center', 'bottom', unit=self.unit, flip=True) class PatternProtoArea: -- cgit