🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    M5StickC Plus2 crash when Button State call

    Arduino
    1
    1
    105
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      restart-au
      last edited by

      Hello together,
      I'am using the M5StickC Plus2 with the Rover.
      I have an issue when trying to implement the Button state.
      Whenewer I have other other Code in the loop() besides the StickCP2.update()
      and the If(StickCP2.wasClicked()) the Controller is crashing. Here I wrote a simple Firmware:

      #include <Arduino.h>
      #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(&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);
      }
      

      I Only see the the BatteryLevel and then the screen gets dark and it restarts.
      Serial Output is:

      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.
      1 Reply Last reply Reply Quote 0
      • First post
        Last post