2019-09-25 04:26:56 -07:00
|
|
|
#include "functional_sensor.h"
|
|
|
|
|
2020-01-12 00:25:23 -08:00
|
|
|
void FunctionalSensor::postRawValue(float inputValue, efitick_t timestamp) {
|
2019-09-25 04:26:56 -07:00
|
|
|
// If no function is set, this sensor isn't valid.
|
|
|
|
if (!m_function) {
|
|
|
|
invalidate();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-01-12 00:25:23 -08:00
|
|
|
m_rawValue = inputValue;
|
|
|
|
|
2019-09-25 04:26:56 -07:00
|
|
|
auto r = m_function->convert(inputValue);
|
|
|
|
|
|
|
|
// This has to happen so that we set the valid bit after
|
|
|
|
// the value is stored, to prevent the data race of reading
|
|
|
|
// an old invalid value
|
|
|
|
if (r.Valid) {
|
2020-01-12 00:25:23 -08:00
|
|
|
setValidValue(r.Value, timestamp);
|
2019-09-25 04:26:56 -07:00
|
|
|
} else {
|
|
|
|
invalidate();
|
|
|
|
}
|
|
|
|
}
|