// The cutouts to allow external components (such as buttons and connectors) to be mounted on the box

// 4056-based li-ion charging module
module usb_cutout() {
    hull() {
        translate([0, -3, 0]) cylinder(h=11, d=8);
        translate([0, 3, 0]) cylinder(h=11, d=8);
        translate([0, 0, 15]) cube([3, 8.9, 2], true);
    }
}

// 19x13mm rocker switch with 21x15mm flange
module switch_cutout() {
    cube([19.2, 13.2, 50], true);
}

module speaker_grille() {
    linear_extrude(height = 10, center = true) {
        import("speaker_grille.svg");
    }
}

module keycap() {
    cylinder(h = 10, d = 20, $fn = 128);
}

module character_retainer_cutout() {
    $fn = 128;
    screw_hole_diameter = 3;
    // Ring cutout
    cylinder(d = 60, h = 5);
    // Led diffuser cutout
    translate([-28, -15, 0]) cylinder(d = 15, h = 5);
    // Led housing cutout
    translate([-28, -15, 3]) cylinder(d = 5.2, h = 15);
    
    
    // Screw holes
    translate([0, -25, 10]) cylinder(d = screw_hole_diameter, h = 15, center = true);
    rotate([0, 0, 120]) translate([0, -25, 10]) cylinder(d = screw_hole_diameter, h = 15, center = true);
    rotate([0, 0, 240]) translate([0, -25, 10]) cylinder(d = screw_hole_diameter, h = 15, center = true);
}

module sdcard_access_port_cutout() {
    $fn = 32;
    union() {
        translate([-13, -8.5, 0]) cube([26, 17, 8]);
        // Flange
        hull() {
            translate([15, 0, 0]) cylinder(d = 21, h = 2);
            translate([-15, 0, 0]) cylinder(d = 21, h = 2);
        }
        // Screw holes
        translate([16, 0, -1]) cylinder(d = 2, h = 10);
        translate([-16, 0, -1]) cylinder(d = 2, h = 10);
    }
}

//usb_cutout();
//speaker_grille();
character_retainer_cutout();
//sdcard_access_port_cutout();