use <../../WebWeaver/scad/Util.scad>;



$fs = 0.5;
$fa = 1.0;



pcb_w      = 40.5;
pcb_h      = 67.5;
pcb_r      =    5;  // edge radius
pcb_off    =  0.4;
pcb_t      =    5;  // thickness including LED and inductor
pcb_sc_off =    5;  // offset of screw holes from edge
pcb_conn_w =   20;
pcb_conn_h =    3;


module pcb(w=pcb_w, h=pcb_h, r=pcb_r, off=pcb_off) {

  _w = w + 2*off;
  _h = h + 2*off;
  _r = r +   off;

  hull() {

    // function of WebWeaver
    roundRect(_w, _h, _r, true, true);
  
    translate([0, -_h/2 +1 -pcb_conn_h, 0]) square([pcb_conn_w, pcb_conn_h + 1], center=true);
  
  }
}


module pcbBox(wi, hi, ri, _str) {

  linear_extrude(hi) pcb();
}


module body(wi, hi, ri, _str) {
  difference() {
    pcbBox(wi, hi, ri, _str);
    translate([0, 0, _str]) pcbBox(wi, hi, ri, _str);
  }
}


module PCBMockUp(w=pcb_w, h=pcb_h, r=pcb_r, off_xy=pcb_sc_off) {
  
  w2 = w / 2;
  h2 = h / 2;
  
  color([0.1, 0.1, 0.1], 1.0) difference() {
    roundRect(w, h, r, true, true);
    
    for (tx=[-w2 + off_xy, w2 - off_xy], ty=[-h2 + off_xy, h2 - off_xy]) translate([tx, ty, 0]) circle(d=3.2);
  }
}



// body(pcb_w, pcb_h, pcb_r, pcb_off);

PCBMockUp();