rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
init_lambda.cpp
Go to the documentation of this file.
1#include "pch.h"
2
3#include "init.h"
4#include "adc_subscription.h"
6#include "live_data.h"
7
8struct GetAfrWrapper {
9 float getLambda() {
10 return getAfr(SensorType::Lambda1) / STOICH_RATIO;
11 };
12 float getLambda2() {
13 return getAfr(SensorType::Lambda2) / STOICH_RATIO;
14 }
15};
16
17static GetAfrWrapper afrWrapper;
18
20[]() {
21 return afrWrapper.getLambda();
22});
23
25[]() {
26 return afrWrapper.getLambda2();
27});
28
29#include "AemXSeriesLambda.h"
30
31#if EFI_CAN_SUPPORT
34#endif
35
36template <>
37const wideband_state_s* getLiveData(size_t idx) {
38#if EFI_CAN_SUPPORT
39 switch (idx) {
40 case 0:
42 return &aem1;
43 case 1:
45 return &aem2;
46 }
47#endif
48
49 return nullptr;
50}
51
52void initLambda() {
53 // first we register the smoothed sensors for the early return on the can wbo case
56
57#if EFI_CAN_SUPPORT
60 criticalError("CAN read and write are required to use CAN wideband.");
61 return;
62 }
63
66
67 return;
68 }
69#endif
70
71#if EFI_UNIT_TEST
72 constexpr bool isUnitTest = true;
73#else
74 constexpr bool isUnitTest = false;
75#endif
76
77 // CANbus option is handled above, let's handle analog inputs conditionally to give Lua sensors a chance
80 }
83 }
84}
bool isAdcChannelValid(adc_channel_e hwChannel)
Definition adc_inputs.h:23
void registerCanSensor(CanSensorBase &sensor)
Definition can_rx.cpp:92
bool Register()
Definition sensor.cpp:131
float getAfr(SensorType type)
Definition ego.cpp:25
StoredValueSensor smoothedLambda2Sensor(SensorType::SmoothedLambda2, MS2NT(500))
StoredValueSensor smoothedLambda1Sensor(SensorType::SmoothedLambda1, MS2NT(500))
static constexpr engine_configuration_s * engineConfiguration
A sensor to provide a bridge from old getX()-style functions to the new sensor registry.
const wideband_state_s * getLiveData(size_t idx)
static FunctionPointerSensor lambdaSensor2(SensorType::Lambda2, []() { return afrWrapper.getLambda2();})
void initLambda()
static FunctionPointerSensor lambdaSensor(SensorType::Lambda1, []() { return afrWrapper.getLambda();})
static AemXSeriesWideband aem2(1, SensorType::Lambda2)
static AemXSeriesWideband aem1(0, SensorType::Lambda1)
static GetAfrWrapper afrWrapper