From a020f1c093168330d41cf0b02a5951b4e3f3075f Mon Sep 17 00:00:00 2001 From: Nicolas Mailloux Date: Tue, 21 Dec 2021 22:27:10 -0500 Subject: [PATCH] Ignore false battery readings if running in emulator --- main.cpp | 29 ++++++++++++++++------------- mainwindow.cpp | 5 ++++- reader.cpp | 5 ++++- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/main.cpp b/main.cpp index 6c69edf..fe4dae8 100644 --- a/main.cpp +++ b/main.cpp @@ -58,20 +58,23 @@ int main(int argc, char *argv[]) global::reader::startUsbmsPrompt = false; // Checking if battery level is critical; if true (and if it is not charging), then display a "Please charge your eReader" splash and power off. - if(isBatteryCritical() == true) { - string_checkconfig_ro("/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/status"); - if(checkconfig_str_val == "Charging\n") { - ; - } - else { - global::battery::showCriticalBatteryAlert = true; - QApplication a(argc, argv); - alert w; + string_checkconfig_ro("/opt/inkbox_device"); + if(checkconfig_str_val != "emu\n") { + if(isBatteryCritical() == true) { + string_checkconfig_ro("/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/status"); + if(checkconfig_str_val == "Charging\n") { + ; + } + else { + global::battery::showCriticalBatteryAlert = true; + QApplication a(argc, argv); + alert w; - const QScreen* screen = qApp->primaryScreen(); - w.setGeometry(QRect(QPoint(0,0), screen->geometry().size())); - w.show(); - return a.exec(); + const QScreen* screen = qApp->primaryScreen(); + w.setGeometry(QRect(QPoint(0,0), screen->geometry().size())); + w.show(); + return a.exec(); + } } } diff --git a/mainwindow.cpp b/mainwindow.cpp index 5bbd8f7..7d5a4dc 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -328,7 +328,10 @@ MainWindow::MainWindow(QWidget *parent) } } } ); - batteryWatchdog->start(); + string_checkconfig_ro("/opt/inkbox_device"); + if(checkconfig_str_val != "emu\n") { + batteryWatchdog->start(); + } // USB mass storage prompt QTimer *usbmsPrompt = new QTimer(this); diff --git a/reader.cpp b/reader.cpp index 5ad4b04..e17f53a 100644 --- a/reader.cpp +++ b/reader.cpp @@ -675,7 +675,10 @@ reader::reader(QWidget *parent) : } } } ); - t->start(); + string_checkconfig_ro("/opt/inkbox_device"); + if(checkconfig_str_val != "emu\n") { + t->start(); + } } // Pages number info label