Skip to content

Commit

Permalink
Restore custom background function, fix clockbg usage, restore img li…
Browse files Browse the repository at this point in the history
…nked in readme
  • Loading branch information
stweedo authored Sep 3, 2024
1 parent 48d077e commit 3cc5c3f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
3 changes: 2 additions & 1 deletion apps/boxclk/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
0.03: Allows showing the month in short or long format by setting `"shortMonth"` to true or false
0.04: Improves touchscreen drag handling for background apps such as Pattern Launcher
0.05: Fixes step count not resetting after a new day starts
0.06 Added clockbackground app functionality
0.06: Added clockbackground app functionality
0.07: Allow custom backgrounds per boxclk config and from the clockbg module
22 changes: 19 additions & 3 deletions apps/boxclk/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
let locale = require("locale");
let widgets = require("widget_utils");
let date = new Date();
let bgImage;
let configNumber = (storage.readJSON("boxclk.json", 1) || {}).selectedConfig || 0;
let fileName = 'boxclk' + (configNumber > 0 ? `-${configNumber}` : '') + '.json';
// Add a condition to check if the file exists, if it does not, default to 'boxclk.json'
Expand Down Expand Up @@ -71,6 +72,14 @@
* ---------------------------------------------------------------
*/

for (let key in boxesConfig) {
if (key === 'bg' && boxesConfig[key].img) {
bgImage = storage.read(boxesConfig[key].img);
} else if (key !== 'selectedConfig') {
boxes[key] = Object.assign({}, boxesConfig[key]);
}
}

let boxKeys = Object.keys(boxes);

boxKeys.forEach((key) => {
Expand Down Expand Up @@ -211,14 +220,21 @@
*/

let draw = (function() {
let updatePerMinute = true; // variable to track the state of time display
let updatePerMinute = true;

return function(boxes) {
date = new Date();
g.clear();
background.fillRect(Bangle.appRect);

// Always draw background for full screen
if (bgImage) {
g.drawImage(bgImage, 0, 0);
} else {
background.fillRect(0, 0, g.getWidth(), g.getHeight());
}

if (boxes.time) {
boxes.time.string = modString(boxes.time, locale.time(date, isBool(boxes.time.short, true) ? 1 : 0));
boxes.time.string = modString(boxes.time, locale.time(date, isBool(boxes.time.short, true) ? 1 : 0).trim());
updatePerMinute = isBool(boxes.time.short, true);
}
if (boxes.meridian) {
Expand Down
Binary file added apps/boxclk/boxclk.space.img
Binary file not shown.
Binary file modified apps/boxclk/screenshot-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3cc5c3f

Please sign in to comment.