Skip to content

Commit 681577f

Browse files
authored
Make mirrored back LEDs mirror the pattern live (#247)
Prior to this PR, the back LED was set to the front LED/pattern value at the moment of insertion, rather than live animating along with the current pattern.
1 parent f111888 commit 681577f

File tree

1 file changed

+17
-6
lines changed
  • modules/system/hexpansion

1 file changed

+17
-6
lines changed

modules/system/hexpansion/app.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@
2929
import settings
3030

3131

32+
active_back_leds = [False] * 6
33+
34+
3235
def Hexspansion_inserted(epin):
3336
for i, nPin in enumerate(HexpansionManagerApp.hexpansion_pins):
3437
if nPin is epin:
35-
if settings.get("pattern_mirror_hexpansions", False):
36-
tildagonos.leds[13 + i] = tildagonos.leds[1 + (i * 2)]
37-
else:
38+
if not settings.get("pattern_mirror_hexpansions", False):
3839
tildagonos.leds[13 + i] = led_colours[i]
40+
active_back_leds[i] = True
3941
eventbus.emit(HexpansionInsertionEvent(port=i + 1))
4042
tildagonos.leds.write()
4143

@@ -44,6 +46,7 @@ def Hexspansion_removed(epin):
4446
for i, nPin in enumerate(HexpansionManagerApp.hexpansion_pins):
4547
if nPin is epin:
4648
tildagonos.leds[13 + i] = (0, 0, 0)
49+
active_back_leds[i] = False
4750
eventbus.emit(HexpansionRemovalEvent(port=i + 1))
4851
tildagonos.leds.write()
4952

@@ -77,10 +80,9 @@ def __init__(self, autolaunch=True):
7780
pin.irq(handler=Hexspansion_inserted, trigger=pin.IRQ_FALLING)
7881
pin.irq(handler=Hexspansion_removed, trigger=pin.IRQ_RISING)
7982
if not pin.value():
80-
if settings.get("pattern_mirror_hexpansions", False):
81-
tildagonos.leds[13 + i] = tildagonos.leds[1 + (i * 2)]
82-
else:
83+
if not settings.get("pattern_mirror_hexpansions", False):
8384
tildagonos.leds[13 + i] = led_colours[i]
85+
active_back_leds[i] = True
8486
eventbus.emit(HexpansionInsertionEvent(port=i + 1))
8587
tildagonos.leds.write()
8688

@@ -111,6 +113,15 @@ def close():
111113
eventbus.emit(RequestForegroundPushEvent(self))
112114
return True
113115

116+
def background_update(self, delta):
117+
if settings.get("pattern_mirror_hexpansions", False):
118+
for i in range(0, 6):
119+
if active_back_leds[i]:
120+
tildagonos.leds[13 + i] = tildagonos.leds[1 + (i * 2)]
121+
else:
122+
tildagonos.leds[13 + i] = (0, 0, 0)
123+
tildagonos.leds.write()
124+
114125
def draw(self, ctx):
115126
if self.format_dialog is not None:
116127
self.format_dialog.draw(ctx)

0 commit comments

Comments
 (0)