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