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,154 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""The step grid: a part's drums by steps, one bar at a time.
|
|
5
|
+
|
|
6
|
+
A row is a drum the kit has, a column a step of the bar, and a cell's
|
|
7
|
+
brightness is how hard it plays: dim on, bright loud, faint soft. A tap on
|
|
8
|
+
a cell sends the op that moves it to its next level (`parts.tap`), and the
|
|
9
|
+
column playing now is outlined while the part on show plays.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import lvgl as lv
|
|
13
|
+
|
|
14
|
+
from . import look
|
|
15
|
+
from .. import parts as song
|
|
16
|
+
from .. import art
|
|
17
|
+
from ..floor import fit, text_width
|
|
18
|
+
|
|
19
|
+
# Shorter words for a drum's name, tried in turn until the name fits.
|
|
20
|
+
SHORTER = (
|
|
21
|
+
(("High", "Hi"), ("Low", "Lo")),
|
|
22
|
+
(("Floor", "Flr"), ("Closed", "Cl"), ("Open", "Op"), ("Tambourine", "Tamb"), ("Cowbell", "Cowbl"),
|
|
23
|
+
("Maracas", "Mrcs"), ("Conga", "Cga"), ("Bongo", "Bgo"), ("Splash", "Spl"), ("Stick", "Stk")),
|
|
24
|
+
)
|
|
25
|
+
LABEL_SHARE = 22 # the most of the grid's width the names take, in percent
|
|
26
|
+
|
|
27
|
+
ON = (look.RAISED, art.mix(look.AMBER, look.RAISED, 0.25), look.AMBER, art.mix(look.AMBER, look.RAISED, 0.62))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def shorter(name):
|
|
31
|
+
"""``name``, then shorter ways to write it (`SHORTER`), longest first."""
|
|
32
|
+
out = [name]
|
|
33
|
+
for table in SHORTER:
|
|
34
|
+
words = out[-1].split(" ")
|
|
35
|
+
swap = dict(table)
|
|
36
|
+
short = " ".join(swap.get(word, word) for word in words)
|
|
37
|
+
if short != out[-1]:
|
|
38
|
+
out.append(short)
|
|
39
|
+
return out
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class Grid:
|
|
43
|
+
"""The grid in ``parent`` at ``(x, y)``, ``w`` by ``h``. ``on_tap(pitch, step)``
|
|
44
|
+
gets a tap, ``step`` counted from the part's first bar."""
|
|
45
|
+
|
|
46
|
+
def __init__(self, parent, x, y, w, h, fnt, on_tap):
|
|
47
|
+
self.w, self.h = int(w), int(h)
|
|
48
|
+
self.fnt = fnt
|
|
49
|
+
self.on_tap = on_tap
|
|
50
|
+
self.base = look.plain(lv.obj(parent))
|
|
51
|
+
self.base.set_pos(int(x), int(y))
|
|
52
|
+
self.base.set_size(self.w, self.h)
|
|
53
|
+
self.base.add_flag(lv.obj.FLAG.SCROLLABLE)
|
|
54
|
+
self.base.set_scroll_dir(lv.DIR.VER)
|
|
55
|
+
self.rows = []
|
|
56
|
+
self.cols = 16
|
|
57
|
+
self.beat = 4
|
|
58
|
+
self.bar = 0
|
|
59
|
+
self.cells = {} # (pitch, column) -> [obj, level shown]
|
|
60
|
+
self.head = None
|
|
61
|
+
self.head_col = -1
|
|
62
|
+
self.label_w = 0
|
|
63
|
+
self.cell_w = self.cell_h = 0
|
|
64
|
+
|
|
65
|
+
def build(self, rows, cols, beat):
|
|
66
|
+
"""Rows ``[(pitch, name)]``, ``cols`` steps a bar, ``beat`` steps a beat."""
|
|
67
|
+
self.base.clean()
|
|
68
|
+
self.rows, self.cols, self.beat = rows, cols, beat
|
|
69
|
+
self.cells = {}
|
|
70
|
+
gap = 3
|
|
71
|
+
beat_gap = 5
|
|
72
|
+
# The names' column is as wide as the longest name needs, up to
|
|
73
|
+
# LABEL_SHARE of the grid; a name still too long goes by shorter words.
|
|
74
|
+
widest = max([text_width(n, self.fnt) for _p, n in rows] or [0])
|
|
75
|
+
self.label_w = lw = max(64, min(self.w * LABEL_SHARE // 100, widest + 8))
|
|
76
|
+
groups = cols // beat
|
|
77
|
+
cw = (self.w - lw - gap * (cols - 1) - beat_gap * (groups - 1) - 2) // cols
|
|
78
|
+
ch = max(22, min(cw + 6, (self.h - 2) // max(1, len(rows)) - gap))
|
|
79
|
+
ch = min(ch, int(cw * 1.4))
|
|
80
|
+
self.cell_w, self.cell_h = cw, ch
|
|
81
|
+
self.xs = []
|
|
82
|
+
x = lw
|
|
83
|
+
for c in range(cols):
|
|
84
|
+
if c and c % beat == 0:
|
|
85
|
+
x += beat_gap
|
|
86
|
+
self.xs.append(x)
|
|
87
|
+
x += cw + gap
|
|
88
|
+
for r, (pitch, name) in enumerate(rows):
|
|
89
|
+
art.pause() # a grid is hundreds of objects: the song plays on between rows
|
|
90
|
+
y = r * (ch + gap)
|
|
91
|
+
lbl = look.text(self.base, name, self.fnt, look.DIM, lw - 8)
|
|
92
|
+
fit(lbl, shorter(name), lw - 8, 0)
|
|
93
|
+
lbl.set_pos(0, y + (ch - self.fnt.line_height) // 2)
|
|
94
|
+
for c in range(cols):
|
|
95
|
+
if c and c % 8 == 0:
|
|
96
|
+
art.pause()
|
|
97
|
+
o = look.box(self.base, self.xs[c], y, cw, ch, self._off(c), 4, None)
|
|
98
|
+
o.add_flag(lv.obj.FLAG.CLICKABLE)
|
|
99
|
+
o.set_style_border_color(look.color(look.AMBER), lv.STATE.PRESSED)
|
|
100
|
+
o.set_style_border_width(2, lv.STATE.PRESSED)
|
|
101
|
+
o.add_event_cb(self._tapper(pitch, c), lv.EVENT.CLICKED, None)
|
|
102
|
+
self.cells[(pitch, c)] = [o, 0]
|
|
103
|
+
head = look.box(self.base, 0, 0, cw + 4, max(1, len(rows)) * (ch + gap) - gap + 4, 0xFFFFFF, 5, None)
|
|
104
|
+
head.set_style_bg_opa(0, 0)
|
|
105
|
+
head.set_style_border_color(look.color(0xFFFFFF), 0)
|
|
106
|
+
head.set_style_border_width(2, 0)
|
|
107
|
+
head.set_style_border_opa(200, 0)
|
|
108
|
+
head.add_flag(lv.obj.FLAG.HIDDEN)
|
|
109
|
+
self.head = head
|
|
110
|
+
self.head_col = -1
|
|
111
|
+
|
|
112
|
+
def _off(self, c):
|
|
113
|
+
return art.mix(look.RAISED, 0xFFFFFF, 0.06) if c % self.beat == 0 else look.RAISED
|
|
114
|
+
|
|
115
|
+
def _tapper(self, pitch, c):
|
|
116
|
+
def on_event(_e):
|
|
117
|
+
self.on_tap(pitch, self.bar * self.cols + c)
|
|
118
|
+
|
|
119
|
+
return on_event
|
|
120
|
+
|
|
121
|
+
def show(self, levels):
|
|
122
|
+
"""Light the cells: ``levels`` is `parts.levels` of the part on show.
|
|
123
|
+
Only a cell whose level changed is restyled."""
|
|
124
|
+
base = self.bar * self.cols
|
|
125
|
+
for (pitch, c), slot in self.cells.items():
|
|
126
|
+
lvl = levels.get((pitch, base + c), 0)
|
|
127
|
+
if slot[1] == lvl:
|
|
128
|
+
continue
|
|
129
|
+
slot[1] = lvl
|
|
130
|
+
o = slot[0]
|
|
131
|
+
o.set_style_bg_color(look.color(ON[lvl] if lvl else self._off(c)), 0)
|
|
132
|
+
|
|
133
|
+
def level(self, pitch, c):
|
|
134
|
+
"""The level a cell shows (for a check), or -1 when there's no such cell."""
|
|
135
|
+
slot = self.cells.get((pitch, c))
|
|
136
|
+
return -1 if slot is None else slot[1]
|
|
137
|
+
|
|
138
|
+
def center(self, pitch, c):
|
|
139
|
+
"""A cell's centre on the screen, for a press."""
|
|
140
|
+
o = self.cells[(pitch, c)][0]
|
|
141
|
+
a = lv.area_t()
|
|
142
|
+
o.get_coords(a)
|
|
143
|
+
return (a.x1 + a.x2) // 2, (a.y1 + a.y2) // 2
|
|
144
|
+
|
|
145
|
+
def playhead(self, column):
|
|
146
|
+
"""Outline ``column`` of the bar on show, or nothing when -1."""
|
|
147
|
+
if self.head is None or column == self.head_col:
|
|
148
|
+
return
|
|
149
|
+
self.head_col = column
|
|
150
|
+
if column < 0:
|
|
151
|
+
self.head.add_flag(lv.obj.FLAG.HIDDEN)
|
|
152
|
+
return
|
|
153
|
+
self.head.set_pos(self.xs[column] - 2, -2)
|
|
154
|
+
self.head.remove_flag(lv.obj.FLAG.HIDDEN)
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""The desk view's colours, fonts and the few widgets it styles itself.
|
|
5
|
+
|
|
6
|
+
Every widget here sets its own colours, so the desk looks the same under
|
|
7
|
+
any LVGL theme: on the box's own screen inside the shell, or alone on a
|
|
8
|
+
remote screen.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import lvgl as lv
|
|
12
|
+
from icons import lvgl as lvicons
|
|
13
|
+
|
|
14
|
+
from .. import art, glyphs
|
|
15
|
+
|
|
16
|
+
BG = 0x0A0D12
|
|
17
|
+
PANEL = 0x121821
|
|
18
|
+
RAISED = 0x1A2230
|
|
19
|
+
LINE = 0x2A3444
|
|
20
|
+
TEXT = 0xDDE3EC
|
|
21
|
+
DIM = 0x8792A5
|
|
22
|
+
FAINT = 0x5A6578
|
|
23
|
+
AMBER = art.AMBER
|
|
24
|
+
BAD = 0xFF4D6D
|
|
25
|
+
ROLE_COLORS = art.ROLE_COLORS
|
|
26
|
+
FONT_SIZES = (14, 16, 24, 32, 40)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def color(rgb):
|
|
30
|
+
return lv.color_hex(rgb)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def font(px):
|
|
34
|
+
"""The largest built-in font no taller than ``px``, else the smallest."""
|
|
35
|
+
best = None
|
|
36
|
+
for size in FONT_SIZES:
|
|
37
|
+
f = getattr(lv, "font_montserrat_%d" % size, None)
|
|
38
|
+
if f is not None and (best is None or size <= px):
|
|
39
|
+
best = f
|
|
40
|
+
return best or lv.font_get_default()
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def plain(obj):
|
|
44
|
+
"""``obj`` with no theme style, no scrolling and no clicks."""
|
|
45
|
+
obj.remove_style_all()
|
|
46
|
+
obj.remove_flag(lv.obj.FLAG.SCROLLABLE)
|
|
47
|
+
obj.remove_flag(lv.obj.FLAG.CLICKABLE)
|
|
48
|
+
return obj
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def box(parent, x, y, w, h, bg=PANEL, radius=8, border=LINE, opa=255):
|
|
52
|
+
"""A filled rectangle with a rounded edge."""
|
|
53
|
+
b = plain(lv.obj(parent))
|
|
54
|
+
b.set_pos(int(x), int(y))
|
|
55
|
+
b.set_size(int(w), int(h))
|
|
56
|
+
b.set_style_bg_color(color(bg), 0)
|
|
57
|
+
b.set_style_bg_opa(opa, 0)
|
|
58
|
+
b.set_style_radius(radius, 0)
|
|
59
|
+
if border is not None:
|
|
60
|
+
b.set_style_border_color(color(border), 0)
|
|
61
|
+
b.set_style_border_width(1, 0)
|
|
62
|
+
return b
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def text(parent, value, fnt, rgb=TEXT, width=None, align=None):
|
|
66
|
+
"""A label; with ``width``, one line ending in dots when it's too long."""
|
|
67
|
+
lbl = lv.label(parent)
|
|
68
|
+
lbl.set_style_text_font(fnt, 0)
|
|
69
|
+
lbl.set_style_text_color(color(rgb), 0)
|
|
70
|
+
lbl.set_text(value)
|
|
71
|
+
if width is not None:
|
|
72
|
+
lbl.set_width(int(width))
|
|
73
|
+
lbl.set_height(fnt.line_height)
|
|
74
|
+
lbl.set_long_mode(lv.label.LONG_MODE.DOTS)
|
|
75
|
+
if align is not None:
|
|
76
|
+
lbl.set_style_text_align(align, 0)
|
|
77
|
+
return lbl
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def heading(parent, value, fnt, x, y, role=None):
|
|
81
|
+
"""A small, spaced, dim heading over a group of controls, after the icon
|
|
82
|
+
for ``role`` (`glyphs.ICONS`) when one is given."""
|
|
83
|
+
lbl = text(parent, value.upper(), fnt, DIM)
|
|
84
|
+
lbl.set_style_text_letter_space(2, 0)
|
|
85
|
+
lbl.set_pos(int(x), int(y))
|
|
86
|
+
if role is not None:
|
|
87
|
+
size = fnt.line_height + 4
|
|
88
|
+
icon = glyphs.show(parent, role, size, color(DIM))
|
|
89
|
+
icon.set_pos(int(x) - 2, int(y) - 2)
|
|
90
|
+
lbl.set_x(int(x) + size + 2)
|
|
91
|
+
return lbl
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def button(parent, x, y, w, h, label=None, icon=None, fnt=None, on_click=None, radius=8, role=None):
|
|
95
|
+
"""A flat button: ``label`` text, an ``icon`` from the icons package, or
|
|
96
|
+
the icon for ``role`` (`glyphs.ICONS`).
|
|
97
|
+
|
|
98
|
+
Returns:
|
|
99
|
+
The button; its child 0 is the label or the icon.
|
|
100
|
+
"""
|
|
101
|
+
b = box(parent, x, y, w, h, RAISED, radius, LINE)
|
|
102
|
+
b.add_flag(lv.obj.FLAG.CLICKABLE)
|
|
103
|
+
b.set_style_bg_color(color(LINE), lv.STATE.PRESSED)
|
|
104
|
+
b.set_style_border_color(color(AMBER), lv.STATE.PRESSED)
|
|
105
|
+
if icon is not None or role is not None:
|
|
106
|
+
size = int(min(w, h) * 0.62)
|
|
107
|
+
if role is not None:
|
|
108
|
+
img = glyphs.show(b, role, size, color(TEXT))
|
|
109
|
+
else:
|
|
110
|
+
img = lvicons.image(b, icon, size, color(TEXT))
|
|
111
|
+
img.center()
|
|
112
|
+
else:
|
|
113
|
+
lbl = text(b, label or "", fnt or font(16))
|
|
114
|
+
lbl.center()
|
|
115
|
+
if on_click is not None:
|
|
116
|
+
b.add_event_cb(lambda _e: on_click(), lv.EVENT.CLICKED, None)
|
|
117
|
+
return b
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def select(btn, on, rgb=AMBER):
|
|
121
|
+
"""Show ``btn`` (made by `button`) chosen, or not."""
|
|
122
|
+
btn.set_style_border_color(color(rgb if on else LINE), 0)
|
|
123
|
+
btn.set_style_border_width(2 if on else 1, 0)
|
|
124
|
+
btn.set_style_bg_color(color(art.mix(rgb, RAISED, 0.78) if on else RAISED), 0)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def slider(parent, x, y, w, h, lo, hi, on_change):
|
|
128
|
+
"""A slider in the desk's colours; vertical when taller than wide.
|
|
129
|
+
``on_change(value)`` runs as it moves."""
|
|
130
|
+
s = lv.slider(parent)
|
|
131
|
+
s.set_pos(int(x), int(y))
|
|
132
|
+
s.set_size(int(w), int(h))
|
|
133
|
+
s.set_range(lo, hi)
|
|
134
|
+
s.set_style_bg_color(color(LINE), lv.PART.MAIN)
|
|
135
|
+
s.set_style_bg_opa(255, lv.PART.MAIN)
|
|
136
|
+
s.set_style_radius(4, lv.PART.MAIN)
|
|
137
|
+
s.set_style_bg_color(color(AMBER), lv.PART.INDICATOR)
|
|
138
|
+
s.set_style_bg_opa(255, lv.PART.INDICATOR)
|
|
139
|
+
s.set_style_radius(4, lv.PART.INDICATOR)
|
|
140
|
+
s.set_style_bg_color(color(TEXT), lv.PART.KNOB)
|
|
141
|
+
s.set_style_bg_opa(255, lv.PART.KNOB)
|
|
142
|
+
s.set_style_pad_all(max(2, int(min(w, h) // 3)), lv.PART.KNOB)
|
|
143
|
+
s.set_style_shadow_width(0, lv.PART.KNOB)
|
|
144
|
+
s.set_style_outline_width(0, lv.PART.MAIN)
|
|
145
|
+
s.set_style_outline_width(0, lv.PART.KNOB)
|
|
146
|
+
s.add_event_cb(lambda _e: on_change(s.get_value()), lv.EVENT.VALUE_CHANGED, None)
|
|
147
|
+
return s
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def dropdown(parent, x, y, w, h, fnt, on_pick):
|
|
151
|
+
"""A dropdown in the desk's colours; ``on_pick(index)`` when one is chosen."""
|
|
152
|
+
d = lv.dropdown(parent)
|
|
153
|
+
d.set_pos(int(x), int(y))
|
|
154
|
+
d.set_size(int(w), int(h))
|
|
155
|
+
d.set_style_text_font(fnt, 0)
|
|
156
|
+
d.set_style_bg_color(color(RAISED), 0)
|
|
157
|
+
d.set_style_text_color(color(TEXT), 0)
|
|
158
|
+
d.set_style_border_color(color(LINE), 0)
|
|
159
|
+
d.set_style_border_width(1, 0)
|
|
160
|
+
d.set_style_radius(8, 0)
|
|
161
|
+
d.set_style_pad_ver(max(2, (int(h) - fnt.line_height) // 2 - 1), 0)
|
|
162
|
+
lst = d.get_list()
|
|
163
|
+
lst.set_style_text_font(fnt, 0)
|
|
164
|
+
lst.set_style_bg_color(color(PANEL), 0)
|
|
165
|
+
lst.set_style_text_color(color(TEXT), 0)
|
|
166
|
+
lst.set_style_border_color(color(LINE), 0)
|
|
167
|
+
lst.set_style_bg_color(color(art.mix(AMBER, PANEL, 0.6)), lv.PART.SELECTED | lv.STATE.CHECKED)
|
|
168
|
+
d.add_event_cb(lambda _e: on_pick(d.get_selected()), lv.EVENT.VALUE_CHANGED, None)
|
|
169
|
+
return d
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""The editor's Pedals section: learn a MIDI foot controller's switches and
|
|
5
|
+
choose what each one does.
|
|
6
|
+
|
|
7
|
+
One row for each of the box's four switch slots. The button on the left
|
|
8
|
+
shows the message the switch sends; tap it, then press the switch, and the
|
|
9
|
+
slot learns it. The menu on the right binds the slot to pedal A or B (taps,
|
|
10
|
+
holds and double taps; the switch must send a release) or to one action. A
|
|
11
|
+
switch that sends a program change can only take an action: the box says so
|
|
12
|
+
if it's bound to a pedal.
|
|
13
|
+
|
|
14
|
+
Everything goes to the box as a ``pedals`` command, and the box's map comes
|
|
15
|
+
back to every desk (`box.Box`).
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from . import look
|
|
19
|
+
|
|
20
|
+
LEARNING = "PRESS NOW"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class Pedals:
|
|
24
|
+
"""The section in ``parent`` at ``(x, y)``, ``w`` by ``h``, for ``desk``."""
|
|
25
|
+
|
|
26
|
+
def __init__(self, parent, x, y, w, h, desk):
|
|
27
|
+
self.desk = desk
|
|
28
|
+
f = desk.fonts
|
|
29
|
+
self.base = look.box(parent, x, y, w, h, look.PANEL, 8, look.LINE)
|
|
30
|
+
self.bindings = []
|
|
31
|
+
self.map = None
|
|
32
|
+
pad = 6
|
|
33
|
+
foot = f["small"].line_height + 4
|
|
34
|
+
rh = (int(h) - 2 * pad - foot) // 4
|
|
35
|
+
bh = max(f["small"].line_height + 6, rh - 6)
|
|
36
|
+
lw = int((w - 3 * pad) * 0.44)
|
|
37
|
+
self.learn_buttons = []
|
|
38
|
+
self.menus = []
|
|
39
|
+
for i in range(4):
|
|
40
|
+
ry = pad + i * rh + (rh - bh) // 2
|
|
41
|
+
b = look.button(self.base, pad, ry, lw, bh, "%d -" % (i + 1), fnt=f["small"],
|
|
42
|
+
on_click=self._learner(i), radius=6)
|
|
43
|
+
self.learn_buttons.append(b)
|
|
44
|
+
d = look.dropdown(self.base, 2 * pad + lw, ry, int(w) - 3 * pad - lw - 2, bh, f["small"], self._binder(i))
|
|
45
|
+
self.menus.append(d)
|
|
46
|
+
self.hint = look.text(self.base, "", f["small"], look.DIM, int(w) - 2 * pad)
|
|
47
|
+
self.hint.set_pos(pad, int(h) - foot - 2)
|
|
48
|
+
|
|
49
|
+
# -- what it sends --
|
|
50
|
+
|
|
51
|
+
def _learner(self, i):
|
|
52
|
+
def on_click():
|
|
53
|
+
learning = self.map is not None and self.map.get("learning") == i
|
|
54
|
+
self.desk.command("pedals", learn=-1 if learning else i)
|
|
55
|
+
|
|
56
|
+
return on_click
|
|
57
|
+
|
|
58
|
+
def _binder(self, i):
|
|
59
|
+
def on_pick(index):
|
|
60
|
+
if 0 <= index < len(self.bindings):
|
|
61
|
+
self.desk.command("pedals", slot=i, bind=self.bindings[index][0])
|
|
62
|
+
|
|
63
|
+
return on_pick
|
|
64
|
+
|
|
65
|
+
# -- what it shows --
|
|
66
|
+
|
|
67
|
+
def on_map(self, pedal_map):
|
|
68
|
+
"""The box's map (`midipedal.MidiPedal.describe`)."""
|
|
69
|
+
if not pedal_map:
|
|
70
|
+
return
|
|
71
|
+
self.map = pedal_map
|
|
72
|
+
names = [b[0] for b in pedal_map.get("bindings") or []]
|
|
73
|
+
if names != [b[0] for b in self.bindings]:
|
|
74
|
+
self.bindings = pedal_map["bindings"]
|
|
75
|
+
options = "\n".join(label for _b, label in self.bindings)
|
|
76
|
+
for d in self.menus:
|
|
77
|
+
d.set_options(options)
|
|
78
|
+
learning = pedal_map.get("learning", -1)
|
|
79
|
+
for i, slot in enumerate(pedal_map.get("slots") or []):
|
|
80
|
+
b = self.learn_buttons[i]
|
|
81
|
+
label = LEARNING if i == learning else "%d %s" % (i + 1, describe(slot.get("msg")))
|
|
82
|
+
b.get_child(0).set_text(label)
|
|
83
|
+
look.select(b, i == learning)
|
|
84
|
+
if slot.get("bind") in names:
|
|
85
|
+
k = names.index(slot["bind"])
|
|
86
|
+
if self.menus[i].get_selected() != k and not self.menus[i].is_open():
|
|
87
|
+
self.menus[i].set_selected(k)
|
|
88
|
+
if learning >= 0:
|
|
89
|
+
self.hint.set_text("Press switch %d" % (learning + 1))
|
|
90
|
+
elif any(s.get("msg") and s["msg"][0] == "pc" for s in pedal_map.get("slots") or []):
|
|
91
|
+
self.hint.set_text("A PC switch takes an action only")
|
|
92
|
+
else:
|
|
93
|
+
last = pedal_map.get("last") or ""
|
|
94
|
+
self.hint.set_text(("Last: " + last) if last else "Tap a switch's button to learn it")
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def describe(msg):
|
|
98
|
+
"""``"CC 80 ch 1"`` for a slot's message, ``"-"`` for none."""
|
|
99
|
+
if not msg:
|
|
100
|
+
return "-"
|
|
101
|
+
kind, ch, num = msg
|
|
102
|
+
return "%s %d ch %d" % ({"cc": "CC", "note": "Note", "pc": "PC"}.get(kind, kind), num, ch + 1)
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""The desk's performance tab: the floor view's face, larger, with the
|
|
5
|
+
song's form under it and the songs, tempo and kit beside it.
|
|
6
|
+
|
|
7
|
+
The face is the floor view itself (`floor.Floor`), drawn at this tab's
|
|
8
|
+
size, so its lamps are pedals here too. The strip under it shows every part
|
|
9
|
+
of the song, the one playing lit with the playhead crossing it.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import lvgl as lv
|
|
13
|
+
|
|
14
|
+
from . import look
|
|
15
|
+
from .. import parts as song
|
|
16
|
+
from .strip import Strip
|
|
17
|
+
from .. import floor as floormod
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class Perform:
|
|
21
|
+
"""The tab in ``parent`` at ``(x, y)``, ``w`` by ``h``, for ``desk``."""
|
|
22
|
+
|
|
23
|
+
def __init__(self, parent, x, y, w, h, desk):
|
|
24
|
+
self.desk = desk
|
|
25
|
+
s = desk.scale
|
|
26
|
+
m = desk.m
|
|
27
|
+
f = desk.fonts
|
|
28
|
+
w, h = int(w), int(h)
|
|
29
|
+
self.base = look.plain(lv.obj(parent))
|
|
30
|
+
self.base.set_pos(int(x), int(y))
|
|
31
|
+
self.base.set_size(w, h)
|
|
32
|
+
rw = int(w * 0.3)
|
|
33
|
+
lw = w - rw - 3 * m
|
|
34
|
+
fh = int((h - 3 * m) * 0.72)
|
|
35
|
+
face = look.plain(lv.obj(self.base))
|
|
36
|
+
face.set_pos(m, m)
|
|
37
|
+
face.set_size(lw, fh)
|
|
38
|
+
face.set_style_radius(10, 0)
|
|
39
|
+
face.set_style_clip_corner(True, 0)
|
|
40
|
+
self.face = face
|
|
41
|
+
self.floor = floormod.Floor(face, (lw, fh), desk.panel_proxy)
|
|
42
|
+
|
|
43
|
+
sy = m + fh + m
|
|
44
|
+
look.heading(self.base, "Song form", f["small"], m, sy, "form")
|
|
45
|
+
hy = sy + f["small"].line_height + 2
|
|
46
|
+
self.strip = Strip(self.base, m, hy, lw, h - hy - m, f["small"])
|
|
47
|
+
|
|
48
|
+
rx = lw + 2 * m
|
|
49
|
+
y = m
|
|
50
|
+
look.heading(self.base, "Songs", f["small"], rx, y, "songs")
|
|
51
|
+
y += f["small"].line_height + 4
|
|
52
|
+
tempo_h = int(44 * s)
|
|
53
|
+
kit_h = int(38 * s)
|
|
54
|
+
list_h = h - y - 2 * m - tempo_h - kit_h - 2 * (f["small"].line_height + 4) - m
|
|
55
|
+
self.songs = look.box(self.base, rx, y, rw, list_h, look.PANEL, 8, look.LINE)
|
|
56
|
+
self.songs_w = rw
|
|
57
|
+
self.songs.add_flag(lv.obj.FLAG.SCROLLABLE)
|
|
58
|
+
self.songs.set_scroll_dir(lv.DIR.VER)
|
|
59
|
+
self.song_buttons = []
|
|
60
|
+
self.song_index = -1
|
|
61
|
+
y += list_h + m
|
|
62
|
+
look.heading(self.base, "Tempo", f["small"], rx, y)
|
|
63
|
+
y += f["small"].line_height + 4
|
|
64
|
+
bw = tempo_h
|
|
65
|
+
look.button(self.base, rx, y, bw, tempo_h, icon="remove", on_click=lambda: self._tempo(-1))
|
|
66
|
+
look.button(self.base, rx + rw - bw, y, bw, tempo_h, icon="add", on_click=lambda: self._tempo(1))
|
|
67
|
+
well = look.box(self.base, rx + bw + 6, y, rw - 2 * bw - 12, tempo_h, 0x05070B, 8, look.LINE)
|
|
68
|
+
self.tempo = look.text(well, "", f["value"], look.AMBER)
|
|
69
|
+
self.tempo.align(lv.ALIGN.CENTER, -int(14 * s), 0)
|
|
70
|
+
bpm = look.text(well, "BPM", f["small"], look.DIM)
|
|
71
|
+
bpm.align(lv.ALIGN.RIGHT_MID, -8, 0)
|
|
72
|
+
y += tempo_h + m
|
|
73
|
+
look.heading(self.base, "Kit", f["small"], rx, y)
|
|
74
|
+
y += f["small"].line_height + 4
|
|
75
|
+
self.kits = look.dropdown(self.base, rx, y, rw, kit_h, f["body"], self._kit)
|
|
76
|
+
self.kit_specs = []
|
|
77
|
+
self.kits_listed = None # the kit specs the list was set to
|
|
78
|
+
self.titles = None # the songs the buttons were made for
|
|
79
|
+
|
|
80
|
+
# -- what it sends --
|
|
81
|
+
|
|
82
|
+
def _tempo(self, step):
|
|
83
|
+
panel = self.desk.panel
|
|
84
|
+
if panel is None or panel.doc is None:
|
|
85
|
+
return
|
|
86
|
+
panel.set("/tempo", int(panel.doc.get("tempo", 120) + 0.5) + step)
|
|
87
|
+
self.show_tempo(panel.doc)
|
|
88
|
+
|
|
89
|
+
def _kit(self, index):
|
|
90
|
+
if 0 <= index < len(self.kit_specs):
|
|
91
|
+
self.desk.command("kit", spec=self.kit_specs[index])
|
|
92
|
+
|
|
93
|
+
def _song(self, index):
|
|
94
|
+
def on_click(_e):
|
|
95
|
+
self.desk.command("song", index=index)
|
|
96
|
+
|
|
97
|
+
return on_click
|
|
98
|
+
|
|
99
|
+
# -- what it shows --
|
|
100
|
+
|
|
101
|
+
def show_tempo(self, doc):
|
|
102
|
+
self.tempo.set_text("%d" % int(doc.get("tempo", 120) + 0.5))
|
|
103
|
+
|
|
104
|
+
def on_doc(self, doc, desc):
|
|
105
|
+
self.floor._doc(doc, desc)
|
|
106
|
+
self.strip.set_blocks(song.blocks(doc))
|
|
107
|
+
self.show_tempo(doc)
|
|
108
|
+
titles = desc.get("titles") or [doc.get("name", "")]
|
|
109
|
+
if titles != self.titles: # a song change keeps the list
|
|
110
|
+
self.titles = titles
|
|
111
|
+
f = self.desk.fonts
|
|
112
|
+
s = self.desk.scale
|
|
113
|
+
self.songs.clean()
|
|
114
|
+
self.song_buttons = []
|
|
115
|
+
bh = int(34 * s)
|
|
116
|
+
w = self.songs_w - 14
|
|
117
|
+
for i, name in enumerate(titles):
|
|
118
|
+
b = look.button(self.songs, 6, 6 + i * (bh + 4), w, bh, name, fnt=f["body"], radius=6)
|
|
119
|
+
b.get_child(0).align(lv.ALIGN.LEFT_MID, 10, 0)
|
|
120
|
+
b.add_event_cb(self._song(i), lv.EVENT.CLICKED, None)
|
|
121
|
+
self.song_buttons.append(b)
|
|
122
|
+
self.song_index = -1
|
|
123
|
+
kits = desc.get("kit_list") or []
|
|
124
|
+
specs = [k["spec"] for k in kits]
|
|
125
|
+
if specs != self.kits_listed:
|
|
126
|
+
self.kits_listed = self.kit_specs = specs
|
|
127
|
+
self.kits.set_options("\n".join(k["name"] for k in kits))
|
|
128
|
+
self.show_kit(desc.get("kit"))
|
|
129
|
+
|
|
130
|
+
def show_kit(self, spec):
|
|
131
|
+
if spec in self.kit_specs and not self.kits.is_open():
|
|
132
|
+
self.kits.set_selected(self.kit_specs.index(spec))
|
|
133
|
+
|
|
134
|
+
def on_op(self, op):
|
|
135
|
+
path = op.get("path", "")
|
|
136
|
+
doc = self.desk.panel.doc
|
|
137
|
+
if path == "/tempo":
|
|
138
|
+
self.show_tempo(doc)
|
|
139
|
+
elif path.startswith("/parts") or path.endswith("/bars"):
|
|
140
|
+
self.strip.set_blocks(song.blocks(doc))
|
|
141
|
+
|
|
142
|
+
def on_event(self, ev):
|
|
143
|
+
if ev.get("name") == "kit":
|
|
144
|
+
self.show_kit(ev.get("spec"))
|
|
145
|
+
elif ev.get("name") == "song":
|
|
146
|
+
self.show_kit(ev.get("kit"))
|
|
147
|
+
|
|
148
|
+
def on_tele(self, t):
|
|
149
|
+
self.floor._tele(t)
|
|
150
|
+
self.strip.show(t)
|
|
151
|
+
index = t.get("song_index", -1)
|
|
152
|
+
if index != self.song_index:
|
|
153
|
+
for i, b in enumerate(self.song_buttons):
|
|
154
|
+
look.select(b, i == index)
|
|
155
|
+
self.song_index = index
|
|
156
|
+
if 0 <= index < len(self.song_buttons):
|
|
157
|
+
self.song_buttons[index].scroll_to_view(False)
|