rusefi/firmware/controllers/sensors/ego.cpp

47 lines
952 B
C++
Raw Normal View History

2014-08-29 07:52:33 -07:00
#include "main.h"
#include "engine_configuration.h"
#include "interpolation.h"
#include "adc_inputs.h"
2014-11-11 14:03:38 -08:00
#include "engine.h"
2014-08-29 07:52:33 -07:00
2014-11-11 14:03:38 -08:00
EXTERN_ENGINE;
2014-08-29 07:52:33 -07:00
2014-11-11 14:03:38 -08:00
float getAfr(DECLARE_ENGINE_PARAMETER_F) {
2014-08-29 07:52:33 -07:00
afr_sensor_s * sensor = &engineConfiguration->afrSensor;
float volts = getVoltageDivided(sensor->afrAdcChannel);
return interpolate(sensor->v1, sensor->value1, sensor->v2, sensor->value2, volts);
}
void initEgoSensor(afr_sensor_s *sensor, ego_sensor_e type) {
switch (type) {
case ES_BPSX_D1:
/**
* This decodes BPSX D1 Wideband Controller analog signal
*/
sensor->v1 = 0;
sensor->value1 = 9;
sensor->v2 = 5;
sensor->value2 = 19;
break;
case ES_Innovate_MTX_L:
sensor->v1 = 0;
sensor->value1 = 7.35;
sensor->v2 = 5;
sensor->value2 = 22.39;
break;
2014-10-22 17:02:55 -07:00
case ES_14Point7_Free:
sensor->v1 = 0;
sensor->value1 = 10;
sensor->v2 = 5;
sensor->value2 = 20;
break;
2014-08-29 07:52:33 -07:00
default:
firmwareError("Unexpected EGO %d", type);
break;
}
}