From e7c8ea9813eba5813d2b374cb0da834d35950f31 Mon Sep 17 00:00:00 2001 From: Dimitri Gigot Date: Thu, 2 Apr 2020 20:29:37 +0000 Subject: [PATCH] add touch and swipe support --- apps/toucher/app.js | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/apps/toucher/app.js b/apps/toucher/app.js index 1b5a9186c..2b80198c9 100644 --- a/apps/toucher/app.js +++ b/apps/toucher/app.js @@ -103,10 +103,28 @@ function drawMenu(){ } drawMenu(); + +// Physical buttons setWatch(prev, BTN1, {repeat:true}); -setWatch(prev, BTN4, {repeat:true}); - setWatch(next, BTN3, {repeat:true}); -setWatch(next, BTN5, {repeat:true}); - setWatch(run, BTN2, {repeat:true,edge:"falling"}); + +// Screen event +Bangle.on('touch', function(button){ + switch(button){ + case 1: + prev(); + break; + case 2: + next(); + break; + case 3: + run(); + break; + } +}); + +Bangle.on('swipe', dir => { + if(dir == 1) prev(); + else next(); +}); \ No newline at end of file