refactoring: reducing code duplication

This commit is contained in:
rusefi 2017-10-16 14:19:41 -04:00
parent 02eed1c82c
commit 0fc9da6cfb
2 changed files with 3 additions and 10 deletions

View File

@ -34,11 +34,6 @@ TriggerEmulatorHelper::TriggerEmulatorHelper() {
EXTERN_ENGINE
;
static void fireShaftSignal(trigger_event_e signal) {
if (isUsefulSignal(signal, engineConfiguration))
hwHandleShaftSignal(signal);
}
void TriggerEmulatorHelper::handleEmulatorCallback(PwmConfig *state, int stateIndex) {
int prevIndex = (stateIndex + state->phaseCount - 1) % state->phaseCount;
@ -55,17 +50,17 @@ void TriggerEmulatorHelper::handleEmulatorCallback(PwmConfig *state, int stateIn
if (primaryWheelState != newPrimaryWheelState) {
primaryWheelState = newPrimaryWheelState;
fireShaftSignal(primaryWheelState ? SHAFT_PRIMARY_RISING : SHAFT_PRIMARY_FALLING);
hwHandleShaftSignal(primaryWheelState ? SHAFT_PRIMARY_RISING : SHAFT_PRIMARY_FALLING);
}
if (secondaryWheelState != newSecondaryWheelState) {
secondaryWheelState = newSecondaryWheelState;
fireShaftSignal(secondaryWheelState ? SHAFT_SECONDARY_RISING : SHAFT_SECONDARY_FALLING);
hwHandleShaftSignal(secondaryWheelState ? SHAFT_SECONDARY_RISING : SHAFT_SECONDARY_FALLING);
}
if (thirdWheelState != new3rdWheelState) {
thirdWheelState = new3rdWheelState;
fireShaftSignal(thirdWheelState ? SHAFT_3RD_RISING : SHAFT_3RD_FALLING);
hwHandleShaftSignal(thirdWheelState ? SHAFT_3RD_RISING : SHAFT_3RD_FALLING);
}
// print("hello %d\r\n", chTimeNow());

View File

@ -74,8 +74,6 @@ static void shaft_icu_period_callback(ICUDriver *icup) {
// icucnt_t last_period = icuGetPeriod(icup); so far we are fine with system time
trigger_event_e signal =
isPrimary ? SHAFT_PRIMARY_FALLING : SHAFT_SECONDARY_FALLING;
if (CONFIG(useOnlyRisingEdgeForTrigger))
return;
hwHandleShaftSignal(signal);
}