<?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[How should I resume work after calling M5.shutdown()?]]></title><description><![CDATA[<p dir="auto">I modified the RTC example for the M5Paper to call <code>M5.shutdown</code> instead of <code>delay</code>. However, when I do this, the time is no longer written to the screen. If the device is plugged into a computer, the screen is correctly updated (but I think this is because <code>M5.shutdown</code> has no effect when plugged into power).</p>
<p dir="auto">Is there some change I need to make to correctly resume work after calling <code>M5.shutdown()</code>?</p>
<pre><code>#include &lt;M5EPD.h&gt;

M5EPD_Canvas canvas(&amp;M5.EPD);

rtc_time_t RTCtime;
rtc_date_t RTCDate;

char timeStrbuff[64];

void flushTime(){
    M5.RTC.getTime(&amp;RTCtime);
    M5.RTC.getDate(&amp;RTCDate);
    
    sprintf(timeStrbuff,"%d/%02d/%02d %02d:%02d:%02d",
                        RTCDate.year,RTCDate.mon,RTCDate.day,
                        RTCtime.hour,RTCtime.min,RTCtime.sec);
                                         
    canvas.drawString(timeStrbuff, 0, 0);
    canvas.pushCanvas(100,200,UPDATE_MODE_DU4);
}

void setupTime(){
  
  RTCtime.hour = 17;
  RTCtime.min = 47;
  RTCtime.sec = 0;
  M5.RTC.setTime(&amp;RTCtime);
  
  RTCDate.year = 2021;
  RTCDate.mon = 2;
  RTCDate.day = 7;
  M5.RTC.setDate(&amp;RTCDate);
}

void setup() {

    M5.begin();
    M5.EPD.SetRotation(90);
    M5.EPD.Clear(true);
    M5.RTC.begin();
    canvas.createCanvas(400, 300);
    canvas.setTextSize(3);
    setupTime();
}

void loop() {
  flushTime();
  M5.shutdown(60);
}
</code></pre>
]]></description><link>https://community.m5stack.com/topic/2914/how-should-i-resume-work-after-calling-m5-shutdown</link><generator>RSS for Node</generator><lastBuildDate>Sun, 08 Mar 2026 23:51:34 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/2914.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 08 Feb 2021 02:07:11 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How should I resume work after calling M5.shutdown()? on Fri, 12 Feb 2021 07:11:45 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/6776">@dstaley</a></p>
<p dir="auto">Correct, that is what should happen. But yes, when I run your code I can see that the screen gets cleared but no time is shown.</p>
<p dir="auto">Here is why: the ePaper needs some time to actually do the writing on screen. When the <code>pushCanvas()</code> call returns, the actual writing is still ongoing, but in your case the system is shutdown immediately after and before the ePaper had a chance to finish. Therefore the time is not shown. The trick is to add a delay before the shutdown. I tried with a <code>delay(1000)</code> and now the time shows.</p>
<p dir="auto">Cheers<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/12460</link><guid isPermaLink="true">https://community.m5stack.com/post/12460</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Fri, 12 Feb 2021 07:11:45 GMT</pubDate></item><item><title><![CDATA[Reply to How should I resume work after calling M5.shutdown()? on Fri, 12 Feb 2021 01:17:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/4037">@felmue</a> said in <a href="/post/12406">How should I resume work after calling M5.shutdown()?</a>:</p>
<blockquote>
<p dir="auto">Hello <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/6776">@dstaley</a></p>
<p dir="auto">you are correct, when M5Paper is running from USB <code>M5.shutdown()</code> has no effect.</p>
<p dir="auto">When M5Paper runs from battery and you call <code>M5.shutdown(60)</code> that means everything (including the ESP32) is powered down. The only exception is the RTC clock chip which will power on M5Paper after 60 seconds. The program flow does <strong>not</strong> continue after <code>M5.shutdown()</code> but starts from the top, eg. <code>setup()</code> is run again. That is why is seem as time stands still.</p>
<p dir="auto">The trick is to know the reason the program got started, eg. by power button or by RTC clock. With that knowledge different things can be done in <code>setup()</code>.</p>
<p dir="auto">The RTC clock has a timer flag which when set tells you that the RTC timer has woken M5Paper; if not set then it was a regular restart. I've implemented that for M5CoreInk (which has a similar architecture) <a href="https://github.com/m5stack/M5-CoreInk/pull/6/files" target="_blank" rel="noopener noreferrer nofollow ugc">here</a>.</p>
<p dir="auto">Good luck!</p>
<p dir="auto">Thanks<br />
Felix</p>
</blockquote>
<p dir="auto">Hi Felix! Thanks for the information, but I'm still unclear as to why my program doesn't continually update the display. If it's running though <code>setup()</code> every time, shouldn't it be initializing the clock to the same time and drawing to the screen? When I run this program, the time is written once, and then the screen is cleared and it's not written to again.</p>
]]></description><link>https://community.m5stack.com/post/12458</link><guid isPermaLink="true">https://community.m5stack.com/post/12458</guid><dc:creator><![CDATA[dstaley]]></dc:creator><pubDate>Fri, 12 Feb 2021 01:17:30 GMT</pubDate></item><item><title><![CDATA[Reply to How should I resume work after calling M5.shutdown()? on Wed, 10 Feb 2021 08:44:27 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/6776">@dstaley</a></p>
<p dir="auto">you are correct, when M5Paper is running from USB <code>M5.shutdown()</code> has no effect.</p>
<p dir="auto">When M5Paper runs from battery and you call <code>M5.shutdown(60)</code> that means everything (including the ESP32) is powered down. The only exception is the RTC clock chip which will power on M5Paper after 60 seconds. The program flow does <strong>not</strong> continue after <code>M5.shutdown()</code> but starts from the top, eg. <code>setup()</code> is run again. That is why is seem as time stands still.</p>
<p dir="auto">The trick is to know the reason the program got started, eg. by power button or by RTC clock. With that knowledge different things can be done in <code>setup()</code>.</p>
<p dir="auto">The RTC clock has a timer flag which when set tells you that the RTC timer has woken M5Paper; if not set then it was a regular restart. I've implemented that for M5CoreInk (which has a similar architecture) <a href="https://github.com/m5stack/M5-CoreInk/pull/6/files" target="_blank" rel="noopener noreferrer nofollow ugc">here</a>.</p>
<p dir="auto">Good luck!</p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/12406</link><guid isPermaLink="true">https://community.m5stack.com/post/12406</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Wed, 10 Feb 2021 08:44:27 GMT</pubDate></item></channel></rss>