From 8416f6e5c535ea1ad1dbcdb8865267968d021a3a Mon Sep 17 00:00:00 2001 From: Hugh Barney Date: Sun, 23 Apr 2023 13:30:15 +0100 Subject: [PATCH] clkinfogps added screenshots, debug, consistant timer handling --- apps/clkinfogps/README.md | 56 +++++++++++++++++++++++++++ apps/clkinfogps/clkinfo.js | 66 ++++++++++++++++++++++---------- apps/clkinfogps/screenshot0.png | Bin 0 -> 2989 bytes apps/clkinfogps/screenshot1.png | Bin 0 -> 2952 bytes apps/clkinfogps/screenshot2.png | Bin 0 -> 3122 bytes apps/clkinfogps/screenshot3.png | Bin 0 -> 2744 bytes 6 files changed, 101 insertions(+), 21 deletions(-) create mode 100644 apps/clkinfogps/screenshot0.png create mode 100644 apps/clkinfogps/screenshot1.png create mode 100644 apps/clkinfogps/screenshot2.png create mode 100644 apps/clkinfogps/screenshot3.png diff --git a/apps/clkinfogps/README.md b/apps/clkinfogps/README.md index 8526114f7..6cee9d47e 100644 --- a/apps/clkinfogps/README.md +++ b/apps/clkinfogps/README.md @@ -1,5 +1,61 @@ # GPS Clock Info +![](app.png) + +A clock info that displays the Ordanance Survey (OS) grid reference + +- The primary use is for walking where a GPS fix that is 2 minutes old is + perfectly fine for providing an OS map grid reference. +- Saves power by only turning the GPS on for the time it takes to get a fix. +- It then switches the GPS off for 90 seconds before trying to get the next fix +- At the start of the walk update the GPS with using one of the AGPS apps. This will + significantly reduce the time to the first fix. +- Displays the GPS time and number of satelites while waiting for a fix. +- The fix is invalidated after 4 minutes and will display 00:00:00 0 + or the gps time while the gps is powered on and searching for a fix. +- If the display is shows solid 00:00:00 0 then tap the clkinfo to restart it + as it will have timed out after 4 minutes +- I suggest installing the GPS power widget so that you can be assured + when the GPS is draining power. +- It is unlikley that this style of gps clock info will work well with the Recorder + app as that would hold the GPS power permantly on all the time during the + recording. + + ## Screenshots + +![](screenshot0.png) + +- Above: The GPS is powered on and waiting for a fix. +- The GPS widget shows yellow indicating powered on +- The time from the GPS chip is displayed with the satellite count +- The time from the GPS chip is incrementing approximately every second +- Note the time on the GPS is in UTC and not the current timezone + + +![](screenshot1.png) + +- Above: The GPS has a fix +- The OS grid reference has been calculated +- The GPS has been turned off for 90 seconds +- The GPS widget is grey showing the GPS is off +- You will not see the GPS widget turn green as the GPS is turned off after a fix + + +![](screenshot2.png) + +- Above: The GPS has been powered on after 90 seconds and is waiting for a fix + + +![](screenshot3.png) + +- Above: The GPS has not had a fix for 4 minutes and the cycle has stopped +- The time from the GPS is 00:00:00 0, indicating that the GPS not on +- The GPS widget is grey showing the GPS is off +- Tap the clock_info to restart the GPS clock info + + + + Written by: [Hugh Barney](https://github.com/hughbarney) For support and discussion please post in the [Bangle JS Forum](http://forum.espruino.com/microcosms/1424/) diff --git a/apps/clkinfogps/clkinfo.js b/apps/clkinfogps/clkinfo.js index 7c955e6b9..349cf13b6 100644 --- a/apps/clkinfogps/clkinfo.js +++ b/apps/clkinfogps/clkinfo.js @@ -4,6 +4,10 @@ var fixTs; var geo = require("geotools"); + var debug = function(o) { + console.log(o); + }; + var resetLastFix = function() { last_fix = { fix: 0, @@ -26,6 +30,35 @@ } }; + var clearTimer = function() { + if (timeout) { + clearTimeout(timeout); + timeout = undefined; + debug("timer cleared"); + } + }; + + var queueGPSon = function() { + clearTimer(); + // power on the GPS again in 90 seconds + timeout = setTimeout(function() { + timeout = undefined; + Bangle.setGPSPower(1,"clkinfo"); + }, 90000); + debug("gps on queued"); + }; + + var queueGPSoff = function() { + // turn off after 5 minutes, sooner if we get a fix + clearTimer(); + timeout = setTimeout(function() { + timeout = undefined; + Bangle.setGPSPower(0,"clkinfo"); + resetLastFix(); + }, 300000); + debug("gps off queued"); + }; + var onGPS = function(fix) { //console.log(fix); last_fix.time = fix.time; @@ -35,17 +68,10 @@ last_fix = fix; fixTs = Math.round(getTime()); // cancel the timeout, if not already timed out - if (this.timeout) { - clearTimeout(timeout); - this.timeout = undefined; - } + clearTimer(); // power off the GPS Bangle.setGPSPower(0,"clkinfo"); - // power on the GPS again in 90 seconds - timeout = setTimeout(function() { - timeout = undefined; - Bangle.setGPSPower(1,"clkinfo"); - }, 90000); + queueGPSon(); } // if our last fix was more than 4 minutes ago, reset the fix to show gps time + satelites @@ -63,8 +89,8 @@ // show gps time and satelite count if (!last_fix.fix) - return formatTime(last_fix.time) + '.' + last_fix.satelites; - + return formatTime(last_fix.time) + ' ' + last_fix.satellites; + return geo.gpsToOSMapRef(last_fix); }; @@ -77,27 +103,25 @@ text: gpsText() }); }, run : function() { + console.log("run"); + // if the timer is already runnuing reset it, we can get multiple run calls by tapping + clearTimer(); Bangle.setGPSPower(1,"clkinfo"); - /* turn off after 5 minutes, sooner if we get a fix */ - this.timeout = setTimeout(function() { - this.timeout = undefined; - Bangle.setGPSPower(0,"clkinfo"); - resetLastFix(); - }, 300000); + // turn GPS off after 5 mins if we dont get a fix, sooner if we get a fix + queueGPSoff(); }, show: function () { + console.log("show"); resetLastFix(); fixTs = Math.round(getTime()); Bangle.on("GPS",onGPS); this.run(); }, hide: function() { + console.log("hide"); + clearTimer(); Bangle.setGPSPower(0,"clkinfo"); Bangle.removeListener("GPS", onGPS); - if (this.timeout) { - clearTimeout(this.timeout); - this.timeout = undefined; - } resetLastFix(); } } diff --git a/apps/clkinfogps/screenshot0.png b/apps/clkinfogps/screenshot0.png new file mode 100644 index 0000000000000000000000000000000000000000..cfe9358d39be981324535631f5c0a86180b0f631 GIT binary patch literal 2989 zcmeHJX;jh+9{sb3ChjIGf>u^er9OM^2%0^GN_%CSrl};ko7$M>9=K-W(()2iG_t3e zs3LzZHqALRU*??oHfKJ~hu^*Do^wC_&hMVz%{l%nK~)*4 z3;=-Y;X^JbelYtVqXheb^-stAeh?_;1mPf1*M<5F0Px_$F3zXo{bm@S8c{W>87ae? z%#?7Ep(q0w(n`A#Cw97d3V)zR&ZIP?tSx;J)l1sGx~XlAl@b8m+R_VcXbm2i`3M4T zy1cS;V-wg|PfFdnv67&wzd4mhAl3EHl9EXH0oqD^gFA~YMa}mOoXCyKdy={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<3W`A5485=wi8=1gifl1Dya#o|C`?7O+sNTyyaPlWNCz{! zVy-&23^E_H41%HR1IJ}+ku%bLQ8Xnxx_t*YV%?iZyVOp_NM)>Mh?MTvnMI7DzqpEV za;rT8qAF*X`B0zzanHE(Gq`>%RKG?oVjE1qvlO1xxxL9Nha2E{nmDG@@%EuXLeoRV z&kWp8VoLx08!OXTncK?1LkU3_F0N}cAmn`5Y*z8LUm@Tb)J zO>_fOZ^oT!?c}y5f?%5$IE5A9dy{tp_7~n8rJPp3PUx;(IXl{>OuVe$B5;srC+Oi2 zW@gfhCXsWRf`u@fiO_h-3O7~##gP;jY|cB`{2}ad`IkLCArSW6cN^H(zUnQ^V1t_s(q-zR>^$-7Yb=aSVDaBj`amGl i-T$MT{SRqaQ&cnbPdFO7wf;x{1`fOa>QZ-*nD%#v4|%Ns literal 0 HcmV?d00001 diff --git a/apps/clkinfogps/screenshot1.png b/apps/clkinfogps/screenshot1.png new file mode 100644 index 0000000000000000000000000000000000000000..ab17af5728f1cf64f60e85b6232ae9c967fa2c55 GIT binary patch literal 2952 zcmeH}*(1~o8^?e18?r=^nL?bD^)1R$ob1HNlI<{BZ9Eff<&Lko^A=_rmR#*$?y zYhf4?V#GvatRW0pGs9ShIo^x+A9%0ci}&Jrz89a1XSw>s+gh6m3rY$C03d9B)x`cF z-~PM!4;}Q%`Wg3wfP~na83Pqxq!s|+u(7#`kptF!IeR#GTvNoPkjwQeu5i7lCK9*e z@>ayJrQoa-V(vYe6m6Elp{62}pSqN>iRXMUezbr$;MntGUYl*@ zlauFMAQUK0IGa}62URr^J+U_e6)~w?i?}eA9=~%> z_yMRVq}tHuF7O~Fu~;XG4Wo;Fbas?IUAG>iFZ39K*1z%Ee33L%vl6sKg<_@H-47D^9+wZc({#Qa*Ar34kmeOOsxg|Bejn;+_=6OxXZR_P z!M-MgS0kTjqCT9y`cOrARejd2F|_ndM^xk!Lts2tmI1yBituPuYVwO2st~g&KF8dy zJ*24@O+8|aC%8SK5g3_dO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J&A);a-9CHxvC90==Hz19j<00@$KFk5r6XpPQa4NZe@x)Saq$Z%@3+1i*r7pi1^9ro-Dzc$Vjbq_w2cUMNu_ITwvXy=03_js{eM1 zH}l4F_d*wELqJbUJxvRGCq>(tTo0v>tfkvh51AFoiZ$Ms_PpnL^KB><=j^u{`VrXY z|MRh7pR6Ia-DvwYgNPILM1Du^?)pE=wtUc*7Y5qg-p`)Pt-LDAM-%9fG7oH>D1%mmrvou=Op7(P3B$}L10Sp5g zDBWRiM%A9B)Y<+Kq0I_P45i)owAtUVYlT{K_5&H?a)BvPEh)rPS7z+p)wCzGrF_fC$Qg9*VKS6bp0tI+Tb`zl?hb@h z0>_;L6k{0$hH6x%;_qgRmOg&RjlELc*8IamaVs-c?i7b|&7$>3vB>f2;P`f*U3!%mx!_Nv2-WFnahX`dAK@}9 z*_MaB6f}opN?n}rvhn^znCF28BwAFtAR&;ZK+Fqq0v=$nS}eA672I1MYQ~ zEE4Su0gbbt(JluDQbn}$N(8}IcIKKrXJzm&gOZNj{4YmyA&a@O4_X(uiw@KpFgLX} JsWA48`3EE9kc9vM literal 0 HcmV?d00001 diff --git a/apps/clkinfogps/screenshot2.png b/apps/clkinfogps/screenshot2.png new file mode 100644 index 0000000000000000000000000000000000000000..c912a37ea628c1616f270dbc788d50a55e13b6ea GIT binary patch literal 3122 zcmd^C`#;kS1O0ByWwV#5Nn~LX=9*9Ad@OK z@bvv8(RhQBSBa&&@wLi1E|(h``m+e^K#)=Z$<9;ImD_AUOQo6U3P>DT&~+Df+S=FV zPKl(uWXUhC!|tEPglm+Fw-@2Ov{xQoP?%5p%aGx6W|JBu%?02~o%52VU;7@u2>fZu z3g*cKjrK}q_gC_EFp3^l5jht>emKtfH2TZ~Db-SIHxnjjJq@>Dbf(^NFCQ5{E125i zynZ5zIWMux#-Dtj{y-_oRNg~(6b#b}^8z;9X;vlozxeel#-fwNdPn%Kt||V9==R`r z$6h=%tk!n`g!}n{I(1@ixWZUNYZ3yUnMjlxSEX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