omnipython-applibs 0.1.2.dev16__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- appkit/__init__.py +52 -0
- appkit/__init__.pyi +17 -0
- appkit/data.py +149 -0
- appkit/data.pyi +25 -0
- appkit/foreground.py +357 -0
- appkit/foreground.pyi +45 -0
- appkit/home.py +19 -0
- appkit/home.pyi +8 -0
- appkit/hover.py +59 -0
- appkit/hover.pyi +13 -0
- appkit/index.py +199 -0
- appkit/index.pyi +30 -0
- appkit/launcher.py +1075 -0
- appkit/launcher.pyi +96 -0
- appkit/manifest.py +75 -0
- appkit/manifest.pyi +8 -0
- appkit/net.py +167 -0
- appkit/net.pyi +34 -0
- appkit/places.py +202 -0
- appkit/places.pyi +39 -0
- appkit/py.typed +0 -0
- appkit/scope.py +636 -0
- appkit/scope.pyi +110 -0
- appkit/shell.py +121 -0
- appkit/shell.pyi +32 -0
- appkit/worker.py +409 -0
- appkit/worker.pyi +83 -0
- controlkit/__init__.py +19 -0
- controlkit/__init__.pyi +10 -0
- controlkit/_draw.py +88 -0
- controlkit/_safe.py +29 -0
- controlkit/dotmatrix.py +101 -0
- controlkit/dotmatrix.pyi +23 -0
- controlkit/encoder.py +297 -0
- controlkit/encoder.pyi +55 -0
- controlkit/font5x7.py +22 -0
- controlkit/font5x7.pyi +11 -0
- controlkit/lamp_button.py +92 -0
- controlkit/lamp_button.pyi +40 -0
- controlkit/meter.py +86 -0
- controlkit/meter.pyi +30 -0
- controlkit/mock.py +116 -0
- controlkit/mock.pyi +35 -0
- controlkit/pad_grid.py +113 -0
- controlkit/pad_grid.pyi +41 -0
- controlkit/py.typed +0 -0
- controlkit/slider.py +185 -0
- controlkit/slider.pyi +49 -0
- controlkit/sprites.py +279 -0
- controlkit/sprites.pyi +22 -0
- controlkit/theme.py +120 -0
- controlkit/theme.pyi +15 -0
- deskkit/__init__.py +74 -0
- deskkit/__init__.pyi +18 -0
- deskkit/forecast.py +261 -0
- deskkit/forecast.pyi +40 -0
- deskkit/localtime.py +215 -0
- deskkit/localtime.pyi +33 -0
- deskkit/py.typed +0 -0
- deskkit/shell.py +113 -0
- deskkit/shell.pyi +33 -0
- omnipython_applibs-0.1.2.dev16.dist-info/METADATA +90 -0
- omnipython_applibs-0.1.2.dev16.dist-info/RECORD +143 -0
- omnipython_applibs-0.1.2.dev16.dist-info/WHEEL +5 -0
- omnipython_applibs-0.1.2.dev16.dist-info/licenses/LICENSE +21 -0
- omnipython_applibs-0.1.2.dev16.dist-info/top_level.txt +9 -0
- programkit/__init__.py +27 -0
- programkit/__init__.pyi +8 -0
- programkit/board.py +56 -0
- programkit/board.pyi +20 -0
- programkit/press.py +63 -0
- programkit/press.pyi +17 -0
- programkit/py.typed +0 -0
- programkit/rows.py +149 -0
- programkit/rows.pyi +34 -0
- sayso/__init__.py +109 -0
- sayso/__init__.pyi +124 -0
- sayso/auth.py +811 -0
- sayso/auth.pyi +102 -0
- sayso/client.py +1286 -0
- sayso/client.pyi +138 -0
- sayso/keepalive.py +371 -0
- sayso/keepalive.pyi +53 -0
- sayso/local.py +85 -0
- sayso/local.pyi +28 -0
- sayso/object_specs.py +706 -0
- sayso/object_specs.pyi +8 -0
- sayso/objects.py +411 -0
- sayso/objects.pyi +854 -0
- sayso/py.typed +0 -0
- sayso/schema_coverage.py +210 -0
- sayso/schema_coverage.pyi +13 -0
- sayso/transport.py +426 -0
- sayso/transport.pyi +47 -0
- songmodel/__init__.py +30 -0
- songmodel/__init__.pyi +9 -0
- songmodel/link.py +189 -0
- songmodel/link.pyi +53 -0
- songmodel/model.py +238 -0
- songmodel/model.pyi +40 -0
- songmodel/page.html +225 -0
- songmodel/page_data.py +236 -0
- songmodel/page_data.pyi +6 -0
- songmodel/py.typed +0 -0
- soundmodule/__init__.py +7 -0
- soundmodule/__init__.pyi +6 -0
- soundmodule/engine.py +1001 -0
- soundmodule/engine.pyi +196 -0
- soundmodule/names.py +298 -0
- soundmodule/names.pyi +30 -0
- soundmodule/pipes.py +105 -0
- soundmodule/pipes.pyi +31 -0
- soundmodule/py.typed +0 -0
- soundmodule/run.py +249 -0
- soundmodule/run.pyi +49 -0
- spectrum/__init__.py +72 -0
- spectrum/__init__.pyi +30 -0
- spectrum/analyzer.py +231 -0
- spectrum/analyzer.pyi +67 -0
- spectrum/fake_music.py +201 -0
- spectrum/fake_music.pyi +36 -0
- spectrum/pump_levels.py +126 -0
- spectrum/pump_levels.pyi +46 -0
- spectrum/py.typed +0 -0
- spectrum/spectrum_view.py +403 -0
- spectrum/spectrum_view.pyi +80 -0
- touchkit/__init__.py +4 -0
- touchkit/__init__.pyi +4 -0
- touchkit/cam.py +146 -0
- touchkit/cam.pyi +35 -0
- touchkit/clock.py +18 -0
- touchkit/clock.pyi +6 -0
- touchkit/ecp.py +134 -0
- touchkit/ecp.pyi +28 -0
- touchkit/net.py +347 -0
- touchkit/net.pyi +27 -0
- touchkit/py.typed +0 -0
- touchkit/settings.py +85 -0
- touchkit/settings.pyi +17 -0
- touchkit/shell.py +268 -0
- touchkit/shell.pyi +42 -0
- touchkit/ui.py +167 -0
- touchkit/ui.pyi +53 -0
controlkit/encoder.pyi
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""One endless encoder: a knurled cap, its pointer, and a ring of 16 LEDs."""
|
|
5
|
+
from typing import Any, Protocol
|
|
6
|
+
|
|
7
|
+
from .theme import _Theme
|
|
8
|
+
|
|
9
|
+
LEDS: int
|
|
10
|
+
MAX: int
|
|
11
|
+
MODES: tuple[str, ...]
|
|
12
|
+
MIN_ROOM: int
|
|
13
|
+
|
|
14
|
+
class _EncoderPanel(Protocol):
|
|
15
|
+
travel: float
|
|
16
|
+
fine: bool
|
|
17
|
+
def default_value(self, index: int) -> int: ...
|
|
18
|
+
def _turned(self, encoder: Encoder, value: int) -> None: ...
|
|
19
|
+
def _focused(self, encoder: Encoder) -> None: ...
|
|
20
|
+
|
|
21
|
+
def geometry(width: int, height: int, scale: float) -> dict[str, float]:
|
|
22
|
+
"""The sizes of one encoder that fits a `width` x `height` cell."""
|
|
23
|
+
|
|
24
|
+
class Encoder:
|
|
25
|
+
"""One macro's encoder, at (`x`, `y`) in `parent`, `width` x `height`."""
|
|
26
|
+
|
|
27
|
+
panel: _EncoderPanel
|
|
28
|
+
index: int
|
|
29
|
+
value: int
|
|
30
|
+
enabled: bool
|
|
31
|
+
mode: str
|
|
32
|
+
obj: Any
|
|
33
|
+
legend: Any
|
|
34
|
+
cx: int
|
|
35
|
+
cy: int
|
|
36
|
+
pointer: Any
|
|
37
|
+
def __init__(
|
|
38
|
+
self,
|
|
39
|
+
panel: _EncoderPanel,
|
|
40
|
+
parent: Any,
|
|
41
|
+
index: int,
|
|
42
|
+
label: str,
|
|
43
|
+
x: int,
|
|
44
|
+
y: int,
|
|
45
|
+
width: int,
|
|
46
|
+
height: int,
|
|
47
|
+
geom: dict[str, float],
|
|
48
|
+
theme: _Theme,
|
|
49
|
+
enabled: bool = True,
|
|
50
|
+
mode: str = 'fill',
|
|
51
|
+
) -> None: ...
|
|
52
|
+
def set_value(self, value: float) -> None:
|
|
53
|
+
"""Show `value` (0 to 127). Never reports back to the panel."""
|
|
54
|
+
def lit(self) -> list[int]:
|
|
55
|
+
"""How bright each LED is, 0 to 255."""
|
controlkit/font5x7.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""A 5x7 dot-matrix font for printable ASCII, drawn for this package.
|
|
5
|
+
|
|
6
|
+
Each character is seven bytes, one per row from the top; the low five bits
|
|
7
|
+
of a byte are the row's dots, the highest of them the leftmost dot.
|
|
8
|
+
Characters outside 32 to 126 draw as a question mark.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
FIRST = 32
|
|
12
|
+
LAST = 126
|
|
13
|
+
DATA = b'\x00\x00\x00\x00\x00\x00\x00\x04\x04\x04\x04\x04\x00\x04\n\n\n\x00\x00\x00\x00\n\n\x1f\n\x1f\n\n\x04\x0f\x14\x0e\x05\x1e\x04\x18\x19\x02\x04\x08\x13\x03\x0c\x12\x14\x08\x15\x12\r\x04\x04\x08\x00\x00\x00\x00\x02\x04\x08\x08\x08\x04\x02\x08\x04\x02\x02\x02\x04\x08\x00\x04\x15\x0e\x15\x04\x00\x00\x04\x04\x1f\x04\x04\x00\x00\x00\x00\x00\x0c\x04\x08\x00\x00\x00\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x0c\x0c\x00\x01\x02\x04\x08\x10\x00\x0e\x11\x13\x15\x19\x11\x0e\x04\x0c\x04\x04\x04\x04\x0e\x0e\x11\x01\x02\x04\x08\x1f\x1f\x02\x04\x02\x01\x11\x0e\x02\x06\n\x12\x1f\x02\x02\x1f\x10\x1e\x01\x01\x11\x0e\x06\x08\x10\x1e\x11\x11\x0e\x1f\x01\x02\x04\x08\x08\x08\x0e\x11\x11\x0e\x11\x11\x0e\x0e\x11\x11\x0f\x01\x02\x0c\x00\x0c\x0c\x00\x0c\x0c\x00\x00\x0c\x0c\x00\x0c\x04\x08\x02\x04\x08\x10\x08\x04\x02\x00\x00\x1f\x00\x1f\x00\x00\x08\x04\x02\x01\x02\x04\x08\x0e\x11\x01\x02\x04\x00\x04\x0e\x11\x01\r\x15\x15\x0e\x0e\x11\x11\x1f\x11\x11\x11\x1e\x11\x11\x1e\x11\x11\x1e\x0e\x11\x10\x10\x10\x11\x0e\x1c\x12\x11\x11\x11\x12\x1c\x1f\x10\x10\x1e\x10\x10\x1f\x1f\x10\x10\x1e\x10\x10\x10\x0e\x11\x10\x17\x11\x11\x0f\x11\x11\x11\x1f\x11\x11\x11\x0e\x04\x04\x04\x04\x04\x0e\x07\x02\x02\x02\x02\x12\x0c\x11\x12\x14\x18\x14\x12\x11\x10\x10\x10\x10\x10\x10\x1f\x11\x1b\x15\x15\x11\x11\x11\x11\x11\x19\x15\x13\x11\x11\x0e\x11\x11\x11\x11\x11\x0e\x1e\x11\x11\x1e\x10\x10\x10\x0e\x11\x11\x11\x15\x12\r\x1e\x11\x11\x1e\x14\x12\x11\x0f\x10\x10\x0e\x01\x01\x1e\x1f\x04\x04\x04\x04\x04\x04\x11\x11\x11\x11\x11\x11\x0e\x11\x11\x11\x11\x11\n\x04\x11\x11\x11\x15\x15\x15\n\x11\x11\n\x04\n\x11\x11\x11\x11\x11\n\x04\x04\x04\x1f\x01\x02\x04\x08\x10\x1f\x0e\x08\x08\x08\x08\x08\x0e\x00\x10\x08\x04\x02\x01\x00\x0e\x02\x02\x02\x02\x02\x0e\x04\n\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x08\x04\x02\x00\x00\x00\x00\x00\x00\x0e\x01\x0f\x11\x0f\x10\x10\x16\x19\x11\x11\x1e\x00\x00\x0e\x10\x10\x11\x0e\x01\x01\r\x13\x11\x11\x0f\x00\x00\x0e\x11\x1f\x10\x0e\x06\t\x08\x1c\x08\x08\x08\x00\x0f\x11\x11\x0f\x01\x0e\x10\x10\x16\x19\x11\x11\x11\x04\x00\x0c\x04\x04\x04\x0e\x02\x00\x06\x02\x02\x12\x0c\x10\x10\x12\x14\x18\x14\x12\x0c\x04\x04\x04\x04\x04\x0e\x00\x00\x1a\x15\x15\x11\x11\x00\x00\x16\x19\x11\x11\x11\x00\x00\x0e\x11\x11\x11\x0e\x00\x00\x1e\x11\x1e\x10\x10\x00\x00\r\x13\x0f\x01\x01\x00\x00\x16\x19\x10\x10\x10\x00\x00\x0e\x10\x0e\x01\x1e\x08\x08\x1c\x08\x08\t\x06\x00\x00\x11\x11\x11\x13\r\x00\x00\x11\x11\x11\n\x04\x00\x00\x11\x11\x15\x15\n\x00\x00\x11\n\x04\n\x11\x00\x00\x11\x11\x0f\x01\x0e\x00\x00\x1f\x02\x04\x08\x1f\x02\x04\x04\x08\x04\x04\x02\x04\x04\x04\x04\x04\x04\x04\x08\x04\x04\x02\x04\x04\x08\x00\x00\x08\x15\x02\x00\x00'
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def rows(char):
|
|
17
|
+
"""The seven row bytes of *char*."""
|
|
18
|
+
code = ord(char) if char else 32
|
|
19
|
+
if code < FIRST or code > LAST:
|
|
20
|
+
code = ord("?")
|
|
21
|
+
start = (code - FIRST) * 7
|
|
22
|
+
return DATA[start : start + 7]
|
controlkit/font5x7.pyi
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""A 5x7 dot-matrix font for printable ASCII, drawn for this package."""
|
|
5
|
+
|
|
6
|
+
FIRST: int
|
|
7
|
+
LAST: int
|
|
8
|
+
DATA: bytes
|
|
9
|
+
|
|
10
|
+
def rows(char: str) -> bytes:
|
|
11
|
+
"""The seven row bytes of `char`."""
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""A labelled push button with a coloured lamp in its corner.
|
|
5
|
+
|
|
6
|
+
It looks like the panel's header buttons: a legend above, a rubber cap below,
|
|
7
|
+
and a lamp that lights in the colour the host gives it.
|
|
8
|
+
|
|
9
|
+
- momentary (the default): each press calls ``on_press(button, True)``;
|
|
10
|
+
- toggle (``toggle=True``): each press flips ``button.on`` and calls
|
|
11
|
+
``on_press(button, on)``. ``set_on()`` changes the state without a call.
|
|
12
|
+
|
|
13
|
+
The lamp shows its colour while the button is on, or always for a momentary
|
|
14
|
+
button. ``set_lamp(rgb)`` sets the colour, and ``None`` darkens the lamp.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
import lvgl as lv
|
|
18
|
+
|
|
19
|
+
from ._draw import Lamp, box, fill, label, plain
|
|
20
|
+
from ._safe import safe
|
|
21
|
+
|
|
22
|
+
_LEGEND_H = 16
|
|
23
|
+
_LAMP_R = 3
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class LampButton:
|
|
27
|
+
"""A button at (*x*, *y*) in *parent*, *width* x *height* of cap."""
|
|
28
|
+
|
|
29
|
+
def __init__(self, parent, x, y, width, height, theme, legend="", toggle=False, lamp=None, on_press=None):
|
|
30
|
+
self.theme = theme
|
|
31
|
+
self.toggle = toggle
|
|
32
|
+
self.on = False
|
|
33
|
+
self.on_press = on_press
|
|
34
|
+
self._lamp_rgb = lamp if lamp is not None else theme["amber"]
|
|
35
|
+
legend_h = _LEGEND_H if legend else 0
|
|
36
|
+
|
|
37
|
+
cell = plain(lv.obj(parent))
|
|
38
|
+
cell.set_pos(x, y)
|
|
39
|
+
cell.set_size(width, height + legend_h)
|
|
40
|
+
self.obj = cell
|
|
41
|
+
|
|
42
|
+
if legend:
|
|
43
|
+
text = label(cell, legend.upper(), theme["header_legend"], None, 0)
|
|
44
|
+
text.set_width(width)
|
|
45
|
+
text.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
|
|
46
|
+
text.set_pos(0, 0)
|
|
47
|
+
|
|
48
|
+
cap = box(cell, 0, legend_h, width, height)
|
|
49
|
+
cap.add_flag(lv.obj.FLAG.CLICKABLE)
|
|
50
|
+
fill(cap, theme["button"], theme["button_bottom"])
|
|
51
|
+
cap.set_style_radius(4, 0)
|
|
52
|
+
cap.set_style_border_width(1, 0)
|
|
53
|
+
cap.set_style_border_color(lv.color_hex(theme["pad_edge"]), 0)
|
|
54
|
+
cap.set_style_shadow_width(4, 0)
|
|
55
|
+
cap.set_style_shadow_offset_y(2, 0)
|
|
56
|
+
cap.set_style_shadow_opa(170, 0)
|
|
57
|
+
cap.set_style_shadow_color(lv.color_hex(0), 0)
|
|
58
|
+
cap.set_style_translate_y(1, lv.STATE.PRESSED)
|
|
59
|
+
cap.set_style_shadow_offset_y(0, lv.STATE.PRESSED)
|
|
60
|
+
cap.add_event_cb(safe(self._on_clicked), lv.EVENT.CLICKED, None)
|
|
61
|
+
self.cap = cap
|
|
62
|
+
|
|
63
|
+
self.lamp = Lamp(cell, width - _LAMP_R - 4, legend_h + _LAMP_R + 4, _LAMP_R, theme)
|
|
64
|
+
self._show()
|
|
65
|
+
|
|
66
|
+
# ---- what the host calls -------------------------------------------------
|
|
67
|
+
|
|
68
|
+
def set_lamp(self, rgb):
|
|
69
|
+
"""Set the lamp's colour; None darkens it. A toggle's lamp shows only while it is on."""
|
|
70
|
+
self._lamp_rgb = rgb
|
|
71
|
+
self._show()
|
|
72
|
+
|
|
73
|
+
def set_on(self, on):
|
|
74
|
+
"""Set the toggle state without calling ``on_press``."""
|
|
75
|
+
self.on = bool(on)
|
|
76
|
+
self._show()
|
|
77
|
+
|
|
78
|
+
# ---- drawing and input ---------------------------------------------------
|
|
79
|
+
|
|
80
|
+
def _show(self):
|
|
81
|
+
lit = self.on if self.toggle else True
|
|
82
|
+
self.lamp.set(self._lamp_rgb if lit else None)
|
|
83
|
+
|
|
84
|
+
def _on_clicked(self, _event):
|
|
85
|
+
if self.toggle:
|
|
86
|
+
self.on = not self.on
|
|
87
|
+
self._show()
|
|
88
|
+
value = self.on
|
|
89
|
+
else:
|
|
90
|
+
value = True
|
|
91
|
+
if self.on_press is not None:
|
|
92
|
+
self.on_press(self, value)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""A labelled push button with a coloured lamp in its corner."""
|
|
5
|
+
from collections.abc import Callable
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from .theme import _Theme
|
|
9
|
+
|
|
10
|
+
class _Lamp:
|
|
11
|
+
rgb: int | None
|
|
12
|
+
def set(self, rgb: int | None) -> None: ...
|
|
13
|
+
|
|
14
|
+
class LampButton:
|
|
15
|
+
"""A button at (`x`, `y`) in `parent`, `width` x `height` of cap."""
|
|
16
|
+
|
|
17
|
+
theme: _Theme
|
|
18
|
+
toggle: bool
|
|
19
|
+
on: bool
|
|
20
|
+
on_press: Callable[[LampButton, bool], None] | None
|
|
21
|
+
obj: Any
|
|
22
|
+
cap: Any
|
|
23
|
+
lamp: _Lamp
|
|
24
|
+
def __init__(
|
|
25
|
+
self,
|
|
26
|
+
parent: Any,
|
|
27
|
+
x: int,
|
|
28
|
+
y: int,
|
|
29
|
+
width: int,
|
|
30
|
+
height: int,
|
|
31
|
+
theme: _Theme,
|
|
32
|
+
legend: str = '',
|
|
33
|
+
toggle: bool = False,
|
|
34
|
+
lamp: int | None = None,
|
|
35
|
+
on_press: Callable[[LampButton, bool], None] | None = None,
|
|
36
|
+
) -> None: ...
|
|
37
|
+
def set_lamp(self, rgb: int | None) -> None:
|
|
38
|
+
"""Set the lamp's colour; None darkens it. A toggle's lamp shows only while it is on."""
|
|
39
|
+
def set_on(self, on: object) -> None:
|
|
40
|
+
"""Set the toggle state without calling `on_press`."""
|
controlkit/meter.py
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""An LED segment meter: a column (or row) of lit segments for a level.
|
|
5
|
+
|
|
6
|
+
The bottom segments run green, the top ones amber and red, as on a hardware
|
|
7
|
+
output meter. ``set_level(0.0 to 1.0)`` lights as many segments as the level
|
|
8
|
+
covers; it only repaints the segments that change, so a meter updated every
|
|
9
|
+
tick costs a few small rectangles.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import lvgl as lv
|
|
13
|
+
|
|
14
|
+
from ._draw import box, fill, label, plain
|
|
15
|
+
|
|
16
|
+
_LEGEND_H = 16
|
|
17
|
+
_GAP = 2
|
|
18
|
+
#: Where the green zone ends and the amber one begins, and the red one starts,
|
|
19
|
+
#: as fractions of the full scale.
|
|
20
|
+
_AMBER = 0.7
|
|
21
|
+
_RED = 0.9
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class LedMeter:
|
|
25
|
+
"""A meter at (*x*, *y*) in *parent*, *width* x *height*, with *segments* lit in turn."""
|
|
26
|
+
|
|
27
|
+
def __init__(self, parent, x, y, width, height, theme, segments=16, vertical=True, legend=""):
|
|
28
|
+
self.theme = theme
|
|
29
|
+
self.vertical = vertical
|
|
30
|
+
self.count = segments
|
|
31
|
+
self.level = 0.0
|
|
32
|
+
self._lit = 0
|
|
33
|
+
self._legend_h = _LEGEND_H if legend else 0
|
|
34
|
+
|
|
35
|
+
cell = plain(lv.obj(parent))
|
|
36
|
+
cell.set_pos(x, y)
|
|
37
|
+
cell.set_size(width, height)
|
|
38
|
+
self.obj = cell
|
|
39
|
+
|
|
40
|
+
if legend:
|
|
41
|
+
text = label(cell, legend.upper(), theme["legend"], None, 1)
|
|
42
|
+
text.set_width(width)
|
|
43
|
+
text.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
|
|
44
|
+
text.set_pos(0, 0)
|
|
45
|
+
|
|
46
|
+
self._segments = []
|
|
47
|
+
bar_h = height - self._legend_h
|
|
48
|
+
bar_w = width
|
|
49
|
+
for i in range(segments):
|
|
50
|
+
if vertical:
|
|
51
|
+
seg_len = (bar_h - _GAP * (segments - 1)) / segments
|
|
52
|
+
seg_y = self._legend_h + bar_h - (i + 1) * seg_len - i * _GAP
|
|
53
|
+
seg = box(cell, 0, int(seg_y), bar_w, int(seg_len))
|
|
54
|
+
else:
|
|
55
|
+
seg_len = (bar_w - _GAP * (segments - 1)) / segments
|
|
56
|
+
seg = box(cell, int(i * (seg_len + _GAP)), self._legend_h, int(seg_len), bar_h)
|
|
57
|
+
seg.set_style_radius(2, 0)
|
|
58
|
+
fill(seg, self._off())
|
|
59
|
+
self._segments.append((seg, self._zone((i + 1) / segments)))
|
|
60
|
+
|
|
61
|
+
def set_level(self, level):
|
|
62
|
+
"""Light the segments that *level* (0.0 to 1.0) covers."""
|
|
63
|
+
level = 0.0 if level < 0 else (1.0 if level > 1 else float(level))
|
|
64
|
+
self.level = level
|
|
65
|
+
lit = int(level * self.count + 0.5)
|
|
66
|
+
if lit == self._lit:
|
|
67
|
+
return
|
|
68
|
+
low, high = (self._lit, lit) if lit > self._lit else (lit, self._lit)
|
|
69
|
+
for i in range(low, high):
|
|
70
|
+
seg, zone = self._segments[i]
|
|
71
|
+
fill(seg, self._colour(zone) if i < lit else self._off())
|
|
72
|
+
self._lit = lit
|
|
73
|
+
|
|
74
|
+
def _zone(self, fraction):
|
|
75
|
+
if fraction > _RED:
|
|
76
|
+
return "red"
|
|
77
|
+
if fraction > _AMBER:
|
|
78
|
+
return "amber"
|
|
79
|
+
return "green"
|
|
80
|
+
|
|
81
|
+
def _colour(self, zone):
|
|
82
|
+
theme = self.theme
|
|
83
|
+
return {"green": theme["status_ok"], "amber": theme["amber"], "red": theme["status_bad"]}[zone]
|
|
84
|
+
|
|
85
|
+
def _off(self):
|
|
86
|
+
return self.theme["display_bezel"]
|
controlkit/meter.pyi
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""An LED segment meter: a column (or row) of lit segments for a level."""
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from .theme import _Theme
|
|
8
|
+
|
|
9
|
+
class LedMeter:
|
|
10
|
+
"""A meter at (`x`, `y`) in `parent`, `width` x `height`, with `segments` lit in turn."""
|
|
11
|
+
|
|
12
|
+
theme: _Theme
|
|
13
|
+
vertical: bool
|
|
14
|
+
count: int
|
|
15
|
+
level: float
|
|
16
|
+
obj: Any
|
|
17
|
+
def __init__(
|
|
18
|
+
self,
|
|
19
|
+
parent: Any,
|
|
20
|
+
x: int,
|
|
21
|
+
y: int,
|
|
22
|
+
width: int,
|
|
23
|
+
height: int,
|
|
24
|
+
theme: _Theme,
|
|
25
|
+
segments: int = 16,
|
|
26
|
+
vertical: bool = True,
|
|
27
|
+
legend: str = '',
|
|
28
|
+
) -> None: ...
|
|
29
|
+
def set_level(self, level: float) -> None:
|
|
30
|
+
"""Light the segments that `level` (0.0 to 1.0) covers."""
|
controlkit/mock.py
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""A stand-in adapter: an instrument with patches and macros, and no sound.
|
|
5
|
+
|
|
6
|
+
It keeps the same contract a real one does, so the panel can be built,
|
|
7
|
+
driven and tested anywhere. ``host_program`` and ``host_parameter`` play
|
|
8
|
+
the part of a host or a sequencer changing things from outside.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
MACRO_LABELS = (
|
|
12
|
+
"Cutoff", "Resonance", "Env Amt", "Drive",
|
|
13
|
+
"Attack", "Decay", "Sustain", "Release",
|
|
14
|
+
"LFO Rate", "LFO Depth", "Detune", "Sub Osc",
|
|
15
|
+
"Chorus", "Delay", "Reverb", "Volume",
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
_NAMES = (
|
|
19
|
+
"Init", "Fat Bass", "Acid Line", "Rubber Sub", "Glass Keys", "Warm Pad",
|
|
20
|
+
"Brass Stab", "Sync Lead", "Pluck Box", "Choir Air", "Wobble", "Bell Tree",
|
|
21
|
+
"Dark Drone", "Hoover", "Soft Saw", "Zap Perc", "Tape Strings", "Organ 7",
|
|
22
|
+
"Ice Arp", "Saw Swarm", "Noise Hit", "Mono Grit", "Detroit", "Sine Sub",
|
|
23
|
+
"Vox Formant", "Clav Funk", "Juno Pad", "Laser", "Duck Bass", "Hollow",
|
|
24
|
+
"Ring Mod", "Dust Keys", "Space Lead", "Pulse 25", "Rave Stab", "Mellow",
|
|
25
|
+
"Metal Bell", "Big Room", "Lo-Fi Pad", "Last Light",
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _patch_values(index):
|
|
30
|
+
"""Sixteen repeatable values for patch *index*, spread over the range."""
|
|
31
|
+
values = []
|
|
32
|
+
seed = 2654435761 * (index + 7) & 0xFFFFFFFF
|
|
33
|
+
for _ in range(16):
|
|
34
|
+
seed = (1103515245 * seed + 12345) & 0x7FFFFFFF
|
|
35
|
+
values.append((seed >> 8) % 128)
|
|
36
|
+
return values
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class MockAdapter:
|
|
40
|
+
"""An adapter with *patch_count* patches and *macro_count* labelled macros.
|
|
41
|
+
|
|
42
|
+
*echo* says whether a patch change reports each macro it moved, the way
|
|
43
|
+
an engine does; with False it only reports the patch, the way a simpler
|
|
44
|
+
adapter might, and the panel must still follow.
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
def __init__(self, name="Demo Synth", patch_count=40, macro_count=16, echo=True):
|
|
48
|
+
self.script_name = name
|
|
49
|
+
self.macro_labels = list(MACRO_LABELS[:macro_count])
|
|
50
|
+
self.macro_count = macro_count
|
|
51
|
+
self.patches = [_NAMES[i] if i < len(_NAMES) else "Patch %03d" % (i + 1) for i in range(patch_count)]
|
|
52
|
+
self.patch_index = 0
|
|
53
|
+
self.macro_values = _patch_values(0)
|
|
54
|
+
self.bypass = False
|
|
55
|
+
self.engine_ready = True
|
|
56
|
+
self.engine_error = 0
|
|
57
|
+
self.echo = echo
|
|
58
|
+
self.edits = []
|
|
59
|
+
self.reloads = 0
|
|
60
|
+
self._listeners = []
|
|
61
|
+
|
|
62
|
+
def on_external_change(self, callback):
|
|
63
|
+
self._listeners.append(callback)
|
|
64
|
+
|
|
65
|
+
def _notify(self, kind, index, value):
|
|
66
|
+
for listener in self._listeners:
|
|
67
|
+
listener(kind, index, value)
|
|
68
|
+
|
|
69
|
+
def _load(self, index):
|
|
70
|
+
for macro, value in enumerate(_patch_values(index)):
|
|
71
|
+
if self.macro_values[macro] == value:
|
|
72
|
+
continue
|
|
73
|
+
self.macro_values[macro] = value
|
|
74
|
+
if self.echo:
|
|
75
|
+
self._notify("macro", macro, value)
|
|
76
|
+
|
|
77
|
+
# ---- the panel's calls ----
|
|
78
|
+
|
|
79
|
+
def set_macro(self, index, value):
|
|
80
|
+
self.macro_values[index] = value
|
|
81
|
+
self.edits.append(("macro", index, value))
|
|
82
|
+
|
|
83
|
+
def set_patch(self, index):
|
|
84
|
+
self.patch_index = index
|
|
85
|
+
self.edits.append(("patch", index, index))
|
|
86
|
+
self._load(index)
|
|
87
|
+
|
|
88
|
+
def set_bypass(self, enabled):
|
|
89
|
+
self.bypass = bool(enabled)
|
|
90
|
+
self.edits.append(("bypass", 0, self.bypass))
|
|
91
|
+
|
|
92
|
+
def request_reload(self):
|
|
93
|
+
self.reloads += 1
|
|
94
|
+
|
|
95
|
+
def tick(self):
|
|
96
|
+
pass
|
|
97
|
+
|
|
98
|
+
def close_all(self):
|
|
99
|
+
pass
|
|
100
|
+
|
|
101
|
+
# ---- the outside world ----
|
|
102
|
+
|
|
103
|
+
def host_program(self, index):
|
|
104
|
+
"""A host or sequencer picks patch *index*: patch first, then macros."""
|
|
105
|
+
if index == self.patch_index:
|
|
106
|
+
return
|
|
107
|
+
self.patch_index = index
|
|
108
|
+
self._notify("patch", index, index)
|
|
109
|
+
self._load(index)
|
|
110
|
+
|
|
111
|
+
def host_parameter(self, index, value):
|
|
112
|
+
"""A host's automation moves macro *index* to *value*."""
|
|
113
|
+
if self.macro_values[index] == value:
|
|
114
|
+
return
|
|
115
|
+
self.macro_values[index] = value
|
|
116
|
+
self._notify("macro", index, value)
|
controlkit/mock.pyi
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""A stand-in adapter: an instrument with patches and macros, and no sound."""
|
|
5
|
+
from collections.abc import Callable
|
|
6
|
+
|
|
7
|
+
MACRO_LABELS: tuple[str, ...]
|
|
8
|
+
|
|
9
|
+
class MockAdapter:
|
|
10
|
+
"""An adapter with `patch_count` patches and `macro_count` labelled macros."""
|
|
11
|
+
|
|
12
|
+
script_name: str
|
|
13
|
+
macro_labels: list[str]
|
|
14
|
+
macro_count: int
|
|
15
|
+
patches: list[str]
|
|
16
|
+
patch_index: int
|
|
17
|
+
macro_values: list[int]
|
|
18
|
+
bypass: bool
|
|
19
|
+
engine_ready: bool
|
|
20
|
+
engine_error: int
|
|
21
|
+
echo: bool
|
|
22
|
+
edits: list[tuple[str, int, int | bool]]
|
|
23
|
+
reloads: int
|
|
24
|
+
def __init__(self, name: str = 'Demo Synth', patch_count: int = 40, macro_count: int = 16, echo: bool = True) -> None: ...
|
|
25
|
+
def on_external_change(self, callback: Callable[[str, int, int], None]) -> None: ...
|
|
26
|
+
def set_macro(self, index: int, value: int) -> None: ...
|
|
27
|
+
def set_patch(self, index: int) -> None: ...
|
|
28
|
+
def set_bypass(self, enabled: object) -> None: ...
|
|
29
|
+
def request_reload(self) -> None: ...
|
|
30
|
+
def tick(self) -> None: ...
|
|
31
|
+
def close_all(self) -> None: ...
|
|
32
|
+
def host_program(self, index: int) -> None:
|
|
33
|
+
"""A host or sequencer picks patch `index`: patch first, then macros."""
|
|
34
|
+
def host_parameter(self, index: int, value: int) -> None:
|
|
35
|
+
"""A host's automation moves macro `index` to `value`."""
|
controlkit/pad_grid.py
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""A grid of illuminated pads, each lit in any colour, as a step or session grid.
|
|
5
|
+
|
|
6
|
+
``set_color(index, rgb)`` lights pad *index* (row-major: row * cols + column)
|
|
7
|
+
and ``None`` puts it out. A press calls ``on_press(grid, index)``. Only the
|
|
8
|
+
pads that change are repainted.
|
|
9
|
+
|
|
10
|
+
For pads that play, ``on_down(grid, index)`` is called the moment a finger
|
|
11
|
+
lands and ``on_up(grid, index)`` when it lifts or slides off, so a note can
|
|
12
|
+
start and end with the touch. ``set_label(index, text)`` prints a legend on
|
|
13
|
+
a pad, and ``pad(index)`` is the pad's own object, to read where it is.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import lvgl as lv
|
|
17
|
+
|
|
18
|
+
from ._draw import box, fill, label, plain
|
|
19
|
+
from ._safe import safe
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class PadGrid:
|
|
23
|
+
"""A grid of *cols* x *rows* pads in *width* x *height* at (*x*, *y*) in *parent*."""
|
|
24
|
+
|
|
25
|
+
def __init__(self, parent, x, y, width, height, theme, cols=8, rows=2, gap=4, on_press=None,
|
|
26
|
+
on_down=None, on_up=None):
|
|
27
|
+
self.theme = theme
|
|
28
|
+
self.cols = cols
|
|
29
|
+
self.rows = rows
|
|
30
|
+
self.on_press = on_press
|
|
31
|
+
self.on_down = on_down
|
|
32
|
+
self.on_up = on_up
|
|
33
|
+
self._labels = {}
|
|
34
|
+
self.colors = [None] * (cols * rows)
|
|
35
|
+
|
|
36
|
+
cell = plain(lv.obj(parent))
|
|
37
|
+
cell.set_pos(x, y)
|
|
38
|
+
cell.set_size(width, height)
|
|
39
|
+
self.obj = cell
|
|
40
|
+
|
|
41
|
+
pad_w = (width - gap * (cols - 1)) // cols
|
|
42
|
+
pad_h = (height - gap * (rows - 1)) // rows
|
|
43
|
+
self._pads = []
|
|
44
|
+
for row in range(rows):
|
|
45
|
+
for col in range(cols):
|
|
46
|
+
pad = box(cell, col * (pad_w + gap), row * (pad_h + gap), pad_w, pad_h)
|
|
47
|
+
pad.add_flag(lv.obj.FLAG.CLICKABLE)
|
|
48
|
+
pad.set_style_radius(3, 0)
|
|
49
|
+
pad.set_style_border_width(1, 0)
|
|
50
|
+
pad.set_style_border_color(lv.color_hex(theme["pad_edge"]), 0)
|
|
51
|
+
pad.set_style_translate_y(1, lv.STATE.PRESSED)
|
|
52
|
+
index = len(self._pads)
|
|
53
|
+
pad.add_event_cb(safe(self._handler(index)), lv.EVENT.CLICKED, None)
|
|
54
|
+
if on_down is not None or on_up is not None:
|
|
55
|
+
pad.remove_flag(lv.obj.FLAG.GESTURE_BUBBLE) # a slide is a held pad, not a swipe
|
|
56
|
+
pad.add_event_cb(safe(self._edge(index, True)), lv.EVENT.PRESSED, None)
|
|
57
|
+
pad.add_event_cb(safe(self._edge(index, False)), lv.EVENT.RELEASED, None)
|
|
58
|
+
pad.add_event_cb(safe(self._edge(index, False)), lv.EVENT.PRESS_LOST, None)
|
|
59
|
+
self._pads.append(pad)
|
|
60
|
+
self._paint(index)
|
|
61
|
+
|
|
62
|
+
def set_color(self, index, rgb):
|
|
63
|
+
"""Light pad *index* in *rgb*, or put it out with None."""
|
|
64
|
+
if not 0 <= index < len(self._pads):
|
|
65
|
+
raise IndexError("pad %d is not in a %dx%d grid" % (index, self.cols, self.rows))
|
|
66
|
+
if self.colors[index] == rgb:
|
|
67
|
+
return
|
|
68
|
+
self.colors[index] = rgb
|
|
69
|
+
self._paint(index)
|
|
70
|
+
|
|
71
|
+
def set_label(self, index, text, rgb=None):
|
|
72
|
+
"""Print *text* in the middle of pad *index*, in *rgb* (the theme's pad text by default)."""
|
|
73
|
+
lbl = self._labels.get(index)
|
|
74
|
+
if lbl is None:
|
|
75
|
+
lbl = label(self._pads[index], text, rgb if rgb is not None else self.theme["pad_text"], None, 0)
|
|
76
|
+
lbl.center()
|
|
77
|
+
self._labels[index] = lbl
|
|
78
|
+
else:
|
|
79
|
+
lbl.set_text(text)
|
|
80
|
+
if rgb is not None:
|
|
81
|
+
lbl.set_style_text_color(lv.color_hex(rgb), 0)
|
|
82
|
+
return lbl
|
|
83
|
+
|
|
84
|
+
def pad(self, index):
|
|
85
|
+
"""Pad *index*'s LVGL object."""
|
|
86
|
+
return self._pads[index]
|
|
87
|
+
|
|
88
|
+
def _paint(self, index):
|
|
89
|
+
rgb = self.colors[index]
|
|
90
|
+
pad = self._pads[index]
|
|
91
|
+
if rgb is None:
|
|
92
|
+
fill(pad, self.theme["pad"], self.theme["pad_bottom"])
|
|
93
|
+
pad.set_style_shadow_width(0, 0)
|
|
94
|
+
else:
|
|
95
|
+
fill(pad, rgb)
|
|
96
|
+
pad.set_style_shadow_width(6, 0)
|
|
97
|
+
pad.set_style_shadow_color(lv.color_hex(rgb), 0)
|
|
98
|
+
pad.set_style_shadow_opa(160, 0)
|
|
99
|
+
|
|
100
|
+
def _handler(self, index):
|
|
101
|
+
def handle(_event):
|
|
102
|
+
if self.on_press is not None:
|
|
103
|
+
self.on_press(self, index)
|
|
104
|
+
|
|
105
|
+
return handle
|
|
106
|
+
|
|
107
|
+
def _edge(self, index, down):
|
|
108
|
+
def handle(_event):
|
|
109
|
+
cb = self.on_down if down else self.on_up
|
|
110
|
+
if cb is not None:
|
|
111
|
+
cb(self, index)
|
|
112
|
+
|
|
113
|
+
return handle
|
controlkit/pad_grid.pyi
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""A grid of illuminated pads, each lit in any colour, as a step or session grid."""
|
|
5
|
+
from collections.abc import Callable
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from .theme import _Theme
|
|
9
|
+
|
|
10
|
+
class PadGrid:
|
|
11
|
+
"""A grid of `cols` x `rows` pads in `width` x `height` at (`x`, `y`) in `parent`."""
|
|
12
|
+
|
|
13
|
+
theme: _Theme
|
|
14
|
+
cols: int
|
|
15
|
+
rows: int
|
|
16
|
+
on_press: Callable[[PadGrid, int], None] | None
|
|
17
|
+
on_down: Callable[[PadGrid, int], None] | None
|
|
18
|
+
on_up: Callable[[PadGrid, int], None] | None
|
|
19
|
+
colors: list[int | None]
|
|
20
|
+
obj: Any
|
|
21
|
+
def __init__(
|
|
22
|
+
self,
|
|
23
|
+
parent: Any,
|
|
24
|
+
x: int,
|
|
25
|
+
y: int,
|
|
26
|
+
width: int,
|
|
27
|
+
height: int,
|
|
28
|
+
theme: _Theme,
|
|
29
|
+
cols: int = 8,
|
|
30
|
+
rows: int = 2,
|
|
31
|
+
gap: int = 4,
|
|
32
|
+
on_press: Callable[[PadGrid, int], None] | None = None,
|
|
33
|
+
on_down: Callable[[PadGrid, int], None] | None = None,
|
|
34
|
+
on_up: Callable[[PadGrid, int], None] | None = None,
|
|
35
|
+
) -> None: ...
|
|
36
|
+
def set_color(self, index: int, rgb: int | None) -> None:
|
|
37
|
+
"""Light pad `index` in `rgb`, or put it out with None."""
|
|
38
|
+
def set_label(self, index: int, text: str, rgb: int | None = None) -> Any:
|
|
39
|
+
"""Print `text` in the middle of pad `index`, in `rgb` (the theme's pad text by default)."""
|
|
40
|
+
def pad(self, index: int) -> Any:
|
|
41
|
+
"""Pad `index`'s LVGL object."""
|
controlkit/py.typed
ADDED
|
File without changes
|