$fn = 72; include include include module top_case(with_keyboard=false) { keyboard_deck_z_offset = wall_height - keyboard_switch_height; accent_width = 1.0000; accent_depth = 0.5; accent_y_stride = (keyboard_pcb_length - accent_width) / 5.0; accent_y_bottom = keyboard_y_offset; vent_width = 2.0000; vent_length = wall_width; vent_height = 12.0000; vent_count = 32; vent_x_first = keyboard_x_offset + keyboard_pcb_width - vent_count * (vent_width + vent_width); vent_y_offset = case_length_bottom - vent_length; eps = 0.01; module fascia() { difference() { cube([case_width_bottom, case_length_bottom, wall_width]); if (with_keyboard) { translate([keyboard_x_offset, keyboard_y_offset, -eps]) cube([keyboard_pcb_width, keyboard_pcb_length, wall_width + 2*eps]); } } } module vents() { for (i = [0:vent_count]) { x = vent_x_first + (i * (vent_width + vent_width)); translate([x, vent_y_offset-eps, wall_height - vent_height]) cube([vent_width, vent_length+2*eps, vent_height+eps]); } } module accents() { for (y = [accent_y_bottom: accent_y_stride: case_length_bottom]) { /* Top */ translate([-eps, y - eps, wall_height - accent_depth]) cube([case_width_bottom+2*eps, accent_width + 2*eps, accent_depth+eps]); /* Right */ translate([case_width_bottom - accent_depth, y, -eps]) cube([accent_depth+eps, accent_width+eps, wall_height+2*eps]); /* Left */ translate([-eps, y, -eps]) cube([accent_depth+eps, accent_width, wall_height+2*eps]); } } module screw_posts() { module screw_post(h) { linear_extrude(h) difference() { circle(d=screw_post_diameter_outer); circle(d=screw_post_diameter_inner); } } for (post = top_case_screw_posts) { translate([post[0], post[1], wall_height - wall_width - post[2] - eps]) screw_post(post[2] + eps); } } module keyboard_supports() { support_width = 1.2500; support_height = keyboard_switch_height - wall_width; support_x_interval = (keyboard_pcb_width + 2 * wall_width - support_width) / 6; support_x_offset = keyboard_x_offset - wall_width; support_y_interval = (keyboard_pcb_length + 2 * wall_width - support_width) / 4; support_y_offset = keyboard_y_offset; /* Upper vertical supports */ upper_support_length = case_length_bottom - keyboard_pcb_length - keyboard_y_offset - 2 * wall_width; upper_support_y_offset = keyboard_y_offset + keyboard_pcb_length + wall_width; /* Lower vertical supports */ lower_support_length = keyboard_y_offset - 2 * wall_width; lower_support_y_offset = wall_width; /* Left horizontal supports */ left_support_length = keyboard_x_offset - 2 * wall_width; left_support_x_offset = wall_width; /* Right horizontal supports */ right_support_length = case_width_bottom - keyboard_pcb_width - keyboard_x_offset - 2 * wall_width; right_support_x_offset = keyboard_x_offset + keyboard_pcb_width + wall_width; for (x = [0: support_x_interval: keyboard_pcb_width + 2 * wall_width]) { translate([support_x_offset + x, upper_support_y_offset - eps, wall_height - wall_width]) support([upper_support_length + 2*eps, support_height], support_width); translate([support_x_offset + x, lower_support_y_offset - eps, wall_height - wall_width]) support([lower_support_length + 2*eps, support_height], support_width); } for (y = [0: support_y_interval: keyboard_pcb_length + 2 * wall_width]) { translate([right_support_x_offset - eps, support_y_offset + y - wall_width + support_width, wall_height - wall_width]) rotate([0, 0, -90]) support([right_support_length + 2*eps, support_height], support_width); translate([left_support_x_offset - eps, support_y_offset + y - wall_width + support_width, wall_height - wall_width]) rotate([0, 0, -90]) support([left_support_length + 2*eps, support_height], support_width); } } module logotype() { module logotype_text(size) { size_ratio = 1/5; text("XANTRONIX", font="Proxima Nova Semibold", size=size*size_ratio); translate([16, 0, 0]) text("Z32", font="Proxima Nova Semibold", size=size); } size = 10; translate([keyboard_x_offset, keyboard_y_offset + keyboard_pcb_length + keyboard_switch_length + accent_width, wall_height - accent_depth]) linear_extrude(accent_depth + eps) logotype_text(size); } module sextile() { module shape(width) { ratio = 33 / 197; margin = 0.5; for (angle = [0, -55, 55]) { rotate([0, 0, angle]) square([width + margin, ratio * width + 2*margin], true); } } width = 16.0; offset_y = keyboard_y_offset + (keyboard_switch_width + accent_width) / 2; offset_x = case_width_bottom - width; translate([offset_x, offset_y, wall_height - accent_depth]) linear_extrude(accent_depth + eps) shape(width); } module body() { translate([0, 0, wall_height - wall_width]) fascia(); /* Upper */ translate([wall_width, case_length_bottom - wall_width_upper, 0]) cube([case_width_bottom - 2*wall_width, wall_width_upper, wall_lip_upper]); translate([0, case_length_bottom - wall_width, wall_lip_upper - eps]) cube([case_width_bottom, wall_width, wall_height - wall_lip_upper + eps]); /* Right */ translate([case_width_bottom - wall_width, 0, 0]) cube([wall_width, case_length_bottom, wall_height]); /* Lower */ cube([case_width_bottom, wall_width, wall_height]); /* Left */ cube([wall_width, case_length_bottom, wall_height]); } difference() { body(); logotype(); sextile(); accents(); vents(); } screw_posts(); if (with_keyboard) { keyboard_supports(); translate([keyboard_x_offset, keyboard_y_offset, keyboard_deck_z_offset]) keyboard_deck(wall_width); } } top_case(true);