279 lines
8.4 KiB
OpenSCAD
279 lines
8.4 KiB
OpenSCAD
$fn = 32;
|
|
|
|
$space = 3;
|
|
$width = 15.5;
|
|
$length = $width;
|
|
$height = 1;
|
|
$holes = $height*4;
|
|
$cut = $holes/2*-1;
|
|
$clearance = 0.2;
|
|
$switchDistance = $width+ $space;
|
|
|
|
// shell width is set to double of actual shell width and results in haft of the actual value due to division by 2.
|
|
// this needs to be fixed
|
|
$shellWidth = 12;
|
|
$shellHeight = 3.5 + $clearance;
|
|
|
|
|
|
|
|
$columns = 6;
|
|
$rows = 5;
|
|
|
|
$fingerStep = 5;
|
|
|
|
$xBase = (($width + $space) * $columns) + $space;
|
|
$yBase = (($length + $space) * $rows) + $space;
|
|
|
|
$pcbHeight = 1.6;
|
|
$dampenerHeight = 1;
|
|
|
|
$pcbDampenerOffset = $pcbHeight + $dampenerHeight;
|
|
|
|
points = [
|
|
[0,0],
|
|
[0, $switchDistance * $rows],
|
|
[$switchDistance * 2, $switchDistance * $rows],
|
|
[$switchDistance * 2, $switchDistance * $rows + $fingerStep],
|
|
[$switchDistance * 3, $switchDistance * $rows + $fingerStep],
|
|
[$switchDistance * 3, $switchDistance * $rows],
|
|
[$switchDistance * 4, $switchDistance * $rows],
|
|
[$switchDistance * 4, $switchDistance * $rows - $fingerStep],
|
|
[$switchDistance * 6, $switchDistance * $rows - $fingerStep],
|
|
[$switchDistance * 6, 0 - $fingerStep],
|
|
[$switchDistance * 4, 0 - $fingerStep],
|
|
[$switchDistance * 4, 0],
|
|
[$switchDistance * 3, 0],
|
|
[$switchDistance * 3, 0 + $fingerStep],
|
|
[$switchDistance * 2, 0 + $fingerStep],
|
|
[$switchDistance * 2, 0],
|
|
];
|
|
|
|
picoUsbBody = [8, 5.66, 2.65];
|
|
|
|
module pin(){
|
|
cylinder(h=$holes, r=1, center=false);
|
|
}
|
|
|
|
module switch($diodesTop = false){
|
|
$xCenter = $width/2;
|
|
$yCenter = $length/2;
|
|
translate([$xCenter, $yCenter, 0])
|
|
cylinder(h=$holes, r=2.522, center=false);
|
|
translate([$xCenter + 0, $yCenter + 5.9,0])
|
|
pin();
|
|
translate([$xCenter + 5, $yCenter + 3.8,0])
|
|
pin();
|
|
translate([$xCenter + -5, $yCenter + 3.8,0])
|
|
pin();
|
|
translate([$xCenter + -5, $yCenter + -5.15,0])
|
|
pin();
|
|
translate([$xCenter + 5, $yCenter+-5.15,0])
|
|
pin();
|
|
translate([0, $length + 1.4, 0]);
|
|
$dDistanceFromCenter = $switchDistance/2;
|
|
$dWidth = 10.95;
|
|
$dHeight = 1.8;
|
|
if ($diodesTop){
|
|
translate([$xCenter - ($dWidth/2), $yCenter + $dDistanceFromCenter - ($dHeight/2), 0]){
|
|
cube([$dWidth, $dHeight, $holes]);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
module switchColumn(){
|
|
difference() {
|
|
translate([-($space/2), -($space/2)])
|
|
cube([$switchDistance, $switchDistance * $rows, $height]);
|
|
for (y=[0:$rows-1]){
|
|
translate([0 * ($width + $space) ,y * ($length+$space) ,0]) {
|
|
switch(y<3);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
module rightTopDampener(){
|
|
union(){
|
|
switchColumn();
|
|
translate([$switchDistance,0,0])
|
|
switchColumn();
|
|
translate([$switchDistance * 2,5,0])
|
|
switchColumn();
|
|
translate([$switchDistance * 3,0,0])
|
|
switchColumn();
|
|
translate([$switchDistance * 4,-5,0])
|
|
switchColumn();
|
|
translate([$switchDistance * 5,-5,0])
|
|
switchColumn();
|
|
}
|
|
}
|
|
|
|
module leftTopDampener(){
|
|
rotate([0,180,0]){
|
|
rightTopDampener();
|
|
}
|
|
}
|
|
|
|
|
|
module topDampeners(){
|
|
translate([1.5,1.5,0]){
|
|
rightTopDampener();
|
|
}
|
|
//translate([-10,0,0]){
|
|
//leftTopDampener();
|
|
//}
|
|
}
|
|
|
|
module case(){
|
|
// Then adjust the shim, aux and pico.
|
|
// Last add magnets, don't forget the clearance.
|
|
$baseHeight = 7.6;
|
|
|
|
module magnets(){
|
|
$magnetWidth = 4;
|
|
$magnetRadius = ($magnetWidth / 2) + $clearance/2;
|
|
$magnetHeight = 2 + $clearance;
|
|
$offset = ($shellWidth / 2 / 2) -0.8 ;
|
|
// Set Z-origin to align with shell top
|
|
translate([0, 0, $shellHeight -$magnetHeight]){
|
|
translate(points[0] + [-$offset, -$offset])
|
|
cylinder(h=$magnetHeight, r=$magnetRadius);
|
|
translate(points[1] + [-$offset, $offset])
|
|
cylinder(h=$magnetHeight, r=$magnetRadius);
|
|
translate(points[8] + [$offset, $offset])
|
|
cylinder(h=$magnetHeight, r=$magnetRadius);
|
|
translate(points[9] + [$offset, -$offset])
|
|
cylinder(h=$magnetHeight, r=$magnetRadius);
|
|
}
|
|
}
|
|
module aux(){
|
|
$topLeftOfPcbToCenterOfAux = 15.4;
|
|
$measurementPcbPlaneToCenterOfAux = 2.8;
|
|
$auxClearanceFromBase = $measurementPcbPlaneToCenterOfAux - $dampenerHeight;
|
|
$auxHoleRadius = 3.15;
|
|
$auxHoleLength = 17 + $shellWidth/2;
|
|
$auxCableRadius = 4.15;
|
|
// Move to the position along the wall the aux will be
|
|
translate([-($shellWidth/2 + $clearance),$switchDistance * $rows - $topLeftOfPcbToCenterOfAux,-$auxClearanceFromBase])
|
|
// Make cylinder perpendicular with the wall
|
|
rotate([0,90,0]){
|
|
// Aux component clearance
|
|
cylinder(h=$auxHoleLength,r=$auxHoleRadius);
|
|
// Aux cable housing clearance
|
|
cylinder(h=$shellWidth/2,r=$auxCableRadius );
|
|
}
|
|
}
|
|
//TODO: Continue aligning pico clearance
|
|
module pico(){
|
|
$topLeftEdgeOfPcbToCenterOfUsb = 27.7;
|
|
$usbHoleWidth = 11.15+($clearance*2);
|
|
$usbHoleHeight = 7 + ($clearance *2);
|
|
$usbOffsetFromPcb = 4.1 - $pcbHeight;
|
|
$picoPcbClearanceFromBase = 5.4 - $pcbHeight;
|
|
$picoWidth = 25;
|
|
$picoLength = 53;
|
|
// Move to position along the wall the usb will be
|
|
// Hole should be centered on the pico usb
|
|
translate([
|
|
$topLeftEdgeOfPcbToCenterOfUsb - ($usbHoleWidth/2),
|
|
$switchDistance * $rows,
|
|
-$usbOffsetFromPcb - (($usbHoleHeight - picoUsbBody.z )/2)
|
|
]){
|
|
// Create a hole for the usb cable to go through
|
|
cube([
|
|
$usbHoleWidth,
|
|
$shellWidth,
|
|
$usbHoleHeight
|
|
]);
|
|
// Move inside the shell, nullify the usb clearance from pcb and move down according to pico clearance
|
|
translate([
|
|
-(($picoWidth - $usbHoleWidth)/2),
|
|
$clearance - $picoLength,
|
|
+$usbOffsetFromPcb - $picoPcbClearanceFromBase
|
|
])
|
|
// Make clearance downwards for the pico board
|
|
cube([
|
|
$picoWidth,
|
|
$picoLength,
|
|
$picoPcbClearanceFromBase + $clearance
|
|
]);
|
|
}
|
|
}
|
|
module shim(){
|
|
$shimPoints = [
|
|
[0 - $shellWidth / 2, - $baseHeight],
|
|
[$switchDistance * $columns + $shellWidth/2 + $clearance, -$clearance],
|
|
[$switchDistance * $columns + $shellWidth/2 + $clearance, - ($baseHeight + $clearance)]
|
|
];
|
|
// Face z/x-plane
|
|
rotate([90,0,0])
|
|
// Move in front of model on the y-axis
|
|
translate([0,0,-500])
|
|
// Extrude it through the case
|
|
linear_extrude(99999)
|
|
polygon($shimPoints);
|
|
}
|
|
module body(){
|
|
union() {
|
|
linear_extrude($shellHeight){
|
|
difference(){
|
|
offset(r=$shellWidth/2 + $clearance, chamfer=true) polygon(points);
|
|
offset(r=$clearance) polygon(points);
|
|
}
|
|
}
|
|
translate([0,0,-$baseHeight])
|
|
linear_extrude($baseHeight){
|
|
offset(r=$shellWidth/2 + $clearance, chamfer=true) polygon(points);
|
|
}
|
|
}
|
|
}
|
|
|
|
difference(){
|
|
body();
|
|
shim();
|
|
pico();
|
|
aux();
|
|
magnets();
|
|
}
|
|
}
|
|
module pcb() {
|
|
jackBody = [15,6.15,5.3];
|
|
picoBody = [21, 51.5, 1];
|
|
module jack() {
|
|
translate([0,jackBody.y/2, jackBody.z/2])
|
|
rotate([0,90])
|
|
cylinder(r=2, h=2.2);
|
|
translate([2.2,0,0])
|
|
color("#333")
|
|
cube(jackBody);
|
|
|
|
}
|
|
module pcbPico(){
|
|
translate([0,-1.6,0])
|
|
color("#00aa00")
|
|
cube(picoBody);
|
|
translate([(picoBody.x - picoUsbBody.x)/2, picoBody.y - picoUsbBody.y, -picoUsbBody.z])
|
|
color("#666")
|
|
cube(picoUsbBody);
|
|
}
|
|
translate([0,0,$dampenerHeight]) {
|
|
color("#008800")
|
|
linear_extrude($pcbHeight)
|
|
polygon(points);
|
|
translate(points[1] + [0, -12.3 - jackBody.y])
|
|
translate([0,0,-jackBody.z])
|
|
color("#333")
|
|
jack();
|
|
translate(points[1] + [27.7 - picoBody.x/2, -picoBody.y])
|
|
translate([0,0,-picoBody.z])
|
|
pcbPico();
|
|
}
|
|
|
|
|
|
}
|
|
|
|
%pcb();
|
|
%topDampeners();
|
|
case();
|