diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp
index f118940f34..5d6738fdd0 100644
--- a/firmware/console/status_loop.cpp
+++ b/firmware/console/status_loop.cpp
@@ -131,9 +131,13 @@ void printSensors(Engine *engine) {
reportSensorF(getCaption(LP_MAP), getMap(), 2);
reportSensorF("map_r", getRawMap(), 2);
}
- reportSensorF("baro", getBaroPressure(), 2);
+ if (engineConfiguration->hasBaroSensor) {
+ reportSensorF("baro", getBaroPressure(), 2);
+ }
+ if (engineConfiguration->hasAfrSensor) {
+ reportSensorF("afr", getAfr(), 2);
+ }
- reportSensorF("afr", getAfr(), 2);
reportSensorF("vref", getVRef(engineConfiguration), 2);
reportSensorF("vbatt", getVBatt(engineConfiguration), 2);
diff --git a/firmware/controllers/algo/engine_configuration.h b/firmware/controllers/algo/engine_configuration.h
index b14b7a6a22..8ac5432374 100644
--- a/firmware/controllers/algo/engine_configuration.h
+++ b/firmware/controllers/algo/engine_configuration.h
@@ -311,6 +311,10 @@ typedef struct {
cranking_parameters_s crankingSettings;
+ /**
+ * @see hasMapSensor
+ * @see isMapAveragingEnabled
+ */
MAP_sensor_config_s map;
// todo: merge with channel settings, use full-scale Thermistor here!
@@ -437,6 +441,9 @@ typedef struct {
adc_channel_e iatAdcChannel;
adc_channel_e mafAdcChannel;
+ /**
+ * @see hasAfrSensor
+ */
afr_sensor_s afrSensor;
float injectionOffset;
@@ -445,6 +452,9 @@ typedef struct {
float diffLoadEnrichmentCoef;
+ /**
+ * @see hasBaroSensor
+ */
air_pressure_sensor_config_s baroSensor;
float veLoadBins[FUEL_LOAD_COUNT];
@@ -461,6 +471,9 @@ typedef struct {
board_configuration_s bc;
+ /**
+ * @see isMapAveragingEnabled
+ */
bool_t hasMapSensor : 1; // bit 0
bool_t hasIatSensor : 1; // bit 1
bool_t hasBaroSensor : 1; // bit 1
diff --git a/firmware/controllers/controllers.mk b/firmware/controllers/controllers.mk
index b114c8904b..97980ffc64 100644
--- a/firmware/controllers/controllers.mk
+++ b/firmware/controllers/controllers.mk
@@ -1,7 +1,6 @@
CONTROLLERSSRC = \
controllers/ignition_central.c \
- $(PROJECT_DIR)/controllers/malfunction_indicator.c \
$(PROJECT_DIR)/controllers/error_handling.c
CONTROLLERS_SRC_CPP = $(PROJECT_DIR)/controllers/settings.cpp \
@@ -12,6 +11,7 @@ CONTROLLERS_SRC_CPP = $(PROJECT_DIR)/controllers/settings.cpp \
controllers/injector_central.cpp \
controllers/idle_thread.cpp \
controllers/PwmTester.cpp \
+ $(PROJECT_DIR)/controllers/malfunction_indicator.cpp \
$(PROJECT_DIR)/controllers/alternatorController.cpp \
$(PROJECT_DIR)/controllers/lcd_controller.cpp \
$(PROJECT_DIR)/controllers/engine_controller.cpp
diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp
index 2affd11dfc..fb7aaa695e 100644
--- a/firmware/controllers/engine_controller.cpp
+++ b/firmware/controllers/engine_controller.cpp
@@ -513,13 +513,13 @@ void initEngineContoller(Engine *engine) {
#if EFI_MALFUNCTION_INDICATOR
if (engineConfiguration->isMilEnabled) {
- initMalfunctionIndicator();
+ initMalfunctionIndicator(engine);
}
#endif /* EFI_MALFUNCTION_INDICATOR */
#if EFI_MAP_AVERAGING
if (engineConfiguration->isMapAveragingEnabled) {
- initMapAveraging();
+ initMapAveraging(engine);
}
#endif /* EFI_MAP_AVERAGING */
diff --git a/firmware/controllers/malfunction_indicator.c b/firmware/controllers/malfunction_indicator.cpp
similarity index 98%
rename from firmware/controllers/malfunction_indicator.c
rename to firmware/controllers/malfunction_indicator.cpp
index 1eb5dbe7ec..6ea0cf7ed5 100644
--- a/firmware/controllers/malfunction_indicator.c
+++ b/firmware/controllers/malfunction_indicator.cpp
@@ -98,7 +98,7 @@ static msg_t mfiThread(void)
}
}
-void initMalfunctionIndicator(void) {
+void initMalfunctionIndicator(Engine *engine) {
// create static thread
chThdCreateStatic(mfiThreadStack, sizeof(mfiThreadStack), LOWPRIO, (tfunc_t) mfiThread, NULL);
// only for debug
diff --git a/firmware/controllers/malfunction_indicator.h b/firmware/controllers/malfunction_indicator.h
index 5fd3706e52..834dee0020 100644
--- a/firmware/controllers/malfunction_indicator.h
+++ b/firmware/controllers/malfunction_indicator.h
@@ -12,21 +12,12 @@
#define MALFUNCTION_INDICATOR_H_
#include "main.h"
+#include "engine.h"
#if EFI_MALFUNCTIONAL_INDICATOR
-#ifdef __cplusplus
-extern "C"
-{
-#endif /* __cplusplus */
-
-void initMalfunctionIndicator(void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif
+void initMalfunctionIndicator(Engine *engine);
+#endif /* EFI_MALFUNCTIONAL_INDICATOR */
#endif /* MALFUNCTION_INDICATOR_H_ */
diff --git a/firmware/controllers/map_averaging.cpp b/firmware/controllers/map_averaging.cpp
index 3e8175970a..5743c901db 100644
--- a/firmware/controllers/map_averaging.cpp
+++ b/firmware/controllers/map_averaging.cpp
@@ -124,7 +124,7 @@ static void endAveraging(void *arg) {
/**
* Shaft Position callback used to schedule start and end of MAP averaging
*/
-static void shaftPositionCallback(trigger_event_e ckpEventType, uint32_t index DECLARE_ENGINE_PARAMETER_S) {
+static void mapAveragingCallback(trigger_event_e ckpEventType, uint32_t index DECLARE_ENGINE_PARAMETER_S) {
// this callback is invoked on interrupt thread
if (index != 0)
@@ -170,7 +170,7 @@ float getMap(void) {
return getMapByVoltage(v_averagedMapValue);
}
-void initMapAveraging(void) {
+void initMapAveraging(Engine *engine) {
initLogging(&logger, "Map Averaging");
startTimer[0].name = "map start0";
@@ -178,7 +178,7 @@ void initMapAveraging(void) {
endTimer[0].name = "map end0";
endTimer[1].name = "map end1";
-// addTriggerEventListener(&shaftPositionCallback, "rpm reporter", NULL);
+ addTriggerEventListener(&mapAveragingCallback, "MAP averaging", engine);
addConsoleAction("faststat", showMapStats);
}
diff --git a/firmware/controllers/map_averaging.h b/firmware/controllers/map_averaging.h
index bd52af40a3..ee6b6b9700 100644
--- a/firmware/controllers/map_averaging.h
+++ b/firmware/controllers/map_averaging.h
@@ -8,16 +8,9 @@
#ifndef ADC_AVERAGING_H_
#define ADC_AVERAGING_H_
-#ifdef __cplusplus
-extern "C"
-{
-#endif /* __cplusplus */
+#include "engine.h"
void mapAveragingCallback(adcsample_t newValue);
-void initMapAveraging(void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+void initMapAveraging(Engine *engine);
#endif /* ADC_AVERAGING_H_ */
diff --git a/firmware/iar/ch.ewp b/firmware/iar/ch.ewp
index 7a10848bdc..5ea9c4dc82 100644
--- a/firmware/iar/ch.ewp
+++ b/firmware/iar/ch.ewp
@@ -2185,7 +2185,7 @@
$PROJ_DIR$\..\controllers\algo\main_trigger_callback.h
- $PROJ_DIR$\..\controllers\algo\malfunction_central.c
+ $PROJ_DIR$\..\controllers\algo\malfunction_central.cpp
$PROJ_DIR$\..\controllers\algo\malfunction_central.h