fome-fw/firmware/controllers/sensors/oil_pressure.cpp

29 lines
764 B
C++
Raw Normal View History

/**
* @author Matthew Kennedy, (c) 2017
*/
2018-09-16 19:26:57 -07:00
#include "global.h"
#include "os_access.h"
#include "oil_pressure.h"
#include "interpolation.h"
2019-09-19 22:06:15 -07:00
#include "adc_inputs.h"
#include "engine.h"
EXTERN_ENGINE;
bool hasOilPressureSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
return engineConfiguration->oilPressure.hwChannel != EFI_ADC_NONE;
}
float getOilPressure(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
// If there's no sensor, return 0 pressure.
if(!hasOilPressureSensor(PASS_ENGINE_PARAMETER_SIGNATURE)) {
return 0.0f;
}
oil_pressure_config_s* sensor = &CONFIG(oilPressure);
float volts = getVoltageDivided("oilp", sensor->hwChannel);
2018-06-12 02:45:11 -07:00
return interpolateMsg("oil", sensor->v1, sensor->value1, sensor->v2, sensor->value2, volts);
2017-11-24 16:16:00 -08:00
}