+ // space under the wire holes for battery contacts
+ translate([-batt_len/2-2*wall-cable_sep-eps, 0, 0])
+ difference() {
+ rotate([0, 90, 0])
+ cylinder(r = batt_diam/2-wall, h = batt_len + 4*wall + 2*cable_sep + 2*eps);
+ translate([-infty/2, -infty/2, -batt_end_h])
+ cube(infty);
+ };
+ // space above the wire holes for battery contacts
+ translate([-batt_len/2-2*wall-cable_sep-eps, -batt_diam/2, batt_end_h])
+ cube([batt_len + 4*wall + 2*cable_sep + 2*eps,
+ batt_diam,
+ batt_end_h]);
+ // wire holes for battery contacts
+ for (x = [-1, 1])
+ for (y = [-1, 1])
+ translate([-batt_len/2-wall-eps, x*wire_sep/2, y*wire_sep/2])
+ rotate([0, 90, 0])
+ cylinder(r = wire_thick/2, h = batt_len + 2*wall + 2*eps, $fn=6);
+ // wire hole from PCB to battery contacts
+ // translate([-batt_len/2-wall-eps, 0, -batt_diam/2-pcb_comp_h + wire_thick/2])
+ rotate([40, 0, 0])
+ translate([-batt_len/2-wall-eps, 0, -batt_diam/2 - wall/2 - wire_thick/2])
+ rotate([0, 90, 0])
+ cylinder(r = wire_thick/2, h = batt_len + 2*wall + 2*eps, $fn=6);
+ // hole behind the battery contacts
+ for(x=[1, -1])
+ scale([x, 1, 1]) translate([batt_len/2+wall+cable_sep, 0, 0]) hull() {
+ translate([0, -batt_diam/2, 0])
+ cube([wall + eps, batt_diam, infty]);
+ rotate([0, 90, 0])
+ cylinder(r = batt_diam/2, h = wall+eps);
+ translate([0, batt_diam/2 - pcb_width,
+ -batt_diam/2-pcb_comp_h-pcb_thick])
+ cube([wall + eps, pcb_width, eps]);
+ translate([0, batt_diam/2 - pcb_width + 0.5*wall,
+ -batt_diam/2-pcb_comp_h-pcb_comp_h2-pcb_thick])
+ cube([wall + eps, pcb_width-0.5*wall, eps]);
+ };
+ // inner hole behind the battery contacts
+ for(x=[1, -1])
+ scale([x, 1, 1]) translate([batt_len/2+wall, 0, 0]) hull() {
+ translate([0, -batt_diam/2+wall, 0])
+ cube([cable_sep + eps, batt_diam-2*wall, infty]);
+ rotate([0, 90, 0])
+ cylinder(r = batt_diam/2-wall, h = cable_sep+eps);
+ };
+ // cable lead to battery contacts
+ for (x=[1, -1]) scale([x, 1, 1])
+ rotate([-140, 0, 0])
+ translate([batt_len/2-eps, -wire_thick/2, batt_diam/2-2.7])
+ cube([wall+cable_sep+2*eps, wire_thick, 5.4]);