Increased GPS altitude resolution
This commit is contained in:
1 parent
7ab96b67bc
commit
a3f036c4d2
3 files changed
+5
-8
No files matched your search
@@ -151,11 +151,8 @@ var altitude = function (bytes) {
|
||||
if (bytes.length !== altitude.BYTES) {
|
||||
throw new Error('Altitude must have exactly 2 bytes');
|
||||
}
|
||||
var alt = bytesToInt(bytes);
|
||||
if (alt > 32767) {
|
||||
alt -= 65536;
|
||||
}
|
||||
return alt;
|
||||
var alt = bytesToInt(bytes) / 4 - 1000;
|
||||
return +alt.toFixed(1);
|
||||
};
|
||||
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.sats = 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.sats = 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) {
|
||||
|
||||
Reference in new issue
Block a user