117 lines
2.9 KiB
OpenSCAD
117 lines
2.9 KiB
OpenSCAD
include <defaults.scad>
|
|
include <dimensions.scad>
|
|
use <bits.scad>
|
|
use <phone.scad>
|
|
use <primitives.scad>
|
|
|
|
// thickness of case walls
|
|
Thickness = 2;
|
|
// how large of cuts (radial) to make around each component
|
|
MarginCamera = 2;
|
|
MarginButtons = 2.5;
|
|
MarginPorts = 5.5;
|
|
// how far into the xy plane to extend the part of the case which covers the front of the phone.
|
|
// the top of the phone contains stuff we don't want to cover (camera); the bottom has more margin
|
|
FrontOverhangX = 3;
|
|
FrontOverhangTop = 3;
|
|
FrontOverhangBot = 6;
|
|
|
|
// gives a 1cm margin around the whole body of the phone, but only in the xy plane.
|
|
module _PhoneBulkLayer(tol=tol)
|
|
{
|
|
minkowski() {
|
|
PhoneBody();
|
|
cube([20, 20, tol], center=true);
|
|
}
|
|
}
|
|
|
|
module _FrontFace(tol=tol) {
|
|
color("thistle")
|
|
difference() {
|
|
translate([0, 0, -Thickness]) PhoneBody();
|
|
_PhoneBulkLayer(tol=tol);
|
|
};
|
|
}
|
|
|
|
/// we want to cutout a portion of the case to expose the touchscreen.
|
|
/// but we don't want to cut out the entire front face.
|
|
/// so, produce a "mask", of just that front-facing portion of the case we want to preserve:
|
|
/// returns a mask which is -Thickness <= z <= 0, within tolerance
|
|
module _FrontKeep(tol=tol) {
|
|
minkowski() {
|
|
// take the outline of the front face of the phone
|
|
difference() {
|
|
minkowski() {
|
|
cylinder(r=2*tol, h=tol, center=true);
|
|
_FrontFace();
|
|
};
|
|
minkowski() {
|
|
cylinder(r=tol, h=2*tol, center=true);
|
|
_FrontFace();
|
|
};
|
|
};
|
|
// and expand it
|
|
// cylinder(r=FrontOverhangX, h=tol, center=false);
|
|
// translate([0, -0.5*(FrontOverhangBot - FrontOverhangTop), -Thickness])
|
|
pillZ(2*FrontOverhangX, FrontOverhangBot + FrontOverhangTop, tol, center=true);
|
|
};
|
|
}
|
|
|
|
/// returns the region which we want to subtract from the case, in order to keep the front screen accessible.
|
|
/// the returned cutout is strictly z <= 0,
|
|
module _FrontCutout() {
|
|
difference() {
|
|
_FrontFace();
|
|
_FrontKeep();
|
|
};
|
|
}
|
|
|
|
module Case()
|
|
{
|
|
color("DarkSlateGray")
|
|
difference() {
|
|
minkowski() {
|
|
sphere(d=Thickness);
|
|
// Phone(volume=false, power=false, camera=false);
|
|
PhoneBody();
|
|
}
|
|
union() {
|
|
minkowski() {
|
|
sphere(r=MarginCamera);
|
|
Camera();
|
|
};
|
|
// restrict these cutouts to just the phone bulk -- don't let them impact the back of the case
|
|
intersection() {
|
|
_PhoneBulkLayer();
|
|
union() {
|
|
minkowski() {
|
|
sphere(r=MarginButtons);
|
|
union() {
|
|
Volume();
|
|
Power();
|
|
};
|
|
}
|
|
minkowski() {
|
|
sphere(r=MarginPorts);
|
|
union() {
|
|
Usb();
|
|
Aux();
|
|
};
|
|
};
|
|
};
|
|
};
|
|
Phone(usb=false, aux=false);
|
|
translate([0, 0, tol]) _FrontCutout();
|
|
// _FrontCutout();
|
|
}
|
|
}
|
|
}
|
|
|
|
Case();
|
|
|
|
// debugging:
|
|
// _FrontFace();
|
|
// _FrontKeep();
|
|
// _FrontCutout();
|
|
// Phone();
|