Stopwatch touch - adjust on touch for x,y outside the g dimensions of the screen

pull/1487/head
hughbarney 2022-02-19 14:00:33 +00:00
parent eb64a7a436
commit 7f515b172a
3 changed files with 16 additions and 5 deletions

View File

@ -1 +1,2 @@
0.01: first release
0.02: Adjust for touch events outside of screen g dimensions

View File

@ -1,7 +1,7 @@
{
"id": "stopwatch",
"name": "Stopwatch Touch",
"version": "0.01",
"version": "0.02",
"description": "A touch based stop watch for Bangle JS 2",
"icon": "stopwatch.png",
"screenshots": [{"url":"screenshot1.png"},{"url":"screenshot2.png"},{"url":"screenshot3.png"}],

View File

@ -185,17 +185,27 @@ resetBtn.setImage(pause_img);
Bangle.on('touch', function(button, xy) {
var x = xy.x;
var y = xy.y;
// adjust for outside the dimension of the screen
// http://forum.espruino.com/conversations/371867/#comment16406025
if (y > h) y = h;
if (y < 0) y = 0;
if (x > w) x = w;
if (x < 0) x = 0;
// not running, and reset
if (!running && tCurrent == tTotal && bigPlayPauseBtn.check(xy.x, xy.y)) return;
if (!running && tCurrent == tTotal && bigPlayPauseBtn.check(x, y)) return;
// paused and hit play
if (!running && tCurrent != tTotal && smallPlayPauseBtn.check(xy.x, xy.y)) return;
if (!running && tCurrent != tTotal && smallPlayPauseBtn.check(x, y)) return;
// paused and press reset
if (!running && tCurrent != tTotal && resetBtn.check(xy.x, xy.y)) return;
if (!running && tCurrent != tTotal && resetBtn.check(x, y)) return;
// must be running
if (running && bigPlayPauseBtn.check(xy.x, xy.y)) return;
if (running && bigPlayPauseBtn.check(x, y)) return;
});
// Stop updates when LCD is off, restart when on