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
deskkit/shell.py
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""deskkit.shell: swipe between apps, drift back to the first, and sleep at night."""
|
|
5
|
+
|
|
6
|
+
import board_config
|
|
7
|
+
import lvgl as lv
|
|
8
|
+
from appkit import Shell
|
|
9
|
+
|
|
10
|
+
from . import localtime
|
|
11
|
+
|
|
12
|
+
_CHECK_MS = 1000
|
|
13
|
+
_SWIPE_PX = 60
|
|
14
|
+
_HOLD_MS = 1000 # long enough that resting a finger isn't a hold
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def is_awake(hour, weekday, awake, weekends):
|
|
18
|
+
"""Return True when the screen belongs on at this time.
|
|
19
|
+
|
|
20
|
+
Args:
|
|
21
|
+
hour (int): The local hour.
|
|
22
|
+
weekday (int): 0 for Monday through 6 for Sunday.
|
|
23
|
+
awake (tuple): ``(from, until)`` hours, or None for always.
|
|
24
|
+
weekends (bool): True to keep those hours on Saturday and Sunday.
|
|
25
|
+
"""
|
|
26
|
+
if awake is None:
|
|
27
|
+
return True
|
|
28
|
+
if weekday >= 5 and not weekends:
|
|
29
|
+
return False
|
|
30
|
+
return awake[0] <= hour < awake[1]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def tune_touch(indev):
|
|
34
|
+
"""Make a one-finger swipe easy on *indev*.
|
|
35
|
+
|
|
36
|
+
`display_driver` asks for 255 px, so that a two-finger swipe can't steal a
|
|
37
|
+
pinch, and these apps have no pinch. A touch chip also repeats a position
|
|
38
|
+
between reads, which LVGL takes for a stopped finger and restarts its count,
|
|
39
|
+
so the minimum speed goes too. Otherwise a swipe has to cross over half of a
|
|
40
|
+
480 px screen with no repeat at all.
|
|
41
|
+
"""
|
|
42
|
+
indev.set_gesture_min_distance(_SWIPE_PX)
|
|
43
|
+
indev.set_gesture_min_velocity(0)
|
|
44
|
+
indev.set_long_press_time(_HOLD_MS)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class DeskShell(Shell):
|
|
48
|
+
"""Give each app the whole screen, with no buttons around it.
|
|
49
|
+
|
|
50
|
+
Args:
|
|
51
|
+
launcher (Launcher): The launcher it serves.
|
|
52
|
+
apps (tuple): The apps to swipe between; the first is the home screen.
|
|
53
|
+
awake (tuple): The hours the screen is lit, or None for always.
|
|
54
|
+
weekends (bool): True to keep those hours on Saturday and Sunday.
|
|
55
|
+
idle_ms (int): How long a touch keeps the screen awake, and how long
|
|
56
|
+
an app other than the first stays up without one.
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
def __init__(self, launcher, apps, *, awake, weekends, idle_ms):
|
|
60
|
+
super().__init__(launcher)
|
|
61
|
+
self.apps = apps
|
|
62
|
+
self.awake = awake
|
|
63
|
+
self.weekends = weekends
|
|
64
|
+
self.idle_ms = idle_ms
|
|
65
|
+
self._lit = True
|
|
66
|
+
device = getattr(getattr(board_config, "display_drv", None), "touch_device", None)
|
|
67
|
+
if device is not None:
|
|
68
|
+
tune_touch(device.user_data)
|
|
69
|
+
self._timer = lv.timer_create(self._check, _CHECK_MS, None)
|
|
70
|
+
|
|
71
|
+
def make_root(self, scope):
|
|
72
|
+
root = super().make_root(scope)
|
|
73
|
+
root.add_event_cb(self._gesture, lv.EVENT.GESTURE, None)
|
|
74
|
+
return root
|
|
75
|
+
|
|
76
|
+
def _gesture(self, _event):
|
|
77
|
+
direction = lv.indev_active().get_gesture_dir()
|
|
78
|
+
if direction == lv.DIR.LEFT:
|
|
79
|
+
step = 1
|
|
80
|
+
elif direction == lv.DIR.RIGHT:
|
|
81
|
+
step = -1
|
|
82
|
+
else:
|
|
83
|
+
return # up and down are the app's
|
|
84
|
+
lv.indev_active().wait_release()
|
|
85
|
+
if localtime.offset_s is None:
|
|
86
|
+
return # still asking where it is: the clock has no timezone yet
|
|
87
|
+
apps = self.apps
|
|
88
|
+
current = self.launcher.current
|
|
89
|
+
if current in apps:
|
|
90
|
+
self.launcher.request(apps[(apps.index(current) + step) % len(apps)])
|
|
91
|
+
|
|
92
|
+
def _set_lit(self, lit):
|
|
93
|
+
if lit == self._lit:
|
|
94
|
+
return
|
|
95
|
+
self._lit = lit
|
|
96
|
+
backlight = getattr(board_config, "backlight", None)
|
|
97
|
+
if backlight is not None:
|
|
98
|
+
backlight.value(1 if lit else 0)
|
|
99
|
+
else:
|
|
100
|
+
board_config.display_drv.brightness = 1.0 if lit else 0.0
|
|
101
|
+
|
|
102
|
+
def _check(self, _timer):
|
|
103
|
+
idle = lv.display_get_default().get_inactive_time()
|
|
104
|
+
current = self.launcher.current
|
|
105
|
+
if idle >= self.idle_ms and localtime.offset_s is not None:
|
|
106
|
+
if current != self.apps[0] and current in self.apps:
|
|
107
|
+
self.launcher.request(self.apps[0])
|
|
108
|
+
# Without the real time and place, a dark screen could be dark for no reason.
|
|
109
|
+
if not localtime.is_set() or localtime.offset_s is None:
|
|
110
|
+
self._set_lit(True)
|
|
111
|
+
return
|
|
112
|
+
t = localtime.now()
|
|
113
|
+
self._set_lit(is_awake(t[3], t[6], self.awake, self.weekends) or idle < self.idle_ms)
|
deskkit/shell.pyi
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""deskkit.shell: swipe between apps, drift back to the first, and sleep at night."""
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from appkit.shell import Shell
|
|
8
|
+
from appkit.launcher import Launcher
|
|
9
|
+
|
|
10
|
+
from . import localtime as localtime
|
|
11
|
+
|
|
12
|
+
def is_awake(hour: int, weekday: int, awake: tuple[int, int] | None, weekends: bool) -> bool:
|
|
13
|
+
"""Return True when the screen belongs on at this time."""
|
|
14
|
+
def tune_touch(indev: Any) -> None:
|
|
15
|
+
"""Make a one-finger swipe easy on `indev`."""
|
|
16
|
+
|
|
17
|
+
class DeskShell(Shell):
|
|
18
|
+
"""Give each app the whole screen, with no buttons around it."""
|
|
19
|
+
|
|
20
|
+
apps: tuple[str, ...]
|
|
21
|
+
awake: tuple[int, int] | None
|
|
22
|
+
weekends: bool
|
|
23
|
+
idle_ms: int
|
|
24
|
+
def __init__(
|
|
25
|
+
self,
|
|
26
|
+
launcher: Launcher,
|
|
27
|
+
apps: tuple[str, ...],
|
|
28
|
+
*,
|
|
29
|
+
awake: tuple[int, int] | None,
|
|
30
|
+
weekends: bool,
|
|
31
|
+
idle_ms: int,
|
|
32
|
+
) -> None: ...
|
|
33
|
+
def make_root(self, scope: Any) -> Any: ...
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: omnipython-applibs
|
|
3
|
+
Version: 0.1.2.dev16
|
|
4
|
+
Summary: The libraries apps share: appkit, controlkit, deskkit, programkit, sayso, songmodel, soundmodule, spectrum and touchkit
|
|
5
|
+
Author: Brad Barnett
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: lvgl,controls,apps,micropython
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: Implementation :: MicroPython
|
|
12
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+

|
|
18
|
+
|
|
19
|
+
# Apps
|
|
20
|
+
|
|
21
|
+
The apps for PyDevices: things you run on a board or a desktop. A Home app lives in `apps/`; a program, which runs on its own, lives in [`programs/`](programs/README.md).
|
|
22
|
+
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
On a Wi-Fi board, one line installs an app with what it needs, and another
|
|
26
|
+
starts Home at boot ([install an app](docs/guides/install-an-app.md)):
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
import omip
|
|
30
|
+
omip.install("github:PyDevices/apps/apps/home")
|
|
31
|
+
omip.install("github:PyDevices/apps/apps/home/main.py", target="/")
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
On a computer, the apps are used from a clone, beside the libraries they build on:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
git clone https://github.com/PyDevices/apps
|
|
38
|
+
git clone https://github.com/PyDevices/audioinstruments
|
|
39
|
+
git clone https://github.com/PyDevices/audioeffects
|
|
40
|
+
git clone https://github.com/PyDevices/audiodsp
|
|
41
|
+
pip install ./audiodsp numpy
|
|
42
|
+
pip install --no-deps ./audioinstruments ./audioeffects/lib/audioeffects
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The libraries the apps share (`appkit`, `controlkit`, `deskkit`, `sayso`,
|
|
46
|
+
`songmodel`, `soundmodule`, `spectrum` and `touchkit`) also install as a package, under
|
|
47
|
+
their own names. Each is imported directly, as in `import controlkit`:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install -i https://test.pypi.org/simple/ omnipython-applibs
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
On a board, use `mip.install("applibs", index="https://lib.omnipython.org")`.
|
|
54
|
+
To freeze them into firmware, name this repository's folder as a module of the
|
|
55
|
+
build: its [manifest.py](manifest.py) lists them.
|
|
56
|
+
|
|
57
|
+
## Try it
|
|
58
|
+
|
|
59
|
+
Render a MIDI file through the sound module to a WAV, with no MIDI hardware.
|
|
60
|
+
The sound comes from a General MIDI SoundFont (`.sf2`) that you supply, such
|
|
61
|
+
as [GeneralUser GS](https://schristiancollins.com/generaluser.php):
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
cd apps
|
|
65
|
+
python tools/render_mid.py tests/midi/musicbox1_spooky_waltz.mid take.wav --bank GeneralUser-GS.sf2 --path lib
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
It writes `take.wav`, 53 seconds of celesta, and prints what it measured:
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
notes 261
|
|
72
|
+
played 261
|
|
73
|
+
held 0
|
|
74
|
+
sounding 0
|
|
75
|
+
song 53.310
|
|
76
|
+
render 0.947
|
|
77
|
+
reverb 0
|
|
78
|
+
chorus 0
|
|
79
|
+
soundmodule: cpython 3.12.3 (linux): 0 bytes of MIDI, 0 Identity Requests answered, render behind by at most 0 ms while playing (0 ms before the first note)
|
|
80
|
+
channel 1: 157 notes, bank 0:0 program 8, Celesta
|
|
81
|
+
channel 2: 56 notes, bank 0:0 program 8, Celesta
|
|
82
|
+
channel 3: 32 notes, bank 0:0 program 8, Celesta
|
|
83
|
+
channel 16: 16 notes, bank 0:0 program 8, Celesta
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`played` equals `notes` when every note sounded. The `render` and interpreter lines are yours to differ on.
|
|
87
|
+
|
|
88
|
+
[Docs](docs/index.md) | [Examples](https://gallery.omnipython.org) | [Roadmap](ROADMAP.md)
|
|
89
|
+
|
|
90
|
+
Made by [PyDevices](https://pydevices.com).
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
appkit/__init__.py,sha256=5VhCqMliOfrqWG8YPPYzk6MQZhEgtbnqznfdhfBAUVM,1782
|
|
2
|
+
appkit/__init__.pyi,sha256=MulQpeEjmQiyQwg5UhAny47m4fYxthSQ9PVpbBETxrk,773
|
|
3
|
+
appkit/data.py,sha256=BcC5J7VzrLvfwQUQAKTqMglDg-rngugzxbUfF8N52QM,4819
|
|
4
|
+
appkit/data.pyi,sha256=DKSY6JONkUyfmuV5npMtcxZ9LI96SdfEWXFm2SgAJ3E,1173
|
|
5
|
+
appkit/foreground.py,sha256=X_JDOnT89fuJkJkRIKb8bmJf72EzdfjGjHaRZc9zkVA,10719
|
|
6
|
+
appkit/foreground.pyi,sha256=EDDRTP0yIHMabq0xuOAf3avOsYu2eqUryq2hVQLIfbY,1840
|
|
7
|
+
appkit/home.py,sha256=Zrw0mJDAhaT0chJfsV6JfKRiNCuSjl5NP_mUzqniWoY,613
|
|
8
|
+
appkit/home.pyi,sha256=CLXo6znElgVe5RjxG_6yGfOC827p5cifdi04j4HrXD4,192
|
|
9
|
+
appkit/hover.py,sha256=8zqBTf0s4KGDpE1hzSij9Z5ELnMPchb7kTjraM3J1jA,2043
|
|
10
|
+
appkit/hover.pyi,sha256=g_mL_8gFzXHme9yKP5Xlkt7C258g4waXYMZ98uE4wAQ,382
|
|
11
|
+
appkit/index.py,sha256=L14sDN8VNTIKwedvlJmD2UyCTMKlkNn4S6OQxLlDVac,7419
|
|
12
|
+
appkit/index.pyi,sha256=0B2IXWARxHsPcJ2hf7GSJ5dWdvj4ILiOuOfU16-3L9s,1305
|
|
13
|
+
appkit/launcher.py,sha256=c0G3ipNunPLVFwueKY0TD0EUvzry1lBDN5bqiQ6w0ZU,38889
|
|
14
|
+
appkit/launcher.pyi,sha256=mUIkKL1bdUJBBxCT2kWPIcqUK1L5b2XX7NIKruVXUbU,4240
|
|
15
|
+
appkit/manifest.py,sha256=uqfqP_cjmzsjb0jcLxQpKsJ08l0_SXabRwmOPKrNTj4,3349
|
|
16
|
+
appkit/manifest.pyi,sha256=GO-QnrDcQk0hjJSAY-xNjPfTBbI8034XaZzIwU-bYdw,192
|
|
17
|
+
appkit/net.py,sha256=EeimncWJycFbhIgea53byKkvb4QpPzMpxbgiPv-412I,5406
|
|
18
|
+
appkit/net.pyi,sha256=u2SkkfhZN4xcLE1IN3sclhonrDhBa6qxxqASnwwqzoo,1107
|
|
19
|
+
appkit/places.py,sha256=MW3M-sVYo1UmikLMSKZ4nhVkRsuWsW9TvppZGMyOxa8,5840
|
|
20
|
+
appkit/places.pyi,sha256=N6G6kPYp4T5ghOyXj6SsZRwMIEojYS5tQmIgQpLaeFg,1514
|
|
21
|
+
appkit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
|
+
appkit/scope.py,sha256=M-3bM3itOLOEds1wx13x6DoJkvVv3Ixu1RZC5OGnbcI,22675
|
|
23
|
+
appkit/scope.pyi,sha256=Lcy1soB_qv8ildKvcgRwA6mGqYAS3dhFvvoZcpMM9us,5024
|
|
24
|
+
appkit/shell.py,sha256=bcQ7f0-6BwMo5U6rzyvQKXPYRVRJXtm9sUUecIQ3qaw,4734
|
|
25
|
+
appkit/shell.pyi,sha256=Umls7kvfTDKxSuVWZSV1ZbY4MKV4DkhoHO4SR6d8m2I,1283
|
|
26
|
+
appkit/worker.py,sha256=0Nna-_i7JbPQSga-kgj26tqPsKm-HgMwPm5TCQS7vRU,13432
|
|
27
|
+
appkit/worker.pyi,sha256=shQLoPi8vDBZ_isuT-LGZ4A7xL7O1iHfMy1CySNlCnc,2795
|
|
28
|
+
controlkit/__init__.py,sha256=LTpASI_9w2FPqArTzmXF-esExrAWLSiQpoBfxNBimOQ,745
|
|
29
|
+
controlkit/__init__.pyi,sha256=AJQGA5xHCXO1TyZpCmctQXRc8Plmjc4gJurs-jr0YeE,350
|
|
30
|
+
controlkit/_draw.py,sha256=8tc2V_oTkPQ5Zn2Wjo_crDwAwmYruIm3jFMZaXO6L7w,2808
|
|
31
|
+
controlkit/_safe.py,sha256=z12oVglH7YlKh_BiYvxlTAxrvwCxqb6dHMDHU8cSAVc,802
|
|
32
|
+
controlkit/dotmatrix.py,sha256=d-ts9NKoSEuzZacqsC54v42W1VBaITqoB3dHfUiyVqw,3533
|
|
33
|
+
controlkit/dotmatrix.pyi,sha256=3oRsgErJf39KlaDFt1E8wBa2kGU14H-qQTh6-c7MdQE,750
|
|
34
|
+
controlkit/encoder.py,sha256=5AWtXq3q5XAgMTv8wp5YLkYZnQGfWSCqgk09vjNkmW0,11150
|
|
35
|
+
controlkit/encoder.pyi,sha256=RsxC6AaOaWzOo__kxe22f8xN5MWPVHWYWzXHBSgYtKE,1433
|
|
36
|
+
controlkit/font5x7.py,sha256=0iQ0eXP2C0y63kecBHImgKF0hdqHMvBzZzBiq3FbTSM,3211
|
|
37
|
+
controlkit/font5x7.pyi,sha256=SgngmvfOQ9lw6nhq45SJgNMXYIe-zmYzkc27sXYh-MM,256
|
|
38
|
+
controlkit/lamp_button.py,sha256=N91FYo0m46WTuPYHBaHAhUii2It11djXeOmRJIDag-M,3242
|
|
39
|
+
controlkit/lamp_button.pyi,sha256=bfSmUaqDt0GTZKynFzuPRxEIsYH7o5ibwlnS4CC14E4,1126
|
|
40
|
+
controlkit/meter.py,sha256=OMjfPoMv8EjLBco9zjzg35gxGIgjgykP3g3sFc8aojA,3020
|
|
41
|
+
controlkit/meter.pyi,sha256=1zeiV59LFA3ON_3IYTkNxjBmz5d527FuDLRkuTCHcvA,763
|
|
42
|
+
controlkit/mock.py,sha256=AJghjexPZd3oQSoUsj8Npa1REJSOhB7-wri5mCEU5FI,3969
|
|
43
|
+
controlkit/mock.pyi,sha256=rhBqk02W7M2EVOQardyGDUFtE5Doywi3VRhau4AzBGU,1358
|
|
44
|
+
controlkit/pad_grid.py,sha256=igkN5IgVC4YguAlJSBKwPgj8RwB7yzcfgRy3Q2oNClc,4365
|
|
45
|
+
controlkit/pad_grid.pyi,sha256=4ju8ZFZEQTOwmogvOFsmRczc1oGOsfrOxCnUkWYw-Zs,1408
|
|
46
|
+
controlkit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
47
|
+
controlkit/slider.py,sha256=B_BjyWECJYecJHIGWxPPHaiAKNVQ51gKVXYL6ZzNJOA,7066
|
|
48
|
+
controlkit/slider.pyi,sha256=R02LeBgQ2KgpJEj2vxN9FnhXPkWq2Y7FbWpjEyeB1uA,1264
|
|
49
|
+
controlkit/sprites.py,sha256=KlPcEaJD3K9HkTYDF_MTGtGEc68OSb-Deyuq-Qp182I,9806
|
|
50
|
+
controlkit/sprites.pyi,sha256=LVsVUIKwcyN-zdbHoorBbAZ0qtUdqjCxsdFjsjtX0g4,1127
|
|
51
|
+
controlkit/theme.py,sha256=u3KIq3l0y5XIWdnCR53O2u3C6lyRyUihHzH7tYN5Aag,3481
|
|
52
|
+
controlkit/theme.pyi,sha256=2lwtEniUZkNPU45OHKENE2ifJSUoz4ZVK0DhUMdU9HI,555
|
|
53
|
+
deskkit/__init__.py,sha256=e7j07T7y0aXK0CeFhX5RbbzB9uylP9JsjiyPlJ5SpXs,2633
|
|
54
|
+
deskkit/__init__.pyi,sha256=Tmyf_-9Awmv-KDs-4n92BG-pj_x0fkw8KKdPq2USW20,481
|
|
55
|
+
deskkit/forecast.py,sha256=x9B7kJBqXx7Ejysy8c_wuf_N_yXcwPDU0eeZuGvGB1s,7729
|
|
56
|
+
deskkit/forecast.pyi,sha256=TMlfN_46dPSFR-R-wSZVV2Hy4EccWn-wPUpNFQXNx6A,1800
|
|
57
|
+
deskkit/localtime.py,sha256=gIDfoq7jNDbJse9lmrbh1AvDePDVzKwgsbDEOftQy5s,6844
|
|
58
|
+
deskkit/localtime.pyi,sha256=3inCrxpJAKUq1y4TgrFb-d3m1dkaTiB73YEFOIvohWU,1561
|
|
59
|
+
deskkit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
60
|
+
deskkit/shell.py,sha256=wQQzmq64ePikaIOl_r9CD63KdBqflqOhk7o2w74GY5A,4153
|
|
61
|
+
deskkit/shell.pyi,sha256=cgH126YIAd1ut5Ikr-FWovFTk700z2FfNAG2O3iNbt0,983
|
|
62
|
+
omnipython_applibs-0.1.2.dev16.dist-info/licenses/LICENSE,sha256=NI0iQ7ka4pGq-257oD6FAsPI6yOQAAGbKHCj4TjHT6U,1069
|
|
63
|
+
programkit/__init__.py,sha256=fPzh1dVmdRmFITm0QwXCkd4m1SPl4BSFXJWQPJly_bQ,959
|
|
64
|
+
programkit/__init__.pyi,sha256=rSHl29mApn8zegZMenkwc_Dfrce6LPM5nswEyiu21EI,214
|
|
65
|
+
programkit/board.py,sha256=t-0DdF2jh_6cDHXmLWbw7OTTVSana_1slKLsyF5PhQM,1971
|
|
66
|
+
programkit/board.pyi,sha256=bZ0UnK1J2Edna2RGt1xw-naX8rA9r5pHBzXtvgAlQrE,751
|
|
67
|
+
programkit/press.py,sha256=FRHGm3RGgn3pOm5ENfDe1x0FWO_X2PDS3g5BYXPb1FU,1946
|
|
68
|
+
programkit/press.pyi,sha256=0LEACoLnBObN95y5cCgc6v-xQLa2plEeeRJwxNqekX0,605
|
|
69
|
+
programkit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
70
|
+
programkit/rows.py,sha256=yNDKML9u_ZT_msivp9cURy-szUjLDmhrXFHPfFQ7yEU,5620
|
|
71
|
+
programkit/rows.pyi,sha256=K7f2pkzZkAAncQriSfWgr9zncbxlmrM_-tcAZIYnvlg,1330
|
|
72
|
+
sayso/__init__.py,sha256=OORjsBy8aJ-9wUeM_DiSPyadtin8lbuNHM6cprDY6I4,2586
|
|
73
|
+
sayso/__init__.pyi,sha256=cgh5t2c53dejTMfIrrR3uKkICjzAeIdcI9sQ0B1fKq4,6257
|
|
74
|
+
sayso/auth.py,sha256=C-G6s_cBU22t4bGECiHCCSFfvahFMrR_dmCkHPJKqK8,21701
|
|
75
|
+
sayso/auth.pyi,sha256=vqhotAiDPjuOB-iYxlMxnUIWnqLe5mpvTJiEOmtbmcI,5269
|
|
76
|
+
sayso/client.py,sha256=bYYdLjzz47VuzGib-3PPJLt2rrqrCsTbn7lMTjhuYp8,54013
|
|
77
|
+
sayso/client.pyi,sha256=Yi7K8XT8CZlMp_50Fa14ABPsX5XCwFgF_YLsxODT9x0,12793
|
|
78
|
+
sayso/keepalive.py,sha256=t_Q_KEf4cJz0DG5gnNg1vGHnP23GWvTkM2-rszncwU0,12074
|
|
79
|
+
sayso/keepalive.pyi,sha256=GodI6ABppAHCjv3NyP0ekEeDtJmlyGnrh9ZkQuh-Ano,1797
|
|
80
|
+
sayso/local.py,sha256=pyCDx_UCHFlqhMsVyoUdejBG5ewwfuvOnabemyJXLwI,3124
|
|
81
|
+
sayso/local.pyi,sha256=LueJfiFpQaA6BlDBOSPB7G8-i39Al_AfwqffqUIHvr4,1055
|
|
82
|
+
sayso/object_specs.py,sha256=4fs5jzl2Pv10GfhM6STD2XoffDgjEadl6OqLZuBVZKM,21984
|
|
83
|
+
sayso/object_specs.pyi,sha256=Ahaqk0yu4EVm9vsc8sGZsu5BkeJxZng4Lw9hqj5nOWU,213
|
|
84
|
+
sayso/objects.py,sha256=lATylglCmqJnG97eTapeXJD8T_8crWYcQWQIcEUiQVI,10786
|
|
85
|
+
sayso/objects.pyi,sha256=c8w__DKSCc-arv_lifjooPVCSwTivu5cnXtDu1dJk74,23569
|
|
86
|
+
sayso/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
87
|
+
sayso/schema_coverage.py,sha256=S1R3Un6HEfhDhwqtCtbF9aOgaadx0AsdhUuR-AkK5O8,6313
|
|
88
|
+
sayso/schema_coverage.pyi,sha256=wCYQroLG51-fIDyW1g2cby-wcvCI-RM-H5z2sJLf71k,419
|
|
89
|
+
sayso/transport.py,sha256=Fb6RWa-Tb_2ZVLbiiXQoOm45YiQc6O7xFfeBw35OdAo,12231
|
|
90
|
+
sayso/transport.pyi,sha256=NC-NHszXPK68uTydQJBpig4fKXab6wIVPiNHYqN3PEM,3287
|
|
91
|
+
songmodel/__init__.py,sha256=RCQDK1Gvx181cn6k4poKoiuyo7gynknR7djwUXQBoJU,1055
|
|
92
|
+
songmodel/__init__.pyi,sha256=JECMdd1TXRaFJmhzhRp9gLF69Bz4FSxTNuFfkGz69QY,334
|
|
93
|
+
songmodel/link.py,sha256=DnK_XJwvnUPiC5J3slngsoTfm-GmdeU32BVPi1RvODs,7127
|
|
94
|
+
songmodel/link.pyi,sha256=fwfb2x_p88K8d03D7iEeSJNrlbtnCDTZmquiSx9Vias,1961
|
|
95
|
+
songmodel/model.py,sha256=6woqbZCqLLh86nqH4b50GUU5iPnM8RIQ9sMVzIySuvI,8248
|
|
96
|
+
songmodel/model.pyi,sha256=UYSFpz-EKd0PW7Z8ctljE9k-sq6D6lWlmVhAY8t5mIQ,1602
|
|
97
|
+
songmodel/page.html,sha256=_JaUVDzY_30hrhhBJu2bSPKpm5pZEr-H0whm6Tlo43o,10346
|
|
98
|
+
songmodel/page_data.py,sha256=sXsb1aAzMgPs1R6bgHhNP9rQo1m7McTE9E4xXiNukWA,12380
|
|
99
|
+
songmodel/page_data.pyi,sha256=Ne2dxpq33VTd3cXE2nTb8qwHPYCHzT7aCInNpB3dS9Y,149
|
|
100
|
+
songmodel/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
101
|
+
soundmodule/__init__.py,sha256=WdX88iMrBL_LHYV3BajFgYVaWleUV5MuQHXrT-8UzDY,222
|
|
102
|
+
soundmodule/__init__.pyi,sha256=iCgZZRApLfzfqPMhzjIahLCeo7-yuo7og4VtsZN4F18,211
|
|
103
|
+
soundmodule/engine.py,sha256=YE3ofRZXXPNBM7C5lf1Kq-ylykfQLDxuTHpHOZHIgoM,43596
|
|
104
|
+
soundmodule/engine.pyi,sha256=OwMXQWeG-0vm6mGB2Z08jHB09rfu_CcGjb6F5uLp7_o,6242
|
|
105
|
+
soundmodule/names.py,sha256=e_YxmG9S8IzAQa57uZojEqmbMaiZOwkaN4O-xQTtLms,12842
|
|
106
|
+
soundmodule/names.pyi,sha256=ODMAssqAkf5xuOefasGRDHvEFv0OKKNgicEBJBB_1A4,1151
|
|
107
|
+
soundmodule/pipes.py,sha256=6es9A3zGwQdmmCFSpJ5282--DkBcMHk9tG_QGBd3UkA,3240
|
|
108
|
+
soundmodule/pipes.pyi,sha256=Vj2Y71vD0sdc4beupRbGFvFk1UYeKAtSyUND8a5JoF4,1046
|
|
109
|
+
soundmodule/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
110
|
+
soundmodule/run.py,sha256=2JLLFc_wjetENwCtycTY0gwxc2_xACoGx0JI8aIugTg,8877
|
|
111
|
+
soundmodule/run.pyi,sha256=ydEWKgn3_851_WtGwfr0TwIeU09a-HDPQ1qxjvARRLM,1467
|
|
112
|
+
spectrum/__init__.py,sha256=JuEOjVmP5z-JWJ_Hbw3abJMwQi9o-SQxxVmGi239Reg,2099
|
|
113
|
+
spectrum/__init__.pyi,sha256=5l_Aujorsj3Aj6OWiyQRMgYo1MTKIin39nRI2IGkUH0,1083
|
|
114
|
+
spectrum/analyzer.py,sha256=Le5qrzPTnrFbQnDiIH4rO4AG3EKGVomJqCetINhJKbY,9580
|
|
115
|
+
spectrum/analyzer.pyi,sha256=nLimyBDTQJM_JLIMaG121iYI21h0pD7y5guLW_mzBgY,2104
|
|
116
|
+
spectrum/fake_music.py,sha256=t5jiRT0dk6u9QaTTQTXcKJgEpNuueQori32NRnJT6RY,7124
|
|
117
|
+
spectrum/fake_music.pyi,sha256=FUbbe7KCwovIFHvwrZ7rOr8UDTmEKjk5wr0rUct7cjo,929
|
|
118
|
+
spectrum/pump_levels.py,sha256=Sc41t9aPnzOinc-9txIqtLv37gxHKeBDoEkFdJtJedk,4666
|
|
119
|
+
spectrum/pump_levels.pyi,sha256=PruS0x69xDISKkYs6iaIibasAgjHBmtNZiqS2AHfWCU,1302
|
|
120
|
+
spectrum/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
121
|
+
spectrum/spectrum_view.py,sha256=X8EOUBNmRcbefVBOMSjKSIFMODI-YvORML3iK0vkbxk,16163
|
|
122
|
+
spectrum/spectrum_view.pyi,sha256=NxeQeBi3r3fKMBaQIda8xqQx9f0laSjGzNnor-nvJRk,2588
|
|
123
|
+
touchkit/__init__.py,sha256=Y8Rr-MnDMTjR9IRb1CW3dFA-afTZgzPLlChlH-nfCl0,150
|
|
124
|
+
touchkit/__init__.pyi,sha256=3RI8XLKdov13ehrnVVd1Qyt2T5o5pQd2I1sgKFg2IQk,134
|
|
125
|
+
touchkit/cam.py,sha256=TuSuRwOd3CoIaAvnDYyHaGPq8E-AnGMiFzd6sdS12XE,5406
|
|
126
|
+
touchkit/cam.pyi,sha256=bQ96UW7krol8d9xDpb605cmAiQJAConc380gsOXbK24,1455
|
|
127
|
+
touchkit/clock.py,sha256=MBOes40NWrCg8ubSB_9RmXhKhAW9wXsQUYnYLu6xUSU,481
|
|
128
|
+
touchkit/clock.pyi,sha256=wYDP-ycMyb1W-BNDHaN873wk5c3KM10mBxd49L-gcHw,167
|
|
129
|
+
touchkit/ecp.py,sha256=wGQ8iEzgTn96qqxboNOn_vkpGkbLxCKiu8LY3vf3oH4,4443
|
|
130
|
+
touchkit/ecp.pyi,sha256=X_hh__Zq-swXVBFPRBTau4rLfffP_OQ15r3hipI6xGs,929
|
|
131
|
+
touchkit/net.py,sha256=jc5A-ENZVKQKcu14XHK94TdqrrpFn_0ympCsmbvqubA,11067
|
|
132
|
+
touchkit/net.pyi,sha256=KIvsOfZZ3IbqVqRLS8hTbcI9FAJhZU3r4_ogMtEZyTg,1161
|
|
133
|
+
touchkit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
134
|
+
touchkit/settings.py,sha256=xO3an_b1kVCTi-P4vSnNRuR8Sw-nCTMeZE6iYv-5VMw,2597
|
|
135
|
+
touchkit/settings.pyi,sha256=v2bqIlC_ataFVUmYJVMnPrAARccQgwt_nJWVG4ifSCM,639
|
|
136
|
+
touchkit/shell.py,sha256=J1CUPh5DQld8dNj9goz_9G-vVpwreur0Y8RmNuvntG4,9099
|
|
137
|
+
touchkit/shell.pyi,sha256=MxwW4qxWFXftCj2bEkoPSN4WoSjdMbpMukmGNsKAxEM,1445
|
|
138
|
+
touchkit/ui.py,sha256=Mm7SCtjHzejt5b0TzbkSTMurzBUbweHM97W5dmP39ow,4915
|
|
139
|
+
touchkit/ui.pyi,sha256=PNDuPR0U2ge5pJq4FhXJXYXywj4YHM4msL5jTY-mih4,1871
|
|
140
|
+
omnipython_applibs-0.1.2.dev16.dist-info/METADATA,sha256=tdPGQUSo1f5O5T8kW4FZeC83DaWEkpx64Zb39pNzud8,3301
|
|
141
|
+
omnipython_applibs-0.1.2.dev16.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
142
|
+
omnipython_applibs-0.1.2.dev16.dist-info/top_level.txt,sha256=HGazKmU9bM1oIAaURgDTwy5SZqF-IFn-ctteLdgQJz4,83
|
|
143
|
+
omnipython_applibs-0.1.2.dev16.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Brad Barnett
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
programkit/__init__.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""Reach a board's display, keys and touch from a program that runs without Home.
|
|
5
|
+
|
|
6
|
+
A program in ``programs/`` runs on any board with the hardware it needs, so it
|
|
7
|
+
never names a pin. `Board` finds what the board's ``board_config`` and
|
|
8
|
+
``board_peripherals`` offer, `Rows` puts lines of text on whatever display is
|
|
9
|
+
there, and `Press` hears a press of any key, touch or button::
|
|
10
|
+
|
|
11
|
+
from programkit import Board, Press, Rows
|
|
12
|
+
|
|
13
|
+
board = Board()
|
|
14
|
+
rows = Rows(board.display) if board.display else None
|
|
15
|
+
press = Press(board)
|
|
16
|
+
if board.has("audio_out"):
|
|
17
|
+
out = board.get("audio_out")(AudioFormat(44100, 2, 16))
|
|
18
|
+
|
|
19
|
+
A board with no display has no ``board_config``; `Board` then reads
|
|
20
|
+
``board_peripherals`` alone, which is how a headless board describes itself.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
from .board import Board
|
|
24
|
+
from .press import Press
|
|
25
|
+
from .rows import Rows
|
|
26
|
+
|
|
27
|
+
__all__ = ["Board", "Press", "Rows"]
|
programkit/__init__.pyi
ADDED
programkit/board.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""What the board offers: its ``board_config`` if it has one, and its lazy roles."""
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def _optional(name):
|
|
8
|
+
"""Import a module that may be absent, but not one that's broken."""
|
|
9
|
+
try:
|
|
10
|
+
return __import__(name)
|
|
11
|
+
except ImportError as e:
|
|
12
|
+
if name in str(e):
|
|
13
|
+
return None
|
|
14
|
+
raise
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Board:
|
|
18
|
+
"""The board this program runs on.
|
|
19
|
+
|
|
20
|
+
Importing ``board_config`` starts the board's display, so a program that
|
|
21
|
+
makes a `Board` gets one. A board without a display has only
|
|
22
|
+
``board_peripherals``.
|
|
23
|
+
|
|
24
|
+
Attributes:
|
|
25
|
+
config: the ``board_config`` module, or None.
|
|
26
|
+
peripherals: the ``board_peripherals`` module, or None.
|
|
27
|
+
display: ``board_config.display_drv``, or None.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
def __init__(self):
|
|
31
|
+
self.config = _optional("board_config")
|
|
32
|
+
self.peripherals = _optional("board_peripherals")
|
|
33
|
+
self.display = getattr(self.config, "display_drv", None)
|
|
34
|
+
self._roles = getattr(self.peripherals, "PERIPHERALS", frozenset())
|
|
35
|
+
self._factories = getattr(self.peripherals, "FACTORY_ROLES", frozenset())
|
|
36
|
+
|
|
37
|
+
def has(self, role):
|
|
38
|
+
"""True when the board lists ``role`` (``"audio_out"``, ``"sdcard"``, ...)."""
|
|
39
|
+
return role in self._roles
|
|
40
|
+
|
|
41
|
+
def get(self, role):
|
|
42
|
+
"""The role's object, or its factory for the audio roles; None if absent.
|
|
43
|
+
|
|
44
|
+
Each call through ``board_peripherals`` alone makes a new object, so
|
|
45
|
+
keep what this returns.
|
|
46
|
+
"""
|
|
47
|
+
if role not in self._roles:
|
|
48
|
+
return None
|
|
49
|
+
if self.config is not None:
|
|
50
|
+
return getattr(self.config, role)
|
|
51
|
+
factory = getattr(self.peripherals, role)
|
|
52
|
+
return factory if role in self._factories else factory()
|
|
53
|
+
|
|
54
|
+
def eager(self, name):
|
|
55
|
+
"""A ``board_config`` name such as ``touch_read`` or ``keypad_read``, or None."""
|
|
56
|
+
return getattr(self.config, name, None)
|
programkit/board.pyi
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""What the board offers: its `board_config` if it has one, and its lazy roles."""
|
|
5
|
+
from types import ModuleType
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
class Board:
|
|
9
|
+
"""The board this program runs on."""
|
|
10
|
+
|
|
11
|
+
config: ModuleType | None
|
|
12
|
+
peripherals: ModuleType | None
|
|
13
|
+
display: Any
|
|
14
|
+
def __init__(self) -> None: ...
|
|
15
|
+
def has(self, role: str) -> bool:
|
|
16
|
+
"""True when the board lists `role` (`"audio_out"`, `"sdcard"`, ...)."""
|
|
17
|
+
def get(self, role: str) -> Any:
|
|
18
|
+
"""The role's object, or its factory for the audio roles; None if absent."""
|
|
19
|
+
def eager(self, name: str) -> Any:
|
|
20
|
+
"""A `board_config` name such as `touch_read` or `keypad_read`, or None."""
|
programkit/press.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""A press of any key, touch or button the board has."""
|
|
5
|
+
|
|
6
|
+
import time
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Press:
|
|
10
|
+
"""Hears the board's touch screen, its keys and its Boot button as one button.
|
|
11
|
+
|
|
12
|
+
Call it as often as the program loops. It reads every source each time,
|
|
13
|
+
so a board with none of them simply never reports a press.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
board: a `Board`.
|
|
17
|
+
|
|
18
|
+
Attributes:
|
|
19
|
+
sources: the names of what it listens to, for a program to report.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def __init__(self, board):
|
|
23
|
+
self._reads = []
|
|
24
|
+
self.sources = []
|
|
25
|
+
touch = board.eager("touch_read")
|
|
26
|
+
if touch is not None:
|
|
27
|
+
self._reads.append(lambda: bool(touch()))
|
|
28
|
+
self.sources.append("touch")
|
|
29
|
+
keys = board.eager("keypad_read")
|
|
30
|
+
if keys is not None:
|
|
31
|
+
self._reads.append(lambda: bool(keys()))
|
|
32
|
+
self.sources.append("keys")
|
|
33
|
+
button = board.get("boot_button")
|
|
34
|
+
if button is not None:
|
|
35
|
+
self._reads.append(lambda: button.value() == 0)
|
|
36
|
+
self.sources.append("Boot button")
|
|
37
|
+
self._down_at = None
|
|
38
|
+
|
|
39
|
+
def down(self):
|
|
40
|
+
"""True while anything is pressed."""
|
|
41
|
+
for read in self._reads:
|
|
42
|
+
try:
|
|
43
|
+
if read():
|
|
44
|
+
return True
|
|
45
|
+
except OSError:
|
|
46
|
+
pass # a touch controller that missed one read
|
|
47
|
+
return False
|
|
48
|
+
|
|
49
|
+
def __call__(self):
|
|
50
|
+
"""True once for each new press."""
|
|
51
|
+
if self.down():
|
|
52
|
+
if self._down_at is None:
|
|
53
|
+
self._down_at = time.ticks_ms()
|
|
54
|
+
return True
|
|
55
|
+
return False
|
|
56
|
+
self._down_at = None
|
|
57
|
+
return False
|
|
58
|
+
|
|
59
|
+
def held_ms(self):
|
|
60
|
+
"""How long the current press has lasted, in ms, or None between presses."""
|
|
61
|
+
if self._down_at is None:
|
|
62
|
+
return None
|
|
63
|
+
return time.ticks_diff(time.ticks_ms(), self._down_at)
|
programkit/press.pyi
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""A press of any key, touch or button the board has."""
|
|
5
|
+
from .board import Board
|
|
6
|
+
|
|
7
|
+
class Press:
|
|
8
|
+
"""Hears the board's touch screen, its keys and its Boot button as one button."""
|
|
9
|
+
|
|
10
|
+
sources: list[str]
|
|
11
|
+
def __init__(self, board: Board) -> None: ...
|
|
12
|
+
def down(self) -> bool:
|
|
13
|
+
"""True while anything is pressed."""
|
|
14
|
+
def __call__(self) -> bool:
|
|
15
|
+
"""True once for each new press."""
|
|
16
|
+
def held_ms(self) -> int | None:
|
|
17
|
+
"""How long the current press has lasted, in ms, or None between presses."""
|
programkit/py.typed
ADDED
|
File without changes
|