TEMP build123d framework stuff and test layout
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
This commit is contained in:
parent
82d914c30c
commit
e63a5da6a2
1
src/bss/__init__.py
Normal file
1
src/bss/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
"""The Buildable Stick System, code to generate arcade stick components."""
|
68
src/bss/core.py
Normal file
68
src/bss/core.py
Normal file
@ -0,0 +1,68 @@
|
||||
"""Shared parameters and foundational objects.
|
||||
|
||||
Reminder that the default unit is millimeters.
|
||||
|
||||
SPDX-FileCopyrightText: © 2023 Brian S. Stephan <bss@incorporeal.org>
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
"""
|
||||
import build123d as bd
|
||||
|
||||
####################
|
||||
# measurements for holes and connectors
|
||||
####################
|
||||
HOLE_TOLERANCE = 0.15
|
||||
|
||||
M4_BOLT_RADIUS = 2 + HOLE_TOLERANCE
|
||||
M4_BOLT_COUNTERSINK_RADIUS = M4_BOLT_RADIUS + 2
|
||||
|
||||
####################
|
||||
# basic dimensions necessary for proper object composition
|
||||
####################
|
||||
|
||||
# these are for ONE frame box, not the overall case, which may be composed
|
||||
# of multiple frames
|
||||
FRAME_X = 233
|
||||
FRAME_Y = 208
|
||||
FRAME_Z = 57
|
||||
|
||||
# the "wall" is the space inside the frame that is reserved to make a lip for panels
|
||||
FRAME_WALL = 4
|
||||
|
||||
# panel dimensions for either an inset panel or the inner tray of an overhang panel
|
||||
PANEL_X = FRAME_X - (FRAME_WALL * 2)
|
||||
PANEL_Y = FRAME_Y - (FRAME_WALL * 2)
|
||||
PANEL_Z = 5
|
||||
|
||||
# the center point of where the standoff and bolts connecting a panel to a frame go,
|
||||
# relative to a centered object
|
||||
PANEL_TO_FRAME_POINT_OFFSET = 10
|
||||
PANEL_TO_FRAME_POINT_X = (PANEL_X/2) - PANEL_TO_FRAME_POINT_OFFSET
|
||||
PANEL_TO_FRAME_POINT_Y = (PANEL_Y/2) - PANEL_TO_FRAME_POINT_OFFSET
|
||||
|
||||
####################
|
||||
# commonly used button dimensions
|
||||
####################
|
||||
|
||||
BUTTON_30MM_RADIUS = 15 + HOLE_TOLERANCE
|
||||
BUTTON_24MM_RADIUS = 12 + HOLE_TOLERANCE
|
||||
|
||||
# carve out space for snap-ins
|
||||
# judgng by https://www.slagcoin.com/joystick/attributes_brands.html 2.5mm is good for everything
|
||||
BUTTON_SNAP_IN_THICKNESS = 2.5
|
||||
|
||||
# make sure the carve out space is also enough for screw-in nuts
|
||||
# slagcoin has screw-in nut diameter at 36mm for 30mm buttons, 29.5 for 24mm buttons
|
||||
# radius + value below should leave space for the nut and for fingers to grab the nut
|
||||
BUTTON_30MM_RADIUS_CONNECTOR_SPACE = 6
|
||||
|
||||
####################
|
||||
# arcade stick parts that are relevant in a number of contexts
|
||||
####################
|
||||
|
||||
|
||||
class CutoutButtonHole(bd.CounterBoreHole):
|
||||
"""Use an inverted counter bore hole as the button hole with the extra thin space for snap-ins."""
|
||||
|
||||
def __init__(self, radius, **kwargs):
|
||||
"""Initialize the inverted counter bore hole with the right thinness for e.g. a panel to take snap-ins."""
|
||||
super().__init__(radius, radius+BUTTON_30MM_RADIUS_CONNECTOR_SPACE, BUTTON_SNAP_IN_THICKNESS, **kwargs)
|
31
src/bss/layouts.py
Normal file
31
src/bss/layouts.py
Normal file
@ -0,0 +1,31 @@
|
||||
"""Button and other component layouts for use in panels.
|
||||
|
||||
SPDX-FileCopyrightText: © 2023 Brian S. Stephan <bss@incorporeal.org>
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
"""
|
||||
import build123d as bd
|
||||
|
||||
from bss import core
|
||||
|
||||
####################
|
||||
# collected points and related data, to be used to construct a layout
|
||||
####################
|
||||
|
||||
# 3x3, centered on top left (P1) button
|
||||
SEGA_2P_SIX_BUTTON = {'radius': core.BUTTON_30MM_RADIUS,
|
||||
'positions': [(0, 0), (30.5, 11 + 9), (30.5 + 36, 11 + 9),
|
||||
(0, -19 - 9 - 11), (30.5, -19), (30.5 + 36, -19)]}
|
||||
|
||||
####################
|
||||
# Layouts are Locations with extra stuff to document what it is
|
||||
####################
|
||||
|
||||
|
||||
class Layout(bd.Locations):
|
||||
"""A set of button positions that can be adjusted relative to some parameters."""
|
||||
|
||||
def __init__(self, layout, *args, distance_scale=1.00, **kwargs):
|
||||
"""Lay out the points for the buttons, etc. but can be scaled."""
|
||||
self.points = list(map(lambda x: (x[0] * distance_scale, x[1] * distance_scale), layout['positions']))
|
||||
self.button_radius = layout['radius']
|
||||
super().__init__(self.points, *args, **kwargs)
|
Loading…
Reference in New Issue
Block a user