2022-11-06 13:30:11 +00:00
|
|
|
"""Constants"""
|
|
|
|
ERROR_THRESHOLD = 350
|
|
|
|
OPEN_THRESHOLD = 190
|
|
|
|
CLOSED_THRESHOLD = 6*7
|
|
|
|
CLOSED_WANT = 4*7
|
2022-11-26 13:16:49 +00:00
|
|
|
MIN_IDLE_TIME = 0.5
|
2022-11-06 13:30:11 +00:00
|
|
|
|
|
|
|
UPDATE_RATE = 1
|
|
|
|
MAX_UPDATE_RATE = 20
|
|
|
|
COMMAND_IDLE_TIME = 0.5
|
|
|
|
|
|
|
|
class state:
|
|
|
|
IDLE, CLOSE, OPEN_THEN_CLOSE, OPEN, CLOSE_THEN_OPEN, ERROR, RESTART = range(7)
|
|
|
|
|
|
|
|
|
|
|
|
state_names = {
|
|
|
|
state.OPEN: "open",
|
|
|
|
state.CLOSE: "closed",
|
|
|
|
state.ERROR: "error",
|
|
|
|
state.OPEN_THEN_CLOSE: "open, then close",
|
|
|
|
state.CLOSE_THEN_OPEN: "close, then open",
|
|
|
|
state.RESTART: "reset MCU",
|
|
|
|
state.IDLE: "idle",
|
|
|
|
}
|
|
|
|
|
|
|
|
action_names = {
|
|
|
|
state.IDLE: "idling",
|
|
|
|
state.OPEN: "waiting for open door",
|
|
|
|
state.CLOSE: "waiting for closed door",
|
|
|
|
state.ERROR: "error",
|
|
|
|
}
|