Arduino入門
機能です:
LCDの初期化、電源管理チップAXP192の初期化、シリアルポートバッファーのクリア、シリアルポートのボーレートを115200に設定
原型関数です:
void begin(bool LCDEnable=true, bool PowerEnable=true, bool SerialEnable=true)
函数实现:
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"); }}
使用例です:
#include <M5StickC.h> void setup() { M5.begin();}
これはBM8563チップのAPI関数です。該チップはESP32とI2C通信を通じて通信し、I2Cのアドレスは0x51です。
機能です:
現在の時分秒の値を取得し、M5.Rtc.Hour、M5.Rtc.Minute、M5.Rtc.SecondにASCII形式で保存します。
原型関数です:
void GetBm8563Time(void)
使用例です:
#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);}