Files
m5-docs/docs/en/api/system_m5stickc.md

87 lines
1.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# System (M5StickC)
## begin()
**Syntax:**
`void begin(bool LCDEnable=true, bool PowerEnable=true, bool SerialEnable=true);`
**Description: Clear the serial port buffer, set the serial port baud rate to 115200; initialize the LCD; initialize the power management chip AXP192.**
**Definition:**
```clike
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");
}
}
```
**Example:**
```clike
#include <M5StickC.h>
void setup() {
M5.begin();
}
void loop() {}
```
## GetBm8563Time()
*This is the API function of the BM8563 chip. The chip communicates with the ESP32 via I2C, and the I2C address is 0x51.*
**Syntax:**
`void GetBm8563Time(void);`
**Description: Get the current hour, minute, and second value and save it to M5.Rtc.Hour, M5.Rtc.Minute, M5.Rtc.Second, in ASCII format.**
**Example:**
```clike
#include <M5StickC.h>
void setup() {
// put your setup code here, to run once:
M5.begin();
M5.Lcd.setRotation(3);
M5.Lcd.fillScreen(BLACK);
M5.Lcd.setTextSize(2);
M5.Lcd.println("rtc test");
}
void loop() {
// put your main code here, to run repeatedly:
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);
}
```