Hysteresis aware method for calculating non-dim switch state
This commit is contained in:
parent
9c5654b34d
commit
8979dd4699
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue