mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-14 09:25:30 -04:00
Radiosonde-vaisala-add-temp-humidity
Also added the fields "DateTime" which just shows the raw timestamp that portapack assigned the last packet received, in the format: YYYYMMDDHHMMSS ... And "Frame" which shows the packet # (or frame) for correlating with other software / verify that there are new packets being received. Also moved a string function for returning rounded-up decimals, originally inside the whipcalc tool app, into the string_format functions library, because I used that function on TEMP and HUMIDITY values inisde the radiosonde app. Finally, the whole UI has its widgets moved a bit, giving space for these new parameters.
This commit is contained in:
parent
c626d83c3b
commit
13abb620f6
8 changed files with 409 additions and 134 deletions
|
@ -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();
|
||||
|
@ -46,9 +51,14 @@ SondeView::SondeView(NavigationView& nav) {
|
|||
&field_vga,
|
||||
&rssi,
|
||||
&check_log,
|
||||
&check_crc,
|
||||
&text_signature,
|
||||
&text_serial,
|
||||
&text_timestamp,
|
||||
&text_voltage,
|
||||
&text_frame,
|
||||
&text_temp,
|
||||
&text_humid,
|
||||
&geopos,
|
||||
&button_see_map
|
||||
});
|
||||
|
@ -73,6 +83,10 @@ SondeView::SondeView(NavigationView& nav) {
|
|||
check_log.on_select = [this](Checkbox&, bool v) {
|
||||
logging = v;
|
||||
};
|
||||
|
||||
check_crc.on_select = [this](Checkbox&, bool v) {
|
||||
use_crc = v;
|
||||
};
|
||||
|
||||
radio::enable({
|
||||
tuning_frequency(),
|
||||
|
@ -109,26 +123,46 @@ void SondeView::focus() {
|
|||
field_vga.focus();
|
||||
}
|
||||
|
||||
void SondeView::on_packet(const sonde::Packet& packet) {
|
||||
//const auto hex_formatted = packet.symbols_formatted();
|
||||
|
||||
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");
|
||||
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());
|
||||
|
||||
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);
|
||||
sonde_id = packet.serial_number(); //used also as tag on the geomap
|
||||
text_serial.set(sonde_id);
|
||||
|
||||
text_timestamp.set(to_string_timestamp(packet.received_at()));
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/*if( packet.crc_ok() ) {
|
||||
}*/
|
||||
}
|
||||
|
||||
void SondeView::set_target_frequency(const uint32_t new_value) {
|
||||
|
|
|
@ -67,18 +67,26 @@ private:
|
|||
std::unique_ptr<SondeLogger> logger { };
|
||||
uint32_t target_frequency_ { 402700000 };
|
||||
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 }
|
||||
};
|
||||
|
@ -96,31 +104,59 @@ private:
|
|||
};
|
||||
|
||||
Checkbox check_log {
|
||||
{ 22 * 8, 3 * 16 },
|
||||
{ 23 * 8, 6 * 16 },
|
||||
3,
|
||||
"Log"
|
||||
};
|
||||
|
||||
Text text_signature {
|
||||
{ 10 * 8, 2 * 16, 10 * 8, 16 },
|
||||
"..."
|
||||
};
|
||||
Text text_serial {
|
||||
{ 10 * 8, 3 * 16, 11 * 8, 16 },
|
||||
"..."
|
||||
};
|
||||
Text text_voltage {
|
||||
{ 10 * 8, 4 * 16, 10 * 8, 16 },
|
||||
"..."
|
||||
Checkbox check_crc {
|
||||
{ 23 * 8, 8 * 16 },
|
||||
3,
|
||||
"CRC"
|
||||
};
|
||||
|
||||
Text text_signature {
|
||||
{ 9 * 8, 2 * 16, 10 * 8, 16 },
|
||||
"..."
|
||||
};
|
||||
|
||||
Text text_serial {
|
||||
{ 9 * 8, 3 * 16, 11 * 8, 16 },
|
||||
"..."
|
||||
};
|
||||
|
||||
Text text_timestamp {
|
||||
{ 9 * 8, 4 * 16, 11 * 8, 16 },
|
||||
"..."
|
||||
};
|
||||
|
||||
Text text_voltage {
|
||||
{ 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, 6 * 16 },
|
||||
{ 0, 12 * 16 },
|
||||
GeoPos::alt_unit::METERS
|
||||
};
|
||||
|
||||
Button button_see_map {
|
||||
{ 8 * 8, 10 * 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 &);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue