How to use a button
I am missing something. I am using the M5GFX button to create buttons. How do I know when it has been touched (CoreS2)? If I check isPressed, it is always false.
At the beginning, I have it defined
`#include <M5GFX.h>
M5GFX display;
LGFX_Button startBtn; `
startBtn.initButton(&display, 150, 122, 150, 150, TFT_RED, TFT_GREEN, TFT_BLACK, "START", 4, 4); startBtn.drawButton();
This is in my setup.
In my loop
if (startBtn.justPressed()) { Serial.println("GET data"); collecting = true; } if (startBtn.isPressed()) { Serial.println("GET data pressed"); collecting = true; }
How do I get the start button to be recognized when it is touched?
You can refer to the example in Tab5 of this page.https://docs.m5stack.com/en/arduino/m5tab5/touch
The url goes to an empty page.
The url goes to an empty page.
Please copy the website address and paste it to view.
That showed an example. I will see if that works.
That worked (very slow to compile) so I will try to work it into what I had.
Hello, @Grandpa-G This just draws a button image. It expects the pressed state of the button to be set by user code via the press method. This function does not automatically get the touch state.