<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[M5  touch wakeup read coordinates]]></title><description><![CDATA[<p dir="auto">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).</p>
<p dir="auto">My proto-code is something like this</p>
<pre><code>#include &lt;M5EPD.h&gt;

M5EPD_Canvas canvas(&amp;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);
}
</code></pre>
<p dir="auto">Not sure this is the right way as I could not find any specific way to read the touch coordinates.</p>
]]></description><link>https://community.m5stack.com/topic/7352/m5-touch-wakeup-read-coordinates</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Mar 2026 13:40:29 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/7352.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 04 Mar 2025 08:39:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to M5  touch wakeup read coordinates on Thu, 06 Mar 2025 19:36:18 GMT]]></title><description><![CDATA[<p dir="auto">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!</p>
]]></description><link>https://community.m5stack.com/post/28416</link><guid isPermaLink="true">https://community.m5stack.com/post/28416</guid><dc:creator><![CDATA[cthulu]]></dc:creator><pubDate>Thu, 06 Mar 2025 19:36:18 GMT</pubDate></item><item><title><![CDATA[Reply to M5  touch wakeup read coordinates on Wed, 05 Mar 2025 09:07:33 GMT]]></title><description><![CDATA[<p dir="auto">Thanks <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/4037">@felmue</a>!</p>
<p dir="auto">I will change that. Regarding reading the touch location, is that the proper way? First <code>M5.TP.update()</code> and then trying to clear the interrupt using <code>M5.TP.flush()</code>?</p>
<p dir="auto">I am trying render some buttons on the screen and then go to deep sleep, waiting for the touch push.</p>
]]></description><link>https://community.m5stack.com/post/28399</link><guid isPermaLink="true">https://community.m5stack.com/post/28399</guid><dc:creator><![CDATA[cthulu]]></dc:creator><pubDate>Wed, 05 Mar 2025 09:07:33 GMT</pubDate></item><item><title><![CDATA[Reply to M5  touch wakeup read coordinates on Wed, 05 Mar 2025 03:38:39 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/242276">@cthulu</a></p>
<p dir="auto">you want to check against <code>ESP_SLEEP_WAKEUP_EXT0</code> as wake-up cause since the touch interrupt line (GPIO36) is setup using <code>esp_sleep_enable_ext0_wakeup()</code>.</p>
<p dir="auto">BTW: <code>ESP_SLEEP_WAKEUP_TOUCHPAD</code> is meant for an ESP32 feature where a GPIO can act as a touch sensor. See <a href="https://docs.espressif.com/projects/esp-idf/en/v5.4/esp32/api-reference/peripherals/touch_pad.html" target="_blank" rel="noopener noreferrer nofollow ugc">here</a> (Which is different from the touch screen).</p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/28394</link><guid isPermaLink="true">https://community.m5stack.com/post/28394</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Wed, 05 Mar 2025 03:38:39 GMT</pubDate></item></channel></rss>