You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Deferred from the #943 review (thread, deferral) as a nice-to-have for v2.1.
DigitalIOHardware::CheckEvent() (src/components/digitalIO/hardware.cpp) currently treats the first read after a pinAdd specially: _prv_value starts as a guess, so the first read seeds the baseline from hardware and is always published as the pin's initial state (fixed in dcb1f04 — previously the guess could suppress or fabricate a transition).
Feature
For input pins, IO should supply the last known state in the pinAdd's optional initial write (the field already exists in ws_digitalio_Add and is currently only meaningful for outputs). The firmware would use that as the starting previous value for the on-change trigger:
current reading == last known state → no redundant initial event; the broker already has this value
current reading != last known state → a genuine transition event fires, so a state change that happened while the device was offline / rebooting / sleeping is detected and published as a change rather than a fresh baseline
Notes
Needs IO/broker cooperation: the pinAdd for an input must carry the last value the broker saw (companion change in adafruit/Wippersnapper_Protobuf semantics/docs if the existing write field is reused).
Interaction with is_inverted and expander-backed pins (EXP_0xNN_P) should follow the logical-value convention used by ReadValue().
Context
Deferred from the #943 review (thread, deferral) as a nice-to-have for v2.1.
DigitalIOHardware::CheckEvent()(src/components/digitalIO/hardware.cpp) currently treats the first read after a pinAdd specially:_prv_valuestarts as a guess, so the first read seeds the baseline from hardware and is always published as the pin's initial state (fixed in dcb1f04 — previously the guess could suppress or fabricate a transition).Feature
For input pins, IO should supply the last known state in the pinAdd's optional initial
write(the field already exists inws_digitalio_Addand is currently only meaningful for outputs). The firmware would use that as the starting previous value for the on-change trigger:Notes
writefield is reused).is_invertedand expander-backed pins (EXP_0xNN_P) should follow the logical-value convention used byReadValue().Refs: #943, #952.
🤖 Generated with Claude Code