1
0
Fork 0

Hysteresis aware method for calculating non-dim switch state

This commit is contained in:
Kevin Matz 2023-03-30 14:55:12 -04:00
parent 9c5654b34d
commit 8979dd4699
1 changed files with 14 additions and 0 deletions

View File

@ -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