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:
nao
2019-04-12 10:41:12 +09:00
committed by zhouyangyale
parent 2b5b04fd17
commit 13674bfcae
31 changed files with 3847 additions and 4112 deletions
+43 -44
View File
@@ -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;