Add adc_ladder() factory for ADC resistor-ladder binary inputs#78
Open
teancom wants to merge 2 commits into
Open
Add adc_ladder() factory for ADC resistor-ladder binary inputs#78teancom wants to merge 2 commits into
teancom wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
ADC resistor-ladder buttons (input_type=2) share one ADC pin and are distinguished by voltage. adc_ladder() packs (N, id_base) + (N+1) strictly-descending LE uint16 thresholds into BinaryInputs.reserved[14], matching the firmware's registerAdcLadder decode byte-for-byte. Validation mirrors the firmware contract so this helper can't build a config the device would silently drop: - 2..6 thresholds (N = 1..5; reserved[14] holds at most N+1=6) - thresholds strictly descending, each a uint16 - button_data_byte_index 0..10 (index into the 11-byte MSD block) - id_base >= 0 and last id <= 7 (button id is a 3-bit report field) Adds BinaryInputType enum and tests pinning the wire contract plus every rejection branch. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Matches firmware OpenDisplay#35 review: input_type == 2 is reserved for the host-side switch feature. Add SWITCH = 2 to model the reservation and renumber ADC_LADDER to 3. Wire layout is otherwise unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Matching PR to OpenDisplay/Firmware#35, this adds support for configs of analog buttons. Tested live on an XTEINK X4, and I tried to make it as generic as possible. As always, let me know if something doesn't look right / should be architected differently, I'm still learning (obvs!) so any/all feedback is very welcome.
Robot's commit message:
ADC resistor-ladder buttons (input_type=2) share one ADC pin and are distinguished by voltage. adc_ladder() packs (N, id_base) + (N+1) strictly-descending LE uint16 thresholds into BinaryInputs.reserved[14], matching the firmware's registerAdcLadder decode byte-for-byte.
Validation mirrors the firmware contract so this helper can't build a config the device would silently drop:
Adds BinaryInputType enum and tests pinning the wire contract plus every rejection branch.