returned to solid convenience functions up, down etc

This commit is contained in:
Ricardo (XenGi) Band 2022-02-26 18:30:58 +01:00
commit 1b64b3a2c8
No known key found for this signature in database
GPG key ID: 1A9D657D06B5820E
7 changed files with 55 additions and 35 deletions

26
mkbd65/camera_bump.py Normal file
View file

@ -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)
)

View file

@ -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)(

View file

@ -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))(

View file

@ -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:

View file

@ -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))

18
motorola_g100.ini Normal file
View file

@ -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

View file

@ -1,4 +1,4 @@
# oneplus_8t
# Oneplus 8t
[phone]
width = 160.7