diff --git a/functions.h b/functions.h index 11e37c6..6c8ea7d 100644 --- a/functions.h +++ b/functions.h @@ -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; diff --git a/mainwindow.cpp b/mainwindow.cpp index 7d5a4dc..5bbd8f7 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -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);