diff options
author | jaseg <git@jaseg.de> | 2023-04-29 23:26:13 +0200 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2023-04-29 23:26:13 +0200 |
commit | fb61b4fa12a5662f92d0dbaa8314686656e97386 (patch) | |
tree | 9d640eb904383c0fc92de70749f208f2d15fcd9c /gerbonara | |
parent | e4a459368c1befe89c48af1b7721f490df17d001 (diff) | |
download | gerbonara-fb61b4fa12a5662f92d0dbaa8314686656e97386.tar.gz gerbonara-fb61b4fa12a5662f92d0dbaa8314686656e97386.tar.bz2 gerbonara-fb61b4fa12a5662f92d0dbaa8314686656e97386.zip |
protoserve: Adjust margins and clearance defaults
Diffstat (limited to 'gerbonara')
-rw-r--r-- | gerbonara/cad/protoboard.py | 26 | ||||
-rw-r--r-- | gerbonara/cad/protoserve.py | 3 | ||||
-rw-r--r-- | gerbonara/cad/protoserve_data/protoserve.html | 2 | ||||
-rw-r--r-- | gerbonara/rs274x.py | 2 |
4 files changed, 18 insertions, 15 deletions
diff --git a/gerbonara/cad/protoboard.py b/gerbonara/cad/protoboard.py index bc759f8..69f3328 100644 --- a/gerbonara/cad/protoboard.py +++ b/gerbonara/cad/protoboard.py @@ -192,9 +192,10 @@ def alphabetic(case='upper'): class PatternProtoArea: - def __init__(self, pitch_x, pitch_y=None, obj=None, numbers=True, font_size=None, font_stroke=None, number_x_gen=alphabetic(), number_y_gen=numeric(), interval_x=5, interval_y=None, unit=MM): + def __init__(self, pitch_x, pitch_y=None, obj=None, numbers=True, font_size=None, font_stroke=None, number_x_gen=alphabetic(), number_y_gen=numeric(), interval_x=5, interval_y=None, margin=0, unit=MM): self.pitch_x = pitch_x self.pitch_y = pitch_y or pitch_x + self.margin = margin self.obj = obj self.unit = unit self.numbers = numbers @@ -205,12 +206,13 @@ class PatternProtoArea: self.number_x_gen, self.number_y_gen = number_x_gen, number_y_gen def fit_size(self, w, h, unit=MM): - (min_x, min_y), (max_x, max_y) = self.fit_rect(((0, 0), (w, h))) - return max_x-min_x, max_y-min_y + (min_x, min_y), (max_x, max_y) = self.fit_rect(((0, 0), (max(0, w-2*self.margin), max(0, h-2*self.margin)))) + return max_x-min_x + 2*self.margin, max_y-min_y + 2*self.margin def fit_rect(self, bbox, unit=MM): (x, y), (w, h) = bbox - w, h = w-x, h-y + x, y = x+self.margin, y+self.margin + w, h = w-x-self.margin, h-y-self.margin w_mod = round((w + 5e-7) % unit(self.pitch_x, self.unit), 6) h_mod = round((h + 5e-7) % unit(self.pitch_y, self.unit), 6) @@ -558,20 +560,20 @@ def eval_value(value, total_length=None): def _demo(): #pattern1 = PatternProtoArea(2.54, obj=THTPad.circle(0, 0, 0.9, 1.8, paste=False)) - pattern1 = PatternProtoArea(2.54, 2.54, obj=SpikyProto()) - pattern2 = PatternProtoArea(1.2, 2.0, obj=SMDPad.rect(0, 0, 1.0, 1.8, paste=False)) - pattern3 = PatternProtoArea(2.54, 1.27, obj=SMDPad.rect(0, 0, 2.3, 1.0, paste=False)) + #pattern1 = PatternProtoArea(2.54, 2.54, obj=SpikyProto()) + #pattern2 = PatternProtoArea(1.2, 2.0, obj=SMDPad.rect(0, 0, 1.0, 1.8, paste=False)) + #pattern3 = PatternProtoArea(2.54, 1.27, obj=SMDPad.rect(0, 0, 2.3, 1.0, paste=False)) #pattern3 = EmptyProtoArea(copper_fill=True) #stack = TwoSideLayout(pattern2, pattern3) - stack = PropLayout([pattern2, pattern3], 'v', [0.5, 0.5]) - pattern = PropLayout([pattern1, stack], 'h', [0.5, 0.5]) + pattern2 = PatternProtoArea(2.54, obj=PoweredProto(), margin=1) + pattern3 = PatternProtoArea(2.54, obj=RFGroundProto()) + stack = PropLayout([pattern2, pattern3], 'h', [0.5, 0.5]) + #pattern = PropLayout([pattern1, stack], 'h', [0.5, 0.5]) #pattern = PatternProtoArea(2.54, obj=ManhattanPads(2.54)) - #pattern = PatternProtoArea(2.54, obj=PoweredProto()) - #pattern = PatternProtoArea(2.54, obj=RFGroundProto()) #pattern = PatternProtoArea(2.54*1.5, obj=THTFlowerProto()) #pattern = PatternProtoArea(2.54, obj=THTPad.circle(0, 0, 0.9, 1.8, paste=False)) #pattern = PatternProtoArea(2.54, obj=PoweredProto()) - pb = ProtoBoard(50, 50, pattern1, mounting_hole_dia=3.2, mounting_hole_offset=5) + pb = ProtoBoard(50, 47, stack, mounting_hole_dia=3.2, mounting_hole_offset=5) #pb = ProtoBoard(10, 10, pattern1) print(pb.pretty_svg()) pb.layer_stack().save_to_directory('/tmp/testdir') diff --git a/gerbonara/cad/protoserve.py b/gerbonara/cad/protoserve.py index 8512ca5..4a10acc 100644 --- a/gerbonara/cad/protoserve.py +++ b/gerbonara/cad/protoserve.py @@ -99,7 +99,8 @@ def deserialize(obj, unit): via_drill = mil(float(obj['via_hole_dia'])) via_dia = mil(float(obj['via_dia'])) trace_width = mil(float(obj['trace_width'])) - return pb.PatternProtoArea(pitch, pitch, pb.PoweredProto(pitch, hole_dia, clearance, via_size=via_drill, power_pad_dia=via_dia, trace_width=trace_width, unit=unit), unit=unit) + # Force 1mm margin to avoid shorts when adjacent to planes such as that one in the RF THT proto. + return pb.PatternProtoArea(pitch, pitch, pb.PoweredProto(pitch, hole_dia, clearance, via_size=via_drill, power_pad_dia=via_dia, trace_width=trace_width, unit=unit), margin=1.0, unit=unit) case 'flower': pitch = mil(float(obj.get('pitch', 2.54))) diff --git a/gerbonara/cad/protoserve_data/protoserve.html b/gerbonara/cad/protoserve_data/protoserve.html index ad612ac..9568718 100644 --- a/gerbonara/cad/protoserve_data/protoserve.html +++ b/gerbonara/cad/protoserve_data/protoserve.html @@ -593,7 +593,7 @@ input { <span class="unit us">mil</span> </label> <label>Clearance - <input type="text" name="clearance" placeholder="length" value="0.5"> + <input type="text" name="clearance" placeholder="length" value="0.3"> <span class="unit metric">mm</span> <span class="unit us">mil</span> </label> diff --git a/gerbonara/rs274x.py b/gerbonara/rs274x.py index fb70869..c559029 100644 --- a/gerbonara/rs274x.py +++ b/gerbonara/rs274x.py @@ -286,7 +286,7 @@ class GerberFile(CamFile): number = 10 for aperture in self.apertures: if isinstance(aperture, apertures.ApertureMacroInstance): - macro_def = am_stmt(aperture.rotated().macro) + macro_def = am_stmt(aperture.macro) if macro_def not in processed_macros: processed_macros.add(macro_def) yield macro_def |