Add - Expanders, ADCs#917
Open
brentru wants to merge 36 commits into
Open
Conversation
…t - digitaliopins
brentru
commented
May 12, 2026
brentru
commented
May 12, 2026
brentru
commented
May 12, 2026
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR migrates the firmware’s Analog IO component from analogio to the new analogin API and introduces a new expander component (plus drivers) to support I/O expanders and external ADCs, with corresponding protobuf and offline-config updates.
Changes:
- Replaced
analogioprotobuf/component/controller paths withanalogin(including checkin routing, SD-card parsing, and tests/config). - Added a new
expanderprotobuf/component/controller and multiple expander/ADC driver wrappers. - Updated DigitalIO and PWM layers to optionally operate on expander-backed pins.
Reviewed changes
Copilot reviewed 84 out of 84 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_offline.py | Updates offline tests to expect analogin API and new checksums/log strings. |
| src/wippersnapper.h | Wires in AnalogInController and new ExpanderController. |
| src/wippersnapper.cpp | Routes/publishes analogin + expander signals and updates controller lifecycle calls. |
| src/provisioning/sdcard/ws_sdcard.h | Renames SD parsing helper to ParseAnalogInAdd. |
| src/provisioning/sdcard/ws_sdcard.cpp | Updates offline JSON parsing from analogio to analogin. |
| src/protos/uart.pb.h | Regenerated nanopb header timestamp. |
| src/protos/uart.pb.c | Regenerated nanopb source timestamp. |
| src/protos/sleep.pb.h | Regenerated nanopb header timestamp. |
| src/protos/sleep.pb.c | Regenerated nanopb source timestamp. |
| src/protos/signal.pb.h | Swaps analogio for analogin in the signal envelope and adds expander payloads. |
| src/protos/signal.pb.c | Regenerated nanopb source timestamp. |
| src/protos/servo.pb.h | Regenerated nanopb header timestamp. |
| src/protos/servo.pb.c | Regenerated nanopb source timestamp. |
| src/protos/sensor.pb.h | Regenerated nanopb header timestamp. |
| src/protos/sensor.pb.c | Regenerated nanopb source timestamp. |
| src/protos/pwm.pb.h | Regenerated nanopb header timestamp. |
| src/protos/pwm.pb.c | Regenerated nanopb source timestamp. |
| src/protos/pixels.pb.h | Regenerated nanopb header timestamp. |
| src/protos/pixels.pb.c | Regenerated nanopb source timestamp. |
| src/protos/i2c.pb.h | Regenerated nanopb header timestamp. |
| src/protos/i2c.pb.c | Regenerated nanopb source timestamp. |
| src/protos/gps.pb.h | Regenerated nanopb header timestamp. |
| src/protos/gps.pb.c | Regenerated nanopb source timestamp. |
| src/protos/expander.pb.h | Adds new nanopb-generated expander messages. |
| src/protos/expander.pb.c | Adds new nanopb-generated expander bindings. |
| src/protos/error.pb.h | Renames error component enum from ANALOGIO to ANALOGIN. |
| src/protos/error.pb.c | Regenerated nanopb source timestamp. |
| src/protos/ds18x20.pb.h | Regenerated nanopb header timestamp. |
| src/protos/ds18x20.pb.c | Regenerated nanopb source timestamp. |
| src/protos/display.pb.h | Regenerated nanopb header timestamp. |
| src/protos/display.pb.c | Regenerated nanopb source timestamp. |
| src/protos/digitalio.pb.h | Regenerated nanopb header timestamp. |
| src/protos/digitalio.pb.c | Regenerated nanopb source timestamp. |
| src/protos/checkin.pb.h | Switches component adds from analogio_adds to analogin_adds. |
| src/protos/checkin.pb.c | Regenerated nanopb source timestamp. |
| src/protos/analogio.pb.h | Removes old nanopb-generated analogio messages. |
| src/protos/analogio.pb.c | Removes old nanopb-generated analogio bindings. |
| src/protos/analogin.pb.h | Adds new nanopb-generated analogin messages (sample mode, gain, etc.). |
| src/protos/analogin.pb.c | Adds new nanopb-generated analogin bindings. |
| src/components/pwm/hardware.h | Refactors PWM hardware API to support expander-backed pins and message-based writes. |
| src/components/pwm/hardware.cpp | Implements expander-aware attach/detach/write behavior. |
| src/components/pwm/controller.h | Refactors pin tracking to a vector-based collection and adds helper methods. |
| src/components/pwm/controller.cpp | Adds expander pin parsing/driver resolution and refactors add/remove/write flows. |
| src/components/i2c/model.h | Adds/extends doc comments and formatting tweaks. |
| src/components/i2c/hardware.h | Adds doc comments and formatting tweaks. |
| src/components/i2c/hardware.cpp | Adds doc comments and formatting tweaks. |
| src/components/i2c/controller.cpp | Formatting and small refactors for readability. |
| src/components/expander/model.h | Adds expander model wrapper for D2B envelopes. |
| src/components/expander/model.cpp | Implements expander D2B envelope building for added/removed. |
| src/components/expander/hardware.h | Adds base expander hardware abstraction (Arduino/Wiring-like API + pin parsing/formatting). |
| src/components/expander/drivers/drv_tca8418.h | Adds TCA8418 expander driver wrapper. |
| src/components/expander/drivers/drv_seesaw.h | Adds Seesaw expander driver wrapper (incl. analogRead/analogWrite). |
| src/components/expander/drivers/drv_pcf8575.h | Adds PCF8575 expander driver wrapper. |
| src/components/expander/drivers/drv_pcf8574.h | Adds PCF8574 expander driver wrapper. |
| src/components/expander/drivers/drv_mcp23x17.h | Adds MCP23X17 expander driver wrapper. |
| src/components/expander/drivers/drv_mcp23x08.h | Adds MCP23X08 expander driver wrapper. |
| src/components/expander/drivers/drv_aw9523.h | Adds AW9523 expander driver wrapper. |
| src/components/expander/drivers/drv_ads1115.h | Adds ADS1115 ADC driver wrapper (analogRead + gain). |
| src/components/expander/drivers/drv_ads1015.h | Adds ADS1015 ADC driver wrapper (analogRead + gain). |
| src/components/expander/controller.h | Adds expander controller API and driver registry. |
| src/components/expander/controller.cpp | Implements expander add/remove routing and driver management. |
| src/components/error/controller.h | Renames analog error publish helper to PublishAnalogIn. |
| src/components/error/controller.cpp | Publishes analog errors under analogin signal tag. |
| src/components/digitalIO/hardware.h | Refactors digital pin representation into a per-pin hardware object (supports expander). |
| src/components/digitalIO/hardware.cpp | Implements expander-aware read/write/polling and sleep-cycle tracking. |
| src/components/digitalIO/controller.h | Refactors controller to manage DigitalIOHardware* lists (input/output) and helpers. |
| src/components/digitalIO/controller.cpp | Adds expander support, validation, new pin lifecycle, and logging adjustments. |
| src/components/checkin/model.h | Renames callback to cbAnalogInAdds. |
| src/components/checkin/model.cpp | Routes checkin analog adds to AnalogInController and configures ref/max pins via analogin controller. |
| src/components/analogIn/model.h | Adds AnalogIn model for decoding/encoding analogin messages. |
| src/components/analogIn/model.cpp | Implements AnalogIn model encoding/decoding helpers. |
| src/components/analogIn/hardware.h | Adds per-pin analog input hardware abstraction with optional expander backing. |
| src/components/analogIn/hardware.cpp | Implements expander/native analog reads, scaling, gain, timers, and event checks. |
| src/components/analogIn/controller.h | Adds AnalogIn controller interface and pin registry. |
| src/components/analogIn/controller.cpp | Implements analog pin add/remove/update and event publishing/logging. |
| src/components/analogIO/model.h | Removes old AnalogIO model API. |
| src/components/analogIO/model.cpp | Removes old AnalogIO model implementation. |
| src/components/analogIO/hardware.h | Removes old AnalogIO hardware API. |
| src/components/analogIO/hardware.cpp | Removes old AnalogIO hardware implementation. |
| src/components/analogIO/controller.h | Removes old AnalogIO controller API. |
| src/components/analogIO/controller.cpp | Removes old AnalogIO controller implementation. |
| platformio.ini | Adds additional library dependencies for expanders/ADCs. |
| library.properties | Extends Arduino library dependencies list for expanders/ADCs. |
| config.json | Updates example config to use analogin component API and new checksum. |
Comments suppressed due to low confidence (5)
src/components/pwm/controller.cpp:1
- PWM pins are also looked up only by numeric pin id, which creates the same collision issue for expander pins and native pins / multiple expanders. Consider tracking PWM pins with a composite key (expander address + pin number + native/expander flag), and update
RemovePin()/Handle_PWM_Add()/Handle_PWM_Write()accordingly.
src/provisioning/sdcard/ws_sdcard.cpp:1 - The offline JSON examples/tests in this PR use
totalGPIOPins,totalAnalogPins, andreferenceVoltage, but the SD-card CheckIn path is readingmaxDigitalPins,maxAnalogPins, andrefVoltage. This will silently fall back to zeros when those keys are absent, breaking controller sizing/ref-voltage config in offline mode. Update the key names to match the exported schema, or support both spellings for backward compatibility.
src/provisioning/sdcard/ws_sdcard.cpp:1 strcpyinto a fixed-size protobuf field (pin_name[64]) can overflow if the SD config contains an unexpectedly long pin string, leading to memory corruption. Use a bounded copy (e.g.,strncpy/snprintf/strlcpywhere available) and enforce null-termination.
src/wippersnapper.cpp:1- The doc comment states
wifi_offpowers off the WiFi radio, but the implementation explicitly ignores the parameter. Either implement the documented behavior (even if only for specific network backends via#ifdefs) or adjust the docstring to reflect thatwifi_offis currently unused.
src/protos/expander.pb.h:1 - The generated comment for
ws_expander_Removeincorrectly mentions removing an analog pin, but this message removes an expander device. If the.protofile is the source of truth, fix the comment there and regenerate nanopb outputs to avoid misleading API documentation.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Member
Author
|
@tyeth when you have time, could you review this PR ? Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces the expander component to expand a device's I/O, ADC, and PWM functionality. The expander component aims to be flexible enough to support [existing component behavior] over a transport (which is I2c, for now).
Major changes
src/expander/component withcontroller,hardware,model, anddrivers/.analogioprotobuf/component/controller paths withanalogin(including checkin routing, SD-card parsing, and tests/config).Related:
adafruit/Wippersnapper_Protobuf#181
adafruit/Wippersnapper_Protobuf#193
adafruit/Wippersnapper_Boards#246
adafruit/Wippersnapper_Components#320