diff --git a/src/pinephone.py b/src/pinephone.py index bca4d59..74af394 100644 --- a/src/pinephone.py +++ b/src/pinephone.py @@ -48,16 +48,88 @@ camera_min_x = 41.6 camera_width = 22.0 camera_length = 10.0 -def PinePhone(): - # returns just the body - # TODO: add peripherals +def body(): return ( - cq.Workplane("XY") - .box(body_width, body_length, body_height) + cq.Workplane("front") + .box(body_width, body_length, body_height, centered=False) + .tag("body") + .faces(">>X").tag("body_right") + .faces(tag="body") + .faces("<>Y").tag("body_bottom") + .faces(tag="body") + .faces(">>Z").tag("body_back") + .faces(tag="body") .edges("|Z") .fillet(body_rad_xy) - .edges("(|X or |Y) and Z") - .fillet(body_rad_back_z) ) + +def volume(body): + return ( + body + .faces(tag="body_right") + .workplane() + .move(volume_min_y, volume_min_z) + .box(volume_length, volume_height, volume_width, centered=False, combine=False) + .tag("volume") + .edges("|X") + .fillet(volume_height/3) #< XXX: cadquery doesn't allow a full 1/2 fillet + ) + +def power(body): + return ( + body + .faces(tag="body_right") + .workplane() + .move(power_min_y, power_min_z) + .box(power_length, power_height, power_width, centered=False, combine=False) + .tag("volume") + .edges("|X") + .fillet(power_height/3) #< XXX: cadquery doesn't allow a full 1/2 fillet + ) + +def camera(body): + return ( + body + .faces(tag="body_back") + .workplane() + .move(camera_min_x, camera_min_y) + .box(camera_width, camera_length, 2, centered=False, combine=False) + .tag("camera") + .edges("|Z") + .fillet(camera_length/3) + ) + +def aux(body): + return ( + body + .faces(tag="body_top") + .workplane() + .move(aux_min_x, aux_min_z) + .cylinder(radius=3.5/2, height=10, direct=(0, 0, -1), centered=False, combine=False) + .tag("aux") + ) + +def usb(body): + return ( + body + .faces(tag="body_bottom") + .workplane(offset=-10) + .move(-body_width/2, usb_min_z) + .box(usb_width, usb_height, 10, centered=(True, False, False), combine=False) + .tag("usb") + .edges("|Y") + .fillet(usb_height/3) + ) + +def PinePhone(): + phone = body() + phone = phone.union(volume(phone)) + phone = phone.union(power(phone)) + phone = phone.union(camera(phone)) + phone = phone.cut(aux(phone)) + phone = phone.cut(usb(phone)) + return phone