mirror of https://github.com/espruino/BangleApps
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 2pull/1312/head
commit
991fd5c78f
|
@ -838,7 +838,7 @@
|
||||||
{
|
{
|
||||||
"id": "slevel",
|
"id": "slevel",
|
||||||
"name": "Spirit Level",
|
"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",
|
"description": "Show the current angle of the watch, so you can use it to make sure something is absolutely flat",
|
||||||
"icon": "spiritlevel.png",
|
"icon": "spiritlevel.png",
|
||||||
"tags": "tool",
|
"tags": "tool",
|
||||||
|
@ -1540,7 +1540,7 @@
|
||||||
{
|
{
|
||||||
"id": "gpsinfo",
|
"id": "gpsinfo",
|
||||||
"name": "GPS Info",
|
"name": "GPS Info",
|
||||||
"version": "0.09",
|
"version": "0.10",
|
||||||
"description": "An application that displays information about altitude, lat/lon, satellites and time",
|
"description": "An application that displays information about altitude, lat/lon, satellites and time",
|
||||||
"icon": "gps-info.png",
|
"icon": "gps-info.png",
|
||||||
"type": "app",
|
"type": "app",
|
||||||
|
|
|
@ -6,3 +6,4 @@
|
||||||
0.07: Resolve one FIFO_FULL case and exit App with button press
|
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.08: Leave GPS power switched on on exit (will switch off after 0.5 seconds anyway)
|
||||||
0.09: Fix FIFO_FULL error
|
0.09: Fix FIFO_FULL error
|
||||||
|
0.10: Show satellites "in view" separated by GNS-system
|
||||||
|
|
|
@ -16,9 +16,8 @@ var lastFix = {
|
||||||
time: 0,
|
time: 0,
|
||||||
satellites: 0
|
satellites: 0
|
||||||
};
|
};
|
||||||
var SATinView = 0;
|
var SATinView = 0, lastSATinView = -1, nofGP = 0, nofBD = 0, nofGL = 0;
|
||||||
var nofBD = 0;
|
const leaveNofixLayout = 1; // 0 = stay on initial screen for debugging (default = 1)
|
||||||
var nofGP = 0;
|
|
||||||
var listenerGPSraw = 0;
|
var listenerGPSraw = 0;
|
||||||
|
|
||||||
function formatTime(now) {
|
function formatTime(now) {
|
||||||
|
@ -63,7 +62,7 @@ function getMaidenHead(param1,param2){
|
||||||
function onGPS(fix) {
|
function onGPS(fix) {
|
||||||
if (lastFix.fix != fix.fix) {
|
if (lastFix.fix != fix.fix) {
|
||||||
// if fix is different, change the layout
|
// if fix is different, change the layout
|
||||||
if (fix.fix) {
|
if (fix.fix && leaveNofixLayout) {
|
||||||
layout = new Layout( {
|
layout = new Layout( {
|
||||||
type:"v", c: [
|
type:"v", c: [
|
||||||
{type:"txt", font:"6x8:2", label:"GPS Info" },
|
{type:"txt", font:"6x8:2", label:"GPS Info" },
|
||||||
|
@ -92,11 +91,12 @@ function onGPS(fix) {
|
||||||
g.clearRect(0,24,g.getWidth(),g.getHeight());
|
g.clearRect(0,24,g.getWidth(),g.getHeight());
|
||||||
layout.render();
|
layout.render();
|
||||||
}
|
}
|
||||||
//lastFix = fix;
|
if (fix.fix && leaveNofixLayout) {
|
||||||
if (fix.fix) {
|
|
||||||
if (listenerGPSraw == 1) {
|
if (listenerGPSraw == 1) {
|
||||||
Bangle.removeListener('GPS-raw', onGPSraw);
|
Bangle.removeListener('GPS-raw', onGPSraw);
|
||||||
listenerGPSraw = 0;
|
listenerGPSraw = 0;
|
||||||
|
lastSATinView = -1;
|
||||||
|
Bangle.buzz(50);
|
||||||
}
|
}
|
||||||
var locale = require("locale");
|
var locale = require("locale");
|
||||||
var satellites = fix.satellites;
|
var satellites = fix.satellites;
|
||||||
|
@ -115,27 +115,31 @@ function onGPS(fix) {
|
||||||
layout.sat.label = fix.satellites;
|
layout.sat.label = fix.satellites;
|
||||||
layout.render(layout.sat);
|
layout.render(layout.sat);
|
||||||
}
|
}
|
||||||
if (SATinView != lastFix.SATinView) {
|
if (SATinView != lastSATinView) {
|
||||||
|
if (!leaveNofixLayout) SATinView = -1;
|
||||||
|
lastSATinView = SATinView;
|
||||||
layout.clear(layout.progress);
|
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(layout.progress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//layout.render();
|
|
||||||
|
|
||||||
if (listenerGPSraw == 0 && !fix.fix) {
|
if (listenerGPSraw == 0 && !fix.fix) {
|
||||||
setTimeout(() => Bangle.on('GPS-raw', onGPSraw), 10);
|
setTimeout(() => Bangle.on('GPS-raw', onGPSraw), 10);
|
||||||
listenerGPSraw = 1;
|
listenerGPSraw = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
lastFix = fix;
|
lastFix = fix;
|
||||||
lastFix.SATinView = SATinView;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onGPSraw(nmea) {
|
function onGPSraw(nmea) {
|
||||||
if (nmea.slice(0,7) == "$BDGSV,") nofBD = Number(nmea.slice(11,13));
|
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) == "$GPGSV,") nofGP = Number(nmea.slice(11,13));
|
||||||
SATinView = nofBD + nofGP;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
0.01: New App!
|
0.01: New App!
|
||||||
0.02: Updated to work with both Bangle.js 1 and 2.
|
0.02: Updated to work with both Bangle.js 1 and 2.
|
||||||
|
0.03: Now also visible on Bangle.js 2
|
||||||
|
|
|
@ -2,6 +2,13 @@ g.clear();
|
||||||
var old = {x:0,y:0};
|
var old = {x:0,y:0};
|
||||||
var W = g.getWidth();
|
var W = g.getWidth();
|
||||||
var H = g.getHeight();
|
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) {
|
Bangle.on('accel',function(v) {
|
||||||
var max = Math.max(Math.abs(v.x),Math.abs(v.y),Math.abs(v.z));
|
var max = Math.max(Math.abs(v.x),Math.abs(v.y),Math.abs(v.z));
|
||||||
if (Math.abs(v.y)==max) {
|
if (Math.abs(v.y)==max) {
|
||||||
|
@ -13,6 +20,7 @@ Bangle.on('accel',function(v) {
|
||||||
var d = Math.sqrt(v.x*v.x+v.y*v.y);
|
var d = Math.sqrt(v.x*v.x+v.y*v.y);
|
||||||
var ang = Math.atan2(d,Math.abs(v.z))*180/Math.PI;
|
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.setColor(1,1,1);
|
||||||
g.setFont("6x8",2);
|
g.setFont("6x8",2);
|
||||||
g.setFontAlign(0,-1);
|
g.setFontAlign(0,-1);
|
||||||
|
@ -22,11 +30,19 @@ Bangle.on('accel',function(v) {
|
||||||
x:E.clip(W/2+v.x*256,4,W-4),
|
x:E.clip(W/2+v.x*256,4,W-4),
|
||||||
y:E.clip(H/2+v.y*256,4,H-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);
|
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.setColor(1,1,1);
|
||||||
g.fillRect(n.x-3,n.y-3,n.x+6,n.y+6);
|
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.setColor(1,0,0);
|
||||||
g.drawCircle(W/2,H/2,W*(1/12));
|
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*(1/4));
|
||||||
g.drawCircle(W/2,H/2,W*(5/12));
|
g.drawCircle(W/2,H/2,W*(5/12));
|
||||||
old = n;
|
old = n;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setWatch(_=>load(), BTN1);
|
||||||
|
if (global.BTN2) {
|
||||||
|
setWatch(_=>load(), BTN2);
|
||||||
|
setWatch(_=>load(), BTN3);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue