diff --git a/mkbd65/camera_bump.py b/mkbd65/camera_bump.py new file mode 100644 index 0000000..cada21e --- /dev/null +++ b/mkbd65/camera_bump.py @@ -0,0 +1,26 @@ +from solid import OpenSCADObject, translate, minkowski, cube, cylinder + + +def _generic_bump(width: float, height: float, thickness: float, radius: float) -> OpenSCADObject: + """ + A rounded rectangular bump + + :return: + """ + return translate(v=(radius, -1 * height + radius, 0))( + minkowski()( + cube([width - 2 * radius, height - 2 * radius, thickness]), + cylinder(r=radius, h=thickness) + ) + ) + + +def oneplus_8t() -> OpenSCADObject: + """ + Camera bump of the Oneplus 8T + + :return: + """ + return translate(v=(6, 7, 0))( + _generic_bump(width=39, height=25, thickness=1, radius=5) + ) diff --git a/mkbd65/key_mat.py b/mkbd65/key_mat.py index d51ff1c..2d6a2bf 100644 --- a/mkbd65/key_mat.py +++ b/mkbd65/key_mat.py @@ -1,8 +1,9 @@ from typing import Tuple from solid import OpenSCADObject, cube, linear_extrude, text, translate, scale, rotate, cylinder, union, color, square, offset +from solid.utils import up -from mkbd65.util import get_label_size, FILAMENT_LAYER, LAYOUTS, forward, right, backward +from util import get_label_size, FILAMENT_LAYER, LAYOUTS def key( @@ -45,7 +46,7 @@ def key( ) ) ) - ) * forward(v=2)( + ) * up(z=2)( linear_extrude(height=dome_height / 2)( translate(v=(corner_radius, corner_radius, 0))( offset(r=corner_radius)( diff --git a/mkbd65/lower_case.py b/mkbd65/lower_case.py index d0cddc4..fcd6d40 100644 --- a/mkbd65/lower_case.py +++ b/mkbd65/lower_case.py @@ -1,6 +1,7 @@ from solid import OpenSCADObject, hull, translate, sphere, cube, scale, offset, square +from solid.utils import up, right, down -from mkbd65.util import PCB_WIDTH, PCB_HEIGHT, PCB_RADIUS, forward, backward, up, right +from util import PCB_WIDTH, PCB_HEIGHT, PCB_RADIUS def lower_case(phone_width: float, phone_height: float, phone_radius: float) -> OpenSCADObject: @@ -15,15 +16,15 @@ def lower_case(phone_width: float, phone_height: float, phone_radius: float) -> thickness = 2 window_thickness = 0.5 - return forward(v=thickness)( + return up(z=thickness)( (scale(v=(1, 1, thickness / phone_radius))( hull()( translate(v=(phone_radius, phone_radius, 0))( sphere(r=phone_radius), - up(v=phone_height - 2 * phone_radius)( + up(z=phone_height - 2 * phone_radius)( sphere(r=phone_radius) ), - right(v=phone_width - 2 * phone_radius)( + right(x=phone_width - 2 * phone_radius)( sphere(r=phone_radius) ), translate(v=(phone_width - 2 * phone_radius, phone_height - 2 * phone_radius, 0))( @@ -31,7 +32,7 @@ def lower_case(phone_width: float, phone_height: float, phone_radius: float) -> ) ) ) - ) * backward(v=thickness)( + ) * down(z=thickness)( cube([phone_width, phone_height, thickness]) )) - translate(v=(2 * phone_radius, 2 * phone_radius, -1 * thickness / 2))( scale(v=(1, 1, thickness))( diff --git a/mkbd65/pcb.py b/mkbd65/pcb.py index 2a57180..672ebd6 100644 --- a/mkbd65/pcb.py +++ b/mkbd65/pcb.py @@ -1,6 +1,6 @@ from solid import OpenSCADObject, color, linear_extrude, polygon, translate, scale, offset, square, union, cylinder -from mkbd65.util import PCB_WIDTH, PCB_HEIGHT, PCB_RADIUS +from util import PCB_WIDTH, PCB_HEIGHT, PCB_RADIUS def switch() -> OpenSCADObject: diff --git a/mkbd65/util.py b/mkbd65/util.py index 474de80..7650010 100644 --- a/mkbd65/util.py +++ b/mkbd65/util.py @@ -1,5 +1,3 @@ -from solid import polygon, circle, translate, OpenSCADObject - PCB_RADIUS = 5 PCB_WIDTH = 150 PCB_HEIGHT = 64 @@ -53,27 +51,3 @@ def get_label_size(label: str) -> float: return 2.5 else: return 3.5 - - -def up(v: float) -> translate: - return translate(v=(0, v, 0)) - - -def down(v: float) -> translate: - return translate(v=(0, v * -1, 0)) - - -def left(v: float) -> translate: - return translate(v=(v * -1, 0, 0)) - - -def right(v: float) -> translate: - return translate(v=(v, 0, 0)) - - -def forward(v: float) -> translate: - return translate(v=(0, 0, v)) - - -def backward(v: float) -> translate: - return translate(v=(0, 0, v * -1)) diff --git a/motorola_g100.ini b/motorola_g100.ini new file mode 100644 index 0000000..8cddd43 --- /dev/null +++ b/motorola_g100.ini @@ -0,0 +1,18 @@ +# Motorola moto g100 + +[phone] +width = 74.2 +height = 168.4 +thickness = 9.7 +corner_radius = 10 +side_radius = 5 + +[key_mat] +margin = 1 +padding = 1 +thickness = 0.5 +key_width = 9 +key_height = 6 +key_corner_radius = 1 +key_thickness = 2 +font = DejaVu Sans:style=Bold diff --git a/oneplus_8t.ini b/oneplus_8t.ini index a10afcb..bde405f 100644 --- a/oneplus_8t.ini +++ b/oneplus_8t.ini @@ -1,4 +1,4 @@ -# oneplus_8t +# Oneplus 8t [phone] width = 160.7