mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-12-05 16:32:15 +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:
@@ -29,12 +29,14 @@
|
||||
|
||||
using namespace portapack;
|
||||
|
||||
#include "string_format.hpp"
|
||||
|
||||
namespace ui {
|
||||
|
||||
GeoPos::GeoPos(
|
||||
const Point pos
|
||||
) {
|
||||
set_parent_rect({pos, {30 * 8, 3 * 16}});
|
||||
set_parent_rect({pos, { 30 * 8, 3 * 16 }});
|
||||
|
||||
add_children({
|
||||
&labels_position,
|
||||
@@ -42,9 +44,11 @@ GeoPos::GeoPos(
|
||||
&field_lat_degrees,
|
||||
&field_lat_minutes,
|
||||
&field_lat_seconds,
|
||||
&text_lat_decimal,
|
||||
&field_lon_degrees,
|
||||
&field_lon_minutes,
|
||||
&field_lon_seconds
|
||||
&field_lon_seconds,
|
||||
&text_lon_decimal
|
||||
});
|
||||
|
||||
// Defaults
|
||||
@@ -53,8 +57,22 @@ GeoPos::GeoPos(
|
||||
set_lon(0);
|
||||
|
||||
const auto changed_fn = [this](int32_t) {
|
||||
float lat_value = lat();
|
||||
float lon_value = lon();
|
||||
double integer_part;
|
||||
double fractional_part;
|
||||
|
||||
fractional_part = modf(lat_value, &integer_part) * 100000;
|
||||
if (fractional_part < 0)
|
||||
fractional_part = -fractional_part;
|
||||
text_lat_decimal.set(to_string_dec_int(integer_part) + "." + to_string_dec_uint(fractional_part, 5));
|
||||
fractional_part = modf(lon_value, &integer_part) * 100000;
|
||||
if (fractional_part < 0)
|
||||
fractional_part = -fractional_part;
|
||||
text_lon_decimal.set(to_string_dec_int(integer_part) + "." + to_string_dec_uint(fractional_part, 5));
|
||||
|
||||
if (on_change && report_change)
|
||||
on_change(altitude(), lat(), lon());
|
||||
on_change(altitude(), lat_value, lon_value);
|
||||
};
|
||||
|
||||
field_altitude.on_change = changed_fn;
|
||||
@@ -66,6 +84,11 @@ GeoPos::GeoPos(
|
||||
field_lon_seconds.on_change = changed_fn;
|
||||
}
|
||||
|
||||
void GeoPos::set_read_only(bool v) {
|
||||
for(auto child : children_)
|
||||
child->set_focusable(!v);
|
||||
}
|
||||
|
||||
// Stupid hack to avoid an event loop
|
||||
void GeoPos::set_report_change(bool v) {
|
||||
report_change = v;
|
||||
@@ -103,10 +126,6 @@ int32_t GeoPos::altitude() {
|
||||
return field_altitude.value();
|
||||
};
|
||||
|
||||
void GeoPos::set_read_only(bool v) {
|
||||
set_focusable(~v);
|
||||
};
|
||||
|
||||
GeoMap::GeoMap(
|
||||
Rect parent_rect
|
||||
) : Widget { parent_rect }
|
||||
@@ -117,7 +136,6 @@ GeoMap::GeoMap(
|
||||
void GeoMap::paint(Painter& painter) {
|
||||
Coord line;
|
||||
std::array<ui::Color, 240> map_line_buffer;
|
||||
//Color border;
|
||||
const auto r = screen_rect();
|
||||
|
||||
// Ony redraw map if it moved by at least 1 pixel
|
||||
|
||||
@@ -60,13 +60,13 @@ private:
|
||||
bool report_change { true };
|
||||
|
||||
Labels labels_position {
|
||||
{ { 2 * 8, 0 * 16 }, "Alt: feet", Color::light_grey() },
|
||||
{ { 2 * 8, 1 * 16 }, "Lat: * ' \"", Color::light_grey() }, // No ° symbol in 8x16 font
|
||||
{ { 2 * 8, 2 * 16 }, "Lon: * ' \"", Color::light_grey() },
|
||||
{ { 1 * 8, 0 * 16 }, "Alt: feet", Color::light_grey() },
|
||||
{ { 1 * 8, 1 * 16 }, "Lat: * ' \"", Color::light_grey() }, // No ° symbol in 8x16 font
|
||||
{ { 1 * 8, 2 * 16 }, "Lon: * ' \"", Color::light_grey() },
|
||||
};
|
||||
|
||||
NumberField field_altitude {
|
||||
{ 7 * 8, 0 * 16 },
|
||||
{ 6 * 8, 0 * 16 },
|
||||
5,
|
||||
{ -1000, 50000 },
|
||||
250,
|
||||
@@ -74,23 +74,31 @@ private:
|
||||
};
|
||||
|
||||
NumberField field_lat_degrees {
|
||||
{ 7 * 8, 1 * 16 }, 4, { -90, 90 }, 1, ' '
|
||||
{ 5 * 8, 1 * 16 }, 4, { -90, 90 }, 1, ' '
|
||||
};
|
||||
NumberField field_lat_minutes {
|
||||
{ 12 * 8, 1 * 16 }, 2, { 0, 59 }, 1, ' '
|
||||
{ 10 * 8, 1 * 16 }, 2, { 0, 59 }, 1, ' '
|
||||
};
|
||||
NumberField field_lat_seconds {
|
||||
{ 15 * 8, 1 * 16 }, 2, { 0, 59 }, 1, ' '
|
||||
{ 13 * 8, 1 * 16 }, 2, { 0, 59 }, 1, ' '
|
||||
};
|
||||
Text text_lat_decimal {
|
||||
{ 17 * 8, 1 * 16, 13 * 8, 1 * 16 },
|
||||
""
|
||||
};
|
||||
|
||||
NumberField field_lon_degrees {
|
||||
{ 7 * 8, 2 * 16 }, 4, { -180, 180 }, 1, ' '
|
||||
{ 5 * 8, 2 * 16 }, 4, { -180, 180 }, 1, ' '
|
||||
};
|
||||
NumberField field_lon_minutes {
|
||||
{ 12 * 8, 2 * 16 }, 2, { 0, 59 }, 1, ' '
|
||||
{ 10 * 8, 2 * 16 }, 2, { 0, 59 }, 1, ' '
|
||||
};
|
||||
NumberField field_lon_seconds {
|
||||
{ 15 * 8, 2 * 16 }, 2, { 0, 59 }, 1, ' '
|
||||
{ 13 * 8, 2 * 16 }, 2, { 0, 59 }, 1, ' '
|
||||
};
|
||||
Text text_lon_decimal {
|
||||
{ 17 * 8, 2 * 16, 13 * 8, 1 * 16 },
|
||||
""
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -21,20 +21,17 @@
|
||||
*/
|
||||
|
||||
#include "ui_sonde.hpp"
|
||||
|
||||
#include "baseband_api.hpp"
|
||||
|
||||
#include "portapack.hpp"
|
||||
using namespace portapack;
|
||||
|
||||
//#include "manchester.hpp"
|
||||
|
||||
#include "string_format.hpp"
|
||||
|
||||
/*void SondeLogger::on_packet(const sonde::Packet& packet) {
|
||||
void SondeLogger::on_packet(const sonde::Packet& packet) {
|
||||
const auto formatted = packet.symbols_formatted();
|
||||
log_file.write_entry(packet.received_at(), formatted.data + "/" + formatted.errors);
|
||||
}*/
|
||||
log_file.write_entry(packet.received_at(), formatted.data);
|
||||
}
|
||||
|
||||
namespace ui {
|
||||
|
||||
@@ -43,15 +40,15 @@ SondeView::SondeView(NavigationView& nav) {
|
||||
|
||||
add_children({
|
||||
&labels,
|
||||
&field_frequency,
|
||||
&field_rf_amp,
|
||||
&field_lna,
|
||||
&field_vga,
|
||||
&rssi,
|
||||
&field_frequency,
|
||||
&text_debug_a,
|
||||
&text_debug_b,
|
||||
&check_log,
|
||||
&text_signature,
|
||||
&text_sats,
|
||||
&text_serial,
|
||||
&text_voltage,
|
||||
&geopos,
|
||||
&button_see_map
|
||||
});
|
||||
@@ -73,6 +70,10 @@ SondeView::SondeView(NavigationView& nav) {
|
||||
|
||||
geopos.set_read_only(true);
|
||||
|
||||
check_log.on_select = [this](Checkbox&, bool v) {
|
||||
logging = v;
|
||||
};
|
||||
|
||||
radio::enable({
|
||||
tuning_frequency(),
|
||||
sampling_rate,
|
||||
@@ -92,10 +93,10 @@ SondeView::SondeView(NavigationView& nav) {
|
||||
0);
|
||||
};
|
||||
|
||||
/*logger = std::make_unique<SondeLogger>();
|
||||
if( logger ) {
|
||||
logger = std::make_unique<SondeLogger>();
|
||||
if (logger)
|
||||
logger->append(u"sonde.txt");
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
SondeView::~SondeView() {
|
||||
@@ -108,14 +109,11 @@ void SondeView::focus() {
|
||||
}
|
||||
|
||||
void SondeView::on_packet(const sonde::Packet& packet) {
|
||||
const auto hex_formatted = packet.symbols_formatted();
|
||||
|
||||
text_debug_a.set(hex_formatted.data.substr(0, 30));
|
||||
text_debug_b.set(hex_formatted.errors.substr(0, 30));
|
||||
//const auto hex_formatted = packet.symbols_formatted();
|
||||
|
||||
text_signature.set(packet.signature());
|
||||
|
||||
text_sats.set(to_string_dec_uint(packet.visible_sats()));
|
||||
text_serial.set(packet.serial_number());
|
||||
text_voltage.set(to_string_dec_uint(packet.battery_voltage()) + "mV");
|
||||
|
||||
altitude = packet.GPS_altitude();
|
||||
latitude = packet.GPS_latitude();
|
||||
@@ -125,9 +123,9 @@ void SondeView::on_packet(const sonde::Packet& packet) {
|
||||
geopos.set_lat(latitude);
|
||||
geopos.set_lon(longitude);
|
||||
|
||||
/*if( logger ) {
|
||||
if (logger && logging) {
|
||||
logger->on_packet(packet);
|
||||
}*/
|
||||
}
|
||||
|
||||
/*if( packet.crc_ok() ) {
|
||||
}*/
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include "ui_navigation.hpp"
|
||||
#include "ui_receiver.hpp"
|
||||
#include "ui_rssi.hpp"
|
||||
#include "ui_channel.hpp"
|
||||
#include "ui_geomap.hpp"
|
||||
|
||||
#include "event_m0.hpp"
|
||||
@@ -35,12 +34,10 @@
|
||||
|
||||
#include "sonde_packet.hpp"
|
||||
|
||||
#include "recent_entries.hpp"
|
||||
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
|
||||
/*class SondeLogger {
|
||||
class SondeLogger {
|
||||
public:
|
||||
Optional<File::Error> append(const std::filesystem::path& filename) {
|
||||
return log_file.append(filename);
|
||||
@@ -50,7 +47,7 @@ public:
|
||||
|
||||
private:
|
||||
LogFile log_file { };
|
||||
};*/
|
||||
};
|
||||
|
||||
namespace ui {
|
||||
|
||||
@@ -67,16 +64,17 @@ public:
|
||||
std::string title() const override { return "Radiosonde RX"; };
|
||||
|
||||
private:
|
||||
//std::unique_ptr<SondeLogger> logger { };
|
||||
std::unique_ptr<SondeLogger> logger { };
|
||||
uint32_t target_frequency_ { 402000000 };
|
||||
bool logging { false };
|
||||
int32_t altitude { 0 };
|
||||
float latitude { 0 };
|
||||
float longitude { 0 };
|
||||
|
||||
Labels labels {
|
||||
{ { 3 * 8, 5 * 16 }, "Signature:", Color::light_grey() },
|
||||
{ { 0 * 8, 6 * 16 }, "Visible sats:", Color::light_grey() },
|
||||
//{ { 4 * 8, 7 * 16 }, "Altitude:", Color::light_grey() },
|
||||
{ { 0 * 8, 2 * 16 }, "Signature:", Color::light_grey() },
|
||||
{ { 3 * 8, 3 * 16 }, "Serial:", Color::light_grey() },
|
||||
{ { 4 * 8, 4 * 16 }, "Vbatt:", Color::light_grey() }
|
||||
};
|
||||
|
||||
FrequencyField field_frequency {
|
||||
@@ -98,30 +96,31 @@ private:
|
||||
{ 21 * 8, 0, 6 * 8, 4 },
|
||||
};
|
||||
|
||||
Text text_debug_a {
|
||||
{ 0, 2 * 16, 240, 16 },
|
||||
"Waiting for frame..."
|
||||
};
|
||||
Text text_debug_b {
|
||||
{ 0, 3 * 16, 240, 16 },
|
||||
"Waiting for frame..."
|
||||
Checkbox check_log {
|
||||
{ 22 * 8, 2 * 16 + 8 },
|
||||
3,
|
||||
"Log"
|
||||
};
|
||||
|
||||
Text text_signature {
|
||||
{ 13 * 8, 5 * 16, 240, 16 },
|
||||
{ 10 * 8, 2 * 16, 10 * 8, 16 },
|
||||
"..."
|
||||
};
|
||||
Text text_sats {
|
||||
{ 13 * 8, 6 * 16, 240, 16 },
|
||||
Text text_serial {
|
||||
{ 10 * 8, 3 * 16, 11 * 8, 16 },
|
||||
"..."
|
||||
};
|
||||
Text text_voltage {
|
||||
{ 10 * 8, 4 * 16, 10 * 8, 16 },
|
||||
"..."
|
||||
};
|
||||
|
||||
GeoPos geopos {
|
||||
{ 0, 8 * 16 }
|
||||
{ 0, 6 * 16 }
|
||||
};
|
||||
|
||||
Button button_see_map {
|
||||
{ 8 * 8, 12 * 16, 14 * 8, 3 * 16 },
|
||||
{ 8 * 8, 10 * 16, 14 * 8, 3 * 16 },
|
||||
"See on map"
|
||||
};
|
||||
|
||||
@@ -134,7 +133,6 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
//void on_packet(const sonde::Packet& packet);
|
||||
void on_packet(const sonde::Packet& packet);
|
||||
void set_target_frequency(const uint32_t new_value);
|
||||
uint32_t tuning_frequency() const;
|
||||
|
||||
Reference in New Issue
Block a user