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
@@ -0,0 +1,228 @@
1
+ # SPDX-FileCopyrightText: 2026 Brad Barnett
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+ """Walkie-talkie: talk to another device while you hold a button.
5
+
6
+ Open Walkie-talkie from the appkit launcher on two boards, or on a board and
7
+ a computer, each with its own NAME and the other's as PEER. They find each
8
+ other on the network by name. Hold the button and speak; let go, and the
9
+ other one hears you. One talks at a time: while the other is talking, the
10
+ button does nothing.
11
+
12
+ The screen shows whether the peer is here, and a line when a turn ends: how
13
+ many frames went or came, how long the sound took from one microphone to the
14
+ other speaker, and how often the speaker ran dry waiting for the network. If
15
+ the network drops, the two find each other again when it comes back.
16
+
17
+ They find each other on the network they are on. Where the Wi-Fi is weak, set
18
+ HOTSPOT_PASSWORD on both: one board starts an access point, the other joins
19
+ it, and both go back to their own network when the app closes.
20
+
21
+ On a computer it uses the sound input and output chosen in the picker, and moves
22
+ to another when you choose one while it runs.
23
+
24
+ Needs: a microphone and a speaker that boarddev.pcm_in() and pcm_out() reach,
25
+ which an OmniPython board package or omnipython-desktop provides, and a
26
+ network: a board already on Wi-Fi, with mdns in its firmware. On a computer, hold any
27
+ key or a mouse button in the window; CPython also needs python-zeroconf for
28
+ mdns. Without a microphone, speaker, network port or mDNS, the screen says
29
+ which one is missing and the app stays open.
30
+ """
31
+
32
+ import events
33
+ import lvgl as lv
34
+ import medialink
35
+ import multimer
36
+ from appkit import connections
37
+ from audiodev import AudioFormat
38
+ from touchkit import ui
39
+
40
+ # Change these to match your setup.
41
+ NAME = "walkie-1" # this side's name on the network
42
+ PEER = "walkie-2" # the other side's
43
+ PEER_ADDRESS = None # or ("192.168.1.20", PORT) to skip the search
44
+ PORT = 47800
45
+ BUTTON_PIN = None # a board's button GPIO, pressed when low; None for the window
46
+ RATE = 16000 # samples a second
47
+ HOTSPOT_PASSWORD = None # a password to talk over a hotspot one board starts
48
+
49
+
50
+ def _close(thing):
51
+ """Close a device that may or may not be open, without raising."""
52
+ if thing is None:
53
+ return
54
+ for name in ("close", "deinit"):
55
+ method = getattr(thing, name, None)
56
+ if method is not None:
57
+ try:
58
+ method()
59
+ except Exception:
60
+ pass
61
+ return
62
+
63
+
64
+ def main(scope):
65
+ # Open the microphone and the speaker at one format: mono, 16-bit.
66
+ audio = AudioFormat(RATE, 1, 16)
67
+ sound = connections.Sound(scope, audio)
68
+ try:
69
+ mic = sound.open_mic()
70
+ except Exception as e:
71
+ ui.missing(scope, "no microphone", "Walkie-talkie needs a microphone: %s." % (e,))
72
+ return
73
+ try:
74
+ speaker = sound.open_speaker()
75
+ except Exception as e:
76
+ _close(mic)
77
+ ui.missing(scope, "no speaker", "Walkie-talkie needs a speaker: %s." % (e,))
78
+ return
79
+
80
+ # Listen on PORT, and announce this side by name.
81
+ try:
82
+ link = medialink.Link(medialink.UDPTransport(PORT), retries=2)
83
+ except Exception as e:
84
+ _close(speaker)
85
+ _close(mic)
86
+ ui.missing(scope, "no network port", "Walkie-talkie couldn't use port %d: %s." % (PORT, e))
87
+ return
88
+
89
+ # The button is a pin on a board, or a key or mouse button in a window.
90
+ # The window's events arrive through the app's subscriptions.
91
+ pad = {"held": False}
92
+ if BUTTON_PIN is not None:
93
+ from machine import Pin
94
+
95
+ pin = Pin(BUTTON_PIN, Pin.IN, Pin.PULL_UP)
96
+
97
+ def held():
98
+ return not pin.value()
99
+
100
+ else:
101
+ def down(event):
102
+ pad["held"] = True
103
+
104
+ def up(event):
105
+ pad["held"] = False
106
+
107
+ scope.on((events.KEYDOWN, events.MOUSEBUTTONDOWN), down)
108
+ scope.on((events.KEYUP, events.MOUSEBUTTONUP), up)
109
+
110
+ def held():
111
+ return pad["held"]
112
+
113
+ try:
114
+ finder = medialink.Hotspot(HOTSPOT_PASSWORD) if HOTSPOT_PASSWORD else medialink.MDNS()
115
+ except Exception as e:
116
+ finder = None
117
+ print("walkie-talkie: no mDNS: %s" % (e,))
118
+ if finder is not None:
119
+ finder.advertise(NAME, PORT)
120
+
121
+ intercom = medialink.Intercom(link, mic, speaker)
122
+ sound.attach(intercom)
123
+
124
+ # The screen: the peer's state on the status line, and each turn in the
125
+ # middle.
126
+ scr = scope.root
127
+ status = ui.status(scope)
128
+ sound.on_error = status.set_text
129
+ status.set_text("Looking for %r" % (PEER,))
130
+ ui.label(scr, "Walkie-talkie: %s" % NAME, ui.big, ui.WHITE).align(lv.ALIGN.TOP_LEFT, 24, 80)
131
+ if finder is None and PEER_ADDRESS is None:
132
+ hint = "No mDNS here: set PEER_ADDRESS to reach %r." % (PEER,)
133
+ else:
134
+ hint = "Hold the button to talk to %r." % (PEER,)
135
+ ui.label(scr, hint, ui.font, ui.MUTED).align(lv.ALIGN.TOP_LEFT, 24, 124)
136
+ msg = ui.label(scr, "", ui.big, ui.ACCENT)
137
+ msg.align(lv.ALIGN.CENTER, 0, 0)
138
+
139
+ def show(text):
140
+ msg.set_text(text)
141
+ print(text)
142
+
143
+ # The search runs on the worker, so the screen doesn't wait on it. The
144
+ find_key = "walkie-talkie-find"
145
+ searching = {"on": False}
146
+
147
+ def connect(peers):
148
+ for _name, address in peers:
149
+ try:
150
+ link.connect(address)
151
+ print("Connected to %r at %s" % (PEER, address))
152
+ except medialink.PeerUnreachable:
153
+ pass
154
+
155
+ def found(value, error):
156
+ searching["on"] = False
157
+ if error is not None:
158
+ print("walkie-talkie: search:", error)
159
+ return
160
+ connect(value)
161
+
162
+ def look_for_peer():
163
+ """Find the peer and say hello. Either side may find the other first."""
164
+ if PEER_ADDRESS:
165
+ connect([(PEER, PEER_ADDRESS)])
166
+ elif finder is not None and not searching["on"]:
167
+ searching["on"] = True
168
+ scope.worker.submit(lambda: finder.find(PEER, timeout=1), found, key=find_key)
169
+
170
+ st = {
171
+ "looked": multimer.ticks_add(multimer.ticks_ms(), -5000),
172
+ "was_alive": False,
173
+ "refused": False,
174
+ "heard": 0,
175
+ "sent": 0,
176
+ "played": 0,
177
+ }
178
+
179
+ def close():
180
+ intercom.close()
181
+ link.close()
182
+
183
+ scope.on_close(close)
184
+ if finder is not None:
185
+ scope.on_close(finder.deinit)
186
+
187
+ def step():
188
+ """One pass of the loop: find the peer, talk while the button is
189
+ held, and listen the rest of the time. The program's main loop
190
+ calls it."""
191
+ if scope.closed:
192
+ return
193
+ if not link.alive and multimer.ticks_diff(multimer.ticks_ms(), st["looked"]) > 3000:
194
+ look_for_peer()
195
+ st["looked"] = multimer.ticks_ms()
196
+ if link.alive != st["was_alive"]:
197
+ st["was_alive"] = link.alive
198
+ status.set_text("Peer here" if st["was_alive"] else "Peer gone: waiting for it")
199
+ pressed = held()
200
+ if pressed and not intercom.talking and link.alive and not st["refused"]:
201
+ try:
202
+ if intercom.press():
203
+ show("Talking...")
204
+ st["sent"] = intercom.stats["sent"]
205
+ else:
206
+ show("The other side is talking")
207
+ st["refused"] = True
208
+ except medialink.PeerUnreachable:
209
+ show("No answer from the other side")
210
+ st["refused"] = True
211
+ elif not pressed:
212
+ st["refused"] = False
213
+ if intercom.talking:
214
+ intercom.release()
215
+ show("Sent %d frames" % (intercom.stats["sent"] - st["sent"]))
216
+ intercom.service()
217
+
218
+ # When the peer's turn ends, say how it went.
219
+ if intercom.stats["spurts"] != st["heard"] and link.floor == medialink.IDLE:
220
+ st["heard"] = intercom.stats["spurts"]
221
+ show("Heard %d frames, %s ms mouth to ear, %d underruns so far, round trip %s ms"
222
+ % (intercom.stats["played"] - st["played"], intercom.stats["latency_ms"],
223
+ intercom.stats["underruns"], link.rtt_ms))
224
+ st["played"] = intercom.stats["played"]
225
+ if not intercom.talking:
226
+ multimer.sleep_ms(2)
227
+
228
+ scope.foreground(step)
@@ -0,0 +1 @@
1
+ {"name": "medialink_walkie_talkie", "title": "Walkie-talkie", "category": "Link", "icon": "record_voice_over", "color": "#1E8C4E"}