diff --git a/bike-lights/case/common.scad b/bike-lights/case/common.scad index 64bc628..75ba697 100644 --- a/bike-lights/case/common.scad +++ b/bike-lights/case/common.scad @@ -5,43 +5,53 @@ module pill(length, bevel) { } } -module box_face(length, width, wall_thickness, bevel) { - center_width = width - bevel * 2; - center_length = length - bevel * 2; +module box_face(dimensions, bevel = 0) { + x = dimensions[0]; + y = dimensions[1]; + z = dimensions[2]; - hull() { - translate([-center_width / 2, -center_length / 2, 0]) - pill(wall_thickness, bevel); - translate([center_width / 2, -center_length / 2, 0]) - pill(wall_thickness, bevel); - translate([center_width / 2, center_length / 2, 0]) - pill(wall_thickness, bevel); - translate([-center_width / 2, center_length / 2, 0]) - pill(wall_thickness, bevel); + if (bevel > 0) { + translate([0, 0, z / 2]) + hull() { + pill(z, bevel); + translate([x, 0, 0]) + pill(z, bevel); + translate([x, y, 0]) + pill(z, bevel); + translate([0, y, 0]) + pill(z, bevel); + } + } else { + cube(dimensions); } } -module channel(length, width, height) { +module channel(length, width, height, bevel) { union() { - translate([0, 0, -height / 2 + wall_thickness / 2]) - box_face(length, width, wall_thickness, bevel); - translate([-width / 2 + wall_thickness / 2, 0, 0]) rotate([0, 90, 0]) - box_face(length, height, wall_thickness, bevel); - translate([width / 2 - wall_thickness / 2, 0, 0]) rotate([0, 90, 0]) - box_face(length, height, wall_thickness, bevel); + box_face([length, width, wall_thickness], bevel); + + translate([0, wall_thickness - bevel, bevel]) + rotate([90, 0, 0]) + box_face([length, height, wall_thickness], bevel); + + translate([0, width + bevel, bevel]) + rotate([90, 0, 0]) + box_face([length, height, wall_thickness], bevel); } } -module box(length, width, height) { +module box(length, width, height, bevel = 0) { union() { - channel(length, width, height); + channel(length, width, height, bevel); - translate([0, -length / 2 + wall_thickness / 2, 0]) rotate([90, 0, 0]) - box_face(height, width, wall_thickness, bevel); - - translate([0, length / 2 - wall_thickness / 2, 0]) rotate([90, 0, 0]) - box_face(height, width, wall_thickness, bevel); + translate([-bevel, 0, bevel]) + rotate([90, 0, 0]) + rotate([0, 90, 0]) + box_face([width, height, wall_thickness], bevel); + translate([length - wall_thickness + bevel, 0, bevel]) + rotate([90, 0, 0]) + rotate([0, 90, 0]) + box_face([width, height, wall_thickness], bevel); } } - diff --git a/bike-lights/case/control_panel.scad b/bike-lights/case/control_panel.scad new file mode 100644 index 0000000..de323bc --- /dev/null +++ b/bike-lights/case/control_panel.scad @@ -0,0 +1,95 @@ +$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(); diff --git a/bike-lights/case/control_panel_case.scad b/bike-lights/case/control_panel_case.scad new file mode 100644 index 0000000..9ba0bf7 --- /dev/null +++ b/bike-lights/case/control_panel_case.scad @@ -0,0 +1,4 @@ + +include <./control_panel.scad> + +main_case(); diff --git a/bike-lights/case/control_panel_lid.scad b/bike-lights/case/control_panel_lid.scad new file mode 100644 index 0000000..6824eca --- /dev/null +++ b/bike-lights/case/control_panel_lid.scad @@ -0,0 +1,5 @@ + +include <./control_panel.scad> + +lid(); +