Files
rp2040-hid/3dprint/panel.scad

109 lines
3.4 KiB
OpenSCAD

$fa = 1;
$fs = 0.4;
panel_border = 5;
panel_width = 160 + 2*panel_border;
panel_height = 100 + 2*panel_border;
panel_thick = 1;
led_diam = 3;
button_width = 15;
button_height = 8;
button_small_width = 8;
button_small_height = 8;
enc_shaft_diam = 6;
led_height = 12.7;
led_width = 4*2.54;
cutout_depth = panel_thick + 1;
wiggle_room = 0.1;
epsilon = 0.01;
module cutout_rect(left, upper, width, height) {
translate([left + 5 - wiggle_room,
panel_height - 5 - upper - height - wiggle_room, 0])
cube([width + 2*wiggle_room, height + 2*wiggle_room,
cutout_depth+2*epsilon]);
}
module cutout_rect_c(c_x, c_y, width, height) {
translate([c_x + 5 - width/2 - wiggle_room,
panel_height - 5 - c_y - height/2 - wiggle_room, 0])
cube([width + 2*wiggle_room, height + 2*wiggle_room,
cutout_depth+2*epsilon]);
}
module cutout_cyl(c_x, c_y, diam) {
translate([c_x + 5 - wiggle_room, panel_height - 5 - c_y - wiggle_room, 0])
cylinder(r=diam/2 + wiggle_room, h=cutout_depth+2*epsilon);
}
module screw_point(c_x, c_y, length = 5) {
translate([c_x + 5, panel_height - 5 - c_y, -length])
difference() {
cylinder(r=5.2/2+1, h=length);
translate([0, 0, -epsilon])
cylinder(r=5.2/2, $fn=6, h=2+epsilon);
}
}
function col_x(col) = (5.5+col*8)*2.54;
difference() {
union() {
cube([panel_width, panel_height, panel_thick]);
screw_point(2*2.54, 1.5*2.54);
screw_point(61*2.54, 2.5*2.54);
screw_point(2*2.54, 37.5*2.54, length=12);
screw_point(61*2.54, 37.5*2.54, length=12);
}
translate([0, 0, -cutout_depth+panel_thick-epsilon]) union() {
// HDG led
cutout_rect(8.9, 5.5, 3*led_width, led_height);
// ALT led
cutout_rect(8.9+2*led_width, 5.5 + led_height + 3*2.54, 5*led_width, led_height);
// VS led
cutout_rect(8.9+6*led_width, 5.5, 5*led_width, led_height);
// AS led
cutout_rect(8.9+10*led_width, 5.5 + led_height + 3*2.54, 4*led_width, led_height);
// HDG rot
cutout_cyl(15.24, 55, enc_shaft_diam);
// ALT rot
cutout_cyl(15.24+16*2.54, 55, enc_shaft_diam);
// VS rot
cutout_cyl(15.24+32*2.54, 55, enc_shaft_diam);
// AS rot
cutout_cyl(15.24+48*2.54, 55, enc_shaft_diam);
// ALT INTV
cutout_rect_c(15.24+(16+6.5)*2.54, 55, button_small_width,
button_small_height);
// SPD INTV
cutout_rect_c(15.24+(48+6.5)*2.54, 55, button_small_width,
button_small_height);
// c/o
cutout_rect_c(15.24+(32+9.5)*2.54, 55-2.54, button_small_width,
button_small_height);
row_1_led_y = 55+5*2.54;
row_1_but_y = 55+8*2.54;
for (col = [0:6]) {
// HDG, LNAV, ALT, VNAV, VS, FLC, SPD
cutout_cyl(col_x(col), row_1_led_y, led_diam);
cutout_rect_c(col_x(col), row_1_but_y, button_width, button_height);
}
row_2_led_y = 55+12*2.54;
row_2_but_y = 55+15*2.54;
for (col = [0, 1.5, 2.5, 3.5, 4.5, 6]) {
// APR, LVL, FD, AP, A/T, N1
cutout_cyl(col_x(col), row_2_led_y, led_diam);
cutout_rect_c(col_x(col), row_2_but_y, button_width, button_height);
}
}
}