$fa = 1; $fs = 0.4; panel_border = 5; panel_width = 160 + 2*panel_border; panel_height = 100 + 2*panel_border; panel_thick = 1.5; 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; guide_thick = 0.5; guide_height = 2; guide_length = 3; wiggle_room = 0.3; epsilon = 0.01; module cutout_rect(left, upper, width, height) { translate([left + panel_border - wiggle_room, panel_height - panel_border - 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 + panel_border - width/2 - wiggle_room, panel_height - panel_border - 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 + panel_border - wiggle_room, panel_height - panel_border - 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 + panel_border, panel_height - panel_border - c_y, -length]) difference() { cylinder(r=5.6/2+1, h=length); translate([0, 0, -epsilon]) cylinder(r=(5.6+wiggle_room)/2, $fn=6, h=2+epsilon+wiggle_room); } } module button_guide(c_x, c_y, width, height) { translate([c_x + panel_border - width/2 - wiggle_room - guide_thick, panel_height - panel_border - c_y - height/2 - wiggle_room - guide_thick, -1-guide_height/2]) { cube([guide_length, guide_thick, guide_height]); cube([guide_thick, guide_length, guide_height]); } translate([c_x + panel_border + width/2 + wiggle_room, panel_height - panel_border - c_y - height/2 - wiggle_room - guide_thick, -1-guide_height/2]) { translate([-guide_length+guide_thick, 0, 0]) cube([guide_length, guide_thick, guide_height]); cube([guide_thick, guide_length, guide_height]); } translate([c_x + panel_border - width/2 - wiggle_room - guide_thick, panel_height - panel_border - c_y + height/2 + wiggle_room, -1-guide_height/2]) { cube([guide_length, guide_thick, guide_height]); translate([0, -guide_length+guide_thick, 0]) cube([guide_thick, guide_length, guide_height]); } translate([c_x + panel_border + width/2 + wiggle_room, panel_height - panel_border - c_y + height/2 + wiggle_room, -1-guide_height/2]) { translate([-guide_length+guide_thick, 0, 0]) cube([guide_length, guide_thick, guide_height]); translate([0, -guide_length+guide_thick, 0]) cube([guide_thick, guide_length, guide_height]); } } function col_x(col) = (5.5+col*8)*2.54; panel_angle = 60; bottom_border = 5; top_border = 5; top_shelf = 15; module panel() { row_1_but_y = 55+8*2.54; row_2_but_y = 55+15*2.54; buttons = concat([[15.24+(16+6.5)*2.54, 55, button_small_width, button_small_height], [15.24+(48+6.5)*2.54, 55, button_small_width, button_small_height], [15.24+(32+9.5)*2.54, 55-2.54, button_small_width, button_small_height]], [for (col = [0:6]) [col_x(col), row_1_but_y, button_width, button_height]], [for (col = [0, 1.5, 2.5, 3.5, 4.5, 6]) [col_x(col), row_2_but_y, button_width, button_height]]); difference() { union() { cube([panel_width, panel_height, panel_thick]); for (but = buttons) { button_guide(but[0], but[1], but[2], but[3]); } 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=14); screw_point(61*2.54, 37.5*2.54, length=14); } 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); for (but = buttons) { cutout_rect_c(but[0], but[1], but[2], but[3]); } row_1_led_y = 55+5*2.54; for (col = [0:6]) { // HDG, LNAV, ALT, VNAV, VS, FLC, SPD cutout_cyl(col_x(col), row_1_led_y, led_diam); } row_2_led_y = 55+12*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); } } } translate([0, (panel_border-bottom_border)/2, 0]) rotate([0, 90, 0]) screw_block(); translate([0, 100+panel_border+top_border/2-3, 0]) rotate([0, 90, 0]) screw_block(); translate([panel_width, (panel_border-bottom_border)/2, -6]) rotate([0, -90, 0]) screw_block(); translate([panel_width, 100+panel_border+top_border/2-3, -6]) rotate([0, -90, 0]) screw_block(); //color("green") translate([panel_border, panel_border, -12]) cube([160, 100, 1]); // dummy PCB translate([0, -bottom_border, 0]) cube([panel_width, bottom_border, panel_thick]); translate([0, panel_height, 0]) cube([panel_width, top_border, panel_thick]); rotate([0, -90, 0]) translate([0, 0, -panel_width+panel_thick]) linear_extrude(height=panel_width-panel_thick) polygon([[0, panel_height+top_border], [1, panel_height+top_border], [0, panel_height+top_border+panel_thick/tan(panel_angle)+epsilon]]); } module screw_block() { difference() { cube([6, 6, 12]); translate([3, 3, -epsilon]) cylinder(r=1.25+wiggle_room/2, h=10+epsilon); } } side_screw_head_diam = 5.9+wiggle_room; side_screw_shaft_diam = 3+wiggle_room; side_screw_head_height = 2.7; module side(rightside = false) { difference() { rotate([90, 0, 90]) translate([0, 0, -panel_thick+epsilon]) linear_extrude(height=panel_thick) polygon([[-bottom_border*cos(panel_angle), -bottom_border*sin(panel_angle)], [-bottom_border*cos(panel_angle)-panel_thick*sin(panel_angle), -bottom_border*sin(panel_angle)+panel_thick*cos(panel_angle)], [(panel_height+top_border)*cos(panel_angle)-panel_thick*sin(panel_angle), (panel_height+top_border)*sin(panel_angle)+panel_thick*cos(panel_angle)], [(panel_height+top_border)*cos(panel_angle)+top_shelf, (panel_height+top_border)*sin(panel_angle)+panel_thick*cos(panel_angle)], [(panel_height+top_border)*cos(panel_angle)+top_shelf, -bottom_border*sin(panel_angle)], ]); rotate([panel_angle, 0, 0]) { translate([0, (panel_border-bottom_border)/2, 0]) rotate([0, 90, 0]) if (rightside) { translate([3, 3, -epsilon-panel_thick]) cylinder(r1=side_screw_shaft_diam/2, r2=side_screw_head_diam/2, h=side_screw_head_height); } else { translate([3, 3, 2*epsilon-side_screw_head_height]) cylinder(r2=side_screw_shaft_diam/2, r1=side_screw_head_diam/2, h=side_screw_head_height); } translate([0, 100+panel_border+top_border/2-3, 0]) rotate([0, 90, 0]) if (rightside) { translate([3, 3, -epsilon-panel_thick]) cylinder(r1=side_screw_shaft_diam/2, r2=side_screw_head_diam/2, h=side_screw_head_height); } else { translate([3, 3, 2*epsilon-side_screw_head_height]) cylinder(r2=side_screw_shaft_diam/2, r1=side_screw_head_diam/2, h=side_screw_head_height); } if (rightside) { translate([-panel_thick-2*epsilon, panel_height - 27, -20]) cube([2*panel_thick, 10, 5]); } } /*#translate([0, (bottom_border/2+panel_thick)*cos(panel_angle) - 2.5*sin(panel_angle), (-bottom_border/2)*sin(panel_angle) + 2.5*cos(panel_angle)]) rotate([0, 90, 0]) cylinder(r=1, h=7);*/ } } render_panel = true; render_case = true; mount_screw_diam = 4+wiggle_room; mount_screw_head_diam = 6.7+wiggle_room; mount_screw_head_height = 2.3; if (render_panel && !render_case) { rotate([180, 0, 0]) panel(); } else if (render_panel && render_case) { rotate([panel_angle, 0, 0]) { // panel part #panel(); } } module mount_hole() { cylinder(r=mount_screw_diam/2, h=panel_thick*2); translate([0, 0, panel_thick*2-epsilon]) cylinder(r1=mount_screw_diam/2, r2 = mount_screw_head_diam/2, h=mount_screw_head_height); } if (render_case) { // case part difference() { union() { translate([0, -bottom_border*cos(panel_angle), -bottom_border*sin(panel_angle)]) cube([panel_width, top_shelf + cos(panel_angle)*(panel_height+bottom_border+top_border), 1]); translate([0, (panel_height+top_border)*cos(panel_angle), (panel_height+top_border)*sin(panel_angle)-epsilon]) translate([0, -0.5*panel_thick*sin(panel_angle), -panel_thick*cos(panel_angle)]) cube([panel_width, top_shelf+0.5*panel_thick*sin(panel_angle), panel_thick]); translate([0, (panel_height+top_border)*cos(panel_angle)+top_shelf-panel_thick, -bottom_border*sin(panel_angle)+panel_thick*cos(panel_angle)]) cube([panel_width, panel_thick+epsilon, (panel_height+bottom_border+top_border)*sin(panel_angle)-2*panel_thick*cos(panel_angle)]); } rotate([panel_angle, 0, 0]) { translate([0, -bottom_border-epsilon, 0]) cube([panel_width, 2*panel_thick+epsilon, 1]); translate([-wiggle_room, panel_height+top_border-panel_thick, 0]) cube([panel_width+2*wiggle_room, 2*panel_thick+epsilon, 1]); } translate([18-panel_thick, 28, -bottom_border*sin(panel_angle)-2]) { translate([0, 0, 0]) mount_hole(); translate([40, 0, 0]) mount_hole(); translate([40+54, 0, 0]) mount_hole(); translate([2*40+54, 0, 0]) mount_hole(); } } difference() { union() { side(); translate([panel_width+panel_thick-2*epsilon, 0, 0]) side(true); } rotate([panel_angle, 0, 0]) { translate([-wiggle_room, -bottom_border-panel_thick, 0]) cube ([wiggle_room+epsilon, panel_height+top_border+bottom_border+2*panel_thick, panel_thick]); translate([panel_width-epsilon, -bottom_border-panel_thick, 0]) cube ([wiggle_room, panel_height+top_border+bottom_border+2*panel_thick, panel_thick+epsilon]); } } }