The button has three functions:
In the code, starting around line 37, the first two types of press are being used, but the long press currently does nothing.
For each type, doing the press toggles between showing something on the screen and showing the data you have chosen to display.
The structure of the working buttons is:
async def wait_press(e, lcd):
global data
while True:
await e.wait()
e.clear()
print("Debugging: button pressed")
if data == True:
# do something
data = False
else:
lcd[0] = ""
lcd[1] = ""
data = True
Breaking this down:
async def starts the function, there is one for each type of button pressglobal data accesses the variable that checks whether you are 'data collection mode' or notwhile True: always do the following codeawait e.wait(), e.clear() background set up codeprint(): give you some information to help with debuggingif data == True: are you currently displaying data? If True, do something new.data = False if you are doing something else, you are not in data collection mode, so let the code know thiselse: if you are NOT in data collection mode, clear the display, and put yourself back into data mode - this is how you 'exit' the new code and go back to displaying the data.The code feels complicated, but what you are doing is either displaying the data set up further down in your code, or displaying something else.
To start with, leave button press and double press alone, as they do useful things, and edit the long press code only.
if data = True: else:).If you are confident editing the button presses, you can also change the behaviour of the other two.