Skip to content
This repository was archived by the owner on Jan 28, 2022. It is now read-only.

Commit 3101d01

Browse files
authored
fix: stuck charging screen issue (#487)
Closes #462
1 parent f987f4f commit 3101d01

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

main.qml

+26-2
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,33 @@ ApplicationWindow {
231231
width: 480; height: 800
232232
x: 0; y: 0
233233
asynchronous: true
234-
source: "qrc:/basic_ui/ChargingScreen.qml"
235234
visible: StandbyControl.mode == StandbyControl.ON || StandbyControl.mode == StandbyControl.DIM
236-
active: visible
235+
active: false
236+
}
237+
238+
Connections {
239+
target: Battery
240+
241+
onIsChargingChanged: {
242+
if (Battery.isCharging) {
243+
chargingScreen.setSource("qrc:/basic_ui/ChargingScreen.qml");
244+
chargingScreen.active = true;
245+
} else {
246+
chargingScreenTimer.start();
247+
}
248+
}
249+
}
250+
251+
Timer {
252+
id: chargingScreenTimer
253+
repeat: false
254+
interval: 700
255+
running: false
256+
257+
onTriggered: {
258+
chargingScreen.setSource("");
259+
chargingScreen.active = false;
260+
}
237261
}
238262

239263

sources/hardware/linux/arm/bq27441.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <QtDebug>
3030

3131
#include "../../../notifications.h"
32+
#include "../../../standbycontrol.h"
3233
#include "QFile"
3334

3435
static Q_LOGGING_CATEGORY(CLASS_LC, "hw.dev.BQ27441");
@@ -47,6 +48,9 @@ BQ27441::BQ27441(InterruptHandler *interruptHandler, const QString &i2cDevice, i
4748
updateBatteryValues();
4849
}
4950
});
51+
52+
StandbyControl *standbyControl = StandbyControl::getInstance();
53+
connect(standbyControl, &StandbyControl::standByOff, this, [=]() { updateBatteryValues(); });
5054
}
5155

5256
BQ27441::~BQ27441() { close(); }

sources/standbycontrol.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,13 @@ void StandbyControl::wakeup() {
153153
// start bluetooth scanning
154154

155155
// reset battery charging screen
156-
QObject *showClock = m_config->getQMLObject("showClock");
157-
QMetaObject::invokeMethod(showClock, "start", Qt::AutoConnection);
156+
if (m_batteryFuelGauge->getIsCharging()) {
157+
qCDebug(CLASS_LC()) << "Battery is charging";
158+
QObject *showClock = m_config->getQMLObject("showClock");
159+
QMetaObject::invokeMethod(showClock, "start", Qt::AutoConnection);
160+
} else {
161+
qCDebug(CLASS_LC()) << "Battery not is charging";
162+
}
158163

159164
QTimer::singleShot(300, this, [=]() {
160165
// disable touch event catcher

0 commit comments

Comments
 (0)