From fbce9aaa7cd1bddaefa71ee8a9b15fb54912d7f1 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Fri, 3 Apr 2020 15:24:09 +0100 Subject: [PATCH] stopwatch - Added widgets --- apps.json | 2 +- apps/swatch/ChangeLog | 1 + apps/swatch/stopwatch.js | 14 +++++++++----- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/apps.json b/apps.json index 18d20b9da..dcb27d1d1 100644 --- a/apps.json +++ b/apps.json @@ -392,7 +392,7 @@ { "id": "swatch", "name": "Stopwatch", "icon": "stopwatch.png", - "version":"0.04", + "version":"0.05", "interface": "interface.html", "description": "Simple stopwatch with Lap Time logging to a JSON file", "tags": "health", diff --git a/apps/swatch/ChangeLog b/apps/swatch/ChangeLog index 2900c9aa1..3246eeced 100644 --- a/apps/swatch/ChangeLog +++ b/apps/swatch/ChangeLog @@ -4,3 +4,4 @@ 0.03: Added ability to save Lap log as a date named JSON file into memory Fixed bug from 0.01 where BN1 (reset) could clear the lap log when timer is running 0.04: Changed save file filename, add interface.html to allow laps to be loaded +0.05: Added widgets diff --git a/apps/swatch/stopwatch.js b/apps/swatch/stopwatch.js index 2ebd8198b..6f8ad9e34 100644 --- a/apps/swatch/stopwatch.js +++ b/apps/swatch/stopwatch.js @@ -13,24 +13,26 @@ function timeToText(t) { return mins+":"+("0"+secs).substr(-2)+"."+("0"+hs).substr(-2); } function updateLabels() { - g.clear(); + g.reset(1); + g.clearRect(0,23,g.getWidth()-1,g.getHeight()-24); g.setFont("6x8",2); g.setFontAlign(0,0,3); g.drawString(started?"STOP":"GO",230,120); - if (!started) g.drawString("RESET",230,190); + if (!started) g.drawString("RESET",230,180); g.drawString(started?"LAP":"SAVE",230,50); g.setFont("6x8",1); g.setFontAlign(-1,-1); for (var i in lapTimes) { - if (i<18) + if (i<16) {g.drawString(lapTimes.length-i+": "+timeToText(lapTimes[i]),35,timeY + 30 + i*8);} - else - {g.drawString(lapTimes.length-i+": "+timeToText(lapTimes[i]),125,timeY + 30 + (i-18)*8);} + else if (i<32) + {g.drawString(lapTimes.length-i+": "+timeToText(lapTimes[i]),125,timeY + 30 + (i-16)*8);} } drawsecs(); } function drawsecs() { var t = tCurrent-tStart; + g.reset(1); g.setFont("Vector",48); g.setFontAlign(0,0); var secs = Math.floor(t/1000)%60; @@ -103,3 +105,5 @@ setWatch(function() { // Reset }, BTN3, {repeat:true}); updateLabels(); +Bangle.loadWidgets(); +Bangle.drawWidgets();