From fa9f9ecaa751b283d46f7c5bd4c2024b287c2957 Mon Sep 17 00:00:00 2001 From: 0x1abin <270995079@qq.com> Date: Thu, 26 Jul 2018 14:02:30 +0800 Subject: [PATCH] added m5stack-fire ip5306 i2c method --- src/M5Stack.cpp | 8 +++++++- src/M5Stack.h | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/M5Stack.cpp b/src/M5Stack.cpp index 94c8f43..d034ec6 100644 --- a/src/M5Stack.cpp +++ b/src/M5Stack.cpp @@ -13,8 +13,10 @@ void M5Stack::begin(bool LCDEnable, bool SDEnable) { // I2C Startup BUG? // pinMode(SCL, OUTPUT); // digitalWrite(SCL, 1); + #ifdef M5STACK_FIRE Wire.begin(21, 22); setPowerBoostKeepOn(true); + #endif // TONE Speaker.begin(); @@ -52,6 +54,7 @@ void M5Stack::update() { Speaker.update(); } +#ifdef M5STACK_FIRE // ================ Power IC IP5306 =================== #define IP5306_ADDR 117 #define IP5306_REG_SYS_CTL0 0x00 @@ -78,7 +81,7 @@ uint8_t M5Stack::isChargeFull() if (data & (1 << CHARGE_FULL_BIT)) return true; else return false; } - +#endif // ================== Low power mode ===================== void M5Stack::setWakeupButton(uint8_t button) { @@ -86,8 +89,11 @@ void M5Stack::setWakeupButton(uint8_t button) { } void M5Stack::powerOFF() { + + #ifdef M5STACK_FIRE // Keep power keep boost on setPowerBoostKeepOn(true); + #endif // power off the Lcd Lcd.setBrightness(0); diff --git a/src/M5Stack.h b/src/M5Stack.h index 28b9742..54e1517 100644 --- a/src/M5Stack.h +++ b/src/M5Stack.h @@ -109,8 +109,11 @@ class M5Stack { void begin(bool LCDEnable=true, bool SDEnable=true); void update(); + #ifdef M5STACK_FIRE void setPowerBoostKeepOn(bool en); uint8_t isChargeFull(); + #endif + void setWakeupButton(uint8_t button); void powerOFF();