Skip to content
Snippets Groups Projects
pcb.py 183 KiB
Newer Older
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
J1 = header_ISP('J1\nISP')
pcb = J1.add(pcb,IC1.x+.05,IC1.pad[7].y-.22,z,angle=90)

pcb = wire(pcb,w,
   IC1.pad[8],
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   point(J1.pad[1].x,IC1.pad[8].y,z),
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   J1.pad[1])

pcb = wire(pcb,w,
   IC1.pad[9],
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   point(J1.pad[3].x,IC1.pad[9].y,z),
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   J1.pad[3])
   
pcb = wire(pcb,w,
   IC1.pad[7],
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   point(IC1.pad[7].x,J1.y+.02,z),
   point(IC1.pad[7].x+.04,J1.y-.02,z),
   point(J1.pad[4].x,J1.y-.02,z),
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   J1.pad[4])
   
pcb = wire(pcb,w,
   IC1.pad[4],
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   point(J1.pad[5].x,IC1.pad[4].y,z),
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   J1.pad[5])

pcb = wire(pcb,w,
   IC1.pad[14],
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   point(J1.x-.01,IC1.pad[14].y,z),
   point(J1.x-.05,IC1.pad[14].y-.04,z),
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   point(J1.x-.05,J1.y+.02,z),
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   point(J1.x+.05,J1.y+.02,z),
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   point(J1.x+.05,J1.pad[2].y-.08,z),
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   point(J1.pad[6].x,J1.pad[2].y-.08,z),
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   J1.pad[6])

J2 = header_FTDI('J2 FTDI')
pcb = J2.add(pcb,x+width-.22,IC1.y-.0,z,angle=0)

pcb = wire(pcb,w,
   J1.pad[2],
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   point(J2.x,J1.pad[2].y,z),
   point(J2.x+.08,J1.pad[2].y+.08,z),
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   point(J2.x+.08,J2.pad[3].y,z),
   J2.pad[3])

pcb = wire(pcb,w,
   IC1.pad[13],
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   point(IC1.pad[13].x+.105,IC1.pad[13].y,z),
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   point(IC1.pad[13].x+.105,J2.pad[4].y,z),
   J2.pad[4])

pcb = wire(pcb,w,
   IC1.pad[12],
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   point(IC1.pad[12].x+.07,IC1.pad[12].y,z),
   point(IC1.pad[12].x+.07,J2.pad[5].y+.04,z),
   point(IC1.pad[12].x+.11,J2.pad[5].y,z),
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   J2.pad[5])

XTAL1 = XTAL_EFOBM('XTAL1\n20 MHz')
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
pcb = XTAL1.add(pcb,IC1.pad[4].x-.2,IC1.pad[13].y+.003,z,angle=-90)
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed

pcb = wire(pcb,w,
   IC1.pad[2],
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   point(XTAL1.x+.12,IC1.pad[2].y,z),
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   point(XTAL1.x+.12,XTAL1.pad[1].y,z),
   XTAL1.pad[1])

pcb = wire(pcb,w,
   J1.pad[6],
   point(J1.pad[6].x,J1.pad[6].y-.08,z),
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   point(XTAL1.x-.04,J1.pad[6].y-.08,z),
   point(XTAL1.x-.12,J1.pad[6].y,z),
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   point(XTAL1.x-.12,XTAL1.pad[2].y,z),
   XTAL1.pad[2])

pcb = wire(pcb,w,
   IC1.pad[3],
   XTAL1.pad[3])

R1 = R_1206('R1\n10k');
pcb = R1.add(pcb,IC1.pad[1].x,IC1.pad[1].y+.1,z)

pcb = wire(pcb,w,
   R1.pad[1],
   IC1.pad[1])

pcb = wire(pcb,w,
   J2.pad[3],
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   point(J2.pad[3].x+.08,J2.pad[3].y,z),
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   point(J2.pad[3].x+.08,R1.y+.06,z),
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   point(R1.pad[1].x,R1.y+.06,z),
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   R1.pad[1])

pcb = wire(pcb,w,
   R1.pad[2],
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   point(J1.pad[5].x,R1.y,z),
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   J1.pad[5])

C1 = C_1206('C1\n1uF');
pcb = C1.add(pcb,IC1.pad[14].x,R1.y,z)

pcb = wire(pcb,w,
   IC1.pad[14],
   C1.pad[2])

pcb = wire(pcb,w,
   C1.pad[1],
   point(C1.pad[1].x,C1.y+.06,z))

pcb = wire(pcb,w,
   J2.pad[1],
   C1.pad[2])

#
# select output
#

outputs = {}
if (output == "traces, labels, and exterior"):
   outputs["function"] = add(add(color(Tan,pcb.board),pcb.labels),color(White,pcb.exterior))
elif (output == "traces and exterior"):
   outputs["function"] = color(White,add(pcb.board,pcb.exterior))
elif (output == "interior"):
   outputs["function"] = color(White,pcb.interior)
elif (output == "exterior"):
   outputs["function"] = color(White,pcb.exterior)
elif(output == "traces"):
   outputs["function"] = color(White,pcb.board)
elif (output == "holes"):
   z = z-z
   outputs["function"] = color(White,add(pcb.exterior,subtract(pcb.interior,pcb.board)))
elif (output == "solder mask"):
   outputs["function"] = color(White,pcb.mask)
else:
   print("oops -- don't recognize output")

#
# set limits and parameters
#

border = 0.05
outputs["xmin"] = x-border # min x to render
outputs["xmax"] = x+width+border # max x to render
outputs["ymin"] = y-border # min y to render
outputs["ymax"] = y+height+border # max y to render
outputs["zmin"] = z # min z to zender
outputs["zmax"] = z # max z to zender
outputs["mm_per_unit"] = 25.4 # use inch units
outputs["type"] = "RGB" # use RGB color

#
# send output
#

json.dump(outputs,sys.stdout)