Merge pull request #2775 from bobrippling/bikespeedo-recorder
bikespeedo recorder / show max functionsmaster
commit
439ffb83a8
|
|
@ -2,3 +2,4 @@
|
||||||
0.02: Barometer altitude adjustment setting
|
0.02: Barometer altitude adjustment setting
|
||||||
0.03: Use default Bangle formatter for booleans
|
0.03: Use default Bangle formatter for booleans
|
||||||
0.04: Add options for units in locale and recording GPS
|
0.04: Add options for units in locale and recording GPS
|
||||||
|
0.05: Allow toggling of "max" values (screen tap) and recording (button press)
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ const fontFactorB2 = 2/3;
|
||||||
const colfg=g.theme.fg, colbg=g.theme.bg;
|
const colfg=g.theme.fg, colbg=g.theme.bg;
|
||||||
const col1=colfg, colUncertain="#88f"; // if (lf.fix) g.setColor(col1); else g.setColor(colUncertain);
|
const col1=colfg, colUncertain="#88f"; // if (lf.fix) g.setColor(col1); else g.setColor(colUncertain);
|
||||||
|
|
||||||
var altiGPS=0, altiBaro=0;
|
var altiBaro=0;
|
||||||
var hdngGPS=0, hdngCompass=0, calibrateCompass=false;
|
var hdngGPS=0, hdngCompass=0, calibrateCompass=false;
|
||||||
|
|
||||||
/*kalmanjs, Wouter Bulten, MIT, https://github.com/wouterbulten/kalmanjs */
|
/*kalmanjs, Wouter Bulten, MIT, https://github.com/wouterbulten/kalmanjs */
|
||||||
|
|
@ -183,7 +183,6 @@ var KalmanFilter = (function () {
|
||||||
|
|
||||||
var lf = {fix:0,satellites:0};
|
var lf = {fix:0,satellites:0};
|
||||||
var showMax = 0; // 1 = display the max values. 0 = display the cur fix
|
var showMax = 0; // 1 = display the max values. 0 = display the cur fix
|
||||||
var canDraw = 1;
|
|
||||||
var time = ''; // Last time string displayed. Re displayed in background colour to remove before drawing new time.
|
var time = ''; // Last time string displayed. Re displayed in background colour to remove before drawing new time.
|
||||||
var sec; // actual seconds for testing purposes
|
var sec; // actual seconds for testing purposes
|
||||||
|
|
||||||
|
|
@ -194,30 +193,9 @@ max.n = 0; // counter. Only start comparing for max after a certain number of
|
||||||
|
|
||||||
var emulator = (process.env.BOARD=="EMSCRIPTEN" || process.env.BOARD=="EMSCRIPTEN2")?1:0; // 1 = running in emulator. Supplies test values;
|
var emulator = (process.env.BOARD=="EMSCRIPTEN" || process.env.BOARD=="EMSCRIPTEN2")?1:0; // 1 = running in emulator. Supplies test values;
|
||||||
|
|
||||||
var wp = {}; // Waypoint to use for distance from cur position.
|
|
||||||
var SATinView = 0;
|
var SATinView = 0;
|
||||||
|
|
||||||
function radians(a) {
|
|
||||||
return a*Math.PI/180;
|
|
||||||
}
|
|
||||||
|
|
||||||
function distance(a,b){
|
|
||||||
var x = radians(a.lon-b.lon) * Math.cos(radians((a.lat+b.lat)/2));
|
|
||||||
var y = radians(b.lat-a.lat);
|
|
||||||
|
|
||||||
// Distance in selected units
|
|
||||||
var d = Math.sqrt(x*x + y*y) * 6371000;
|
|
||||||
d = (d/parseFloat(cfg.dist)).toFixed(2);
|
|
||||||
if ( d >= 100 ) d = parseFloat(d).toFixed(1);
|
|
||||||
if ( d >= 1000 ) d = parseFloat(d).toFixed(0);
|
|
||||||
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
function drawFix(dat) {
|
function drawFix(dat) {
|
||||||
|
|
||||||
if (!canDraw) return;
|
|
||||||
|
|
||||||
g.clearRect(0,screenYstart,screenW,screenH);
|
g.clearRect(0,screenYstart,screenW,screenH);
|
||||||
|
|
||||||
var v = '';
|
var v = '';
|
||||||
|
|
@ -227,7 +205,7 @@ function drawFix(dat) {
|
||||||
v = (cfg.primSpd)?dat.speed.toString():dat.alt.toString();
|
v = (cfg.primSpd)?dat.speed.toString():dat.alt.toString();
|
||||||
|
|
||||||
// Primary Units
|
// Primary Units
|
||||||
u = (cfg.primSpd)?cfg.spd_unit:dat.alt_units;
|
u = (showMax ? 'max ' : '') + (cfg.primSpd?cfg.spd_unit:dat.alt_units);
|
||||||
|
|
||||||
drawPrimary(v,u);
|
drawPrimary(v,u);
|
||||||
|
|
||||||
|
|
@ -260,14 +238,6 @@ function drawFix(dat) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function drawClock() {
|
|
||||||
if (!canDraw) return;
|
|
||||||
g.clearRect(0,screenYstart,screenW,screenH);
|
|
||||||
drawTime();
|
|
||||||
g.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function drawPrimary(n,u) {
|
function drawPrimary(n,u) {
|
||||||
//if(emulator)console.log("\n1: " + n +" "+ u);
|
//if(emulator)console.log("\n1: " + n +" "+ u);
|
||||||
var s=40; // Font size
|
var s=40; // Font size
|
||||||
|
|
@ -337,16 +307,6 @@ function drawSats(sats) {
|
||||||
g.setFont("6x8", 2);
|
g.setFont("6x8", 2);
|
||||||
g.setFontAlign(1,1); //right, bottom
|
g.setFontAlign(1,1); //right, bottom
|
||||||
g.drawString(sats,screenW,screenH);
|
g.drawString(sats,screenW,screenH);
|
||||||
|
|
||||||
g.setFontVector(18);
|
|
||||||
g.setColor(col1);
|
|
||||||
|
|
||||||
if ( cfg.modeA == 1 ) {
|
|
||||||
if ( showMax ) {
|
|
||||||
g.setFontAlign(0,1); //centre, bottom
|
|
||||||
g.drawString('MAX',120,164);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onGPS(fix) {
|
function onGPS(fix) {
|
||||||
|
|
@ -367,7 +327,6 @@ function onGPS(fix) {
|
||||||
|
|
||||||
var sp = '---';
|
var sp = '---';
|
||||||
var al = '---';
|
var al = '---';
|
||||||
var di = '---';
|
|
||||||
var age = '---';
|
var age = '---';
|
||||||
|
|
||||||
if (fix.fix) lf = fix;
|
if (fix.fix) lf = fix;
|
||||||
|
|
@ -412,10 +371,6 @@ function onGPS(fix) {
|
||||||
al = Math.round(parseFloat(al)/parseFloat(cfg.alt));
|
al = Math.round(parseFloat(al)/parseFloat(cfg.alt));
|
||||||
if (parseFloat(al) > parseFloat(max.alt) && max.n > 15 ) max.alt = parseFloat(al);
|
if (parseFloat(al) > parseFloat(max.alt) && max.n > 15 ) max.alt = parseFloat(al);
|
||||||
|
|
||||||
// Distance to waypoint
|
|
||||||
di = distance(lf,wp);
|
|
||||||
if (isNaN(di)) di = 0;
|
|
||||||
|
|
||||||
// Age of last fix (secs)
|
// Age of last fix (secs)
|
||||||
age = Math.max(0,Math.round(getTime())-(lf.time.getTime()/1000));
|
age = Math.max(0,Math.round(getTime())-(lf.time.getTime()/1000));
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -448,15 +403,7 @@ function onGPS(fix) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setButtons(){
|
|
||||||
setWatch(_=>load(), BTN1);
|
|
||||||
|
|
||||||
onGPS(lf);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function updateClock() {
|
function updateClock() {
|
||||||
if (!canDraw) return;
|
|
||||||
drawTime();
|
drawTime();
|
||||||
g.reset();
|
g.reset();
|
||||||
|
|
||||||
|
|
@ -545,6 +492,10 @@ function Compass_reading() {
|
||||||
hdngCompass = Compass_heading.toFixed(0);
|
hdngCompass = Compass_heading.toFixed(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function nextMode() {
|
||||||
|
showMax = 1 - showMax;
|
||||||
|
}
|
||||||
|
|
||||||
function start() {
|
function start() {
|
||||||
Bangle.setBarometerPower(1); // needs some time...
|
Bangle.setBarometerPower(1); // needs some time...
|
||||||
g.clearRect(0,screenYstart,screenW,screenH);
|
g.clearRect(0,screenYstart,screenW,screenH);
|
||||||
|
|
@ -556,10 +507,30 @@ function start() {
|
||||||
Bangle.setCompassPower(1);
|
Bangle.setCompassPower(1);
|
||||||
if (!calibrateCompass) setInterval(Compass_reading,200);
|
if (!calibrateCompass) setInterval(Compass_reading,200);
|
||||||
|
|
||||||
setButtons();
|
|
||||||
if (emulator) setInterval(updateClock, 2000);
|
if (emulator) setInterval(updateClock, 2000);
|
||||||
else setInterval(updateClock, 10000);
|
else setInterval(updateClock, 10000);
|
||||||
|
|
||||||
|
let createdRecording = false;
|
||||||
|
Bangle.setUI({
|
||||||
|
mode: "custom",
|
||||||
|
touch: nextMode,
|
||||||
|
btn: () => {
|
||||||
|
const rec = WIDGETS["recorder"];
|
||||||
|
if(rec){
|
||||||
|
const active = rec.isRecording();
|
||||||
|
if(active){
|
||||||
|
createdRecording = true;
|
||||||
|
rec.setRecording(false);
|
||||||
|
}else{
|
||||||
|
rec.setRecording(true, { force: createdRecording ? "append" : "new" });
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
nextMode();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// can't delay loadWidgets til here - need to have already done so for recorder
|
||||||
Bangle.drawWidgets();
|
Bangle.drawWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -571,6 +542,7 @@ if (cfg.record && WIDGETS["recorder"]) {
|
||||||
|
|
||||||
if (cfg.recordStopOnExit)
|
if (cfg.recordStopOnExit)
|
||||||
E.on('kill', () => WIDGETS["recorder"].setRecording(false));
|
E.on('kill', () => WIDGETS["recorder"].setRecording(false));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
"id": "bikespeedo",
|
"id": "bikespeedo",
|
||||||
"name": "Bike Speedometer (beta)",
|
"name": "Bike Speedometer (beta)",
|
||||||
"shortName": "Bike Speedometer",
|
"shortName": "Bike Speedometer",
|
||||||
"version": "0.04",
|
"version": "0.05",
|
||||||
"description": "Shows GPS speed, GPS heading, Compass heading, GPS altitude and Barometer altitude from internal sources",
|
"description": "Shows GPS speed, GPS heading, Compass heading, GPS altitude and Barometer altitude from internal sources",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"screenshots": [{"url":"Screenshot.png"}],
|
"screenshots": [{"url":"Screenshot.png"}],
|
||||||
|
|
|
||||||
|
|
@ -29,4 +29,5 @@
|
||||||
0.23: Add graphing for HRM, fix some other graphs
|
0.23: Add graphing for HRM, fix some other graphs
|
||||||
Altitude graphing now uses barometer altitude if it exists
|
Altitude graphing now uses barometer altitude if it exists
|
||||||
plotTrack in widget allows track to be drawn in the background (doesn't block execution)
|
plotTrack in widget allows track to be drawn in the background (doesn't block execution)
|
||||||
0.24: Can now specify `setRecording(true, {force:...` to not show a menu
|
0.24: Can now specify `setRecording(true, {force:...` to not show a menu
|
||||||
|
0.25: Widget now has `isRecording()` for retrieving recording status.
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
"id": "recorder",
|
"id": "recorder",
|
||||||
"name": "Recorder",
|
"name": "Recorder",
|
||||||
"shortName": "Recorder",
|
"shortName": "Recorder",
|
||||||
"version": "0.24",
|
"version": "0.25",
|
||||||
"description": "Record GPS position, heart rate and more in the background, then download to your PC.",
|
"description": "Record GPS position, heart rate and more in the background, then download to your PC.",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"tags": "tool,outdoors,gps,widget",
|
"tags": "tool,outdoors,gps,widget",
|
||||||
|
|
|
||||||
|
|
@ -231,6 +231,8 @@
|
||||||
},getRecorders:getRecorders,reload:function() {
|
},getRecorders:getRecorders,reload:function() {
|
||||||
reload();
|
reload();
|
||||||
Bangle.drawWidgets(); // relayout all widgets
|
Bangle.drawWidgets(); // relayout all widgets
|
||||||
|
},isRecording:function() {
|
||||||
|
return !!writeInterval;
|
||||||
},setRecording:function(isOn, options) {
|
},setRecording:function(isOn, options) {
|
||||||
/* options = {
|
/* options = {
|
||||||
force : [optional] "append"/"new"/"overwrite" - don't ask, just do what's requested
|
force : [optional] "append"/"new"/"overwrite" - don't ask, just do what's requested
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue