mirror of
https://github.com/fishyboteso/fishyboteso.git
synced 2024-08-30 18:32:13 +00:00
add timeout to unblock idle state
This commit is contained in:
parent
6c4b00775e
commit
13319e2606
@ -1,7 +1,8 @@
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
from time import time, sleep
|
||||||
|
|
||||||
subscribers = []
|
subscribers = []
|
||||||
|
checkpoint = 0
|
||||||
|
|
||||||
class State(Enum):
|
class State(Enum):
|
||||||
IDLE = 0
|
IDLE = 0
|
||||||
@ -32,9 +33,17 @@ def loop(state_num: int):
|
|||||||
Executed in the start of the main loop in fishy.py
|
Executed in the start of the main loop in fishy.py
|
||||||
Changes modes, calls mode events (callbacks) when mode is changed
|
Changes modes, calls mode events (callbacks) when mode is changed
|
||||||
"""
|
"""
|
||||||
|
global checkpoint
|
||||||
FishingMode.CurrentMode = State(state_num)
|
FishingMode.CurrentMode = State(state_num)
|
||||||
|
|
||||||
if FishingMode.CurrentMode != FishingMode.PrevMode:
|
if FishingMode.CurrentMode != FishingMode.PrevMode:
|
||||||
|
checkpoint = time()
|
||||||
_notify(FishingMode.CurrentMode)
|
_notify(FishingMode.CurrentMode)
|
||||||
|
elif FishingMode.CurrentMode == State.LOOKING:
|
||||||
|
if time() - checkpoint > 5:
|
||||||
|
_notify(FishingMode.CurrentMode)
|
||||||
|
checkpoint = time()
|
||||||
|
else:
|
||||||
|
sleep(0.5)
|
||||||
|
|
||||||
FishingMode.PrevMode = FishingMode.CurrentMode
|
FishingMode.PrevMode = FishingMode.CurrentMode
|
||||||
|
Loading…
Reference in New Issue
Block a user