Closed patfelst closed 2 years ago
PS I just tried function if (M5.BtnA.pressedFor(1000))
also in the main loop and it never goes true when I hold BtnA. Should that work in Chimera?
hey @patfelst thanks for your feedback
The touch emulation is still a work in progress, indeed you need to call M5.update()
at least once before entering the loop, I'm still trying to figure out why (wild guess: touch is inited when I2C is busy, or is inited twice).
Button::pressedFor()
may act differently depending on the debounce value, native buttons (M5Classic) have a debounce of 10ms while the touch emulation has a default debounce set to 100ms.
You can eventually set a custom debounce with BtnA.setDebounce( 10 )
to see if things improve, but there are limits to what a touch button can provide as means to replace real buttons, and some information is lost in translation (e.g. multizone touch, drag, swipe are discarded).
Please let me know if you see some improvements and I'll integrate it in the next release.
I tried a reduced debounce time of 10ms, however Button::pressedFor()
is never becoming true.
I'm not sure how to debug this. It looks like the code is in /ESP32-Chimera-Core/src/drivers/common/Button/Button.cpp.
It looks quite different to the M5Stack code, so I'm assuming you re-wrote it? Is there a reason you had to change M5's code?
this is where the button states are evaluated, M5.update()
only calls M5Core2TouchButtonEmu->read();
M5 initial code was only compatible with M5Stack devices, which was too narrow for the scope of this library.
Also the TFT_eSPI driver was very old and inefficient, it was later replaced by an integrated (and now detached) version of LovyanGFX, but still 90% API compatible.
The Touch_Class from M5Unified is probably a better pick with its gesture implementation, but it also has its limits when emulating BtnA/BtnB/BtnC.
ok thanks. I'll try and debug.
What is M5Unified? Do you mean the original M5 Stack library? Are you able to show me how to include that just for the touch functionality? The main reason I am using Chimera is for the updated TFT_eSPI library.
M5Unified is the result of M5Stack (the company) recently asking the developer of LovyanGFX to implement M5GFX for them, it covers most M5Stack products, so it's multi device like Chimera-Core but focused on the product line of the M5Stack brand only.
https://github.com/m5stack/M5Unified << runs on M5Stack, M5Core2, M5Paper, M5Stick, M5Atom, etc
M5Unified sits on the M5GFX driver, which is a M5 flavoured version of LovyanGFX. So M5Unified is to M5GFX what Chimera-Core is to LovyanGFX.
https://github.com/m5stack/M5GFX <= same as => https://github.com/m5stack/LovyanGFX but narrowed to M5 products
I can't tell if Chimera Core can use the Touch_Class component from M5Unified without research, so it'll take some time before it happens.
You can eventually check issue #55 there's a standalone Touch buttons snippet, it does not use M5.update()
and may be easier to experiment with.
Thanks @tobozo. I didn't know about M5Unified, I will have a look.
Will also try the touch button snippet.
Hi again, still loving Chimera!
I'm using the touch button emulation (3 touch buttons at bottom of Core2 LCD) for the first time on Core2, and notice in the main loop if I test for
M5.BtnX.wasReleased()
(i.e. BtnA, BtnB or BtnC) it is always set true after boot up. I'm not sure if this is a Chimera library issue or not.A work around seems be to put a single call to
M5.update()
in setup(), but just wondering if you could make this false at ESP32 boot? It shouldn't be true until user has pressed then released a button for the first time.e.g. in this code I get BtnB released true after boot without touching any keys:
thank you.