gpsmagcourse: Avoid jitter, fix widget

pull/2581/head
Erik Andresen 2023-02-22 19:33:24 +01:00
parent a59f500895
commit ed3ebf9754
3 changed files with 5 additions and 3 deletions

View File

@ -25,7 +25,7 @@ On Bangle.js 2 a click on the widget does reset the built-in compass.
## Settings
* **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**
- 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.

View File

@ -6,6 +6,7 @@
tiltCompensation: true, // tilt compensation on built-in compass
}, require("Storage").readJSON("gpsmagcourse.json", true) || {});
const CALIBDATA = (settings.compassSrc === 2) ? require("Storage").readJSON("magnav.json",1) : undefined;
let cntAboveSpeed = 0;
// Check if magnav is installed
try {
@ -63,7 +64,8 @@
};
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
const heading = Bangle.getCompass().heading;
if (!isNaN(heading)) {

View File

@ -49,7 +49,7 @@
if (gps.courseOrig && WIDGETS.gpsmagcourse.show !== 1 && Bangle.isGPSOn()) {
WIDGETS.gpsmagcourse.show = 1;
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.draw();
}