1
0
Fork 0
mirror of https://github.com/dbarzin/pandora-box.git synced 2025-07-19 05:19:40 +02:00
pandora-box/tests/states.py

39 lines
846 B
Python
Raw Normal View History

2023-02-12 18:10:04 +01:00
#!/usr/bin/python3
def waitMouseClick():
print("wait mouse click")
2023-02-25 18:59:41 +01:00
mouse = open("/dev/input/mice", "rb")
down = False
2023-02-12 18:10:04 +01:00
while True:
buf = mouse.read(3)
2023-02-25 18:59:41 +01:00
if ((buf[0] & 0x1) == 1):
2023-02-12 18:10:04 +01:00
down = True
2023-02-25 18:59:41 +01:00
if (((buf[0] & 0x1) == 0) and down):
break
2023-02-12 18:10:04 +01:00
mouse.close()
2023-02-25 18:59:41 +01:00
2023-02-12 18:10:04 +01:00
def loop(state):
2023-02-25 18:59:41 +01:00
print('loop ' + state)
2023-02-12 18:10:04 +01:00
match state:
case "START":
waitMouseClick()
return "STEP1"
case "STEP1":
waitMouseClick()
return "STEP2"
case "STEP2":
waitMouseClick()
return "STOP"
case _:
2023-02-25 18:59:41 +01:00
print("Unknwn state " + state)
2023-02-12 18:10:04 +01:00
return "STOP"
print("end loop")
if __name__ == "__main__":
# The client code.
2023-02-25 18:59:41 +01:00
state = "START"
while (state != "STOP"):
2023-02-12 18:10:04 +01:00
state = loop(state)