rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions
map.cpp File Reference

Detailed Description

See also map_averaging.cpp

Author
Andrey Belomutskiy, (c) 2012-2020

Definition in file map.cpp.

Functions

static float validateBaroMap (float mapKPa)
 
static void printMAPInfo ()
 
void initMapDecoder ()
 

Function Documentation

◆ initMapDecoder()

void initMapDecoder ( )

Definition at line 66 of file map.cpp.

66 {
68 // Read initial MAP sensor value and store it for Baro correction.
69 float storedInitialBaroPressure = Sensor::get(SensorType::MapSlow).value_or(STD_ATMOSPHERE);
70 efiPrintf("Get initial baro MAP pressure = %.2fkPa", storedInitialBaroPressure);
71 // validate if it's within a reasonable range (the engine should not be spinning etc.)
72 storedInitialBaroPressure = validateBaroMap(storedInitialBaroPressure);
73 if (!std::isnan(storedInitialBaroPressure)) {
74 efiPrintf("Using this fixed MAP pressure to override the baro correction!");
75
76 // TODO: do literally anything other than this
77 Sensor::setMockValue(SensorType::BarometricPressure, storedInitialBaroPressure);
78 } else {
79 efiPrintf("The baro pressure is invalid. The fixed baro correction will be disabled!");
80 }
81 }
82
83#if EFI_PROD_CODE
85#endif
86}
static void setMockValue(SensorType type, float value, bool mockRedundant=false)
Definition sensor.cpp:203
virtual SensorResult get() const =0
void addConsoleAction(const char *token, Void callback)
Register console action without parameters.
static constexpr engine_configuration_s * engineConfiguration
static void printMAPInfo()
Definition map.cpp:28
static float validateBaroMap(float mapKPa)
Definition map.cpp:16
@ BarometricPressure

Referenced by initSensors().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ printMAPInfo()

static void printMAPInfo ( )
static

Definition at line 28 of file map.cpp.

28 {
29#if EFI_ANALOG_SENSORS
30 efiPrintf("instant value=%.2fkPa", Sensor::getOrZero(SensorType::Map));
31
32#if EFI_MAP_AVERAGING && defined (MODULE_MAP_AVERAGING)
33 efiPrintf("map type=%d/%s MAP=%.2fkPa", engineConfiguration->map.sensor.type,
36#endif // EFI_MAP_AVERAGING
37
39 char pinNameBuffer[16];
40
41 efiPrintf("MAP %.2fv @%s",
42 adcGetRawVoltage("mapinfo", mapAdc).value_or(0),
43 getPinNameByAdcChannel("map", mapAdc, pinNameBuffer, sizeof(pinNameBuffer)));
44 if (engineConfiguration->map.sensor.type == MT_CUSTOM) {
45 efiPrintf("at %.2fv=%.2f at %.2fv=%.2f",
50 }
51
53 efiPrintf("baro type=%d value=%.2f", engineConfiguration->baroSensor.type, Sensor::get(SensorType::BarometricPressure).value_or(-1));
54 if (engineConfiguration->baroSensor.type == MT_CUSTOM) {
55 efiPrintf("min=%.2f@%.2f max=%.2f@%.2f",
60 }
61 }
62#endif /* EFI_ANALOG_SENSORS */
63}
expected< float > adcGetRawVoltage(const char *msg, adc_channel_e hwChannel)
const char * getAir_pressure_sensor_type_e(air_pressure_sensor_type_e value)
virtual bool hasSensor() const
Definition sensor.h:141
static float getOrZero(SensorType type)
Definition sensor.h:83
char * getPinNameByAdcChannel(const char *msg, adc_channel_e hwChannel, char *buffer, size_t bufferSize)

Referenced by initMapDecoder().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ validateBaroMap()

static float validateBaroMap ( float  mapKPa)
static

This function checks if Baro/MAP sensor value is inside of expected range

Returns
unchanged mapKPa parameter or NaN

Definition at line 16 of file map.cpp.

16 {
17 // Highest interstate is the Eisenhower Tunnel at 11158 feet -> 66 kpa
18 // Lowest point is the Dead Sea, -1411 feet -> 106 kpa
19 if (std::isnan(mapKPa) || mapKPa > 110 || mapKPa < 60) {
20 warning(ObdCode::OBD_Barometric_Press_Circ, "Invalid start-up baro pressure = %.2fkPa", mapKPa);
21 return NAN;
22 }
23 return mapKPa;
24}
bool warning(ObdCode code, const char *fmt,...)
@ OBD_Barometric_Press_Circ

Referenced by initMapDecoder().

Here is the call graph for this function:
Here is the caller graph for this function:

Go to the source code of this file.