System

begin

功能:

清空串口缓冲区,设置串口波特率为 115200;初始化I2C;初始化LED矩阵

函数原型:

void begin(bool SerialEnable, bool I2CEnable, bool DisplayEnable)

使用示例:

#include "M5Atom.h"
void setup(){
    M5.begin(true, true, true); //清空串口缓冲区,设置串口波特率为 115200;初始化I2C;初始化LED矩阵
}

update

功能:

读取按键的状态。

函数原型:

void update()

使用示例:

#include "M5Atom.h"
#include <M5Atom.h>

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

void loop() {
  M5.update();    //需添加M5.update()才能读取到按键的状态,细节请见System
  if (M5.Btn.isPressed()) {    //如果按键按下
    Serial.println("Button is pressed.");
  }
  delay(20);
}
On This Page