From 8ac2cdb6ff9f9581a8e3be80ca68f9055b6f9538 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Sun, 8 Sep 2024 13:09:04 -0400 Subject: [PATCH 1/7] Add the enclosure --- bike-lights/case/enclosure.scad | 174 ++++++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 bike-lights/case/enclosure.scad diff --git a/bike-lights/case/enclosure.scad b/bike-lights/case/enclosure.scad new file mode 100644 index 0000000..953253f --- /dev/null +++ b/bike-lights/case/enclosure.scad @@ -0,0 +1,174 @@ +width = 65; +length = 75; +height = 16; +wall_thickness = 2; +guide_thickness = 1; +power_width = 21; +output_width = 37.5; +half_wall_thickness = wall_thickness / 2; +standoff_thickness = 10; +hole_diameter = 3; +// The radius of a nut in mm. However, based on my measurements, I'm not actually sure I have this right. The short height of a nut is 7.86mm. Derive from there. +nut_radius = 8.5 * cos(30) / 2; +nut_height = 2.69; // mm +screw_radius = 2; +handlebar_radius = 15; +clasp_thickness = 4; +clasp_width = 35; +circular_face_count = 96; + +module hexagon(r, h) { + pi = 3.1415926; + polyhedron( + points=[ + [r, 0, 0], + [r * cos(60), r * sin(60), 0], + [r * cos(120), r * sin(120), 0], + [r * cos(180), r * sin(180), 0], + [r * cos(240), r * sin(240), 0], + [r * cos(300), r * sin(300), 0], + + [r, 0, h], + [r * cos(60), r * sin(60), h], + [r * cos(120), r * sin(120), h], + [r * cos(180), r * sin(180), h], + [r * cos(240), r * sin(240), h], + [r * cos(300), r * sin(300), h], + ], + faces=[ + [0, 1, 2, 3, 4, 5], + [11, 10, 9, 8, 7, 6], + [6, 7, 1, 0], + [7, 8, 2, 1], + [8, 9, 3, 2], + [9, 10, 4, 3], + [10, 11, 5, 4], + [11, 6, 0, 5], + ] + ); +} + +// Nut holders are blocks that have a hole drilled through them and a hexagonal-shaped cavity. The idea is to +module nut_holder() { + difference() { + translate([-4.5, -4.5, -2]) cube([9, 9, 4]); + union() { + translate([0, 0, -1]) hexagon(nut_radius, 2); + cylinder(h = 6, r = screw_radius, center = true, $fn = 24); + } + } +} + +module screw_hole() { + union() { + translate([0, 0, 4]) cylinder(h = 2.1, r = screw_radius * 2, center = true, $fn = 24); + cylinder(h = 6, r = screw_radius, center = true, $fn = 24); + } +} + +module base() { + cube([width, length, wall_thickness]); +} + +module face() { + union() { + cube([width, length, wall_thickness / 2]); + translate([wall_thickness, wall_thickness, wall_thickness / 2]) cube([width-wall_thickness*2, length-wall_thickness*2, wall_thickness / 2]); + translate([4.5 + wall_thickness, 4.5 + wall_thickness, 4]) nut_holder(); + translate([width - 4.5 - wall_thickness, 4.5 + wall_thickness, 4]) nut_holder(); + translate([width - 4.5 - wall_thickness, length - 4.5 - wall_thickness, 4]) nut_holder(); + translate([4.5 + wall_thickness, length - 4.5 - wall_thickness, 4]) nut_holder(); + } +} + +module wall(length) { + cube([length, height, wall_thickness]); +} + +module power_wall() { + difference() { + wall(65); + translate([9, 2, -.5]) cube([power_width, height, wall_thickness + 1]); + } +} + +module output_wall() { + difference() { + wall(65); + translate([9, 2, -.5]) cube([output_width, height, wall_thickness + 1]); + } +} + +// Use hexagons as cutouts into which I can install a hex nut. This isn't quite right yet, but close. +// hexagon(nut_radius, 1); + +// cube([standoff_thickness, standoff_thickness, 2]); + +/* +difference() { + union() { + base(); + rotate([90, 0, 90]) wall(75); + // translate([width - wall_thickness, 0, 0]) rotate([90, 0, 90]) wall(length); + // rotate([90, 0, 0]) power_wall(); + // translate([0, length, 0]) rotate([90, 0, 0]) output_wall(); + // translate([wall_thickness, + // wall_thickness, + // wall_thickness]) standoff(); + // translate([width - wall_thickness - standoff_thickness, + // wall_thickness, + // wall_thickness]) standoff(); + // translate([wall_thickness, + // length - wall_thickness - standoff_thickness, + // wall_thickness]) standoff(); + // translate([width - wall_thickness - standoff_thickness, + // length - wall_thickness - standoff_thickness, + // wall_thickness]) standoff(); + } + // translate([-half_wall_thickness, -wall_thickness - half_wall_thickness, height - half_wall_thickness]) cube([wall_thickness, length + wall_thickness * 2, wall_thickness]); + // translate([width - half_wall_thickness, -wall_thickness - half_wall_thickness, height - half_wall_thickness]) cube([wall_thickness, length + wall_thickness * 2, wall_thickness]); + // translate([-half_wall_thickness, -half_wall_thickness, height - half_wall_thickness]) rotate([0, 0, 270]) cube([wall_thickness, width + wall_thickness * 2, wall_thickness]); + // translate([-half_wall_thickness, length + half_wall_thickness, height - half_wall_thickness]) rotate([0, 0, 270]) cube([wall_thickness, width + wall_thickness * 2, wall_thickness]); +} +*/ + +module box() { + difference() { + union() { + cube([width, length, wall_thickness * 2]); + translate([0, 0, wall_thickness]) rotate([90, 0, 90]) wall(length); + translate([width - wall_thickness, 0, wall_thickness]) rotate([90, 0, 90]) wall(length); + translate([0, wall_thickness, wall_thickness]) rotate([90, 0, 0]) wall(width); + translate([0, length, wall_thickness]) rotate([90, 0, 0]) wall(width); + } + translate([4.5 + wall_thickness, 4.5 + wall_thickness, 4]) rotate([180, 0, 0]) screw_hole(); + translate([width - 4.5 - wall_thickness, 4.5 + wall_thickness, 4]) rotate([180, 0, 0]) screw_hole(); + translate([width - 4.5 - wall_thickness, length - 4.5 - wall_thickness, 4]) rotate([180, 0, 0]) screw_hole(); + translate([4.5 + wall_thickness, length - 4.5 - wall_thickness, 4]) rotate([180, 0, 0]) screw_hole(); + } +} + +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.5, center = true, $fn = circular_face_count); + translate([0, 0, -clasp_width / 2 + 4]) cylinder(h = 1, r = handlebar_radius + clasp_thickness + 1.5, center = true, $fn = circular_face_count); + translate([0, 0, clasp_width / 2]) cylinder(h = 1, r = handlebar_radius + clasp_thickness + 1.5, center = true, $fn = circular_face_count); + translate([0, 0, clasp_width / 2 - 4]) cylinder(h = 1, r = handlebar_radius + clasp_thickness + 1.5, 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 body() { + union() { + box(); + // translate([width / 2, length / 2, -5 - handlebar_radius]) rotate([0, 90, 90]) top_clasp(); + } +} + +body(); +// translate([width + 10, 0, 0]) face(); -- 2.44.1 From d794b4872ff0e9897fc6647880721a697788814d Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Fri, 13 Sep 2024 20:29:10 -0400 Subject: [PATCH 2/7] First draft of the battery enclosure. --- bike-lights/case/battery_enclosure.scad | 229 ++++++++++++++++++++++++ 1 file changed, 229 insertions(+) create mode 100644 bike-lights/case/battery_enclosure.scad diff --git a/bike-lights/case/battery_enclosure.scad b/bike-lights/case/battery_enclosure.scad new file mode 100644 index 0000000..0ba2753 --- /dev/null +++ b/bike-lights/case/battery_enclosure.scad @@ -0,0 +1,229 @@ +$fn = 50; +threshold = 0.1; +half_threshold = threshold / 2; + +wire_radius = 1; + +wall_thickness = 2; +cutout_threshold = 1; + +battery_length = 71; +battery_width = 18.75; + +cell_holder_length = battery_length + wall_thickness * 2; +cell_holder_width = battery_width + wall_thickness * 2; +cell_holder_height = battery_width + wall_thickness; + +battery_contact_thickness = .6; +// battery_contact_thickness = 1; +battery_contact_width = 11; +battery_contact_length = 12.8; +battery_contact_spring_height = 10.5; +battery_contact_flange_height = 1.9; + +converter_width = 11.25; +converter_length = 22.25; +converter_height = 4.25; + +module box(length, width, height, wall_thickness) { + center_width = width - wall_thickness; + center_height = height - wall_thickness; + center_length = length - wall_thickness; + + union() { + hull() { + translate([-center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness); + translate([-center_width / 2, -center_length / 2, center_height / 2]) sphere(r = wall_thickness); + translate([center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness); + translate([center_width / 2, -center_length / 2, center_height / 2]) sphere(r = wall_thickness); + } + hull() { + translate([-center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness); + translate([-center_width / 2, center_length / 2, center_height / 2]) sphere(r = wall_thickness); + translate([center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness); + translate([center_width / 2, center_length / 2, center_height / 2]) sphere(r = wall_thickness); + } + hull() { + translate([-center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness); + translate([-center_width / 2, -center_length / 2, center_height / 2]) sphere(r = wall_thickness); + translate([-center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness); + translate([-center_width / 2, center_length / 2, center_height / 2]) sphere(r = wall_thickness); + } + hull() { + translate([center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness); + translate([center_width / 2, -center_length / 2, center_height / 2]) sphere(r = wall_thickness); + translate([center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness); + translate([center_width / 2, center_length / 2, center_height / 2]) sphere(r = wall_thickness); + } + hull() { + translate([-center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness); + translate([-center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness); + translate([center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness); + translate([center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness); + } + } + + /* + difference() { + cube([width, + length, + height], + center = true); + translate([0, 0, wall_thickness]) + cube([width - wall_thickness * 2, + length - wall_thickness * 2, + height + threshold], + center = true); + } + */ +} + +module channel(length, width, height, wall_thickness) { + center_width = width - wall_thickness; + center_height = height - wall_thickness; + center_length = length - wall_thickness; + + union() { + hull() { + translate([-center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness); + translate([-center_width / 2, -center_length / 2, center_height / 2]) sphere(r = wall_thickness); + translate([-center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness); + translate([-center_width / 2, center_length / 2, center_height / 2]) sphere(r = wall_thickness); + } + hull() { + translate([center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness); + translate([center_width / 2, -center_length / 2, center_height / 2]) sphere(r = wall_thickness); + translate([center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness); + translate([center_width / 2, center_length / 2, center_height / 2]) sphere(r = wall_thickness); + } + hull() { + translate([-center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness); + translate([-center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness); + translate([center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness); + translate([center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness); + } + } + + /* + difference() { + cube([width, + length, + height], + center = true); + translate([0, 0, wall_thickness]) + cube([width - wall_thickness * 2, + length + threshold, + height + threshold], + center = true); + } + */ +} + +module cell_cradle(length, width) { + translate([0, 0, -width / 4]) difference() { + cube([width + wall_thickness * 2, + wall_thickness, + width / 2], + center = true); + translate([0, 0, width / 2]) + rotate([90, 0, 0]) + cylinder(h = wall_thickness + cutout_threshold, + r = width / 2, + center = true); + } +} + +module cell_box() { + union() { + channel(cell_holder_length, cell_holder_width, cell_holder_height, wall_thickness); + translate([0, -battery_length / 6, 0]) cell_cradle(cell_holder_length, battery_width); + translate([0, battery_length / 6, 0]) cell_cradle(cell_holder_length, battery_width); + } +} + + +module contact_box(width, contact_width, contact_height, contact_thickness) { + contact_thickness_ = contact_thickness * .75; + cutout_width = contact_width * .8; + box_width = width + wall_thickness * 2; + box_thickness = contact_thickness_ + wall_thickness * 2; + box_height = width + wall_thickness; + + union() { + color("red", 1) cube([box_width, + box_thickness, + width + wall_thickness], + center = true); + + translate([0, + 0, + wall_thickness * 2]) + cube([contact_width, + contact_thickness_, + contact_height + cutout_threshold], + center = true); + + /* + translate([box_width / 2 - (contact_width * .8) / 2, + wall_thickness, + box_height - contact_height]) + cube([contact_width * .8, + wall_thickness + contact_thickness_ + cutout_threshold, + contact_height + cutout_threshold]); + + translate([width / 2 + wall_thickness, + 0, + width + wire_radius * 2]) + rotate([-90, 0, 0]) + cylinder(h=wall_thickness * 4, r=wire_radius, center = true); + + rotate([0, 180, 0]) + translate([-cutout_threshold / 2, + box_thickness, + width + wire_radius * 2]) + cylinder(h = width + wall_thickness * 2 + cutout_threshold, r = 1, center = true); + */ + } +} + +module battery_slot(length, width) { + union() { + translate([width + wall_thickness * 2, wall_thickness, 0]) + contact_box(battery_width, + battery_contact_width, + battery_contact_length, + battery_contact_flange_height); + translate([0, wall_thickness, 0]) cell_box(); + translate([0, wall_thickness + length, 0]) + rotate([0, 0, 180]) + contact_box(battery_width, + battery_contact_width, + battery_contact_length, + battery_contact_flange_height); + } +} + +module battery_case() { + union() { + battery_slot(battery_length, battery_width); + translate([battery_width + wall_thickness, 0, 0]) battery_slot(battery_length, battery_width); + } +} + +battery_case(); + +translate([-50, 0, 0]) + contact_box(battery_width, + battery_contact_width, + battery_contact_length, + battery_contact_flange_height); + +/* +rotate([0, 90, 0]) + translate([0, 5, 0]) + cylinder(h=battery_width + wall_thickness * 2 + cutout_threshold, r=1, center = true); + +translate([0, -5, 0]) + rotate([0, 90, 0]) + cylinder(h=battery_width + wall_thickness * 2 + cutout_threshold, r=1, center = true); +*/ -- 2.44.1 From e44c53acf0da8dd537c818617653fed4d9e5a724 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Fri, 13 Sep 2024 23:20:43 -0400 Subject: [PATCH 3/7] Apply bevels to everything --- bike-lights/case/battery_enclosure.scad | 216 ++++++++---------------- 1 file changed, 73 insertions(+), 143 deletions(-) diff --git a/bike-lights/case/battery_enclosure.scad b/bike-lights/case/battery_enclosure.scad index 0ba2753..ad5f14b 100644 --- a/bike-lights/case/battery_enclosure.scad +++ b/bike-lights/case/battery_enclosure.scad @@ -1,6 +1,7 @@ $fn = 50; threshold = 0.1; half_threshold = threshold / 2; +bevel = 0.5; wire_radius = 1; @@ -25,107 +26,63 @@ converter_width = 11.25; converter_length = 22.25; converter_height = 4.25; -module box(length, width, height, wall_thickness) { - center_width = width - wall_thickness; - center_height = height - wall_thickness; - center_length = length - wall_thickness; - union() { - hull() { - translate([-center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness); - translate([-center_width / 2, -center_length / 2, center_height / 2]) sphere(r = wall_thickness); - translate([center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness); - translate([center_width / 2, -center_length / 2, center_height / 2]) sphere(r = wall_thickness); - } - hull() { - translate([-center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness); - translate([-center_width / 2, center_length / 2, center_height / 2]) sphere(r = wall_thickness); - translate([center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness); - translate([center_width / 2, center_length / 2, center_height / 2]) sphere(r = wall_thickness); - } - hull() { - translate([-center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness); - translate([-center_width / 2, -center_length / 2, center_height / 2]) sphere(r = wall_thickness); - translate([-center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness); - translate([-center_width / 2, center_length / 2, center_height / 2]) sphere(r = wall_thickness); - } - hull() { - translate([center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness); - translate([center_width / 2, -center_length / 2, center_height / 2]) sphere(r = wall_thickness); - translate([center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness); - translate([center_width / 2, center_length / 2, center_height / 2]) sphere(r = wall_thickness); - } - hull() { - translate([-center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness); - translate([-center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness); - translate([center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness); - translate([center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness); - } +module pill(length, bevel) { + hull() { + translate([0, 0, (-length / 2) + bevel]) sphere(r = bevel); + translate([0, 0, (length / 2) - bevel]) sphere(r = bevel); } - - /* - difference() { - cube([width, - length, - height], - center = true); - translate([0, 0, wall_thickness]) - cube([width - wall_thickness * 2, - length - wall_thickness * 2, - height + threshold], - center = true); - } - */ } -module channel(length, width, height, wall_thickness) { - center_width = width - wall_thickness; - center_height = height - wall_thickness; - center_length = length - wall_thickness; +module box_face(length, width, wall_thickness, bevel) { + center_width = width - bevel * 2; + center_length = length - bevel * 2; - union() { - hull() { - translate([-center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness); - translate([-center_width / 2, -center_length / 2, center_height / 2]) sphere(r = wall_thickness); - translate([-center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness); - translate([-center_width / 2, center_length / 2, center_height / 2]) sphere(r = wall_thickness); - } - hull() { - translate([center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness); - translate([center_width / 2, -center_length / 2, center_height / 2]) sphere(r = wall_thickness); - translate([center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness); - translate([center_width / 2, center_length / 2, center_height / 2]) sphere(r = wall_thickness); - } - hull() { - translate([-center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness); - translate([-center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness); - translate([center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness); - translate([center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness); - } + 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); } - - /* - difference() { - cube([width, - length, - height], - center = true); - translate([0, 0, wall_thickness]) - cube([width - wall_thickness * 2, - length + threshold, - height + threshold], - center = true); - } - */ } -module cell_cradle(length, width) { - translate([0, 0, -width / 4]) difference() { - cube([width + wall_thickness * 2, +module channel(length, width, height) { + 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); + } +} + +module box(length, width, height) { + union() { + channel(length, width, height); + + 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); + } +} + +// box(20, 10, 10); +// color("blue", 0.5) cube([10, 20, 10], center = true); + +module cell_cradle(width, height) { + difference() { + translate([0, 0, -height / 2]) cube([width, wall_thickness, - width / 2], + height], center = true); - translate([0, 0, width / 2]) + color("red", 1) translate([0, 0, 0]) rotate([90, 0, 0]) cylinder(h = wall_thickness + cutout_threshold, r = width / 2, @@ -135,35 +92,30 @@ module cell_cradle(length, width) { module cell_box() { union() { - channel(cell_holder_length, cell_holder_width, cell_holder_height, wall_thickness); - translate([0, -battery_length / 6, 0]) cell_cradle(cell_holder_length, battery_width); - translate([0, battery_length / 6, 0]) cell_cradle(cell_holder_length, battery_width); + channel(cell_holder_length, cell_holder_width, cell_holder_height); + translate([0, -battery_length / 6, wall_thickness]) cell_cradle(cell_holder_width, cell_holder_height / 2); + translate([0, battery_length / 6, wall_thickness]) cell_cradle(cell_holder_width, cell_holder_height / 2); } } +module contact_box() { + contact_thickness = battery_contact_flange_height * .75; + cutout_width = battery_contact_width * .8; + // box_thickness = contact_thickness_ + wall_thickness * 2; + // box_height = width + wall_thickness; -module contact_box(width, contact_width, contact_height, contact_thickness) { - contact_thickness_ = contact_thickness * .75; - cutout_width = contact_width * .8; - box_width = width + wall_thickness * 2; - box_thickness = contact_thickness_ + wall_thickness * 2; - box_height = width + wall_thickness; - - union() { - color("red", 1) cube([box_width, - box_thickness, - width + wall_thickness], - center = true); - - translate([0, - 0, - wall_thickness * 2]) - cube([contact_width, - contact_thickness_, - contact_height + cutout_threshold], + difference() { + box(wall_thickness * 2 + contact_thickness, cell_holder_width, cell_holder_height); + translate([0, contact_thickness, wall_thickness * 2]) + cube([battery_contact_width, + wall_thickness * 2, + battery_contact_length + threshold], center = true); + } - /* + +/* + union() { translate([box_width / 2 - (contact_width * .8) / 2, wall_thickness, box_height - contact_height]) @@ -182,48 +134,26 @@ module contact_box(width, contact_width, contact_height, contact_thickness) { box_thickness, width + wire_radius * 2]) cylinder(h = width + wall_thickness * 2 + cutout_threshold, r = 1, center = true); - */ } +*/ } -module battery_slot(length, width) { +module battery_slot() { union() { - translate([width + wall_thickness * 2, wall_thickness, 0]) - contact_box(battery_width, - battery_contact_width, - battery_contact_length, - battery_contact_flange_height); + translate([0, -cell_holder_length / 2, 0]) contact_box(); translate([0, wall_thickness, 0]) cell_box(); - translate([0, wall_thickness + length, 0]) + translate([0, cell_holder_length / 2 + wall_thickness * 2, 0]) rotate([0, 0, 180]) - contact_box(battery_width, - battery_contact_width, - battery_contact_length, - battery_contact_flange_height); + contact_box(); } } module battery_case() { union() { - battery_slot(battery_length, battery_width); - translate([battery_width + wall_thickness, 0, 0]) battery_slot(battery_length, battery_width); + translate([-cell_holder_width / 2, 0, 0]) battery_slot(); + translate([cell_holder_width / 2 - wall_thickness, 0, 0]) battery_slot(); } } battery_case(); -translate([-50, 0, 0]) - contact_box(battery_width, - battery_contact_width, - battery_contact_length, - battery_contact_flange_height); - -/* -rotate([0, 90, 0]) - translate([0, 5, 0]) - cylinder(h=battery_width + wall_thickness * 2 + cutout_threshold, r=1, center = true); - -translate([0, -5, 0]) - rotate([0, 90, 0]) - cylinder(h=battery_width + wall_thickness * 2 + cutout_threshold, r=1, center = true); -*/ -- 2.44.1 From ce91ebc2ba561ae9f81bd360a519760024b98df1 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Fri, 13 Sep 2024 23:46:08 -0400 Subject: [PATCH 4/7] Add a channel for running wires --- bike-lights/case/battery_enclosure.scad | 51 ++++++++++--------------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/bike-lights/case/battery_enclosure.scad b/bike-lights/case/battery_enclosure.scad index ad5f14b..9e9131d 100644 --- a/bike-lights/case/battery_enclosure.scad +++ b/bike-lights/case/battery_enclosure.scad @@ -111,40 +111,31 @@ module contact_box() { wall_thickness * 2, battery_contact_length + threshold], center = true); + + color("red", 1) translate([0, + -(wall_thickness + contact_thickness + threshold) / 2, + cell_holder_height / 2]) + cube([5, wall_thickness + threshold * 2, cell_holder_height], center = true); + + translate([0, + -(wall_thickness + contact_thickness + threshold) / 2 - wire_radius, + 0]) + rotate([0, 90, 0]) + cylinder(h = cell_holder_width, r = wire_radius / 2, center = true); } - - -/* - union() { - translate([box_width / 2 - (contact_width * .8) / 2, - wall_thickness, - box_height - contact_height]) - cube([contact_width * .8, - wall_thickness + contact_thickness_ + cutout_threshold, - contact_height + cutout_threshold]); - - translate([width / 2 + wall_thickness, - 0, - width + wire_radius * 2]) - rotate([-90, 0, 0]) - cylinder(h=wall_thickness * 4, r=wire_radius, center = true); - - rotate([0, 180, 0]) - translate([-cutout_threshold / 2, - box_thickness, - width + wire_radius * 2]) - cylinder(h = width + wall_thickness * 2 + cutout_threshold, r = 1, center = true); - } -*/ } module battery_slot() { - union() { - translate([0, -cell_holder_length / 2, 0]) contact_box(); - translate([0, wall_thickness, 0]) cell_box(); - translate([0, cell_holder_length / 2 + wall_thickness * 2, 0]) - rotate([0, 0, 180]) - contact_box(); + difference() { + union() { + translate([0, -cell_holder_length / 2, 0]) contact_box(); + translate([0, wall_thickness, 0]) cell_box(); + translate([0, cell_holder_length / 2 + wall_thickness * 2, 0]) + rotate([0, 0, 180]) + contact_box(); + } + translate([cell_holder_width / 2, 1, 0]) rotate([90, 0, 0]) cylinder(h = cell_holder_length + wall_thickness * 4 + battery_contact_flange_height * 2, r = wire_radius / 2, center = true); + translate([-cell_holder_width / 2, 1, 0]) rotate([90, 0, 0]) cylinder(h = cell_holder_length + wall_thickness * 4 + battery_contact_flange_height * 2, r = wire_radius / 2, center = true); } } -- 2.44.1 From 98694f763b64e97266c9aec984d34c8f6f4ba356 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Sat, 14 Sep 2024 00:45:20 -0400 Subject: [PATCH 5/7] add the slot to hold the power converter --- bike-lights/case/battery_enclosure.scad | 47 ++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/bike-lights/case/battery_enclosure.scad b/bike-lights/case/battery_enclosure.scad index 9e9131d..565f3cd 100644 --- a/bike-lights/case/battery_enclosure.scad +++ b/bike-lights/case/battery_enclosure.scad @@ -24,7 +24,7 @@ battery_contact_flange_height = 1.9; converter_width = 11.25; converter_length = 22.25; -converter_height = 4.25; +converter_height = 5; module pill(length, bevel) { @@ -121,7 +121,7 @@ module contact_box() { -(wall_thickness + contact_thickness + threshold) / 2 - wire_radius, 0]) rotate([0, 90, 0]) - cylinder(h = cell_holder_width, r = wire_radius / 2, center = true); + cylinder(h = cell_holder_width, r = wire_radius, center = true); } } @@ -134,8 +134,41 @@ module battery_slot() { rotate([0, 0, 180]) contact_box(); } - translate([cell_holder_width / 2, 1, 0]) rotate([90, 0, 0]) cylinder(h = cell_holder_length + wall_thickness * 4 + battery_contact_flange_height * 2, r = wire_radius / 2, center = true); - translate([-cell_holder_width / 2, 1, 0]) rotate([90, 0, 0]) cylinder(h = cell_holder_length + wall_thickness * 4 + battery_contact_flange_height * 2, r = wire_radius / 2, center = true); + translate([cell_holder_width / 2, 1, 0]) rotate([90, 0, 0]) cylinder(h = cell_holder_length + wall_thickness * 4 + battery_contact_flange_height * 2, r = wire_radius, center = true); + translate([-cell_holder_width / 2, 1, 0]) rotate([90, 0, 0]) cylinder(h = cell_holder_length + wall_thickness * 4 + battery_contact_flange_height * 2, r = wire_radius, center = true); + } +} + +module converter_box() { + box_width = wall_thickness * 2 + converter_height; + difference() { + box(box_width, cell_holder_width * 2 - wall_thickness, cell_holder_height); + + translate([cell_holder_width - wire_radius, 0, 0]) + rotate([90, 0, 0]) + cylinder(h = box_width, r = wire_radius, center = true); + translate([cell_holder_width - wire_radius * 2, 0, 0]) + rotate([0, 90, 0]) + cylinder(h = wall_thickness + threshold, r = wire_radius, center = true); + + translate([-cell_holder_width + wire_radius, 0, 0]) + rotate([90, 0, 0]) + cylinder(h = box_width, r = wire_radius, center = true); + translate([-cell_holder_width + wire_radius * 2, 0, 0]) + rotate([0, 90, 0]) + cylinder(h = wall_thickness + threshold, r = wire_radius, center = true); + + translate([0, -box_width / 2, 0]) + rotate([0, 90, 0]) + cylinder(h = cell_holder_width * 2 + wall_thickness, r = wire_radius, center = true); + + translate([-cell_holder_width * .75, (-box_width + wall_thickness) / 2, 0]) + rotate([90, 0, 0]) + cylinder(h = wall_thickness * 2, r = wire_radius, center = true); + + translate([cell_holder_width * .75, (-box_width + wall_thickness) / 2, 0]) + rotate([90, 0, 0]) + cylinder(h = wall_thickness * 2, r = wire_radius, center = true); } } @@ -143,8 +176,14 @@ module battery_case() { union() { translate([-cell_holder_width / 2, 0, 0]) battery_slot(); translate([cell_holder_width / 2 - wall_thickness, 0, 0]) battery_slot(); + color("blue", 1) + translate([-wall_thickness / 2, + cell_holder_length / 2 + wall_thickness * 2 + battery_contact_flange_height + wall_thickness * 2 + wall_thickness / 2, + 0]) + converter_box(); } } + battery_case(); -- 2.44.1 From 2e37a89428a2e7fa6710dc930c492041505a3b15 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Mon, 16 Sep 2024 21:35:12 -0400 Subject: [PATCH 6/7] Add gaps to allow access to the voltage converter --- bike-lights/case/battery_enclosure.scad | 75 +++------- bike-lights/case/common.scad | 47 +++++++ bike-lights/case/enclosure.scad | 174 ------------------------ 3 files changed, 69 insertions(+), 227 deletions(-) create mode 100644 bike-lights/case/common.scad delete mode 100644 bike-lights/case/enclosure.scad diff --git a/bike-lights/case/battery_enclosure.scad b/bike-lights/case/battery_enclosure.scad index 565f3cd..7ffd77d 100644 --- a/bike-lights/case/battery_enclosure.scad +++ b/bike-lights/case/battery_enclosure.scad @@ -27,51 +27,7 @@ converter_length = 22.25; converter_height = 5; -module pill(length, bevel) { - hull() { - translate([0, 0, (-length / 2) + bevel]) sphere(r = bevel); - translate([0, 0, (length / 2) - bevel]) sphere(r = bevel); - } -} - -module box_face(length, width, wall_thickness, bevel) { - center_width = width - bevel * 2; - center_length = length - bevel * 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); - } -} - -module channel(length, width, height) { - 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); - } -} - -module box(length, width, height) { - union() { - channel(length, width, height); - - 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); - } -} +include <./common.scad>; // box(20, 10, 10); // color("blue", 0.5) cube([10, 20, 10], center = true); @@ -122,6 +78,14 @@ module contact_box() { 0]) rotate([0, 90, 0]) cylinder(h = cell_holder_width, r = wire_radius, center = true); + + color("green", 1) translate([-cell_holder_width / 2, 0, cell_holder_height / 2]) + rotate([0, 90, 0]) + cylinder(h = 5, r = contact_thickness / 2, center = true); + + color("green", 1) translate([cell_holder_width / 2, 0, cell_holder_height / 2]) + rotate([0, 90, 0]) + cylinder(h = 5, r = contact_thickness / 2, center = true); } } @@ -140,35 +104,41 @@ module battery_slot() { } module converter_box() { - box_width = wall_thickness * 2 + converter_height; + box_length = wall_thickness * 2 + converter_height; + box_width = cell_holder_width * 2 - wall_thickness; difference() { - box(box_width, cell_holder_width * 2 - wall_thickness, cell_holder_height); + box(box_length, box_width, cell_holder_height); translate([cell_holder_width - wire_radius, 0, 0]) rotate([90, 0, 0]) - cylinder(h = box_width, r = wire_radius, center = true); + cylinder(h = box_length, r = wire_radius, center = true); translate([cell_holder_width - wire_radius * 2, 0, 0]) rotate([0, 90, 0]) cylinder(h = wall_thickness + threshold, r = wire_radius, center = true); translate([-cell_holder_width + wire_radius, 0, 0]) rotate([90, 0, 0]) - cylinder(h = box_width, r = wire_radius, center = true); + cylinder(h = box_length, r = wire_radius, center = true); translate([-cell_holder_width + wire_radius * 2, 0, 0]) rotate([0, 90, 0]) cylinder(h = wall_thickness + threshold, r = wire_radius, center = true); - translate([0, -box_width / 2, 0]) + translate([0, -box_length / 2, 0]) rotate([0, 90, 0]) cylinder(h = cell_holder_width * 2 + wall_thickness, r = wire_radius, center = true); - translate([-cell_holder_width * .75, (-box_width + wall_thickness) / 2, 0]) + translate([-cell_holder_width * .75, (-box_length + wall_thickness) / 2, 0]) rotate([90, 0, 0]) cylinder(h = wall_thickness * 2, r = wire_radius, center = true); - translate([cell_holder_width * .75, (-box_width + wall_thickness) / 2, 0]) + translate([cell_holder_width * .75, (-box_length + wall_thickness) / 2, 0]) rotate([90, 0, 0]) cylinder(h = wall_thickness * 2, r = wire_radius, center = true); + + color("red", 1) translate([-box_width / 4, -(converter_height + wall_thickness) / 2, cell_holder_height / 2]) + cube([5, wall_thickness + threshold * 2, cell_holder_height], center = true); + color("red", 1) translate([box_width / 4, -(converter_height + wall_thickness) / 2, cell_holder_height / 2]) + cube([5, wall_thickness + threshold * 2, cell_holder_height], center = true); } } @@ -176,7 +146,6 @@ module battery_case() { union() { translate([-cell_holder_width / 2, 0, 0]) battery_slot(); translate([cell_holder_width / 2 - wall_thickness, 0, 0]) battery_slot(); - color("blue", 1) translate([-wall_thickness / 2, cell_holder_length / 2 + wall_thickness * 2 + battery_contact_flange_height + wall_thickness * 2 + wall_thickness / 2, 0]) diff --git a/bike-lights/case/common.scad b/bike-lights/case/common.scad new file mode 100644 index 0000000..64bc628 --- /dev/null +++ b/bike-lights/case/common.scad @@ -0,0 +1,47 @@ +module pill(length, bevel) { + hull() { + translate([0, 0, (-length / 2) + bevel]) sphere(r = bevel); + translate([0, 0, (length / 2) - bevel]) sphere(r = bevel); + } +} + +module box_face(length, width, wall_thickness, bevel) { + center_width = width - bevel * 2; + center_length = length - bevel * 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); + } +} + +module channel(length, width, height) { + 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); + } +} + +module box(length, width, height) { + union() { + channel(length, width, height); + + 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); + } +} + + diff --git a/bike-lights/case/enclosure.scad b/bike-lights/case/enclosure.scad deleted file mode 100644 index 953253f..0000000 --- a/bike-lights/case/enclosure.scad +++ /dev/null @@ -1,174 +0,0 @@ -width = 65; -length = 75; -height = 16; -wall_thickness = 2; -guide_thickness = 1; -power_width = 21; -output_width = 37.5; -half_wall_thickness = wall_thickness / 2; -standoff_thickness = 10; -hole_diameter = 3; -// The radius of a nut in mm. However, based on my measurements, I'm not actually sure I have this right. The short height of a nut is 7.86mm. Derive from there. -nut_radius = 8.5 * cos(30) / 2; -nut_height = 2.69; // mm -screw_radius = 2; -handlebar_radius = 15; -clasp_thickness = 4; -clasp_width = 35; -circular_face_count = 96; - -module hexagon(r, h) { - pi = 3.1415926; - polyhedron( - points=[ - [r, 0, 0], - [r * cos(60), r * sin(60), 0], - [r * cos(120), r * sin(120), 0], - [r * cos(180), r * sin(180), 0], - [r * cos(240), r * sin(240), 0], - [r * cos(300), r * sin(300), 0], - - [r, 0, h], - [r * cos(60), r * sin(60), h], - [r * cos(120), r * sin(120), h], - [r * cos(180), r * sin(180), h], - [r * cos(240), r * sin(240), h], - [r * cos(300), r * sin(300), h], - ], - faces=[ - [0, 1, 2, 3, 4, 5], - [11, 10, 9, 8, 7, 6], - [6, 7, 1, 0], - [7, 8, 2, 1], - [8, 9, 3, 2], - [9, 10, 4, 3], - [10, 11, 5, 4], - [11, 6, 0, 5], - ] - ); -} - -// Nut holders are blocks that have a hole drilled through them and a hexagonal-shaped cavity. The idea is to -module nut_holder() { - difference() { - translate([-4.5, -4.5, -2]) cube([9, 9, 4]); - union() { - translate([0, 0, -1]) hexagon(nut_radius, 2); - cylinder(h = 6, r = screw_radius, center = true, $fn = 24); - } - } -} - -module screw_hole() { - union() { - translate([0, 0, 4]) cylinder(h = 2.1, r = screw_radius * 2, center = true, $fn = 24); - cylinder(h = 6, r = screw_radius, center = true, $fn = 24); - } -} - -module base() { - cube([width, length, wall_thickness]); -} - -module face() { - union() { - cube([width, length, wall_thickness / 2]); - translate([wall_thickness, wall_thickness, wall_thickness / 2]) cube([width-wall_thickness*2, length-wall_thickness*2, wall_thickness / 2]); - translate([4.5 + wall_thickness, 4.5 + wall_thickness, 4]) nut_holder(); - translate([width - 4.5 - wall_thickness, 4.5 + wall_thickness, 4]) nut_holder(); - translate([width - 4.5 - wall_thickness, length - 4.5 - wall_thickness, 4]) nut_holder(); - translate([4.5 + wall_thickness, length - 4.5 - wall_thickness, 4]) nut_holder(); - } -} - -module wall(length) { - cube([length, height, wall_thickness]); -} - -module power_wall() { - difference() { - wall(65); - translate([9, 2, -.5]) cube([power_width, height, wall_thickness + 1]); - } -} - -module output_wall() { - difference() { - wall(65); - translate([9, 2, -.5]) cube([output_width, height, wall_thickness + 1]); - } -} - -// Use hexagons as cutouts into which I can install a hex nut. This isn't quite right yet, but close. -// hexagon(nut_radius, 1); - -// cube([standoff_thickness, standoff_thickness, 2]); - -/* -difference() { - union() { - base(); - rotate([90, 0, 90]) wall(75); - // translate([width - wall_thickness, 0, 0]) rotate([90, 0, 90]) wall(length); - // rotate([90, 0, 0]) power_wall(); - // translate([0, length, 0]) rotate([90, 0, 0]) output_wall(); - // translate([wall_thickness, - // wall_thickness, - // wall_thickness]) standoff(); - // translate([width - wall_thickness - standoff_thickness, - // wall_thickness, - // wall_thickness]) standoff(); - // translate([wall_thickness, - // length - wall_thickness - standoff_thickness, - // wall_thickness]) standoff(); - // translate([width - wall_thickness - standoff_thickness, - // length - wall_thickness - standoff_thickness, - // wall_thickness]) standoff(); - } - // translate([-half_wall_thickness, -wall_thickness - half_wall_thickness, height - half_wall_thickness]) cube([wall_thickness, length + wall_thickness * 2, wall_thickness]); - // translate([width - half_wall_thickness, -wall_thickness - half_wall_thickness, height - half_wall_thickness]) cube([wall_thickness, length + wall_thickness * 2, wall_thickness]); - // translate([-half_wall_thickness, -half_wall_thickness, height - half_wall_thickness]) rotate([0, 0, 270]) cube([wall_thickness, width + wall_thickness * 2, wall_thickness]); - // translate([-half_wall_thickness, length + half_wall_thickness, height - half_wall_thickness]) rotate([0, 0, 270]) cube([wall_thickness, width + wall_thickness * 2, wall_thickness]); -} -*/ - -module box() { - difference() { - union() { - cube([width, length, wall_thickness * 2]); - translate([0, 0, wall_thickness]) rotate([90, 0, 90]) wall(length); - translate([width - wall_thickness, 0, wall_thickness]) rotate([90, 0, 90]) wall(length); - translate([0, wall_thickness, wall_thickness]) rotate([90, 0, 0]) wall(width); - translate([0, length, wall_thickness]) rotate([90, 0, 0]) wall(width); - } - translate([4.5 + wall_thickness, 4.5 + wall_thickness, 4]) rotate([180, 0, 0]) screw_hole(); - translate([width - 4.5 - wall_thickness, 4.5 + wall_thickness, 4]) rotate([180, 0, 0]) screw_hole(); - translate([width - 4.5 - wall_thickness, length - 4.5 - wall_thickness, 4]) rotate([180, 0, 0]) screw_hole(); - translate([4.5 + wall_thickness, length - 4.5 - wall_thickness, 4]) rotate([180, 0, 0]) screw_hole(); - } -} - -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.5, center = true, $fn = circular_face_count); - translate([0, 0, -clasp_width / 2 + 4]) cylinder(h = 1, r = handlebar_radius + clasp_thickness + 1.5, center = true, $fn = circular_face_count); - translate([0, 0, clasp_width / 2]) cylinder(h = 1, r = handlebar_radius + clasp_thickness + 1.5, center = true, $fn = circular_face_count); - translate([0, 0, clasp_width / 2 - 4]) cylinder(h = 1, r = handlebar_radius + clasp_thickness + 1.5, 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 body() { - union() { - box(); - // translate([width / 2, length / 2, -5 - handlebar_radius]) rotate([0, 90, 90]) top_clasp(); - } -} - -body(); -// translate([width + 10, 0, 0]) face(); -- 2.44.1 From e21016e0e048c8b4e81e4d60444c8da21ba066ed Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Thu, 26 Sep 2024 22:15:30 -0400 Subject: [PATCH 7/7] Largely design the control panel case --- bike-lights/case/common.scad | 64 +++++++++------- bike-lights/case/control_panel.scad | 95 ++++++++++++++++++++++++ bike-lights/case/control_panel_case.scad | 4 + bike-lights/case/control_panel_lid.scad | 5 ++ 4 files changed, 141 insertions(+), 27 deletions(-) create mode 100644 bike-lights/case/control_panel.scad create mode 100644 bike-lights/case/control_panel_case.scad create mode 100644 bike-lights/case/control_panel_lid.scad 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(); + -- 2.44.1