fix: Restore other pads when cycle effect tag is removed
When a tag with a cycle effect is removed, other pads were left frozen in whatever color the cycle left them at. Now: - Pads with active tags get their lighting theme re-applied - Pads with no tags get turned off properly
This commit is contained in:
@@ -311,17 +311,36 @@ def portal_mode(server_ip, port):
|
|||||||
def on_tag_remove(tag: TagInfo):
|
def on_tag_remove(tag: TagInfo):
|
||||||
print(f"[-] TAG REMOVED from {tag.pad.name} pad")
|
print(f"[-] TAG REMOVED from {tag.pad.name} pad")
|
||||||
|
|
||||||
|
# Check if removed tag had a cycle effect (affects all pads)
|
||||||
|
removed_key = active_pads.get(tag.pad.value)
|
||||||
|
was_cycle = False
|
||||||
|
if removed_key is not None:
|
||||||
|
config = TAG_COLORS.get(removed_key, DEFAULT_TAG_COLOR)
|
||||||
|
was_cycle = config.get('effect', 'solid') == 'cycle'
|
||||||
|
|
||||||
# Remove from active tracking
|
# Remove from active tracking
|
||||||
if tag.pad.value in active_pads:
|
if tag.pad.value in active_pads:
|
||||||
del active_pads[tag.pad.value]
|
del active_pads[tag.pad.value]
|
||||||
|
|
||||||
# Stop any effects and turn off ONLY this pad's LED (not all pads!)
|
|
||||||
if reader:
|
if reader:
|
||||||
# Stop cycle effect if running (it uses all pads)
|
# Stop cycle effect if running (it uses all pads)
|
||||||
reader.stop_cycle_effect()
|
reader.stop_cycle_effect()
|
||||||
# Stop individual pad effect and turn off
|
# Stop individual pad effect and turn off the removed pad
|
||||||
reader.stop_effect(tag.pad)
|
reader.stop_effect(tag.pad)
|
||||||
reader.set_pad_color(tag.pad, COLORS['OFF'])
|
reader.set_pad_color(tag.pad, COLORS['OFF'])
|
||||||
|
|
||||||
|
# If a cycle effect was running, restore all other pads
|
||||||
|
if was_cycle:
|
||||||
|
for pad_enum in [Pad.CENTER, Pad.LEFT, Pad.RIGHT]:
|
||||||
|
if pad_enum == tag.pad:
|
||||||
|
continue # Already handled above
|
||||||
|
if pad_enum.value in active_pads:
|
||||||
|
# Pad has an active tag - re-apply its theme
|
||||||
|
apply_tag_color(pad_enum, active_pads[pad_enum.value])
|
||||||
|
else:
|
||||||
|
# No tag on this pad - turn it off
|
||||||
|
reader.stop_effect(pad_enum)
|
||||||
|
reader.set_pad_color(pad_enum, COLORS['OFF'])
|
||||||
|
|
||||||
def on_connect():
|
def on_connect():
|
||||||
print("✓ Portal connected and initialized")
|
print("✓ Portal connected and initialized")
|
||||||
|
|||||||
Reference in New Issue
Block a user