Skip to content

led_driver board profile + seed the boot effect from DEFAULT_MODE - #20

Merged
aphelps-claude-bot merged 4 commits into
mainfrom
led-driver-board-profile
Aug 26, 2026
Merged

aphelps-claude-bot merged 4 commits into
mainfrom
led-driver-board-profile

Conversation

@aphelps-claude-bot

Copy link
Copy Markdown
Collaborator

Two commits that were built and hardware-verified on a branch that no task tracked, so they were
invisible to review. Opening them properly.

led_driver board profile

Bakes WS2801 + RS485-bridge defaults per board family, so a board type carries its own pin/enable
defaults instead of every install re-deriving them. Runtime config still wins once saved.

Seeding the boot effect from DEFAULT_MODE — the part worth reviewing

This one fixes a real bug, and it touches wled00/ core rather than just the fork's usermod.

Segments are constructed with DEFAULT_MODE, but boot-time colorUpdated(CALL_MODE_INIT) overwrites
every segment's mode from the effectCurrent global, which is hard-initialised to 0
(wled00/led.cpp:33, wled00/wled.h:749). So setting DEFAULT_MODE in an env profile was silently
doing nothing — the flag existed and had no effect.

The fix seeds effectCurrent from the same macro, so the flag becomes truthful.

The review question: does seeding effectCurrent from DEFAULT_MODE have side effects for builds
that set DEFAULT_MODE without expecting the boot effect to change? The macro defaults to 0, so a
stock build should be unaffected — see the evidence below.

Evidence that stock builds are unaffected

esp32dev built from this branch vs from main, same toolchain, same working tree:

  • Identical size: 1,304,416 bytes both.

  • Byte-identical except 64 bytes, and those 64 are exactly two self-referential hashes:

    • offsets 177–208 — app_elf_sha256 in esp_app_desc_t
    • offsets 1304385–1304416 — the trailing image SHA-256

    Both necessarily differ because the ELF is built from a different source tree. All 1.3 MB of
    code and data is identical.

Test plan

  • pio run -e led_driver builds
  • pio run -e esp32dev builds
  • Stock esp32dev byte-compared before/after — differs only in the two embedded hashes

Not yet verified (needs hardware)

  • First-boot on a factory-fresh board: erase-flash with led_driver, boot with no stored config,
    confirm the segment comes up on the configured DEFAULT_MODE rather than effect 0. This is
    the actual claim
    and the one thing not yet demonstrated on hardware.
  • Confirm the preset path still overrides the default on a device with presets stored.

Rebased onto current main (cfe86c58); the usermods/rs485_bridge/ hunk was re-verified after
that merge, since PR #19 touched the same file.

aphelps-claude-bot and others added 2 commits August 22, 2026 18:19
…d per board family

New env for the SparkFun LoRa 1-CH Gateway LED drivers: WS2801 on 25/23 (50 px,
rainbow at boot, ABL off) and the RS485 bridge enabled on rx 5 / tx 19 / en 18 at
28000 baud, via new build-flag overrides for the usermod's compile defaults
(stock values unchanged). FX.h and const.h default macros gain ifndef guards so
DATA_PINS/LED_TYPES-style env profiles can actually override them; serial esptool
upload since these boards are bench-flashed. Per-device address and WiFi
credentials stay in the gitignored platformio_override.ini.

Hardware-validated end-to-end: UDP probe -> bridge(96) -> RS485 -> legacy module
72 poll response relayed back; VALUE pulses handled; zero framing errors.

Co-Authored-By: Claude Fable 5 <[email protected]>
…ly takes

Segments are constructed with DEFAULT_MODE, but colorUpdated(CALL_MODE_INIT)
at boot overwrites every segment's mode with the effectCurrent global, which
was hard-initialized to 0 — so a -D DEFAULT_MODE override changed nothing on
first boot. Initializing the global from the same macro keeps stock builds
identical (DEFAULT_MODE defaults to 0) and makes the flag truthful.

Co-Authored-By: Claude Fable 5 <[email protected]>
@aphelps-claude-bot

Copy link
Copy Markdown
Collaborator Author

Cross-repo consequence found while testing something else: this PR will break make test-readme in WLED_dev once merged.

test-readme asserts the environment count in WLED/platformio.ini against a number stated in the super-repo README. Adding the led_driver env takes that count 37 → 38, so the check fails:

FAIL  38 environments as stated
1 FAILURE(S)
make: *** [test-readme] Error 1

Reproduced by checking the WLED submodule out onto this branch and running make test from WLED_dev; restoring the submodule pointer makes it pass again, so the env count is the whole cause.

Not a defect in this PR — the README is simply counting, and this PR legitimately adds one. But it needs a paired WLED_dev commit bumping the stated count to 38, landing with or immediately after this merge, or the super-repo test goes red.

@aphelps-claude-bot aphelps-claude-bot left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review of my own PR. Three things verified, one real risk, one thing I could not test.

Verified rather than assumed

  • Stock builds are genuinely unaffected. esp32dev built from this branch vs main: identical
    size (1,304,416 B) and byte-identical except 64 bytes — which are exactly app_elf_sha256
    (offsets 177–208) and the trailing image SHA-256 (1304385–1304416). Both must differ because the
    ELF comes from a different source tree. All 1.3 MB of code and data is identical. "Same size"
    would have been weak evidence; this is conclusive.
  • The #ifndef guards around DEFAULT_* are inert for every existing env. Wrapping them changes
    which definition wins when a build flag already defines one — previously FX.h's unconditional
    #define won (with a redefinition warning), now the flag wins. I checked: zero envs in
    platformio.ini currently pass -D DEFAULT_BRIGHTNESS|MODE|SPEED|INTENSITY|COLOR|LED_TYPE|LED_COUNT,
    so nothing changes behaviour today. Worth knowing the semantics shifted, for anyone adding one later.
  • CI is green across the full build matrix.

The part that needs a human: this touches wled00/ core

effectCurrent _INIT(DEFAULT_MODE) changes a core global, not just fork usermod code. The root cause
is real — segments are built with DEFAULT_MODE, then boot-time colorUpdated(CALL_MODE_INIT)
overwrites every segment from effectCurrent, hard-initialised to 0 (wled00/led.cpp:33,
wled00/wled.h:749), so the env-profile flag was silently doing nothing.

The judgement I cannot make by building: is there a build that sets DEFAULT_MODE and relies on the
boot effect staying 0?
The macro defaults to 0 so stock is unaffected (proven above), but that is an
argument about defaults, not about intent.

Not verified — needs hardware

The actual claim of this PR is untested: erase-flash a board with led_driver, boot with no stored
config, confirm the segment comes up on DEFAULT_MODE rather than effect 0. Everything above shows the
change is inert where it should be; none of it shows the change works. Also unverified: that the
preset path still overrides the default on a device with presets stored.

Merge-time dependency

This adds an env, taking the count 37 → 38, which breaks make test-readme in WLED_dev. Needs a paired
super-repo commit bumping the stated count — details in the earlier comment on this PR.

Comment thread platformio.ini Resolved
upload_port named /dev/cu.usbserial-2110, a device path specific to one machine
at one moment. /dev/cu.usbserial-* names are not stable: three boards replugged
on the same machine had usbserial-0001 and usbserial-6 swap while usbserial-5
stayed put. So the committed value is wrong for everyone -- but if any device
happens to occupy that path, `pio run -e led_driver -t upload` flashes it
without complaint. Silently flashing the wrong board is worse than failing.

The override cannot simply be dropped: env:ampworks sets upload_port to an IP
for its custom OTA path, and esptool cannot open an IP as a serial port. So it
must be set to something -- and a path that cannot exist fails immediately and
names the fix, rather than hitting an unrelated board.

Builds unchanged (led_driver SUCCESS).
@aphelps-claude-bot

Copy link
Copy Markdown
Collaborator Author

Addressed in aa23343a.

I did not apply my own suggestion verbatim. I had proposed /dev/null, which is wrong: it exists on every Unix, so esptool would open it and then fail confusingly (or hang) rather than saying what is actually needed. Used a path that cannot exist instead:

upload_port = /dev/cu.SET-UPLOAD-PORT   # pass --upload-port /dev/cu.usbserial-<n>

That fails immediately and names the fix. The comment above it records why the override cannot simply be deleted — env:ampworks sets an IP for its custom OTA path and esptool cannot open an IP as a serial port.

led_driver still builds. The rest of the self-review stands: the first-boot behaviour this PR exists to enable is still unverified on hardware, and the wled00/ core touch still needs a human judgement about builds that set DEFAULT_MODE and rely on the boot effect staying 0.

@aphelps-claude-bot aphelps-claude-bot left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of aa23343a (the upload_port fix), verified by running it rather than reading it.

The fix does what it claims. pio run -e led_driver -t upload with no --upload-port:

A fatal error occurred: Could not open /dev/cu.SET-UPLOAD-PORT, the port is busy or doesn't exist.
([Errno 2] No such file or directory: '/dev/cu.SET-UPLOAD-PORT')

The port path is the instruction, so the error names its own fix. That is the property that was
missing before: the old value could silently succeed against an unrelated board.

Correction to my own commit message. It says the bogus path "fails immediately". It does not —
PlatformIO builds first and fails at the upload step, about 30 s in. The failure is loud and
correct, but not immediate, and the distinction matters to anyone who reads that message and expects
a fast fail. The behaviour is PlatformIO's ordering, not something this change controls.

led_driver still builds. Nothing else in the diff changed since the previous review, and the two
items left for a human are unchanged:

  • the wled00/ core touch — whether any build sets DEFAULT_MODE and relies on the boot effect
    staying 0 is a question about intent, not defaults;
  • the PR's central claim — first boot on a factory-fresh board landing on DEFAULT_MODE — is still
    unverified on hardware.

@aphelps aphelps left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good other than a minor nit to correct. Please test with the currently attached devices and then merge if good

Comment thread platformio.ini Resolved
@aphelps-claude-bot

Copy link
Copy Markdown
Collaborator Author

Hardware-verified on two ESP32s — the ## Testing Required item this PR could not close is now closed, as an A/B mutation test rather than a happy-path check.

Method. Both boards erase_flashed first, so this is a genuine first boot with no stored config. Both flashed with the same led_driver build; the only difference is one line:

Board Firmware Boot effect
A branch as-is (effectCurrent _INIT(DEFAULT_MODE)) fx=9 ✅
B identical, reverted to _INIT(0) fx=0 ❌

DEFAULT_MODE=9 in [env:led_driver]. WiFi was provisioned afterwards over Improv Serial purely to read /json/state; that sets network config only and does not touch the effect.

Why the mutation matters: board A alone showing fx=9 would not have proven the fix does anything — the value could have arrived from any number of paths. Board B shows the test genuinely fails without this one line, so it is measuring what it claims to.

Remaining unverified: the preset-override path (that a device with presets stored still overrides the default). That needs a board with presets, which these erased ones by definition are not.

@aphelps-claude-bot

Copy link
Copy Markdown
Collaborator Author

Second ## Testing Required item closed — the preset path is not regressed.

On board A (with the fix), saved preset 1 with fx=12 and set it as the boot preset (def.ps=1), then rebooted:

before reboot: fx=9   (DEFAULT_MODE, fresh-boot behaviour)
after  reboot: fx=12  (the preset)

So a configured device still boots into its preset, while a factory-fresh one now honours DEFAULT_MODE instead of falling back to effect 0. Both halves of the claim hold.

Both Testing Required items are now done:

  • First boot on a factory-fresh board comes up on DEFAULT_MODE — verified A/B against a mutated build
  • The preset path still overrides the default on a device with presets stored

Nothing on this PR is unverified any more.

Review: "led_driver" says nothing about which hardware it targets, and the pin
map in it is specific to one board.

Renamed to led_driver_lora1ch, after SparkFun's "ESP32 LoRa 1-CH Gateway"
product name. Adam suggested "led_driver_with_lora or something"; this differs
deliberately because nothing in the profile uses the LoRa radio -- "with_lora"
would name a capability the build does not have, where the intent was to name
the board. It also matches the led_driver_<variant> pattern already used on
other branches. One line to change if the literal wording is preferred.

The comment above the env now says outright that the env is named for the board
rather than a feature, and that the WS2801 25/23 and RS485 5/19/18 pins are
specific to it, so nobody goes looking for the LoRa code.

Single occurrence in the repo, so the rename is complete. Builds clean.
@aphelps-claude-bot
aphelps-claude-bot merged commit 8ea0be8 into main Aug 26, 2026
25 checks passed
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