better phone shape, combined model improved

This commit is contained in:
Ricardo (XenGi) Band 2022-03-02 20:26:05 +01:00
commit 7341b4e76e
No known key found for this signature in database
GPG key ID: 1A9D657D06B5820E
4 changed files with 39 additions and 5 deletions

View file

@ -84,12 +84,29 @@ def cli(layout, variant, stl, emf, amf, detail, config_file):
) )
} }
columns = 13
alps_thickness = 0.78
alps_height = 4
alps_width = 6
pcb_thickness = 1
bottom_cover_thickness = 0.5
pcb_margin_y = 3
pcb_margin_x = (PCB_WIDTH - (columns * config.getfloat("key_mat", "key_width", fallback=9) + (columns - 1) * config.getfloat("key_mat", "padding", fallback=1))) / 2 + (config.getfloat("key_mat", "key_width", fallback=9) - 6) / 2
key_mat_width = 13 * config.getfloat("key_mat", "key_width", fallback=9) + 12 * config.getfloat("key_mat", "padding", fallback=1) + 2 * config.getfloat("key_mat", "margin", fallback=1) key_mat_width = 13 * config.getfloat("key_mat", "key_width", fallback=9) + 12 * config.getfloat("key_mat", "padding", fallback=1) + 2 * config.getfloat("key_mat", "margin", fallback=1)
full_model = components["lower_case"] + translate(v=((config.getfloat("phone", "width") - PCB_WIDTH) / 2, config.getfloat("phone", "corner_radius") / 2, 0.5))(
# TODO: fix x of pcb
full_model = components["lower_case"] + translate(v=((config.getfloat("phone", "width") - PCB_WIDTH) / 2, config.getfloat("phone", "corner_radius") / 2, bottom_cover_thickness))(
components["pcb"] components["pcb"]
) + translate(v=((config.getfloat("phone", "width") - key_mat_width) / 2, 3 + config.getfloat("key_mat", "margin", fallback=1) + (config.getfloat("key_mat", "key_height", fallback=6) - 4) / 2 , 1.78))( ) + translate(v=(
pcb_margin_x + config.getfloat("phone", "corner_radius", fallback=10) / 2 - config.getfloat("key_mat", "margin", fallback=1) - (config.getfloat("key_mat", "key_width", fallback=9) - alps_width) / 2,
pcb_margin_y + config.getfloat("phone", "corner_radius", fallback=10) / 2 - config.getfloat("key_mat", "margin", fallback=1) - (config.getfloat("key_mat", "key_height", fallback=6) - alps_height) / 2,
alps_thickness + pcb_thickness + bottom_cover_thickness))(
components["key_mat"] components["key_mat"]
) )
# config.getfloat("phone", "width") - key_mat_width) / 2,
# 3 + config.getfloat("key_mat", "margin", fallback=1) + (config.getfloat("key_mat", "key_height", fallback=6) - 4) / 2 ,
# 1.78
scad_render_to_file( scad_render_to_file(
full_model, full_model,

View file

@ -16,6 +16,8 @@ def lower_case(phone_width: float, phone_height: float, phone_radius: float) ->
thickness = 2 thickness = 2
window_thickness = 0.5 window_thickness = 0.5
# TODO: make a difference between phone_radius and thickness of side walls
return color("DarkSlateGray")(up(z=thickness)( return color("DarkSlateGray")(up(z=thickness)(
(scale(v=(1, 1, thickness / phone_radius))( (scale(v=(1, 1, thickness / phone_radius))(
hull()( hull()(

View file

@ -34,7 +34,7 @@ def pcb(key_width: float, key_height: float, key_padding: float) -> OpenSCADObje
:return: :return:
""" """
pcb_thickness = 0.5 pcb_thickness = 1
rows = 5 rows = 5
columns = 13 columns = 13

View file

@ -1,4 +1,4 @@
from solid import OpenSCADObject, linear_extrude, translate, offset, square from solid import OpenSCADObject, linear_extrude, translate, offset, square, cylinder, rotate, hull, cube
def phone( def phone(
@ -9,12 +9,13 @@ def phone(
side_radius: float side_radius: float
) -> OpenSCADObject: ) -> OpenSCADObject:
""" """
Generates rough estimate of the phones shape Generates rough estimate of the phones shape (basically an oneplus 8t)
:param width: length from top to bottom (landscape) :param width: length from top to bottom (landscape)
:param height: length from left to right (landscape) :param height: length from left to right (landscape)
:param thickness: How thicc is it? :param thickness: How thicc is it?
:param corner_radius: Assuming all phones have round corners :param corner_radius: Assuming all phones have round corners
:param side_radius: Assuming all phones have rounded side rails
:return: :return:
""" """
return linear_extrude(height=thickness)( return linear_extrude(height=thickness)(
@ -23,4 +24,18 @@ def phone(
square(size=(width - 2 * corner_radius, height - 2 * corner_radius)) square(size=(width - 2 * corner_radius, height - 2 * corner_radius))
) )
) )
) * hull()(
translate(v=(0, side_radius, side_radius))(
rotate(a=(0, 90, 0))(
cylinder(r=side_radius, h=width)
)
),
translate(v=(0, height - side_radius, side_radius))(
rotate(a=(0, 90, 0))(
cylinder(r=side_radius, h=width)
)
),
translate(v=(0, 0, thickness / 2))(
cube(size=[width, height, thickness / 2])
)
) )