Hi @felmue,
Interesting post you wrote - nice solution to detect reason for awakening the M5Paper. But unfortunately the code you gave for M5Corelink doesn't compile on a M5Paper.
I did some trial and error modifications and within 5 minutes I got code that does compile.
Here just the relevant code in setup()
- sketch from an example in the M5EPD library:
#include <M5EPD.h>
// is not yet working as should be
M5EPD_Canvas canvas(&M5.EPD);
void setup() {
// Check power on reason before calling M5.begin()
// which calls Rtc.begin() which clears the timer flag.
Wire1.begin(21, 22); // Jop: compiles
//uint8_t data = M5.rtc.ReadReg(0x01); // Jop: compiles NOT
uint8_t data = M5.RTC.readReg(0x01); // Jop: compiles
M5.begin();
bool flagRTC = false;
// Check timer flag
if ((data & 0b00000100) == 0b00000100) {
flagRTC = true;
Serial.println("Power on by: RTC timer");
}
else {
Serial.println("Power on by: PWR Btn");
}
M5.EPD.SetRotation(90);
M5.TP.SetRotation(90);
M5.EPD.Clear(true);
M5.RTC.begin();
canvas.createCanvas(540, 960);
canvas.setTextSize(3);
if (flagRTC)
canvas.drawString("Power on by: RTC timer", 25, 250); // <= this one we see always
else
canvas.drawString("Power on by: PWR Btn", 25, 250);
canvas.drawString("Press PWR Btn for sleep!", 45, 350);
canvas.drawString("after 5 sec wakeup!", 70, 450);
canvas.pushCanvas(0, 0, UPDATE_MODE_DU4);
}
void loop() {
if (M5.BtnP.wasPressed()) {
canvas.drawString("I'm going to sleep.zzzZZZ~", 45, 550);
canvas.pushCanvas(0, 0, UPDATE_MODE_DU4);
delay(1000);
M5.shutdown(5);
}
M5.update();
delay(100);
}
As you see I had to change just some capital-mode in identifiers to get it compiled.
But apparently not the right register or bits are used for detecting wakeup cause.
Maybe someone else is triggered by this to find the full solution for the M5Paper.