2020-04-13 16:33:16 +02:00
|
|
|
"""Generator for a split atreus keyboard."""
|
|
|
|
|
|
|
|
from copy import deepcopy
|
|
|
|
|
|
|
|
from boxes import Boxes, Color, holeCol, restore, boolarg
|
|
|
|
from boxes.edges import FingerJointSettings
|
2021-02-14 13:33:57 +01:00
|
|
|
from .keyboard import Keyboard
|
2020-04-13 16:33:16 +02:00
|
|
|
|
|
|
|
|
2021-02-14 13:33:57 +01:00
|
|
|
class Atreus21(Boxes, Keyboard):
|
2020-04-13 16:33:16 +02:00
|
|
|
"""Generator for a split atreus keyboard."""
|
|
|
|
ui_group = 'Misc'
|
|
|
|
btn_size = 15.6
|
2021-02-14 13:33:57 +01:00
|
|
|
half_btn = btn_size / 2
|
2020-04-13 16:33:16 +02:00
|
|
|
border = 6
|
|
|
|
|
|
|
|
row_offsets=[3, 6, 11, 5, 0, btn_size * .5]
|
|
|
|
row_keys=[4, 4, 4, 4, 4, 1]
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__()
|
|
|
|
|
|
|
|
def render(self):
|
2021-02-14 12:09:42 +01:00
|
|
|
"""Renders the keyboard."""
|
2020-04-13 16:33:16 +02:00
|
|
|
|
|
|
|
self.moveTo(10, 30)
|
|
|
|
case_x, case_y = self._case_x_y()
|
|
|
|
|
2021-02-14 12:09:42 +01:00
|
|
|
margin = 2 * self.border + 1
|
2020-04-13 16:33:16 +02:00
|
|
|
|
|
|
|
for reverse in [False, True]:
|
|
|
|
# keyholder
|
|
|
|
self.outer()
|
|
|
|
self.half(reverse=reverse)
|
|
|
|
self.holes()
|
2021-02-14 12:09:42 +01:00
|
|
|
self.moveTo(case_x + margin)
|
2020-04-13 16:33:16 +02:00
|
|
|
|
|
|
|
# support
|
|
|
|
self.outer()
|
|
|
|
self.half(self.support, reverse=reverse)
|
|
|
|
self.holes()
|
2021-02-14 12:09:42 +01:00
|
|
|
self.moveTo(-case_x - margin, case_y + margin)
|
2020-04-13 16:33:16 +02:00
|
|
|
|
|
|
|
# hotplug
|
|
|
|
self.outer()
|
|
|
|
self.half(self.hotplug, reverse=reverse)
|
|
|
|
self.holes()
|
2021-02-14 12:09:42 +01:00
|
|
|
self.moveTo(case_x + margin)
|
2020-04-13 16:33:16 +02:00
|
|
|
|
|
|
|
# border
|
|
|
|
self.outer()
|
|
|
|
self.rim()
|
|
|
|
self.holes()
|
2021-02-14 12:09:42 +01:00
|
|
|
self.moveTo(-case_x - margin, case_y + margin)
|
2020-04-13 16:33:16 +02:00
|
|
|
|
2021-02-14 12:09:42 +01:00
|
|
|
def holes(self, diameter=3, margin=1.5):
|
2020-04-13 16:33:16 +02:00
|
|
|
case_x, case_y = self._case_x_y()
|
2021-02-14 12:09:42 +01:00
|
|
|
for x in [-margin, case_x + margin]:
|
|
|
|
for y in [-margin, case_y + margin]:
|
|
|
|
self.hole(x, y, d=diameter)
|
2020-04-13 16:33:16 +02:00
|
|
|
|
|
|
|
def micro(self):
|
|
|
|
x = 17.9
|
|
|
|
y = 33
|
|
|
|
b = self.border
|
|
|
|
case_x, case_y = self._case_x_y()
|
|
|
|
self.rectangularHole(
|
|
|
|
x * -.5 + case_x + b * .5,
|
|
|
|
y * -.5 + case_y + b * .5,
|
|
|
|
x, y
|
|
|
|
)
|
|
|
|
|
|
|
|
def rim(self):
|
|
|
|
x, y = self._case_x_y()
|
|
|
|
self.moveTo(x * .5, y * .5)
|
|
|
|
self.rectangularHole(0, 0, x, y, 5)
|
|
|
|
self.moveTo(x * -.5, y * -.5)
|
|
|
|
|
|
|
|
def outer(self):
|
|
|
|
x, y = self._case_x_y()
|
|
|
|
b = self.border
|
|
|
|
self.moveTo(0, -b)
|
|
|
|
corner = [90, b]
|
|
|
|
self.polyline(*([x, corner, y, corner] * 2))
|
|
|
|
self.moveTo(0, b)
|
2021-02-14 13:33:57 +01:00
|
|
|
|
|
|
|
def half(self, hole_cb=None, reverse=False):
|
2020-04-13 16:33:16 +02:00
|
|
|
row_offsets=self.row_offsets
|
|
|
|
row_keys=self.row_keys
|
|
|
|
scheme = list(zip(row_offsets, row_keys))
|
|
|
|
if hole_cb == None:
|
|
|
|
hole_cb = self.key
|
2021-02-14 13:33:57 +01:00
|
|
|
self.moveTo(self.half_btn, self.half_btn)
|
|
|
|
self.apply_callback_on_columns(
|
|
|
|
hole_cb,
|
|
|
|
scheme,
|
|
|
|
self.STANDARD_KEY_SPACING,
|
|
|
|
reverse,
|
|
|
|
)
|
|
|
|
self.moveTo(-self.half_btn, -self.half_btn)
|
2020-04-13 16:33:16 +02:00
|
|
|
|
|
|
|
def support(self):
|
2021-02-14 13:33:57 +01:00
|
|
|
self.outer_hole()
|
2020-04-13 16:33:16 +02:00
|
|
|
|
|
|
|
def hotplug(self):
|
2021-02-14 13:33:57 +01:00
|
|
|
self.pcb_holes()
|
2020-04-13 16:33:16 +02:00
|
|
|
|
|
|
|
def key(self):
|
2021-02-14 13:33:57 +01:00
|
|
|
self.castle_shaped_plate_cutout()
|
2020-04-13 16:33:16 +02:00
|
|
|
|
|
|
|
# get case sizes
|
|
|
|
def _case_x_y(self):
|
2021-02-14 13:33:57 +01:00
|
|
|
x = len(self.row_offsets) * self.STANDARD_KEY_SPACING - 4
|
2020-04-13 16:33:16 +02:00
|
|
|
y = sum([
|
2021-02-14 13:33:57 +01:00
|
|
|
max(self.row_keys) * self.STANDARD_KEY_SPACING, # total button sizes
|
2020-04-13 16:33:16 +02:00
|
|
|
max(self.row_offsets), # offset of highest row
|
|
|
|
-4,
|
|
|
|
])
|
|
|
|
return x, y
|