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.
Files changed (218) hide show
  1. apps/__init__.py +5 -0
  2. apps/about/__init__.py +257 -0
  3. apps/about/app.json +1 -0
  4. apps/about/credits.py +12 -0
  5. apps/about/facts.py +398 -0
  6. apps/about/fonts/OFL.txt +93 -0
  7. apps/about/fonts/latin1_14.bin +0 -0
  8. apps/about/fonts/latin1_16.bin +0 -0
  9. apps/about/fonts/latin1_24.bin +0 -0
  10. apps/about/fonts/latin1_32.bin +0 -0
  11. apps/about/fonts/latin1_40.bin +0 -0
  12. apps/backline/__init__.py +58 -0
  13. apps/backline/app.json +1 -0
  14. apps/backline/app.py +475 -0
  15. apps/backline/art.py +717 -0
  16. apps/backline/ask.py +781 -0
  17. apps/backline/box.py +502 -0
  18. apps/backline/cast.py +137 -0
  19. apps/backline/desk/__init__.py +329 -0
  20. apps/backline/desk/editor.py +331 -0
  21. apps/backline/desk/grid.py +154 -0
  22. apps/backline/desk/look.py +169 -0
  23. apps/backline/desk/pedals.py +102 -0
  24. apps/backline/desk/perform.py +157 -0
  25. apps/backline/desk/prompt.py +210 -0
  26. apps/backline/desk/strip.py +159 -0
  27. apps/backline/desk_main.py +226 -0
  28. apps/backline/engine.py +622 -0
  29. apps/backline/floor.py +509 -0
  30. apps/backline/footswitch.py +119 -0
  31. apps/backline/glyphs.py +82 -0
  32. apps/backline/kits.py +428 -0
  33. apps/backline/midipedal.py +362 -0
  34. apps/backline/page_data.py +413 -0
  35. apps/backline/parts.py +145 -0
  36. apps/backline/pedal.py +107 -0
  37. apps/backline/remote.py +134 -0
  38. apps/backline/songs/ballad_68.json +1 -0
  39. apps/backline/songs/bossa.json +1 -0
  40. apps/backline/songs/country_train.json +1 -0
  41. apps/backline/songs/funk.json +1 -0
  42. apps/backline/songs/metal.json +1 -0
  43. apps/backline/songs/pop.json +1 -0
  44. apps/backline/songs/rock.json +1 -0
  45. apps/backline/songs/shuffle.json +1 -0
  46. apps/battery/__init__.py +101 -0
  47. apps/battery/app.json +1 -0
  48. apps/bit_world/act_deck.py +683 -0
  49. apps/bit_world/act_game.py +762 -0
  50. apps/bit_world/act_pet.py +1032 -0
  51. apps/bit_world/app.json +1 -0
  52. apps/bit_world/bit_output.py +45 -0
  53. apps/bit_world/bit_palette.py +503 -0
  54. apps/bit_world/bit_sound.py +431 -0
  55. apps/bit_world/bit_sprites.py +632 -0
  56. apps/bit_world/bit_world.py +534 -0
  57. apps/btreceiver/__init__.py +690 -0
  58. apps/btreceiver/app.json +1 -0
  59. apps/btreceiver/chime.py +155 -0
  60. apps/btreceiver/demo.py +529 -0
  61. apps/btreceiver/screen.py +633 -0
  62. apps/camera/__init__.py +316 -0
  63. apps/camera/app.json +1 -0
  64. apps/card/__init__.py +113 -0
  65. apps/card/app.json +1 -0
  66. apps/cast/__init__.py +631 -0
  67. apps/cast/app.json +1 -0
  68. apps/cast/receivers.py +193 -0
  69. apps/chess/__init__.py +18 -0
  70. apps/chess/app.json +1 -0
  71. apps/chess/app.py +922 -0
  72. apps/chess/art.py +323 -0
  73. apps/chess/ble.py +411 -0
  74. apps/chess/engine.py +925 -0
  75. apps/chess/game.py +327 -0
  76. apps/chess/net.py +261 -0
  77. apps/clock/__init__.py +38 -0
  78. apps/clock/app.json +1 -0
  79. apps/detect/__init__.py +214 -0
  80. apps/detect/app.json +1 -0
  81. apps/fmsynth/__init__.py +41 -0
  82. apps/fmsynth/algorithms.py +61 -0
  83. apps/fmsynth/app.json +1 -0
  84. apps/fmsynth/app.py +355 -0
  85. apps/fmsynth/editor.py +206 -0
  86. apps/fmsynth/engine.py +257 -0
  87. apps/fmsynth/meters.py +262 -0
  88. apps/fmsynth/midi.py +375 -0
  89. apps/fmsynth/panel_view.py +1071 -0
  90. apps/fmsynth/patches/fmsynth-01.syx +0 -0
  91. apps/fmsynth/settings.py +138 -0
  92. apps/fmsynth/voice.py +398 -0
  93. apps/gamepad/__init__.py +685 -0
  94. apps/gamepad/app.json +1 -0
  95. apps/gamepad/pad.py +94 -0
  96. apps/gamepad/watch.py +352 -0
  97. apps/hidden/__init__.py +72 -0
  98. apps/hidden/app.json +1 -0
  99. apps/home/__init__.py +483 -0
  100. apps/home/app.json +1 -0
  101. apps/home/main.py +36 -0
  102. apps/homeassistant/__init__.py +213 -0
  103. apps/homeassistant/api.py +104 -0
  104. apps/homeassistant/app.json +1 -0
  105. apps/huey/__init__.py +287 -0
  106. apps/huey/acting.py +184 -0
  107. apps/huey/actor.py +194 -0
  108. apps/huey/app.json +1 -0
  109. apps/huey/client.py +125 -0
  110. apps/huey/servers.py +121 -0
  111. apps/huey/settings.example.json +8 -0
  112. apps/huey/settings.py +97 -0
  113. apps/huey/turn.py +504 -0
  114. apps/huey/voice.py +217 -0
  115. apps/info/__init__.py +810 -0
  116. apps/info/app.json +1 -0
  117. apps/lora/__init__.py +62 -0
  118. apps/lora/app.json +1 -0
  119. apps/manifest.py +71 -0
  120. apps/medialink_baby_monitor/__init__.py +222 -0
  121. apps/medialink_baby_monitor/app.json +1 -0
  122. apps/medialink_doorbell/__init__.py +251 -0
  123. apps/medialink_doorbell/app.json +1 -0
  124. apps/medialink_hands_free/__init__.py +217 -0
  125. apps/medialink_hands_free/app.json +1 -0
  126. apps/medialink_surveillance_camera/__init__.py +258 -0
  127. apps/medialink_surveillance_camera/app.json +1 -0
  128. apps/medialink_video_doorbell/__init__.py +289 -0
  129. apps/medialink_video_doorbell/app.json +1 -0
  130. apps/medialink_videophone/__init__.py +273 -0
  131. apps/medialink_videophone/app.json +1 -0
  132. apps/medialink_walkie_talkie/__init__.py +228 -0
  133. apps/medialink_walkie_talkie/app.json +1 -0
  134. apps/midicontroller/__init__.py +774 -0
  135. apps/midicontroller/app.json +1 -0
  136. apps/midicontroller/links.py +421 -0
  137. apps/midicontroller/surface.py +343 -0
  138. apps/midiengine/__init__.py +977 -0
  139. apps/midiengine/app.json +1 -0
  140. apps/midiengine/banks.py +85 -0
  141. apps/midiengine/midiin.py +165 -0
  142. apps/midiengine/player.py +392 -0
  143. apps/midiengine/umidiparser.py +1413 -0
  144. apps/mp3/__init__.py +240 -0
  145. apps/mp3/app.json +1 -0
  146. apps/perch/__init__.py +119 -0
  147. apps/perch/app.json +1 -0
  148. apps/perch/huey.py +481 -0
  149. apps/perch/huey_props.py +386 -0
  150. apps/perch/huey_shift.py +42 -0
  151. apps/perch/huey_views.py +296 -0
  152. apps/perch/scene_bench.py +680 -0
  153. apps/perch/scene_coast.py +479 -0
  154. apps/perch/scene_desk.py +492 -0
  155. apps/perch/stage.py +1274 -0
  156. apps/perch/vec.py +366 -0
  157. apps/repl/__init__.py +325 -0
  158. apps/repl/app.json +1 -0
  159. apps/roku/__init__.py +156 -0
  160. apps/roku/app.json +1 -0
  161. apps/rokucam/__init__.py +362 -0
  162. apps/rokucam/app.json +1 -0
  163. apps/security/__init__.py +261 -0
  164. apps/security/app.json +1 -0
  165. apps/settings/__init__.py +221 -0
  166. apps/settings/app.json +1 -0
  167. apps/shell/__init__.py +33 -0
  168. apps/shell/app.json +1 -0
  169. apps/spotify/__init__.py +669 -0
  170. apps/spotify/app.json +1 -0
  171. apps/spotify/screen.py +82 -0
  172. apps/steps/__init__.py +58 -0
  173. apps/steps/app.json +1 -0
  174. apps/stompbox/__init__.py +31 -0
  175. apps/stompbox/app.json +1 -0
  176. apps/stompbox/app.py +668 -0
  177. apps/stompbox/boards.json +20 -0
  178. apps/stompbox/effects.py +241 -0
  179. apps/stompbox/engine.py +340 -0
  180. apps/stompbox/footswitch.py +331 -0
  181. apps/stompbox/inputs.py +449 -0
  182. apps/stompbox/meter.py +72 -0
  183. apps/stompbox/outputs.py +135 -0
  184. apps/stompbox/pedals.txt +45 -0
  185. apps/stompbox/presets.py +106 -0
  186. apps/stompbox/styles.py +135 -0
  187. apps/stompbox/ui.py +817 -0
  188. apps/stompbox/wavfile.py +73 -0
  189. apps/synthstation/__init__.py +20 -0
  190. apps/synthstation/app.json +1 -0
  191. apps/synthstation/audio.py +397 -0
  192. apps/synthstation/catalog.py +50 -0
  193. apps/synthstation/meters.py +136 -0
  194. apps/synthstation/midi.py +380 -0
  195. apps/synthstation/pads.py +177 -0
  196. apps/synthstation/parts.py +128 -0
  197. apps/synthstation/station.py +1069 -0
  198. apps/system/__init__.py +11 -0
  199. apps/system/app.json +1 -0
  200. apps/touchcal/__init__.py +324 -0
  201. apps/touchcal/app.json +1 -0
  202. apps/touchcal/fit.py +262 -0
  203. apps/wake/__init__.py +268 -0
  204. apps/wake/app.json +1 -0
  205. apps/wake/feed.py +155 -0
  206. apps/watch/__init__.py +355 -0
  207. apps/watch/app.json +1 -0
  208. apps/watch/faces.py +35 -0
  209. apps/watch/wheel.py +157 -0
  210. apps/weather/__init__.py +278 -0
  211. apps/weather/app.json +1 -0
  212. apps/weather/icons.py +172 -0
  213. apps/weather/sizing.py +71 -0
  214. apps/weather/zippad.py +172 -0
  215. omnipython_apps-0.1.4.dev8.dist-info/METADATA +33 -0
  216. omnipython_apps-0.1.4.dev8.dist-info/RECORD +218 -0
  217. omnipython_apps-0.1.4.dev8.dist-info/WHEEL +5 -0
  218. 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"]}