mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-15 08:57:42 +00:00
added qr code for radiosonde
This commit is contained in:
@@ -41,6 +41,7 @@ void SondeLogger::on_packet(const sonde::Packet& packet) {
|
||||
|
||||
namespace ui {
|
||||
|
||||
|
||||
SondeView::SondeView(NavigationView& nav) {
|
||||
baseband::run_image(portapack::spi_flash::image_tag_sonde);
|
||||
|
||||
@@ -63,6 +64,7 @@ SondeView::SondeView(NavigationView& nav) {
|
||||
&text_temp,
|
||||
&text_humid,
|
||||
&geopos,
|
||||
&button_see_qr,
|
||||
&button_see_map
|
||||
});
|
||||
|
||||
@@ -108,6 +110,12 @@ SondeView::SondeView(NavigationView& nav) {
|
||||
static_cast<int8_t>(receiver_model.vga()),
|
||||
});
|
||||
|
||||
|
||||
// QR code with geo URI
|
||||
button_see_qr.on_select = [this, &nav](Button&) {
|
||||
nav.push<QRCodeView>(geo_uri);
|
||||
};
|
||||
|
||||
button_see_map.on_select = [this, &nav](Button&) {
|
||||
nav.push<GeoMapView>(
|
||||
sonde_id,
|
||||
@@ -154,10 +162,56 @@ void SondeView::focus() {
|
||||
field_vga.focus();
|
||||
}
|
||||
|
||||
|
||||
// used to convert float to character pointer, since unfortunately function like
|
||||
// sprintf and c_str aren't supported.
|
||||
char * SondeView::float_to_char(float x, char *p)
|
||||
{
|
||||
|
||||
char *s = p + 9; // go to end of buffer
|
||||
uint16_t decimals; // variable to store the decimals
|
||||
int units; // variable to store the units (part to left of decimal place)
|
||||
if (x < 0) { // take care of negative numbers
|
||||
decimals = (int)(x * -100000) % 100000; // make 1000 for 3 decimals etc.
|
||||
units = (int)(-1 * x);
|
||||
} else { // positive numbers
|
||||
decimals = (int)(x * 100000) % 100000;
|
||||
units = (int)x;
|
||||
}
|
||||
|
||||
// TODO: more elegant solution (loop?)
|
||||
*--s = (decimals % 10) + '0';
|
||||
decimals /= 10;
|
||||
*--s = (decimals % 10) + '0';
|
||||
decimals /= 10;
|
||||
*--s = (decimals % 10) + '0';
|
||||
decimals /= 10;
|
||||
*--s = (decimals % 10) + '0';
|
||||
decimals /= 10;
|
||||
*--s = (decimals % 10) + '0';
|
||||
*--s = '.';
|
||||
|
||||
while (units > 0) {
|
||||
*--s = (units % 10) + '0';
|
||||
units /= 10;
|
||||
}
|
||||
if (x < 0) *--s = '-'; // unary minus sign for negative numbers
|
||||
return s;
|
||||
}
|
||||
|
||||
void SondeView::on_packet(const sonde::Packet &packet)
|
||||
{
|
||||
if (!use_crc || packet.crc_ok()) //euquiq: Reject bad packet if crc is on
|
||||
{
|
||||
|
||||
char buffer_lat[10] = {};
|
||||
char buffer_lon[10] = {};
|
||||
|
||||
strcpy(geo_uri, "geo:");
|
||||
strcat(geo_uri, float_to_char(gps_info.lat, buffer_lat));
|
||||
strcat(geo_uri, ",");
|
||||
strcat(geo_uri, float_to_char(gps_info.lon, buffer_lon));
|
||||
|
||||
text_signature.set(packet.type_string());
|
||||
|
||||
sonde_id = packet.serial_number(); //used also as tag on the geomap
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include "ui_navigation.hpp"
|
||||
#include "ui_receiver.hpp"
|
||||
#include "ui_rssi.hpp"
|
||||
#include "ui_qrcode.hpp"
|
||||
#include "ui_geomap.hpp"
|
||||
|
||||
#include "event_m0.hpp"
|
||||
@@ -63,6 +64,8 @@ public:
|
||||
|
||||
std::string title() const override { return "Radiosonde RX"; };
|
||||
|
||||
|
||||
|
||||
private:
|
||||
std::unique_ptr<SondeLogger> logger { };
|
||||
uint32_t target_frequency_ { 402700000 };
|
||||
@@ -70,6 +73,8 @@ private:
|
||||
bool use_crc { false };
|
||||
bool beep { false };
|
||||
|
||||
char geo_uri[32] = {};
|
||||
|
||||
sonde::GPS_data gps_info { };
|
||||
sonde::temp_humid temp_humid_info { };
|
||||
std::string sonde_id { };
|
||||
@@ -173,9 +178,15 @@ private:
|
||||
{ 0, 12 * 16 },
|
||||
GeoPos::alt_unit::METERS
|
||||
};
|
||||
|
||||
|
||||
|
||||
Button button_see_qr {
|
||||
{ 2 * 8, 15 * 16, 12 * 8, 3 * 16 },
|
||||
"See QR"
|
||||
};
|
||||
|
||||
Button button_see_map {
|
||||
{ 8 * 8, 16 * 16, 14 * 8, 3 * 16 },
|
||||
{ 16 * 8, 15 * 16, 12 * 8, 3 * 16 },
|
||||
"See on map"
|
||||
};
|
||||
|
||||
@@ -190,7 +201,7 @@ private:
|
||||
|
||||
void on_packet(const sonde::Packet& packet);
|
||||
void on_headphone_volume_changed(int32_t v);
|
||||
|
||||
char * float_to_char(float x, char *p);
|
||||
void set_target_frequency(const uint32_t new_value);
|
||||
|
||||
uint32_t tuning_frequency() const;
|
||||
|
Reference in New Issue
Block a user