Trigger: Question: something strange trigger errors #662

refactoring towards an improvement
This commit is contained in:
rusefi 2019-01-14 10:58:38 -05:00
parent 3ba624e279
commit be7df42f43
4 changed files with 41 additions and 34 deletions

View File

@ -23,6 +23,7 @@
#include "settings.h"
#include "aux_valves.h"
#include "map_averaging.h"
#include "fsio_impl.h"
#if EFI_PROD_CODE || defined(__DOXYGEN__)
#include "injector_central.h"
@ -84,9 +85,38 @@ void Engine::initializeTriggerShape(Logging *logger DECLARE_ENGINE_PARAMETER_SUF
if (!TRIGGER_SHAPE(shapeDefinitionError)) {
prepareOutputSignals(PASS_ENGINE_PARAMETER_SIGNATURE);
}
}
static void cylinderCleanupControl(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
bool newValue;
if (engineConfiguration->isCylinderCleanupEnabled) {
newValue = !engine->rpmCalculator.isRunning(PASS_ENGINE_PARAMETER_SIGNATURE) && getTPS(PASS_ENGINE_PARAMETER_SIGNATURE) > CLEANUP_MODE_TPS;
} else {
newValue = false;
}
if (newValue != engine->isCylinderCleanupMode) {
engine->isCylinderCleanupMode = newValue;
scheduleMsg(&engineLogger, "isCylinderCleanupMode %s", boolToString(newValue));
}
#endif
}
void Engine::periodicSlowCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
watchdog();
updateSlowSensors(PASS_ENGINE_PARAMETER_SIGNATURE);
checkShutdown();
#if EFI_FSIO || defined(__DOXYGEN__)
runFsio(PASS_ENGINE_PARAMETER_SIGNATURE);
#endif /* EFI_PROD_CODE && EFI_FSIO */
cylinderCleanupControl(PASS_ENGINE_PARAMETER_SIGNATURE);
slowCallBackWasInvoked = TRUE;
}
/**
* We are executing these heavy (logarithm) methods from outside the trigger callbacks for performance reasons.
* See also periodicFastCallback

View File

@ -324,6 +324,14 @@ public:
#endif /* EFI_ENABLE_CRITICAL_ENGINE_STOP */
};
/**
* I am not sure if this needs to be configurable.
*
* Also technically the whole feature might be implemented as cranking fuel coefficient curve by TPS.
*/
// todo: not great location for these
#define CLEANUP_MODE_TPS 90
#define STEPPER_PARKING_TPS CLEANUP_MODE_TPS
class Engine {
public:
@ -434,6 +442,7 @@ public:
floatms_t actualLastInjection;
void periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void periodicSlowCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void initializeTriggerShape(Logging *logger DECLARE_ENGINE_PARAMETER_SUFFIX);

View File

@ -213,21 +213,6 @@ efitimesec_t getTimeNowSeconds(void) {
#endif /* EFI_PROD_CODE */
static void cylinderCleanupControl(Engine *engine) {
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
bool newValue;
if (engineConfiguration->isCylinderCleanupEnabled) {
newValue = !engine->rpmCalculator.isRunning(PASS_ENGINE_PARAMETER_SIGNATURE) && getTPS(PASS_ENGINE_PARAMETER_SIGNATURE) > CLEANUP_MODE_TPS;
} else {
newValue = false;
}
if (newValue != engine->isCylinderCleanupMode) {
engine->isCylinderCleanupMode = newValue;
scheduleMsg(&logger, "isCylinderCleanupMode %s", boolToString(newValue));
}
#endif
}
static LocalVersionHolder versionForConfigurationListeners;
static void periodicSlowCallback(Engine *engine);
@ -328,17 +313,8 @@ static void periodicSlowCallback(Engine *engine) {
engine->engineState.warmupAfrPid.reset();
}
engine->watchdog();
engine->updateSlowSensors();
engine->checkShutdown();
engine->periodicSlowCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
#if EFI_FSIO || defined(__DOXYGEN__)
runFsio(PASS_ENGINE_PARAMETER_SIGNATURE);
#endif /* EFI_PROD_CODE && EFI_FSIO */
cylinderCleanupControl(engine);
engine->slowCallBackWasInvoked = TRUE;
scheduleNextSlowInvocation();
}

View File

@ -14,14 +14,6 @@
#include "engine_configuration.h"
#include "engine.h"
/**
* I am not sure if this needs to be configurable.
*
* Also technically the whole feature might be implemented as cranking fuel coefficient curve by TPS.
*/
#define CLEANUP_MODE_TPS 90
#define STEPPER_PARKING_TPS CLEANUP_MODE_TPS
char * getPinNameByAdcChannel(const char *msg, adc_channel_e hwChannel, char *buffer);
void initPeriodicEvents(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void initEngineContoller(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX);