mirror of
https://github.com/m5stack/M5Stack.git
synced 2026-05-20 10:06:46 -07:00
clean: fix coding style (#143)
* clean : integrate I2C communication functions. *I2C integrate (power.cpp + MPU9250.cpp) -> move to CommUtil.cpp (Cadd CommUtil class.) *add debug flag for I2C communication (if use, defined I2C_DEBUG_TO_SERIAL in CommUtil.cpp) *cleanup some comment and cords.(power.h) Add :get a input key for M5Stack Faces *add M5Faces.cpp and M5Faces class. * Correction of rewriting mistakes * Fix : refactoring code. Modified to follow Arduino style guide as much as possible *indent : 2spaces /tab *format : UTF-8 *return : LF * clean : integrate code format * clean : integrate code format *miss indent * fix : replace to slash from '\' ( for multi-environment) * fix: *MPU9250.cpp : Correct the error of comment mark *Sprite.cpp : Fixed the problem that the number of parentheses does not match due to the pre-processing condition * fix : Refactoring mistake: number of parentheses did not match
This commit is contained in:
+43
-44
@@ -4,81 +4,80 @@
|
||||
#include "M5Stack.h"
|
||||
|
||||
M5Stack::M5Stack() : isInited(0) {
|
||||
|
||||
}
|
||||
|
||||
void M5Stack::begin(bool LCDEnable, bool SDEnable, bool SerialEnable,bool I2CEnable) {
|
||||
void M5Stack::begin(bool LCDEnable, bool SDEnable, bool SerialEnable, bool I2CEnable) {
|
||||
// Correct init once
|
||||
if (isInited == true) {
|
||||
return;
|
||||
} else {
|
||||
isInited = true;
|
||||
}
|
||||
|
||||
// Correct init once
|
||||
if (isInited) return;
|
||||
else isInited = true;
|
||||
// UART
|
||||
if (SerialEnable == true) {
|
||||
Serial.begin(115200);
|
||||
Serial.flush();
|
||||
delay(50);
|
||||
Serial.print("M5Stack initializing...");
|
||||
}
|
||||
|
||||
// UART
|
||||
if (SerialEnable) {
|
||||
Serial.begin(115200);
|
||||
Serial.flush();
|
||||
delay(50);
|
||||
Serial.print("M5Stack initializing...");
|
||||
}
|
||||
// LCD INIT
|
||||
if (LCDEnable == true) {
|
||||
Lcd.begin();
|
||||
}
|
||||
|
||||
// LCD INIT
|
||||
if (LCDEnable) {
|
||||
Lcd.begin();
|
||||
}
|
||||
// TF Card
|
||||
if (SDEnable == true) {
|
||||
SD.begin(TFCARD_CS_PIN, SPI, 40000000);
|
||||
}
|
||||
|
||||
// TF Card
|
||||
if (SDEnable) {
|
||||
SD.begin(TFCARD_CS_PIN, SPI, 40000000);
|
||||
}
|
||||
// TONE
|
||||
// Speaker.begin();
|
||||
|
||||
// TONE
|
||||
// Speaker.begin();
|
||||
// Set wakeup button
|
||||
Power.setWakeupButton(BUTTON_A_PIN);
|
||||
|
||||
// Set wakeup button
|
||||
Power.setWakeupButton(BUTTON_A_PIN);
|
||||
// I2C init
|
||||
if (I2CEnable == true) {
|
||||
Wire.begin(21, 22);
|
||||
}
|
||||
|
||||
// I2C init
|
||||
if(I2CEnable)
|
||||
{
|
||||
Wire.begin(21, 22);
|
||||
}
|
||||
|
||||
if (SerialEnable) {
|
||||
Serial.println("OK");
|
||||
}
|
||||
if (SerialEnable == true) {
|
||||
Serial.println("OK");
|
||||
}
|
||||
}
|
||||
|
||||
void M5Stack::update() {
|
||||
//Button update
|
||||
BtnA.read();
|
||||
BtnB.read();
|
||||
BtnC.read();
|
||||
|
||||
//Button update
|
||||
BtnA.read();
|
||||
BtnB.read();
|
||||
BtnC.read();
|
||||
|
||||
//Speaker update
|
||||
Speaker.update();
|
||||
//Speaker update
|
||||
Speaker.update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Function has been move to Power class.(for compatibility)
|
||||
* This name will be removed in a future release.
|
||||
*/
|
||||
void M5Stack::setPowerBoostKeepOn(bool en){
|
||||
M5.Power.setPowerBoostKeepOn(en);
|
||||
void M5Stack::setPowerBoostKeepOn(bool en) {
|
||||
M5.Power.setPowerBoostKeepOn(en);
|
||||
}
|
||||
/**
|
||||
* Function has been move to Power class.(for compatibility)
|
||||
* This name will be removed in a future release.
|
||||
*/
|
||||
void M5Stack::setWakeupButton(uint8_t button) {
|
||||
M5.Power.setWakeupButton(button);
|
||||
M5.Power.setWakeupButton(button);
|
||||
}
|
||||
/**
|
||||
* Function has been move to Power class.(for compatibility)
|
||||
* This name will be removed in a future release.
|
||||
*/
|
||||
void M5Stack::powerOFF() {
|
||||
M5.Power.deepSleep();
|
||||
M5.Power.deepSleep();
|
||||
}
|
||||
|
||||
M5Stack M5;
|
||||
|
||||
Reference in New Issue
Block a user