m5stack / M5StickC-Plus

M5StickCPlus Arduino Library
MIT License
359 stars 90 forks source link

Sleep causing unresponsive device #13

Closed pcrowlz closed 2 years ago

pcrowlz commented 3 years ago

Going into LightSleep or DeepSleep causes the device to freeze or lock up. Uploading the same code by using #include instead of #include fixes the issue, but causes other modules like the display to not function correctly.

This is what I get out of the debug: 018,len:4 load:0x3fff001c,len:1044 load:0x40078000,len:10124

pcrowlz commented 3 years ago

I've narrowed it down to something in AXP192.h and .cpp. Transplanting those files from the M5StickC library into the M5StickCPlus library fixed the issue.

felmue commented 3 years ago

Hello @pcrowlz

the issue is in SetSleep() which completely powers off everything (except for RTC) instead of keeping ESP32 powered so it can wake up from deep sleep (or light sleep).

(To be honest I never really understood the role of the SetSleep() function or why it even exists.)

Anyhow, using the functions from M5StickC should help, as you've already figured out yourself.

For reference: M5StickC Plus - SetSleep()

Write1Byte( 0x12 , 0x00 );

M5StickC - SetSleep()

Write1Byte(0x12, Read8bit(0x12) & 0xA1); // Disable all outputs but DCDC1

Thanks Felix

rlsharp commented 2 years ago

Here it is 2022 and they still have not fixed the M5stickCPlus library for deep and light sleep. Seems such critical features should have been fixed a long time ago. Makes me question support or future of this product. Anyway, I fixed it by simply moving the SetSleep(), DeepSleep(), and LightSleep() routines in AXP192.cpp from the m5stickC library to the m4stickcplus library. So far so good. Ron

Knight13th commented 2 years ago

Thank you so much. I agree, how have they not fixed such a significant feature. I would recommend their devices, if it wasn't for the fact that I keep running into major software errors.

Tinyu-Zhao commented 2 years ago

This issue has been fixed in the new version #31