chiark / gitweb /
fairphone4-case: change from v1
[reprap-play.git] / fairphone4-case.scad
index 37e4f5f897f5e1bf8d3b7a586b1254e651bc951f..6080e5e70f298aeea97da02d3c886eb53081e6ca 100644 (file)
@@ -149,30 +149,38 @@ button_cutout_depth = 9;
 
 phone_edge_thick = 11.25;
 
-// xxx this is all wrong
-camera_pos_tl = [  6.450, 12.750 ]; // measured from tl corner
-camera_pos_br = [ 22.300, 37.600 ]; // tl/br as seen from back
+camera_pos_tl = [  6.600,  6.750 ]; // from tl corner (as seen from back)
+camera_edge_rad = 9.750;
+camera_sz = 32.920 + .750;
 
 // this is disabled, FP4 doesn't have one
 jack_pos = [ 13.83, 8.485 ];
 jack_dia = 10.64 + .5; // some jack I had lying around
 
 // this led stuff, is irrelevant, we have disabled it as it doesn't have one
-led_pos = [ 13.98, 10.00 ];
+led_pos = []; // [ 13.98, 10.00 ];
 led_aperture = 9;
 led_window_ledge = 0.75; // each side
 
-noisecancelmic_pos = [ 15.08, 7.37 /* xxx? */ ];   // from rhs
+noisecancelmic_pos = [ 15.08 + .720, 4.35 ];   // from rhs, from top edge
 noisecancelmic_dia = 4.00;
 
-// fingerpushhole_dias = []; xxx what was this
-fingerpushhole_dias = [ 15, 18 ];
+mainmic_pos = [ 21.5, 3.45 ];   // from lhs, from top edge
+mainmic_dia = 4.00;
+
+lhshole_pos = [ phone[1]/2 - 0.80, 4.35 ];
+
+// fingerpushhole_dias = [];
+fingerpushhole_dias = [ 15, 18 ]; // this is for testing
 
 lanyard_half_dia = 1.15;
 lanyard_entry_rel_breadth = 2;
 lanyard_channel_len = 8;
-rearspeaker_pos_bl = [ 12.64, 18.72 ];
-rearspeaker_size   = [  3.76,  7.36 ];
+//rearspeaker_pos_bl = [ 12.64, 18.72 ];
+//rearspeaker_size   = [  3.76,  7.36 ];
+
+bottomspeaker_size = [ 12.35, 1.40 ] + [1,1] * 0.5;
+bottomspeaker_pos = [ 18.05, 5.52 ]; // from rhs, from top
 
 microusb_above = 1.64 - 0.25;
 microusb_below = 2.42;
@@ -200,6 +208,7 @@ keeper_gap_z_top = 0.25;
 keeper_gap_z_bot = 0.75;
 keeper_gap_x     = 0.25;
 keeper_gap_x_holes = 0.75;
+keeper_fatter = 0.30;
 
 keeper_side = 0; // 0 = lhs; 1 = rhs
 
@@ -215,8 +224,6 @@ lid_buttoncover_reinf = 0.65;
 foldover_gap = 0.50;
 foldover_lever_gap = 0.50;
 
-// xxx replace hinge screw with nail plan
-
 // properties of the hinge fasteners
 hingescrew_shaft_dia = 2.0 + 0.25; // M2 x 12mm machine screw
 hingescrew_shaft_len = 12;
@@ -251,9 +258,10 @@ hinge_x_gap = 0.125;
 hinge_x_postscrew_gap = 0.75;
 hinge_x_arms_gap = 0.35;
 hinge_r_arms_gap = 0.55;
+hinge_over_nut_plate = 1.0;
 
-// xxx there isn't one of these, speaker is by hinge
-rearspeaker_gap    = [ 2.0, 2.0 ]; // each side
+// there isn't one of these, speaker is by hinge
+// rearspeaker_gap    = [ 2.0, 2.0 ]; // each side
 
 thumbrecess_depth = 1.3;
 thumbrecess_width = 16.5;
@@ -302,9 +310,6 @@ lid_buttoncover_overlap = case_th_lip + keeper_gap_z_top;
 //prop_recess_width = prop_main_th / cos(prop_max_angle) + prop_backfwd_gap;
 
 
-//lid_lip_overlap_width xxx bad name = ;
-//lid_lip_inner_slope = [ 5, 5 ]; // xxx
-
 epp0 = [0,0];
 epp1 = [0, -phone_edge_thick];
 epp2i = epp1; // conflated for FP4
@@ -405,17 +410,17 @@ hex23 = hex27 - (hingescrew_nut_thick*2
                 + hingescrew_fasteners_extra_thick);
 hex26 = hex23 + hingescrew_nut_thick * 2/3;
 
-echo(hex20, hex21, hex22, hex23, hex24);
-//  6, 10.8725, 10.9975, 13.74, 18.75
-module chk(act,exp) {
-  if (abs(act-exp) > 1e-9) echo("WRONG", act, exp);
-  else echo("ok", act);
-}
-chk(hex20, 6);
-chk(hex21, 10.8725);
-chk(hex22, 10.9975);
-chk(hex23, 13.74);
-chk(hex24, 18.75);
+//echo(hex20, hex21, hex22, hex23, hex24);
+////  6, 10.8725, 10.9975, 13.74, 18.75
+//module chk(act,exp) {
+//  if (abs(act-exp) > 1e-9) echo("WRONG", act, exp);
+//  else echo("ok", act);
+//}
+//chk(hex20, 6);
+//chk(hex21, 10.8725);
+//chk(hex22, 10.9975);
+//chk(hex23, 13.74);
+//chk(hex24, 18.75);
 
 lid_fold_clearance_skew =
   (lpp10[1] - hppB[1]) /
@@ -501,7 +506,13 @@ module AdhocMultiprintFrame(phase, z0, zs) {
 
 module KeeperProfile(slant=0){
   use_e = kppe + [0,-1] * slant * keeper_inner_width / keeper_slant_slope;
-  polygon([use_e, kppd, kppc, kppb, kppa, kppf]);
+  polygon([use_e + [+1,-1] * keeper_fatter,
+          kppd  + [ 0,-1] * keeper_fatter,
+          kppc,
+          kppb,
+          kppa,
+          kppf  + [+1, 0] * keeper_fatter
+          ]);
 }
 
 module EdgeProfile(){
@@ -788,11 +799,13 @@ module AroundEdges(fill_zstart, fill_th, fill_downwards=0){
               [phone_width, -phone_height] + [-1,+1] * phone_cnr_rad);
 }
 
-module CaseAperture(pos, dia, $fn) {
+module CaseAperture(pos, dia, $fn, topbottom=0) {
   theta = 180/$fn;
-  translate([ pos[0] + bumper[0],
+  translate([ bumper[0],
              -epp2i[0],
-             -pos[1] ])
+              0 ])
+    rotate([0,0, 90*topbottom])
+    translate([ pos[0] * (topbottom>0 ? -1 : +1), 0, -pos[1] ])
     rotate([-90, theta, 0])
     cylinder(r = dia/2 / cos(theta),
             h = 60);
@@ -823,8 +836,7 @@ module Buttons(){
   Flip_rhs(1) SideButton(64.220, +1, 14.500  ) children(); // power
   Flip_rhs(1) LidButtonishLeg(14, -1) children();
   Flip_rhs(0) LidButtonishLeg(21, -1) children();
-  Flip_rhs(0) LidButtonishLeg(14, +1) children();
-  // xxx need hole for whatever that hole is on lhs
+  Flip_rhs(0) LidButtonishLeg(21, +1) children();
 }
 
 module Struts(x_start, z_min, th){
@@ -853,7 +865,7 @@ module OrdinaryRearAperture(rhs,bot, pos){
     children();
 }
 
-module MicroUSB(){
+module MicroUSBEtc(){
   Flip_bot(1){
     rotate([90,0,0])
       mirror([0,0,1])
@@ -864,15 +876,34 @@ module MicroUSB(){
   }
 }
 
+module OrdinaryBottomEdgeApertures(){
+  Flip_bot(1)
+    CaseAperture(mainmic_pos, mainmic_dia, 8);
+
+  Flip_bot(1) Flip_rhs(1) {
+    linextr_y_xz(-epp2i[0], 60)
+      hull()
+      for (x= [-1,+1]) {
+       translate([ -bottomspeaker_pos[0], -bottomspeaker_pos[1] ] +
+                 [ 0.5 * x * bottomspeaker_size[0] - bottomspeaker_size[1],
+                   0 ])
+         rotate(360/16)
+         circle(r = bottomspeaker_size[1], $fn = 8);
+      }
+  }
+}
+
 module OrdinaryRearApertures(){
   // rear speaker
-  OrdinaryRearAperture(1,1, rearspeaker_pos_bl)
-    rectfromto(-rearspeaker_gap,
-              rearspeaker_size + rearspeaker_gap);
+  //  OrdinaryRearAperture(1,1, rearspeaker_pos_bl)
+  //    rectfromto(-rearspeaker_gap,
+  //          rearspeaker_size + rearspeaker_gap);
+}
 
+module NotInTestFrameRearApertures(){
   // finger hole to remove phone
   if (len(fingerpushhole_dias))
-    OrdinaryRearAperture(1,0, [ fingerpushhole_dias[0]/2 + epp2i[0],
+    OrdinaryRearAperture(0,0, [ fingerpushhole_dias[0] + epp2i[0],
                                phone[1]/2 ])
     scale(fingerpushhole_dias)
     circle(r= 0.5 );
@@ -881,10 +912,19 @@ module OrdinaryRearApertures(){
 module RearCameraAperture(){
   Flip_rhs(1)
     mirror([0, 0, 1])
+    translate([0,0,0])
+    hull() // there is some kind of bug if hull() is done in 2D here!
     linear_extrude(height = 20)
     mirror([0, 1, 0])
     translate(bumper)
-    rectfromto(camera_pos_tl, camera_pos_br);
+    translate(camera_pos_tl)
+    for (xy = [ [0,0], [0,1], [1,0] ]) {
+      translate(
+         camera_edge_rad * [1,1] +
+         xy * (camera_sz - camera_edge_rad * 2)
+               )
+       circle(r = camera_edge_rad);
+    }
 }
 
 module HingeLidProfile(){
@@ -921,7 +961,7 @@ module HingeLeverInnerProfile(){
   for (s = [-1,+1]) {
     c = s > 0 ? hppT : hppB;
     translate(c)
-      mirror([0,0,s>0])
+      mirror([0,0, s>0 ? 1 : 0])
       rotate(s<0 ? -40 : 0)
       hull()
       for (x=[-20,20])
@@ -1161,11 +1201,15 @@ module Case(){ ////toplevel
       // CaseAperture(jack_pos, jack_dia, 8);
       Flip_rhs(1)
        CaseAperture(noisecancelmic_pos, noisecancelmic_dia, 8);
+      CaseAperture(lhshole_pos, noisecancelmic_dia, 8, 1);
     }
 
+    OrdinaryBottomEdgeApertures();
+
     OrdinaryRearApertures();
+    NotInTestFrameRearApertures();
 
-    MicroUSB();
+    MicroUSBEtc();
 
     // gaps for the lid's hinge arms
     HingePortion(hex20 - hinge_x_arms_gap,
@@ -1305,9 +1349,31 @@ module HingeLever(){ ////toplevel
     // bores for the screws
     HingeScrews();
 
-    // space for the charging cable
-    MicroUSB();
-    Flip_hinge() MicroUSB();
+    // space for the charging cable and speaker and micc apertures
+    hull() {
+      for (x = [-1,+1]) {
+       multmatrix([[ 1,0,
+
+                    x
+                    * ( (hex24 + hinge_over_nut_plate) -
+                        (phone_width/2 - microusb_width/2)
+                       )
+                    / ( (epp0[1] - microusb_above)
+                        -
+                        (hppB[1] - hp_r2) ),
+
+                    x * (epp0[1] - microusb_above)
+
+                     ],
+                   [ 0,1,0, 0 ],
+                   [ 0,0,1, 0 ]]) {
+         union(){
+           MicroUSBEtc();
+           Flip_hinge() MicroUSBEtc();
+         }
+       }
+      }
+    }
   }
 }
 
@@ -1454,11 +1520,17 @@ module TestSelectFrame(){
       linear_extrude(height=200)
       rectfromto(include,  inside_br - include);
   }
+
+  for (i= [1,2]) {
+    translate([ 0, -phone[1] * i/3, 0 ])
+      cube(center=true, [1000, 4, 100]);
+  }
 }
 
 module TestSelectLidFrame(){
   TestSelectFrame();
-  translate([led_pos[0], -led_pos[1], -50])
+  if (len(led_pos))
+    translate([led_pos[0], -led_pos[1], -50])
     cylinder(r= nla_r2+3, h=100);
 }
 
@@ -1634,13 +1706,13 @@ module DemoLanyardCutout(){ ////toplevel
 }
 
 module DemoHingedFrame(){ ///toplevel
-  color("red") TestFrameCase();
+  color("red") render() TestFrameCase();
   translate([0,0, -2*hp_k])
-  color("blue") intersection(){ Lid(); TestSelectLidFrame(); }
+  color("blue") render() intersection(){ Lid(); TestSelectLidFrame(); }
 
   Flip_hinge(){
-    color("orange") HingeLever();
-    color("black") HingeScrews();
+    color("orange") render() HingeLever();
+    color("black") render() HingeScrews();
   }
 }