Browse Source

debug set

main
gsd 8 months ago
parent
commit
6bc9abd1f7
  1. 13
      pipboyIO/next/serialAX.py

13
pipboyIO/next/serialAX.py

@ -11,6 +11,8 @@ import traceback
#1 - 102 - w s
#upButton = 1001
DEBUGIO = os.environ.get("DEBUGIO", False)
class MOVEMENT:
RIGHT = 1
NONE = 0
@ -41,6 +43,7 @@ class ENTER:
self.pin = 1001
self.enter = "xdotool key Return".split()
def __call__(self, data):
if DEBUGIO:
print(self.enter)
subprocess.Popen(self.enter)
@ -52,9 +55,11 @@ class AD:
def __call__(self, data):
if data[2] == MOVEMENT.LEFT:
if DEBUGIO:
print(self.a)
subprocess.Popen(self.a)
if data[2] == MOVEMENT.RIGHT:
if DEBUGIO:
print(self.d)
subprocess.Popen(self.d)
@ -66,9 +71,11 @@ class WS:
def __call__(self, data):
if data[2] == MOVEMENT.LEFT:
if DEBUGIO:
print(self.s)
subprocess.Popen(self.s)
if data[2] == MOVEMENT.RIGHT:
if DEBUGIO:
print(self.w)
subprocess.Popen(self.w)
@ -92,6 +99,7 @@ class MODE:
self.current_key = self.max_key
cmd = f"xdotool key {self.current_key}".split()
if DEBUGIO:
print(cmd)
subprocess.Popen(cmd)
@ -119,11 +127,13 @@ class Listener(asyncio.Protocol):
for line in lines[:-1]:
line = line.decode().replace("\r", "")
if DEBUGIO:
print(line)
try:
pin, value = line.split("*")
pin = int(pin)
value = int(value)
if DEBUGIO:
print(pin, value)
if pin not in self.store:
@ -133,8 +143,11 @@ class Listener(asyncio.Protocol):
self.useX(self.store[pin]())
except:
if DEBUGIO:
traceback.print_exc()
print("Cannot parse")
else:
pass
def useX(self, pin):
if pin[0].id in self.binds:

Loading…
Cancel
Save