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/stompbox/ui.py
ADDED
|
@@ -0,0 +1,817 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
|
|
5
|
+
"""The screen: a pedal board over the engine, laid out to whatever size the
|
|
6
|
+
app is given.
|
|
7
|
+
|
|
8
|
+
Across the top, the source and the boards. Under it, up to four pedals, each
|
|
9
|
+
drawn from its style (`styles`) with its first knobs, a light and a
|
|
10
|
+
footswitch. Tap a pedal to edit it below: every knob, built from the pedal's
|
|
11
|
+
own descriptions, and its patches. Tap an empty slot to add a pedal.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import lvgl as lv
|
|
15
|
+
from touchkit import ui as kit
|
|
16
|
+
|
|
17
|
+
from . import effects, styles
|
|
18
|
+
from .engine import MAX_PEDALS
|
|
19
|
+
from .meter import STEPS
|
|
20
|
+
|
|
21
|
+
BG = 0x15171A
|
|
22
|
+
PANEL = 0x1F2226
|
|
23
|
+
LINE = 0x33373D
|
|
24
|
+
TEXT = 0xE8E6E1
|
|
25
|
+
MUTED = 0x8C9096
|
|
26
|
+
ACCENT = 0xF2A33A # amber, like a pedal's LED
|
|
27
|
+
GOOD = 0x63C27A
|
|
28
|
+
CLIP = 0xE5484D # the clip light
|
|
29
|
+
|
|
30
|
+
NARROW = 600 # below this width, the smaller knobs and buttons
|
|
31
|
+
SWITCH = 0xC8CCD0 # a footswitch's chrome
|
|
32
|
+
LED_OFF = 0x2A1A1A
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def bare(parent):
|
|
36
|
+
"""An object with no look of its own that doesn't scroll."""
|
|
37
|
+
o = lv.obj(parent)
|
|
38
|
+
o.set_style_bg_opa(0, 0)
|
|
39
|
+
o.set_style_border_width(0, 0)
|
|
40
|
+
o.set_style_pad_all(0, 0)
|
|
41
|
+
o.set_style_radius(0, 0)
|
|
42
|
+
o.remove_flag(lv.obj.FLAG.SCROLLABLE)
|
|
43
|
+
return o
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def dot(parent, size, colour):
|
|
47
|
+
d = lv.obj(parent)
|
|
48
|
+
d.set_size(size, size)
|
|
49
|
+
d.set_style_radius(lv.RADIUS_CIRCLE, 0)
|
|
50
|
+
d.set_style_bg_color(c(colour), 0)
|
|
51
|
+
d.set_style_bg_opa(255, 0)
|
|
52
|
+
d.set_style_border_width(0, 0)
|
|
53
|
+
d.set_style_pad_all(0, 0)
|
|
54
|
+
d.remove_flag(lv.obj.FLAG.SCROLLABLE)
|
|
55
|
+
d.remove_flag(lv.obj.FLAG.CLICKABLE)
|
|
56
|
+
return d
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _luma(rgb):
|
|
60
|
+
return (((rgb >> 16) & 255) * 3 + ((rgb >> 8) & 255) * 6 + (rgb & 255)) / 2550
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def accent_of(style):
|
|
64
|
+
"""The colour a pedal's knobs and name light up in the editor: its body,
|
|
65
|
+
unless the body is grey, or too dark or pale to read against the panel,
|
|
66
|
+
and then its LED."""
|
|
67
|
+
body = style["body"]
|
|
68
|
+
parts = ((body >> 16) & 255, (body >> 8) & 255, body & 255)
|
|
69
|
+
coloured = max(parts) - min(parts) >= 60
|
|
70
|
+
return body if coloured and 0.2 < _luma(body) < 0.8 else style["led"]
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def c(hex_):
|
|
74
|
+
return lv.color_hex(hex_)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def label(parent, text, colour=TEXT, font=None):
|
|
78
|
+
lb = lv.label(parent)
|
|
79
|
+
lb.set_text(text)
|
|
80
|
+
lb.set_style_text_color(c(colour), 0)
|
|
81
|
+
lb.set_style_text_font(font or kit.small, 0)
|
|
82
|
+
return lb
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def flow(parent, wrap=True):
|
|
86
|
+
"""A row that wraps, its children centred on the line."""
|
|
87
|
+
parent.set_flex_flow(lv.FLEX_FLOW.ROW_WRAP if wrap else lv.FLEX_FLOW.ROW)
|
|
88
|
+
parent.set_flex_align(lv.FLEX_ALIGN.START, lv.FLEX_ALIGN.CENTER, lv.FLEX_ALIGN.CENTER)
|
|
89
|
+
parent.set_style_pad_column(10, 0)
|
|
90
|
+
parent.set_style_pad_row(8, 0)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def panel(parent):
|
|
94
|
+
p = lv.obj(parent)
|
|
95
|
+
p.set_width(lv.pct(100))
|
|
96
|
+
p.set_height(lv.SIZE_CONTENT)
|
|
97
|
+
p.set_style_bg_color(c(PANEL), 0)
|
|
98
|
+
p.set_style_border_width(0, 0)
|
|
99
|
+
p.set_style_radius(10, 0)
|
|
100
|
+
p.set_style_pad_all(10, 0)
|
|
101
|
+
p.remove_flag(lv.obj.FLAG.SCROLLABLE)
|
|
102
|
+
return p
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def button(parent, text, h, on_click, checkable=False):
|
|
106
|
+
"""A button of the strip's look; *on_click* takes no arguments."""
|
|
107
|
+
b = lv.button(parent)
|
|
108
|
+
b.set_size(lv.SIZE_CONTENT, h)
|
|
109
|
+
b.set_style_bg_color(c(LINE), 0)
|
|
110
|
+
b.set_style_bg_color(c(ACCENT), lv.STATE.CHECKED)
|
|
111
|
+
b.set_style_radius(8, 0)
|
|
112
|
+
b.set_style_shadow_width(0, 0)
|
|
113
|
+
if checkable:
|
|
114
|
+
b.add_flag(lv.obj.FLAG.CHECKABLE)
|
|
115
|
+
lb = label(b, text)
|
|
116
|
+
lb.center()
|
|
117
|
+
b.add_event_cb(lambda e: on_click(), lv.EVENT.CLICKED, None)
|
|
118
|
+
return b, lb
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def dropdown(parent, options, on_pick, list_height):
|
|
122
|
+
dd = lv.dropdown(parent)
|
|
123
|
+
dd.set_flex_grow(1)
|
|
124
|
+
dd.set_style_min_width(140, 0)
|
|
125
|
+
dd.set_options("\n".join(options))
|
|
126
|
+
dd.set_style_bg_color(c(BG), 0)
|
|
127
|
+
dd.set_style_text_color(c(TEXT), 0)
|
|
128
|
+
dd.set_style_text_font(kit.small, 0)
|
|
129
|
+
dd.set_style_border_color(c(LINE), 0)
|
|
130
|
+
lst = dd.get_list()
|
|
131
|
+
lst.set_style_bg_color(c(BG), 0)
|
|
132
|
+
lst.set_style_text_color(c(TEXT), 0)
|
|
133
|
+
lst.set_style_text_font(kit.small, 0)
|
|
134
|
+
lst.set_style_max_height(list_height, 0)
|
|
135
|
+
dd.add_event_cb(lambda e: on_pick(dd.get_selected()),
|
|
136
|
+
lv.EVENT.VALUE_CHANGED, None)
|
|
137
|
+
return dd
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def set_checked(obj, on):
|
|
141
|
+
if on:
|
|
142
|
+
obj.add_state(lv.STATE.CHECKED)
|
|
143
|
+
else:
|
|
144
|
+
obj.remove_state(lv.STATE.CHECKED)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def show(obj, on):
|
|
148
|
+
if on:
|
|
149
|
+
obj.remove_flag(lv.obj.FLAG.HIDDEN)
|
|
150
|
+
else:
|
|
151
|
+
obj.add_flag(lv.obj.FLAG.HIDDEN)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
class Knob:
|
|
155
|
+
"""Drag up or down to turn it; double-click puts it back to the patch's
|
|
156
|
+
value. It turns on the 0 to 127 scale and shows what the step stands for
|
|
157
|
+
in the effect's own units."""
|
|
158
|
+
|
|
159
|
+
def __init__(self, parent, desc, size, on_change, text, colour=ACCENT):
|
|
160
|
+
self.desc = desc
|
|
161
|
+
self.on_change = on_change
|
|
162
|
+
self.text = text
|
|
163
|
+
self.root = lv.obj(parent)
|
|
164
|
+
self.root.set_size(size + 24, size + 26)
|
|
165
|
+
self.root.set_style_bg_opa(0, 0)
|
|
166
|
+
self.root.set_style_border_width(0, 0)
|
|
167
|
+
self.root.set_style_pad_all(0, 0)
|
|
168
|
+
self.root.remove_flag(lv.obj.FLAG.SCROLLABLE)
|
|
169
|
+
self.root.add_flag(lv.obj.FLAG.CLICKABLE)
|
|
170
|
+
# A drag turns the knob; it doesn't scroll the grid behind it.
|
|
171
|
+
self.root.remove_flag(lv.obj.FLAG.SCROLL_CHAIN_VER)
|
|
172
|
+
self.arc = lv.arc(self.root)
|
|
173
|
+
self.arc.set_size(size, size)
|
|
174
|
+
self.arc.align(lv.ALIGN.TOP_MID, 0, 0)
|
|
175
|
+
self.arc.set_range(0, 127)
|
|
176
|
+
self.arc.set_bg_angles(135, 45)
|
|
177
|
+
if desc["mode"] == "BIPOLAR":
|
|
178
|
+
self.arc.set_mode(lv.arc.MODE.SYMMETRICAL)
|
|
179
|
+
self.arc.remove_flag(lv.obj.FLAG.CLICKABLE)
|
|
180
|
+
self.arc.set_style_arc_width(7, lv.PART.MAIN)
|
|
181
|
+
self.arc.set_style_arc_width(7, lv.PART.INDICATOR)
|
|
182
|
+
self.arc.set_style_arc_color(c(LINE), lv.PART.MAIN)
|
|
183
|
+
self.arc.set_style_arc_color(c(colour), lv.PART.INDICATOR)
|
|
184
|
+
self.arc.set_style_bg_color(c(TEXT), lv.PART.KNOB)
|
|
185
|
+
self.arc.set_style_pad_all(3, lv.PART.KNOB)
|
|
186
|
+
self.arc.set_style_pad_all(5, lv.PART.MAIN)
|
|
187
|
+
self.value = label(self.arc, "", TEXT)
|
|
188
|
+
self.value.center()
|
|
189
|
+
self.name = label(self.root, desc["label"], MUTED)
|
|
190
|
+
self.name.set_width(size + 24)
|
|
191
|
+
self.name.set_long_mode(lv.label.LONG_MODE.DOTS)
|
|
192
|
+
self.name.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
|
|
193
|
+
self.name.align(lv.ALIGN.BOTTOM_MID, 0, 0)
|
|
194
|
+
self._drag = None
|
|
195
|
+
self.root.add_event_cb(lambda e: self._pressed(), lv.EVENT.PRESSED, None)
|
|
196
|
+
self.root.add_event_cb(lambda e: self._pressing(), lv.EVENT.PRESSING, None)
|
|
197
|
+
self.root.add_event_cb(lambda e: self._released(), lv.EVENT.RELEASED, None)
|
|
198
|
+
self.root.add_event_cb(lambda e: self.reset(), lv.EVENT.DOUBLE_CLICKED, None)
|
|
199
|
+
|
|
200
|
+
def _y(self):
|
|
201
|
+
pt = lv.point_t()
|
|
202
|
+
lv.indev_active().get_point(pt)
|
|
203
|
+
return pt.y
|
|
204
|
+
|
|
205
|
+
def _pressed(self):
|
|
206
|
+
self._drag = (self._y(), self.arc.get_value())
|
|
207
|
+
|
|
208
|
+
def _pressing(self):
|
|
209
|
+
if self._drag is None:
|
|
210
|
+
return
|
|
211
|
+
y0, v0 = self._drag
|
|
212
|
+
v = max(0, min(127, v0 + (y0 - self._y()) // 2))
|
|
213
|
+
if v != self.arc.get_value():
|
|
214
|
+
self.turn(v)
|
|
215
|
+
|
|
216
|
+
def _released(self):
|
|
217
|
+
self._drag = None
|
|
218
|
+
|
|
219
|
+
def show(self, value):
|
|
220
|
+
self.arc.set_value(int(round(value)))
|
|
221
|
+
self.value.set_text(self.text(self.desc["key"]))
|
|
222
|
+
|
|
223
|
+
def turn(self, value):
|
|
224
|
+
"""Turn it as a hand would: the effect and the screen both follow."""
|
|
225
|
+
self.on_change(self.desc["key"], value)
|
|
226
|
+
self.show(value)
|
|
227
|
+
|
|
228
|
+
def reset(self):
|
|
229
|
+
self.turn(self.desc["default"])
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
class Switch:
|
|
233
|
+
"""A knob that is on or off, as a button."""
|
|
234
|
+
|
|
235
|
+
def __init__(self, parent, desc, h, on_change, colour):
|
|
236
|
+
self.desc = desc
|
|
237
|
+
self.on_change = on_change
|
|
238
|
+
self.btn, _ = button(parent, desc["label"], h, self._clicked, checkable=True)
|
|
239
|
+
self.btn.set_style_bg_color(c(colour), lv.STATE.CHECKED)
|
|
240
|
+
|
|
241
|
+
def _clicked(self):
|
|
242
|
+
self.on_change(self.desc["key"], 127 if self.btn.has_state(lv.STATE.CHECKED) else 0)
|
|
243
|
+
|
|
244
|
+
def show(self, value):
|
|
245
|
+
set_checked(self.btn, value >= 64)
|
|
246
|
+
|
|
247
|
+
def turn(self, value):
|
|
248
|
+
self.on_change(self.desc["key"], value)
|
|
249
|
+
self.show(value)
|
|
250
|
+
|
|
251
|
+
def reset(self):
|
|
252
|
+
self.turn(self.desc["default"])
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
class PedalView:
|
|
256
|
+
"""One slot on the board: a pedal drawn in its style, or an empty space
|
|
257
|
+
to add one. Tap it to select it; tap its footswitch to switch it."""
|
|
258
|
+
|
|
259
|
+
def __init__(self, parent, index, on_select, on_switch):
|
|
260
|
+
self.index = index
|
|
261
|
+
self.on_select = on_select
|
|
262
|
+
self.on_switch = on_switch
|
|
263
|
+
self.root = lv.obj(parent)
|
|
264
|
+
self.root.set_height(lv.pct(100))
|
|
265
|
+
self.root.set_width(0)
|
|
266
|
+
self.root.set_flex_grow(1)
|
|
267
|
+
self.root.set_style_pad_all(0, 0)
|
|
268
|
+
self.root.remove_flag(lv.obj.FLAG.SCROLLABLE)
|
|
269
|
+
self.root.add_flag(lv.obj.FLAG.CLICKABLE)
|
|
270
|
+
self.root.add_event_cb(lambda e: self.on_select(self.index), lv.EVENT.CLICKED, None)
|
|
271
|
+
self.pedal = None
|
|
272
|
+
self.minis = []
|
|
273
|
+
self.selected = False
|
|
274
|
+
|
|
275
|
+
def _clear(self):
|
|
276
|
+
self.root.clean()
|
|
277
|
+
self.minis = []
|
|
278
|
+
self.led = None
|
|
279
|
+
|
|
280
|
+
def show_empty(self, live):
|
|
281
|
+
"""An empty slot: *live* when it's the one a new pedal goes in."""
|
|
282
|
+
self._clear()
|
|
283
|
+
self.pedal = None
|
|
284
|
+
r = self.root
|
|
285
|
+
r.set_style_bg_color(c(PANEL), 0)
|
|
286
|
+
r.set_style_bg_opa(255, 0)
|
|
287
|
+
r.set_style_radius(10, 0)
|
|
288
|
+
r.set_style_border_width(2, 0)
|
|
289
|
+
r.set_style_border_color(c(ACCENT if self.selected else LINE), 0)
|
|
290
|
+
lb = label(r, (lv.SYMBOL.PLUS + " Add") if live else "", MUTED)
|
|
291
|
+
lb.center()
|
|
292
|
+
r.set_style_opa(255 if live else 120, 0)
|
|
293
|
+
|
|
294
|
+
def show_pedal(self, pedal, size):
|
|
295
|
+
"""Draw *pedal* in its style; *size* is the screen's knob size."""
|
|
296
|
+
self._clear()
|
|
297
|
+
self.pedal = pedal
|
|
298
|
+
st = styles.style(pedal.name, effects.category(pedal.name))
|
|
299
|
+
self.style = st
|
|
300
|
+
r = self.root
|
|
301
|
+
r.set_style_opa(255, 0)
|
|
302
|
+
shape = st["shape"]
|
|
303
|
+
r.set_style_bg_color(c(st["body"]), 0)
|
|
304
|
+
r.set_style_bg_opa(255, 0)
|
|
305
|
+
r.set_style_radius({"round": 40, "pedal": 10, "wide": 8, "sliders": 8,
|
|
306
|
+
"panel": 4, "rack": 2}.get(shape, 10), 0)
|
|
307
|
+
r.set_style_border_width(3 if self.selected else 1, 0)
|
|
308
|
+
r.set_style_border_color(c(ACCENT if self.selected else st["trim"]), 0)
|
|
309
|
+
r.set_flex_flow(lv.FLEX_FLOW.COLUMN)
|
|
310
|
+
r.set_flex_align(lv.FLEX_ALIGN.SPACE_EVENLY, lv.FLEX_ALIGN.CENTER, lv.FLEX_ALIGN.CENTER)
|
|
311
|
+
r.set_style_pad_ver(6, 0)
|
|
312
|
+
r.set_style_pad_hor(4, 0)
|
|
313
|
+
r.set_style_pad_row(2, 0)
|
|
314
|
+
mini = max(16, min(28, size // 3))
|
|
315
|
+
|
|
316
|
+
# The knobs come first on a pedal, as on most floor boxes; a front
|
|
317
|
+
# panel puts its name on a band across the top instead.
|
|
318
|
+
title_on_band = shape in ("panel", "rack")
|
|
319
|
+
if title_on_band:
|
|
320
|
+
band = bare(r)
|
|
321
|
+
band.set_width(lv.pct(100))
|
|
322
|
+
band.set_height(lv.SIZE_CONTENT)
|
|
323
|
+
band.set_style_bg_color(c(st["trim"]), 0)
|
|
324
|
+
band.set_style_bg_opa(255, 0)
|
|
325
|
+
band.set_style_radius(3, 0)
|
|
326
|
+
band.set_style_pad_ver(2, 0)
|
|
327
|
+
if shape == "rack":
|
|
328
|
+
band.set_style_border_width(0, 0)
|
|
329
|
+
self._title(band, st, pedal, c_text=st["body"] if shape == "panel" else st["text"])
|
|
330
|
+
|
|
331
|
+
knobs = bare(r)
|
|
332
|
+
knobs.set_size(lv.pct(100), lv.SIZE_CONTENT)
|
|
333
|
+
knobs.set_flex_flow(lv.FLEX_FLOW.ROW)
|
|
334
|
+
knobs.set_flex_align(lv.FLEX_ALIGN.SPACE_EVENLY, lv.FLEX_ALIGN.CENTER, lv.FLEX_ALIGN.CENTER)
|
|
335
|
+
if shape == "sliders":
|
|
336
|
+
knobs.set_style_bg_color(c(st["trim"]), 0)
|
|
337
|
+
knobs.set_style_bg_opa(255, 0)
|
|
338
|
+
knobs.set_style_pad_ver(3, 0)
|
|
339
|
+
knobs.set_style_radius(3, 0)
|
|
340
|
+
for d in pedal.parameters()[:7]:
|
|
341
|
+
b = lv.bar(knobs)
|
|
342
|
+
b.set_size(4, mini + 8)
|
|
343
|
+
b.set_range(0, 127)
|
|
344
|
+
b.set_style_bg_color(c(LINE), lv.PART.MAIN)
|
|
345
|
+
b.set_style_bg_color(c(st["knob"]), lv.PART.INDICATOR)
|
|
346
|
+
b.remove_flag(lv.obj.FLAG.CLICKABLE)
|
|
347
|
+
self.minis.append((b, d["key"], True))
|
|
348
|
+
else:
|
|
349
|
+
heads = [d for d in pedal.parameters() if d["mode"] != "TOGGLE"][:3]
|
|
350
|
+
for d in heads:
|
|
351
|
+
a = lv.arc(knobs)
|
|
352
|
+
a.set_size(mini, mini)
|
|
353
|
+
a.set_range(0, 127)
|
|
354
|
+
a.set_bg_angles(135, 45)
|
|
355
|
+
a.remove_flag(lv.obj.FLAG.CLICKABLE)
|
|
356
|
+
a.set_style_bg_color(c(st["knob"]), 0)
|
|
357
|
+
a.set_style_bg_opa(255, 0)
|
|
358
|
+
a.set_style_radius(lv.RADIUS_CIRCLE, 0)
|
|
359
|
+
# The cap is the arc's background; its pointer is the arc's
|
|
360
|
+
# knob, a dot of the pointer colour riding the rim.
|
|
361
|
+
a.set_style_arc_width(3, lv.PART.MAIN)
|
|
362
|
+
a.set_style_arc_width(3, lv.PART.INDICATOR)
|
|
363
|
+
a.set_style_arc_opa(0, lv.PART.MAIN)
|
|
364
|
+
a.set_style_arc_opa(0, lv.PART.INDICATOR)
|
|
365
|
+
a.set_style_pad_all(2, lv.PART.MAIN)
|
|
366
|
+
a.set_style_bg_color(c(st["pointer"]), lv.PART.KNOB)
|
|
367
|
+
a.set_style_bg_opa(255, lv.PART.KNOB)
|
|
368
|
+
a.set_style_pad_all(1, lv.PART.KNOB)
|
|
369
|
+
a.set_style_border_width(1, 0)
|
|
370
|
+
a.set_style_border_color(c(st["trim"]), 0)
|
|
371
|
+
self.minis.append((a, d["key"], False))
|
|
372
|
+
|
|
373
|
+
if not title_on_band:
|
|
374
|
+
self._title(r, st, pedal)
|
|
375
|
+
|
|
376
|
+
foot = bare(r)
|
|
377
|
+
foot.set_size(lv.pct(100), lv.SIZE_CONTENT)
|
|
378
|
+
foot.set_flex_flow(lv.FLEX_FLOW.ROW)
|
|
379
|
+
foot.set_flex_align(lv.FLEX_ALIGN.CENTER, lv.FLEX_ALIGN.CENTER, lv.FLEX_ALIGN.CENTER)
|
|
380
|
+
foot.set_style_pad_column(8, 0)
|
|
381
|
+
self.led = dot(foot, 9, LED_OFF)
|
|
382
|
+
sw = lv.obj(foot)
|
|
383
|
+
sz = max(22, min(34, size // 2 - 6))
|
|
384
|
+
sw.set_size(sz, sz)
|
|
385
|
+
sw.set_style_radius(lv.RADIUS_CIRCLE, 0)
|
|
386
|
+
sw.set_style_bg_color(c(SWITCH), 0)
|
|
387
|
+
sw.set_style_bg_grad_color(c(0x70767C), 0)
|
|
388
|
+
sw.set_style_bg_grad_dir(lv.GRAD_DIR.VER, 0)
|
|
389
|
+
sw.set_style_border_width(2, 0)
|
|
390
|
+
sw.set_style_border_color(c(0x50565C), 0)
|
|
391
|
+
sw.set_style_bg_color(c(0x90969C), lv.STATE.PRESSED)
|
|
392
|
+
sw.remove_flag(lv.obj.FLAG.SCROLLABLE)
|
|
393
|
+
sw.add_flag(lv.obj.FLAG.CLICKABLE)
|
|
394
|
+
sw.add_event_cb(lambda e: self.on_switch(self.index), lv.EVENT.CLICKED, None)
|
|
395
|
+
self.switch = sw
|
|
396
|
+
self.refresh()
|
|
397
|
+
|
|
398
|
+
def _title(self, parent, st, pedal, c_text=None):
|
|
399
|
+
t = label(parent, pedal.title.upper() if st["weight"] == "bold" else pedal.title,
|
|
400
|
+
c_text if c_text is not None else st["text"],
|
|
401
|
+
kit.small)
|
|
402
|
+
t.set_width(lv.pct(100))
|
|
403
|
+
t.set_long_mode(lv.label.LONG_MODE.DOTS)
|
|
404
|
+
t.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
|
|
405
|
+
if st["weight"] == "bold":
|
|
406
|
+
t.set_style_text_letter_space(1, 0)
|
|
407
|
+
return t
|
|
408
|
+
|
|
409
|
+
def refresh(self):
|
|
410
|
+
"""Show the pedal's knobs and whether it's on."""
|
|
411
|
+
p = self.pedal
|
|
412
|
+
if p is None:
|
|
413
|
+
return
|
|
414
|
+
for w, key, is_bar in self.minis:
|
|
415
|
+
v = int(round(p.get(key)))
|
|
416
|
+
if is_bar:
|
|
417
|
+
w.set_value(v, False)
|
|
418
|
+
else:
|
|
419
|
+
w.set_value(v)
|
|
420
|
+
if self.led is not None:
|
|
421
|
+
self.led.set_style_bg_color(c(self.style["led"] if p.on else LED_OFF), 0)
|
|
422
|
+
self.led.set_style_shadow_width(10 if p.on else 0, 0)
|
|
423
|
+
self.led.set_style_shadow_color(c(self.style["led"]), 0)
|
|
424
|
+
|
|
425
|
+
def select(self, on):
|
|
426
|
+
self.selected = on
|
|
427
|
+
if self.pedal is not None:
|
|
428
|
+
self.root.set_style_border_width(3 if on else 1, 0)
|
|
429
|
+
self.root.set_style_border_color(c(ACCENT if on else self.style["trim"]), 0)
|
|
430
|
+
else:
|
|
431
|
+
self.root.set_style_border_color(c(ACCENT if on else LINE), 0)
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
class Screen:
|
|
435
|
+
def __init__(self, app, scope):
|
|
436
|
+
self.app = app
|
|
437
|
+
self.status_label = kit.status(scope) # first: on a narrow screen its row takes room from scope.size
|
|
438
|
+
W, H = scope.size
|
|
439
|
+
self.W = W
|
|
440
|
+
narrow = W < NARROW
|
|
441
|
+
self.knob_size = 56 if narrow else 72
|
|
442
|
+
self.btn_h = 34 if narrow else 38
|
|
443
|
+
self.list_h = H * 2 // 3
|
|
444
|
+
self.knobs = {}
|
|
445
|
+
scr = scope.root
|
|
446
|
+
scr.set_style_bg_color(c(BG), 0)
|
|
447
|
+
scr.set_style_bg_opa(255, 0)
|
|
448
|
+
scr.set_style_pad_all(6, 0)
|
|
449
|
+
scr.set_style_pad_row(6, 0)
|
|
450
|
+
scr.set_flex_flow(lv.FLEX_FLOW.COLUMN)
|
|
451
|
+
self.scr = scr
|
|
452
|
+
self._source()
|
|
453
|
+
self._board(max(100, min(170, H * 27 // 100)))
|
|
454
|
+
self._editor()
|
|
455
|
+
self._footer()
|
|
456
|
+
|
|
457
|
+
# -- the clip or the live input, and the boards ----------------------------
|
|
458
|
+
|
|
459
|
+
def _source(self):
|
|
460
|
+
p = panel(self.scr)
|
|
461
|
+
p.set_style_pad_all(6, 0)
|
|
462
|
+
flow(p)
|
|
463
|
+
self.live_btn, _ = button(
|
|
464
|
+
p, "Live", self.btn_h,
|
|
465
|
+
lambda: self.app.set_live(self.live_btn.has_state(lv.STATE.CHECKED)),
|
|
466
|
+
checkable=True)
|
|
467
|
+
# In a browser Live is the only input, so there's nothing to switch.
|
|
468
|
+
show(self.live_btn, self.app.can_go_live and not self.app.browser)
|
|
469
|
+
names = self.app.clip_names() or ["(no clips found)"]
|
|
470
|
+
self.clip_dd = dropdown(p, names, self.app.pick_clip, self.list_h)
|
|
471
|
+
# It takes what the row has left over, so a long clip name doesn't push
|
|
472
|
+
# the buttons after it onto a second row.
|
|
473
|
+
self.clip_dd.set_width(100)
|
|
474
|
+
self.clip_dd.set_style_min_width(100, 0)
|
|
475
|
+
self.play_btn, self.play_text = button(p, lv.SYMBOL.PLAY + " Play", self.btn_h,
|
|
476
|
+
self.app.toggle_play)
|
|
477
|
+
self.loop_btn, _ = button(p, lv.SYMBOL.LOOP, self.btn_h,
|
|
478
|
+
lambda: self.app.set_loop(self.loop_btn.has_state(lv.STATE.CHECKED)),
|
|
479
|
+
checkable=True)
|
|
480
|
+
self.pos_label = label(p, "", MUTED)
|
|
481
|
+
self.pos_label.set_width(84) # the same width playing or stopped
|
|
482
|
+
self.live_box = lv.obj(p)
|
|
483
|
+
self.live_box.set_flex_grow(1)
|
|
484
|
+
# Never narrower than a line of text: on a small screen it wraps to
|
|
485
|
+
# a row of its own instead.
|
|
486
|
+
self.live_box.set_style_min_width(min(220, self.W - 24), 0)
|
|
487
|
+
self.live_box.set_height(lv.SIZE_CONTENT)
|
|
488
|
+
self.live_box.set_style_bg_opa(0, 0)
|
|
489
|
+
self.live_box.set_style_border_width(0, 0)
|
|
490
|
+
self.live_box.set_style_pad_all(0, 0)
|
|
491
|
+
self.live_box.set_style_pad_row(0, 0)
|
|
492
|
+
self.live_box.set_flex_flow(lv.FLEX_FLOW.COLUMN)
|
|
493
|
+
self.live_box.remove_flag(lv.obj.FLAG.SCROLLABLE)
|
|
494
|
+
self.live_route = label(self.live_box, "", TEXT)
|
|
495
|
+
self.live_clock = label(self.live_box, "", MUTED)
|
|
496
|
+
self.lat_value = label(self.live_box, "", ACCENT)
|
|
497
|
+
for lb in (self.live_route, self.live_clock, self.lat_value):
|
|
498
|
+
lb.set_width(lv.pct(100))
|
|
499
|
+
# One line each, ending in dots, so the pedals keep their room.
|
|
500
|
+
lb.set_height(lb.get_style_text_font(0).line_height)
|
|
501
|
+
lb.set_long_mode(lv.label.LONG_MODE.DOTS)
|
|
502
|
+
show(self.live_box, False)
|
|
503
|
+
self.board_dd = dropdown(p, ["Boards"], self._board_picked, self.list_h)
|
|
504
|
+
self.board_dd.set_flex_grow(0)
|
|
505
|
+
self.board_dd.set_width(116)
|
|
506
|
+
self.board_dd.set_style_min_width(116, 0)
|
|
507
|
+
self.save_btn, _ = button(p, lv.SYMBOL.SAVE, self.btn_h, self._ask_name)
|
|
508
|
+
self.midi_btn, self.midi_text = button(
|
|
509
|
+
p, "MIDI", self.btn_h,
|
|
510
|
+
lambda: self.app.learn_switches(self.midi_btn.has_state(lv.STATE.CHECKED)),
|
|
511
|
+
checkable=True)
|
|
512
|
+
# The name a board is saved under, typed on any keyboard.
|
|
513
|
+
self.name_row = panel(self.scr)
|
|
514
|
+
self.name_row.set_style_pad_all(6, 0)
|
|
515
|
+
flow(self.name_row, wrap=False)
|
|
516
|
+
label(self.name_row, "Save as", MUTED)
|
|
517
|
+
self.name_field = lv.textarea(self.name_row)
|
|
518
|
+
self.name_field.set_one_line(True)
|
|
519
|
+
self.name_field.set_flex_grow(1)
|
|
520
|
+
self.name_field.set_style_text_font(kit.small, 0)
|
|
521
|
+
self.name_field.add_event_cb(lambda e: self._save_named(), lv.EVENT.READY, None)
|
|
522
|
+
try:
|
|
523
|
+
from appkit import keys
|
|
524
|
+
|
|
525
|
+
keys.attach(self.name_field)
|
|
526
|
+
except ImportError:
|
|
527
|
+
pass
|
|
528
|
+
button(self.name_row, "Save", self.btn_h, self._save_named)
|
|
529
|
+
button(self.name_row, "Cancel", self.btn_h, lambda: show(self.name_row, False))
|
|
530
|
+
show(self.name_row, False)
|
|
531
|
+
|
|
532
|
+
def show_midi(self, names, learned, learning):
|
|
533
|
+
"""The MIDI button: lit while it learns, and what the controller is."""
|
|
534
|
+
set_checked(self.midi_btn, learning)
|
|
535
|
+
if learning:
|
|
536
|
+
self.midi_text.set_text("Learning")
|
|
537
|
+
elif names:
|
|
538
|
+
self.midi_text.set_text("MIDI %d/4" % learned)
|
|
539
|
+
else:
|
|
540
|
+
self.midi_text.set_text("No MIDI")
|
|
541
|
+
|
|
542
|
+
def show_boards(self, names):
|
|
543
|
+
"""The boards menu: its title, then *names*."""
|
|
544
|
+
self._board_names = names
|
|
545
|
+
self.board_dd.set_options("\n".join(["Boards"] + names))
|
|
546
|
+
self.board_dd.set_selected(0)
|
|
547
|
+
|
|
548
|
+
def _board_picked(self, index):
|
|
549
|
+
self.board_dd.set_selected(0)
|
|
550
|
+
if index > 0:
|
|
551
|
+
self.app.load_board(index - 1)
|
|
552
|
+
|
|
553
|
+
def _ask_name(self):
|
|
554
|
+
self.name_field.set_text(self.app.board_name or "")
|
|
555
|
+
show(self.name_row, True)
|
|
556
|
+
|
|
557
|
+
def _save_named(self):
|
|
558
|
+
name = self.name_field.get_text().strip()
|
|
559
|
+
if not name:
|
|
560
|
+
return
|
|
561
|
+
show(self.name_row, False)
|
|
562
|
+
try:
|
|
563
|
+
from appkit import keys
|
|
564
|
+
|
|
565
|
+
keys.hide()
|
|
566
|
+
except ImportError:
|
|
567
|
+
pass
|
|
568
|
+
self.app.save_board(name)
|
|
569
|
+
|
|
570
|
+
def _clip_controls(self, on):
|
|
571
|
+
for o in (self.clip_dd, self.play_btn, self.loop_btn, self.pos_label):
|
|
572
|
+
show(o, on)
|
|
573
|
+
show(self.live_box, not on)
|
|
574
|
+
|
|
575
|
+
def show_live_button(self, on):
|
|
576
|
+
set_checked(self.live_btn, on)
|
|
577
|
+
|
|
578
|
+
def show_live(self, route, clock):
|
|
579
|
+
"""Where a live input comes from and goes, and whether the two ends
|
|
580
|
+
share a clock."""
|
|
581
|
+
self._clip_controls(False)
|
|
582
|
+
self.show_live_button(True)
|
|
583
|
+
self.live_route.set_text(route)
|
|
584
|
+
self.live_clock.set_text(clock)
|
|
585
|
+
self._clock_text = clock
|
|
586
|
+
self.lat_value.set_text("")
|
|
587
|
+
|
|
588
|
+
def show_clips(self):
|
|
589
|
+
self._clip_controls(True)
|
|
590
|
+
self.show_live_button(False)
|
|
591
|
+
|
|
592
|
+
def show_latency(self, total, held, periods, extra=""):
|
|
593
|
+
"""The latency figure: the software hold plus the device periods.
|
|
594
|
+
What the system's engine and the converters add beyond that isn't in
|
|
595
|
+
it, and the note says so."""
|
|
596
|
+
self.lat_value.set_text("%.0f ms: held %.0f + device periods %.0f; the system adds more"
|
|
597
|
+
% (total, held, periods))
|
|
598
|
+
if extra:
|
|
599
|
+
self.live_clock.set_text(self._clock_text + extra)
|
|
600
|
+
|
|
601
|
+
def show_playing(self, on):
|
|
602
|
+
txt = (lv.SYMBOL.STOP + " Stop") if on else (lv.SYMBOL.PLAY + " Play")
|
|
603
|
+
self.play_text.set_text(txt)
|
|
604
|
+
set_checked(self.play_btn, on)
|
|
605
|
+
|
|
606
|
+
def show_loop(self, on):
|
|
607
|
+
set_checked(self.loop_btn, on)
|
|
608
|
+
|
|
609
|
+
def show_position(self, text):
|
|
610
|
+
self.pos_label.set_text(text)
|
|
611
|
+
|
|
612
|
+
# -- the board -------------------------------------------------------------
|
|
613
|
+
|
|
614
|
+
def _board(self, h):
|
|
615
|
+
row = bare(self.scr)
|
|
616
|
+
row.set_size(lv.pct(100), h)
|
|
617
|
+
row.set_flex_flow(lv.FLEX_FLOW.ROW)
|
|
618
|
+
row.set_style_pad_column(8, 0)
|
|
619
|
+
self.slots = [PedalView(row, i, self.app.select, self.app.toggle)
|
|
620
|
+
for i in range(MAX_PEDALS)]
|
|
621
|
+
|
|
622
|
+
def show_board(self, pedals, selected):
|
|
623
|
+
"""Draw the board: *pedals* in their slots, the rest empty, and
|
|
624
|
+
*selected* outlined."""
|
|
625
|
+
for i, v in enumerate(self.slots):
|
|
626
|
+
v.selected = i == selected
|
|
627
|
+
if i < len(pedals):
|
|
628
|
+
v.show_pedal(pedals[i], self.knob_size)
|
|
629
|
+
else:
|
|
630
|
+
v.show_empty(i == len(pedals))
|
|
631
|
+
|
|
632
|
+
def show_pedal_state(self, index):
|
|
633
|
+
"""The pedal at *index* switched or turned: its light and knobs."""
|
|
634
|
+
if 0 <= index < len(self.slots):
|
|
635
|
+
self.slots[index].refresh()
|
|
636
|
+
|
|
637
|
+
# -- the editor ------------------------------------------------------------
|
|
638
|
+
|
|
639
|
+
def _editor(self):
|
|
640
|
+
p = panel(self.scr)
|
|
641
|
+
p.set_height(0)
|
|
642
|
+
p.set_flex_grow(1)
|
|
643
|
+
p.set_style_pad_all(8, 0)
|
|
644
|
+
p.set_style_min_height(self.btn_h + self.knob_size + 50, 0)
|
|
645
|
+
p.set_flex_flow(lv.FLEX_FLOW.COLUMN)
|
|
646
|
+
p.set_style_pad_row(6, 0)
|
|
647
|
+
self.editor = p
|
|
648
|
+
head = bare(p)
|
|
649
|
+
head.set_size(lv.pct(100), lv.SIZE_CONTENT)
|
|
650
|
+
flow(head, wrap=False)
|
|
651
|
+
self.ed_title = label(head, "", TEXT, kit.font)
|
|
652
|
+
self.patch_dd = dropdown(head, [""], self.app.set_patch, self.list_h)
|
|
653
|
+
self.left_btn, _ = button(head, lv.SYMBOL.LEFT, self.btn_h, lambda: self.app.move_selected(-1))
|
|
654
|
+
self.right_btn, _ = button(head, lv.SYMBOL.RIGHT, self.btn_h, lambda: self.app.move_selected(1))
|
|
655
|
+
self.change_btn, _ = button(head, "Change", self.btn_h, self.app.change_selected)
|
|
656
|
+
self.remove_btn, _ = button(head, lv.SYMBOL.CLOSE, self.btn_h, self.app.remove_selected)
|
|
657
|
+
self.all_btn, _ = button(
|
|
658
|
+
head, "Show all", self.btn_h,
|
|
659
|
+
lambda: self.app.set_show_all(self.all_btn.has_state(lv.STATE.CHECKED)),
|
|
660
|
+
checkable=True)
|
|
661
|
+
self.load_label = label(head, "", MUTED)
|
|
662
|
+
self.ed_head = head
|
|
663
|
+
grid = bare(p)
|
|
664
|
+
grid.set_width(lv.pct(100))
|
|
665
|
+
grid.set_height(0)
|
|
666
|
+
grid.set_flex_grow(1)
|
|
667
|
+
grid.add_flag(lv.obj.FLAG.SCROLLABLE)
|
|
668
|
+
grid.set_style_pad_column(8, 0)
|
|
669
|
+
grid.set_style_pad_row(6, 0)
|
|
670
|
+
grid.set_flex_flow(lv.FLEX_FLOW.ROW_WRAP)
|
|
671
|
+
self.grid = grid
|
|
672
|
+
|
|
673
|
+
def _pedal_controls(self, on):
|
|
674
|
+
for o in (self.patch_dd, self.left_btn, self.right_btn, self.change_btn,
|
|
675
|
+
self.remove_btn, self.load_label):
|
|
676
|
+
show(o, on)
|
|
677
|
+
show(self.all_btn, not on)
|
|
678
|
+
|
|
679
|
+
def show_editor(self, pedal):
|
|
680
|
+
"""Every knob of *pedal*, and its patches."""
|
|
681
|
+
st = styles.style(pedal.name, effects.category(pedal.name))
|
|
682
|
+
colour = accent_of(st)
|
|
683
|
+
self._pedal_controls(True)
|
|
684
|
+
self.ed_title.set_text(pedal.title)
|
|
685
|
+
self.ed_title.set_style_text_color(c(colour), 0)
|
|
686
|
+
if pedal.patch_names:
|
|
687
|
+
show(self.patch_dd, True)
|
|
688
|
+
self.patch_dd.set_options("\n".join(pedal.patch_names))
|
|
689
|
+
self.patch_dd.set_selected(pedal.patch or 0)
|
|
690
|
+
else:
|
|
691
|
+
show(self.patch_dd, False)
|
|
692
|
+
self.grid.clean()
|
|
693
|
+
self.grid.scroll_to_y(0, False)
|
|
694
|
+
self.grid.set_flex_align(lv.FLEX_ALIGN.START, lv.FLEX_ALIGN.CENTER, lv.FLEX_ALIGN.START)
|
|
695
|
+
self.knobs = {}
|
|
696
|
+
for d in pedal.parameters():
|
|
697
|
+
if d["mode"] == "TOGGLE":
|
|
698
|
+
k = Switch(self.grid, d, self.btn_h, self.app.turn, colour)
|
|
699
|
+
else:
|
|
700
|
+
k = Knob(self.grid, d, self.knob_size, self.app.turn, pedal.text, colour)
|
|
701
|
+
k.show(pedal.get(d["key"]))
|
|
702
|
+
self.knobs[d["label"]] = k
|
|
703
|
+
self.show_load(pedal)
|
|
704
|
+
|
|
705
|
+
def show_knobs(self, pedal):
|
|
706
|
+
"""Every knob of *pedal* where it now stands: after a patch."""
|
|
707
|
+
for d in pedal.parameters():
|
|
708
|
+
k = self.knobs.get(d["label"])
|
|
709
|
+
if k is not None:
|
|
710
|
+
k.show(pedal.get(d["key"]))
|
|
711
|
+
if pedal.patch is not None and pedal.patch_names:
|
|
712
|
+
self.patch_dd.set_selected(pedal.patch)
|
|
713
|
+
|
|
714
|
+
def show_load(self, pedal):
|
|
715
|
+
if pedal.load is None:
|
|
716
|
+
self.load_label.set_text("")
|
|
717
|
+
else:
|
|
718
|
+
self.load_label.set_text("%d%% of real time" % int(pedal.load * 100 + 0.5))
|
|
719
|
+
|
|
720
|
+
def show_picker(self, groups, show_all, replacing):
|
|
721
|
+
"""The pedals to choose from: *groups* is (group, [names]) pairs."""
|
|
722
|
+
self._pedal_controls(False)
|
|
723
|
+
self.ed_title.set_text("Change the pedal" if replacing else "Add a pedal")
|
|
724
|
+
self.ed_title.set_style_text_color(c(TEXT), 0)
|
|
725
|
+
set_checked(self.all_btn, show_all)
|
|
726
|
+
self.grid.clean()
|
|
727
|
+
self.grid.scroll_to_y(0, False)
|
|
728
|
+
self.grid.set_flex_align(lv.FLEX_ALIGN.START, lv.FLEX_ALIGN.CENTER, lv.FLEX_ALIGN.START)
|
|
729
|
+
self.knobs = {}
|
|
730
|
+
for group, names in groups:
|
|
731
|
+
head = label(self.grid, group.upper(), MUTED, kit.tiny)
|
|
732
|
+
head.set_width(lv.pct(100))
|
|
733
|
+
for name in names:
|
|
734
|
+
st = styles.style(name, effects.category(name))
|
|
735
|
+
b = lv.button(self.grid)
|
|
736
|
+
b.set_size(lv.SIZE_CONTENT, self.btn_h)
|
|
737
|
+
b.set_style_bg_color(c(st["body"]), 0)
|
|
738
|
+
b.set_style_border_width(1, 0)
|
|
739
|
+
b.set_style_border_color(c(st["trim"]), 0)
|
|
740
|
+
b.set_style_radius(6, 0)
|
|
741
|
+
b.set_style_shadow_width(0, 0)
|
|
742
|
+
lb = label(b, effects.display_name(name), st["text"])
|
|
743
|
+
lb.center()
|
|
744
|
+
b.add_event_cb(lambda e, n=name: self.app.add_pedal(n), lv.EVENT.CLICKED, None)
|
|
745
|
+
|
|
746
|
+
# -- master ----------------------------------------------------------------
|
|
747
|
+
|
|
748
|
+
def _footer(self):
|
|
749
|
+
p = panel(self.scr)
|
|
750
|
+
p.set_style_pad_all(6, 0)
|
|
751
|
+
flow(p)
|
|
752
|
+
self._meter(p)
|
|
753
|
+
label(p, "MASTER", MUTED)
|
|
754
|
+
s = lv.slider(p)
|
|
755
|
+
s.set_flex_grow(1)
|
|
756
|
+
s.set_style_min_width(100, 0)
|
|
757
|
+
s.set_range(0, 100)
|
|
758
|
+
s.set_style_bg_color(c(LINE), lv.PART.MAIN)
|
|
759
|
+
s.set_style_bg_color(c(ACCENT), lv.PART.INDICATOR)
|
|
760
|
+
s.set_style_bg_color(c(TEXT), lv.PART.KNOB)
|
|
761
|
+
self.master = s
|
|
762
|
+
self.master_label = label(p, "", TEXT)
|
|
763
|
+
s.add_event_cb(lambda e: self.app.set_master(s.get_value() / 100),
|
|
764
|
+
lv.EVENT.VALUE_CHANGED, None)
|
|
765
|
+
self.chain_label = label(p, "", MUTED)
|
|
766
|
+
self.out_label = label(p, "", MUTED)
|
|
767
|
+
|
|
768
|
+
def _meter(self, parent):
|
|
769
|
+
"""The level before the master, and a light for a clip."""
|
|
770
|
+
label(parent, "LEVEL", MUTED)
|
|
771
|
+
bar = lv.bar(parent)
|
|
772
|
+
bar.set_size(self.knob_size + 36, 10)
|
|
773
|
+
bar.set_range(0, STEPS)
|
|
774
|
+
bar.set_style_radius(3, lv.PART.MAIN)
|
|
775
|
+
bar.set_style_radius(3, lv.PART.INDICATOR)
|
|
776
|
+
bar.set_style_bg_color(c(LINE), lv.PART.MAIN)
|
|
777
|
+
bar.set_style_bg_opa(255, lv.PART.MAIN)
|
|
778
|
+
bar.set_style_bg_color(c(GOOD), lv.PART.INDICATOR)
|
|
779
|
+
self.level_bar = bar
|
|
780
|
+
light = lv.obj(parent)
|
|
781
|
+
light.set_size(lv.SIZE_CONTENT, lv.SIZE_CONTENT)
|
|
782
|
+
light.set_style_bg_color(c(LINE), 0)
|
|
783
|
+
light.set_style_bg_color(c(CLIP), lv.STATE.CHECKED)
|
|
784
|
+
light.set_style_border_width(0, 0)
|
|
785
|
+
light.set_style_radius(4, 0)
|
|
786
|
+
light.set_style_pad_hor(6, 0)
|
|
787
|
+
light.set_style_pad_ver(2, 0)
|
|
788
|
+
light.remove_flag(lv.obj.FLAG.SCROLLABLE)
|
|
789
|
+
light.remove_flag(lv.obj.FLAG.CLICKABLE)
|
|
790
|
+
self.clip_text = label(light, "CLIP", MUTED)
|
|
791
|
+
self.clip_light = light
|
|
792
|
+
|
|
793
|
+
def show_level(self, steps, clip):
|
|
794
|
+
"""The bar's lit steps, 0 to ``meter.STEPS``, and the clip light."""
|
|
795
|
+
self.level_bar.set_value(steps, False)
|
|
796
|
+
set_checked(self.clip_light, clip)
|
|
797
|
+
self.clip_text.set_style_text_color(c(TEXT if clip else MUTED), 0)
|
|
798
|
+
|
|
799
|
+
def show_master(self, level):
|
|
800
|
+
self.master.set_value(int(round(level * 100)), False)
|
|
801
|
+
self.master_label.set_text("%d%%" % int(round(level * 100)))
|
|
802
|
+
|
|
803
|
+
def show_chain_load(self, load, behind=None):
|
|
804
|
+
"""What the pedals that are on take together, and, when the pump has
|
|
805
|
+
measured it falling behind, how far."""
|
|
806
|
+
if behind is not None:
|
|
807
|
+
self.chain_label.set_text("Behind: %d%% of real time" % int(behind * 100))
|
|
808
|
+
self.chain_label.set_style_text_color(c(CLIP), 0)
|
|
809
|
+
elif load is None:
|
|
810
|
+
self.chain_label.set_text("")
|
|
811
|
+
else:
|
|
812
|
+
self.chain_label.set_text("Pedals %d%%" % int(load * 100 + 0.5))
|
|
813
|
+
self.chain_label.set_style_text_color(c(CLIP if load > 0.9 else MUTED), 0)
|
|
814
|
+
|
|
815
|
+
def show_status(self, text, good=False):
|
|
816
|
+
self.status_label.set_text(text)
|
|
817
|
+
self.status_label.set_style_text_color(c(GOOD if good else MUTED), 0)
|