Skip to content

LED strip control and colour picker for Bengle - #3

Open
ChampionDesigns wants to merge 1 commit into
ben/detect-protocolfrom
ben/led-strip
Open

ChampionDesigns wants to merge 1 commit into
ben/detect-protocolfrom
ben/led-strip

Conversation

@ChampionDesigns

Copy link
Copy Markdown
Owner

Filed inside the fork so the diff shows only this PR's own changes.
It will be re-filed against decentespresso/de1app once its base has merged there.

707 insertions, 4 files.

Summary

A Bengle has two addressable LED strips. The firmware stores an awake and a sleep colour
for each and switches between them itself on sleep and wake, so the app needs no
state-change listener and re-pushes nothing when the machine sleeps.

register address kind
FrontLEDAwake 0x00803898 persistent
RearLEDAwake 0x0080389C persistent
FrontLEDSleep 0x008038A0 persistent
RearLEDSleep 0x008038A4 persistent
FrontLEDColor 0x00803890 transient, live preview
RearLEDColor 0x00803894 transient, live preview

Each holds a 24-bit 0xRRGGBB value. decentespresso/decaid agrees on the four
persistent addresses and on the colour depth; it drives only those four, because it has no
picker page.

Changes

de1_comms.tcl — a ::led namespace: hex, integer and HSV conversion; a transient
write_strip with a per-strip cache so an unchanged colour does not re-queue a write; a
persistent write_stored; push_all_stored; and _validate_hex.

The write cache is cleared on disconnect. If the machine is power-cycled while the tablet
is away its registers may come back different, and a stale cache would suppress the write
that corrects them.

machine.tcl — five settings: four stored colours, defaulting to #191919 awake and
#000000 sleep, plus led_target_mode.

bluetooth.tcl — ::led::push_all_stored on connect, after the state reads.

skins/default/de1_skin_settings.tcl — a Lighting card on settings_3 and the
led_picker page: a hue/saturation wheel, brightness slider, preset swatches,
front/rear/both targeting, awake/sleep bank selection, and debounced commit and save.

The Lighting card and the Firmware card

The Lighting card sits at x=1934, where the Firmware card's button otherwise reaches 2540,
so the Firmware card is narrowed. That narrowing is gated on is_bengle_model, the same
as the card itself.
An earlier draft narrowed it unconditionally, which on a DE1 left a
full-width purple card with a half-width button and dead space beside it.

Known issues, not fixed here

Raised by a review of the series, recorded rather than fixed. Neither has been reproduced
on hardware.

  • is_bengle_model is evaluated at skin-load time. On a first-ever connect the model
    MMR has not returned, so the predicate is false and the led_picker page may never be
    registered. If so, the Lighting card would open a page that does not exist. This affects
    the machine-autonomy PR the same way and probably needs one fix covering both.
  • The _last_written dedupe cache is not invalidated by push_all_stored. The
    firmware repaints the live registers from the stored pair, so a later preview of the same
    hex would be skipped and the strips would not change.
  • remove_matching_ble_queue_entries {^MMR ...} never matches, because queue comments
    are the bare note. This mirrors the existing upstream calls, so the new dedupes are inert
    rather than newly broken.

Impact on a DE1

Every write proc tests is_bengle_model and returns early. The card, the page and the
narrowed geometry are inside the same gate. The five settings are inert.

Test plan

  • Open settings_3 on a DE1. Confirm the Firmware card looks as it does today and no
    Lighting card appears.
  • TODO (Ben): set an awake and a sleep colour on a Bengle. Confirm both strips change
    and the machine switches to the sleep pair on its own.
  • TODO (Ben): confirm the Lighting card opens the picker on a first-ever connect —
    this is the known issue above.
  • TODO (Ben): drag the wheel; confirm the strips follow live.
  • TODO (Ben): power-cycle the machine mid-session and reconnect; confirm the colours
    are re-pushed rather than suppressed by the cache.

Testing

Manual verification only, plus a check that all 57 ::led references resolve. There is no
automated test coverage for these Tcl paths in the repo.

A Bengle has two addressable LED strips. The firmware stores an awake and
a sleep colour for each and switches between them itself on sleep and
wake, so the app needs no state-change listener and re-pushes nothing when
the machine sleeps.

  FrontLEDAwake 0x00803898   RearLEDAwake 0x0080389C
  FrontLEDSleep 0x008038A0   RearLEDSleep 0x008038A4
  FrontLEDColor 0x00803890   RearLEDColor 0x00803894

The first four are persistent and carry the colours. The last two are
transient and exist only for the picker's live preview, so the strips
follow the control without writing flash on every frame. Each holds a
24-bit 0xRRGGBB value, matching decentespresso/decaid.

Adds a ::led namespace (hex/int/HSV conversion, transient and persistent
writes, validation), five settings, a push of all four stored colours on
connect, a Lighting card on settings_3, and the picker page itself.

The transient write cache is cleared on disconnect: if the machine is
power-cycled while the tablet is away its registers may come back
different, and a stale cache would suppress the write that corrects them.

The Lighting card sits where the Firmware card's button otherwise reaches,
so the Firmware card is narrowed. That narrowing is gated on
is_bengle_model, the same as the card itself -- ungated it would leave a
DE1 with a full-width card and a half-width button.

Every write proc returns early on a DE1. All 57 ::led references resolve.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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