m5stack / M5StickC

M5StickC Arduino Library
MIT License
477 stars 222 forks source link

Add disable left side wake key option #51

Closed tanakamasayuki closed 4 years ago

tanakamasayuki commented 5 years ago

I do not want you to wake with the left button. I want to control it myself.

Now only the screen wake.

USE CASE

#include <M5StickC.h>

void setup() {
  M5.begin();
  M5.Lcd.fillScreen(BLACK);
  M5.Lcd.println("Sleep Test");
  M5.Lcd.println("BtnA : WAKE");
  M5.Lcd.println("BtnB : Sleep");
}

void loop() {
  M5.update();

  // Sleep
  if( M5.BtnB.wasReleased() ){
    // BtnA wakeup setup
    pinMode(GPIO_NUM_37, INPUT_PULLUP);
    esp_sleep_enable_ext0_wakeup(GPIO_NUM_37, LOW);

    // axp sleep(disable left side wake key)
    M5.axp.SetSleep(false);

    // deep sleep
    esp_deep_sleep_start();
  }
}