mirror of https://github.com/espruino/BangleApps
Merge pull request #2452 from alainsaas/master
a_clock_timer v0.03 (display bugfix; added 1 minute timer buttons)pull/2458/head
commit
f913b71a3e
|
@ -1,2 +1,3 @@
|
|||
0.01: Beta version for Bangle 2 (2021/11/28)
|
||||
0.02: Shows night time on the map (2022/12/28)
|
||||
0.03: Add 1 minute timer with upper taps (2023/01/05)
|
||||
|
|
|
@ -2,7 +2,10 @@
|
|||
|
||||
* Works with Bangle 2
|
||||
* Timer
|
||||
* Right tap: start/increase by 10 minutes; Left tap: decrease by 5 minutes
|
||||
* Top Right tap: increase by 1 minute
|
||||
* Top Left tap: decrease by 1 minute
|
||||
* Bottom Right tap: increase by 10 minutes
|
||||
* Bottom Left tap: decrease by 5 minutes
|
||||
* Short buzz at T-30, T-20, T-10 ; Double buzz at T
|
||||
* Other time zones
|
||||
* Currently hardcoded to Paris and Tokyo (this will be customizable in a future version)
|
||||
|
|
|
@ -18,19 +18,29 @@ var timervalue = 0;
|
|||
var istimeron = false;
|
||||
var timertick;
|
||||
|
||||
Bangle.on('touch',t=>{
|
||||
if (t == 1) {
|
||||
Bangle.on('touch',(touchside, touchdata)=>{
|
||||
if (touchside == 1) {
|
||||
Bangle.buzz(30);
|
||||
if (timervalue < 5*60) { timervalue = 1 ; }
|
||||
else { timervalue -= 5*60; }
|
||||
var changevalue = 0;
|
||||
if(touchdata.y > 88) {
|
||||
changevalue += 60*5;
|
||||
} else {
|
||||
changevalue += 60*1;
|
||||
}
|
||||
if (timervalue < changevalue) { timervalue = 1 ; }
|
||||
else { timervalue -= changevalue; }
|
||||
}
|
||||
else if (t == 2) {
|
||||
else if (touchside == 2) {
|
||||
Bangle.buzz(30);
|
||||
if (!istimeron) {
|
||||
istimeron = true;
|
||||
timertick = setInterval(countDown, 1000);
|
||||
}
|
||||
timervalue += 60*10;
|
||||
if(touchdata.y > 88) {
|
||||
timervalue += 60*10;
|
||||
} else {
|
||||
timervalue += 60*1;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -73,7 +83,7 @@ function countDown() {
|
|||
function showWelcomeMessage() {
|
||||
g.reset().clearRect(0, 76, 44+44, g.getHeight()/2+6);
|
||||
g.setFontAlign(0, 0).setFont("6x8");
|
||||
g.drawString("Touch right to", 44, 80);
|
||||
g.drawString("Tap right to", 44, 80);
|
||||
g.drawString("start timer", 44, 88);
|
||||
setTimeout(function(){ g.reset().clearRect(0, 76, 44+44, g.getHeight()/2+6); }, 8000);
|
||||
}
|
||||
|
@ -103,18 +113,21 @@ function draw() {
|
|||
g.reset().clearRect(0,24,g.getWidth(),g.getHeight()-IMAGEHEIGHT);
|
||||
g.drawImage(getImg(),0,g.getHeight()-IMAGEHEIGHT);
|
||||
|
||||
var x_sun = 176 - (getGmt().getHours() / 24 * 176 + 4);
|
||||
var gmtHours = getGmt().getHours();
|
||||
|
||||
var x_sun = 176 - (gmtHours / 24 * 176 + 4);
|
||||
g.setColor('#ff0').drawLine(x_sun, g.getHeight()-IMAGEHEIGHT, x_sun, g.getHeight());
|
||||
g.reset();
|
||||
|
||||
var x_night_start = 176 - (((getGmt().getHours()-6)%24) / 24 * 176 + 4);
|
||||
var x_night_end = 176 - (((getGmt().getHours()+6)%24) / 24 * 176 + 4);
|
||||
for (let x = x_night_start; x < 176; x+=2) {
|
||||
g.setColor('#000').drawLine(x, g.getHeight()-IMAGEHEIGHT, x, g.getHeight());
|
||||
var x_night_start = 176 - (((gmtHours-6)%24) / 24 * 176 + 4);
|
||||
var x_night_end = 176 - (((gmtHours+6)%24) / 24 * 176 + 4);
|
||||
g.setColor('#000');
|
||||
for (let x = x_night_start; x < (x_night_end < x_night_start ? 176 : x_night_end); x+=2) {
|
||||
g.drawLine(x, g.getHeight()-IMAGEHEIGHT, x, g.getHeight());
|
||||
}
|
||||
if (x_night_end < x_night_start) {
|
||||
for (let x = 0; x < x_night_end; x+=2) {
|
||||
g.setColor('#000').drawLine(x, g.getHeight()-IMAGEHEIGHT, x, g.getHeight());
|
||||
g.drawLine(x, g.getHeight()-IMAGEHEIGHT, x, g.getHeight());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "a_clock_timer",
|
||||
"name": "A Clock with Timer",
|
||||
"version": "0.02",
|
||||
"version": "0.03",
|
||||
"description": "A Clock with Timer, Map and Time Zones",
|
||||
"icon": "app.png",
|
||||
"screenshots": [{"url":"screenshot.png"}],
|
||||
|
|
Loading…
Reference in New Issue