forked from FOSS/BangleApps
Update app.js
parent
9ee180cf41
commit
bafc1b5b48
|
@ -2,7 +2,7 @@
|
|||
Speed and Altitude [speedalt]
|
||||
Mike Bennett mike[at]kereru.com
|
||||
*/
|
||||
var v = '1.11';
|
||||
var v = '1.12';
|
||||
var buf = Graphics.createArrayBuffer(240,160,2,{msb:true});
|
||||
|
||||
// Load fonts
|
||||
|
@ -284,7 +284,7 @@ function setButtons(){
|
|||
LED1.set();
|
||||
}
|
||||
}
|
||||
else setLpMode('SuperE',false); // long press, power off LP GPS
|
||||
else gpsOff(); // long press, power off LP GPS
|
||||
}, BTN2, {repeat:true,edge:"falling"});
|
||||
|
||||
// Toggle between alt or dist
|
||||
|
@ -313,7 +313,7 @@ function updateClock() {
|
|||
|
||||
function startDraw(){
|
||||
canDraw=true;
|
||||
setLpMode('SuperE',true); // off
|
||||
setLpMode('SuperE'); // off
|
||||
g.clear();
|
||||
Bangle.drawWidgets();
|
||||
onGPS(lf); // draw app screen
|
||||
|
@ -321,7 +321,7 @@ function startDraw(){
|
|||
|
||||
function stopDraw() {
|
||||
canDraw=false;
|
||||
if (!tmrLP) tmrLP=setInterval(function () {if (lf.fix) setLpMode('PSMOO',true);}, 30000); //Drop to low power in 30 secs. Keep lp mode off until we have a first fix.
|
||||
if (!tmrLP) tmrLP=setInterval(function () {if (lf.fix) setLpMode('PSMOO');}, 30000); //Drop to low power in 30 secs. Keep lp mode off until we have a first fix.
|
||||
}
|
||||
|
||||
function savSettings() {
|
||||
|
@ -334,18 +334,27 @@ function isLP() {
|
|||
return(1);
|
||||
}
|
||||
|
||||
function setLpMode(m,p) {
|
||||
function setLpMode(m) {
|
||||
if (tmrLP) {clearInterval(tmrLP);tmrLP = false;} // Stop any scheduled drop to low power
|
||||
if ( !lp ) return;
|
||||
var s = WIDGETS.gpsservice.gps_get_settings();
|
||||
if ( m !== s.power_mode || !s.gpsservice ) {
|
||||
s.gpsservice = p;
|
||||
s.gpsservice = true;
|
||||
s.power_mode = m;
|
||||
WIDGETS.gpsservice.gps_set_settings(s);
|
||||
WIDGETS.gpsservice.reload();
|
||||
}
|
||||
}
|
||||
|
||||
function gpsOff() {
|
||||
if ( !lp ) return;
|
||||
var s = WIDGETS.gpsservice.gps_get_settings();
|
||||
s.gpsservice = true;
|
||||
s.power_mode = 'SuperE';
|
||||
WIDGETS.gpsservice.gps_set_settings(s);
|
||||
WIDGETS.gpsservice.reload();
|
||||
}
|
||||
|
||||
// =Main Prog
|
||||
|
||||
// Read settings.
|
||||
|
@ -403,7 +412,7 @@ onGPS(lf);
|
|||
|
||||
var lp = isLP(); // Low power GPS widget installed?
|
||||
if ( lp ) {
|
||||
setLpMode('SuperE',true);
|
||||
setLpMode('SuperE');
|
||||
setInterval(()=>onGPS(WIDGETS.gpsservice.gps_get_fix()), 1000);
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in New Issue