Remove magic numbers for usb and battery compartments

This commit is contained in:
2023-06-20 23:04:46 +02:00
parent a58d172b9b
commit e043705df8

View File

@@ -25,55 +25,67 @@ translate([thickness, thickness, 1.5]){
} }
// usb floor // usb floor
usb_floor(); usb_compartment();
// battery floor // battery floor
battery_floor(145); translate([146.6, 0, 0])
battery_compartment();
// raspberry pi 4 cover // raspberry pi 4 cover
rpi4_cover(); rpi4_cover();
module usb_floor(){ module usb_compartment(){
padding=5.6+thickness; usb_tray_width=31;
hole=6; usb_tray_height=4;
usb_width=41;
usb_height=2;
usb_step_width=10; usb_step_width=10;
center_hole=usb_width-(usb_step_width/2)+thickness; usb_step_height=2;
hole=6;
hole_x=usb_tray_width+(usb_step_width/2)+thickness;
hole_y=5.6+thickness;
// usb tray
difference(){ difference(){
translate([0, 0, height]) translate([0, 0, height])
cube([usb_width+thickness, depth+(thickness*2), usb_height+thickness]); cube([usb_tray_width+thickness, depth+(thickness*2), usb_tray_height+thickness]);
translate([0, 0, height+thickness]) translate([thickness, thickness, height+thickness])
cube([usb_width-usb_step_width, depth+(thickness*2), usb_height]); cube([usb_tray_width, depth, usb_tray_height]);
}
translate([usb_width-usb_step_width+thickness, thickness, height]) // usb step
cube([usb_step_width, depth, usb_height]); difference(){
translate([usb_tray_width, 0, height])
cube([usb_step_width+thickness, depth+(thickness*2), usb_step_height+thickness]);
translate([center_hole, padding, height+usb_height]) translate([usb_tray_width+thickness, thickness, height])
cube([usb_step_width, depth, usb_step_height]);
translate([hole_x, hole_y, height+usb_step_height])
cylinder(h=thickness, d=hole); cylinder(h=thickness, d=hole);
translate([center_hole, depth+(thickness*2)-padding, height+usb_height]) translate([hole_x, depth+(thickness*2)-hole_y, height+usb_step_height])
cylinder(h=thickness, d=hole); cylinder(h=thickness, d=hole);
} }
} }
module battery_floor(x){ module battery_compartment(){
offset=5.6+thickness; battery_width=63.5;
battery_height=4;
hole=6; hole=6;
hole_x=5;
hole_y=5.6+thickness;
difference(){ difference(){
translate([x+thickness, 0, height]) translate([0, 0, height])
cube([width-x+thickness, depth+(thickness*2), 4+thickness]); cube([battery_width+thickness, depth+(thickness*2), battery_height+thickness]);
translate([x+thickness, thickness, height]) translate([0, thickness, height])
cube([width-x, depth, 4]); cube([battery_width, depth, battery_height]);
translate([x+thickness+5, offset, height+4]) translate([hole_x, hole_y, height+4])
cylinder(h=thickness, d=hole); cylinder(h=thickness, d=hole);
translate([x+thickness+5, depth+(thickness*2)-offset, height+4]) translate([hole_x, depth+(thickness*2)-hole_y, height+battery_height])
cylinder(h=thickness, d=hole); cylinder(h=thickness, d=hole);
} }
} }
@@ -90,12 +102,22 @@ module rpi4_cover(){
cylinder(h=thickness, d=41.5); cylinder(h=thickness, d=41.5);
} }
// left slope
difference(){ difference(){
translate([19+thickness, 0, height+thickness]) translate([19+thickness, 0, height+thickness])
prism(22, depth+(thickness*2), 25); left_slope(22, depth+(thickness*2), 23.4);
translate([19+thickness, thickness, height+thickness]) translate([19+thickness, thickness, height+thickness])
prism(22, depth, 25); left_slope(22, depth, 25);
}
// right slope
difference(){
translate([145+thickness, 0, height+thickness])
right_slope(22, depth+(thickness*2), 23.4);
translate([145+thickness, thickness, height+thickness])
right_slope(22, depth, 25);
} }
// logo // logo
@@ -103,11 +125,16 @@ module rpi4_cover(){
linear_extrude(height=1.6) linear_extrude(height=1.6)
resize([42, 42, 0]) resize([42, 42, 0])
import(file="mk-logo.svg", center=true); import(file="mk-logo.svg", center=true);
} }
module prism(l, w, h){ module left_slope(w, d, h){
polyhedron( polyhedron(
points=[[0,w,0], [0,0,0], [l,0,0], [l,w,0], [l,w,h], [l,0,h]], points=[[0,d,0], [0,0,0], [w,0,0], [w,d,0], [w,d,h], [w,0,h]],
faces=[[0,1,2,3],[5,4,3,2],[0,4,5,1],[0,3,4],[5,2,1]]);
}
module right_slope(w, d, h){
polyhedron(
points=[[0,d,0], [0,0,0], [w,0,0], [w,d,0], [0,d,h], [0,0,h]],
faces=[[0,1,2,3],[5,4,3,2],[0,4,5,1],[0,3,4],[5,2,1]]); faces=[[0,1,2,3],[5,4,3,2],[0,4,5,1],[0,3,4],[5,2,1]]);
} }