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 0000000000..c1aaf180da Binary files /dev/null and b/apps/timer/timer.png differ