From e851d1321e646a671cd979e7f8f0a3629319a78e Mon Sep 17 00:00:00 2001 From: Travis Evans Date: Tue, 25 Jul 2023 16:40:46 -0500 Subject: [PATCH] Correct some problems with swipe detection on main clock screen Increase sensitivity so only a small swipe is needed to switch to the appropriate screen. Fix uninitialized variables for calculating swipe length which usually caused first swipe length to register as NaN. --- apps/timerclk/ChangeLog | 1 + apps/timerclk/app.js | 10 +++++----- apps/timerclk/lib.js | 2 +- apps/timerclk/metadata.json | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/apps/timerclk/ChangeLog b/apps/timerclk/ChangeLog index 5a954d58c..46aa52ee1 100644 --- a/apps/timerclk/ChangeLog +++ b/apps/timerclk/ChangeLog @@ -2,3 +2,4 @@ 0.02: Add sunrise/sunset. Fix timer bugs. 0.03: Use default Bangle formatter for booleans 0.04: Use 'modules/suncalc.js' to avoid it being copied 8 times for different apps +0.05: Improve responsiveness and detection of swipes on main clock screen diff --git a/apps/timerclk/app.js b/apps/timerclk/app.js index ee30b059a..e489f9844 100644 --- a/apps/timerclk/app.js +++ b/apps/timerclk/app.js @@ -148,23 +148,23 @@ if (process.env.HWVERSION==1) { setWatch(()=>load("timerclk.alarm.js"), BTN3); setWatch(()=>load("timerclk.alarm.js"), BTN1); } else { - var absY, lastX, lastY; + var absY, lastX=0, lastY=0; Bangle.on('drag', e=>{ if (!e.b) { - if (lastX > 50) { // right + if (lastX > 5) { // right if (absY < dragBorder) { // drag over time load("timerclk.timer.js"); }else { // drag over date/dow load("timerclk.alarm.js"); } - } else if (lastX < -50) { // left + } else if (lastX < -5) { // left if (absY < dragBorder) { // drag over time load("timerclk.stopwatch.js"); }else { // drag over date/dow load("timerclk.alarm.js"); } - } else if (lastY > 50) { // down - } else if (lastY < -50) { // up + } else if (lastY > 5) { // down + } else if (lastY < -5) { // up } lastX = 0; lastY = 0; diff --git a/apps/timerclk/lib.js b/apps/timerclk/lib.js index dd3893fa1..47f49736f 100644 --- a/apps/timerclk/lib.js +++ b/apps/timerclk/lib.js @@ -87,7 +87,7 @@ exports.registerControls = function(o) { } } }); - var absX, lastX, lastY; + var absX, lastX=0, lastY=0; Bangle.on('drag', e=>{ if (!e.b) { if (lastX > 40) { // right diff --git a/apps/timerclk/metadata.json b/apps/timerclk/metadata.json index 5bd6bee24..0a6311ac1 100644 --- a/apps/timerclk/metadata.json +++ b/apps/timerclk/metadata.json @@ -2,7 +2,7 @@ "id": "timerclk", "name": "Timer Clock", "shortName":"Timer Clock", - "version":"0.04", + "version":"0.05", "description": "A clock with stopwatches, timers and alarms build in.", "icon": "app-icon.png", "type": "clock",