rusefi-1/firmware/controllers/sensors/oil_pressure.cpp

28 lines
743 B
C++
Raw Normal View History

/**
* @author Matthew Kennedy, (c) 2017
*/
2018-09-16 19:26:57 -07:00
#include "global.h"
#include "oil_pressure.h"
#include "interpolation.h"
2017-11-24 16:16:00 -08:00
#include "analog_input.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
}