Skip to content

Commit

Permalink
omit module to disable it instead!
Browse files Browse the repository at this point in the history
  • Loading branch information
mck1117 committed Aug 30, 2024
1 parent 65809b1 commit c6f08c0
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 28 deletions.
3 changes: 2 additions & 1 deletion firmware/config/boards/hellen/small-can-board/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ DDEFS += -DEFI_SHAFT_POSITION_INPUT=FALSE
DDEFS += -DEFI_ALTERNATOR_CONTROL=FALSE
DDEFS += -DEFI_VVT_PID=FALSE
DDEFS += -DEFI_EMULATE_POSITION_SENSORS=FALSE
DDEFS += -DEFI_MAP_AVERAGING=FALSE
DDEFS += -DEFI_HPFP=FALSE
DDEFS += -DEFI_TOOTH_LOGGER=FALSE
DDEFS += -DRAM_UNUSED_SIZE=100

NO_MAP_AVERAGING = yes

DDEFS += -DHW_SMALL_CAN_BOARD=1

#Mass Storage
Expand Down
4 changes: 0 additions & 4 deletions firmware/config/stm32f4ems/efifeatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,6 @@
//#define EFI_MALFUNCTION_INDICATOR FALSE
#endif

#ifndef EFI_MAP_AVERAGING
#define EFI_MAP_AVERAGING TRUE
#endif

// todo: most of this should become configurable

// todo: switch to continuous ADC conversion for fast ADC?
Expand Down
4 changes: 2 additions & 2 deletions firmware/controllers/engine_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,9 @@ void commonInitEngineController() {
initElectronicThrottle();
#endif /* EFI_ELECTRONIC_THROTTLE_BODY */

#if EFI_MAP_AVERAGING
#ifdef MODULE_MAP_AVERAGING
initMapAveraging();
#endif /* EFI_MAP_AVERAGING */
#endif /* MODULE_MAP_AVERAGING */

#if EFI_BOOST_CONTROL
initBoostCtrl();
Expand Down
9 changes: 5 additions & 4 deletions firmware/controllers/modules/map_averaging/map_averaging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@

#include "pch.h"

#if EFI_MAP_AVERAGING

#include "trigger_central.h"

#if EFI_SENSOR_CHART
Expand Down Expand Up @@ -78,6 +76,11 @@ static void startAveraging(sampler* s) {
{ endAveraging, &averager });
}

void MapAverager::showInfo(const char* sensorName) const {
const auto value = get();
efiPrintf("Sensor \"%s\" is MAP averager: valid: %s value: %.2f averaged sample count: %d", sensorName, boolToString(value.Valid), value.Value, m_lastCounter);
}

void MapAverager::start(uint8_t cylinderIndex) {
chibios_rt::CriticalSectionLocker csl;

Expand Down Expand Up @@ -245,5 +248,3 @@ void MapAveragingModule::onConfigurationChange(engine_configuration_s const * pr
void initMapAveraging() {
applyMapMinBufferLength();
}

#endif /* EFI_MAP_AVERAGING */
6 changes: 0 additions & 6 deletions firmware/controllers/modules/map_averaging/map_averaging.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,11 @@

#include "sensor_converter_func.h"

#if EFI_MAP_AVERAGING

void initMapAveraging();

// allow smoothing up to number of cylinders
#define MAX_MAP_BUFFER_LENGTH (MAX_CYLINDER_COUNT)

#endif /* EFI_MAP_AVERAGING */

class MapAverager : public StoredValueSensor {
public:
MapAverager(SensorType type, efidur_t timeout)
Expand Down Expand Up @@ -50,7 +46,6 @@ MapAverager& getMapAvg(size_t idx);

class MapAveragingModule : public EngineModule {
public:
#if EFI_MAP_AVERAGING
void onConfigurationChange(engine_configuration_s const * previousConfig);

void onFastCallback() override;
Expand All @@ -60,5 +55,4 @@ class MapAveragingModule : public EngineModule {
float nextPhase) override;

void submitSample(float volts);
#endif // EFI_MAP_AVERAGING
};
5 changes: 4 additions & 1 deletion firmware/controllers/modules/modules.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
include $(PROJECT_DIR)/controllers/modules/fan/fan.mk
include $(PROJECT_DIR)/controllers/modules/fuel_pump/fuel_pump.mk
include $(PROJECT_DIR)/controllers/modules/gear_detector/gear_detector.mk
include $(PROJECT_DIR)/controllers/modules/map_averaging/map_averaging.mk
include $(PROJECT_DIR)/controllers/modules/trip_odometer/trip_odometer.mk

ifeq ($(NO_MAP_AVERAGING),)
include $(PROJECT_DIR)/controllers/modules/map_averaging/map_averaging.mk
endif
4 changes: 2 additions & 2 deletions firmware/controllers/sensors/impl/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ static void printMAPInfo() {
#if EFI_ANALOG_SENSORS
efiPrintf("instant value=%.2fkPa", Sensor::getOrZero(SensorType::Map));

#if EFI_MAP_AVERAGING
#ifdef MODULE_MAP_AVERAGING
efiPrintf("map type=%d/%s MAP=%.2fkPa mapMinBufferLength=%d", engineConfiguration->map.sensor.type,
getAir_pressure_sensor_type_e(engineConfiguration->map.sensor.type),
Sensor::getOrZero(SensorType::Map),
mapMinBufferLength);
#endif // EFI_MAP_AVERAGING
#endif // MODULE_MAP_AVERAGING

adc_channel_e mapAdc = engineConfiguration->map.sensor.hwChannel;
char pinNameBuffer[16];
Expand Down
5 changes: 0 additions & 5 deletions firmware/controllers/sensors/sensor_info_printing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ void Lps25Sensor::showInfo(const char* sensorName) const {
efiPrintf("%s: LPS25 baro %.2f kPa", sensorName, get().Value);
}

void MapAverager::showInfo(const char* sensorName) const {
const auto value = get();
efiPrintf("Sensor \"%s\" is MAP averager: valid: %s value: %.2f averaged sample count: %d", sensorName, boolToString(value.Valid), value.Value, m_lastCounter);
}

void LinearFunc::showInfo(float testRawValue) const {
efiPrintf(" Linear function slope: %.2f offset: %.2f min: %.1f max: %.1f", m_a, m_b, m_minOutput, m_maxOutput);
const auto value = convert(testRawValue);
Expand Down
6 changes: 6 additions & 0 deletions firmware/init/sensor/init_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ static FunctionalSensor slowMapSensor2(SensorType::MapSlow2, MS2NT(50));
static FunctionalSensor compressorDischargePress(SensorType::CompressorDischargePressure, MS2NT(50));
static FunctionalSensor throttleInletPress(SensorType::ThrottleInletPressure, MS2NT(50));

#ifdef MODULE_MAP_AVERAGING
// lowest reasonable idle is maybe 600 rpm
// one sample per cycle (1 cylinder, or "sample one cyl" mode) gives a period of 100ms
// add some margin -> 200ms timeout for fast MAP sampling
Expand All @@ -25,6 +26,7 @@ MapAverager fastMapSensor2(SensorType::MapFast2, MS2NT(200));
MapAverager& getMapAvg(size_t idx) {
return idx == 0 ? fastMapSensor : fastMapSensor2;
}
#endif // MODULE_MAP_AVERAGING

// Combine MAP sensors: prefer fast sensor, but use slow if fast is unavailable.
static FallbackSensor mapCombiner(SensorType::Map, SensorType::MapFast, SensorType::MapSlow);
Expand Down Expand Up @@ -102,17 +104,21 @@ void initMap() {

slowMapSensor.setFunction(mapConverter);
slowMapSensor2.setFunction(mapConverter);
#ifdef MODULE_MAP_AVERAGING
fastMapSensor.setFunction(mapConverter);
fastMapSensor2.setFunction(mapConverter);
#endif // MODULE_MAP_AVERAGING
compressorDischargePress.setFunction(mapConverter);
throttleInletPress.setFunction(mapConverter);

auto mapChannel = engineConfiguration->map.sensor.hwChannel;
if (isAdcChannelValid(mapChannel)) {
slowMapSensor.Register();
slowMapSensor2.Register();
#ifdef MODULE_MAP_AVERAGING
fastMapSensor.Register();
fastMapSensor2.Register();
#endif // MODULE_MAP_AVERAGING
mapCombiner.Register();
mapCombiner2.Register();

Expand Down
1 change: 0 additions & 1 deletion simulator/simulator/efifeatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@

#define EFI_USE_UART_DMA FALSE

#define EFI_MAP_AVERAGING TRUE
#define EFI_ALTERNATOR_CONTROL TRUE

#define EFI_ENGINE_AUDI_AAN FALSE
Expand Down
2 changes: 0 additions & 2 deletions unit_tests/efifeatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@

#define EFI_BOARD_TEST FALSE

#define EFI_MAP_AVERAGING TRUE

#define EFI_LUA TRUE

#define EFI_HPFP TRUE
Expand Down

0 comments on commit c6f08c0

Please sign in to comment.