gpstrek - Differentiate between starting/stopping for usage and background

pull/2175/head
Martin Boonk 2022-10-13 20:30:12 +02:00
parent 0af49fc6d9
commit 89a8d9a026
2 changed files with 13 additions and 8 deletions

View File

@ -7,7 +7,7 @@ if (showWidgets){
}
let state = WIDGETS["gpstrek"].getState();
WIDGETS["gpstrek"].start();
WIDGETS["gpstrek"].start(false);
function parseNumber(toParse){
if (toParse.includes(".")) return parseFloat(toParse);
@ -591,8 +591,8 @@ function showMenu(){
"Route" : showRouteMenu,
"Waypoint" : showWaypointMenu,
"Calibration": showCalibrationMenu,
"Start" : ()=>{ E.showPrompt("Start?").then((v)=>{ if (v) {state.active = true; removeMenu();} else {E.showMenu(mainmenu);}});},
"Stop" : ()=>{ E.showPrompt("Stop?").then((v)=>{ if (v) {WIDGETS["gpstrek"].stop(); removeMenu();} else {E.showMenu(mainmenu);}});},
"Start" : ()=>{ E.showPrompt("Start?").then((v)=>{ if (v) {WIDGETS["gpstrek"].start(true); removeMenu();} else {E.showMenu(mainmenu);}});},
"Stop" : ()=>{ E.showPrompt("Stop?").then((v)=>{ if (v) {WIDGETS["gpstrek"].stop(true); removeMenu();} else {E.showMenu(mainmenu);}});},
"Reset" : ()=>{ E.showPrompt("Do Reset?").then((v)=>{ if (v) {WIDGETS["gpstrek"].resetState(); removeMenu();} else {E.showMenu(mainmenu);}});},
"Slices" : {
value : numberOfSlices,

View File

@ -72,7 +72,7 @@ function onPressure(e) {
}
}
function start(){
function start(bg){
Bangle.on('GPS', onGPS);
Bangle.on("HRM", onPulse);
Bangle.on("mag", onMag);
@ -83,13 +83,18 @@ function start(){
Bangle.setHRMPower(1, "gpstrek");
Bangle.setCompassPower(1, "gpstrek");
Bangle.setBarometerPower(1, "gpstrek");
if (bg){
state.active = true;
saveState();
}
Bangle.drawWidgets();
}
function stop(){
function stop(bg){
if (bg){
state.active = false;
saveState();
}
Bangle.drawWidgets();
}