mirror of
https://github.com/justcallmekoko/ESP32Marauder.git
synced 2025-12-08 05:41:00 -08:00
* Adding new library, changing way of displaying texts (#118) * Adding custom icon for language button * Adding new library, changing way of displaying texts Added new library to make incoming translation possible to exists at the same time. * Prepare for flipper integration * More flipper wifi dev board work * Add command parse * Add set channel * Create bins for release v0.9.6 Co-authored-by: mlodawy <105587112+mlodawy@users.noreply.github.com>
50 lines
1.2 KiB
C++
50 lines
1.2 KiB
C++
#include "BatteryInterface.h"
|
|
#include "lang_var.h"
|
|
BatteryInterface::BatteryInterface() {
|
|
|
|
}
|
|
|
|
void BatteryInterface::main(uint32_t currentTime) {
|
|
#ifndef MARAUDER_FLIPPER
|
|
if (currentTime != 0) {
|
|
if (currentTime - initTime >= 3000) {
|
|
//Serial.println("Checking Battery Level");
|
|
this->initTime = millis();
|
|
int8_t new_level = this->getBatteryLevel();
|
|
//this->battery_level = this->getBatteryLevel();
|
|
if (this->battery_level != new_level) {
|
|
Serial.println(text00 + (String)new_level);
|
|
this->battery_level = new_level;
|
|
}
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
|
|
void BatteryInterface::RunSetup() {
|
|
#ifndef MARAUDER_FLIPPER
|
|
Wire.begin(I2C_SDA, I2C_SCL);
|
|
this->initTime = millis();
|
|
#endif
|
|
}
|
|
|
|
int8_t BatteryInterface::getBatteryLevel() {
|
|
#ifndef MARAUDER_FLIPPER
|
|
Wire.beginTransmission(IP5306_ADDR);
|
|
Wire.write(0x78);
|
|
if (Wire.endTransmission(false) == 0 &&
|
|
Wire.requestFrom(0x75, 1)) {
|
|
this->i2c_supported = true;
|
|
switch (Wire.read() & 0xF0) {
|
|
case 0xE0: return 25;
|
|
case 0xC0: return 50;
|
|
case 0x80: return 75;
|
|
case 0x00: return 100;
|
|
default: return 0;
|
|
}
|
|
}
|
|
this->i2c_supported = false;
|
|
return -1;
|
|
#endif
|
|
}
|