From 3caf2ceb984d1af19fb3e3baf8a7ed5fd23509e2 Mon Sep 17 00:00:00 2001 From: William <82284393+cabiamdos@users.noreply.github.com> Date: Wed, 14 Feb 2024 03:16:43 +0100 Subject: [PATCH] added new wait_for_button_press functionality (#234) --- duckyinpython.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/duckyinpython.py b/duckyinpython.py index a0a6087..96a2a4e 100644 --- a/duckyinpython.py +++ b/duckyinpython.py @@ -97,6 +97,19 @@ def parseLine(line): led.value = False else: led.value = True + elif(line[0:21] == "WAIT_FOR_BUTTON_PRESS"): + button_pressed = False + # NOTE: we don't use assincio in this case because we want to block code execution + while not button_pressed: + button1.update() + + button1Pushed = button1.fell + button1Released = button1.rose + button1Held = not button1.value + + if(button1Pushed): + print("Button 1 pushed") + button_pressed = True else: newScriptLine = convertLine(line) runScriptLine(newScriptLine)