Show fake battery status on emulator

This commit is contained in:
Nicolas Mailloux 2021-12-25 10:36:38 -05:00
parent a020f1c093
commit 0b1fb63142
2 changed files with 13 additions and 10 deletions

View file

@ -291,12 +291,18 @@ namespace {
}
void get_battery_level() {
QFile batt_level_file("/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/capacity");
batt_level_file.open(QIODevice::ReadOnly);
batt_level = batt_level_file.readAll();
batt_level = batt_level.trimmed();
batt_level_int = batt_level.toInt();
batt_level = batt_level.append("%");
batt_level_file.close();
if(batt_level_file.exists()) {
batt_level_file.open(QIODevice::ReadOnly);
batt_level = batt_level_file.readAll();
batt_level = batt_level.trimmed();
batt_level_int = batt_level.toInt();
batt_level = batt_level.append("%");
batt_level_file.close();
}
else {
batt_level_int = 100;
batt_level = "100%";
}
}
void writeconfig(std::string file, std::string config) {
std::ofstream fhandler;

View file

@ -328,10 +328,7 @@ MainWindow::MainWindow(QWidget *parent)
}
}
} );
string_checkconfig_ro("/opt/inkbox_device");
if(checkconfig_str_val != "emu\n") {
batteryWatchdog->start();
}
batteryWatchdog->start();
// USB mass storage prompt
QTimer *usbmsPrompt = new QTimer(this);