Skip to content
Snippets Groups Projects
pcb.py 289 KiB
Newer Older
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed

Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
pcb = wire(pcb,w,
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   V2.pad[1],
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   J1.pad[2])
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed

Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
V3 = via(zb,zt,rv,rp,'V3')
pcb = V3.add(pcb,J1.pad[6].x-.075,J1.pad[6].y)
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed

pcb = wire(pcb,w,
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   V3.pad[1],
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   J1.pad[6])

pcb = wire(pcb,w,
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   V3.pad[2],
   V1.pad[2])
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed

J2 = header_FTDI('J2 FTDI')
pcb = J2.add(pcb,x+width-.22,IC1.y-.0,angle=0)
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed

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),
   point(IC1.pad[13].x+.105,J2.pad[4].y),
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   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),
   point(IC1.pad[12].x+.07,J2.pad[5].y+.04),
   point(IC1.pad[12].x+.11,J2.pad[5].y),
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   J2.pad[5])

Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
V4 = via(zb,zt,rv,rp,'V4')
pcb = V4.add(pcb,J2.pad[3].x+.1,J2.pad[3].y)
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed

pcb = wire(pcb,w,
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   V4.pad[1],
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   J2.pad[3])

pcb = wire(pcb,w,
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   V2.pad[2],
   V4.pad[2])
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed

Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
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,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),
   point(XTAL1.x+.12,XTAL1.pad[1].y),
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   XTAL1.pad[1])

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

Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
V5 = via(zb,zt,rv,rp,'V5')
pcb = V5.add(pcb,XTAL1.x-.12,XTAL1.y)
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed

pcb = wire(pcb,w,
   XTAL1.pad[2],
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   V5.pad[1])
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed

pcb = wire(pcb,w,
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   V3.pad[2],
   V5.pad[2])
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed

Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
R1 = R_1206('R1\n10k');
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
pcb = R1.add(pcb,IC1.pad[1].x,IC1.pad[1].y+.1)
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed

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

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

Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
V6 = via(zb,zt,rv,rp,'V6')
pcb = V6.add(pcb,R1.pad[1].x-.08,R1.y)
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed

pcb = wire(pcb,w,
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   V6.pad[1],
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   R1.pad[1])

pcb = wire(pcb,w,
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   V4.pad[2],
   point(V4.x,V6.y,zb),
   V6.pad[2])
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed

C1 = C_1206('C1\n1uF');
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
pcb = C1.add(pcb,IC1.pad[14].x,R1.y)
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed

pcb = wire(pcb,w,
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   J2.pad[1],
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   C1.pad[2])

pcb = wire(pcb,w,
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   C1.pad[2],
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   V1.pad[1])
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed

Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
V7 = via(zb,zt,rv,rp,'V7')
pcb = V7.add(pcb,C1.pad[1].x-.025,C1.y-.06)
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed

pcb = wire(pcb,w,
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   V7.pad[1],
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   C1.pad[1])

pcb = wire(pcb,w,
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   V6.pad[2],
   point(V7.x,V6.y,zb),
   V7.pad[2])
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed

Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
############################################################
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
# select output
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
############################################################
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed

outputs = {}
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
if (output == "top, labels, and exterior"):
   outputs["function"] = add(add(color(Tan,pcb.board),pcb.labels),
      color(White,pcb.exterior))
   outputs["layers"] = [zt]
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
elif (output == "top, labels, holes, and exterior"):
   outputs["function"] = add(add(color(Tan,pcb.board),pcb.labels),
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
      add(color(White,pcb.exterior),color(Blue,pcb.holes)))
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   outputs["layers"] = [zt]
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
elif (output == "top, bottom, labels, and exterior"):
   outputs["function"] = add(add(color(Tan,pcb.board),pcb.labels),
      color(White,pcb.exterior))
   outputs["layers"] = [zb,zt]
elif (output == "top, bottom, labels, holes, and exterior"):
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   outputs["function"] = add(add(color(Tan,pcb.board),pcb.labels),
      add(color(White,pcb.exterior),color(Blue,pcb.holes)))
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   outputs["layers"] = [zb,zt]
elif (output == "top traces"):
   outputs["function"] = color(White,pcb.board)
   outputs["layers"] = [zt]
elif (output == "top traces and exterior"):
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   outputs["function"] = color(White,add(pcb.board,pcb.exterior))
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   outputs["layers"] = [zt]
elif (output == "bottom traces reversed"):
   outputs["function"] = color(White,
      reflect_x(pcb.board,2*x+width))
   outputs["layers"] = [zb]
elif (output == "bottom traces reversed and exterior"):
   outputs["function"] = color(White,
      reflect_x(add(pcb.board,pcb.exterior),2*x+width))
   outputs["layers"] = [zb]
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
elif (output == "interior"):
   outputs["function"] = color(White,pcb.interior)
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   outputs["layers"] = [zt]
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
elif (output == "exterior"):
   outputs["function"] = color(White,pcb.exterior)
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   outputs["layers"] = [zt]
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
elif (output == "holes"):
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   outputs["function"] = color(White,
      subtract(add(pcb.exterior,pcb.interior),pcb.holes))
   outputs["layers"] = [zb]
elif (output == "holes and interior"):
   outputs["function"] = color(White,
      subtract(pcb.interior,pcb.holes))
   outputs["layers"] = [zb]
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
elif (output == "solder mask"):
   outputs["function"] = color(White,pcb.mask)
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   outputs["layers"] = [zt]
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
else:
   print("oops -- don't recognize output")

Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
############################################################
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
# set limits and parameters
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
############################################################
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed

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["mm_per_unit"] = 25.4 # use inch units
outputs["type"] = "RGB" # use RGB color

Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
############################################################
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
# send output
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
############################################################
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed

json.dump(outputs,sys.stdout)