monorepo/bike-lights/case/control_panel.scad

207 lines
9.7 KiB
OpenSCAD

$fn = 50;
threshold = 0.1;
board_length = 92;
board_width = 72;
board_height = 21.5;
wall_thickness = 4;
bevel = 0.5;
hinge_radius = 2.5;
case_width = board_width + wall_thickness * 2;
case_length = board_length + wall_thickness * 2;
case_height = board_height + wall_thickness;
handlebar_radius = 15;
clasp_thickness = 4;
circular_face_count = 48;
clasp_width = 35;
include <./common.scad>;
module top_clasp() {
difference() {
union() {
cylinder(h = clasp_width, r = handlebar_radius + clasp_thickness, center = true, $fn = circular_face_count);
translate([0, 0, -clasp_width / 2]) cylinder(h = 1, r = handlebar_radius + clasp_thickness + 1, center = true, $fn = circular_face_count);
translate([0, 0, -clasp_width / 2 + 4]) cylinder(h = 1, r = handlebar_radius + clasp_thickness + 1, center = true, $fn = circular_face_count);
translate([0, 0, clasp_width / 2]) cylinder(h = 1, r = handlebar_radius + clasp_thickness + 1, center = true, $fn = circular_face_count);
translate([0, 0, clasp_width / 2 - 4]) cylinder(h = 1, r = handlebar_radius + clasp_thickness + 1, center = true, $fn = circular_face_count);
translate([-handlebar_radius-5, -10, -clasp_width / 2 + 6]) cube([6, 20, clasp_width - 12]);
}
translate([-0.5, 0, 0]) cylinder(h = clasp_width+2, r = handlebar_radius + 1, center = true, $fn = circular_face_count);
translate([-0.5, -handlebar_radius - 10, -clasp_width / 2 - 1]) cube([handlebar_radius + 10, handlebar_radius * 2 + 20, clasp_width + 2]);
}
}
module hinge(length) {
difference() {
union() {
cube([hinge_radius * 2, length, hinge_radius], center = true);
translate([0, 0, -1.5]) rotate([90, 0, 0]) cylinder(h = length, r = hinge_radius, center = true);
}
translate([0, threshold / 2, -1.5]) rotate([90, 0, 0]) cylinder(h = length + threshold * 2, r = 1, center = true);
}
}
module base_case(length, width, height, bevel = 0) {
difference() {
union() {
channel(length + wall_thickness / 2, width, height, bevel);
translate([-bevel, 0, bevel])
rotate([90, 0, 0])
rotate([0, 90, 0])
box_face([width, height, wall_thickness], bevel);
// These are the sleds at the bottom of the case that should hold the lower of the two boards down
color("blue") translate([0, wall_thickness - 2, wall_thickness + 4]) cube([length - 8, 4, wall_thickness / 2]);
color("blue") translate([wall_thickness - 2, wall_thickness - 4, wall_thickness + 4]) cube([4, width, wall_thickness / 2]);
color("blue") translate([length - 25, width - wall_thickness * 3 / 2, wall_thickness + 6]) cube([16, wall_thickness, wall_thickness / 2]);
}
// This makes an indent at the bottom to accomodate solder joins
translate([wall_thickness + 2, wall_thickness + 2, wall_thickness / 2]) cube([length, width - wall_thickness * 2 - 4, wall_thickness / 2 + threshold]);
// This creates a cutout that lets the power plug slide in better.
translate([wall_thickness, width - wall_thickness, wall_thickness]) cube([length, 2, 6]);
// These two put in the slots that should allow the fourth wall to be slotted into place.
color("red") translate([length - 1, wall_thickness - 2, 4]) cube([2, 2, height]);
color("red") translate([length - 1, width - wall_thickness, 4]) cube([2, 2, height]);
}
}
module main_case() {
hinge_length = board_length / 4;
hinge_y_offset = board_width + wall_thickness + hinge_radius;
hinge_z_offset = board_height;
difference() {
union() {
base_case(case_length,
case_width,
case_height,
bevel);
translate([-bevel, 0, bevel])
rotate([90, 0, 0])
rotate([0, 90, 0])
box_face([case_width, case_height, wall_thickness], bevel);
translate([0, -hinge_radius - bevel + threshold, hinge_z_offset + bevel])
rotate([90, 0, 0])
rotate([0, 90, 0])
hinge(case_length / 4);
translate([case_length - hinge_length, -hinge_radius - bevel + threshold, hinge_z_offset + bevel])
rotate([90, 0, 0])
rotate([0, 90, 0])
hinge(case_length / 4);
translate([43, case_width, wall_thickness + 8])
rotate([90, 0, 0])
rotate([0, 180, 0])
linear_extrude(1)
text("lights", size = 3);
translate([67, case_width, wall_thickness + 8])
rotate([90, 0, 0])
rotate([0, 180, 0])
linear_extrude(1)
text("left", size = 3);
translate([55, case_width, wall_thickness + 8])
rotate([90, 0, 0])
rotate([0, 180, 0])
linear_extrude(1)
text("right", size = 3);
// translate([case_length / 2, case_width / 2, -20]) rotate([0, 90, 0]) top_clasp();
}
translate([case_length / 2, case_width / 2, -threshold]) hexagon(4.5, 6);
# translate([8.5 + wall_thickness, case_width - wall_thickness - threshold, wall_thickness])
# cube([60, wall_thickness * 2, 7]);
}
}
module lamp() {
union() {
translate([0, 0, -0.5]) cube([12.9 + threshold, 8, 4], center = true);
translate([0, 0, .88]) cube([5 + threshold, 5 + threshold, 1.56], center = true);
/*
translate([0, 0, -1.56]) cube([12.9, 7.6, wall_thickness], center = true);
*/
}
}
module button() {
union() {
cube([3.5 + threshold, 6.1 + threshold, 4 + threshold], center = true);
translate([0, 0, -0.5]) cube([1.2, 7, 3 + threshold], center = true);
}
}
module lid() {
lid_width = case_width + hinge_radius * 2 + wall_thickness;
hinge_length = case_length / 4;
union() {
difference() {
rounded_cube([case_length,
lid_width,
wall_thickness],
bevel);
translate([0, lid_width / 5, 0.4]) lamp();
translate([-15, lid_width / 5, 0.4]) lamp();
translate([15, lid_width / 5, 0.4]) lamp();
translate([-30, lid_width / 5, 0]) button();
translate([30, lid_width / 5, 0]) button();
translate([0, lid_width / 5, -2]) cube([20, 7, 3], center = true);
color("black") translate([-2, lid_width / 5 - 5, -2]) rotate([0, 0, 90]) rotate([0, 90, 0]) cylinder(h=5, r = 1, center = true, $fn = circular_face_count);
color("black") translate([-17, lid_width / 5 - 5, -2]) rotate([0, 0, 90]) rotate([0, 90, 0]) cylinder(h=5, r = 1, center = true, $fn = circular_face_count);
color("black") translate([13, lid_width / 5 - 5, -2]) rotate([0, 0, 90]) rotate([0, 90, 0]) cylinder(h=5, r = 1, center = true, $fn = circular_face_count);
color("black") translate([-30, lid_width / 5 - 5, -2]) rotate([0, 0, 90]) rotate([0, 90, 0]) cylinder(h=5, r = 1, center = true, $fn = circular_face_count);
color("black") translate([30, lid_width / 5 - 5, -2]) rotate([0, 0, 90]) rotate([0, 90, 0]) cylinder(h=5, r = 1, center = true, $fn = circular_face_count);
color("black") translate([0, 10, -2]) rotate([0, 90, 0]) cylinder(h = 62, r = 1, center = true, $fn = circular_face_count);
color("red") translate([-33, 21, -2]) rotate([0, 90, 0]) cylinder(h = 5, r = 1, center = true, $fn = circular_face_count);
color("red") translate([-35, 13, -2]) rotate([0, 0, 90]) rotate([0, 90, 0]) cylinder(h = 18, r = 1, center = true, $fn = circular_face_count);
color("red") translate([33, 21, -2]) rotate([0, 90, 0]) cylinder(h = 5, r = 1, center = true, $fn = circular_face_count);
color("red") translate([35, 13, -2]) rotate([0, 0, 90]) rotate([0, 90, 0]) cylinder(h = 18, r = 1, center = true, $fn = circular_face_count);
color("red") translate([0, 5, -2]) rotate([0, 90, 0]) cylinder(h = 70, r = 1, center = true, $fn = circular_face_count);
}
translate([case_length / 2 - hinge_length / 2, lid_width / 2 - wall_thickness / 2 - 0.5, -wall_thickness / 2]) rotate([0, 0, 90]) hinge(hinge_length);
translate([-case_length / 2 + hinge_length / 2, lid_width / 2 - wall_thickness / 2 - 0.5, -wall_thickness / 2]) rotate([0, 0, 90]) hinge(hinge_length);
}
}
module box_side() {
box_side_slider(case_length, case_width, case_height);
}
module case_base() {
difference() {
rounded_cube([case_length, case_width, wall_thickness + 2], bevel = 0.5);
translate([wall_thickness, 0, 2]) rounded_cube([case_length + threshold, board_width + threshold, 2 + threshold]);
// These give a screw-hole in the center which will allow the clamp to be attached
translate([0, 0, -1]) hexagon(4.5, 2);
translate([0, 0, -wall_thickness / 2]) cylinder(r = 2, h = wall_thickness + threshold, center = true);
// and now a bit of an indentation to help the clip remain in place
translate([0, 0, -4.5]) cube([clasp_width + threshold, clasp_width + threshold, wall_thickness], center = true);
// here are some grooves along the edges that can be used to piece parts together
translate([wall_thickness / 2, case_width / 2 - wall_thickness / 2, wall_thickness / 2])
cube([board_length + wall_thickness, wall_thickness / 2, wall_thickness / 2 + threshold], center = true);
translate([wall_thickness / 2, -case_width / 2 + wall_thickness / 2, wall_thickness / 2])
cube([board_length + wall_thickness, wall_thickness / 2, wall_thickness / 2 + threshold], center = true);
}
}