Skip to content

Commit

Permalink
Refactor settings in line_clock app
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
deepDiverPaul committed Jan 20, 2024
1 parent 651d08d commit c21ea99
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions apps/line_clock/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ const storage = require('Storage');

const SETTINGS_FILE = "line_clock.setting.json";

let settings = {
let initialSettings = {
showLock: 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) {
settings[key] = saved_settings[key];
initialSettings[key] = saved_settings[key];
}

let gWidth = g.getWidth(), gCenterX = gWidth/2;
Expand Down Expand Up @@ -237,11 +237,12 @@ Bangle.on('lock', lockListenerBw);

Bangle.setUI({
mode : "clock",
remove : function() {
Bangle.removeListener('lock', lockListenerBw);
if (drawTimeout) clearTimeout(drawTimeout);
drawTimeout = undefined;
}
// TODO implement https://www.espruino.com/Bangle.js+Fast+Load
// remove : function() {
// Bangle.removeListener('lock', lockListenerBw);
// if (drawTimeout) clearTimeout(drawTimeout);
// drawTimeout = undefined;
// }
});

/**
Expand All @@ -266,7 +267,7 @@ function draw() {
g.setColor(g.theme.bg);
g.fillRect(0, 0, gWidth, gHeight);

if(settings.showLock && Bangle.isLocked()){
if(initialSettings.showLock && Bangle.isLocked()){
g.setColor(g.theme.fg);
g.drawImage(imgLock(), gWidth-16, 2);
}
Expand All @@ -278,7 +279,7 @@ function draw() {

drawHand();

if(settings.showMinute){
if(initialSettings.showMinute){
drawNumber(currentMinute);
}
}
Expand Down

2 comments on commit c21ea99

@ajkm1
Copy link

@ajkm1 ajkm1 commented on c21ea99 Feb 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, Great clock! Any chance of adding widgets (battery, steps) to the clock screen?

@deepDiverPaul
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hej @ajkm1, sorry, that it has bee so long. I have published #3381 today ☺️

Please sign in to comment.