move swtiches out of idle (#2148)

This commit is contained in:
Matthew Kennedy 2020-12-26 18:31:41 -08:00 committed by GitHub
parent 8def663025
commit 898b7a82e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 26 deletions

View File

@ -471,32 +471,6 @@ static percent_t automaticIdleController(float tpsPos, float rpm, int targetRpm
wasResetPid = true; wasResetPid = true;
} }
#if EFI_GPIO_HARDWARE
// this value is not used yet
if (CONFIG(clutchDownPin) != GPIO_UNASSIGNED) {
engine->clutchDownState = efiReadPin(CONFIG(clutchDownPin));
}
if (hasAcToggle(PASS_ENGINE_PARAMETER_SIGNATURE)) {
bool result = getAcToggle(PASS_ENGINE_PARAMETER_SIGNATURE);
if (engine->acSwitchState != result) {
engine->acSwitchState = result;
engine->acSwitchLastChangeTime = getTimeNowUs();
}
engine->acSwitchState = result;
}
if (CONFIG(clutchUpPin) != GPIO_UNASSIGNED) {
engine->clutchUpState = efiReadPin(CONFIG(clutchUpPin));
}
if (CONFIG(throttlePedalUpPin) != GPIO_UNASSIGNED) {
engine->engineState.idle.throttlePedalUpState = efiReadPin(CONFIG(throttlePedalUpPin));
}
if (engineConfiguration->brakePedalPin != GPIO_UNASSIGNED) {
engine->brakePedalState = efiReadPin(engineConfiguration->brakePedalPin);
}
#endif /* EFI_GPIO_HARDWARE */
finishIdleTestIfNeeded(); finishIdleTestIfNeeded();
undoIdleBlipIfNeeded(); undoIdleBlipIfNeeded();

View File

@ -246,6 +246,8 @@ extern float vBattForTle8888;
* See also periodicFastCallback * See also periodicFastCallback
*/ */
void Engine::updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE) { void Engine::updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
updateSwitchInputs(PASS_ENGINE_PARAMETER_SIGNATURE);
#if EFI_ENGINE_CONTROL #if EFI_ENGINE_CONTROL
int rpm = GET_RPM(); int rpm = GET_RPM();
isEngineChartEnabled = CONFIG(isEngineChartEnabled) && rpm < CONFIG(engineSnifferRpmThreshold); isEngineChartEnabled = CONFIG(isEngineChartEnabled) && rpm < CONFIG(engineSnifferRpmThreshold);
@ -273,6 +275,33 @@ void Engine::updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
#endif #endif
} }
void Engine::updateSwitchInputs(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
#if EFI_GPIO_HARDWARE
// this value is not used yet
if (CONFIG(clutchDownPin) != GPIO_UNASSIGNED) {
engine->clutchDownState = efiReadPin(CONFIG(clutchDownPin));
}
if (hasAcToggle(PASS_ENGINE_PARAMETER_SIGNATURE)) {
bool result = getAcToggle(PASS_ENGINE_PARAMETER_SIGNATURE);
if (engine->acSwitchState != result) {
engine->acSwitchState = result;
engine->acSwitchLastChangeTime = getTimeNowUs();
}
engine->acSwitchState = result;
}
if (CONFIG(clutchUpPin) != GPIO_UNASSIGNED) {
engine->clutchUpState = efiReadPin(CONFIG(clutchUpPin));
}
if (CONFIG(throttlePedalUpPin) != GPIO_UNASSIGNED) {
engine->engineState.idle.throttlePedalUpState = efiReadPin(CONFIG(throttlePedalUpPin));
}
if (engineConfiguration->brakePedalPin != GPIO_UNASSIGNED) {
engine->brakePedalState = efiReadPin(engineConfiguration->brakePedalPin);
}
#endif // EFI_GPIO_HARDWARE
}
void Engine::onTriggerSignalEvent(efitick_t nowNt) { void Engine::onTriggerSignalEvent(efitick_t nowNt) {
isSpinning = true; isSpinning = true;
lastTriggerToothEventTimeNt = nowNt; lastTriggerToothEventTimeNt = nowNt;

View File

@ -252,6 +252,7 @@ public:
void periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE); void periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void periodicSlowCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE); void periodicSlowCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE); void updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void updateSwitchInputs(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void initializeTriggerWaveform(Logging *logger DECLARE_ENGINE_PARAMETER_SUFFIX); void initializeTriggerWaveform(Logging *logger DECLARE_ENGINE_PARAMETER_SUFFIX);
bool clutchUpState = false; bool clutchUpState = false;