From a463aab606782a5028e1faf77e742228a98e74d3 Mon Sep 17 00:00:00 2001 From: liltux Date: Wed, 8 Apr 2020 10:48:12 -0500 Subject: [PATCH 1/2] change read_region() add time.sleep(.3) delays and break(s) to exit loop upon touch. (my opinion) more responsive game. do not have to wait for timer to expire (30 seconds) between touches. --- CPX_Simon_Game/code.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CPX_Simon_Game/code.py b/CPX_Simon_Game/code.py index b8a3ee836..12f6ce0d7 100644 --- a/CPX_Simon_Game/code.py +++ b/CPX_Simon_Game/code.py @@ -59,18 +59,32 @@ def read_region(timeout=30): while time.time() - start_time < timeout: if cpx.touch_A1: val = PAD_REGION['A1'] + time.sleep(.3) + break elif cpx.touch_A2: val = PAD_REGION['A2'] + time.sleep(.3) + break elif cpx.touch_A3: val = PAD_REGION['A3'] + time.sleep(.3) + break elif cpx.touch_A4: val = PAD_REGION['A4'] + time.sleep(.3) + break elif cpx.touch_A5: val = PAD_REGION['A5'] + time.sleep(.3) + break elif cpx.touch_A6: val = PAD_REGION['A6'] + time.sleep(.3) + break elif cpx.touch_A7: val = PAD_REGION['A7'] + time.sleep(.3) + break return val def play_sequence(sequence): From 16c2bc5a394dfaf2fda2e772ff1833034feecf50 Mon Sep 17 00:00:00 2001 From: liltux Date: Fri, 10 Apr 2020 12:34:51 -0500 Subject: [PATCH 2/2] 'debug=false' fails remove 'debug=false' in decoder.decode_bits(pulses). It would crash the code as debug is not used. --- Circuit_Playground_Express_IR_Treasure_Hunt/CPX_Hunter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Circuit_Playground_Express_IR_Treasure_Hunt/CPX_Hunter.py b/Circuit_Playground_Express_IR_Treasure_Hunt/CPX_Hunter.py index dc9c7dea7..5a2f59670 100644 --- a/Circuit_Playground_Express_IR_Treasure_Hunt/CPX_Hunter.py +++ b/Circuit_Playground_Express_IR_Treasure_Hunt/CPX_Hunter.py @@ -31,7 +31,7 @@ # Try and decode them try: # Attempt to convert received pulses into numbers - received_code = tuple(decoder.decode_bits(pulses, debug=False)) + received_code = tuple(decoder.decode_bits(pulses)) except adafruit_irremote.IRNECRepeatException: # We got an unusual short code, probably a 'repeat' signal # print("NEC repeat!")