RandomClockWidget even less invasive

master
msdeibel 2020-05-24 17:57:55 +02:00
parent d2b3cb7d34
commit ef91392a9c
4 changed files with 8 additions and 9 deletions

View File

@ -1725,7 +1725,7 @@
{ "id": "rndmclk", { "id": "rndmclk",
"name": "Random Clock Loader", "name": "Random Clock Loader",
"icon": "rndmclk.png", "icon": "rndmclk.png",
"version":"0.02", "version":"0.03",
"description": "Load a different clock whenever the LCD is switched on.", "description": "Load a different clock whenever the LCD is switched on.",
"readme": "README.md", "readme": "README.md",
"tags": "widget,clock", "tags": "widget,clock",

View File

@ -1,2 +1,3 @@
0.01: New widget 0.01: New widget
0.02: Less invasive, change default clock setting instead of directly loading the new clock (no longer breaks Gadgetbridge notifications) 0.02: Less invasive, change default clock setting instead of directly loading the new clock (no longer breaks Gadgetbridge notifications)
0.03: Only changes when the widget id reloaded (no longer uses LCD turning off)

View File

@ -1,6 +1,6 @@
# Summary # Summary
Random Clock is a widget that will randomly show one of the installed watch faces each time the LCD is turned on. Random Clock is a widget that will randomly show one of the installed watch faces each time after the widget is (re-)loaded.
# How it works # How it works
Everytime the LCD is turned off, the widget randomly changes the clock. When you long press BTN 3 the next time, Everytime the widget is reloaded, it randomly changes the clock. When you long press BTN 3 the next time,
you might (or might not, it's random after all) see another watch face. you might (or might not, it's random after all) see another watch face.

View File

@ -16,20 +16,18 @@
if (clockApps && clockApps.length > 0) { if (clockApps && clockApps.length > 0) {
var clockIndex = getRandomInt(clockApps.length); var clockIndex = getRandomInt(clockApps.length);
// Only update the file if the clock really change to be nice to the FLASH mem // Only update the file if the clock really changed to be nice to the FLASH mem
if (clockApps[clockIndex].src != currentClock) { if (clockApps[clockIndex].src != currentClock) {
currentClock = clockApps[clockIndex].src; currentClock = clockApps[clockIndex].src;
settings = require("Storage").readJSON('setting.json', 1); settings = require("Storage").readJSON('setting.json', 1);
settings.clock = clockApps[clockIndex].src; settings.clock = clockApps[clockIndex].src;
require("Storage").write('setting.json', settings); require("Storage").write('setting.json', settings);
console.log("RandomClockWidget set the clock to '" + clockApps[clockIndex].name + "'");
} }
} }
} }
Bangle.on('lcdPower', (on) => { loadRandomClock();
if (!on) {
loadRandomClock();
}
});
})(); })();