From 6c1e4b974b545c50ab2bdf1efa417147f8d4e250 Mon Sep 17 00:00:00 2001 From: Neil Gershenfeld <gersh@cba.mit.edu> Date: Mon, 30 Aug 2021 17:22:59 -0400 Subject: [PATCH] C eval neg z broken --- python/frep-C.py | 30 ++++++++++++++++++++++++------ python/pcb.py | 18 +++++++++++++++--- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/python/frep-C.py b/python/frep-C.py index a54d9c9..9b08be7 100755 --- a/python/frep-C.py +++ b/python/frep-C.py @@ -53,12 +53,16 @@ xmin = frep['xmin'] xmax = frep['xmax'] ymin = frep['ymin'] ymax = frep['ymax'] +zmin = min(frep['layers']) +zmax = max(frep['layers']) units = float(frep['mm_per_unit']) delta = (25.4/dpi)/units fn = frep['function'] fn = fn.replace('math.','') -for z in frep['layers']: - print(z) +layers = str(frep['layers'][0]) +nlayers = len(frep['layers']) +for i in range(1,nlayers): + layers += ','+str(frep['layers'][i]) # # write program # @@ -70,6 +74,7 @@ f""" #include <png.h> using namespace std; int fn(float X,float Y,float Z) {{ + cout << Z << ' ' << ({fn}) << endl; return ({fn}); }} int main(int argc, char** argv) {{ @@ -77,17 +82,30 @@ int main(int argc, char** argv) {{ float xmax = {xmax}; float ymin = {ymin}; float ymax = {ymax}; + float zmin = {zmin}; + float zmax = {zmax}; float units = {units}; int dpi = {dpi}; float delta = (25.4/dpi)/units; int nx = (xmax-xmin)/delta; int ny = (ymax-ymin)/delta; - int *m = (int*) malloc(nx*ny*sizeof(int)); - for (int ix = 0; ix < nx; ++ix) {{ - float x = xmin+ix*delta; + int *m = (int*) calloc(nx*ny,sizeof(int)); + float layers[] = {{{layers}}}; + int intensity; + for (int layer = 0; layer < {nlayers}; ++layer) {{ + float z = layers[layer]; + cout << " z =" << z << endl; + if (zmin == zmax) + intensity = 0xFFFFFF; + else + intensity = ((int) (255*(z-zmin)/(zmax-zmin))) | (255 << 8) | (255 << 16); for (int iy = 0; iy < ny; ++iy) {{ float y = ymin+iy*delta; - m[iy*nx+ix] = fn(x,y,0); + for (int ix = 0; ix < nx; ++ix) {{ + float x = xmin+ix*delta; + m[iy*nx+ix] += intensity & fn(x,y,z); + //cout << fn(x,y,z) << endl; + }} }} }} FILE *file; diff --git a/python/pcb.py b/python/pcb.py index 9e7608e..187e037 100755 --- a/python/pcb.py +++ b/python/pcb.py @@ -22,10 +22,10 @@ #output = "top, labels, and exterior" #output = "top, labels, holes, and exterior" #output = "top, bottom, labels, and exterior" -output = "top, bottom, labels, holes, and exterior" -#output = "top traces" +#output = "top, bottom, labels, holes, and exterior" +output = "top traces" #output = "top traces and exterior" -#output = "bottom traces reversed" +output = "bottom traces reversed" #output = "bottom traces reversed and exterior" #output = "holes" #output = "interior" @@ -7958,6 +7958,16 @@ mask = .004 # solder mask size pcb = PCB(x,y,width,height,mask) +pcb = wire(pcb,w, + point(x,y,zt), + point(x+width,y,zt)) + +pcb = wire(pcb,w, + point(x,y,zb), + point(x,y+height,zb)) + +''' + IC1 = ATtiny44_SOICN('IC1\nt44') pcb = IC1.add(pcb,x+.49,y+.56) @@ -8109,6 +8119,8 @@ pcb = wire(pcb,w, point(V7.x,V6.y,zb), V7.pad[2]) +''' + ############################################################ # select output ############################################################ -- GitLab