|
|
|
@ -10,21 +10,27 @@ pitch=2.54; // pin pitch
|
|
|
|
|
|
|
|
|
|
body=[(n_switches+0.5)*pitch, 3*pitch, 1.5*pitch];
|
|
|
|
|
height=pitch/8; // body above z axis
|
|
|
|
|
color_body="maroon";
|
|
|
|
|
|
|
|
|
|
swhole=[pitch*0.5,pitch,pitch*0.5];
|
|
|
|
|
button=[pitch*0.4,pitch*0.4,pitch*0.5];
|
|
|
|
|
color_button="white";
|
|
|
|
|
|
|
|
|
|
font = "Liberation Sans";
|
|
|
|
|
letter_size = pitch/2;
|
|
|
|
|
letter_height = pitch/16;
|
|
|
|
|
color_letter="white";
|
|
|
|
|
|
|
|
|
|
module letter(l)
|
|
|
|
|
color_pin="white";
|
|
|
|
|
|
|
|
|
|
module letter(l,scale=1)
|
|
|
|
|
{
|
|
|
|
|
// Use linear_extrude() to make the letters 3D objects as they
|
|
|
|
|
// are only 2D shapes when only using text()
|
|
|
|
|
linear_extrude(height = letter_height)
|
|
|
|
|
linear_extrude(height = letter_height*scale)
|
|
|
|
|
{
|
|
|
|
|
text(l, size = letter_size, font = font, halign = "center", valign = "center", $fn = 16);
|
|
|
|
|
text(l, size = letter_size*scale, font = font, halign = "center",
|
|
|
|
|
valign = "center", $fn = 16);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -35,6 +41,23 @@ module pin_smd()
|
|
|
|
|
cube([pitch/3,pitch*0.75,pitch/4],center=true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module inscription(scale=1)
|
|
|
|
|
{
|
|
|
|
|
translate([
|
|
|
|
|
(0-n_switches/2+0.5)*pitch,
|
|
|
|
|
body[1]/2-letter_size,
|
|
|
|
|
body[2]/2-letter_height*scale])
|
|
|
|
|
letter("ON");
|
|
|
|
|
for(i = [0:n_switches-1])
|
|
|
|
|
{
|
|
|
|
|
translate([
|
|
|
|
|
(i-n_switches/2+0.5)*pitch,
|
|
|
|
|
-body[1]/2+letter_size,
|
|
|
|
|
body[2]/2-letter_height*scale])
|
|
|
|
|
letter(chr(48+(i+1)%10));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module dipsw_smd()
|
|
|
|
|
{
|
|
|
|
|
translate([0,0,body[2]/2+height]) // little above
|
|
|
|
@ -43,43 +66,50 @@ module dipsw_smd()
|
|
|
|
|
// cut off holes for switches
|
|
|
|
|
difference()
|
|
|
|
|
{
|
|
|
|
|
color("maroon")
|
|
|
|
|
color(color_body)
|
|
|
|
|
cube(body,center=true);
|
|
|
|
|
// holes for switches
|
|
|
|
|
for(i = [0:n_switches-1])
|
|
|
|
|
{
|
|
|
|
|
color("maroon")
|
|
|
|
|
translate([(i-n_switches/2+0.5)*pitch,0,body[2]/2-swhole[2]/2+0.01])
|
|
|
|
|
translate([(i-n_switches/2+0.5)*pitch,0,body[2]/2-swhole[2]/2+0.02])
|
|
|
|
|
color(color_body)
|
|
|
|
|
cube(swhole,center=true);
|
|
|
|
|
}
|
|
|
|
|
// cut off space for letters
|
|
|
|
|
if(0)
|
|
|
|
|
translate([0,0,0.1])
|
|
|
|
|
color(color_body)
|
|
|
|
|
inscription(scale=1.1);
|
|
|
|
|
}
|
|
|
|
|
// place the switch buttons and letters
|
|
|
|
|
// place letters
|
|
|
|
|
translate([0,0,0.1])
|
|
|
|
|
color(color_letter)
|
|
|
|
|
inscription();
|
|
|
|
|
// buttons
|
|
|
|
|
for(i = [0:n_switches-1])
|
|
|
|
|
{
|
|
|
|
|
translate([(i-n_switches/2+0.5)*pitch,swhole[1]/2-button[1]/2-(swhole[0]-button[0])/2,body[2]/2-button[2]/2+0.01])
|
|
|
|
|
color("white")
|
|
|
|
|
translate([(i-n_switches/2+0.5)*pitch,swhole[1]/2-button[1]/2-(swhole[0]-button[0])/2,body[2]/2-button[2]/2+0.1])
|
|
|
|
|
color(color_pin)
|
|
|
|
|
cube(button,center=true);
|
|
|
|
|
translate([(i-n_switches/2+0.5)*pitch,-body[1]/2+letter_size,body[2]/2])
|
|
|
|
|
color("white")
|
|
|
|
|
letter(chr(48+(i+1)%10));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// text "ON"
|
|
|
|
|
translate([(0-n_switches/2+0.5)*pitch, body[1]/2-letter_size,body[2]/2])
|
|
|
|
|
color("white")
|
|
|
|
|
letter("ON");
|
|
|
|
|
// pin 1 mark
|
|
|
|
|
translate([(-body[0])/2+pitch/3,-body[1]/2+pitch/2,body[2]/2])
|
|
|
|
|
color(color_letter)
|
|
|
|
|
cylinder(r=pitch/8,h=0.1,$fn=6);
|
|
|
|
|
|
|
|
|
|
// the pins
|
|
|
|
|
for(i = [0:n_switches-1])
|
|
|
|
|
{
|
|
|
|
|
// pins
|
|
|
|
|
for(j = [-1:2:1])
|
|
|
|
|
translate([(i-n_switches/2+0.5)*pitch, j*(body[1]/2+pitch*0.75/2),-body[2]/2-height+pitch/8])
|
|
|
|
|
color("white")
|
|
|
|
|
cube([pitch/3,pitch*0.75,pitch/4],center=true);
|
|
|
|
|
translate([(i-n_switches/2+0.5)*pitch, j*(body[1]/2+pitch*0.6/2),-body[2]/2-height+pitch/8])
|
|
|
|
|
color(color_pin)
|
|
|
|
|
cube([pitch/3,pitch*0.6,pitch/4],center=true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//scale(1/2.54) // required scale for KiCAD VRML file dipswitch_smd.wrl
|
|
|
|
|
scale(1/2.54) // required scale for KiCAD VRML file dipswitch_smd.wrl
|
|
|
|
|
// rotate([0,0,90])
|
|
|
|
|
dipsw_smd();
|
|
|
|
|