pdf-icon

Arduino 上手教程

2. 设备开发 & 案例程序

6. 应用案例

StickS3 Wakeup 休眠唤醒

StickS3 休眠唤醒相关 API 与案例程序。

案例程序

编译要求

  • M5Stack 板管理版本 >= 3.2.5
  • 开发板选项 = M5StickS3
  • M5Unified 库版本 >= 0.2.12
  • M5GFX 库版本 >= 0.2.18
cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#include "M5Unified.h"

void setup(void) {
  M5.begin();

  M5.Display.setTextDatum(middle_center);
  M5.Display.setTextFont(&fonts::FreeMonoBoldOblique9pt7b);
  M5.Display.setRotation(1);

  M5.Display.drawString("BtnA to Sleep 5s", M5.Display.width() / 2, M5.Display.height() / 2);
}

void loop(void) {
  M5.update();

  if (M5.BtnA.wasPressed()) {
    M5.Display.clear();
    M5.Power.timerSleep(5);//sec
  }
}

例程效果如下:

API

StickS3 电源部分使用了 M5Unified 库中的 Power_Class , 更多相关的 API 可以参考下方文档:

On This Page