-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GPS coord's are now properly sent and received. Added payload functions.
Signed-off-by: Brady <brady.aiello@gmail.com>
- Loading branch information
1 parent
24ad218
commit f178aaa
Showing
5 changed files
with
59 additions
and
21 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function Decoder(bytes, port) { | ||
return { | ||
frame_counter: bytes[0] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
function Bytes2Float32(bytes) { | ||
var sign = (bytes & 0x80000000) ? -1 : 1; | ||
var exponent = ((bytes >> 23) & 0xFF) - 127; | ||
var significand = (bytes & ~(-1 << 23)); | ||
|
||
if (exponent == 128) | ||
return sign * ((significand) ? Number.NaN : Number.POSITIVE_INFINITY); | ||
|
||
if (exponent == -127) { | ||
if (significand == 0) return sign * 0.0; | ||
exponent = -126; | ||
significand /= (1 << 22); | ||
} else significand = (significand | (1 << 23)) / (1 << 23); | ||
|
||
return sign * significand * Math.pow(2, exponent); | ||
} | ||
|
||
function Decoder(bytes, port) { | ||
var lat = bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0]; | ||
var lon = bytes[7] << 24 | bytes[6] << 16 | bytes[5] << 8 | bytes[4]; | ||
return{ | ||
latitude: Bytes2Float32(lat), | ||
longitude: Bytes2Float32(lon) | ||
}; | ||
} |