omnipython-apps 0.1.4.dev8__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.
- apps/__init__.py +5 -0
- apps/about/__init__.py +257 -0
- apps/about/app.json +1 -0
- apps/about/credits.py +12 -0
- apps/about/facts.py +398 -0
- apps/about/fonts/OFL.txt +93 -0
- apps/about/fonts/latin1_14.bin +0 -0
- apps/about/fonts/latin1_16.bin +0 -0
- apps/about/fonts/latin1_24.bin +0 -0
- apps/about/fonts/latin1_32.bin +0 -0
- apps/about/fonts/latin1_40.bin +0 -0
- apps/backline/__init__.py +58 -0
- apps/backline/app.json +1 -0
- apps/backline/app.py +475 -0
- apps/backline/art.py +717 -0
- apps/backline/ask.py +781 -0
- apps/backline/box.py +502 -0
- apps/backline/cast.py +137 -0
- apps/backline/desk/__init__.py +329 -0
- apps/backline/desk/editor.py +331 -0
- apps/backline/desk/grid.py +154 -0
- apps/backline/desk/look.py +169 -0
- apps/backline/desk/pedals.py +102 -0
- apps/backline/desk/perform.py +157 -0
- apps/backline/desk/prompt.py +210 -0
- apps/backline/desk/strip.py +159 -0
- apps/backline/desk_main.py +226 -0
- apps/backline/engine.py +622 -0
- apps/backline/floor.py +509 -0
- apps/backline/footswitch.py +119 -0
- apps/backline/glyphs.py +82 -0
- apps/backline/kits.py +428 -0
- apps/backline/midipedal.py +362 -0
- apps/backline/page_data.py +413 -0
- apps/backline/parts.py +145 -0
- apps/backline/pedal.py +107 -0
- apps/backline/remote.py +134 -0
- apps/backline/songs/ballad_68.json +1 -0
- apps/backline/songs/bossa.json +1 -0
- apps/backline/songs/country_train.json +1 -0
- apps/backline/songs/funk.json +1 -0
- apps/backline/songs/metal.json +1 -0
- apps/backline/songs/pop.json +1 -0
- apps/backline/songs/rock.json +1 -0
- apps/backline/songs/shuffle.json +1 -0
- apps/battery/__init__.py +101 -0
- apps/battery/app.json +1 -0
- apps/bit_world/act_deck.py +683 -0
- apps/bit_world/act_game.py +762 -0
- apps/bit_world/act_pet.py +1032 -0
- apps/bit_world/app.json +1 -0
- apps/bit_world/bit_output.py +45 -0
- apps/bit_world/bit_palette.py +503 -0
- apps/bit_world/bit_sound.py +431 -0
- apps/bit_world/bit_sprites.py +632 -0
- apps/bit_world/bit_world.py +534 -0
- apps/btreceiver/__init__.py +690 -0
- apps/btreceiver/app.json +1 -0
- apps/btreceiver/chime.py +155 -0
- apps/btreceiver/demo.py +529 -0
- apps/btreceiver/screen.py +633 -0
- apps/camera/__init__.py +316 -0
- apps/camera/app.json +1 -0
- apps/card/__init__.py +113 -0
- apps/card/app.json +1 -0
- apps/cast/__init__.py +631 -0
- apps/cast/app.json +1 -0
- apps/cast/receivers.py +193 -0
- apps/chess/__init__.py +18 -0
- apps/chess/app.json +1 -0
- apps/chess/app.py +922 -0
- apps/chess/art.py +323 -0
- apps/chess/ble.py +411 -0
- apps/chess/engine.py +925 -0
- apps/chess/game.py +327 -0
- apps/chess/net.py +261 -0
- apps/clock/__init__.py +38 -0
- apps/clock/app.json +1 -0
- apps/detect/__init__.py +214 -0
- apps/detect/app.json +1 -0
- apps/fmsynth/__init__.py +41 -0
- apps/fmsynth/algorithms.py +61 -0
- apps/fmsynth/app.json +1 -0
- apps/fmsynth/app.py +355 -0
- apps/fmsynth/editor.py +206 -0
- apps/fmsynth/engine.py +257 -0
- apps/fmsynth/meters.py +262 -0
- apps/fmsynth/midi.py +375 -0
- apps/fmsynth/panel_view.py +1071 -0
- apps/fmsynth/patches/fmsynth-01.syx +0 -0
- apps/fmsynth/settings.py +138 -0
- apps/fmsynth/voice.py +398 -0
- apps/gamepad/__init__.py +685 -0
- apps/gamepad/app.json +1 -0
- apps/gamepad/pad.py +94 -0
- apps/gamepad/watch.py +352 -0
- apps/hidden/__init__.py +72 -0
- apps/hidden/app.json +1 -0
- apps/home/__init__.py +483 -0
- apps/home/app.json +1 -0
- apps/home/main.py +36 -0
- apps/homeassistant/__init__.py +213 -0
- apps/homeassistant/api.py +104 -0
- apps/homeassistant/app.json +1 -0
- apps/huey/__init__.py +287 -0
- apps/huey/acting.py +184 -0
- apps/huey/actor.py +194 -0
- apps/huey/app.json +1 -0
- apps/huey/client.py +125 -0
- apps/huey/servers.py +121 -0
- apps/huey/settings.example.json +8 -0
- apps/huey/settings.py +97 -0
- apps/huey/turn.py +504 -0
- apps/huey/voice.py +217 -0
- apps/info/__init__.py +810 -0
- apps/info/app.json +1 -0
- apps/lora/__init__.py +62 -0
- apps/lora/app.json +1 -0
- apps/manifest.py +71 -0
- apps/medialink_baby_monitor/__init__.py +222 -0
- apps/medialink_baby_monitor/app.json +1 -0
- apps/medialink_doorbell/__init__.py +251 -0
- apps/medialink_doorbell/app.json +1 -0
- apps/medialink_hands_free/__init__.py +217 -0
- apps/medialink_hands_free/app.json +1 -0
- apps/medialink_surveillance_camera/__init__.py +258 -0
- apps/medialink_surveillance_camera/app.json +1 -0
- apps/medialink_video_doorbell/__init__.py +289 -0
- apps/medialink_video_doorbell/app.json +1 -0
- apps/medialink_videophone/__init__.py +273 -0
- apps/medialink_videophone/app.json +1 -0
- apps/medialink_walkie_talkie/__init__.py +228 -0
- apps/medialink_walkie_talkie/app.json +1 -0
- apps/midicontroller/__init__.py +774 -0
- apps/midicontroller/app.json +1 -0
- apps/midicontroller/links.py +421 -0
- apps/midicontroller/surface.py +343 -0
- apps/midiengine/__init__.py +977 -0
- apps/midiengine/app.json +1 -0
- apps/midiengine/banks.py +85 -0
- apps/midiengine/midiin.py +165 -0
- apps/midiengine/player.py +392 -0
- apps/midiengine/umidiparser.py +1413 -0
- apps/mp3/__init__.py +240 -0
- apps/mp3/app.json +1 -0
- apps/perch/__init__.py +119 -0
- apps/perch/app.json +1 -0
- apps/perch/huey.py +481 -0
- apps/perch/huey_props.py +386 -0
- apps/perch/huey_shift.py +42 -0
- apps/perch/huey_views.py +296 -0
- apps/perch/scene_bench.py +680 -0
- apps/perch/scene_coast.py +479 -0
- apps/perch/scene_desk.py +492 -0
- apps/perch/stage.py +1274 -0
- apps/perch/vec.py +366 -0
- apps/repl/__init__.py +325 -0
- apps/repl/app.json +1 -0
- apps/roku/__init__.py +156 -0
- apps/roku/app.json +1 -0
- apps/rokucam/__init__.py +362 -0
- apps/rokucam/app.json +1 -0
- apps/security/__init__.py +261 -0
- apps/security/app.json +1 -0
- apps/settings/__init__.py +221 -0
- apps/settings/app.json +1 -0
- apps/shell/__init__.py +33 -0
- apps/shell/app.json +1 -0
- apps/spotify/__init__.py +669 -0
- apps/spotify/app.json +1 -0
- apps/spotify/screen.py +82 -0
- apps/steps/__init__.py +58 -0
- apps/steps/app.json +1 -0
- apps/stompbox/__init__.py +31 -0
- apps/stompbox/app.json +1 -0
- apps/stompbox/app.py +668 -0
- apps/stompbox/boards.json +20 -0
- apps/stompbox/effects.py +241 -0
- apps/stompbox/engine.py +340 -0
- apps/stompbox/footswitch.py +331 -0
- apps/stompbox/inputs.py +449 -0
- apps/stompbox/meter.py +72 -0
- apps/stompbox/outputs.py +135 -0
- apps/stompbox/pedals.txt +45 -0
- apps/stompbox/presets.py +106 -0
- apps/stompbox/styles.py +135 -0
- apps/stompbox/ui.py +817 -0
- apps/stompbox/wavfile.py +73 -0
- apps/synthstation/__init__.py +20 -0
- apps/synthstation/app.json +1 -0
- apps/synthstation/audio.py +397 -0
- apps/synthstation/catalog.py +50 -0
- apps/synthstation/meters.py +136 -0
- apps/synthstation/midi.py +380 -0
- apps/synthstation/pads.py +177 -0
- apps/synthstation/parts.py +128 -0
- apps/synthstation/station.py +1069 -0
- apps/system/__init__.py +11 -0
- apps/system/app.json +1 -0
- apps/touchcal/__init__.py +324 -0
- apps/touchcal/app.json +1 -0
- apps/touchcal/fit.py +262 -0
- apps/wake/__init__.py +268 -0
- apps/wake/app.json +1 -0
- apps/wake/feed.py +155 -0
- apps/watch/__init__.py +355 -0
- apps/watch/app.json +1 -0
- apps/watch/faces.py +35 -0
- apps/watch/wheel.py +157 -0
- apps/weather/__init__.py +278 -0
- apps/weather/app.json +1 -0
- apps/weather/icons.py +172 -0
- apps/weather/sizing.py +71 -0
- apps/weather/zippad.py +172 -0
- omnipython_apps-0.1.4.dev8.dist-info/METADATA +33 -0
- omnipython_apps-0.1.4.dev8.dist-info/RECORD +218 -0
- omnipython_apps-0.1.4.dev8.dist-info/WHEEL +5 -0
- omnipython_apps-0.1.4.dev8.dist-info/top_level.txt +1 -0
apps/cast/receivers.py
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""The screens on the network that take a Miracast cast.
|
|
5
|
+
|
|
6
|
+
Three ways in, from quickest to slowest, and Cast lists what each finds as it
|
|
7
|
+
comes:
|
|
8
|
+
|
|
9
|
+
* **Remembered.** The receivers cast to before, kept in ``receivers.json``
|
|
10
|
+
in the Cast app's data folder.
|
|
11
|
+
* **Announced.** A receiver that announces itself on mDNS as
|
|
12
|
+
``_display._tcp`` (Rokus do, and most smart TVs); about two seconds.
|
|
13
|
+
* **Listening.** A Windows PC with its Wireless Display app open announces
|
|
14
|
+
itself only over Wi-Fi Direct, which this board can't hear, but it listens
|
|
15
|
+
on Miracast's port, 7250. ``sweep()`` knocks on that port at every address
|
|
16
|
+
on the subnet, a few at a time (the firmware has ten sockets), and asks
|
|
17
|
+
each one that answers for its NetBIOS name.
|
|
18
|
+
|
|
19
|
+
A receiver is a dict: ``name``, ``host`` (its IPv4 address) and ``kind``,
|
|
20
|
+
"roku" for a Roku (it answers Roku's control port, 8060, and wants MICE's
|
|
21
|
+
session request) and "windows" for anything else.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
import socket
|
|
25
|
+
import struct
|
|
26
|
+
|
|
27
|
+
from touchkit.clock import sleep_ms
|
|
28
|
+
from multimer import ticks_diff, ticks_ms
|
|
29
|
+
|
|
30
|
+
REMEMBER = "receivers.json"
|
|
31
|
+
MICE = 7250
|
|
32
|
+
BATCH = 8 # sockets at once: ten in the firmware, one or two held by WebREPL and the rest
|
|
33
|
+
WAIT_MS = 800 # an absent address costs this; a PC on Wi-Fi answers in 20 to 300 ms
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def remembered(folder):
|
|
37
|
+
"""The receivers remembered in *folder*, last cast to first."""
|
|
38
|
+
try:
|
|
39
|
+
import json
|
|
40
|
+
|
|
41
|
+
with open(folder + "/" + REMEMBER) as f:
|
|
42
|
+
return [r for r in json.load(f).get("receivers", []) if r.get("host")]
|
|
43
|
+
except (OSError, ValueError):
|
|
44
|
+
return []
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def remember(folder, receiver):
|
|
48
|
+
"""Put *receiver* first in *folder*'s ``receivers.json``. Call it before
|
|
49
|
+
the cast starts: a flash write during one stalls the stream."""
|
|
50
|
+
import json
|
|
51
|
+
|
|
52
|
+
keep = [r for r in remembered(folder) if r["host"] != receiver["host"]]
|
|
53
|
+
keep.insert(0, {k: receiver[k] for k in ("name", "host", "kind")})
|
|
54
|
+
try:
|
|
55
|
+
with open(folder + "/" + REMEMBER, "w") as f:
|
|
56
|
+
json.dump({"receivers": keep[:6]}, f)
|
|
57
|
+
except OSError as e:
|
|
58
|
+
print("cast: couldn't remember %s: %s" % (receiver["host"], e))
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _is_roku(host):
|
|
62
|
+
from touchkit import ecp
|
|
63
|
+
|
|
64
|
+
try:
|
|
65
|
+
return ecp.device_info(host) is not None
|
|
66
|
+
except OSError:
|
|
67
|
+
return False
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def announced():
|
|
71
|
+
"""The receivers that answer an mDNS browse for ``_display._tcp``."""
|
|
72
|
+
import mdns
|
|
73
|
+
import network
|
|
74
|
+
|
|
75
|
+
# One mdns.Server may be live at a time (CircuitPython's rule), so give
|
|
76
|
+
# it back before the next scan.
|
|
77
|
+
server = mdns.Server(network.WLAN(network.STA_IF))
|
|
78
|
+
try:
|
|
79
|
+
found = server.find(service_type="_display", protocol="_tcp", timeout=2)
|
|
80
|
+
finally:
|
|
81
|
+
server.deinit()
|
|
82
|
+
out = []
|
|
83
|
+
for s in found:
|
|
84
|
+
if s.ipv4_address:
|
|
85
|
+
host = str(s.ipv4_address)
|
|
86
|
+
out.append({"name": s.instance_name, "host": host, "kind": "roku" if _is_roku(host) else "windows"})
|
|
87
|
+
return out
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def netbios_name(host, ms=1200, tries=2):
|
|
91
|
+
"""A Windows PC's own name, from a NetBIOS node-status query sent to it
|
|
92
|
+
(Windows answers one sent directly, not a broadcast), or None."""
|
|
93
|
+
q = struct.pack(">HHHHHH", 0x4242, 0, 1, 0, 0, 0) + b"\x20CK" + b"A" * 30 + b"\x00" + struct.pack(">HH", 0x21, 1)
|
|
94
|
+
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
95
|
+
try:
|
|
96
|
+
s.settimeout(ms / 1000)
|
|
97
|
+
d = None
|
|
98
|
+
for _ in range(tries): # UDP on Wi-Fi: one may go missing
|
|
99
|
+
s.sendto(q, socket.getaddrinfo(host, 137)[0][-1])
|
|
100
|
+
try:
|
|
101
|
+
d = s.recv(1024)
|
|
102
|
+
break
|
|
103
|
+
except OSError:
|
|
104
|
+
pass
|
|
105
|
+
if d is None:
|
|
106
|
+
return None
|
|
107
|
+
at = 12 + 34 + 10 # header, the name asked about, its type, class, TTL and length
|
|
108
|
+
for i in range(d[at]):
|
|
109
|
+
e = d[at + 1 + i * 18 : at + 19 + i * 18]
|
|
110
|
+
if e[15] == 0 and not e[16] & 0x80: # the workstation name, not a group
|
|
111
|
+
return bytes(e[:15]).decode().strip()
|
|
112
|
+
except (OSError, IndexError, ValueError):
|
|
113
|
+
pass
|
|
114
|
+
finally:
|
|
115
|
+
s.close()
|
|
116
|
+
return None
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def _listening(hosts):
|
|
120
|
+
"""``(those of *hosts* that accept a connection on 7250, how many were
|
|
121
|
+
tried)``: fewer than asked when the firmware runs out of sockets."""
|
|
122
|
+
import errno
|
|
123
|
+
import select
|
|
124
|
+
|
|
125
|
+
poll = select.poll()
|
|
126
|
+
socks = {}
|
|
127
|
+
tried = 0
|
|
128
|
+
for h in hosts:
|
|
129
|
+
try:
|
|
130
|
+
s = socket.socket()
|
|
131
|
+
except OSError:
|
|
132
|
+
break # out of sockets: the rest wait for the next batch
|
|
133
|
+
s.setblocking(False)
|
|
134
|
+
try:
|
|
135
|
+
s.connect(socket.getaddrinfo(h, MICE)[0][-1])
|
|
136
|
+
except OSError:
|
|
137
|
+
pass # EINPROGRESS: the answer comes through poll
|
|
138
|
+
poll.register(s, select.POLLOUT)
|
|
139
|
+
socks[id(s)] = (s, h)
|
|
140
|
+
tried += 1
|
|
141
|
+
found = []
|
|
142
|
+
start = ticks_ms()
|
|
143
|
+
try:
|
|
144
|
+
while socks:
|
|
145
|
+
left = WAIT_MS - ticks_diff(ticks_ms(), start)
|
|
146
|
+
if left <= 0:
|
|
147
|
+
break
|
|
148
|
+
for obj, _ in poll.poll(left):
|
|
149
|
+
s, h = socks.pop(id(obj), (None, None))
|
|
150
|
+
if s is None:
|
|
151
|
+
continue
|
|
152
|
+
poll.unregister(s)
|
|
153
|
+
# Refused shows as writable too; a live connection has
|
|
154
|
+
# nothing to read yet, a refused one is reset.
|
|
155
|
+
try:
|
|
156
|
+
s.recv(1)
|
|
157
|
+
found.append(h)
|
|
158
|
+
except OSError as e:
|
|
159
|
+
if e.args and e.args[0] == errno.EAGAIN:
|
|
160
|
+
found.append(h)
|
|
161
|
+
s.close()
|
|
162
|
+
finally:
|
|
163
|
+
for s, _ in socks.values():
|
|
164
|
+
s.close()
|
|
165
|
+
return found, tried
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def subnet_hosts(skip=()):
|
|
169
|
+
"""Every other address on this board's /24, in order."""
|
|
170
|
+
import network
|
|
171
|
+
|
|
172
|
+
me = network.WLAN(network.STA_IF).ifconfig()[0]
|
|
173
|
+
base = me.rsplit(".", 1)[0]
|
|
174
|
+
return [h for h in ("%s.%d" % (base, i) for i in range(1, 255)) if h != me and h not in skip]
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def sweep(hosts):
|
|
178
|
+
"""Receivers among *hosts* that listen on Miracast's port, named."""
|
|
179
|
+
out = []
|
|
180
|
+
i = 0
|
|
181
|
+
while i < len(hosts):
|
|
182
|
+
found, tried = _listening(hosts[i : i + BATCH])
|
|
183
|
+
if not tried: # every socket busy: give them a moment, then go on regardless
|
|
184
|
+
sleep_ms(300)
|
|
185
|
+
found, tried = _listening(hosts[i : i + 1])
|
|
186
|
+
tried = max(tried, 1)
|
|
187
|
+
i += tried
|
|
188
|
+
for h in found:
|
|
189
|
+
roku = _is_roku(h)
|
|
190
|
+
name = None if roku else netbios_name(h)
|
|
191
|
+
out.append({"name": name or ("Roku at " if roku else "Computer at ") + h, "host": h,
|
|
192
|
+
"kind": "roku" if roku else "windows"})
|
|
193
|
+
return out
|
apps/chess/__init__.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""chess: play chess against the engine or another player on the network.
|
|
5
|
+
appkit calls ``main(scope)``.
|
|
6
|
+
|
|
7
|
+
Importing this does nothing and imports nothing else: the app's modules
|
|
8
|
+
load when it opens.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
__all__ = ["main"]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def main(scope):
|
|
15
|
+
"""Run Chess on *scope*; returns the running app."""
|
|
16
|
+
from .app import App
|
|
17
|
+
|
|
18
|
+
return App(scope)
|
apps/chess/app.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name": "chess", "title": "Chess", "category": "Games", "icon": "grid_on", "color": "#7A4B2A", "needs": ["svgio"]}
|