master
Tomek 2014-02-17 19:38:26 +01:00
commit c3d615dff4
5 changed files with 15327 additions and 0 deletions

14688
Write/Letters.dxf Executable file

File diff suppressed because it is too large Load Diff

378
Write/Write.scad Executable file
View File

@ -0,0 +1,378 @@
/* Version 3
Added support for font selection (default is Letters.dxf)
Added WriteCube module
Added Rotate for text (rotates on the plane of the text)
Added writesphere
Added space= (spacing between characters in char widths) def=1
Added writecylinder()
By Harlan Martin
harlan@sutlog.com
January 2012
(The file TestWrite.scad gives More usage examples)
(This module requires the file Letters.dxf to reside in the same folder)
(The file Letters.dfx was created with inkscape..Each letter is in its own layer)
(This module seperates each letter in the string and imports it from Letters.dfx)
*/
pi=3.1415926535897932384626433832795028841971693993751058209;
pi2=pi*2;
// These control the default values for write() writesphere() writecube()
// if the parameters are not included in the call. Feel free to set your own
// defaults.
//default settings
center=false;
h = 4; //mm letter height
t = 1; //mm letter thickness
space =1; //extra space between characters in (character widths)
rotate=0; // text rotation (clockwise)
font = "/mnt/dysk/roznosci/electronic/libraries/openscad_library/Write/Letters.dxf"; //default for aditional fonts
// write cube defaults
face = "front"; // default face (top,bottom,left,right,back,front)
up =0; //mm up from center on face of cube
down=0;
right =0; //mm left from center on face of cube
left=0;
// write sphere defaults
rounded=false; //default for rounded letters on writesphere
north=0; // intial text position (I suggest leave these 0 defaults)
south=0;
east=0;
west=0;
spin=0;
// writecylinder defaults
middle=0; //(mm toward middle of circle)
ccw=false; //write on top or bottom in a ccw direction
r1=0; //(not implimented yet)
r2=0; //(not implimented yet)
// Contact me if your interested in how to make your own font files
// Its tedious and time consuming, but not very hard
module writecylinder(text,where,radius,height){
wid=(.125* h *5.5 * space);
widall=wid*(len(text)-1)/2;
//angle that measures width of letters on sphere
function NAngle(radius)=(wid/(pi2*radius))*360;
//angle of half width of text
function mmangle(radius)=(widall/(pi2*radius)*360);
if ((face=="top")||(face=="bottom") ){
if (face=="top" ){
if (center==true){
writecircle(text,where+[0,0,height/2],radius-h,rotate=rotate,font=font,h=h,t=t,
space=space,east=east,west=west,middle=middle,ccw=ccw);
}else{
writecircle(text,where+[0,0,height],radius-h,rotate=rotate,font=font,h=h,t=t,
space=space,east=east,west=west,middle=middle,ccw=ccw);
}
}else{
rotate(180,[1,0,0])
if (center==true){
writecircle(text,where+[0,0,height/2],radius-h,rotate=rotate,font=font,h=h,t=t,
space=space,east=east,west=west,middle=middle,ccw=ccw);
}else{
writecircle(text,where+[0,0,0],radius-h,rotate=rotate,font=font,h=h,t=t,
space=space,east=east,west=west,middle=middle,ccw=ccw);
}
}
}else{
// if (radius>0){
if (center==true) {
rotate(-mmangle(radius)*(1-abs(rotate)/90),[0,0,1])
translate(where)
writethecylinder(text,where,radius,height,r1=radius,r2=radius,h=h,
rotate=rotate,t=t,font=font,face=face,up=up,down=down,
east=east,west=west,center=center,space=space,rounded=rounded);
} else{
rotate(-mmangle(radius)*(1-abs(rotate)/90),[0,0,1])
translate(where+[0,0,height/2])
writethecylinder(text,where,radius,height,r1=radius,r2=radius,h=h,
rotate=rotate,t=t,font=font,face=face,up=up,down=down,
east=east,west=west,center=center,space=space,rounded=rounded);
}
// the remarked out code is for cone shaped cylinders (not complete)
// }else{
// if (center==true) {
// rotate(-mmangle(radius)*(1-abs(rotate)/90),[0,0,1])
// translate(where)
// writethecylinder(text,where,radius,height,r1=r1,r2=r2,h=h,
// rotate=rotate,t=t,font=font,face=face,up=up,down=down,
// east=east,west=west,center=center,space=space,rounded=rounded);
// } else{
// rotate(-mmangle(radius)*(1-abs(rotate)/90),[0,0,1])
// translate(where+[0,0,height/2])
// writethecylinder(text,where,radius,height,r1=r1,r2=r2,h=h,
// rotate=rotate,t=t,font=font,face=face,up=up,down=down,
// east=east,west=west,center=center,space=space,rounded=rounded);
// }
// }
}
}
module writecircle(text,where,radius){
wid=(.125* h *5.5 * space);
widall=wid*(len(text)-1)/2;
//angle that measures width of letters on sphere
function NAngle(radius)=(wid/(pi2*radius))*360;
//angle of half width of text
function mmangle(radius)=(widall/(pi2*radius)*360);
if (ccw==true){
rotate(-rotate+east-west,[0,0,1]){
rotate(-mmangle(radius-middle),[0,0,1]){
translate(where)
for (r=[0:len(text)-1]){
rotate(-90+r*NAngle(radius-middle),[0,0,1]) // bottom out=-270+r
translate([radius-middle,0,0])
//rotate(90,[1,0,0])
//rotate(90,[0,1,0])
rotate(-270,[0,0,1]) // flip text (botom out = -270)
write(text[r],center=true,h=h,t=t,font=font);
}
}
}
}else{
rotate(-rotate-east+west,[0,0,1]){
rotate(mmangle(radius-middle),[0,0,1]){
translate(where)
for (r=[0:len(text)-1]){
rotate(90-r*NAngle(radius-middle),[0,0,1]) // bottom out=-270+r
translate([radius-middle,0,0])
//rotate(90,[1,0,0])
//rotate(90,[0,1,0])
rotate(270,[0,0,1]) // flip text (botom out = -270)
write(text[r],center=true,h=h,t=t,font=font);
}
}
}
}
}
module writethecylinder(text,where,radius,height,r1,r2){
wid=(.125* h *5.5 * space);
widall=wid*(len(text)-1)/2;
//angle that measures width of letters on sphere
function NAngle(radius)=(wid/(pi2*radius))*360*(1-abs(rotate)/90);
//angle of half width of text
function mmangle(radius)=(widall/(pi2*radius)*360);
translate([0,0,up-down])
rotate(east-west,[0,0,1])
for (r=[0:len(text)-1]){
rotate(-90+(r*NAngle(radius)),[0,0,1])
translate([radius,0,-r*((rotate)/90*wid)+(len(text)-1)/2*((rotate)/90*wid)])
rotate(90,[1,0,0])
rotate(90,[0,1,0])
write(text[r],center=true,h=h,rotate=rotate,t=t,font=font);
//echo("zloc=",height/2-r*((rotate)/90*wid)+(len(text)-1)/2*((rotate)/90*wid));
}
}
module writesphere(text,where,radius){
wid=(.125* h *5.5 * space);
widall=wid*(len(text)-1)/2;
echo("-----------------",widall,wid,mmangle(radius));
//angle that measures width of letters on sphere
function NAngle(radius)=(wid/(pi2*radius))*360;
//angle of half width of text
function mmangle(radius)=(widall/(pi2*radius)*360);
rotate(east-west,[0,0,1]){
rotate(south-north,[1,0,0]){
rotate(spin,[0,1,0]){
rotate(-mmangle(radius),[0,0,1]){
if ( rounded== false ){
translate(where)
for (r=[0:len(text)-1]){
rotate(-90+r*NAngle(radius),[0,0,1])
translate([radius,0,0])
rotate(90,[1,0,0])
rotate(90,[0,1,0])
write(text[r],center=true,h=h,rotate=rotate,t=t,font=font);
}
}else{
difference(){
translate(where)
for (r=[0:len(text)-1]){
rotate(-90+r*NAngle(radius),[0,0,1])
translate([radius,0,0])
rotate(90,[1,0,0])
rotate(90,[0,1,0])
write(text[r],center=true,h=h,rotate=rotate,t=t*2+h,font=font);
}
difference(){ //rounded outside
sphere(radius+(t*2+h)*2);
sphere(radius+t/2);
}
sphere(radius-t/2); // rounded inside for indented text
}
}
}
}}}
}
module writecube(text,where,size){
if (str(size)[0] != "["){
// its a square cube (size was not a matrix so make it one)
writethecube(text,where,[size,size,size],h=h,rotate=rotate,space=space,
t=t,font=font,face=face,up=up,down=down,right=right,left=left);
}else{
// its not square
writethecube(text,where,size,h=h,rotate=rotate,space=space,
t=t,font=font,face=face,up=up,down=down,right=right,left=left);
}
}
// I split the writecube module into 2 pieces.. easier to add features later
module writethecube(text,where,size){
if (face=="front") {
translate([where[0]+right-left,where[1]-size[1]/2,where[2]+up-down])
rotate(90,[1,0,0])
write(text,center=true,h=h,rotate=rotate,t=t,font=font);
}
if (face=="back") {
translate([where[0]+right-left,where[1]+size[1]/2,where[2]+up-down])
rotate(90,[1,0,0]) // rotate around the x axis
rotate(180,[0,1,0]) // rotate around the y axis (z before rotation)
write(text,center=true,h=h,rotate=rotate,t=t,font=font);
}
if (face=="left") {
translate([where[0]-size[0]/2,where[1]-right+left,where[2]+up-down ])
rotate(90,[1,0,0]) // rotate around the x axis
rotate(90,[0,-1,0]) // rotate around the y axis (z before rotation)
write(text,center=true,h=h,rotate=rotate,t=t,font=font);
}
if (face=="right") {
translate([where[0]+size[0]/2,where[1]+right-left,where[2] +up-down])
rotate(90,[1,0,0]) // rotate around the x axis
rotate(90,[0,1,0]) // rotate around the y axis (z before rotation)
write(text,center=true,h=h,rotate=rotate,t=t,font=font);
}
if (face=="top") {
translate([where[0]+right-left,where[1]+up-down,where[2]+size[2]/2 ])
write(text,center=true,h=h,rotate=rotate,t=t,font=font);
}
if (face=="bottom") {
translate([where[0]+right-left,where[1]-up+down,where[2]-size[2]/2 ])
rotate(180,[1,0,0])
write(text,center=true,h=h,rotate=rotate,t=t,font=font);
}
}
module write(word){
echo (h);
echo (word);
echo ("There are " ,len(word) ," letters in this string");
// echo ("The second letter is ",word[1]);
// echo (str(word[0],"_"));
rotate(rotate,[0,0,-1]){
for (r = [0:len(word)]){ // count off each character
// if the letter is lower case, add an underscore to the end for file lookup
if ((word[r] == "a" ) || (word[r]== "b") || (word[r]== "c")
|| (word[r]== "d") || (word[r]== "e") || (word[r]== "f")
|| (word[r]== "g") || (word[r]== "h") || (word[r]== "i")
|| (word[r]== "j") || (word[r]== "k") || (word[r]== "l")
|| (word[r]== "m") || (word[r]== "n") || (word[r]== "o")
|| (word[r]== "p") || (word[r]== "q") || (word[r]== "r")
|| (word[r]== "s") || (word[r]== "t") || (word[r]== "u")
|| (word[r]== "v") || (word[r]== "w") || (word[r]== "x")
|| (word[r]== "y" )|| (word[r]== "z")){
if (center == true) {
translate([0,-h/2,0]){
scale([.125*h,.125*h,t]){
translate([ (-len(word)*5.5*space/2) + (r*5.5*space),0,0])
linear_extrude(height=1,convexity=10,center=true){
import(file = font,layer=str(word[r],"_"));
}
}
}
}else{
translate([0,0,t/2]){
scale([.125*h,.125*h,t]){
translate([r*5.5*space,0,0])
linear_extrude(height=1,convexity=10,center=true){
import(file = font,layer=str(word[r],"_"));
}
}
}
}
}else{
if (center == true) {
translate([0,-h/2,0]){
scale([.125*h,.125*h,t]){
translate([ (-len(word)*5.5*space/2) + (r*5.5*space),0,0])
linear_extrude(height=1,convexity=10,center=true){
import(file = font,layer=str(word[r]));
}
}
}
}else{
translate([0,0,t/2]){
scale([.125*h,.125*h,t]){
translate([r*5.5*space,0,0])
linear_extrude(height=1,convexity=10,center=true){
import(file = font,layer=str(word[r]));
}
}
}
}
}
}
}
}
/*writecylinder test
translate([0,0,0])
%cylinder(r=20,h=40,center=true);
color([1,0,0])
writecylinder("rotate=90",[0,0,0],20,40,center=true,down=0,rotate=90);
writecylinder("rotate = 30,east = 90",[0,0,0],20,40,center=true,down=0,rotate=30,east=90);
writecylinder("ccw = true",[0,0,0],20,40,center=true,down=0,face="top",ccw=true);
writecylinder("middle = 8",[0,0,0],20,40,h=3,center=true,down=0,face="top",middle=8);
writecylinder("face = top",[0,0,0],20,40,center=true,down=0,face="top");
writecylinder("east=90",[0,0,0],20,40,h=3,center=true,down=0,face="top",east=90);
writecylinder("west=90",[0,0,0],20,40,h=3,center=true,down=0,face="top",ccw=true,west=90);
writecylinder("face = bottom",[0,0,0],20,40,center=true,down=0,face="bottom");
*/
/*writesphere test
sphere(20);
color([1,0,0])
writesphere("Hello World",[0,0,0],20,t=1,h=6);
*/
/* writecube test
translate([30,30,30])
cube([10,15,30],center=true);
write("hello",center=true,rotate =30);
color([1,0,0])
writecube( "front",[30,30,30],[10,15,30],h=5,rotate=-90);
color([0,1,0])
writecube( "back",[30,30,30],size=[10,15,30],h=5,face="back",rotate=90,t=4);
color([0,0,1])
writecube( "left",[30,30,30],[10,15,30],h=5,face="left",up=5);
color([1,1,0])
writecube( "right",where=[30,30,30],size=[10,15,30],h=5,face="right",rotate=55);
color([1,0,1])
writecube( "top",where=[30,30,30],size=[10,15,30],h=5,face="top");
color([1,1,1])
writecube( "bttm",where=[30,30,30],size=[10,15,30],h=5,face="bottom",rotate=90);
*/

95
obudowy/keyboard.scad Normal file
View File

@ -0,0 +1,95 @@
//klawisze
//Blblioteka do tesktu
include <Write/Write.scad>
//definicje
key_ar=1.5; //aspect ratio owalnego klawisza
//standardowy okrągły klawisz
module stdKey(height,radius,text="A")
{
translate([0,0,1])
{
difference()
{
//klawisz
cylinder(h=height,r=radius);
//tekst na klawiszu
translate([0,0,height])
write(text,h=radius,center=true,t=1);
}
}
//spód
cylinder(h=1,r=radius+2);
}
//strzałka
module stdArrowKey(height,radius)
{
translate([0,0,1])
{
difference()
{
//klawisz
oval_prism(height=height,rx=radius,ry=radius*key_ar);
//strzałka na klawiszu
translate([0,0,height])
{
cube([radius*key_ar,1,1],center=true);
translate([radius*key_ar/2+sqrt(2)/2,0,-0.5])
rotate([0,0,135])
cube([radius*key_ar/2,1,1],center=false);
translate([radius*key_ar/2,++sqrt(2)/2,-0.5])
rotate([0,0,-135])
cube([radius*key_ar/2,1,1],center=false);
}
}
}
//spód
oval_prism(height=1,rx=radius+2,ry=radius*key_ar+2);
}
//podstawowa klawiatura : klawisze strzałek + OK i ANULUJ
module stdKeyb()
{
//strzałki
for(i=[0:3])
rotate([0,0,90*i])
translate([15,0,0])
stdArrowKey(height=6,radius=4.75);
//ok
translate([40,15,0])
stdKey(height=6,radius=9.75,text="OK");
//cancel
translate([40,-15,0])
stdKey(height=6,radius=9.75,text="C");
}
//wycięcie pod klawiaturę
module stdKeybCutout(pos)
{
translate(pos)
rotate([0,180,0])
{
//strzałki
for(i=[0:3])
rotate([0,0,90*i])
translate([15,0,0])
stdArrowKey(height=6,radius=5);
//ok
translate([40,15,0])
stdKey(height=6,radius=10,text="OK");
//cancel
translate([40,-15,0])
stdKey(height=6,radius=10,text="C");
}
}

39
obudowy/mounting.scad Normal file
View File

@ -0,0 +1,39 @@
//kołek pod śruby
module stdScrewStandoff(screw_diameter,depth,height)
{
screw_radius=screw_diameter/2;
difference()
{
//materiał
cylinder(h=height,r=screw_radius+2);
//dziura
translate([0,0,height-depth])
cylinder(h=depth+1,r=screw_radius);
}
}
// 4 kołki pod pcb
module stdPcbMounting4x(screw_diameter,size,height)
{
//dla każdego rogu płytki:
for(i=[0,1])
for(j=[0,1])
translate([i*size[0],j*size[1]])
{
//kołek
stdScrewStandoff(screw_diameter,height,height);
}
}
// 2 kołki pod pcb
module stdPcbMounting2x(screw_diameter,size,height)
{
//dla każdego rogu płytki:
for(i=[0,1])
translate([i*size,0])
{
//kołek
stdScrewStandoff(screw_diameter,height,height);
}
}

127
obudowy/obudowy.scad Normal file
View File

@ -0,0 +1,127 @@
// Użyj pudełek z mcada do zaokrągleń
include<MCAD/boxes.scad>
include <MCAD/regular_shapes.scad>
//definicje
stdScrewDiameter=3;
//wycięcie pod śruby+łby
module stdScrewCutWithPhase(screw_diameter,height)
{
screw_radius=screw_diameter/2;
//otwór na śrubę
cylinder(h=height,r=screw_radius*1.1);
//faza
cylinder(h=screw_radius,r2=screw_radius*1.1,r1=screw_radius*2);
//duży cylinder nad razą - żeby wyciąć
translate([0,0,-1])
cylinder(h=1.01,r=screw_radius*2);
}
//wycięcie pod ekran
module stdScreenCutout(pos,size)
{
if(size[0] > size[1])
{
translate([pos[0]+(size[0]/2),pos[1]+(size[1]/2),0])
square_pyramid(size[0],size[1],size[1]);
}
else
{
translate([pos[0]+(size[0]/2),pos[1]+(size[1]/2),0])
square_pyramid(size[0],size[1],size[0]);
}
}
// standardowe pudełko, częśc dolna
// size - wymiary, wektor [l,w,h]
// thickness - grubość ścianek
module stdBox(size,thickness)
{
inner_cutout = size-[thickness*2,thickness*2,0];
standoff_height=size[2]-thickness;
//pudełko
difference()
{
//baza dla pudełka
cube(size);
//wytnij środek
translate([thickness,thickness,thickness])
cube(inner_cutout);
}
//mocowanie - x4 śruby
for(i=[0,1])
for(j=[0,1])
{
translate([stdScrewDiameter*2+i*(size[0]-stdScrewDiameter*4),stdScrewDiameter*2+j*(size[1]-stdScrewDiameter*4),thickness])
stdScrewStandoff(stdScrewDiameter,standoff_height-2,standoff_height);
}
//wzmocnienia
}
// standardowe pudełko, częśc gorna (klapka)
// size - wymiary, wektor [l,w,h]
// thickness - grubość ścianek
module stdCover(size,thickness)
{
inner_cutout = size-[thickness*2,thickness*2,0];
standoff_height=size[2]-thickness;
//klapka
difference()
{
//baza dla pudełka
cube(size);
//wytnij środek
translate([thickness,thickness,thickness])
cube(inner_cutout);
//wytnij otwory pod 4 śruby
for(i=[0,1])
for(j=[0,1])
translate([stdScrewDiameter*2+i*(size[0]-stdScrewDiameter*4),stdScrewDiameter*2+j*(size[1]-stdScrewDiameter*4),0])
stdScrewCutWithPhase(stdScrewDiameter,10);
}
}
// pudełko z zaokrąglonymi rogami, częśc dolna
// size - wymiary, wektor [l,w,h]
// thickness - grubość ścianek
// radius - promień zaokrąglenia
module roundEdgesBox(size,thickness,radius)
{
// aby zaokrąglenie uwzględniało pokrywkę
//robię pudełko wyższe o thickness a potem obcinam o thickness od góry
outer_size = size + [0,0,thickness];
inner_cutout = outer_size-[thickness*2,thickness*2,0];
standoff_height=size[2]-thickness;
difference()
{
//baza dla pudełka
translate(outer_size/2)
roundedBox(outer_size,radius);
//wytnij środek
translate([thickness,thickness,thickness])
translate(inner_cutout/2)
roundedBox(inner_cutout,radius);
//przytnij górę
translate([-1,-1,size[2]])
cube(size+[2,2,2]);
}
//mocowanie - x4 śruby
for(i=[0,1])
for(j=[0,1])
translate([stdScrewRadius*2+i*(size[0]-stdScrewRadius*4),stdScrewRadius*2+j*(size[1]-stdScrewRadius*4),thickness])
stdScrewStandoff(stdScrewRadius,standoff_height-2,standoff_height);
}