From 4c3815b25a23f8df2d6bfdab83962367150bd285 Mon Sep 17 00:00:00 2001 From: jaseg Date: Sun, 7 Jul 2024 14:36:41 +0200 Subject: Fix THT flower proto area --- gerbonara/cad/primitives.py | 1 - gerbonara/cad/protoboard.py | 34 ++++++++++++++++++++++++++++------ gerbonara/cad/protoserve.py | 3 ++- 3 files changed, 30 insertions(+), 8 deletions(-) (limited to 'gerbonara') diff --git a/gerbonara/cad/primitives.py b/gerbonara/cad/primitives.py index 591999c..a5c5209 100644 --- a/gerbonara/cad/primitives.py +++ b/gerbonara/cad/primitives.py @@ -127,7 +127,6 @@ class Board: layer_stack['mechanical', 'outline'].objects.extend(self.outline) layer_stack['top', 'silk'].objects.extend(self.extra_silk_top) layer_stack['bottom', 'silk'].objects.extend(self.extra_silk_bottom) - print('layer stack is', repr(layer_stack['top', 'copper'].objects)[:1000]) return layer_stack diff --git a/gerbonara/cad/protoboard.py b/gerbonara/cad/protoboard.py index 0a5bbbe..cc1ab9e 100644 --- a/gerbonara/cad/protoboard.py +++ b/gerbonara/cad/protoboard.py @@ -271,10 +271,12 @@ class PatternProtoArea: for i in range(n_x): for j in range(n_y): - if isinstance(self.obj, PadStack): - obj = self.obj.grid_variant(i, j, i == n_x-1, j == n_y-1) - if obj is None: - continue + obj = self.obj + if isinstance(obj, PadStack): + if hasattr(obj, 'grid_variant'): + obj = obj.grid_variant(i, j, i == n_x-1, j == n_y-1) + if obj is None: + continue px = self.unit(off_x + x, unit) + (i + 0.5) * self.pitch_x py = self.unit(off_y + y, unit) + (j + 0.5) * self.pitch_y @@ -323,6 +325,10 @@ class ManhattanPads(PadStack): h: float = None gap: float = 0.2 + @property + def single_sided(self): + return True + @property def apertures(self): w = self.w @@ -360,6 +366,10 @@ class RFGroundProto(PadStack): _: KW_ONLY = None suppress_via: bool = False + @property + def single_sided(self): + return False + @property def apertures(self): unit = self.unit @@ -406,12 +416,20 @@ class THTFlowerProto(PadStack): pitch: float = 2.54 drill: float = 0.9 diameter: float = 2.0 + clearance: float = 0.5 + + @property + def single_sided(self): + return False @property def apertures(self): - p = self.pitch / 2 + p = self.diameter / 2 + pad_dist_diag = math.sqrt(2) * (self.pitch - p) - self.drill + pad_dist_ortho = 2*self.pitch - self.diameter - self.drill + pad_dia = self.drill + max(0, min(pad_dist_diag, pad_dist_ortho) - self.clearance) - pad = THTPad.circle(self.drill, self.diameter, paste=False, unit=self.unit) + pad = THTPad.circle(self.drill, pad_dia, paste=False, unit=self.unit) for ox, oy in ((-p, 0), (p, 0), (0, -p), (0, p)): for stack_ap in pad.apertures: @@ -452,6 +470,10 @@ class PoweredProto(Graphics): Yajima Manufacturing Corporation website: http://www.yajima-works.co.jp/index.html """ + @property + def single_sided(self): + return False + def __init__(self, pitch=None, drill=None, clearance=None, power_pad_dia=None, via_size=None, trace_width=None, unit=MM): super().__init__(0, 0) self.unit = unit diff --git a/gerbonara/cad/protoserve.py b/gerbonara/cad/protoserve.py index cc5aae2..3271af1 100644 --- a/gerbonara/cad/protoserve.py +++ b/gerbonara/cad/protoserve.py @@ -107,7 +107,8 @@ def deserialize(obj, unit): pitch = mil(float(obj.get('pitch', 2.54))) hole_dia = mil(float(obj['hole_dia'])) pattern_dia = mil(float(obj['pattern_dia'])) - return pb.PatternProtoArea(2*pitch, 2*pitch, pb.THTFlowerProto(pitch, hole_dia, pattern_dia, unit=unit), unit=unit) + clearance = mil(float(obj['clearance'])) + return pb.PatternProtoArea(pitch, pitch, pb.THTFlowerProto(pitch, hole_dia, pattern_dia, clearance, unit=unit), unit=unit) case 'spiky': return pb.PatternProtoArea(2.54, 2.54, pb.SpikyProto(), unit=unit) -- cgit