############################################################################### # Utilities for generating landpatterns for pcblander program # Copyright (C) 2007 Stephen Morss # # This program is free software; you can redistribute it and/or modify # it under the terms of version 2 of the GNU General Public License as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ############################################################################### teaser_declare_revision("0.2.0") ifdef("landutils_dot_inc_deFined", {exit()}, \ {define("landutils_dot_inc_deFined")}) include("teaser_utils.inc") # handy macros # creates a numeric set of pins from a start, stop(inclusive), and step scriptstart("gen_padset") loadparams("start", "stop", "step") mydefine("return", bracket(start)) while({stop - start}, \ {return = concat(return, bracket(start = start + step))}\ ) return scriptend() # Makes a column of pads scriptstart("mycolumn") loadparams("x", "y", "pins") array(x,y,{},pins) scriptend() # Makes a row of pads scriptstart("myrow") loadparams("x", "y", "pins") array(x,y,pins,{}) scriptend() # Writes out a part. Prints out a message to say if successful or failed. scriptstart("mywriteland") loadparams("partname") ifeq(writeland(partname), "", \ {print("Error: write of ", partname, " failed.")},\ {print("Generated ", partname)}\ ) scriptend() # Writes out a part and it's source. Prints out a message to say if # successful or failed. scriptstart("mywriteland_and_source") loadparams("partname") ifeq(writeland_and_source(partname), "", \ {print("Error: write of ", partname, " failed.")},\ {print("Generated ", partname)}\ ) scriptend() # draws a silk "1" centered at (x,y) scriptstart("silk1") loadparams("x","y","height", "silk_thickness") origin_x = origin_x + x origin_y = origin_y + y - height/2 # draw the 1 silksegment(0, 0, 0, height) # main stem silksegment(-1/4 * height, 0, 1/4 * height, 0) # base silksegment(0, height, -1/4 * height, 3/4 * height) # top scriptend() # draws a silk "+" centered at (x,y) scriptstart("silkplus") loadparams("x","y","height", "silk_thickness") origin_x = origin_x + x origin_y = origin_y + y # draw the + silksegment(0, -height/2, 0, height/2) # vertical silksegment(-height/2, 0, height/2, 0) # horizontal scriptend() # draws a silk keepout box, if KEEPOUTS is defined scriptstart("keepout_box") loadparams("x","y","width","height") silk_thickness = 1 mil ifdef("KEEPOUTS", {silkbox(x, y, width, height)}, {}) scriptend() # draws a silk keepout circle, if KEEPOUTS is defined scriptstart("keepout_circle") loadparams("x","y","diameter") silk_thickness = 1 mil ifdef("KEEPOUTS", {silkcircle(x, y, diameter/2)}, {}) scriptend() # draws a silkbox, but only upper left and lower right corners # have silk brackets. scriptstart("silkbox_brackets") loadparams("x","y","width","height") # upper left silksegment(-width/2, height/2, (-1 + 0.1) * width/2, height/2) silksegment(-width/2, height/2, -width/2, (1 - 0.1) * height/2) # lower right silksegment(width/2, -height/2, (1 - 0.1) * width/2, -height/2) silksegment(width/2, -height/2, width/2, (-1 + 0.1) * height/2) scriptend() # Makes a row of pads at a given position with the first set of pads # as set by pad_shape and the second set of pads different (square or round). # Good for making a row of pads with pin one a different shape. scriptstart("twoshapesrow") loadparams("x","y","pads1", "pads2") mydefine("omit", pad_omit) # save - will overwrite pad_omit ifeq(omit, "", { omit = {} }, {}) # put into standard form # make first pads pad_omit = concat(omit, pads2) array(x,y,concat(pads1,pads2),) # make second pads pad_omit = concat(omit, pads1) # toggle pad shape ifeq(pad_shape, "circular", \ {pad_shape = "rectangular"}, {pad_shape = "circular"}) array(x,y,concat(pads1,pads2),) scriptend() # Makes a column of pads at a given position with the first set of pads # as set by pad_shape and the second set of pads different (square or round). # Good for making a column of pads with pin one a different shape. scriptstart("twoshapescolumn") loadparams("x","y","pads1", "pads2") mydefine("omit", pad_omit) # save - will overwrite pad_omit ifeq(omit, "", { omit = {} }, {}) # put into standard form # make first pads pad_omit = concat(omit, pads2) array(x,y,,concat(pads1,pads2)) # make second pads pad_omit = concat(omit, pads1) # toggle pad shape ifeq(pad_shape, "circular", \ {pad_shape = "rectangular"}, {pad_shape = "circular"}) array(x,y,,concat(pads1,pads2)) scriptend() # move the current origin a given amount scriptstart("move_origin") loadparams("x","y") origin_x = origin_x + x origin_y = origin_y + y export("origin_x") # pass on to the outer environment export("origin_y") scriptend() "done: landutils.inc"