def emit(x, y): copper_pads.append( hole(x=x + edist, y=y + edist, pinnr=pin[0], ringwidth=0.5 * holesize, diameter=holesize)) pin[0] += 1
def gen_pcb(pin_names=[], pins=2, holediameter="0.7", ringwidth="0.4", pitch="2.54", nofrontring=None): pins = int(pins) for x in xrange(pins): pin_names.append("pin%d" % (x, )) holediameter = float(holediameter) ringwidth = float(ringwidth) pitch = float(pitch) N = pins overall_w = N * pitch overall_h = holediameter + 2.0 * ringwidth xx = overall_w / 2.0 yy = overall_h / 2.0 x = overall_w / 2.0 y = overall_h / 2.0 x1 = 0.5 * pitch header = """<?xml version='1.0' encoding='UTF-8'?> <svg xmlns="http://www.w3.org/2000/svg" baseProfile="tiny" viewBox="0 0 %(w)f %(h)f" height="%(height_mm)fmm" width="%(width_mm)fmm" version="1.2"> <desc> <referenceFile>unknown.svg</referenceFile> </desc> <desc >Fritzing footprint SVG</desc> """ % dict( h=overall_h, w=overall_w, height_mm=overall_h, width_mm=overall_w) silkscreen = (""" <g id="silkscreen"> """) silkscreen += (""" </g> """) print "Nofrontring:", nofrontring if nofrontring: print "Is true" if not nofrontring: print "Is false" copper_start = """ <g id="copper0"> """ if not nofrontring: copper_start += """ <g id="copper1"> """ copper_pads = [] for pin in xrange(N): copper_pads.append( hole(pinnr=pin, x=x1 + pitch * float(pin), y=yy, ringwidth=ringwidth, diameter=holediameter)) copper_end = "" if not nofrontring: copper_end = """ </g>""" copper_end += """ </g> """ if nofrontring: copper_end += """<g id="copper1">""" for pin in xrange(N): copper_end += hole(pinnr=pin, x=x1 + pitch * float(pin), y=yy, ringwidth=0.0, diameter=holediameter) copper_end += """</g>""" footer = """ </svg> """ out = header + silkscreen + copper_start + "\n".join( copper_pads) + copper_end + footer return out, False
def gen_pcb(pin_names=[], **options): pin_names.append("minus") pin_names.append("plus") pitch = float(options['pitch']) offset = float(options['offset']) diameter = float(options['diameter']) ringwidth = float(options['ringwidth']) holediameter = float(options['holediameter']) overall_w = diameter + 0.125 y1a = -pitch / 2.0 - holediameter / 2.0 - ringwidth y2a = +pitch / 2.0 + holediameter / 2.0 + ringwidth y1b = -diameter / 2.0 + offset - 0.125 y2b = +diameter / 2.0 + offset + 0.125 y1 = min(y1a, y1b) y2 = max(y2a, y2b) overall_h = y2 - y1 xx = overall_w / 2.0 yy = -y1 header = """<?xml version='1.0' encoding='UTF-8'?> <svg xmlns="http://www.w3.org/2000/svg" baseProfile="tiny" viewBox="0 0 %(w)f %(h)f" height="%(height_mm)fmm" width="%(width_mm)fmm" version="1.2"> <desc> <referenceFile>unknown.svg</referenceFile> </desc> <desc >Fritzing footprint SVG</desc> """ % dict( h=overall_h, w=overall_w, height_mm=overall_h, width_mm=overall_w) silkscreen = (""" <g id="silkscreen"> """) silkscreen += ( """<circle stroke="white" fill="none" cx="%(x)f" cy="%(y)f" r="%(radius)f" stroke-width="0.25"/>""" % dict(x=xx, y=offset + yy, radius=diameter / 2.0)) silkscreen += (""" </g> """) copper_start = """ <g id="copper0"> <g id="copper1"> """ copper_pads = [] copper_pads.append( hole(pinnr=0, x=xx, y=pitch / 2.0 + yy, ringwidth=ringwidth, diameter=holediameter)) copper_pads.append( hole(pinnr=1, x=xx, y=-pitch / 2.0 + yy, ringwidth=ringwidth, diameter=holediameter)) copper_end = """ </g> </g> """ footer = """ </svg> """ out = header + silkscreen + copper_start + "\n".join( copper_pads) + copper_end + footer return out, False
def gen_pcb(pin_names, **options): pins = int(options['pins']) holesize = float(options['holesize']) ring = float(options['ringwidth']) pitch = float(options['pitch']) width = float(options['width'] ) if 'width' in options and options['width'].strip() else 0.0 height = float( options['height'] ) if 'height' in options and options['height'].strip() else 0.0 offset = float( options['height_offset']) if 'height_offset' in options and options[ 'height_offset'].strip() else 0.0 sparkgap = 'sparkgap' in options sparkgap_width = float( options['sparkgap_width'] ) if 'sparkgap_width' and options['sparkgap_width'].strip() else 0.5 sparkgap_lead = float( options['sparkgap_lead'] ) if 'sparkgap_lead' and options['sparkgap_lead'].strip() else 1.0 if sparkgap_lead < 0.5: sparkgap_lead = 0.5 for i in xrange(pins): pin_names.append(options['pin%d' % (i, )]) if sparkgap: pin_names.append("SparkGND") silk_t = 0.5 effective_ring = ring + 2 * pcb.defaultplating if width == 0: width = pitch * (pins + 1) + holesize + effective_ring * 2 if height == 0: height = (3 + holesize + effective_ring * 2) minwidth = pitch * (pins - 1) + holesize + effective_ring * 2.0 minheight = holesize + effective_ring * 2.0 overall_x = max(width, minwidth) overall_y = max(height, minheight) dx = (overall_x - (pins - 1) * pitch) / 2.0 dy = overall_y / 2.0 + offset ringtop = dy - holesize / 2.0 - effective_ring gaph1 = ringtop - sparkgap_width * 2.0 - sparkgap_lead gaph2 = ringtop - sparkgap_width * 2.0 gaph3 = ringtop - sparkgap_width header = """<?xml version='1.0' encoding='UTF-8'?> <svg xmlns="http://www.w3.org/2000/svg" baseProfile="tiny" viewBox="0 0 %(w)f %(h)f" height="%(height_mm)fmm" width="%(width_mm)fmm" version="1.2"> <desc> <referenceFile>unknown.svg</referenceFile> </desc> <desc >Fritzing footprint SVG</desc> """ % dict( w=overall_x, h=overall_y, height_mm=overall_y, width_mm=overall_x) silk_points = [(0, 0), (overall_x, 0), (overall_x, overall_y), (0, overall_y), (0, 0)] silkscreen = (""" <g id="silkscreen"> """) for a, b in zip(silk_points, silk_points[1:]): silkscreen += """<line fill="none" stroke="white" stroke-width="%f" x1="%f" y1="%f" x2="%f" y2="%f"/>""" % ( silk_t, a[0], a[1], b[0], b[1]) silkscreen += "\n" silkscreen += (""" </g> """) copper_start = """ <g id="copper0"> <g id="copper1"> """ copper_pads = [] for x in xrange(pins): copper_pads.append( hole(x=dx + pitch * x, y=dy, pinnr=x, ringwidth=ring, diameter=holesize)) if sparkgap: copper_pads.append( """<path fill="rgb(255, 191, 0)" stroke="none" id="connector%(pin)dpin" d="M%(x)f %(y)f L%(x1)f %(y1)f L%(x2)f %(y2)f""" % (dict(pin=pins, x=dx - holesize / 2.0, y=gaph1, x1=dx + pitch * (pins - 1) + holesize / 2.0, y1=gaph1, x2=dx + pitch * (pins - 1) + holesize / 2.0, y2=gaph2))) for x in reversed(xrange(pins)): a1 = dx + pitch * x - holesize / 2.0 a2 = dx + pitch * x a3 = dx + pitch * x + holesize / 2.0 copper_pads.append(" L%f %f L%f %f L%f %f " % (a3, gaph2, a2, gaph3, a1, gaph2)) copper_pads.append(" Z\" /> ") copper_pads.append( hole(x=dx, y=(gaph1 + gaph2) * 0.5, pinnr=None, ringwidth=sparkgap_lead * 0.4 / 2.0 - pcb.defaultplating, diameter=sparkgap_lead * 0.6)) if pins > 1: copper_pads.append( hole(x=dx + pitch * (pins - 1), y=(gaph1 + gaph2) * 0.5, pinnr=None, ringwidth=sparkgap_lead * 0.4 / 2.0 - pcb.defaultplating, diameter=sparkgap_lead * 0.6)) copper_end = """ </g> </g> """ footer = """ </svg> """ out = header + silkscreen + copper_start + "\n".join( copper_pads) + copper_end + footer return out, False
def gen_pcb(pin_names): overall_x = 55.0 + 2.0 overall_y = 31.0 + 1.0 xx = overall_x / 2.0 yy = overall_y / 2.0 pin_row_dist = 27.94 pin_pitch = 2.54 silk_t = 0.5 header = """<?xml version='1.0' encoding='UTF-8'?> <svg xmlns="http://www.w3.org/2000/svg" baseProfile="tiny" viewBox="0 0 %(w)f %(h)f" height="%(height_mm)fmm" width="%(width_mm)fmm" version="1.2"> <desc> <referenceFile>unknown.svg</referenceFile> </desc> <desc >Fritzing footprint SVG</desc> """ % dict( w=overall_x, h=overall_y, height_mm=overall_y, width_mm=overall_x) silk_points = [(0, 0), (overall_x, 0), (overall_x, overall_y), (0, overall_y), (0, 0)] silkscreen = (""" <g id="silkscreen"> """) for a, b in zip(silk_points, silk_points[1:]): silkscreen += """<line fill="none" stroke="white" stroke-width="%f" x1="%f" y1="%f" x2="%f" y2="%f"/>""" % ( silk_t, a[0], a[1], b[0], b[1]) silkscreen += "\n" silkscreen += (""" </g> """) copper_start = """ <g id="copper0"> <g id="copper1"> """ copper_pads = [] row_width = 19.0 * pin_pitch startx = -row_width / 2.0 starty = -pin_row_dist / 2.0 pinnr = 0 #partgen/fritzing pinnr for col in xrange(20): for row in xrange(2): if row == 1 and not col in (0, 1, 18, 19): continue y = float(row) * pin_row_dist + starty x = startx + 2.54 * col if row == 0: dogpin = 40 - col #pin nr from schematic else: dogpin = 1 + col name = None if row == 1: if dogpin == 1: name = "A1" elif dogpin == 2: name = "C1" elif dogpin == 19: name = "C2" elif dogpin == 20: name = "A2" else: raise Exception() else: name = { 21: 'CAP1N', 22: 'CAP1P', 23: 'PSB', 24: 'VOUT', 25: 'VIN', 26: 'VDD', 27: 'VSS', 28: 'D7', 29: 'D6', 30: 'D5', 31: 'D4', 32: 'D3', 33: 'D2', 34: 'D1', 35: 'D0', 36: 'E', 37: 'R/W', 38: 'CSB', 39: 'RS', 40: 'RESET' }[dogpin] copper_pads.append( hole(x=x + xx, y=y + yy, pinnr=pinnr, ringwidth=0.5, diameter=0.825)) assert name pin_names.append(name) pinnr += 1 copper_end = """ </g> </g> """ footer = """ </svg> """ out = header + silkscreen + copper_start + "\n".join( copper_pads) + copper_end + footer return out, False