<?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[M5StickC Plus2 crash when Button State call]]></title><description><![CDATA[<p dir="auto">Hello together,<br />
I'am using the M5StickC Plus2 with the Rover.<br />
I have an issue when trying to implement the Button state.<br />
Whenewer I have other other Code in the <code>loop()</code> besides the <code>StickCP2.update()</code><br />
and the <code>If(StickCP2.wasClicked())</code> the Controller is crashing. Here I wrote a simple Firmware:</p>
<pre><code class="language-cpp">#include &lt;Arduino.h&gt;
#include "M5StickCPlus2.h"
#include "M5_RoverC.h"

void setup()
{
    Serial.begin(9600);
    Serial.println("Startup");
    auto cfg = M5.config();
    StickCP2.begin(cfg);
    StickCP2.Display.setFont(&amp;fonts::Orbitron_Light_24);
    StickCP2.Display.setTextColor(GREEN,DARKGREY);
    StickCP2.Display.print("Startup");
    delay(100);
}

void loop()
{
    StickCP2.update();

    Serial.println("Battery Test Start here!");
    int vol = StickCP2.Power.getBatteryLevel();
    StickCP2.Display.clear();
    StickCP2.Display.setCursor(StickCP2.Display.width()/2, StickCP2.Display.height()/2);
    StickCP2.Display.printf("%d \%", vol);
    
    if (StickCP2.BtnA.wasClicked())
    {
        StickCP2.Display.clear(DARKCYAN);
    }
    delay(50);
}
</code></pre>
<p dir="auto">I Only see the the BatteryLevel and then the screen gets dark and it restarts.<br />
Serial Output is:</p>
<pre><code>Rebooting...
�R��RgRStartup
Battery Test Start here!
Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.

Core  1 register dump:
PC      : 0x400d2312  PS      : 0x00060a30  A0      : 0x800db9e4  A1      : 0x3ffb2270  
A2      : 0x00000000  A3      : 0x3ffc2804  A4      : 0x00000064  A5      : 0x00000004  
A6      : 0x3ffb8188  A7      : 0x80000001  A8      : 0x800d2310  A9      : 0x3ffb21d0  
A10     : 0x00000004  A11     : 0x416778b6  A12     : 0x416778b6  A13     : 0x3ffb220c  
A14     : 0x3ffc2b70  A15     : 0x3ffb220c  SAR     : 0x0000001b  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000016  LBEG    : 0x400867e0  LEND    : 0x400867f6  LCOUNT  : 0x00000000  


Backtrace: 0x400d230f:0x3ffb2270 0x400db9e1:0x3ffb2290




ELF file SHA256: 706bf00c17c9ca5e
```
The Button Example for the StickC Plus 2 works fine. Also, when I remove everything else from the loop except the `Update` and the check for a Button action.

I am Using Visual Studio Code and PlatformIO with the Arduiono Framework.</code></pre>
]]></description><link>https://community.m5stack.com/topic/7543/m5stickc-plus2-crash-when-button-state-call</link><generator>RSS for Node</generator><lastBuildDate>Tue, 28 Apr 2026 21:00:10 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/7543.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 04 May 2025 19:36:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to M5StickC Plus2 crash when Button State call on Mon, 28 Jul 2025 20:19:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/restart-au" aria-label="Profile: restart-au">@<bdi>restart-au</bdi></a> said in <a href="/post/29026">M5StickC Plus2 crash when Button State call</a>:</p>
<blockquote>
<p dir="auto"><code>StickCP2.Display.printf("%d \%", vol);</code></p>
</blockquote>
<p dir="auto">I don't think that backslash-percent means anything special in printf(). You probably want <code>%%</code> instead to get a literal percent sign in the output. I don't know what happens with what you've used, but a crash would not surprise me.</p>
]]></description><link>https://community.m5stack.com/post/29639</link><guid isPermaLink="true">https://community.m5stack.com/post/29639</guid><dc:creator><![CDATA[wjcarpenter]]></dc:creator><pubDate>Mon, 28 Jul 2025 20:19:31 GMT</pubDate></item></channel></rss>