Numerals clock: Add date on touch and some improvements

master
ps-igel 2020-06-18 22:56:27 +02:00
parent c6fa3a9fcc
commit 2f06eeb9f9
5 changed files with 44 additions and 21 deletions

View File

@ -1332,7 +1332,7 @@
"name": "Numerals Clock", "name": "Numerals Clock",
"shortName": "Numerals Clock", "shortName": "Numerals Clock",
"icon": "numerals.png", "icon": "numerals.png",
"version":"0.06", "version":"0.07",
"description": "A simple big numerals clock", "description": "A simple big numerals clock",
"tags": "numerals,clock", "tags": "numerals,clock",
"type":"clock", "type":"clock",

View File

@ -4,3 +4,4 @@
0.04: Don't overwrite existing settings on app update 0.04: Don't overwrite existing settings on app update
0.05: Fix settings issue 0.05: Fix settings issue
0.06: Improve rendering of Numeral 1, fix issue with alarms not showing up 0.06: Improve rendering of Numeral 1, fix issue with alarms not showing up
0.07: Add date on touch and some improvements (see settings and readme)

View File

@ -18,3 +18,6 @@ Settings can be accessed through the app/widget settings menu of the Bangle.js
### Menu button ### Menu button
* choose button to start launcher menu with * choose button to start launcher menu with
### Date on touch
* shows the current date as DD MM on touch and reverts back to time after 5 seconds

View File

@ -42,7 +42,8 @@ if (!settings) {
settings = { settings = {
color:0, color:0,
drawMode:"fill", drawMode:"fill",
menuButton:24 menuButton:24,
showDate:0
}; };
} }
@ -56,35 +57,46 @@ function drawNum(num,col,x,y,func){
} }
} }
function draw(drawMode){ function draw(date){
let d = new Date(); let d = new Date();
let h1 = Math.floor((_12hour?d.getHours()%12:d.getHours())/10); let l1, l2;
let h2 = (_12hour?d.getHours()%12:d.getHours())%10; if (date) {
let m1 = Math.floor(d.getMinutes()/10); setUpdateInt(0);
let m2 = d.getMinutes()%10; l1 = ("0"+(new Date()).getDate()).substr(-2);
l2 = ("0"+(new Date()).getMonth()).substr(-2);
setTimeout(()=>{ draw(); setUpdateInt(1); }, 5000);
} else {
l1 = ("0"+(_12hour?d.getHours()%12:d.getHours())).substr(-2);
l2 = ("0"+d.getMinutes()).substr(-2);
}
g.clearRect(0,24,240,240); g.clearRect(0,24,240,240);
drawNum(h1,_hCol[_rCol],0,0,eval(drawMode)); drawNum(l1[0],_hCol[_rCol],0,0,eval(settings.drawMode));
drawNum(h2,_hCol[_rCol],1,0,eval(drawMode)); drawNum(l1[1],_hCol[_rCol],1,0,eval(settings.drawMode));
drawNum(m1,_mCol[_rCol],0,1,eval(drawMode)); drawNum(l2[0],_mCol[_rCol],0,1,eval(settings.drawMode));
drawNum(m2,_mCol[_rCol],1,1,eval(drawMode)); drawNum(l2[1],_mCol[_rCol],1,1,eval(settings.drawMode));
}
function setUpdateInt(set){
if (interval) clearInterval(interval);
if (set) interval=setInterval(draw, REFRESH_RATE);
} }
Bangle.setLCDMode(); Bangle.setLCDMode();
g.reset().clear(); g.reset().clear();
setWatch(Bangle.showLauncher, settings.menuButton, {repeat:false,edge:"falling"}); setWatch(Bangle.showLauncher, settings.menuButton, {repeat:false,edge:"falling"});
if (settings.color>0) _rCol=settings.color-1; if (settings.color>0) _rCol=settings.color-1;
interval=setInterval(draw, REFRESH_RATE, settings.drawMode); setUpdateInt(1);
draw(settings.drawMode); draw();
if (settings.showDate) {
Bangle.on('touch', () => draw(1));
}
Bangle.on('lcdPower', function(on){ Bangle.on('lcdPower', function(on){
if (on){ if (on){
if (settings.color==0) _rCol = Math.floor(Math.random()*_hCol.length); if (settings.color==0) _rCol = Math.floor(Math.random()*_hCol.length);
draw(settings.drawMode); draw();
interval=setInterval(draw, REFRESH_RATE, settings.drawMode); setUpdateInt(1);
}else } else setUpdateInt(0);
{
clearInterval(interval);
}
}); });
Bangle.loadWidgets(); Bangle.loadWidgets();

View File

@ -6,7 +6,8 @@
numeralsSettings = { numeralsSettings = {
color:0, color:0,
drawMode:"fill", drawMode:"fill",
menuButton:22 menuButton:22,
showDate:0
}; };
updateSettings(); updateSettings();
} }
@ -36,6 +37,12 @@
format: v=>btn[v][1], format: v=>btn[v][1],
onchange: v=> { numeralsSettings.menuButton=btn[v][0]; updateSettings();} onchange: v=> { numeralsSettings.menuButton=btn[v][0]; updateSettings();}
}, },
"Date on touch": {
value: 0|numeralsSettings.showDate,
min:0,max:1,
format: v=>v?"On":"Off",
onchange: v=> { numeralsSettings.showDate=v; updateSettings();}
},
"< back": back "< back": back
}; };
E.showMenu(menu); E.showMenu(menu);