Repository navigation
port AMPWorks to WLED 16.0.1 (effects, usermods, HSPI, envs) - #8
Conversation
aphelps-claude-bot
left a comment
There was a problem hiding this comment.
Self-review: AMPWorks stack → WLED 16.0.1
Verified the port against the actual tree (branch upgrade-wled-16-0-1, base 29b389df = 16.0.1). The port is clean — no correctness blockers found. Detail on the review priorities:
1. fastled_compat.h shim — correct. random8/random16 → hw_random8/hw_random16, whose 16.x overloads are exactly (), (uint32_t), (uint32_t,uint32_t) (fcn_declare.h:488-493). Every call site matches an overload: random8(), random8(100), random8(MPR121::MAX_SENSORS), random8(150,210), random16(SEGMENT.width()). beatsin8→beatsin8_t(bpm,lo,hi,timebase=0,phase=0) (fcn_declare.h:461); the sole call beatsin8(30,80,220) binds correctly. No pre-existing beatsin8/random8 symbol in 16.x to collide with the macro. scale8/qadd8/qsub8 resolve to fastled_slim (via colors.h). The shim is genuinely required — fastled_slim provides the color helpers but not map8/sqrt16/random*/beatsin8, and core 16.x migrated its own call sites to the hw_random8/beatsin8_t natives. There is no cleaner in-tree path without editing every effect call site; the macro/shim approach keeps effect code untouched as the owner wanted.
2. void effect conversion — complete. All 7 mode_* are void mode_*(void); grep for return FRAMETIME / bare value returns in ampworks.cpp is empty. Nothing missed.
3. MPR121 ODR fix — sound. _name/_enabled defs moved to usermod_mpr121.cpp; the header is pure-inline, so ampworks.cpp / usermod_sensor_sync.cpp can include it without multiple-definition. The three REGISTER_USERMOD instances (ampworks_usermod, sensor_sync_usermod, mpr121_usermod) have distinct identifiers, so the um_##x array members don't collide.
4. Usermod IDs — no collision. const.h: 55=DEEP_SLEEP, 56=RF433, 57=BRIGHTNESS_FOLLOW_SUN, 58=USER_FX (59 free), MPR121=60, SENSOR_SYNC=61. No hardcoded 55/56 remain; all references use the USERMOD_ID_* symbols.
5. Runtime layout — correct. The audioreactive um_data->u_data[] indices used by the effects ([0]=volumeSmth float, [1]=volumeRaw int16, [2]=fftResult uint8_t*, [3]=samplePeak uint8_t) match audio_reactive.cpp:1359-1365 in 16.x exactly. Touch Grid tail math (180 - t*(140/tail)) bottoms out at 40 for all tail∈[1,5] — no underflow.
Minor notes (non-blocking)
- Self-registration
.cppfiles are not#ifdef-guarded by theirUSERMOD_*defines (ampworks.cpp / usermod_sensor_sync.cpp / usermod_mpr121.cpp). This is correct for 16.x's folder-basedcustom_usermodsmechanism (folder membership, not the define, controls compilation), and both shipped envs pass all three-D USERMOD_*. But note the define and the folder-inclusion are now two independent switches: includingampworksincustom_usermodswithout-D USERMOD_SENSOR_SYNCwould still compile+self-register SensorSync while the effects'#ifdef USERMOD_SENSOR_SYNCremote-drain blocks compile out — a latent inconsistency, harmless for the current envs. - See inline notes on
fastled_compat.h(map8 robustness) andampworks.h(getId).
d24062e to
bc022fb
Compare
aphelps
left a comment
There was a problem hiding this comment.
Can more tests be added to cover the code in ampworks and mpr121? I'd like my code additions to come as close to full coverage as possible
aphelps-claude-bot
left a comment
There was a problem hiding this comment.
Great question. Here's a concrete plan for what's feasible:
What we have: tests/sensor_sync_test.cpp covers sensor_sync_protocol.h — the dependency-free wire protocol (header serialization, dispatch, magic/version rejection). It builds with plain c++ -std=c++11, no Arduino or WLED headers.
What we can add for ampworks.cpp (effects):
The effect functions (mode_amp_ai, mode_amp_moving_sin, etc.) use SEGMENT, SEGENV, strip.now, and SEGLEN — but these are all just struct fields accessed through macros. A thin stub file can define them as plain C++ globals:
// stub: segment struct with pixel array, SEGLEN, SEGCOLOR, SEGMENT.speed/custom1
// stub: strip.now as a uint32_t
// then: #include "../ampworks.cpp"That lets us call the effect function directly and assert pixel output. Good first target: mode_amp_ai with SEGLEN=9, spacing=3, SEGMENT.speed=128 — the output pattern (every 3rd pixel colored, offset by SEGENV.aux0) is fully deterministic at a fixed strip.now.
What we can add for mpr121:
UsermodMPR121 is a thin wrapper over a MPR121* pointer. Three things are testable without I2C hardware:
- Timing gate in
loop()— stubmillis()and verify reads happen at the configuredupdateHz - IRQ-vs-polling mode — with
irqPin < 0, verifyloop()setsmpr121->triggered = truebefore callingreadTouchInputs() - Wrapper methods — inject a mock MPR121 with known
touched()/getFiltered()return values; verify the wrappers pass through correctly (and return 0/false whensensorFound = false)
The MPR121 library class is header-defined, so we can subclass it in a stub and inject it via the private mpr121 pointer.
Proposed subtask: Add tests/ampworks_effects_test.cpp (effect pixel pattern tests) and tests/mpr121_usermod_test.cpp (loop timing + wrapper method tests), both building with the same c++ -std=c++11 approach as the existing test. I'd add this as a subtask to the upgrade plan.
aphelps-claude-bot
left a comment
There was a problem hiding this comment.
CI fix — mpr121 now header-only (pushed 20d34a8)
Root cause of the usermods env failure: the glob CI picks up every folder with a library.json and then validate_modules.py requires ≥1 symbol from each in the linked ELF. With mpr121/library.json present, it expected mpr121 symbols — but <MPR121.h> is in ../ArduinoLibs (absent from the fork's standalone CI), so the build couldn't link them.
What changed:
- Deleted
usermods/mpr121/library.jsonandusermods/mpr121/usermod_mpr121.cpp— glob CI no longer discovers mpr121 as a library - Moved
_name/_enableddefinitions +REGISTER_USERMODintoampworks.cpp(the sole TU that includes the header under#ifdef USERMOD_MPR121) — keeps ODR clean - Updated the header comment to reflect the new arrangement
This mirrors the 0.15.3 pattern where the usermod was registered from usermods_list.cpp. The ampworks and apa102_mpr121 envs are unaffected — they define USERMOD_MPR121 and supply the lib path.
aphelps-claude-bot
left a comment
There was a problem hiding this comment.
Re-review: two follow-up commits (f0d1a80, 20d34a8) — both look correct.
f0d1a80 — → : Correct fix. (=2) conflicts with the stock example usermod; is the right sentinel when no usermod-manager lookup is needed.
20d34a8 — mpr121 header-only / CI fix: Deleting correctly removes the folder from the usermods-glob CI scope. Moving / definitions and into under the existing block is sound: (via ) makes and available before that block, and is already included in the same , so the class definition is visible at the point of the static-member definitions. No ODR risk — no other TU includes the header under . CI is now fully green (30/30). ✅
aphelps-claude-bot
left a comment
There was a problem hiding this comment.
Overall the CI-fix approach — header-only mpr121, definitions and REGISTER_USERMOD moved to ampworks.cpp — is clean and mirrors the 0.15.3 pattern. Two correctness items worth resolving before merge, plus one include-order fragility:
Include order: usermod_mpr121.h is included in ampworks.cpp before colors.h/fastled_compat.h. This is safe today (the touch header doesn't call random8/map8), but silently breaks if the MPR121 usermod is ever extended with those helpers. Moving both compat #includes to before the usermod #ifdef blocks would be more robust.
| # ArduinoLibs (MPR121/Debug) vendored in the parent WLED_dev repo (../ArduinoLibs). | ||
| [env:ampworks] | ||
| extends = env:esp32dev | ||
| custom_usermods = audioreactive ampworks mpr121 |
There was a problem hiding this comment.
mpr121 is still listed in custom_usermods but its library.json was deleted to fix the CI 'No symbols' error. WLED's load_usermods.py behaviour for entries without a backing library.json is implementation-dependent; listing a name with no library is at minimum confusing and potentially fragile on future WLED upgrades. Since MPR121 registration now happens inside ampworks.cpp under #ifdef USERMOD_MPR121, the entry is redundant — remove it.
| custom_usermods = audioreactive ampworks mpr121 | |
| custom_usermods = audioreactive ampworks |
| } | ||
|
|
||
| uint16_t getId() override { return USERMOD_ID_EXAMPLE; } | ||
| uint16_t getId() override { return USERMOD_ID_UNSPECIFIED; } |
There was a problem hiding this comment.
USERMOD_ID_UNSPECIFIED (typically 0) is the sentinel for 'no stable ID.' If UsermodManager uses the ID for dedup checks, or if any code calls lookup(USERMOD_ID_UNSPECIFIED), AMPWorks will be returned unexpectedly. ID 59 is unused between upstream USER_FX=58 and the new MPR121=60. Add #define USERMOD_ID_AMPWORKS 59 in const.h and return it here.
| uint16_t getId() override { return USERMOD_ID_UNSPECIFIED; } | |
| uint16_t getId() override { return USERMOD_ID_AMPWORKS; } |
| #define random8 hw_random8 | ||
| #define random16 hw_random16 | ||
| // beatsin8(bpm,lo,hi) -> beatsin8_t(bpm,lo,hi,timebase=0,phase=0). | ||
| #define beatsin8 beatsin8_t |
There was a problem hiding this comment.
Suggested test: Grep ampworks.cpp for beatsin8( and confirm every call site uses exactly 3 arguments. FastLED's beatsin8 accepts up to 5 (bpm, lo, hi, timebase, phase); if any effect calls it with 4 or 5 args, the call compiles silently against beatsin8_t but may produce wrong timing if parameter semantics differ for the optional args.
| const char UsermodMPR121::_name[] PROGMEM = "MPR121"; | ||
| const char UsermodMPR121::_enabled[] PROGMEM = "enabled"; | ||
| static UsermodMPR121 mpr121_usermod; | ||
| REGISTER_USERMOD(mpr121_usermod); |
There was a problem hiding this comment.
Suggested post-merge check: After flashing ampworks, confirm UsermodManager::lookup(USERMOD_ID_MPR121) returns non-null — e.g., via a serial log in mode_touch_ripple's early guard path or the WLED /json/info endpoint. A silent nullptr here makes Touch Ripple and Touch Grid inert with no compile-time signal.
… usermod USERMOD_ID_EXAMPLE (=2) conflicts with the stock example usermod id. Nothing currently looks up AMPWorks by id, but UNSPECIFIED avoids the collision. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> (cherry picked from commit f0d1a80)
The mpr121 usermod depends on the MPR121 + Debug libraries in aphelps/ArduinoLibs, which are vendored as a submodule in the parent WLED_dev repo and are absent from this fork's standalone CI checkout — so the `usermods` glob env (build.yml) and the mpr121 matrix job (usermods.yml) failed with 'MPR121.h: No such file'. Both workflows now clone ArduinoLibs and expose it via PLATFORMIO_LIB_EXTRA_DIRS, so PlatformIO resolves MPR121.h and its transitive Debug.h. mpr121 stays a normal .cpp usermod (implementation in the .cpp, plain library.json) — the CI is fixed rather than the code worked around. Verified locally: mpr121 builds SUCCESS with PLATFORMIO_LIB_EXTRA_DIRS pointing at ArduinoLibs.
20d34a8 to
621f94d
Compare
aphelps-claude-bot
left a comment
There was a problem hiding this comment.
Self-review of the reconstructed branch (post-20d34a84): both CI-workaround commits are gone, usermod_mpr121.cpp is restored with its implementation (impl in .cpp, only structure in the header — matches Adam's requirement), and the real CI fix (621f94dd) clones aphelps/ArduinoLibs + sets PLATFORMIO_LIB_EXTRA_DIRS so the usermods glob env and the mpr121 matrix job resolve MPR121.h and its transitive Debug.h. The mechanism is correct: PLATFORMIO_LIB_EXTRA_DIRS points at the clone root, and PlatformIO treats each subdir (MPR121, Debug, ...) as a candidate library, so both headers resolve. ${{ runner.temp }} is the right ephemeral, per-job path (no stale-clone collision across cache-restore reruns). The env: block is correctly scoped to the Build firmware step in both files. Verified: only one beatsin8 call site and it is 3-arg, so the #define beatsin8 beatsin8_t shim is safe for current code. No blocking issues. Findings below are non-blocking robustness/cleanup notes.
Broad note (build.yml — cross-cutting, not line-specific): The ArduinoLibs clone in build.yml runs unconditionally for every matrix environment, but only mpr121-consuming envs actually need it. This is harmless (the comment acknowledges it) and keeps the step simple, so it is acceptable as-is; if the default-env matrix grows large, consider gating the clone on the envs that need it to save a clone per job. No change required for merge.
| # from this fork's standalone checkout). Fetch them and expose via PLATFORMIO_LIB_EXTRA_DIRS | ||
| # so the `usermods` env (custom_usermods = *) can build mpr121. Harmless for other envs. | ||
| - name: Fetch ArduinoLibs (MPR121 + Debug) for AMPWorks usermods | ||
| run: git clone --depth 1 https://github.com/aphelps/ArduinoLibs.git "${{ runner.temp }}/ArduinoLibs" |
There was a problem hiding this comment.
Robustness: this clones the ArduinoLibs default-branch tip with no pinned ref, so a future push to that repo could change what CI builds against and break this PR's CI non-deterministically — a classic un-pinned-dependency footgun in CI. --depth 1 only bounds history, not the ref. Consider pinning to a tag or commit SHA (--branch <tag> / a post-clone git checkout <sha>) so the fork's CI is reproducible. Non-blocking.
Suggested post-merge check: after merge, confirm CI still resolves MPR121.h + Debug.h if aphelps/ArduinoLibs default branch moves (or pin the clone to a SHA to make this a non-issue).
| # mpr121 depends on the MPR121 + Debug libs from aphelps/ArduinoLibs (vendored in the | ||
| # parent WLED_dev repo, absent here). Fetch + expose them so mpr121's matrix job builds. | ||
| - name: Fetch ArduinoLibs (MPR121 + Debug) for AMPWorks usermods | ||
| run: git clone --depth 1 https://github.com/aphelps/ArduinoLibs.git "${{ runner.temp }}/ArduinoLibs" |
There was a problem hiding this comment.
Same un-pinned-clone note as build.yml: the mpr121 matrix job clones the ArduinoLibs default-branch tip with no pinned ref. Pinning to a tag/SHA would make the usermod CI reproducible. Non-blocking; mirror whatever pin approach is chosen for build.yml here.
| run: pio run -e ${{ matrix.environment }} | ||
| run: pio run -e ${{ matrix.environment }} | ||
| env: | ||
| PLATFORMIO_LIB_EXTRA_DIRS: ${{ runner.temp }}/ArduinoLibs |
There was a problem hiding this comment.
Suggested post-merge check: confirm PLATFORMIO_LIB_EXTRA_DIRS here (which sets the value fresh) composes correctly with the lib_extra_dirs = ${PROJECT_DIR}/../ArduinoLibs that the ampworks/apa102_mpr121 envs set in platformio.ini — i.e. that the env var supplements rather than shadows the ini setting for local builds. The CI usermods_* envs don't set lib_extra_dirs, so CI is fine; this is only to confirm local ampworks builds are unaffected.
| } | ||
|
|
||
| uint16_t getId() override { return USERMOD_ID_EXAMPLE; } | ||
| uint16_t getId() override { return USERMOD_ID_UNSPECIFIED; } |
There was a problem hiding this comment.
getId() now returns USERMOD_ID_UNSPECIFIED (=1), a shared sentinel rather than a unique ID. This is cosmetically cleaner than the old USERMOD_ID_EXAMPLE and safe here (nothing looks AMPWorks up by ID — only MPR121/SensorSync are lookup()-ed), but multiple usermods sharing the UNSPECIFIED sentinel means an ID-based lookup(USERMOD_ID_UNSPECIFIED) would be ambiguous. If AMPWorks is ever lookup()-ed, define a unique USERMOD_ID_AMPWORKS = 59 in const.h (59 is free between USER_FX=58 and MPR121=60). No change needed now.
|
|
||
| // mpr may report no physical sensor (display-only node): the touched() wrappers then | ||
| // return false, so local-touch logic is inert but remote/audio waves still render. | ||
| UsermodMPR121 *mpr = (UsermodMPR121*) UsermodManager::lookup(USERMOD_ID_MPR121); |
There was a problem hiding this comment.
UsermodManager::lookup(USERMOD_ID_MPR121) returning nullptr silently makes mode_touch_ripple a no-op with no diagnostic — on a device where the usermod failed to register, the effect just renders nothing with no clue why. Consider a one-time DEBUG_PRINTLN when the lookup is null so misconfiguration is observable at runtime. Non-blocking.
Suggested post-merge check: on a real device, confirm Touch Ripple + Touch Grid actually locate the MPR121 usermod at runtime (compile-passing != registered); the JSON /json effects list + touch response is the observable signal.
The 0.15.3->16.x port dropped three custom pieces that never got re-applied: - tools/upload_wled.py (custom curl-based /update HTTP upload; macOS blocks espota UDP) - tools/set_build_info.py (injects WLED_GIT_HASH/BRANCH/BUILD_TIME as CPPDEFINES) - the json.cpp serializeInfo() consumer that surfaces git/branch/built in /json/info Restore all three (scripts verbatim from 0.15.3) and re-wire the ampworks env: upload_protocol=custom + upload_port + extra_scripts (user_config_copy, set_build_info, upload_wled). apa102_mpr121 now inherits ampworks' HTTP-OTA (drops its esptool override) since the grid device is OTA-flashed in practice — WLED_IP=<ip> pio run -e apa102_mpr121 -t upload. Restores the documented 'pio run -t upload' one-command flash and the /json/info build fields the upgrade plan's Test Plan relies on. Verified: -e ampworks and -e apa102_mpr121 both build SUCCESS; set_build_info runs and the branch/hash are embedded in firmware.bin. Only touches the ampworks/apa102_mpr121 envs + a guarded json.cpp block (compiles out when WLED_GIT_HASH is undefined), so stock CI envs are unaffected.
aphelps-claude-bot
left a comment
There was a problem hiding this comment.
Follow-up review of f2f0f196 (v16 port-gap restore: HTTP-OTA upload + build-info injection), incremental over the last-reviewed 621f94dd.
Prior issues: no regressions to previously-noted items; the build.yml unconditional-clone note from the last review is unchanged and still non-blocking. The json.cpp build-info block, the two restored tools/*.py scripts, set_build_info.py's define-quoting, and the apa102_mpr121 USB->OTA inheritance all look correct (see inline notes).
One high-value finding (INLINE on platformio.ini): the new extra_scripts override in [env:ampworks] is a full replace, not an append — it drops 7 of the 8 inherited default scripts (most importantly load_usermods.py and build_ui.py). At 621f94dd the env carried no extra_scripts key, so it inherited ${scripts_defaults.extra_scripts} (set_metadata, output_bins, strip-floats, dynarray, user_config_copy, load_usermods, build_ui, validate_modules) from [env]. PlatformIO does not list-merge extra_scripts across extends, so listing only 3 scripts silently removes the rest. load_usermods.py is what consumes custom_usermods = audioreactive ampworks mpr121, and build_ui.py regenerates the web UI — dropping them likely breaks the -e ampworks / -e apa102_mpr121 build (or produces a firmware with no usermods / stale UI). The overnight "-e ampworks builds" evidence predates this commit (the old env inherited the scripts); the new env is not yet build-verified (Test-Plan builds blocked by the local Python 3.9-vs-3.10 issue). Recommend prepending the defaults. Not merge-blocking only if a fresh -e ampworks build is confirmed green first.
| upload_port = 192.168.1.55 | ||
| extra_scripts = pre:pio-scripts/user_config_copy.py | ||
| pre:tools/set_build_info.py | ||
| post:tools/upload_wled.py |
There was a problem hiding this comment.
The extra_scripts override fully replaces the inherited ${scripts_defaults.extra_scripts} (PlatformIO does not merge this key across extends). At the prior reviewed sha this env had no extra_scripts key and inherited all 8 defaults from [env]; this commit narrows it to 3, dropping set_metadata.py, output_bins.py, strip-floats.py, dynarray.py, load_usermods.py, build_ui.py, and validate_modules.py. load_usermods.py is required to turn custom_usermods = audioreactive ampworks mpr121 into build flags, and build_ui.py regenerates html_*.h — so this likely breaks the ampworks build or yields firmware with no usermods. Prepend the defaults:
| post:tools/upload_wled.py | |
| extra_scripts = ${scripts_defaults.extra_scripts} | |
| pre:tools/set_build_info.py | |
| post:tools/upload_wled.py |
(user_config_copy.py is already in the defaults, so it need not be re-listed.) Suggested test: run pio run -e ampworks on this exact commit and confirm the usermods register + the UI builds before merge.
|
|
||
| # AMPWorks: effects + MPR121 touch + SensorSync bus (WLED 16.x port). | ||
| # ArduinoLibs (MPR121/Debug) vendored in the parent WLED_dev repo (../ArduinoLibs). | ||
| [env:ampworks] |
There was a problem hiding this comment.
upload_port = 192.168.1.55 is the touch-box default. Since apa102_mpr121 now inherits this env's custom HTTP-OTA (good — matches the documented practice), the matrix/APA102 board will also default to .55; the header comment already tells users to pass WLED_IP=<matrix-ip>, so this is fine, just calling out the inherited default explicitly. Non-blocking.
| root[F("release")] = releaseString; | ||
| root[F("repo")] = repoString; | ||
| root[F("deviceId")] = getDeviceId(); | ||
| #ifdef WLED_GIT_HASH |
There was a problem hiding this comment.
#ifdef WLED_GIT_HASH guard is correct: the three defines are always injected together by set_build_info.py (a single env.Append), so guarding on just WLED_GIT_HASH safely covers WLED_GIT_BRANCH/WLED_BUILD_TIME too. Stock CI envs never run set_build_info.py (it's only in the ampworks extra_scripts), so the block compiles out cleanly for upstream/CI builds. Good.
| build_time = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ") | ||
|
|
||
| print(f"Build info: {hash_str} branch={branch} time={build_time}") | ||
|
|
There was a problem hiding this comment.
Define-quoting looks correct for the SCons CPPDEFINES path: f'\\\"{hash_str}\\\"' yields an escaped-quote string literal so the value lands as a C string. Fallbacks to "unknown" on any git failure keep the build from breaking in a non-git checkout. Verbatim from 0.15.3 as claimed. No change needed.
Self-review of the prior commit caught it: PlatformIO REPLACES extra_scripts across
`extends` (no list-merge), so setting extra_scripts on [env:ampworks] dropped the 8
inherited scripts_defaults — including load_usermods.py. Result: -e ampworks/-e
apa102_mpr121 built SUCCESS but with ZERO usermods compiled (no AMPWorks effects, MPR121,
or sensor-sync in the firmware). Prepend ${scripts_defaults.extra_scripts} so the defaults
run, then append set_build_info + upload_wled.
Verified: ampworks.cpp.o, usermod_mpr121.cpp.o, usermod_sensor_sync.cpp.o now all compile
in both envs; set_build_info still injects the git/branch/built defines.
aphelps-claude-bot
left a comment
There was a problem hiding this comment.
Follow-up review of 3ec86654 (fix ampworks extra_scripts to prepend inherited defaults), incremental over the last-reviewed f2f0f196.
Prior high-value finding is RESOLVED. The previous review flagged that [env:ampworks]'s extra_scripts was a full replace that dropped 7 of the 8 inherited default scripts (most importantly load_usermods.py and build_ui.py), so the firmware would build with no usermods / stale UI. This commit fixes it exactly as recommended: extra_scripts = ${scripts_defaults.extra_scripts} is now prepended before the two custom scripts, restoring the full default chain.
Verified against the tree at 3ec86654:
- (a) All 8 defaults restored.
[scripts_defaults].extra_scripts(platformio.ini:135) lists set_metadata, output_bins, strip-floats, dynarray, user_config_copy, load_usermods, build_ui, validate_modules. Referencing it via${scripts_defaults.extra_scripts}pulls all 8 back in.load_usermods.pyis what turnscustom_usermods = audioreactive ampworks mpr121into the usermod build;build_ui.pyregenerates the web UI. Both present again. - (b) Ordering is correct. Effective order: the 8 defaults in listed order (incl.
pre:user_config_copy.py), thenpre:tools/set_build_info.py, thenpost:tools/upload_wled.py.set_build_infoonly doesenv.Append(CPPDEFINES=...)andupload_wledonly doesenv.Replace(UPLOADCMD=...)— both order-independent w.r.t. the defaults, so appending them after the default chain is fine. The git/branch/built defines still inject. - (c) No remaining bare replace. The only two
extra_scriptsassignments in the file are the defaults definition (line 135) and[env]base (line 194, itself= ${scripts_defaults.extra_scripts}). ampworks (line 523) is the sole env override and now correctly references the defaults. No other env does a bare replace. - (d) apa102_mpr121 inherits the fix.
[env:apa102_mpr121](extends = env:ampworks) defines noextra_scriptskey of its own, so it inherits ampworks' now-correct value. Itsbuild_flagsalso correctly composes via${env:ampworks.build_flags}.
All five referenced scripts (pio-scripts/{load_usermods,build_ui,user_config_copy}.py, tools/{set_build_info,upload_wled}.py) exist on disk. Caller reports a green build: ampworks.cpp.o + usermod_mpr121.cpp.o + usermod_sensor_sync.cpp.o all compile under both -e ampworks and -e apa102_mpr121 with build-info injection intact. Locally unverifiable here (Python 3.9 vs the 3.10+ the 16.x build scripts require), so build evidence rests on the caller's run.
The pre-existing build.yml/usermods.yml unconditional-clone note from earlier reviews is unchanged and still non-blocking (un-pinned ArduinoLibs clone → potential CI drift; awaiting Adam's pin decision). No new issues introduced. Fix confirmed complete.
aphelps
left a comment
There was a problem hiding this comment.
Tested on a device and appears to work
Ports the AMPWorks stack (effects, MPR121, SensorSync bus, custom envs) onto upstream WLED 16.0.1 — the mesh M2 milestone.
Base note: this PR targets
base-wled-16.0.1(a branch at the upstream v16.0.1 tag), not the fork's 0.15-basedmain, so the diff is just our port (16 files) instead of the entire 0.15→16 upstream delta. Landing the upgrade means the fork'smainmoves to 16.0.1 — a separate, owner-driven step once this is approved + hardware-tested.What changed (16.x port)
-D USERMOD_x+usermods_list.cppwith per-librarycustom_usermods+REGISTER_USERMODself-registration. Addedlibrary.jsonforampworks/mpr121, static-instance registration in each usermod (+ a newusermod_mpr121.cpp, since the header-only mod needed a TU), and rewrote the[env:ampworks]/[env:apa102_mpr121]envs.void(notuint16_t) — converted allmode_*signatures + droppedreturn FRAMETIME.fastled_slimreplacement keepsscale8/qadd8/color_fadebut notrandom8/random16/map8/beatsin8/sqrt16(the core migrated those tohw_random8/beatsin8_t). Re-exposed just those 5 via a dedicatedfastled_compat.hso the effect code is unchanged.bus_wrapper.h'sB_HS_DOT_3guard withAMPWORKS_DOTSTAR_HSPI(APA102+MPR121 GPIO-19 fix), adapted toNeoPixelBus.Test plan
pio run -e esp32dev— upstream base builds.pio run -e ampworks— effects + usermods build on 16.0.1.pio run -e apa102_mpr121— HSPI/MPR121 target builds.c++ -std=c++11 -Wall -Wextra usermods/ampworks/tests/sensor_sync_test.cpp && ./a.out→ ALL TESTS PASSED (protocol header is dependency-free).grep -R /Users/ platformio.ini→ clean.setup.sh) — pending the parent submodule-pointer bump at merge.Manual (Testing Required — before merge)
ampworks: all effects render; MPR121 touch works; sensor-sync cross-device works.apa102_mpr121: APA102 LEDs + MPR121 touch work (HSPI fix intact).Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]