Update app.js

pull/2452/head
Alain Saas 2023-01-05 06:35:42 -05:00 committed by GitHub
parent a88ce6a5c1
commit 4846c45885
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 25 additions and 12 deletions

View File

@ -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;
}
}
});
@ -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());
}
}