progress: rpm register based on trigger input being none or not (#4691)

* progress: rpm register based on trigger input being none or not

* use helper functions

Co-authored-by: rusefillc <sdfsdfqsf2334234234>
This commit is contained in:
rusefillc 2022-10-22 09:27:41 -04:00 committed by GitHub
parent 983f88709a
commit 98076927b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 27 deletions

View File

@ -475,14 +475,6 @@ void commonInitEngineController() {
engine->rpmCalculator.Register();
#endif /* EFI_UNIT_TEST */
#if EFI_SHAFT_POSITION_INPUT
/**
* there is an implicit dependency on the fact that 'tachometer' listener is the 1st listener - this case
* other listeners can access current RPM value
*/
initRpmCalculator();
#endif /* EFI_SHAFT_POSITION_INPUT */
#if (EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT) || EFI_SIMULATOR || EFI_UNIT_TEST
if (engineConfiguration->isEngineControlEnabled) {
initAuxValves();

View File

@ -381,21 +381,6 @@ void tdcMarkCallback(
}
}
void initRpmCalculator() {
#if ! HW_CHECK_MODE
if (hasFirmwareError()) {
return;
}
#endif // HW_CHECK_MODE
// Only register if not configured to read RPM over OBD2
if (!engineConfiguration->consumeObdSensors) {
engine->rpmCalculator.Register();
}
}
/**
* Schedules a callback 'angle' degree of crankshaft from now.
* The callback would be executed once after the duration of time which

View File

@ -174,10 +174,6 @@ void rpmShaftPositionCallback(trigger_event_e ckpSignalType, uint32_t trgEventIn
void tdcMarkCallback(
uint32_t trgEventIndex, efitick_t edgeTimestamp);
/**
* @brief Initialize RPM calculator
*/
void initRpmCalculator();
operation_mode_e lookupOperationMode();
#define getRevolutionCounter() (engine->rpmCalculator.getRevolutionCounterM())

View File

@ -183,9 +183,20 @@ void startTriggerDebugPins() {
}
void applyNewTriggerInputPins() {
if (hasFirmwareError()) {
return;
}
#if EFI_PROD_CODE
// first we will turn off all the changed pins
stopTriggerInputPins();
if (isConfigurationChanged(triggerInputDebugPins[0])) {
engine->rpmCalculator.unregister();
if (isBrainPinValid(engineConfiguration->triggerInputDebugPins[0])) {
// if we do not have primary input channel maybe it's BCM mode and we inject RPM value via Lua?
engine->rpmCalculator.Register();
}
}
// then we will enable all the changed pins
startTriggerInputPins();
#endif /* EFI_PROD_CODE */