Merge pull request #1310 from HilmarSt/master

1. GPS Info App: Show satellites "in view" separated by GNS-system; 2. Spirit Level App: Now also visible on Bangle.js 2
pull/1312/head
Gordon Williams 2022-01-18 14:38:55 +00:00 committed by GitHub
commit 991fd5c78f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 17 deletions

View File

@ -838,7 +838,7 @@
{
"id": "slevel",
"name": "Spirit Level",
"version": "0.02",
"version": "0.03",
"description": "Show the current angle of the watch, so you can use it to make sure something is absolutely flat",
"icon": "spiritlevel.png",
"tags": "tool",
@ -1540,7 +1540,7 @@
{
"id": "gpsinfo",
"name": "GPS Info",
"version": "0.09",
"version": "0.10",
"description": "An application that displays information about altitude, lat/lon, satellites and time",
"icon": "gps-info.png",
"type": "app",

View File

@ -6,3 +6,4 @@
0.07: Resolve one FIFO_FULL case and exit App with button press
0.08: Leave GPS power switched on on exit (will switch off after 0.5 seconds anyway)
0.09: Fix FIFO_FULL error
0.10: Show satellites "in view" separated by GNS-system

View File

@ -16,9 +16,8 @@ var lastFix = {
time: 0,
satellites: 0
};
var SATinView = 0;
var nofBD = 0;
var nofGP = 0;
var SATinView = 0, lastSATinView = -1, nofGP = 0, nofBD = 0, nofGL = 0;
const leaveNofixLayout = 1; // 0 = stay on initial screen for debugging (default = 1)
var listenerGPSraw = 0;
function formatTime(now) {
@ -63,7 +62,7 @@ function getMaidenHead(param1,param2){
function onGPS(fix) {
if (lastFix.fix != fix.fix) {
// if fix is different, change the layout
if (fix.fix) {
if (fix.fix && leaveNofixLayout) {
layout = new Layout( {
type:"v", c: [
{type:"txt", font:"6x8:2", label:"GPS Info" },
@ -92,11 +91,12 @@ function onGPS(fix) {
g.clearRect(0,24,g.getWidth(),g.getHeight());
layout.render();
}
//lastFix = fix;
if (fix.fix) {
if (fix.fix && leaveNofixLayout) {
if (listenerGPSraw == 1) {
Bangle.removeListener('GPS-raw', onGPSraw);
listenerGPSraw = 0;
lastSATinView = -1;
Bangle.buzz(50);
}
var locale = require("locale");
var satellites = fix.satellites;
@ -115,27 +115,31 @@ function onGPS(fix) {
layout.sat.label = fix.satellites;
layout.render(layout.sat);
}
if (SATinView != lastFix.SATinView) {
if (SATinView != lastSATinView) {
if (!leaveNofixLayout) SATinView = -1;
lastSATinView = SATinView;
layout.clear(layout.progress);
layout.progress.label = "in view: " + SATinView;
layout.progress.label = "in view GP/BD/GL: " + nofGP + " " + nofBD + " " + nofGL;
// console.log("in view GP/BD/GL: " + nofGP + " " + nofBD + " " + nofGL);
layout.render(layout.progress);
}
}
//layout.render();
if (listenerGPSraw == 0 && !fix.fix) {
setTimeout(() => Bangle.on('GPS-raw', onGPSraw), 10);
listenerGPSraw = 1;
}
lastFix = fix;
lastFix.SATinView = SATinView;
}
function onGPSraw(nmea) {
if (nmea.slice(0,7) == "$BDGSV,") nofBD = Number(nmea.slice(11,13));
if (nmea.slice(0,7) == "$GPGSV,") nofGP = Number(nmea.slice(11,13));
SATinView = nofBD + nofGP;
if (nmea.slice(3,6) == "GSV") {
// console.log(nmea.slice(1,3) + " " + nmea.slice(11,13));
if (nmea.slice(0,7) == "$GPGSV,") nofGP = Number(nmea.slice(11,13));
if (nmea.slice(0,7) == "$BDGSV,") nofBD = Number(nmea.slice(11,13));
if (nmea.slice(0,7) == "$GLGSV,") nofGL = Number(nmea.slice(11,13));
SATinView = nofGP + nofBD + nofGL;
}
}

View File

@ -1,2 +1,3 @@
0.01: New App!
0.02: Updated to work with both Bangle.js 1 and 2.
0.03: Now also visible on Bangle.js 2

View File

@ -2,6 +2,13 @@ g.clear();
var old = {x:0,y:0};
var W = g.getWidth();
var H = g.getHeight();
// colour definitions for Bangle.js 2
const RED = "#ff0000";
const GRN = "#00ff00";
const BLU = "#0000ff";
const HwVer = process.env.HWVERSION;
Bangle.on('accel',function(v) {
var max = Math.max(Math.abs(v.x),Math.abs(v.y),Math.abs(v.z));
if (Math.abs(v.y)==max) {
@ -12,7 +19,8 @@ Bangle.on('accel',function(v) {
var d = Math.sqrt(v.x*v.x+v.y*v.y);
var ang = Math.atan2(d,Math.abs(v.z))*180/Math.PI;
if (2 == HwVer) g.setColor(RED); else
g.setColor(1,1,1);
g.setFont("6x8",2);
g.setFontAlign(0,-1);
@ -22,11 +30,19 @@ Bangle.on('accel',function(v) {
x:E.clip(W/2+v.x*256,4,W-4),
y:E.clip(H/2+v.y*256,4,H-4)};
g.clearRect(old.x-3,old.y-3,old.x+6,old.y+6);
if (2 == HwVer) g.setColor(GRN); else
g.setColor(1,1,1);
g.fillRect(n.x-3,n.y-3,n.x+6,n.y+6);
if (2 == HwVer) g.setColor(BLU); else
g.setColor(1,0,0);
g.drawCircle(W/2,H/2,W*(1/12));
g.drawCircle(W/2,H/2,W*(1/4));
g.drawCircle(W/2,H/2,W*(5/12));
old = n;
});
setWatch(_=>load(), BTN1);
if (global.BTN2) {
setWatch(_=>load(), BTN2);
setWatch(_=>load(), BTN3);
}