-module base() {
- translate([0, 0, base_h/2]) {
- hull() {
- cube([batt_len + 2*wall + 2*cable_sep, batt_diam + 2*wall, base_h], center=true);
- // under the PCB
- translate([0, -batt_diam/2-wall-pcb_thick/2-wall/2, 0])
- cube([batt_len + 2*wall, pcb_thick + wall + eps, base_h], center=true);
- // battery-side extension
- translate([0, batt_diam/2 + wall + base_batt_extend, 0])
- cube([batt_len + 2*wall, eps, base_h], center=true);
- };
- };
-}
-module base_protrusions() {
- // pcb-side side protrusion
- translate([-pcbside_protrusion_len/2, -batt_diam/2-2*wall-pcb_thick, base_h-pcbside_protrusion_diam/2])
- rotate([0, 90, 0])
- cylinder(r = pcbside_protrusion_diam/2, h = pcbside_protrusion_len, $fn = 6);
-
- // battery-side side protrusion
- translate([-battside_protrusion_len/2, batt_diam/2+wall+base_batt_extend, base_h-battside_protrusion_diam/2])
- rotate([0, 90, 0])
- cylinder(r = battside_protrusion_diam/2, h = battside_protrusion_len, $fn = 6);
-};
-
-module pcb_clips() {
- // rear part of the PCB holder (behind S1)
- translate([pcb_clip_off, -batt_diam/2-wall-pcb_thick+eps, 0])
- cube([pcb_clip_w, pcb_thick+wall, pcb_width + wall + base_h - pcb_groove]);
- // side part of the PCB holder (near the battery wires)
- translate([-pcb_len/2-wall, -batt_diam/2-pcb_thick-2*wall, 0])
- cube([pcb_groove+wall, pcb_thick+2*wall+eps, pcb_width + wall + base_h - pcb_groove]);
-};
-
-module batt_clips() {
- difference() {
- union() {
- // frot + rear part of the battery clip
- for (r = [0, 180]) {
- rotate([0, 0, r])
- translate([batt_len/2+wall/2, 0, batt_clip_h/2+wall/2])
- hull() {
- cube([wall, batt_diam + 2*wall, batt_clip_h + wall], center=true);
- translate([-15/2, 0, -batt_clip_h/2])
- cube([15, batt_diam+2*wall, wall], center=true);
- };
- }
- // middle clips
- translate([pcb_clip_off+pcb_clip_w/2, 0, batt_clip_h/2+wall/2])
- hull() {
- cube([pcb_clip_w, batt_diam + 2*wall, batt_clip_h + wall], center=true);
- translate([0, 0, -batt_clip_h/2])
- cube([2*pcb_clip_w, batt_diam+2*wall, wall], center=true);
- };
- // pcb holder - pcb side only
- translate([-pcb_len/2-wall, -batt_diam/2-wall, 0])
- hull() {
- cube([pcb_groove + wall, batt_diam/2 + wall, base_h + pcb_width + wall - pcb_groove]);
- translate([-3*(pcb_groove+wall), 0, 0])
- cube([4*(pcb_groove+wall), batt_diam/2 + wall, base_h]);
- };
- }
- // top part rounded