clutch input via CAN #3605

This commit is contained in:
rusefillc 2021-12-15 17:48:21 -05:00
parent 34b6be08b1
commit 1a3f8d8b32
2 changed files with 20 additions and 6 deletions

View File

@ -312,6 +312,20 @@ void Engine::updateSlowSensors() {
#endif
}
static bool getClutchUpState() {
if (isBrainPinValid(engineConfiguration->clutchUpPin)) {
return engineConfiguration->clutchUpPinInverted ^ efiReadPin(engineConfiguration->clutchUpPin);
}
return engine->engineState.luaAdjustments.clutchUpState;
}
static bool getBrakePedalState() {
if (isBrainPinValid(engineConfiguration->throttlePedalUpPin)) {
return efiReadPin(engineConfiguration->brakePedalPin);
}
return engine->engineState.luaAdjustments.brakePedalState;
}
void Engine::updateSwitchInputs() {
#if EFI_GPIO_HARDWARE
// this value is not used yet
@ -326,16 +340,14 @@ void Engine::updateSwitchInputs() {
}
engine->acSwitchState = result;
}
if (isBrainPinValid(engineConfiguration->clutchUpPin)) {
engine->clutchUpState = engineConfiguration->clutchUpPinInverted ^ efiReadPin(engineConfiguration->clutchUpPin);
}
engine->clutchUpState = getClutchUpState();
if (isBrainPinValid(engineConfiguration->throttlePedalUpPin)) {
engine->idle.throttlePedalUpState = efiReadPin(engineConfiguration->throttlePedalUpPin);
}
if (isBrainPinValid(engineConfiguration->brakePedalPin)) {
engine->brakePedalState = efiReadPin(engineConfiguration->brakePedalPin);
}
engine->brakePedalState = getBrakePedalState();
#endif // EFI_GPIO_HARDWARE
}

View File

@ -19,6 +19,8 @@ struct LuaAdjustments {
float fuelAdd = 0;
float fuelMult = 1;
float etbTargetPositionAdd = 0;
bool clutchUpState = false;
bool brakePedalState = false;
};
class EngineState : public engine_state2_s {