mirror of https://github.com/espruino/BangleApps
gpsmagcourse: Avoid jitter, fix widget
parent
a59f500895
commit
ed3ebf9754
|
@ -25,7 +25,7 @@ On Bangle.js 2 a click on the widget does reset the built-in compass.
|
||||||
|
|
||||||
## Settings
|
## Settings
|
||||||
* **Speed threshold**
|
* **Speed threshold**
|
||||||
- (default = 6 km/h) When GPS speed is lower then this threshold use the compass direction.
|
- (default = 6 km/h) When GPS speed is lower then this threshold use the compass direction. The speed must be for at least 10 seconds this fast to switch back to GPS course.
|
||||||
* **Compass source**
|
* **Compass source**
|
||||||
- off: Disables this addon.
|
- off: Disables this addon.
|
||||||
- built-in (default): Uses the built-in compass. Its calibration can be restarted by pressing the Widget. When tilt compensation is disabled or "Navigation compass" is not installed the watch must be orientated horizontally for the compass heading to be used.
|
- built-in (default): Uses the built-in compass. Its calibration can be restarted by pressing the Widget. When tilt compensation is disabled or "Navigation compass" is not installed the watch must be orientated horizontally for the compass heading to be used.
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
tiltCompensation: true, // tilt compensation on built-in compass
|
tiltCompensation: true, // tilt compensation on built-in compass
|
||||||
}, require("Storage").readJSON("gpsmagcourse.json", true) || {});
|
}, require("Storage").readJSON("gpsmagcourse.json", true) || {});
|
||||||
const CALIBDATA = (settings.compassSrc === 2) ? require("Storage").readJSON("magnav.json",1) : undefined;
|
const CALIBDATA = (settings.compassSrc === 2) ? require("Storage").readJSON("magnav.json",1) : undefined;
|
||||||
|
let cntAboveSpeed = 0;
|
||||||
|
|
||||||
// Check if magnav is installed
|
// Check if magnav is installed
|
||||||
try {
|
try {
|
||||||
|
@ -63,7 +64,8 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
const changeGpsCourse = (gps) => {
|
const changeGpsCourse = (gps) => {
|
||||||
if (gps.speed < settings.speed) {
|
cntAboveSpeed = gps.speed < settings.speed ? 0 : cntAboveSpeed+1;
|
||||||
|
if (cntAboveSpeed < 10) { // need to stay x events above or equal threshold
|
||||||
if (settings.compassSrc === 1 && (settings.tiltCompensation || isFaceUp(Bangle.getAccel()))) { // Use uncompensated built-in compass heading only if face is up
|
if (settings.compassSrc === 1 && (settings.tiltCompensation || isFaceUp(Bangle.getAccel()))) { // Use uncompensated built-in compass heading only if face is up
|
||||||
const heading = Bangle.getCompass().heading;
|
const heading = Bangle.getCompass().heading;
|
||||||
if (!isNaN(heading)) {
|
if (!isNaN(heading)) {
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
if (gps.courseOrig && WIDGETS.gpsmagcourse.show !== 1 && Bangle.isGPSOn()) {
|
if (gps.courseOrig && WIDGETS.gpsmagcourse.show !== 1 && Bangle.isGPSOn()) {
|
||||||
WIDGETS.gpsmagcourse.show = 1;
|
WIDGETS.gpsmagcourse.show = 1;
|
||||||
WIDGETS.gpsmagcourse.draw();
|
WIDGETS.gpsmagcourse.draw();
|
||||||
} else if (WIDGETS.gpsmagcourse.show) {
|
} else if (!gps.courseOrig && WIDGETS.gpsmagcourse.show === 1) {
|
||||||
WIDGETS.gpsmagcourse.show = settings.showWidget === 1 ? 0 : 2;
|
WIDGETS.gpsmagcourse.show = settings.showWidget === 1 ? 0 : 2;
|
||||||
WIDGETS.gpsmagcourse.draw();
|
WIDGETS.gpsmagcourse.draw();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue