System Functions

begin()

Functionality:

Initializes the LCD; initializes the power management chip AXP192; clears the serial buffer, and sets the serial baud rate to 115200.

Function Prototype:

void begin(bool LCDEnable=true, bool PowerEnable=true, bool SerialEnable=true)

Function Implementation:

void M5StickC::begin(bool LCDEnable, bool PowerEnable, bool SerialEnable){

    //! Correct init once
    if (isInited) return;
    else isInited = true;

    //! UART
    if (SerialEnable) {
        Serial.begin(115200);
        Serial.flush();
        delay(50);
        Serial.print("M5StickC initializing...");
    }

    // Power
    if (PowerEnable) {
        Axp.begin();
    }

    // LCD INIT
    if (LCDEnable) {
        Lcd.begin();
    }

    if (SerialEnable) {
        Serial.println("OK");
    }
}

Usage Example:

#include <M5StickC.h>

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

GetBm8563Time()

This is an API function for the BM8563 chip. This chip communicates with the ESP32 via I2C, with an I2C address of 0x51.

Functionality:

Retrieves the current hour, minute, and second values, and saves them in M5.Rtc.Hour, M5.Rtc.Minute, and M5.Rtc.Second, in ASCII format.

Function Prototype:

void GetBm8563Time(void)

Usage Example:

#include <M5StickC.h>

void setup() {
  M5.begin();
  M5.Lcd.setRotation(3);
  M5.Lcd.setTextSize(2);
  M5.Lcd.fillScreen(BLACK);
  M5.Lcd.println("rtc test");
}

void loop() {
  M5.Rtc.GetBm8563Time();
  M5.Lcd.setCursor(0, 30, 2);
  M5.Lcd.printf("%02d:%02d:%02d/n",M5.Rtc.Hour, M5.Rtc.Minute, M5.Rtc.Second);
  delay(1000);
}
On This Page