mirror of https://github.com/espruino/BangleApps
Refactor settings in line_clock app
The `settings` object has been renamed to `initialSettings` for better clarity as these values represent the initial, default settings. Also, the code to remove the clock UI has been commented out, possibly signaling future work on applying the Fast Load system, but this needs to be confirmed. Lastly, calling settings to draw locking and minute indicators has been updated to call the renamed `initialSettings` object.pull/3148/head
parent
651d08de53
commit
c21ea99724
|
@ -13,14 +13,14 @@ const storage = require('Storage');
|
||||||
|
|
||||||
const SETTINGS_FILE = "line_clock.setting.json";
|
const SETTINGS_FILE = "line_clock.setting.json";
|
||||||
|
|
||||||
let settings = {
|
let initialSettings = {
|
||||||
showLock: true,
|
showLock: true,
|
||||||
showMinute: true,
|
showMinute: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
let saved_settings = storage.readJSON(SETTINGS_FILE, 1) || settings;
|
let saved_settings = storage.readJSON(SETTINGS_FILE, 1) || initialSettings;
|
||||||
for (const key in saved_settings) {
|
for (const key in saved_settings) {
|
||||||
settings[key] = saved_settings[key];
|
initialSettings[key] = saved_settings[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
let gWidth = g.getWidth(), gCenterX = gWidth/2;
|
let gWidth = g.getWidth(), gCenterX = gWidth/2;
|
||||||
|
@ -237,11 +237,12 @@ Bangle.on('lock', lockListenerBw);
|
||||||
|
|
||||||
Bangle.setUI({
|
Bangle.setUI({
|
||||||
mode : "clock",
|
mode : "clock",
|
||||||
remove : function() {
|
// TODO implement https://www.espruino.com/Bangle.js+Fast+Load
|
||||||
Bangle.removeListener('lock', lockListenerBw);
|
// remove : function() {
|
||||||
if (drawTimeout) clearTimeout(drawTimeout);
|
// Bangle.removeListener('lock', lockListenerBw);
|
||||||
drawTimeout = undefined;
|
// if (drawTimeout) clearTimeout(drawTimeout);
|
||||||
}
|
// drawTimeout = undefined;
|
||||||
|
// }
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -266,7 +267,7 @@ function draw() {
|
||||||
g.setColor(g.theme.bg);
|
g.setColor(g.theme.bg);
|
||||||
g.fillRect(0, 0, gWidth, gHeight);
|
g.fillRect(0, 0, gWidth, gHeight);
|
||||||
|
|
||||||
if(settings.showLock && Bangle.isLocked()){
|
if(initialSettings.showLock && Bangle.isLocked()){
|
||||||
g.setColor(g.theme.fg);
|
g.setColor(g.theme.fg);
|
||||||
g.drawImage(imgLock(), gWidth-16, 2);
|
g.drawImage(imgLock(), gWidth-16, 2);
|
||||||
}
|
}
|
||||||
|
@ -278,7 +279,7 @@ function draw() {
|
||||||
|
|
||||||
drawHand();
|
drawHand();
|
||||||
|
|
||||||
if(settings.showMinute){
|
if(initialSettings.showMinute){
|
||||||
drawNumber(currentMinute);
|
drawNumber(currentMinute);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue