force small delay between gpio connection comparisons

This commit is contained in:
ohsqueezy 2022-11-04 21:05:26 -04:00
parent f091e01605
commit d70c305626
1 changed files with 4 additions and 2 deletions

View File

@ -52,6 +52,9 @@ def connection2(pin_a, pin_b):
# Set all other pins to input pullup
GPIO.setup(pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
# Force 25ns delay between comparisons
time.sleep(0.025)
# pin_b can now be tested to see if if reads the LOW signal from pin_a
return GPIO.input(pin_b) == GPIO.LOW
@ -104,9 +107,8 @@ if __name__ == "__main__":
while True:
# Try all connections once each frame
for connection_ids, connection_state in connections():
for connection_ids, connection_state in connections().items():
# Only print connected combinations of pins
if connection_state:
pin_id_a, pin_id_b = connection_ids
print(f"{pin_id_a} ({pins[pin_id_a]}) <-> {pin_id_b} ({pins[pin_id_b]})")
time.sleep(0.1)