parent
e2e2d67674
commit
6d72805a56
|
@ -631,3 +631,9 @@ void doScheduleStopEngine() {
|
|||
//backupRamFlush();
|
||||
#endif // EFI_PROD_CODE
|
||||
}
|
||||
|
||||
EngineRotationState * getEngineRotationState() {
|
||||
return &engine->rpmCalculator;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ InjectionEvent::InjectionEvent() {
|
|||
// Returns the start angle of this injector in engine coordinates (0-720 for a 4 stroke),
|
||||
// or unexpected if unable to calculate the start angle due to missing information.
|
||||
expected<float> InjectionEvent::computeInjectionAngle(int cylinderIndex) const {
|
||||
floatus_t oneDegreeUs = engine->rpmCalculator.oneDegreeUs; // local copy
|
||||
floatus_t oneDegreeUs = getEngineRotationState()->getOneDegreeUs(); // local copy
|
||||
if (cisnan(oneDegreeUs)) {
|
||||
// in order to have fuel schedule we need to have current RPM
|
||||
// wonder if this line slows engine startup?
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "scheduler.h"
|
||||
#include "stored_value_sensor.h"
|
||||
#include "timer.h"
|
||||
#include "rpm_calculator_api.h"
|
||||
|
||||
// we use this value in case of noise on trigger input lines
|
||||
#define NOISY_RPM -1
|
||||
|
@ -39,7 +40,7 @@ typedef enum {
|
|||
/**
|
||||
* Most consumers should access value via Sensor framework by SensorType::Rpm key
|
||||
*/
|
||||
class RpmCalculator : public StoredValueSensor {
|
||||
class RpmCalculator : public StoredValueSensor, public EngineRotationState {
|
||||
public:
|
||||
RpmCalculator();
|
||||
|
||||
|
@ -109,12 +110,17 @@ public:
|
|||
* this is RPM on previous engine cycle.
|
||||
*/
|
||||
int previousRpmValue = 0;
|
||||
|
||||
/**
|
||||
* This is a performance optimization: let's pre-calculate this each time RPM changes
|
||||
* NaN while engine is not spinning
|
||||
*/
|
||||
volatile floatus_t oneDegreeUs = NAN;
|
||||
|
||||
floatus_t getOneDegreeUs() override {
|
||||
return oneDegreeUs;
|
||||
}
|
||||
|
||||
Timer lastTdcTimer;
|
||||
|
||||
// RPM rate of change, in RPM per second
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
/**
|
||||
* @file rpm_calculator_api.h
|
||||
*/
|
||||
|
||||
#include "rusefi_types.h"
|
||||
|
||||
class EngineRotationState {
|
||||
public:
|
||||
virtual floatus_t getOneDegreeUs() = 0;
|
||||
};
|
||||
|
||||
EngineRotationState * getEngineRotationState();
|
Loading…
Reference in New Issue