Fixed reverse driving and improved disabling of pwmomat

This commit is contained in:
CommanderRedYT
2022-02-18 22:11:59 +01:00
parent 7222211c08
commit cc591cebc2

View File

@ -224,10 +224,16 @@ void DefaultMode::update()
pwmomat::wish = pwmomat::WISH::NONE;
pwmomat::enabled_time = now;
}
else if ((pwmomat::tempomat_pwm && pwmomat::enabled_time) && (espchrono::ago(*pwmomat::enabled_time) > 500ms) && (pwm >= std::min(*pwmomat::tempomat_pwm+10, 1500.f) || pwmomat::wish == pwmomat::WISH::WISH_DISABLE)) // disable tempomat when pwm is larger than saved pwm
else if ((pwmomat::tempomat_pwm && pwmomat::enabled_time) && (espchrono::ago(*pwmomat::enabled_time) > 500ms))
{
pwmomat::wish = pwmomat::WISH::NONE;
pwmomat::tempomat_pwm = std::nullopt;
if ((*pwmomat::tempomat_pwm >= 0 && (pwm >= *pwmomat::tempomat_pwm + 10 || pwm < -10)) ||
(*pwmomat::tempomat_pwm < 0 && (pwm <= *pwmomat::tempomat_pwm - 10 || pwm > 10)) ||
(pwmomat::wish == pwmomat::WISH::WISH_DISABLE)
)
{
pwmomat::wish = pwmomat::WISH::NONE;
pwmomat::tempomat_pwm = std::nullopt;
}
}
if (pwmomat::tempomat_pwm)