small code reduction, call getWaypoint() in draw()
parent
0e43af0d63
commit
9f18be847e
|
|
@ -106,6 +106,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function onButtonShort(btn) {
|
function onButtonShort(btn) {
|
||||||
|
log_debug("onButtonShort()");
|
||||||
if (gpsObject.getState() !== gpsObject.GPS_RUNNING) return;
|
if (gpsObject.getState() !== gpsObject.GPS_RUNNING) return;
|
||||||
switch(btn) {
|
switch(btn) {
|
||||||
case 1:
|
case 1:
|
||||||
|
|
@ -129,7 +130,6 @@
|
||||||
log_debug("markWaypoint()");
|
log_debug("markWaypoint()");
|
||||||
if (btn !== 1) return;
|
if (btn !== 1) return;
|
||||||
if (gpsObject.getState() !== gpsObject.GPS_RUNNING) return;
|
if (gpsObject.getState() !== gpsObject.GPS_RUNNING) return;
|
||||||
|
|
||||||
log_debug("markWaypoint()");
|
log_debug("markWaypoint()");
|
||||||
|
|
||||||
gpsObject.markWaypoint();
|
gpsObject.markWaypoint();
|
||||||
|
|
@ -144,8 +144,8 @@
|
||||||
wp_distance = gpsObject.getWPdistance();
|
wp_distance = gpsObject.getWPdistance();
|
||||||
wp_bearing = gpsObject.getWPbearing();
|
wp_bearing = gpsObject.getWPbearing();
|
||||||
log_debug(wp);
|
log_debug(wp);
|
||||||
log_debug(wp_distance);
|
log_debug("wp_distance:" + wp_distance);
|
||||||
log_debug(wp_bearing);
|
log_debug("wp_bearing:" + wp_bearing);
|
||||||
}
|
}
|
||||||
|
|
||||||
// takes 32ms
|
// takes 32ms
|
||||||
|
|
@ -206,16 +206,8 @@
|
||||||
var d = tiltfixread(CALIBDATA.offset,CALIBDATA.scale);
|
var d = tiltfixread(CALIBDATA.offset,CALIBDATA.scale);
|
||||||
heading = newHeading(d,heading);
|
heading = newHeading(d,heading);
|
||||||
|
|
||||||
if (gpsObject.getState() === gpsObject.GPS_RUNNING) {
|
getWaypoint();
|
||||||
wp_dist = gpsObject.getWPdistance();
|
|
||||||
wp_bearing = gpsObject.getWPbearing();
|
|
||||||
bearing = wp_bearing;
|
|
||||||
} else {
|
|
||||||
bearing = 0;
|
|
||||||
wp_distance = 0;
|
|
||||||
wp_bearing = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
var dir = bearing - heading;
|
var dir = bearing - heading;
|
||||||
if (dir < 0) dir += 360;
|
if (dir < 0) dir += 360;
|
||||||
if (dir > 360) dir -= 360;
|
if (dir > 360) dir -= 360;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue