updates to version 0.3, fixes bug where enerysave is not activated after receiving message

pull/2753/head
Targor 2023-05-14 14:03:47 +02:00
parent 9f96ae0955
commit 0c5a442558
3 changed files with 19 additions and 10 deletions

View File

@ -1,2 +1,3 @@
0.01: New App! 0.01: New App!
0.02: Fixes temperature not loading at start. 0.02: Fixes temperature not loading at start.
0.03: reduces energy consumption, fixes bug where app thinks that screen is still unlocked after receiving a message

View File

@ -50,9 +50,11 @@ var temperature = getTemperature();
var drawTimeout; var drawTimeout;
// schedule a draw for the next minute // schedule a draw for the next minute
function queueDraw() { function queueDraw()
{
if (drawTimeout) clearTimeout(drawTimeout); if (drawTimeout) clearTimeout(drawTimeout);
drawTimeout = setTimeout(function () { drawTimeout = setTimeout(function ()
{
drawTimeout = undefined; drawTimeout = undefined;
draw(); draw();
}, (energySave == true ? 60000 : 1000) - (Date.now() % (energySave == true ? 60000 : 1000))); }, (energySave == true ? 60000 : 1000) - (Date.now() % (energySave == true ? 60000 : 1000)));
@ -60,6 +62,11 @@ function queueDraw() {
function draw() { function draw() {
// sometimes, when gadgetbridge sends a message, the locked event is not thrown after the messages was displayed.
// this checks the lock state manually and set the energysave.
if (!energySave && Bangle.isLocked()) { energySave=true; }
var date = new Date(); var date = new Date();
var x = 10; var x = 10;
var y = 2; var y = 2;
@ -69,8 +76,9 @@ function draw() {
//draw main background image //draw main background image
g.drawImage(getKanagawa(), 0, 0); g.drawImage(getKanagawa(), 0, 0);
// only update the batterylvl and temperature every 30 seconds // only update the batterylvl and temperature every 30 seconds or every minute if energysave is on
if (date.getSeconds() % 30 == 0) { if (date.getSeconds() % 30 == 0)
{
batteryLvl = E.getBattery() + "%"; batteryLvl = E.getBattery() + "%";
temperature = getTemperature(); temperature = getTemperature();
} }
@ -121,13 +129,13 @@ function draw() {
// Stop updates when LCD is off, restart when on // Stop updates when LCD is off, restart when on
Bangle.on('lock', on => { Bangle.on('lock', on => {
if (!on) { if (on) {
energySave = false;
queueDraw();
}
else {
energySave = true; energySave = true;
} }
else {
energySave = false;
}
draw();
}); });
g.clear(); g.clear();

View File

@ -2,7 +2,7 @@
"id": "kanagsec", "id": "kanagsec",
"name": "Kanagawa clock", "name": "Kanagawa clock",
"shortName":"kanagawa", "shortName":"kanagawa",
"version":"0.02", "version":"0.03",
"description": "A clock that displays the great wave of kanagawa (image from wikipedia) with seconds in active mode.", "description": "A clock that displays the great wave of kanagawa (image from wikipedia) with seconds in active mode.",
"icon": "app.png", "icon": "app.png",
"tags": "clock, kanagawa, wave", "tags": "clock, kanagawa, wave",