Closed Sarah-C closed 2 years ago
hey @Sarah-C thanks for your feedback,
Chimera-Core only implements BtnA/BtnB/BtnC as real buttons, although the TouchButton -> Button emulation is still being researched. there is no support for M5Core2 touch buttons via M5.Btnx
.
Since any M5Core2 feature added to the Chimera-Core should also benefit other devices equipped with display+touch, some problems must be solved first.
For example the M5Core2 is using a touch surface that is larger than the display surface, this is non standard. Also some custom devices can have both touch and real buttons, which invalidates the very idea of TouchButton -> Button emulation.
So I'm not sure whether I still should research in that direction, mixing touch and button cultures feels like opening a pandora box :-)
I understand!
That's some interesting and awkward hardware situations. Hm....
I wonder if it's worth me writing a shim to read in serial input and just pipe that through as a button instruction? The device would be stuck being connected to a PC, but the "buttons" would work. Say something like "btna 50" << press button a for 50 milliseconds?
Cheap hack I know.... but compared to the headache you've described... hackable in a short time!
On Mon, 9 Aug 2021 at 21:26, tobozo @.***> wrote:
hey @Sarah-C https://github.com/Sarah-C thanks for your feedback,
Chimera-Core only implements BtnA/BtnB/BtnC as real buttons, althgouth the TouchButton -> Button emulation is still being researched. there is no support for M5Core2 touch buttons via M5.Btnx.
Since any M5Core2 feature added to the Chimera-Core should also benefit other devices equipped with display+touch, some problems must be solved first.
For example the M5Core2 is using a touch surface that is larger than the display surface, this is non standard. Also some custom devices can have both touch and real buttons, which invalidates the very idea of TouchButton -> Button emulation.
So I'm not sure whether I still should research in that direction, mixing touch and button cultures feels like opening a pandora box :-)
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tobozo/ESP32-Chimera-Core/issues/55#issuecomment-895518133, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMDJHA3QFDK3KOJOKBERPTT4A2W5ANCNFSM5BKZG3EQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .
[edit] better example code
Are you planning to use this sketch on different M5Stack devices or will it only run on M5Core2 ?
If it's for M5Core2 only, buttons placed outside the display area can be accessed as follows:
#include <ESP32-Chimera-Core.h>
#define tft M5.Lcd
void setup()
{
M5.begin();
}
void loop()
{
uint16_t number = 0; // M5Core2 has no multi touch support so this number will always be zero, but the driver requires it
uint16_t button_zone_width = ((tft.width()+1)/3); // 1/3rd of the screen per button
uint16_t button_marginleft = 15; // dead space in pixels before and after each button to prevent overlap
uint16_t button_marginright = button_zone_width-button_marginleft;
bool pressed = false; // on release
int button_num = -1; // pressed button (0, 1, 2)
unsigned long startpress = millis();
unsigned long pressedfor = 0;
lgfx::touch_point_t tp; // touch coordinates will be stored there
number = tft.getTouch(&tp, 1);
while ( number>0 ) {
if( tp.y < tft.height() ) { // inside display area, no buttons there, just draw some circles to test coordinates
tft.fillCircle(tp.x, tp.y, 5, TFT_WHITE);
} else { // outside display area, find out what button zone is touched
uint16_t tpxmod = tp.x%button_zone_width; // convert touch position to button relative coords
// assign a button number only if touch position is between button margins
if( tpxmod > button_marginleft && tpxmod < button_marginright ) {
button_num = tp.x / button_zone_width;
pressed = true;
}
}
number = tft.getTouch(&tp, 1);
}
if( pressed && button_num > -1 ) {
pressedfor = millis() - startpress;
Serial.printf("M5Core2 Touch Button #%d was pressed for %d ms\n", button_num, (int)pressedfor );
// put your logic there e.g. if( button_num == 0 && pressed_for > 700 ) // BtnA longpress
}
}
Nope - it's exclusively running on the Core2 I have.
Your code is excellent, thank you for posting it.
xx
On Tue, 10 Aug 2021 at 10:25, tobozo @.***> wrote:
Are you planning to use this sketch on different M5Stack devices or will it only run on M5Core2 ?
If it's for M5Core2 only, buttons placed outside the display area can be accessed as follows:
include
define tft M5.Lcd
void setup() { M5.begin();
} void loop() { uint8_t number = 0; // multiple touch support requires zone number lgfx::touch_point_t tp; number = tft.getTouch(&tp, 1); bool pressed = false; unsigned long startpress = millis(); unsigned long pressedfor = 0; int button_num = -1;
while ( number>0 ) { if( tp.y < tft.height() ) { // inside display area, no buttons there, just draw some circles to test coordinates tft.fillCircle(tp.x, tp.y, 5, TFT_WHITE); } else { // outside display area, find out what zone is touched and assign a button number button_num = tp.x / (tft.width()/3); pressed = true; } number = tft.getTouch(&tp, 1); }
if( pressed && button_num > -1 ) { pressedfor = millis() - startpress; Serial.printf("M5Core2 Touch Button #%d was pressed for %d ms\n", button_num, (int)pressedfor ); // put your logic there e.g. if( button_num == 0 && pressed_for > 700 ) // BtnA longpress }
}
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tobozo/ESP32-Chimera-Core/issues/55#issuecomment-895874736, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMDJHCCMXFIZXBTQWT2BFDT4DWAFANCNFSM5BKZG3EQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .
bump
latest release (1.2.2) now implements full button emulation for M5Core2
thanks again for your feedback, closing this as solved
Expected: Pressing the buttons writes messages to the Serial output.
Result: No Serial output.
Changing the header to read: #include Makes the program work as expected.