mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-14 11:17:58 +00:00
Added logging, serial number and battery voltage display to radiosonde RX
Added decimal degrees display to geopos widget
This commit is contained in:
@@ -21,8 +21,7 @@
|
||||
*/
|
||||
|
||||
#include "sonde_packet.hpp"
|
||||
|
||||
//#include "crc.hpp"
|
||||
#include "string_format.hpp"
|
||||
|
||||
namespace sonde {
|
||||
|
||||
@@ -42,12 +41,8 @@ Packet::Type Packet::type() const {
|
||||
return type_;
|
||||
}
|
||||
|
||||
uint32_t Packet::visible_sats() const {
|
||||
return reader_.read(30 * 8, 8);
|
||||
}
|
||||
|
||||
uint32_t Packet::GPS_altitude() const {
|
||||
return reader_.read(22 * 8, 32) / 1000;
|
||||
return (reader_.read(22 * 8, 32) / 1000) - 48;
|
||||
}
|
||||
|
||||
float Packet::GPS_latitude() const {
|
||||
@@ -58,6 +53,10 @@ float Packet::GPS_longitude() const {
|
||||
return reader_.read(18 * 8, 32) / ((1ULL << 32) / 360.0);
|
||||
}
|
||||
|
||||
uint32_t Packet::battery_voltage() const {
|
||||
return (reader_.read(69 * 8, 8) + (reader_.read(70 * 8, 8) << 8)) * 1000 / 150;
|
||||
}
|
||||
|
||||
std::string Packet::signature() const {
|
||||
const auto header = reader_.read(0, 24);
|
||||
|
||||
@@ -66,18 +65,25 @@ std::string Packet::signature() const {
|
||||
else if (header == 0x648F20)
|
||||
return "M2K2";
|
||||
else
|
||||
return symbols_formatted().data.substr(0, 6);
|
||||
return "0x" + symbols_formatted().data.substr(0, 6);
|
||||
}
|
||||
|
||||
SN Packet::serial_number() const {
|
||||
std::string Packet::serial_number() const {
|
||||
if (type() == Type::M10) {
|
||||
// See https://github.com/rs1729/RS/blob/master/m10/m10x.c line 606
|
||||
return (reader_.read(2 * 8, 8) << 20) |
|
||||
(reader_.read(0, 4) << 16) |
|
||||
(reader_.read(4 * 8, 3) << 13) |
|
||||
(reader_.read(4 * 8 + 3, 5) << 8) |
|
||||
reader_.read(3 * 8, 8);
|
||||
// Starting at byte #93: 00000000 11111111 22222222 33333333 44444444
|
||||
// CCCC AAAABBBB
|
||||
// 44444444 33333333
|
||||
// DDDEEEEE EEEEEEEE
|
||||
|
||||
return to_string_hex(reader_.read(93 * 8 + 16, 4), 1) +
|
||||
to_string_dec_uint(reader_.read(93 * 8 + 20, 4), 2, '0') + " " +
|
||||
to_string_hex(reader_.read(93 * 8 + 4, 4), 1) + " " +
|
||||
to_string_dec_uint(reader_.read(93 * 8 + 24, 3), 1) +
|
||||
to_string_dec_uint(reader_.read(93 * 8 + 27, 13), 4, '0');
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user