+module CaseAperture(pos, dia, $fn) {
+ theta = 180/$fn;
+ translate([ pos[0] + bumper[0],
+ -epp2i[0],
+ -pos[1] ])
+ rotate([-90, theta, 0])
+ cylinder(r = dia/2 / cos(theta),
+ h = 60);
+}
+
+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;
+ 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 LidButtonishLeg(y, y_ref_sign, l=buttonishleg_default_l_is_fudge) {
+ $button_leg_only = true;
+ SideButton(y, y_ref_sign, l) children();
+}
+
+module Buttons(){
+ Flip_rhs(1) SideButton(15.580, +1, 8.9) children(); // power
+ Flip_rhs(1) SideButton(48.700, -1, 8.920) children(); // camera
+ Flip_rhs(0) SideButton(30.800, +1, 21.96) children(); // volume
+ Flip_rhs( ) LidButtonishLeg(20, -1) children();
+// Flip_rhs(0) LidButtonishLeg(20, +1, 20) children();
+}
+
+module Struts(x_start, z_min, th){
+ // if th is negative, starts at z_min and works towards -ve z
+ // and object should then be printed other way up
+ for (i= [1 : 1 : case_struts_count]) {
+ translate([0,
+ 0,
+ z_min])
+ mirror([0,0, th<0 ? 1 : 0])
+ translate([0,
+ -phone_height * i / (case_struts_count+1),
+ case_struts_solid_below])
+ linear_extrude(height= abs(th)
+ -(case_struts_solid_below+case_struts_solid_above))
+ rectfromto([ x_start, -0.5 * case_struts_width ],
+ [ phone_width - x_start, +0.5 * case_struts_width ]);
+ }
+}
+
+module OrdinaryRearAperture(rhs,bot, pos){
+ Flip_rhs(rhs) Flip_bot(bot)
+ linextr(-20, 20)
+ mirror([0,1])
+ translate(pos + bumper)
+ children();
+}
+
+module OrdinaryRearApertures(){
+ // rear speaker
+ OrdinaryRearAperture(1,1, rearspeaker_pos_bl)
+ rectfromto(-rearspeaker_gap,
+ rearspeaker_size + rearspeaker_gap);
+
+ // finger hole to remove phone
+ OrdinaryRearAperture(1,0, [ fingerpushhole_dias[0]/2 + epp2i[0],
+ phone[1]/2 ])
+ scale(fingerpushhole_dias)
+ circle(r= 0.5 );
+}
+
+module RearCameraAperture(){
+ Flip_rhs(1)
+ mirror([0, 0, 1])
+ linear_extrude(height = 20)
+ mirror([0, 1, 0])
+ translate(bumper)
+ rectfromto(camera_pos_tl, camera_pos_br);
+}
+
+module HingeLidProfile(){
+ hull(){
+ circleat(hppT, hp_r1);
+ circleat(lpp12, lp_r12);
+ polygon([lpp10,
+ lpp13 + [2,0],
+ lpp12,
+ hppT]);
+ }
+}
+
+module HingeBaseProfile(){
+ difference(){
+ hull(){
+ circleat(hppB, hp_r1);
+ circleat(epp2o, case_th_bottom);
+ circleat(hppB + [10,0], hp_r1);
+ }
+ polygon([epp5, epp1, epp2i, epp3, bppL]);
+ }
+}
+
+module HingeLeverOuterProfile(){
+ hull(){
+ circleat(hppT, hp_r2);
+ circleat(hppB, hp_r2);
+ }
+}
+
+module HingeLeverInnerProfile(){
+ for (c = [hppT, hppB]) {
+ hull()
+ for (x=[0,20])
+ translate([x,0])
+ circleat(c, hp_rn);
+ circleat(hppB, hp_rn);
+ }
+}
+
+module HingePortion(x0,x1){
+ Flip_rhs() Flip_bot(1)
+ translate([x0,0,0])
+ mirror([1,0,0])
+ rotate([90,0,-90])
+ linear_extrude(height=x1-x0)
+ children(0);
+}
+