From bdfcea2bf725f7f8344897a6693b080a40a66646 Mon Sep 17 00:00:00 2001 From: MaBecker Date: Thu, 2 Apr 2020 12:04:41 +0200 Subject: [PATCH] widget hand wash timer --- apps.json | 2 +- apps/widhwt/widget.js | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/apps.json b/apps.json index ce63d3b00..644258709 100644 --- a/apps.json +++ b/apps.json @@ -956,7 +956,7 @@ "name": "Hand Wash Timer", "icon": "widget.png", "version":"0.01", - "description": "Any swip will start your personal Bangle.js hand wash timer for 35 sec. Start washing after the short buzz and stop after the long buzz.", + "description": "Swipe your wrist over the watch face to start your personal Bangle.js hand wash timer for 35 sec. Start washing after the short buzz and stop after the long buzz.", "tags": "widget,tool", "type":"widget", "storage": [ diff --git a/apps/widhwt/widget.js b/apps/widhwt/widget.js index 55ffec028..a8b15ac9b 100644 --- a/apps/widhwt/widget.js +++ b/apps/widhwt/widget.js @@ -2,6 +2,7 @@ (() => { var icon = require("heatshrink").decompress(atob("jEYwIKHgwCBhwCBh4CEggPCkACBmAXDBwVZ+EB+F4gEsjl8EgMP+EChk/gEMh+ehkA+YIBxwxBnF/4HggH/wEAj0AA==")); var color = 0x4A69; + var isActive = false; function draw() { g.reset().setColor(color).drawImage(icon, this.x + 1, 0); @@ -9,14 +10,18 @@ WIDGETS["widhwt"] = { area: "tr", width: 26, draw: draw }; - Bangle.on('swipe', function() { - color = 0x41f; - Bangle.buzz(); - Bangle.drawWidgets(); - setTimeout(() => { - color = 0x4A69; - Bangle.buzz(1E3, 1); + Bangle.on('twist', function() { + if (!isActive) { + isActive = true; + color = 0x41f; + Bangle.buzz(); Bangle.drawWidgets(); - }, 35E3); + setTimeout(() => { + color = 0x4A69; + Bangle.buzz(1E3, 1); + Bangle.drawWidgets(); + setTimeout(() => { isActive = false; }, 1E10); + }, 35E3); + } }); -})(); +})(); \ No newline at end of file