chiark / gitweb /
fairphone-case: introduce SideButton y_ref_sign etc. (nfc)
[reprap-play.git] / fairphone-case.scad
index 761c2509fe55920eec9dd6b8b41560b5135c3834..7735c9faa1cb863cd5c6789a21389c6430ed4633 100644 (file)
@@ -57,8 +57,8 @@ strut_min_at_end = 1.5;
 phone_height = (phone + bumper*2)[0];
 phone_width =  (phone + bumper*2)[1];
 
-echo(camera_pos_tl + bumper,
-     camera_pos_br + bumper);
+//echo(camera_pos_tl + bumper,
+//     camera_pos_br + bumper);
 
 // ----- could be changed -----
 lid_buttoncover_gap = lid_gap_x;
@@ -258,14 +258,22 @@ module AroundEdges(fill_zstart, fill_th, fill_downwards=0){
               [phone_width, -phone_height] + [-1,+1] * phone_cnr_rad);
 }
 
-module SideButton(y,l){
+module SideButton(y, y_ref_sign, l){
+  // y_ref_sign:
+  //   +1  measured from top    of actual phone to top    of button
+  //   -1  measured from bottom of actual phone to bottom of button
+  //    0  y is centre of button in coordinate system
   $button_l= l;
-  translate([0, -y, 0])
+  eff_y = y_ref_sign > 0 ?         -bumper [1] -y -l/2 :
+         y_ref_sign < 0 ? (-phone +bumper)[1] +y +l/2 :
+         -y;
+  echo(eff_y);
+  translate([0, eff_y, 0])
     children();
 }
 
 module Buttons(){
-  CaseBase_rhsflip([1]) SideButton(19.650, 8.9) children(); // power
+  CaseBase_rhsflip([1]) SideButton(14.950, +1, 8.9) children(); // power
 }
 
 module Struts(x_start, z_min, th){