177 lines
5.6 KiB
OpenSCAD
177 lines
5.6 KiB
OpenSCAD
include <BOSL/constants.scad>
|
|
use <BOSL/math.scad>
|
|
use <BOSL/shapes.scad>
|
|
use <BOSL/transforms.scad>
|
|
include <wemos_d1_mini.scad>
|
|
|
|
$fn = $preview ? 30 : 50;
|
|
|
|
case_thickness = 3;
|
|
wire_clearance = 10;
|
|
plate_margin = 5;
|
|
plate_thickness = 3;
|
|
plate_depth = 3;
|
|
plate_clearance = 0.3;
|
|
|
|
// Number of key switches
|
|
keys = 3;
|
|
// Spacing between keys
|
|
key_distance = 0;
|
|
// With of a 1u keycap
|
|
key_width = 19.05;
|
|
// Width of key switch cutout
|
|
keyswitch_cutout_width = 14;
|
|
|
|
// Diameter of the dial, used for spacing
|
|
dial_diameter = 20;
|
|
dial_base_width = 12.85;
|
|
dial_base_height = 16.75;
|
|
dial_base_protrusion = 1.5;
|
|
dial_pin_width = 6;
|
|
dial_pin_length = 3;
|
|
// Space between the dial and the keypad
|
|
dial_distance = 5;
|
|
|
|
keys_width = (key_width * keys) + (key_distance * (keys - 1));
|
|
keys_height = key_width;
|
|
plate_width = (plate_margin * 2) + dial_diameter + dial_distance + keys_width;
|
|
plate_height = (plate_margin * 2) + max(dial_diameter, key_width);
|
|
|
|
module support_plate() {
|
|
difference() {
|
|
keyswitch_cutout_offset = (key_width - keyswitch_cutout_width) / 2;
|
|
dial_cutout_offset_x = (dial_diameter - dial_base_width) / 2;
|
|
dial_cutout_offset_y = (dial_diameter - dial_base_height) / 2;
|
|
cube([plate_width, plate_height, plate_thickness]);
|
|
translate([plate_margin, plate_margin, -1]) {
|
|
// Dial cutouts
|
|
translate([(dial_diameter - dial_base_width) / 2,
|
|
(dial_diameter - dial_base_height) / 2]) {
|
|
union() {
|
|
cube([dial_base_width, dial_base_height, plate_thickness + 2]);
|
|
translate([(dial_base_width - dial_pin_width) / 2, - dial_pin_length]) {
|
|
// Provide a 0.5mm-thick lip to hide the pins
|
|
cube([dial_pin_width, dial_base_height + dial_pin_length, plate_thickness + 2 - 1.5]);
|
|
}
|
|
}
|
|
}
|
|
// Key switch cutouts
|
|
offset_y = dial_diameter <= key_width ? 0 : (dial_diameter - key_width) / 2;
|
|
translate([dial_diameter + dial_distance, offset_y]) {
|
|
translate([keyswitch_cutout_offset, keyswitch_cutout_offset + offset_y]) {
|
|
xspread(spacing=key_width + key_distance, n=keys, sp=[0,0,0]) {
|
|
cube([keyswitch_cutout_width, keyswitch_cutout_width, plate_thickness + 2]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
case = [(plate_margin * 2) + dial_diameter + dial_distance + keys_width + (plate_clearance * 2),
|
|
(plate_margin * 2) + max(dial_diameter, key_width) + (plate_clearance * 2),
|
|
wire_clearance + wemos_d1_mini.z + plate_depth];
|
|
|
|
module case() {
|
|
difference() {
|
|
cuboid([case.x + case_thickness * 2,
|
|
case.y + case_thickness * 2,
|
|
case.z + case_thickness],
|
|
center=false,
|
|
fillet=2,
|
|
edges=EDGES_TOP + EDGES_Z_ALL);
|
|
translate([case_thickness,case_thickness, case_thickness]) {
|
|
cube([case.x, case.y, case.z + 1]);
|
|
}
|
|
translate([case.x + case_thickness * 1.5,
|
|
case.y / 2 + case_thickness,
|
|
case_thickness + (usb_thickness / 2)])
|
|
rotate([90,0,90])
|
|
slot(l=12, d=7, h=case_thickness * 2);
|
|
}
|
|
|
|
// Wemos D1 Mini clip
|
|
color("red", 0.1)
|
|
translate([case_thickness + case.x - wemos_d1_mini.y,
|
|
case_thickness + ((case.y - (wemos_d1_mini.x + 4)) / 2),
|
|
case_thickness]) {
|
|
difference() {
|
|
cube([wemos_d1_mini.y, wemos_d1_mini.x + 4,
|
|
wemos_d1_mini.z - esp_thickness + 2]);
|
|
translate([0,1, usb_thickness])
|
|
cuboid([wemos_d1_mini.y,
|
|
wemos_d1_mini.x + 2,
|
|
pcb_thickness + 2],
|
|
center=false,
|
|
chamfer=1,
|
|
edges=EDGES_X_ALL);
|
|
translate([0,2])
|
|
cube([wemos_d1_mini.y, wemos_d1_mini.x,
|
|
usb_thickness]);
|
|
}
|
|
translate([-3,wemos_d1_mini.x / 2 - 3])
|
|
cube([2,9,wemos_d1_mini.z - esp_thickness]);
|
|
}
|
|
|
|
// Supports
|
|
color("purple") {
|
|
// position within the bounds of the case
|
|
translate([case_thickness, case_thickness]) {
|
|
// position within the bounds of the support plate
|
|
translate([plate_clearance, plate_clearance]) {
|
|
// dial support pillar
|
|
// position in the center of the dial
|
|
translate([(plate_margin + dial_diameter / 2) - 2.5,
|
|
(plate_margin + dial_diameter / 2) - 2.5])
|
|
cube([5, 5, case.z - plate_depth - dial_base_protrusion]);
|
|
|
|
// screw pillar
|
|
translate([plate_margin + dial_diameter + (dial_distance / 2),
|
|
case.y / 2]) {
|
|
difference() {
|
|
cylinder(d=6,h=case.z - plate_depth);
|
|
cylinder(d=3,h=case.z - plate_depth);
|
|
}
|
|
}
|
|
}
|
|
|
|
cube([3,3, case.z - plate_depth]);
|
|
translate([0, case.y - 3])
|
|
cube([3,3, case.z - plate_depth]);
|
|
|
|
translate([case.x / 2, 0])
|
|
cube([3,3, case.z - plate_depth]);
|
|
translate([case.x / 2, case.y - 3])
|
|
cube([3,3, case.z - plate_depth]);
|
|
|
|
translate([case.x - 1.5, 0])
|
|
cube([1.5,1.5,case.z - plate_depth]);
|
|
translate([case.x - 1.5, case.y - 1.5])
|
|
cube([1.5,1.5,case.z - plate_depth]);
|
|
|
|
translate([1.5, case_thickness, case.z - plate_depth]) {
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
translate([-4, -4, 0]) {
|
|
case();
|
|
translate([case_thickness, case_thickness, case_thickness]) {
|
|
translate([plate_clearance,
|
|
plate_clearance,
|
|
case.z - plate_thickness - plate_depth]) {
|
|
color("yellow", 0.3) {
|
|
// support_plate();
|
|
}
|
|
}
|
|
color("white", 0.05)
|
|
translate([case.x - wemos_d1_mini.y,
|
|
wemos_d1_mini.x + ((case.y - wemos_d1_mini.x) / 2),
|
|
0])
|
|
rotate([0,0,-90]) {
|
|
// wemos_d1_mini();
|
|
}
|
|
}
|
|
}
|