Merge pull request #2480 from BartS23/clock_info

Update clock_info, fix [BW clock]
pull/2483/head
Gordon Williams 2023-01-09 13:58:19 +00:00 committed by GitHub
commit 1c2456dc9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 5 deletions

View File

@ -27,4 +27,5 @@
0.26: Use clkinfo.addInteractive instead of a custom implementation
0.27: Clean out some leftovers in the remove function after switching to
clkinfo.addInteractive that would cause ReferenceError.
0.28: Option to show (1) time only and (2) week of year.
0.28: Option to show (1) time only and (2) week of year.
0.29: use setItem of clockInfoMenu to change the active item

View File

@ -327,9 +327,7 @@ Bangle.on('lock', lockListenerBw);
let charging = function(charging){
// Jump to battery
clockInfoMenu.menuA = 0;
clockInfoMenu.menuB = 2;
clockInfoMenu.redraw();
clockInfoMenu.setItem(0, 2);
drawTime();
}
Bangle.on('charging', charging);

View File

@ -1,7 +1,7 @@
{
"id": "bwclk",
"name": "BW Clock",
"version": "0.28",
"version": "0.29",
"description": "A very minimalistic clock.",
"readme": "README.md",
"icon": "app.png",

View File

@ -296,6 +296,23 @@ exports.addInteractive = function(menu, options) {
options.redraw = function() {
drawItem(menu[options.menuA].items[options.menuB]);
};
options.setItem = function (menuA, menuB) {
if (!menu[menuA] || !menu[menuA].items[menuB] || (options.menuA == menuA && options.menuB == menuB)) {
// menuA or menuB did not exist or did not change
return false;
}
const oldMenuItem = menu[options.menuA].items[options.menuB];
if (oldMenuItem) {
menuHideItem(oldMenuItem);
oldMenuItem.removeAllListeners("draw");
}
options.menuA = menuA;
options.menuB = menuB;
menuShowItem(menu[options.menuA].items[options.menuB]);
return true;
}
return options;
};