From a8f52da8030a4d6214c3223464ef414e1ac25d6c Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Mon, 22 Jun 2020 20:48:08 +0200 Subject: [PATCH] Added gpsautotime widget --- apps.json | 12 ++++++++++++ apps/gpsautotime/widget.js | 33 +++++++++++++++++++++++++++++++++ apps/gpsautotime/widget.png | Bin 0 -> 1826 bytes 3 files changed, 45 insertions(+) create mode 100644 apps/gpsautotime/widget.js create mode 100644 apps/gpsautotime/widget.png diff --git a/apps.json b/apps.json index d447aa18c..8b428092d 100644 --- a/apps.json +++ b/apps.json @@ -1974,5 +1974,17 @@ "data": [ {"name":"one_button_presses.csv","storageFile": true} ] + }, + { "id": "gpsautotime", + "name": "GPS auto time", + "shortName":"GPS auto time", + "icon": "widget.png", + "version":"0.01", + "description": "A widget that automatically updates the Bangle.js time to the GPS time whenever there is a valid GPS fix.", + "tags": "widget,gps", + "type": "widget", + "storage": [ + {"name":"gps_auto_time.wid.js","url":"widget.js"} + ] } ] diff --git a/apps/gpsautotime/widget.js b/apps/gpsautotime/widget.js new file mode 100644 index 000000000..a1d1b2b08 --- /dev/null +++ b/apps/gpsautotime/widget.js @@ -0,0 +1,33 @@ +(() => { + var lastTimeSet = 0; + + Bangle.on('GPS',function(fix) { + if (fix.fix) { + var curTime = fix.time.getTime()/1000; + setTime(curTime); + lastTimeSet = curTime; + + WIDGETS["gpsAutoTime"].draw(WIDGETS["gpsAutoTime"]); + } + }); + + // add your widget + WIDGETS["gpsAutoTime"]={ + area:"tl", // tl (top left), tr (top right), bl (bottom left), br (bottom right) + width: 28, // width of the widget + draw: function() { + g.reset(); // reset the graphics context to defaults (color/font/etc) + g.setFont("6x8"); + if ((getTime() - lastTimeSet) <= 60) { + // time is uptodate + g.setColor('#00ff00'); // green + } + g.drawString("auto", this.x, this.y); + g.drawString("time", this.x, this.y+10); + } + }; + + setInterval(function() { + WIDGETS["gpsAutoTime"].draw(WIDGETS["gpsAutoTime"]); + }, 1*60000); // update every minute +})() diff --git a/apps/gpsautotime/widget.png b/apps/gpsautotime/widget.png new file mode 100644 index 0000000000000000000000000000000000000000..6f6e23f2f6d22c2854f6c436c45cef5292dbd6e4 GIT binary patch literal 1826 zcmV+-2i^FIP)bMK~!jg?U!FrRM#EHKj+@vds&c05F-#ptr0}4i9{tqOpUaY05zj& z)6CSFJ|xp*ATvg1`X_xV5B-yw{vjGAO*_*UC(XoZNlgqIjTjpW0{#oprs`N@6j!&4t+61_4RF^W;sUs%Y$EjezlXSVrWYYVPg3s+M9hDo zNb~p1PiC;kzzA5Rq&e{og#cJtd=GQ)O{VG44gA9<67i`cWNrE?{!Wf~&1Wx6VfChL zyaNV}?{?rF95KJ5D3jb}Zp@IxmEyoZY$A|zZKop>@EmAp%$JDLn{NG2&#ze%nl3=p zCG^x&`&C=zEg(~OsXVZ89*P28*SuJ!J=V{2&5Pl;XgktLpCU0+|XPZuDj5~_OWV1cEo4M?)G7R|z)?&Q+heuRL$!a00?X%PRgiRw_W zOdA2+!s45+wUo8jooFslEUN)TnmC&FrN^JxS~WP#H`s)N}k9CpzUZUyn~Prtu(VNT_W#S1M}Rh(0eC7@d%kHzC-+G#XgPC}wi zv0*1N&@EL_y5$?ipTskNLgI8~(VxkQ>>{RaN~V(|R0e2aw=yzj&qCZv-17`w8go z^?56Ne&aJ~@ip7j4+5EUvPa^0aoKz{S8ORZApiis`_c0~eFFne2ZN!&D1_2}>B>se zvJQmJOI4IUx25cT<6K7N(BUkX?Nc&TheF|_SvZ`6?hYTJfHevm9Yn$a0Q&p-YHxIP zBn5*(KY)~^oxOPZf|OKQwp|k5u)a&KeYRIkM+hv_=1hZ!|C}G-lcrlp2}@SaCN)Ek z3Sz=I{YtAb1f&{4&Hd97F%0ng(}DXGOI!x7>{zGYH~t$5=cQ%a-l5(~Ei?N~;6c-r zdj>D z$N??_INbVmyFX|FxwRk3^r{V_Kk}Qu?*7&G@bk}h|G7-s_6Gu){{{0|F4lf42ZvLT zo1ezTQ@sG_E|o>g)39y0@XuS3i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