Improved smpltmr clock info to be not specialiset for bw clock.

pull/2162/head
David Peer 2022-10-02 14:30:13 +02:00
parent 3809c91f1f
commit ae84bc9a18
4 changed files with 127 additions and 125 deletions

View File

@ -217,7 +217,7 @@ function drawCursor(){
}
function drawCmd(cmd){
function drawCmd(cmd){
var c = 0;
var x = 10;
var y = 28;
@ -236,38 +236,38 @@ function drawCursor(){
g.setColor(g.theme.fg);
g.drawString(cmd, x+c, y);
}
}
function twoD(str){
function twoD(str){
return ("0" + str).slice(-2)
}
}
/************************************************
* Listener
*/
// timeout used to update every minute
var drawTimeout;
/************************************************
* Listener
*/
// timeout used to update every minute
var drawTimeout;
// schedule a draw for the next minute
function queueDraw() {
// schedule a draw for the next minute
function queueDraw() {
if (drawTimeout) clearTimeout(drawTimeout);
drawTimeout = setTimeout(function() {
drawTimeout = undefined;
draw();
}, 60000 - (Date.now() % 60000));
}
}
// Stop updates when LCD is off, restart when on
Bangle.on('lcdPower',on=>{
// Stop updates when LCD is off, restart when on
Bangle.on('lcdPower',on=>{
if (on) {
draw(); // draw immediately, queue redraw
} else { // stop draw timer
if (drawTimeout) clearTimeout(drawTimeout);
drawTimeout = undefined;
}
});
});
Bangle.on('lock', function(isLocked) {
@ -275,7 +275,7 @@ Bangle.on('lock', function(isLocked) {
});
Bangle.on('charging',function(charging) {
Bangle.on('charging',function(charging) {
if (drawTimeout) clearTimeout(drawTimeout);
drawTimeout = undefined;
@ -283,11 +283,11 @@ Bangle.on('lock', function(isLocked) {
settings.menuPosY=0;
draw();
});
});
var lock_input = 0;
var lock_input = 0;
Bangle.on('touch', function(btn, e){
Bangle.on('touch', function(btn, e){
if(lock_input > 0){
return;
}
@ -357,15 +357,15 @@ Bangle.on('lock', function(isLocked) {
}
draw();
});
});
E.on("kill", function(){
E.on("kill", function(){
try{
storage.write(SETTINGS_FILE, settings);
} catch(ex){
// If this fails, we still kill the app...
}
});
});
/************************************************

View File

@ -1,3 +1,4 @@
0.01: Release
0.02: Rewrite with new interface
0.03: Added clock infos to expose timer functionality to clocks.
0.04: Improvements of clock infos.

View File

@ -69,7 +69,7 @@
img: img,
items: [
{
name: "Timer",
name: null,
get: () => ({ text: getAlarmMinutesText() + (isAlarmEnabled() ? " min" : ""), img: null}),
show: function() { smpltmrItems.items[0].emit("redraw"); },
hide: function () {},
@ -78,17 +78,18 @@
]
};
var offsets = [+1,+5,-1,-5];
var offsets = [+5,-5];
offsets.forEach((o, i) => {
smpltmrItems.items = smpltmrItems.items.concat({
name: String(o),
get: () => ({ text: getAlarmMinutesText() + " (" + (o > 0 ? "+" : "") + o + ")", img: null}),
name: null,
get: () => ({ text: (o > 0 ? "+" : "") + o + " min.", img: null}),
show: function() { smpltmrItems.items[i+1].emit("redraw"); },
hide: function () {},
run: function() {
if(o > 0) increaseAlarm(o);
else decreaseAlarm(Math.abs(o));
this.show();
return true;
}
});
});

View File

@ -2,7 +2,7 @@
"id": "smpltmr",
"name": "Simple Timer",
"shortName": "Simple Timer",
"version": "0.03",
"version": "0.04",
"description": "A very simple app to start a timer.",
"icon": "app.png",
"tags": "tool,alarm,timer",