now it works

This commit is contained in:
Alexander Richter 2023-07-23 17:29:17 +02:00
parent 60be9d8736
commit 92cfa16212

View File

@ -96,7 +96,7 @@ BinSelKnobvalues = [[180,190,200,0,0,0,0,0,0,0,0,0,0,0,0,10,20,30,40,50,60,70,80
#Enable Quadrature Encoders #Enable Quadrature Encoders
QuadEncs = 2 QuadEncs = 2
QuadEncSig = [1,1] QuadEncSig = [2,2]
#1 = send up or down signal (typical use for selecting modes in hal) #1 = send up or down signal (typical use for selecting modes in hal)
#2 = send position signal (typical use for MPG wheel) #2 = send position signal (typical use for MPG wheel)
@ -395,32 +395,26 @@ while True:
elif cmd == "R": elif cmd == "R":
firstcom = 1 firstcom = 1
if JoySticks > 0: if JoySticks > 0:
for pins in range(JoySticks*2): for pins in range(JoySticks*2):
if io == JoyStickPins[pins]: if (io == JoyStickPins[pins]):
c["Counter.{}".format(io)] = value c["Counter.{}".format(io)] = value
if Debug: if (Debug):print("Counter.{}:{}".format(io,value))
print("Counter.{}:{}".format(io, value))
if QuadEncs > 0: if QuadEncs > 0:
if io not in counter_last_update:
counter_last_update[io] = 0
if time.time() - counter_last_update[io] >= min_update_interval:
global counter_last_update
if QuadEncSig[io]== 1: if QuadEncSig[io]== 1:
if value == 0: if value == 0:
c["CounterDown.{}".format(io)] = 1 c["CounterDown.{}".format(io)] = 1
counter_last_update[io] = time.time() # Set the last update time time.sleep(0.05)
elif value == 1: c["CounterDown.{}".format(io)] = 0
time.sleep(0.05)
if value == 1:
c["CounterUp.{}".format(io)] = 1 c["CounterUp.{}".format(io)] = 1
counter_last_update[io] = time.time() # Set the last update time time.sleep(0.05)
elif QuadEncSig[io] == 2: c["CounterUp.{}".format(io)] = 0
time.sleep(0.05)
if QuadEncSig[io]== 2:
c["Counter.{}".format(io)] = value c["Counter.{}".format(io)] = value
elif cmd == 'E': elif cmd == 'E':
arduino.write(b"E0:0\n") arduino.write(b"E0:0\n")
if (Debug):print("Sending E0:0 to establish contact") if (Debug):print("Sending E0:0 to establish contact")