mirror of https://github.com/espruino/BangleApps
added BTN2 toggle gps recording in gps watch
parent
5730d8cc23
commit
d4435366a4
|
@ -85,14 +85,19 @@
|
|||
|
||||
function onButtonLong(btn) {
|
||||
log_debug("markWaypoint()");
|
||||
if (btn !== 1) return;
|
||||
if (gpsObject.getState() !== gpsObject.GPS_RUNNING) return;
|
||||
log_debug("markWaypoint()");
|
||||
if (btn === 1) {
|
||||
if (gpsObject.getState() !== gpsObject.GPS_RUNNING) return;
|
||||
log_debug("markWaypoint()");
|
||||
|
||||
gpsObject.markWaypoint();
|
||||
resetPrevious();
|
||||
getWaypoint();
|
||||
drawGPSData();
|
||||
gpsObject.markWaypoint();
|
||||
resetPrevious();
|
||||
getWaypoint();
|
||||
drawGPSData();
|
||||
return;
|
||||
}
|
||||
|
||||
if (btn === 2)
|
||||
Bangle.showLauncher();
|
||||
}
|
||||
|
||||
function getWaypoint() {
|
||||
|
|
|
@ -55,7 +55,10 @@
|
|||
if (btn === 1) cycleInfoMode();
|
||||
}
|
||||
|
||||
function onButtonLong(btn) {}
|
||||
function onButtonLong(btn) {
|
||||
if (btn === 2) Bangle.showLauncher();
|
||||
}
|
||||
|
||||
function getGPSfix() { return undefined; }
|
||||
function setGPSfix(f) {}
|
||||
|
||||
|
|
|
@ -45,7 +45,14 @@
|
|||
}
|
||||
|
||||
function onButtonLong(btn) {
|
||||
if (btn === 1) toggleGPSPower();
|
||||
switch(btn) {
|
||||
case 1:
|
||||
toggleGPSPower();
|
||||
return;
|
||||
case 2:
|
||||
gpsObject.toggleGpsLogging();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function draw(){
|
||||
|
@ -142,8 +149,9 @@
|
|||
g.clearRect(0, Y_ACTIVITY, 239, Y_MODELINE - 1);
|
||||
g.drawString(activityStr, 120, Y_ACTIVITY);
|
||||
g.setFont("6x8",2);
|
||||
g.setColor(1,1,1);
|
||||
g.drawString(age, 120, Y_ACTIVITY + 46);
|
||||
g.setColor(1,1,1);
|
||||
var age_and_logging = age + " logging " + gpsObject.loggingStatus();
|
||||
g.drawString(age_and_logging, 120, Y_ACTIVITY + 46);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,8 @@ function buttonReleased(btn) {
|
|||
face.onButtonLong(btn);
|
||||
break;
|
||||
case 2:
|
||||
Bangle.showLauncher();
|
||||
face.onButtonLong(btn);
|
||||
//Bangle.showLauncher();
|
||||
break;
|
||||
case 3:
|
||||
// do nothing
|
||||
|
@ -369,6 +370,26 @@ GPS.prototype.nextWaypoint = function(inc) {
|
|||
return this.wp_current;
|
||||
}
|
||||
|
||||
GPS.prototype.toggleGpsLogging = function() {
|
||||
var settings = require("Storage").readJSON("gpsrec.json",1)||{};
|
||||
if (settings == {}) return false;
|
||||
|
||||
settings.recording = !settings.recording;
|
||||
require("Storage").write("gpsrec.json", settings);
|
||||
|
||||
if (WIDGETS["gpsrec"])
|
||||
WIDGETS["gpsrec"].reload();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
GPS.prototype.loggingStatus = function() {
|
||||
var settings = require("Storage").readJSON("gpsrec.json",1)||{};
|
||||
if (settings == {}) return "E-LOG";
|
||||
if (settings.recording) return "ON";
|
||||
return "OFF";
|
||||
}
|
||||
|
||||
var gpsObj = new GPS();
|
||||
|
||||
|
||||
|
|
|
@ -19,11 +19,16 @@
|
|||
}
|
||||
|
||||
function onButtonLong(btn) {
|
||||
trip.resetTrip(getSteps());
|
||||
trip.setTripState(true);
|
||||
drawStepText();
|
||||
if (btn === 1) {
|
||||
trip.resetTrip(getSteps());
|
||||
trip.setTripState(true);
|
||||
drawStepText();
|
||||
return;
|
||||
}
|
||||
|
||||
if (btn === 2) Bangle.showLauncher();
|
||||
}
|
||||
|
||||
|
||||
function radians(a) {
|
||||
return a*Math.PI/180;
|
||||
}
|
||||
|
|
|
@ -62,12 +62,17 @@
|
|||
}
|
||||
|
||||
function onButtonLong(btn) {
|
||||
trip.resetTrip(getSteps());
|
||||
infoMode = INFO_TRIP;
|
||||
forceRedraw();
|
||||
draw();
|
||||
if (btn === 1) {
|
||||
trip.resetTrip(getSteps());
|
||||
infoMode = INFO_TRIP;
|
||||
forceRedraw();
|
||||
draw();
|
||||
return;
|
||||
}
|
||||
|
||||
if (btn === 2) Bangle.showLauncher();
|
||||
}
|
||||
|
||||
|
||||
function radians(a) {
|
||||
return a*Math.PI/180;
|
||||
}
|
||||
|
@ -207,7 +212,8 @@
|
|||
var midrot = -180 - (360 * percent);
|
||||
var endrot = -360 - 180;
|
||||
|
||||
g.setColor(0x07FF); // light cyan
|
||||
//g.setColor(0x07FF); // light cyan
|
||||
g.setColor(0xFFC0); // yellow
|
||||
|
||||
// draw guauge
|
||||
for (i = startrot; i > midrot; i -= 3) {
|
||||
|
@ -218,8 +224,8 @@
|
|||
|
||||
// change the remaining color to RED if battery is below 25%
|
||||
if (E.getBattery() > 25) {
|
||||
//g.setColor(0x7BEF); // grey
|
||||
g.setColor(0x000D); // dark navy
|
||||
g.setColor(0x7BEF); // grey
|
||||
//g.setColor(0x000D); // dark navy
|
||||
} else {
|
||||
g.setColor(0xF800); // red
|
||||
}
|
||||
|
|
|
@ -31,7 +31,9 @@
|
|||
}
|
||||
}
|
||||
|
||||
function onButtonLong(btn) {}
|
||||
function onButtonLong(btn) {
|
||||
if (btn === 2) Bangle.showLauncher();
|
||||
}
|
||||
|
||||
return {init:init, freeResources:freeResources, startTimer:startTimer, stopTimer:stopTimer,
|
||||
onButtonShort:onButtonShort, onButtonLong:onButtonLong};
|
||||
|
|
Loading…
Reference in New Issue