Open rhubarbdog opened 6 years ago
was_pressed()
and get_pressed()
are independent, so calling one does not clear the state of the other. Their state is also retained after a soft reboot (ctrl-D), as is the state of the display and some other internal things.
So if you execute a program that uses just was_pressed()
and press the button a lot, then do a soft reboot and execute a different program that uses just get_pressed()
(or vice versa) it will report all of the queued up button presses from before the soft reboot.
I achieve REPL using the program screen. When I break into a program by pressing control-C i have the option of giving my microbit a soft reboot by pressing control-D. the following 2 programs display behavior that i think is a bug using either of these listings and follow these steps to reproduce it.
getpresses.py.txt waspressed.py.txt
flash and execute the script of choice start REPL typing
screen /dev/ttyACM0 115200
press control-C to break the program and get a >>> python prompt press button A one or more times press control-D to soft reboot the microbitThe button_a.was_pressed() / button_a.get_pressses() code executes
surely not when a microbit has had a soft reboot, the
was_pressed()
method should return False andget_presses()
should return 0