mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-10-17 17:35:18 +00:00
Merge branch 'pr/166' into Radiosonde-vaisala-add-temp-humidity-merge-conflicts-fix
This commit is contained in:
@@ -24,9 +24,14 @@
|
||||
#include "baseband_api.hpp"
|
||||
|
||||
#include "portapack.hpp"
|
||||
#include <cstring>
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace portapack;
|
||||
|
||||
#include "string_format.hpp"
|
||||
#include "complex.hpp"
|
||||
|
||||
|
||||
void SondeLogger::on_packet(const sonde::Packet& packet) {
|
||||
const auto formatted = packet.symbols_formatted();
|
||||
@@ -49,7 +54,11 @@ SondeView::SondeView(NavigationView& nav) {
|
||||
&check_crc,
|
||||
&text_signature,
|
||||
&text_serial,
|
||||
&text_timestamp,
|
||||
&text_voltage,
|
||||
&text_frame,
|
||||
&text_temp,
|
||||
&text_humid,
|
||||
&geopos,
|
||||
&button_see_map
|
||||
});
|
||||
@@ -114,24 +123,45 @@ void SondeView::focus() {
|
||||
field_vga.focus();
|
||||
}
|
||||
|
||||
void SondeView::on_packet(const sonde::Packet& packet) {
|
||||
void SondeView::on_packet(const sonde::Packet &packet)
|
||||
{
|
||||
if (!use_crc || packet.crc_ok()) //euquiq: Reject bad packet if crc is on
|
||||
{
|
||||
text_signature.set(packet.type_string());
|
||||
|
||||
if (use_crc && !packet.crc_ok()) //euquiq: Reject bad packet if crc is on
|
||||
return;
|
||||
sonde_id = packet.serial_number(); //used also as tag on the geomap
|
||||
text_serial.set(sonde_id);
|
||||
|
||||
text_signature.set(packet.type_string());
|
||||
sonde_id = packet.serial_number(); //used also as tag on the geomap
|
||||
text_serial.set(sonde_id);
|
||||
text_voltage.set(unit_auto_scale(packet.battery_voltage(), 2, 3) + "V");
|
||||
text_timestamp.set(to_string_timestamp(packet.received_at()));
|
||||
|
||||
gps_info = packet.get_GPS_data();
|
||||
|
||||
geopos.set_altitude(gps_info.alt);
|
||||
geopos.set_lat(gps_info.lat);
|
||||
geopos.set_lon(gps_info.lon);
|
||||
|
||||
if (logger && logging) {
|
||||
logger->on_packet(packet);
|
||||
text_voltage.set(unit_auto_scale(packet.battery_voltage(), 2, 2) + "V");
|
||||
|
||||
text_frame.set(to_string_dec_uint(packet.frame(),0)); //euquiq: integrate frame #, temp & humid.
|
||||
|
||||
temp_humid_info = packet.get_temp_humid();
|
||||
if (temp_humid_info.humid != 0)
|
||||
{
|
||||
double decimals = abs(get_decimals(temp_humid_info.humid, 10, true));
|
||||
//if (decimals < 0)
|
||||
// decimals = -decimals;
|
||||
text_humid.set(to_string_dec_int((int)temp_humid_info.humid) + "." + to_string_dec_uint(decimals, 1) + "%");
|
||||
}
|
||||
|
||||
if (temp_humid_info.temp != 0)
|
||||
{
|
||||
double decimals = abs(get_decimals(temp_humid_info.temp, 10, true));
|
||||
// if (decimals < 0)
|
||||
// decimals = -decimals;
|
||||
text_temp.set(to_string_dec_int((int)temp_humid_info.temp) + "." + to_string_dec_uint(decimals, 1) + "C");
|
||||
}
|
||||
|
||||
gps_info = packet.get_GPS_data();
|
||||
geopos.set_altitude(gps_info.alt);
|
||||
geopos.set_lat(gps_info.lat);
|
||||
geopos.set_lon(gps_info.lon);
|
||||
|
||||
if (logger && logging)
|
||||
logger->on_packet(packet);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -69,17 +69,24 @@ private:
|
||||
bool logging { false };
|
||||
bool use_crc { false };
|
||||
sonde::GPS_data gps_info;
|
||||
sonde::temp_humid temp_humid_info;
|
||||
std::string sonde_id;
|
||||
|
||||
Labels labels {
|
||||
{ { 0 * 8, 2 * 16 }, "Signature:", Color::light_grey() },
|
||||
{ { 3 * 8, 3 * 16 }, "Serial:", Color::light_grey() },
|
||||
{ { 4 * 8, 4 * 16 }, "Vbatt:", Color::light_grey() }
|
||||
{ { 4 * 8, 2 * 16 }, "Type:", Color::light_grey() },
|
||||
{ { 6 * 8, 3 * 16 }, "ID:", Color::light_grey() },
|
||||
{ { 0 * 8, 4 * 16 }, "DateTime:", Color::light_grey() },
|
||||
|
||||
{ { 3 * 8, 5 * 16 }, "Vbatt:", Color::light_grey() },
|
||||
{ { 3 * 8, 6 * 16 }, "Frame:", Color::light_grey() },
|
||||
{ { 4 * 8, 7 * 16 }, "Temp:", Color::light_grey() },
|
||||
{ { 0 * 8, 8 * 16 }, "Humidity:", Color::light_grey() }
|
||||
};
|
||||
|
||||
FrequencyField field_frequency {
|
||||
{ 0 * 8, 0 * 8 },
|
||||
};
|
||||
|
||||
RFAmpField field_rf_amp {
|
||||
{ 13 * 8, 0 * 16 }
|
||||
};
|
||||
@@ -97,37 +104,59 @@ private:
|
||||
};
|
||||
|
||||
Checkbox check_log {
|
||||
{ 22 * 8, 3 * 16 },
|
||||
{ 23 * 8, 6 * 16 },
|
||||
3,
|
||||
"Log"
|
||||
};
|
||||
|
||||
Checkbox check_crc {
|
||||
{ 22 * 8, 5 * 16 },
|
||||
{ 23 * 8, 8 * 16 },
|
||||
3,
|
||||
"CRC"
|
||||
};
|
||||
|
||||
Text text_signature {
|
||||
{ 10 * 8, 2 * 16, 10 * 8, 16 },
|
||||
{ 9 * 8, 2 * 16, 10 * 8, 16 },
|
||||
"..."
|
||||
};
|
||||
|
||||
Text text_serial {
|
||||
{ 10 * 8, 3 * 16, 11 * 8, 16 },
|
||||
{ 9 * 8, 3 * 16, 11 * 8, 16 },
|
||||
"..."
|
||||
};
|
||||
|
||||
Text text_timestamp {
|
||||
{ 9 * 8, 4 * 16, 11 * 8, 16 },
|
||||
"..."
|
||||
};
|
||||
|
||||
Text text_voltage {
|
||||
{ 10 * 8, 4 * 16, 10 * 8, 16 },
|
||||
{ 9 * 8, 5 * 16, 10 * 8, 16 },
|
||||
"..."
|
||||
};
|
||||
|
||||
|
||||
Text text_frame {
|
||||
{ 9 * 8, 6 * 16, 10 * 8, 16 },
|
||||
"..."
|
||||
};
|
||||
|
||||
Text text_temp {
|
||||
{ 9 * 8, 7 * 16, 10 * 8, 16 },
|
||||
"..."
|
||||
};
|
||||
|
||||
Text text_humid {
|
||||
{ 9 * 8, 8 * 16, 10 * 8, 16 },
|
||||
"..."
|
||||
};
|
||||
|
||||
GeoPos geopos {
|
||||
{ 0, 7 * 16 },
|
||||
{ 0, 12 * 16 },
|
||||
GeoPos::alt_unit::METERS
|
||||
};
|
||||
|
||||
Button button_see_map {
|
||||
{ 8 * 8, 11 * 16, 14 * 8, 3 * 16 },
|
||||
{ 8 * 8, 16 * 16, 14 * 8, 3 * 16 },
|
||||
"See on map"
|
||||
};
|
||||
|
||||
|
@@ -38,19 +38,6 @@ namespace ui
|
||||
field_frequency.focus();
|
||||
}
|
||||
|
||||
double ui::WhipCalcView::get_decimals(double num, int16_t mult, bool round)
|
||||
{
|
||||
num -= int(num); //keep decimals only
|
||||
num *= mult; //Shift decimals into integers
|
||||
if (!round)
|
||||
return num;
|
||||
int16_t intnum = int(num); //Round it up if necessary
|
||||
num -= intnum; //Get decimal part
|
||||
if (num > .5)
|
||||
intnum++; //Round up
|
||||
return intnum;
|
||||
}
|
||||
|
||||
void WhipCalcView::update_result()
|
||||
{
|
||||
double length, calclength, divider;
|
||||
|
@@ -51,7 +51,6 @@ namespace ui
|
||||
};
|
||||
|
||||
std::vector<antenna_entry> antenna_db{};
|
||||
double get_decimals(double num, int16_t mult, bool round = false);
|
||||
void update_result();
|
||||
uint16_t string_to_number(std::string);
|
||||
void txtline_process(std::string &);
|
||||
|
@@ -223,3 +223,13 @@ std::string unit_auto_scale(double n, const uint32_t base_nano, uint32_t precisi
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
double get_decimals(double num, int16_t mult, bool round) {
|
||||
num -= int(num); //keep decimals only
|
||||
num *= mult; //Shift decimals into integers
|
||||
if (!round) return num;
|
||||
int16_t intnum = int(num); //Round it up if necessary
|
||||
num -= intnum; //Get decimal part
|
||||
if (num > .5) intnum++; //Round up
|
||||
return intnum;
|
||||
}
|
||||
|
@@ -54,5 +54,5 @@ std::string to_string_timestamp(const rtc::RTC& value);
|
||||
std::string to_string_FAT_timestamp(const FATTimestamp& timestamp);
|
||||
|
||||
std::string unit_auto_scale(double n, const uint32_t base_nano, uint32_t precision);
|
||||
|
||||
double get_decimals(double num, int16_t mult, bool round = false); //euquiq added
|
||||
#endif/*__STRING_FORMAT_H__*/
|
||||
|
Reference in New Issue
Block a user