rusefi-1/firmware/init/sensor/init_map.cpp

45 lines
878 B
C++
Raw Normal View History

#include "pch.h"
#include "function_pointer_sensor.h"
struct GetMapWrapper {
DECLARE_ENGINE_PTR;
float getMap() {
return ::getMap(PASS_ENGINE_PARAMETER_SIGNATURE);
}
};
static GetMapWrapper mapWrapper;
static FunctionPointerSensor mapSensor(SensorType::Map,
[]() {
return mapWrapper.getMap();
});
struct GetBaroWrapper {
DECLARE_ENGINE_PTR;
float getBaro() {
return ::getBaroPressure(PASS_ENGINE_PARAMETER_SIGNATURE);
}
};
static GetBaroWrapper baroWrapper;
static FunctionPointerSensor baroSensor(SensorType::BarometricPressure,
[]() {
return baroWrapper.getBaro();
});
void initMap(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
INJECT_ENGINE_REFERENCE(&mapWrapper);
INJECT_ENGINE_REFERENCE(&baroWrapper);
mapSensor.Register();
// Only register if configured
if (isAdcChannelValid(engineConfiguration->baroSensor.hwChannel)) {
baroSensor.Register();
}
}