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
|
@@ -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"}
|