Increased GPS altitude resolution
This commit is contained in:
parent
7ab96b67bc
commit
a3f036c4d2
@ -151,11 +151,8 @@ var altitude = function (bytes) {
|
|||||||
if (bytes.length !== altitude.BYTES) {
|
if (bytes.length !== altitude.BYTES) {
|
||||||
throw new Error('Altitude must have exactly 2 bytes');
|
throw new Error('Altitude must have exactly 2 bytes');
|
||||||
}
|
}
|
||||||
var alt = bytesToInt(bytes);
|
var alt = bytesToInt(bytes) / 4 - 1000;
|
||||||
if (alt > 32767) {
|
return +alt.toFixed(1);
|
||||||
alt -= 65536;
|
|
||||||
}
|
|
||||||
return alt;
|
|
||||||
};
|
};
|
||||||
altitude.BYTES = 2;
|
altitude.BYTES = 2;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ function Decoder(bytes, port) {
|
|||||||
decoded.longitude = ((bytes[i++] << 24) | (bytes[i++] << 16) | (bytes[i++] << 8) | bytes[i++]);
|
decoded.longitude = ((bytes[i++] << 24) | (bytes[i++] << 16) | (bytes[i++] << 8) | bytes[i++]);
|
||||||
decoded.sats = bytes[i++];
|
decoded.sats = bytes[i++];
|
||||||
decoded.hdop = (bytes[i++] << 8) | (bytes[i++]);
|
decoded.hdop = (bytes[i++] << 8) | (bytes[i++]);
|
||||||
decoded.altitude = (bytes[i++] << 8) | (bytes[i++]);
|
decoded.altitude = ((bytes[i++] << 8) | (bytes[i++])) / 4 - 1000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ function Decoder(bytes, port) {
|
|||||||
decoded.longitude = ((bytes[i++] << 24) | (bytes[i++] << 16) | (bytes[i++] << 8) | bytes[i++]);
|
decoded.longitude = ((bytes[i++] << 24) | (bytes[i++] << 16) | (bytes[i++] << 8) | bytes[i++]);
|
||||||
decoded.sats = bytes[i++];
|
decoded.sats = bytes[i++];
|
||||||
decoded.hdop = (bytes[i++] << 8) | (bytes[i++]);
|
decoded.hdop = (bytes[i++] << 8) | (bytes[i++]);
|
||||||
decoded.altitude = (bytes[i++] << 8) | (bytes[i++]);
|
decoded.altitude = ((bytes[i++] << 8) | (bytes[i++])) / 4 - 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (port === 5) {
|
if (port === 5) {
|
||||||
|
@ -71,7 +71,7 @@ void gps_storelocation(gpsStatus_t &gps_store) {
|
|||||||
gps_store.longitude = (int32_t)(gps.location.lng() * 1e6);
|
gps_store.longitude = (int32_t)(gps.location.lng() * 1e6);
|
||||||
gps_store.satellites = (uint8_t)gps.satellites.value();
|
gps_store.satellites = (uint8_t)gps.satellites.value();
|
||||||
gps_store.hdop = (uint16_t)gps.hdop.value();
|
gps_store.hdop = (uint16_t)gps.hdop.value();
|
||||||
gps_store.altitude = (int16_t)gps.altitude.meters();
|
gps_store.altitude = (int16_t)((gps.altitude.meters() + 1000) * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
// store current GPS timedate in struct
|
// store current GPS timedate in struct
|
||||||
|
Loading…
Reference in New Issue
Block a user