// The support the character is inserted in when playing a story.
// Mounted on the shell with two screws.
// To be printed in clear plastic because it receives the light from the RGB led.
// Indents at height 4

module retainer_spring() {
    rotate_extrude(convexity = 10, angle = 90, $fn = 128)
        translate([22, 0, 0])
            square([2, 10]);
}

module character_retainer_ring() {
    $fn = 128;
    screw_hole_diameter = 2;
    difference() {
        // Body
        union() {
            // Main body
            cylinder(d = 59.5, h = 6);
            // Secondary circle (status LED diffuser)
            translate([28, -15, 0]) cylinder(d = 14.5, h = 6);
        }
        cylinder(d = 40.5, h = 20, center = true);
        // Screw holes
        translate([0, -25, 0]) cylinder(d = screw_hole_diameter, h = 6, center = true);
        rotate([0, 0, 120]) translate([0, -25, 0]) cylinder(d = screw_hole_diameter, h = 6, center = true);
        rotate([0, 0, 240]) translate([0, -25, 0]) cylinder(d = screw_hole_diameter, h = 6, center = true);
    
        // Retainer springs
        rotate([0, 0, 45]) retainer_spring();
        rotate([0, 0, 165]) retainer_spring();
        rotate([0, 0, 285]) retainer_spring();
        
        // Status LED housing
        translate([28, -15, -0.1]) cylinder(d = 5.2, h = 3);
    }
    
    // Retainer bumps
    rotate([0, 0, -30]) translate ([20.25, 0, 4]) sphere(d = 2);
    rotate([0, 0, 90]) translate ([20.25, 0, 4]) sphere(d = 2);
    rotate([0, 0, 210]) translate ([20.25, 0, 4]) sphere(d = 2);
    
    
}

module sdcard_access_port() {
    $fn = 32;
    difference() {
        union() {
            translate([-12, -7.5, 0]) cube([24, 15, 8]);
            // Flange
            hull() {
                translate([15, 0, 0]) cylinder(d = 20, h = 2);
                translate([-15, 0, 0]) cylinder(d = 20, h = 2);
            }
        }
        // Text
        translate([6, -3, -0.1]) linear_extrude(height = 1) rotate([0, 180, 0]) text("SD", size = 6);
        // Mounting holes
        translate([16, 0, -1]) cylinder(d = 3, h = 10);
        translate([-16, 0, -1]) cylinder(d = 3, h = 10);
    }
}

//retainer_spring();
character_retainer_ring();
//status_led_diffuser();
//sdcard_access_port();
