diff --git a/bits.scad b/bits.scad index 7313b8c..9a5cd5b 100644 --- a/bits.scad +++ b/bits.scad @@ -1,48 +1,60 @@ -module Volume() +include +use + +module Volume_(Depth) { - hull() { - translate([10,0,0])cylinder(d=5, h=5); - translate([-10,0,0])cylinder(d=5, h=5); - } + cube([Depth, VolumeLength, VolumeHeight], center=false); +} +module Volume(Depth) +{ + translate([BodyWidth, VolumeMinY, VolumeMinZ])Volume_(Depth); } -module Power() +module Power_(Depth) { - hull() { - translate([5,0,0])cylinder(d=5, h=5); - translate([-5,0,0])cylinder(d=5, h=5); - } + cube([Depth, PowerLength, PowerHeight], center=false); +} +module Power(Depth) +{ + translate([BodyWidth, PowerMinY, PowerMinZ])Power_(Depth); } -module Camera() +module Camera_(Depth) { - hull() { - translate([0,10,0])cylinder(d=10, h=5); - translate([0,-10,0])cylinder(d=10, h=5); - } + cube([CameraWidth, CameraLength, Depth], center=false); +} +module Camera(Depth) +{ + translate([CameraMinX, CameraMinY, -Depth])Camera_(Depth); } -module Speaker() +module Usb_(Depth) { - hull() { - translate([0,5,0])cylinder(d=5, h=5); - translate([0,25,0])cylinder(d=5, h=5); - } - hull() { - translate([0,-5,0])cylinder(d=5, h=5); - translate([0,-25,0])cylinder(d=5, h=5); - } + cube([UsbWidth, Depth, UsbHeight], center=false); +} +module Usb(Depth) +{ + translate([BodyWidth/2 - UsbWidth/2, BodyLength-Depth, UsbMinZ])Usb_(Depth); } -module Usb() +module Aux_(Depth) { - hull() { - translate([0,5,0])cylinder(d=5, h=5); - translate([0,-5,0])cylinder(d=5, h=5); - } + translate([3.5/2, 0, 0])cylinderY(d=3.5, h=Depth); +} +module Aux(Depth) +{ + translate([AuxMinX, 0, AuxMinZ])Aux_(Depth); } -module Microphone() -{ - cylinder(d=3, h=5); -} +// module Speaker() +// { +// hull() { +// translate([0,5,0])cylinder(d=5, h=5); +// translate([0,25,0])cylinder(d=5, h=5); +// } +// hull() { +// translate([0,-5,0])cylinder(d=5, h=5); +// translate([0,-25,0])cylinder(d=5, h=5); +// } +// } + diff --git a/dimensions.scad b/dimensions.scad index ab35cbb..2288b91 100644 --- a/dimensions.scad +++ b/dimensions.scad @@ -1,5 +1,40 @@ -Length=160.5; -Width=76.6; -Height=9.2; +// all measurements in mm +// +// x = width +// y = length = the longest axis of the phone +// z = height = the shortest axis of the phone +// +// (0, 0, 0) = top-left of the front of the phone. +// i.e. the screen is defined to be at z=0. +// phone body +BodyLength=160.5; +BodyWidth=76.6; +BodyHeight=9.2; +BodyRadXY=9.6; +BodyRadFrontZ=1.8; +// offset from top of phone to top of volume button +VolumeMinY=26.0; +VolumeMinZ=3.5; +VolumeLength=19.8; +VolumeHeight=2.0; + +// offset from top of phone to the top of power button +PowerMinY=53.0; +PowerMinZ=3.5; +PowerLength=10.0; +PowerHeight=2.0; + +// offset from left edge of phone to left edge of 3.5mm audio jack +AuxMinX=23.0; +AuxMinZ=4.1; + +UsbWidth=9.0; +UsbHeight=3.5; +UsbMinZ=5.1; + +CameraMinY=4.0; +CameraMinX=41.6; +CameraWidth=22.0; +CameraLength=10.0; diff --git a/phone.scad b/phone.scad index 49f054d..f65cae5 100644 --- a/phone.scad +++ b/phone.scad @@ -1,26 +1,57 @@ include use +use $fs = 1; -module phone (Pad=0, Bits=0) -{ - minkowski() { - cube([Length-Height+0.2, Width-Height+0.2, 0.2], true); - sphere(d=(Height-0.2)+Pad); - } - if(Bits != 0) { - // add holes for buttons and other things - translate([-50,Width/2+4,0]) rotate([90,0,0]) Volume(); - translate([-25,Width/2+4,0]) rotate([90,0,0]) Power(); - translate([-70,-17,-Height/2-4]) Camera(); - translate([70,0,-Height/2-4]) Speaker(); - translate([Length/2,0,0]) rotate([0,90,0]) Usb(); - translate([Length/2,20,0]) rotate([0,90,0]) Microphone(); - } +Tol = 0.1; + +// simple box-shaped body; preserve for easier debugging +module BodyBox() { + cube([BodyWidth, BodyLength, BodyHeight], center=false); } -//%cube([Length, Width, Height], true); -phone(Bits=1); -%phone(4); +// return the kernel which can be convolved with the box body to produce the actual body +module BodyConvolve(Tol=Tol) { + minkowski() { + // cylinder rounds the four corners of the phone + cylinder(r=BodyRadXY-BodyRadFrontZ, h=Tol, center=true); + // sphere rounds the thickness of the phone + // in actuality this shouldn't be symmetric (the screen and back cover have different radii), + // but using a single radius is Good Enough + sphere(r=BodyRadFrontZ); + // cylinderY(r=BodyRadFrontZ, h=Tol, center=true); + // cylinderX(r=BodyRadFrontZ, h=Tol, center=true); + } +} +module Body() +{ + translate([BodyRadXY, BodyRadXY, BodyRadFrontZ]) + minkowski() { + cube([BodyWidth-2*BodyRadXY, BodyLength-2*BodyRadXY, BodyHeight-2*BodyRadFrontZ], center=false); + BodyConvolve(); + } +} + +module Phone(Box=false) +{ + difference() { + union() { + if (Box) { BodyBox(); } else { Body(); } + Volume(2); + Power(2); + Camera(2); + } + union() { + translate([0, Tol, 0])Usb(2); + translate([0, -Tol, 0])Aux(2); + } + } +} + +Phone(); + +// debugging: +// translate([0, 0, 20])Phone(Box=true); +// translate([0, 0, 80])BodyConvolve(); diff --git a/primitives.scad b/primitives.scad new file mode 100644 index 0000000..d6b65d3 --- /dev/null +++ b/primitives.scad @@ -0,0 +1,9 @@ +/// cylinder() but with the axis on the y axis instead of the z axis +module cylinderY(d=undef, r=undef, h=undef, center=false) { + rotate(a=[-90,0,0]) cylinder(d=d, r=r, h=h, center=center); +} + +/// cylinder() but with the axis on the x axis instead of the z axis +module cylinderX(d=undef, r=undef, h=undef, center=false) { + rotate(a=[0,-90,0]) cylinder(d=d, r=r, h=h, center=center); +}