// ============================================
// SaltyLab — Kill Switch Mount
// 60×60×40mm PETG
// 22mm panel-mount emergency stop button
// Mounts to 2020 extrusion, easily reachable
// ============================================
include <dimensions.scad>

mount_w = 60;
mount_d = 60;
mount_h = 40;
panel_h = 3;  // Panel face thickness

module kill_switch_mount() {
    difference() {
        union() {
            // Main body (angled face for visibility)
            hull() {
                translate([-mount_w/2, 0, 0])
                    cube([mount_w, mount_d, 1]);
                translate([-mount_w/2, 5, mount_h])
                    cube([mount_w, mount_d - 5, 1]);
            }
            
            // 2020 extrusion mount bracket (back)
            translate([-15, mount_d, 0])
                cube([30, 10, 20]);
        }
        
        // Kill switch hole (22mm, through angled face)
        translate([0, mount_d/2, mount_h/2])
            rotate([10, 0, 0])  // Slight angle for ergonomics
                cylinder(d=kill_sw_dia + tol, h=panel_h + 2, center=true, $fn=50);
        
        // Interior cavity (hollow for switch body)
        translate([-kill_sw_dia/2 - 3, 5, 3])
            cube([kill_sw_dia + 6, mount_d - 10, mount_h - 3]);
        
        // Wire exit hole (bottom)
        translate([0, mount_d/2, -1])
            cylinder(d=10, h=5, $fn=25);
        
        // Extrusion bolt holes (M5, through back bracket)
        for (z = [7, 15]) {
            translate([-20, mount_d + 5, z])
                rotate([90, 0, 0])
                    cylinder(d=m5_clear, h=15, center=true, $fn=25);
        }
        
        // Label recess ("EMERGENCY STOP" — flat area for sticker)
        translate([-25, 5, mount_h - 1])
            cube([50, 15, 1.5]);
    }
}

kill_switch_mount();
