smarter sleep logic

only:small-can-board
This commit is contained in:
rusefi 2023-10-17 22:15:36 -04:00
parent 5cce138d88
commit 8ee694010d
2 changed files with 18 additions and 4 deletions

View File

@ -74,8 +74,17 @@ end
canRxAdd(1, 0x17C, onPOWERTRAIN_DATA)
canRxAdd(1, 0x309, onCAR_SPEED)
commTimer = Timer.new()
commTimer : reset()
canDelay = 1
commDelay = 20
function onTick()
if (canTimer : getElapsedSeconds() > 20) and (secondsSinceTsActivity() > 20) then
if getOutput("isUsbConnected") == 1 then
commTimer : reset()
end
if (canTimer : getElapsedSeconds() > canDelay) and (commTimer : getElapsedSeconds() > commDelay) then
mcu_standby()
end
end

View File

@ -91,13 +91,18 @@ startPwm(1, 10, 0)
startPwm(2, 10, 0)
startPwm(3, 10, 0)
commTimer = Timer.new()
commTimer : reset()
canDelay = 1
commDelay = 20
function onTick()
if (canTimer : getElapsedSeconds() > canDelay) and (secondsSinceTsActivity() > commDelay) then
if getOutput("isUsbConnected") == 1 then
commTimer : reset()
end
if (canTimer : getElapsedSeconds() > canDelay) and (commTimer : getElapsedSeconds() > commDelay) then
mcu_standby()
end
handle()
handle()
end