From ef391cefbf59c76037244cba4f0cb51d6be166da Mon Sep 17 00:00:00 2001 From: marcocastignoli Date: Wed, 1 Apr 2020 14:22:25 +0200 Subject: [PATCH] Fix timer app --- apps.json | 6 ++-- apps/timer/app-icon.js | 1 - apps/timer/app.js | 73 --------------------------------------- apps/timer/timer-icon.js | 1 + apps/timer/timer.js | 73 +++++++++++++++++++++++++++++++++++++++ apps/timer/timer.png | Bin 0 -> 3630 bytes 6 files changed, 77 insertions(+), 77 deletions(-) delete mode 100644 apps/timer/app-icon.js delete mode 100644 apps/timer/app.js create mode 100644 apps/timer/timer-icon.js create mode 100644 apps/timer/timer.js create mode 100644 apps/timer/timer.png diff --git a/apps.json b/apps.json index 0a901ee923..cef59b0e60 100644 --- a/apps.json +++ b/apps.json @@ -943,13 +943,13 @@ { "id": "timer", "name": "Timer", "shortName":"Timer", - "icon": "app.png", + "icon": "timer.png", "version":"0.01", "description": "BTN1 => +5min, BTN2 => +30sec, BTN3 => +5sec, TOUCH => pause,play, BTN1(double click) => reset", "tags": "Tools", "storage": [ - {"name":"timer.app.js","url":"app.js"}, - {"name":"timer.img","url":"app-icon.js","evaluate":true} + {"name":"timer.app.js","url":"timer.js"}, + {"name":"timer.img","url":"timer-icon.js","evaluate":true} ] } ] diff --git a/apps/timer/app-icon.js b/apps/timer/app-icon.js deleted file mode 100644 index 7388566a11..0000000000 --- a/apps/timer/app-icon.js +++ /dev/null @@ -1 +0,0 @@ -var img = require("heatshrink").decompress(atob("mEwwglihGIxAWUwADBDCYTDhAXSFwQEGIxowBL4QXTx///AXWF6qnBwCTDO6EIF4KnEDwLWO/4QFx7FNdwQQEGwP4GBYUB/4QBDIYXMIgQAEDIIKCVwItJFggFEx4uKCAQUBX4QDC/B2KhASCAQP/AQQcDLpQlCLgQsCCoIGBC5IkCFon/xwxCDgIXJFwYxFHIR3ILwIkBCIeIFwQHBHgReIJAgCBOoP+MYZIHhB1EDgIRBA4ZIJC4LrEMYvoAgQXJxHvI4gtDC5OIF4QSDbYY3EC5QAKG4QXNPwg0BSBAJCIQhLCDwgXKIAwXUMo4XPFwrwKC4YOCUooVCR453DIxIXJU4IqDxwXJa45FDdgxnEC40IC4TbINQYXIRQZwDAAXv/xuBCwoXBVAgXDA4wXGSARcEC4o7BRwx4DOon+C4YiCLwxIDDAobDEYJGIGAYYBxDAD9AJDC5IwCDIYACJARGIDAapDaooWLDAZhEAoIWNMggADCqAAPA")) \ No newline at end of file diff --git a/apps/timer/app.js b/apps/timer/app.js deleted file mode 100644 index 82a78ae10a..0000000000 --- a/apps/timer/app.js +++ /dev/null @@ -1,73 +0,0 @@ -function msToTime(duration) { - var milliseconds = parseInt((duration % 1000) / 100), - seconds = Math.floor((duration / 1000) % 60), - minutes = Math.floor((duration / (1000 * 60)) % 60), - hours = Math.floor((duration / (1000 * 60 * 60)) % 24); - - hours = (hours < 10) ? "0" + hours : hours; - minutes = (minutes < 10) ? "0" + minutes : minutes; - seconds = (seconds < 10) ? "0" + seconds : seconds; - - return hours + ":" + minutes + ":" + seconds; - } - - - var counter = 0; - var started = false; - - function drawInterface() { - g.clear(); - g.setFontAlign(0,0); - g.setFont("6x8",2); - g.drawString("+5m", g.getWidth()-30, 30); - g.drawString("+30s", g.getWidth()-30, g.getHeight()/2); - g.drawString("+5s", g.getWidth()-30, g.getHeight() - 30); - - g.setFontAlign(0,0); // center font - g.setFont("6x8",3); - // draw the current counter value - - g.drawString(msToTime(counter*1000), g.getWidth()/2 - 30, g.getHeight()/2); - // optional - this keeps the watch LCD lit up - g.flip(); - } - - function countDown() { - if(counter > 0) { - if (started) { - counter--; - drawInterface(); - } - } else { - if (started) { - Bangle.buzz(); - } - } - } - - setWatch((p) => { - if (p.time - p.lastTime < 0.1) { - counter = 0; - started = false; - } else { - counter+=60*5; - } - drawInterface(); - }, BTN1, {repeat:true}); - - setWatch(() => { - counter+=30; - drawInterface(); - }, BTN2, {repeat:true}); - - setWatch(() => { - counter+=5; - drawInterface(); - }, BTN3, {repeat:true}); - - Bangle.on('touch', function(button) { - started = !started; - }); - - var interval = setInterval(countDown, 1000); - drawInterface(); \ No newline at end of file diff --git a/apps/timer/timer-icon.js b/apps/timer/timer-icon.js new file mode 100644 index 0000000000..5807138252 --- /dev/null +++ b/apps/timer/timer-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEwwglihGIxAWUwADBDCYTDhAXSFwQEGIxowBL4QXTx///AXWF6qnBwCTDO6EIF4KnEDwLWO/4QFx7FNdwQQEGwP4GBYUB/4QBDIYXMIgQAEDIIKCVwItJFggFEx4uKCAQUBX4QDC/B2KhASCAQP/AQQcDLpQlCLgQsCCoIGBC5IkCFon/xwxCDgIXJFwYxFHIR3ILwIkBCIeIFwQHBHgReIJAgCBOoP+MYZIHhB1EDgIRBA4ZIJC4LrEMYvoAgQXJxHvI4gtDC5OIF4QSDbYY3EC5QAKG4QXNPwg0BSBAJCIQhLCDwgXKIAwXUMo4XPFwrwKC4YOCUooVCR453DIxIXJU4IqDxwXJa45FDdgxnEC40IC4TbINQYXIRQZwDAAXv/xuBCwoXBVAgXDA4wXGSARcEC4o7BRwx4DOon+C4YiCLwxIDDAobDEYJGIGAYYBxDAD9AJDC5IwCDIYACJARGIDAapDaooWLDAZhEAoIWNMggADCqAAPA")) \ No newline at end of file diff --git a/apps/timer/timer.js b/apps/timer/timer.js new file mode 100644 index 0000000000..cd50b8a22f --- /dev/null +++ b/apps/timer/timer.js @@ -0,0 +1,73 @@ +function msToTime(duration) { + var milliseconds = parseInt((duration % 1000) / 100), + seconds = Math.floor((duration / 1000) % 60), + minutes = Math.floor((duration / (1000 * 60)) % 60), + hours = Math.floor((duration / (1000 * 60 * 60)) % 24); + + hours = (hours < 10) ? "0" + hours : hours; + minutes = (minutes < 10) ? "0" + minutes : minutes; + seconds = (seconds < 10) ? "0" + seconds : seconds; + + return hours + ":" + minutes + ":" + seconds; +} + + +var counter = 0; +var started = false; + +function drawInterface() { + g.clear(); + g.setFontAlign(0, 0); + g.setFont("6x8", 2); + g.drawString("+5m", g.getWidth() - 30, 30); + g.drawString("+30s", g.getWidth() - 30, g.getHeight() / 2); + g.drawString("+5s", g.getWidth() - 30, g.getHeight() - 30); + + g.setFontAlign(0, 0); // center font + g.setFont("6x8", 3); + // draw the current counter value + + g.drawString(msToTime(counter * 1000), g.getWidth() / 2 - 30, g.getHeight() / 2); + // optional - this keeps the watch LCD lit up + g.flip(); +} + +function countDown() { + if (counter > 0) { + if (started) { + counter--; + drawInterface(); + } + } else { + if (started) { + Bangle.buzz(); + } + } +} + +setWatch((p) => { + if (p.time - p.lastTime < 0.1) { + counter = 0; + started = false; + } else { + counter += 60 * 5; + } + drawInterface(); +}, BTN1, { repeat: true }); + +setWatch(() => { + counter += 30; + drawInterface(); +}, BTN2, { repeat: true }); + +setWatch(() => { + counter += 5; + drawInterface(); +}, BTN3, { repeat: true }); + +Bangle.on('touch', function (button) { + started = !started; +}); + +var interval = setInterval(countDown, 1000); +drawInterface(); \ No newline at end of file diff --git a/apps/timer/timer.png b/apps/timer/timer.png new file mode 100644 index 0000000000000000000000000000000000000000..c1aaf180da22407f079a2d4d2fca2600e58c3b09 GIT binary patch literal 3630 zcmV+}4$<+6P)%wuIoBr2i%=BX6Hc=gwr%<9ZV)ujx5VfHk-|e zj*d1YNz#GI0HP>9D~jUUpOI>t$QJ~m0>}d%x7lp9%a<=VN=r+Ph=_;=K@dI`1flYx zP51T!sjB)v7K`Pa$z)mpSg$s)*g5=JU>L?9L{aQ2iegVq(}HoEnwliTFy1r_W2#{o z$-wD$;!Jcn93z%4T^gR6nmSuilyV@xy@5MxXN&^|%d*_lZnq~kH8u6xzkk1J`}Xae zJ9kb}Rn_nJ`^_{bjeh~g6=GN{7E4KfetvjDLV}QWhY$Z(MMZ_Ty1H60 zo6Uc9I-QGw1DC~1lO!oTGBPrl8IK$}VhDopm-a|pPZ|xg+wF@2fk1Y8db%)v{CMkt z0RuYhTw7a9Sy`D@R8-^*1Oi_rrow|*)oUOY-ZN1S%%;5*L7W=0F<=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