enjoying C++11
This commit is contained in:
parent
8aea068532
commit
655f43f61a
|
@ -78,10 +78,9 @@ private:
|
||||||
|
|
||||||
class Accelerometer {
|
class Accelerometer {
|
||||||
public:
|
public:
|
||||||
Accelerometer();
|
float x = 0; // G value
|
||||||
float x; // G value
|
float y = 0;
|
||||||
float y;
|
float z = 0;
|
||||||
float z;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SensorsState {
|
class SensorsState {
|
||||||
|
@ -120,10 +119,10 @@ public:
|
||||||
FuelConsumptionState();
|
FuelConsumptionState();
|
||||||
void addData(float durationMs);
|
void addData(float durationMs);
|
||||||
void update(efitick_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX);
|
void update(efitick_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
float perSecondConsumption;
|
float perSecondConsumption = 0;
|
||||||
float perMinuteConsumption;
|
float perMinuteConsumption = 0;
|
||||||
float perSecondAccumulator;
|
float perSecondAccumulator = 0;
|
||||||
float perMinuteAccumulator;
|
float perMinuteAccumulator = 0;
|
||||||
efitick_t accumulatedSecondPrevNt;
|
efitick_t accumulatedSecondPrevNt;
|
||||||
efitick_t accumulatedMinutePrevNt;
|
efitick_t accumulatedMinutePrevNt;
|
||||||
};
|
};
|
||||||
|
@ -156,24 +155,24 @@ public:
|
||||||
|
|
||||||
FuelConsumptionState fuelConsumption;
|
FuelConsumptionState fuelConsumption;
|
||||||
|
|
||||||
efitick_t crankingTime;
|
efitick_t crankingTime = 0;
|
||||||
efitick_t timeSinceCranking;
|
efitick_t timeSinceCranking = 0;
|
||||||
|
|
||||||
WarningCodeState warnings;
|
WarningCodeState warnings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* speed-density logic, calculated air mass in grams
|
* speed-density logic, calculated air mass in grams
|
||||||
*/
|
*/
|
||||||
float airMass;
|
float airMass = 0;
|
||||||
/**
|
/**
|
||||||
* speed-density logic, calculated air flow in kg/h for tCharge Air-Interp. method
|
* speed-density logic, calculated air flow in kg/h for tCharge Air-Interp. method
|
||||||
*/
|
*/
|
||||||
float airFlow;
|
float airFlow = 0;
|
||||||
|
|
||||||
float engineNoiseHipLevel;
|
float engineNoiseHipLevel = 0;
|
||||||
|
|
||||||
float auxValveStart;
|
float auxValveStart = 0;
|
||||||
float auxValveEnd;
|
float auxValveEnd = 0;
|
||||||
|
|
||||||
ThermistorMath iatCurve;
|
ThermistorMath iatCurve;
|
||||||
ThermistorMath cltCurve;
|
ThermistorMath cltCurve;
|
||||||
|
@ -182,67 +181,68 @@ public:
|
||||||
* MAP averaging angle start, in relation to 'mapAveragingSchedulingAtIndex' trigger index index
|
* MAP averaging angle start, in relation to 'mapAveragingSchedulingAtIndex' trigger index index
|
||||||
*/
|
*/
|
||||||
angle_t mapAveragingStart[INJECTION_PIN_COUNT];
|
angle_t mapAveragingStart[INJECTION_PIN_COUNT];
|
||||||
angle_t mapAveragingDuration;
|
angle_t mapAveragingDuration = 0;
|
||||||
|
|
||||||
// spark-related
|
// spark-related
|
||||||
floatms_t sparkDwell;
|
floatms_t sparkDwell = 0;
|
||||||
angle_t timingAdvance;
|
angle_t timingAdvance = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ignition dwell duration as crankshaft angle
|
* ignition dwell duration as crankshaft angle
|
||||||
* NAN if engine is stopped
|
* NAN if engine is stopped
|
||||||
*/
|
*/
|
||||||
angle_t dwellAngle;
|
angle_t dwellAngle = NAN;
|
||||||
|
|
||||||
angle_t cltTimingCorrection;
|
angle_t cltTimingCorrection = 0;
|
||||||
|
|
||||||
// fuel-related;
|
// fuel-related;
|
||||||
float iatFuelCorrection;
|
float iatFuelCorrection = 0;
|
||||||
float cltFuelCorrection;
|
float cltFuelCorrection = 0;
|
||||||
float postCrankingFuelCorrection;
|
float postCrankingFuelCorrection = 0;
|
||||||
float fuelCutoffCorrection;
|
float fuelCutoffCorrection = 0;
|
||||||
efitick_t coastingFuelCutStartTime;
|
efitick_t coastingFuelCutStartTime = 0;
|
||||||
/**
|
/**
|
||||||
* injectorLag(VBatt)
|
* injectorLag(VBatt)
|
||||||
*
|
*
|
||||||
* this value depends on a slow-changing VBatt value, so
|
* this value depends on a slow-changing VBatt value, so
|
||||||
* we update it once in a while
|
* we update it once in a while
|
||||||
*/
|
*/
|
||||||
floatms_t injectorLag;
|
floatms_t injectorLag = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See useWarmupPidAfr
|
* See useWarmupPidAfr
|
||||||
*/
|
*/
|
||||||
Pid warmupAfrPid;
|
Pid warmupAfrPid;
|
||||||
float warmupTargetAfr;
|
float warmupTargetAfr = 0;
|
||||||
|
|
||||||
float baroCorrection;
|
float baroCorrection = 0;
|
||||||
|
|
||||||
// speed density
|
// speed density
|
||||||
// Rate-of-change limiter is applied to degrees, so we store both Kelvin and degrees.
|
// Rate-of-change limiter is applied to degrees, so we store both Kelvin and degrees.
|
||||||
float tCharge, tChargeK;
|
float tCharge = 0;
|
||||||
|
float tChargeK = 0;
|
||||||
efitick_t timeSinceLastTChargeK;
|
efitick_t timeSinceLastTChargeK;
|
||||||
|
|
||||||
float currentVE;
|
float currentVE = 0;
|
||||||
float targetAFR;
|
float targetAFR = 0;
|
||||||
|
|
||||||
int vssEventCounter;
|
int vssEventCounter = 0;
|
||||||
int totalLoggedBytes;
|
int totalLoggedBytes = 0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pre-calculated value from simple fuel lookup
|
* pre-calculated value from simple fuel lookup
|
||||||
*/
|
*/
|
||||||
floatms_t baseTableFuel;
|
floatms_t baseTableFuel = 0;
|
||||||
/**
|
/**
|
||||||
* Raw fuel injection duration produced by current fuel algorithm, without any correction
|
* Raw fuel injection duration produced by current fuel algorithm, without any correction
|
||||||
*/
|
*/
|
||||||
floatms_t baseFuel;
|
floatms_t baseFuel = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* closed-loop fuel correction
|
* closed-loop fuel correction
|
||||||
*/
|
*/
|
||||||
floatms_t fuelPidCorrection;
|
floatms_t fuelPidCorrection = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Total fuel with CLT, IAT and TPS acceleration corrections per cycle,
|
* Total fuel with CLT, IAT and TPS acceleration corrections per cycle,
|
||||||
|
@ -251,14 +251,14 @@ public:
|
||||||
* @see baseFuel
|
* @see baseFuel
|
||||||
* @see actualLastInjection
|
* @see actualLastInjection
|
||||||
*/
|
*/
|
||||||
floatms_t runningFuel;
|
floatms_t runningFuel = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TPS acceleration: extra fuel amount
|
* TPS acceleration: extra fuel amount
|
||||||
*/
|
*/
|
||||||
floatms_t tpsAccelEnrich;
|
floatms_t tpsAccelEnrich = 0;
|
||||||
|
|
||||||
angle_t injectionOffset;
|
angle_t injectionOffset = 0;
|
||||||
|
|
||||||
#if EFI_ENABLE_MOCK_ADC || defined(__DOXYGEN__)
|
#if EFI_ENABLE_MOCK_ADC || defined(__DOXYGEN__)
|
||||||
MockAdcState mockAdcState;
|
MockAdcState mockAdcState;
|
||||||
|
|
|
@ -77,8 +77,6 @@ void MockAdcState::setMockVoltage(int hwChannel, float voltage) {
|
||||||
#endif /* EFI_ENABLE_MOCK_ADC */
|
#endif /* EFI_ENABLE_MOCK_ADC */
|
||||||
|
|
||||||
FuelConsumptionState::FuelConsumptionState() {
|
FuelConsumptionState::FuelConsumptionState() {
|
||||||
perSecondConsumption = perSecondAccumulator = 0;
|
|
||||||
perMinuteConsumption = perMinuteAccumulator = 0;
|
|
||||||
accumulatedSecondPrevNt = accumulatedMinutePrevNt = getTimeNowNt();
|
accumulatedSecondPrevNt = accumulatedMinutePrevNt = getTimeNowNt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,33 +104,10 @@ void FuelConsumptionState::update(efitick_t nowNt DECLARE_ENGINE_PARAMETER_SUFFI
|
||||||
}
|
}
|
||||||
|
|
||||||
TransmissionState::TransmissionState() {
|
TransmissionState::TransmissionState() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EngineState::EngineState() {
|
EngineState::EngineState() {
|
||||||
dwellAngle = NAN;
|
|
||||||
engineNoiseHipLevel = 0;
|
|
||||||
injectorLag = 0;
|
|
||||||
crankingTime = 0;
|
|
||||||
timeSinceCranking = 0;
|
|
||||||
vssEventCounter = 0;
|
|
||||||
targetAFR = 0;
|
|
||||||
tpsAccelEnrich = 0;
|
|
||||||
tCharge = tChargeK = 0;
|
|
||||||
timeSinceLastTChargeK = getTimeNowNt();
|
timeSinceLastTChargeK = getTimeNowNt();
|
||||||
airFlow = 0;
|
|
||||||
cltTimingCorrection = 0;
|
|
||||||
runningFuel = baseFuel = currentVE = 0;
|
|
||||||
baseTableFuel = iatFuelCorrection = 0;
|
|
||||||
fuelPidCorrection = 0;
|
|
||||||
cltFuelCorrection = postCrankingFuelCorrection = 0;
|
|
||||||
warmupTargetAfr = airMass = 0;
|
|
||||||
baroCorrection = timingAdvance = 0;
|
|
||||||
sparkDwell = mapAveragingDuration = 0;
|
|
||||||
totalLoggedBytes = injectionOffset = 0;
|
|
||||||
auxValveStart = auxValveEnd = 0;
|
|
||||||
fuelCutoffCorrection = 0;
|
|
||||||
coastingFuelCutStartTime = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EngineState::updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
void EngineState::updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
|
@ -255,16 +230,11 @@ int MockAdcState::getMockAdcValue(int hwChannel) {
|
||||||
return fakeAdcValues[hwChannel];
|
return fakeAdcValues[hwChannel];
|
||||||
}
|
}
|
||||||
|
|
||||||
Accelerometer::Accelerometer() {
|
|
||||||
x = y = z = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SensorsState::reset() {
|
void SensorsState::reset() {
|
||||||
fuelTankGauge = vBatt = 0;
|
fuelTankGauge = vBatt = 0;
|
||||||
iat = clt = NAN;
|
iat = clt = NAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
StartupFuelPumping::StartupFuelPumping() {
|
StartupFuelPumping::StartupFuelPumping() {
|
||||||
isTpsAbove50 = false;
|
isTpsAbove50 = false;
|
||||||
pumpsCounter = 0;
|
pumpsCounter = 0;
|
||||||
|
|
Loading…
Reference in New Issue