Repository navigation
Commit 3af8d68
Add ADC resistor-ladder binary inputs (analog buttons) (#35)
* Add ADC resistor-ladder binary inputs (analog buttons)
BinaryInputs input_type == 2: several buttons share one ADC pin, distinguished by voltage. Polled (no edge interrupt) and reported through the same MSD button byte as digital buttons, so hosts decode one uniform contract. Wire layout (num_buttons, id_base, N+1 LE uint16 descending thresholds in reserved[]) is documented in structs.h.
device_control.cpp adds classify/register/poll with sample debounce, per-pin ADC attenuation, a static_assert guarding reserved[] capacity, and rejection of non-descending thresholds from any host. ESP32 only; NRF gets an empty poll stub.
Verified on an ESP32-C3 (XTEINK X4): valid ladders register and report presses; a malformed (non-descending) config is skipped at init with a diagnostic while a valid ladder beside it still works.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Reject out-of-range ADC-ladder id_base instead of masking it
registerAdcLadder stored id_base raw and the poll path masked the
reported id with & 0x07. A host sending id_base + count > 8 (3-bit id
field) produced wrapped, colliding button ids that HA cannot
disambiguate — silently, with no feedback. The firmware is the
validation boundary for any host, not just py-opendisplay, so reject it.
Also give the existing count and byte_index guards the same diagnostic
the descending-threshold check already emits; previously they dropped a
malformed config silently.
Hardware-verified on XTEINK X4: a GPIO2 ladder with id_base=6, N=4 is
now rejected ("exceeds 3-bit id space ... skipping") while a valid GPIO1
ladder registers.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Move ADC ladder to input_type 3 (2 is reserved for switches)
Per maintainer review on #35: BinaryInputs input_type == 2 is reserved
for the host-side switch feature. Renumber the ADC resistor-ladder type
to 3 and document 2 = switch in the struct contract. Wire layout and the
reused reserved[] fields are unchanged.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Log ADC ladder binary input summary
* Fix ADC ladder diagnostics for canonical input fields
* Use canonical button input type in button setup
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 67a83d3 commit 3af8d68
2 files changed
Lines changed: 147 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
778 | 778 | | |
779 | 779 | | |
780 | 780 | | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
781 | 786 | | |
782 | 787 | | |
783 | 788 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
84 | 215 | | |
85 | 216 | | |
86 | 217 | | |
| |||
453 | 584 | | |
454 | 585 | | |
455 | 586 | | |
| 587 | + | |
456 | 588 | | |
457 | 589 | | |
458 | 590 | | |
| |||
593 | 725 | | |
594 | 726 | | |
595 | 727 | | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
596 | 731 | | |
597 | 732 | | |
598 | 733 | | |
599 | | - | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
600 | 741 | | |
601 | 742 | | |
602 | 743 | | |
| |||
0 commit comments