monorepo/bike-lights/case/control_panel.scad

96 lines
2.8 KiB
OpenSCAD
Raw Normal View History

2024-09-27 02:15:30 +00:00
$fn = 50;
threshold = 0.1;
board_length = 92;
board_width = 72;
board_height = 21.5;
wall_thickness = 2;
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;
include <./common.scad>;
module hinge(length) {
difference() {
union() {
cylinder(h = length, r = hinge_radius);
translate([0, -hinge_radius, 0])
cube([hinge_radius, hinge_radius * 2, length]);
}
translate([0, 0, -threshold / 2]) cylinder(h = length + threshold, r = 1);
}
}
module main_case() {
hinge_length = board_length / 4;
hinge_y_offset = board_width + wall_thickness + hinge_radius;
hinge_z_offset = board_height;
difference() {
union() {
box(case_length,
case_width,
case_height,
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);
}
color("green", 1) translate([8.5 + wall_thickness, case_width - wall_thickness - threshold, wall_thickness])
cube([60, wall_thickness * 2, 7]);
}
}
module lid() {
lid_width = case_width + hinge_radius * 2 + wall_thickness;
union() {
difference() {
box_face([case_length,
lid_width,
wall_thickness],
bevel);
translate([(case_length - 60) / 2, 14 + hinge_radius * 2, -threshold / 2])
cube([60, 16, wall_thickness + threshold]);
}
translate([case_length / 4 + 1, hinge_radius - 0.4, -hinge_radius])
rotate([180, 0, 0])
rotate([0, 90, 0]) hinge(case_length / 2 - 2);
}
}
// main_case();
// color("red", 1) translate([0, 0, case_height + wall_thickness / 2]) lid();
// color("red", 1) translate([0, 0, 40]) lid();