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
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__()
|
2021-02-14 13:53:21 +01:00
|
|
|
self.add_common_keyboard_parameters(
|
|
|
|
# By default, columns from Atreus 21
|
|
|
|
default_columns_definition='4@3/4@6/4@11/4@5/4@0/1@{}'.format(self.btn_size * 0.5)
|
|
|
|
)
|
2020-04-13 16:33:16 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
)
|
|
|
|
|
2021-02-14 15:27:17 +01:00
|
|
|
@restore
|
2020-04-13 16:33:16 +02:00
|
|
|
def rim(self):
|
|
|
|
x, y = self._case_x_y()
|
|
|
|
self.moveTo(x * .5, y * .5)
|
|
|
|
self.rectangularHole(0, 0, x, y, 5)
|
|
|
|
|
2021-02-14 15:27:17 +01:00
|
|
|
@restore
|
2020-04-13 16:33:16 +02:00
|
|
|
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))
|
2021-02-14 13:33:57 +01:00
|
|
|
|
2021-02-14 15:27:17 +01:00
|
|
|
@restore
|
2021-02-14 13:33:57 +01:00
|
|
|
def half(self, hole_cb=None, reverse=False):
|
2022-12-28 18:14:58 +01:00
|
|
|
if hole_cb is None:
|
2020-04-13 16:33:16 +02:00
|
|
|
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,
|
2021-02-14 13:53:21 +01:00
|
|
|
self.columns_definition,
|
2021-02-14 15:27:17 +01:00
|
|
|
reverse=reverse,
|
2021-02-14 13:33:57 +01:00
|
|
|
)
|
2020-04-13 16:33:16 +02:00
|
|
|
|
|
|
|
def support(self):
|
2021-02-14 13:53:21 +01:00
|
|
|
self.configured_plate_cutout(support=True)
|
2020-04-13 16:33:16 +02:00
|
|
|
|
|
|
|
def hotplug(self):
|
2021-02-14 13:53:21 +01:00
|
|
|
self.pcb_holes(
|
|
|
|
with_hotswap=self.hotswap_enable,
|
|
|
|
with_pcb_mount=self.pcb_mount_enable,
|
|
|
|
with_diode=self.diode_enable,
|
|
|
|
with_led=self.led_enable,
|
|
|
|
)
|
2020-04-13 16:33:16 +02:00
|
|
|
|
|
|
|
def key(self):
|
2021-02-14 13:53:21 +01:00
|
|
|
self.configured_plate_cutout()
|
2020-04-13 16:33:16 +02:00
|
|
|
|
|
|
|
# get case sizes
|
|
|
|
def _case_x_y(self):
|
2021-02-14 13:53:21 +01:00
|
|
|
spacing = Keyboard.STANDARD_KEY_SPACING
|
|
|
|
margin = spacing - self.btn_size
|
|
|
|
x = len(self.columns_definition) * spacing - margin
|
|
|
|
y = max(offset + keys * spacing for (offset, keys) in self.columns_definition) - margin
|
2020-04-13 16:33:16 +02:00
|
|
|
return x, y
|