Update app.js
parent
defc6206ff
commit
35cf7630b3
|
|
@ -349,7 +349,7 @@ function drawSecondary(n,u) {
|
||||||
s = 30; // Font size
|
s = 30; // Font size
|
||||||
if (BANGLEJS2) s *= fontFactorB2;
|
if (BANGLEJS2) s *= fontFactorB2;
|
||||||
buf.setFontVector(s);
|
buf.setFontVector(s);
|
||||||
buf.drawString(u,xu - (BANGLEJS2*20),screenH_TwoThirds-25);
|
buf.drawString(u,xu - (BANGLEJS2*xu/5),screenH_TwoThirds-25);
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawTime() {
|
function drawTime() {
|
||||||
|
|
@ -391,7 +391,7 @@ function drawWP() { // from waypoints.json - see README.md
|
||||||
buf.setFontAlign(-1,1); //left, bottom
|
buf.setFontAlign(-1,1); //left, bottom
|
||||||
if (BANGLEJS2) s *= fontFactorB2;
|
if (BANGLEJS2) s *= fontFactorB2;
|
||||||
buf.setFontVector(s);
|
buf.setFontVector(s);
|
||||||
buf.drawString(nm.substring(0,6),72,screenH_TwoThirds-(BANGLEJS2 * 20));
|
buf.drawString(nm.substring(0,6),72,screenH_TwoThirds-(BANGLEJS2 * 15));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( cfg.modeA == 2 ) { // clock/large mode
|
if ( cfg.modeA == 2 ) { // clock/large mode
|
||||||
|
|
@ -421,7 +421,7 @@ function drawSats(sats) {
|
||||||
buf.drawString('A',screenW,140-(BANGLEJS2 * 40));
|
buf.drawString('A',screenW,140-(BANGLEJS2 * 40));
|
||||||
if ( showMax ) {
|
if ( showMax ) {
|
||||||
buf.setFontAlign(0,1); //centre, bottom
|
buf.setFontAlign(0,1); //centre, bottom
|
||||||
buf.drawString('MAX',120,164);
|
buf.drawString('MAX',screenW_Half,screenH_TwoThirds + 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( cfg.modeA == 0 ) buf.drawString('D',screenW,140-(BANGLEJS2 * 40));
|
if ( cfg.modeA == 0 ) buf.drawString('D',screenW,140-(BANGLEJS2 * 40));
|
||||||
|
|
@ -536,22 +536,18 @@ function onGPS(fix) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setButtons(){
|
|
||||||
if (!BANGLEJS2) { // Buttons for Bangle.js
|
function btn1press(longpress) {
|
||||||
// Spd+Dist : Select next waypoint
|
if(emulator) console.log("Btn1, long="+longpress);
|
||||||
setWatch(function(e) {
|
if ( cfg.modeA == 1 ) { // Spd+Alt mode - Switch between fix and MAX
|
||||||
var dur = e.time - e.lastTime;
|
if ( !longpress ) showMax = !showMax; // Short press toggle fix/max display
|
||||||
if ( cfg.modeA == 1 ) {
|
|
||||||
// Spd+Alt mode - Switch between fix and MAX
|
|
||||||
if ( dur < 2 ) showMax = !showMax; // Short press toggle fix/max display
|
|
||||||
else { max.spd = 0; max.alt = 0; } // Long press resets max values.
|
else { max.spd = 0; max.alt = 0; } // Long press resets max values.
|
||||||
}
|
}
|
||||||
else nxtWp(1); // Spd+Dist or Clock mode - Select next waypoint
|
else nxtWp(1); // Spd+Dist or Clock mode - Select next waypoint
|
||||||
onGPS(lf);
|
onGPS(lf);
|
||||||
}, BTN1, { edge:"falling",repeat:true});
|
}
|
||||||
|
function btn2press(){
|
||||||
// Power saving on/off
|
if(emulator) console.log("Btn2");
|
||||||
setWatch(function(e){
|
|
||||||
pwrSav=!pwrSav;
|
pwrSav=!pwrSav;
|
||||||
if ( pwrSav ) {
|
if ( pwrSav ) {
|
||||||
LED1.reset();
|
LED1.reset();
|
||||||
|
|
@ -564,52 +560,51 @@ if (!BANGLEJS2) { // Buttons for Bangle.js
|
||||||
Bangle.setLCDPower(1);
|
Bangle.setLCDPower(1);
|
||||||
LED1.set();
|
LED1.set();
|
||||||
}
|
}
|
||||||
}, BTN2, {repeat:true,edge:"falling"});
|
}
|
||||||
|
function btn3press(){
|
||||||
// Toggle between alt or dist
|
if(emulator) console.log("Btn3");
|
||||||
setWatch(function(e){
|
|
||||||
cfg.modeA = cfg.modeA+1;
|
cfg.modeA = cfg.modeA+1;
|
||||||
if ( cfg.modeA > 2 ) cfg.modeA = 0;
|
if ( cfg.modeA > 2 ) cfg.modeA = 0;
|
||||||
|
if(emulator)console.log("cfg.modeA="+cfg.modeA);
|
||||||
savSettings();
|
savSettings();
|
||||||
onGPS(lf);
|
onGPS(lf);
|
||||||
}, BTN3, {repeat:true,edge:"falling"});
|
}
|
||||||
|
function btn4press(){
|
||||||
// Touch left screen to toggle display
|
if(emulator) console.log("Btn4");
|
||||||
setWatch(function(e){
|
|
||||||
cfg.primSpd = !cfg.primSpd;
|
cfg.primSpd = !cfg.primSpd;
|
||||||
savSettings();
|
savSettings();
|
||||||
onGPS(lf); // Update display
|
onGPS(lf); // Update display
|
||||||
}, BTN4, {repeat:true,edge:"falling"});
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function setButtons(){
|
||||||
|
if (!BANGLEJS2) { // Buttons for Bangle.js 1
|
||||||
|
setWatch(function(e) {
|
||||||
|
btn1press(( e.time - e.lastTime) > 2); // > 2 sec. is long press
|
||||||
|
}, BTN1, { edge:"falling",repeat:true});
|
||||||
|
|
||||||
|
// Power saving on/off (red dot visible if off)
|
||||||
|
setWatch(btn2press, BTN2, {repeat:true,edge:"falling"});
|
||||||
|
|
||||||
|
// Toggle between alt or dist
|
||||||
|
setWatch(btn3press, BTN3, {repeat:true,edge:"falling"});
|
||||||
|
|
||||||
|
// Touch left screen to toggle display
|
||||||
|
setWatch(btn4press, BTN4, {repeat:true,edge:"falling"});
|
||||||
|
|
||||||
} else { // Buttons for Bangle.js 2
|
} else { // Buttons for Bangle.js 2
|
||||||
setWatch(function(e){ // Bangle.js BTN3
|
setWatch(function(e) {
|
||||||
cfg.modeA = cfg.modeA+1;
|
btn1press(( e.time - e.lastTime) > 0.4); // > 0.4 sec. is long press
|
||||||
if ( cfg.modeA > 2 ) cfg.modeA = 0;
|
}, BTN1, { edge:"falling",repeat:true});
|
||||||
if(emulator)console.log("cfg.modeA="+cfg.modeA);
|
|
||||||
savSettings();
|
|
||||||
onGPS(lf);
|
|
||||||
}, BTN1, {repeat:true,edge:"falling"});
|
|
||||||
|
|
||||||
/* Bangle.on('tap', function(data) { // data - {dir, double, x, y, z}
|
Bangle.on('touch', function(btn_l_r, e) {
|
||||||
cfg.primSpd = !cfg.primSpd;
|
if(e.x < screenW_Half) btn4press();
|
||||||
if(emulator)console.log("!cfg.primSpd");
|
|
||||||
}); */
|
|
||||||
|
|
||||||
/* Bangle.on('swipe', function(dir) {
|
|
||||||
if (dir < 0) { // left: Bangle.js BTN3
|
|
||||||
cfg.modeA = cfg.modeA+1;
|
|
||||||
if ( cfg.modeA > 2 ) cfg.modeA = 0;
|
|
||||||
if(emulator)console.log("cfg.modeA="+cfg.modeA);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{ // right: Bangle.js BTN4
|
if (e.y < screenH_Half)
|
||||||
cfg.primSpd = !cfg.primSpd;
|
btn2press();
|
||||||
if(emulator)console.log("!cfg.primSpd");
|
else
|
||||||
}
|
btn3press();
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
savSettings();
|
|
||||||
onGPS(lf);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -700,18 +695,6 @@ Bangle.on('lcdPower',function(on) {
|
||||||
else stopDraw();
|
else stopDraw();
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
|
||||||
function onGPSraw(nmea) {
|
|
||||||
var nofGP = 0, nofBD = 0, nofGL = 0;
|
|
||||||
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) == "$BDGSV,") nofBD = Number(nmea.slice(11,13));
|
|
||||||
if (nmea.slice(0,7) == "$GLGSV,") nofGL = Number(nmea.slice(11,13));
|
|
||||||
SATinView = nofGP + nofBD + nofGL;
|
|
||||||
} }
|
|
||||||
if(BANGLEJS2) Bangle.on('GPS-raw', onGPSraw);
|
|
||||||
*/
|
|
||||||
|
|
||||||
var gpssetup;
|
var gpssetup;
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue