Skip to content

fix: carry LED segment mask to GUI preview via FrameSent#180

Closed
kali-urs wants to merge 1 commit into
Lexonight1:mainfrom
kali-urs:fix/macos-led-segment-mask-preview
Closed

fix: carry LED segment mask to GUI preview via FrameSent#180
kali-urs wants to merge 1 commit into
Lexonight1:mainfrom
kali-urs:fix/macos-led-segment-mask-preview

Conversation

@kali-urs

Copy link
Copy Markdown

Problem

The GUI simulated LED segment display was showing all segments lit regardless of mode. This happened because FrameSent only carried display_colors but not the mask (on/off boolean list) computed by compute_mask(). For segment-display styles like TEMP_LINKED, LOAD_LINKED, etc., the preview would show all segments illuminated even though only specific segments should be lit.

Fix

  • Add mask: list field to FrameSent event (default empty, backward compatible)
  • Pass mask from RenderLed.execute() when publishing FrameSent
  • Wire mask through TRCCApp._on_bus_frame_sentLEDHandler.handle_frame
  • Add optional mask parameter to UCLedControl.set_led_colors()
  • Add UCScreenLED.set_mask() to update on/off state per tick
  • Check _is_on in _paint_led_rects() so masked-off segments stay dim (grey underlay only)

Files changed

  • src/trcc/core/events.py — add mask field
  • src/trcc/core/commands/led.py — publish mask with FrameSent
  • src/trcc/ui/gui/trcc_app.py — bridge mask from event
  • src/trcc/ui/gui/led_handler.py — extract and forward mask
  • src/trcc/ui/gui/uc_led_control.py — accept optional mask
  • src/trcc/ui/gui/uc_screen_led.py — set_mask() + render check

Testing

Tested on macOS 26.6 (Intel x86_64) with PA120 Digital (0416:8001):

  • TEMP_LINKED mode now shows only temperature-digit segments lit
  • Other modes (COLORFUL, BREATHING, etc.) unaffected
  • No regression on LCD FrameSent path (mask default empty)

The GUI simulated LED display was showing all segments lit because
FrameSent only carried display_colors but not the on/off mask computed
by compute_mask().  This meant the preview never knew which segments
should actually be lit for segment-display styles (TEMP_LINKED, etc.).

- Add  field to FrameSent event (list of bool, default empty)
- Pass mask from RenderLed.execute() when publishing FrameSent
- Wire mask through TRCCApp._on_bus_frame_sent → LEDHandler.handle_frame
- Add UCLedControl.set_led_colors() optional mask parameter
- Add UCScreenLED.set_mask() to update on/off state per tick
- Check _is_on in _paint_led_rects() so masked-off segments stay dim

Fixes the GUI preview on macOS where all segments appeared lit
regardless of the actual hardware mask.
@Lexonight1

Copy link
Copy Markdown
Owner

Thank you for this, and for the clear diagnosis — you're exactly right that the segment preview was lighting every segment because the on/off mask wasn't reaching it. Nicely traced.

It turns out this is already fixed in main (shipped in v9.7.1) via a slightly different route: rather than adding a mask field to FrameSent and threading it through the handler + UCScreenLED, RenderLed now bakes the mask into the display_colors it publishes — masked-off segments go out as (0,0,0), so the preview shows the lit digits instead of "888". Same outcome, fewer moving parts.

Since the preview already honors that, I'll close this as already-fixed — but your analysis was spot-on and I really appreciate you taking the time to write it up and PR it. If you're on v9.7.1 and any segment style's preview still looks wrong, please drop a note and I'll dig in.


If this project helps you, consider buying me a beer 🍺 or Ko-fi

@Lexonight1 Lexonight1 closed this Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants