diff --git a/protocol/esta/analog/receiver.h b/protocol/esta/analog/receiver.h index ce1b1fd..3beeb24 100644 --- a/protocol/esta/analog/receiver.h +++ b/protocol/esta/analog/receiver.h @@ -56,6 +56,20 @@ struct Receiver else return (mV - zero) / (full - zero); } + + /** + * @brief Determine the state of a non-dim switch. + * @param mV + * @param cur If incorporating hysteresis, the current state of the switch. + * @return + */ + bool state(const int16_t mV, const bool cur = false) const + { + uint8_t l = level(mV); + if (cur) + return !(l < 102); // ~40% + return l > 153; // ~60% + } }; } // namespace ANALOG