Looks like the code, with the modification you've suggested works! I can get the coordinates of the touch that lead to the wake up of the M5. Thanks!
C
Latest posts made by cthulu
-
RE: M5 touch wakeup read coordinates
-
RE: M5 touch wakeup read coordinates
Thanks @felmue!
I will change that. Regarding reading the touch location, is that the proper way? First
M5.TP.update()
and then trying to clear the interrupt usingM5.TP.flush()
?I am trying render some buttons on the screen and then go to deep sleep, waiting for the touch push.
-
M5 touch wakeup read coordinates
Hi, I am trying to update my weatherapp (modified from an open source project) to wake up when the screen is touched. I want to read the coordinates after the wakeup, do something, and go back to deep sleep (for 1hr).
My proto-code is something like this
#include <M5EPD.h> M5EPD_Canvas canvas(&M5.EPD); int x, y= 0; void setup() { M5.begin(); M5.EPD.SetRotation(0); M5.EPD.Clear(true); canvas.createCanvas(960, 540); canvas.setTextSize(5); canvas.drawString("Touch The Screen!", 400, 20); canvas.pushCanvas(0, 0, UPDATE_MODE_DU4); } void loop() { if (M5.TP.available() || esp_sleep_get_wakeup_cause() == ESP_SLEEP_WAKEUP_TOUCHPAD) { M5.TP.update(); tp_finger_t fingerItem = M5.TP.readFinger(0); x = fingerItem.x; y = fingerItem.y; canvas.setTextSize(5); canvas.drawFloat(x, 0, 400, 60); canvas.drawFloat(y, 0, 400, 60); canvas.pushCanvas(0, 0, UPDATE_MODE_DU4); } // Clear out all previous touch screen interrupts while(digitalRead(GPIO_NUM_36) == LOW) { M5.TP.flush(); delay(10); } Serial.println("before sleep"); Serial.flush(); delay(1000); // Enable timer (3600 s) esp_sleep_enable_timer_wakeup(3600 * 1000000UL); esp_sleep_enable_ext0_wakeup(GPIO_NUM_36, LOW); gpio_hold_en((gpio_num_t) M5EPD_MAIN_PWR_PIN); gpio_deep_sleep_hold_en(); esp_deep_sleep_start(); // Only reached after light sleep Serial.println("after sleep"); delay(1000); }
Not sure this is the right way as I could not find any specific way to read the touch coordinates.