mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-12-05 16:32:15 +00:00
Merge branch 'master' of https://github.com/furrtek/portapack-havoc
This commit is contained in:
@@ -209,6 +209,7 @@ set(CPPSRC
|
||||
ui_spectrum.cpp
|
||||
ui_sstvtx.cpp
|
||||
ui_tabview.cpp
|
||||
ui_test.cpp
|
||||
ui_textentry.cpp
|
||||
ui_touch_calibration.cpp
|
||||
ui_touchtunes.cpp
|
||||
@@ -229,6 +230,7 @@ set(CPPSRC
|
||||
${COMMON}/adsb_frame.cpp
|
||||
${COMMON}/adsb.cpp
|
||||
${COMMON}/sonde_packet.cpp
|
||||
${COMMON}/test_packet.cpp
|
||||
ais_app.cpp
|
||||
tpms_app.cpp
|
||||
pocsag_app.cpp
|
||||
|
||||
@@ -59,7 +59,24 @@ Continuous (Fox-oring)
|
||||
60s transmit, 240s space (Classic 1/5 min)
|
||||
60s transmit, 360s space (Classic 1/7 min)
|
||||
*/
|
||||
<<<<<<< ./firmware/application/main_LOCAL_5232.cpp
|
||||
||||||| ./firmware/application/main_BASE_5232.cpp
|
||||
//TODO: Use TransmitterView in TEDI/LCR, Numbers, ...
|
||||
=======
|
||||
//TODO: Use TransmitterView in TEDI/LCR, Numbers, ...
|
||||
//TODO: Use TransmitterView in TEDI/LCR, Numbers, ...
|
||||
>>>>>>> ./firmware/application/main_REMOTE_5232.cpp
|
||||
//TODO: FreqMan: Remove and rename categories
|
||||
<<<<<<< ./firmware/application/main_LOCAL_5232.cpp
|
||||
||||||| ./firmware/application/main_BASE_5232.cpp
|
||||
//TODO: Wav visualizer
|
||||
//TODO: File browser view ?
|
||||
=======
|
||||
//TODO: Wav visualizer
|
||||
//TODO: File browser view ?
|
||||
//TODO: Wav visualizer
|
||||
//TODO: File browser view ?
|
||||
>>>>>>> ./firmware/application/main_REMOTE_5232.cpp
|
||||
//TODO: Mousejack ?
|
||||
//TODO: Move frequencykeypad from ui_receiver to ui_widget (used everywhere)
|
||||
//TODO: ADS-B draw trajectory + GPS coordinates + scale, and playback
|
||||
|
||||
@@ -161,6 +161,7 @@ ADSBRxDetailsView::ADSBRxDetailsView(
|
||||
geomap_view = nav.push<GeoMapView>(
|
||||
entry_copy.callsign,
|
||||
entry_copy.pos.altitude,
|
||||
GeoPos::alt_unit::FEET,
|
||||
entry_copy.pos.latitude,
|
||||
entry_copy.pos.longitude,
|
||||
0,
|
||||
|
||||
@@ -89,6 +89,7 @@ ADSBPositionView::ADSBPositionView(
|
||||
button_set_map.on_select = [this, &nav](Button&) {
|
||||
nav.push<GeoMapView>(
|
||||
geopos.altitude(),
|
||||
GeoPos::alt_unit::FEET,
|
||||
geopos.lat(),
|
||||
geopos.lon(),
|
||||
[this](int32_t altitude, float lat, float lon) {
|
||||
|
||||
@@ -55,7 +55,8 @@ public:
|
||||
|
||||
private:
|
||||
GeoPos geopos {
|
||||
{ 0, 2 * 16 }
|
||||
{ 0, 2 * 16 },
|
||||
GeoPos::FEET
|
||||
};
|
||||
|
||||
Button button_set_map {
|
||||
|
||||
@@ -29,22 +29,29 @@
|
||||
|
||||
using namespace portapack;
|
||||
|
||||
#include "string_format.hpp"
|
||||
|
||||
namespace ui {
|
||||
|
||||
GeoPos::GeoPos(
|
||||
const Point pos
|
||||
) {
|
||||
set_parent_rect({pos, {30 * 8, 3 * 16}});
|
||||
const Point pos,
|
||||
const alt_unit altitude_unit
|
||||
) : altitude_unit_(altitude_unit) {
|
||||
|
||||
set_parent_rect({pos, { 30 * 8, 3 * 16 }});
|
||||
|
||||
add_children({
|
||||
&labels_position,
|
||||
&field_altitude,
|
||||
&text_alt_unit,
|
||||
&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 +60,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;
|
||||
@@ -64,6 +85,13 @@ GeoPos::GeoPos(
|
||||
field_lon_degrees.on_change = changed_fn;
|
||||
field_lon_minutes.on_change = changed_fn;
|
||||
field_lon_seconds.on_change = changed_fn;
|
||||
|
||||
text_alt_unit.set(altitude_unit_ ? "m" : "ft");
|
||||
}
|
||||
|
||||
void GeoPos::set_read_only(bool v) {
|
||||
for(auto child : children_)
|
||||
child->set_focusable(!v);
|
||||
}
|
||||
|
||||
// Stupid hack to avoid an event loop
|
||||
@@ -103,10 +131,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 +141,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
|
||||
@@ -265,12 +288,14 @@ GeoMapView::GeoMapView(
|
||||
NavigationView& nav,
|
||||
const std::string& tag,
|
||||
int32_t altitude,
|
||||
GeoPos::alt_unit altitude_unit,
|
||||
float lat,
|
||||
float lon,
|
||||
float angle,
|
||||
const std::function<void(void)> on_close
|
||||
) : nav_ (nav),
|
||||
altitude_ (altitude),
|
||||
altitude_unit_ (altitude_unit),
|
||||
lat_ (lat),
|
||||
lon_ (lon),
|
||||
angle_ (angle),
|
||||
@@ -296,11 +321,13 @@ GeoMapView::GeoMapView(
|
||||
GeoMapView::GeoMapView(
|
||||
NavigationView& nav,
|
||||
int32_t altitude,
|
||||
GeoPos::alt_unit altitude_unit,
|
||||
float lat,
|
||||
float lon,
|
||||
const std::function<void(int32_t, float, float)> on_done
|
||||
) : nav_ (nav),
|
||||
altitude_ (altitude),
|
||||
altitude_unit_ (altitude_unit),
|
||||
lat_ (lat),
|
||||
lon_ (lon)
|
||||
{
|
||||
|
||||
@@ -39,9 +39,14 @@ enum GeoMapMode {
|
||||
|
||||
class GeoPos : public View {
|
||||
public:
|
||||
enum alt_unit {
|
||||
FEET = 0,
|
||||
METERS
|
||||
};
|
||||
|
||||
std::function<void(int32_t, float, float)> on_change { };
|
||||
|
||||
GeoPos(const Point pos);
|
||||
GeoPos(const Point pos, const alt_unit altitude_unit);
|
||||
|
||||
void focus() override;
|
||||
|
||||
@@ -58,39 +63,52 @@ public:
|
||||
private:
|
||||
bool read_only { false };
|
||||
bool report_change { true };
|
||||
alt_unit altitude_unit_ { };
|
||||
|
||||
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:", 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,
|
||||
' '
|
||||
};
|
||||
Text text_alt_unit {
|
||||
{ 12 * 8, 0 * 16, 2 * 8, 16 },
|
||||
""
|
||||
};
|
||||
|
||||
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 },
|
||||
""
|
||||
};
|
||||
};
|
||||
|
||||
@@ -133,13 +151,15 @@ public:
|
||||
NavigationView& nav,
|
||||
const std::string& tag,
|
||||
int32_t altitude,
|
||||
GeoPos::alt_unit altitude_unit,
|
||||
float lat,
|
||||
float lon,
|
||||
float angle,
|
||||
const std::function<void(void)> on_close
|
||||
const std::function<void(void)> on_close = nullptr
|
||||
);
|
||||
GeoMapView(NavigationView& nav,
|
||||
int32_t altitude,
|
||||
GeoPos::alt_unit altitude_unit,
|
||||
float lat,
|
||||
float lon,
|
||||
const std::function<void(int32_t, float, float)> on_done
|
||||
@@ -167,6 +187,7 @@ private:
|
||||
const Dim banner_height = 3 * 16;
|
||||
GeoMapMode mode_ { };
|
||||
int32_t altitude_ { };
|
||||
GeoPos::alt_unit altitude_unit_ { };
|
||||
float lat_ { };
|
||||
float lon_ { };
|
||||
float angle_ { };
|
||||
@@ -175,7 +196,8 @@ private:
|
||||
bool map_opened { };
|
||||
|
||||
GeoPos geopos {
|
||||
{ 0, 0 }
|
||||
{ 0, 0 },
|
||||
altitude_unit_
|
||||
};
|
||||
|
||||
GeoMap geomap {
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
#include "ui_sonde.hpp"
|
||||
#include "ui_soundboard.hpp"
|
||||
#include "ui_sstvtx.hpp"
|
||||
#include "ui_test.hpp"
|
||||
#include "ui_touchtunes.hpp"
|
||||
#include "ui_view_wav.hpp"
|
||||
#include "ui_whipcalc.hpp"
|
||||
@@ -297,7 +298,7 @@ ReceiversMenuView::ReceiversMenuView(NavigationView& nav) {
|
||||
{ "POCSAG", ui::Color::green(), &bitmap_icon_pocsag, [&nav](){ nav.push<POCSAGAppView>(); } },
|
||||
{ "SIGFOX", ui::Color::grey(), &bitmap_icon_fox, [&nav](){ nav.push<NotImplementedView>(); } }, // SIGFRXView
|
||||
{ "LoRa", ui::Color::grey(), nullptr, [&nav](){ nav.push<NotImplementedView>(); } },
|
||||
{ "Radiosondes", ui::Color::red(), &bitmap_icon_sonde, [&nav](){ nav.push<SondeView>(); } },
|
||||
{ "Radiosondes", ui::Color::yellow(),&bitmap_icon_sonde, [&nav](){ nav.push<SondeView>(); } },
|
||||
{ "SSTV", ui::Color::grey(), &bitmap_icon_sstv, [&nav](){ nav.push<NotImplementedView>(); } },
|
||||
{ "TPMS: Cars", ui::Color::green(), &bitmap_icon_tpms, [&nav](){ nav.push<TPMSAppView>(); } },
|
||||
});
|
||||
@@ -335,6 +336,7 @@ TransmittersMenuView::TransmittersMenuView(NavigationView& nav) {
|
||||
|
||||
UtilitiesMenuView::UtilitiesMenuView(NavigationView& nav) {
|
||||
add_items({
|
||||
{ "Test app", ui::Color::grey(), nullptr, [&nav](){ nav.push<TestView>(); } },
|
||||
{ "Frequency manager", ui::Color::green(), &bitmap_icon_freqman, [&nav](){ nav.push<FrequencyManagerView>(); } },
|
||||
{ "File manager", ui::Color::yellow(), &bitmap_icon_file, [&nav](){ nav.push<FileManagerView>(); } },
|
||||
{ "Whip antenna length", ui::Color::yellow(), nullptr, [&nav](){ nav.push<WhipCalcView>(); } },
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -42,16 +39,22 @@ SondeView::SondeView(NavigationView& nav) {
|
||||
baseband::run_image(portapack::spi_flash::image_tag_sonde);
|
||||
|
||||
add_children({
|
||||
&labels,
|
||||
&field_frequency,
|
||||
&text_debug,
|
||||
&field_rf_amp,
|
||||
&field_lna,
|
||||
&field_vga,
|
||||
&rssi
|
||||
&rssi,
|
||||
&check_log,
|
||||
&text_signature,
|
||||
&text_serial,
|
||||
&text_voltage,
|
||||
&geopos,
|
||||
&button_see_map
|
||||
});
|
||||
|
||||
field_frequency.set_value(receiver_model.tuning_frequency());
|
||||
field_frequency.set_step(receiver_model.frequency_step());
|
||||
field_frequency.set_value(target_frequency_);
|
||||
field_frequency.set_step(10000);
|
||||
field_frequency.on_change = [this](rf::Frequency f) {
|
||||
set_target_frequency(f);
|
||||
field_frequency.set_value(f);
|
||||
@@ -65,8 +68,14 @@ SondeView::SondeView(NavigationView& nav) {
|
||||
};
|
||||
};
|
||||
|
||||
geopos.set_read_only(true);
|
||||
|
||||
check_log.on_select = [this](Checkbox&, bool v) {
|
||||
logging = v;
|
||||
};
|
||||
|
||||
radio::enable({
|
||||
receiver_model.tuning_frequency(),
|
||||
tuning_frequency(),
|
||||
sampling_rate,
|
||||
baseband_bandwidth,
|
||||
rf::Direction::Receive,
|
||||
@@ -74,13 +83,21 @@ SondeView::SondeView(NavigationView& nav) {
|
||||
static_cast<int8_t>(receiver_model.lna()),
|
||||
static_cast<int8_t>(receiver_model.vga()),
|
||||
});
|
||||
|
||||
set_target_frequency(402000000);
|
||||
|
||||
/*logger = std::make_unique<SondeLogger>();
|
||||
if( logger ) {
|
||||
button_see_map.on_select = [this, &nav](Button&) {
|
||||
nav.push<GeoMapView>(
|
||||
"",
|
||||
altitude,
|
||||
GeoPos::alt_unit::METERS,
|
||||
latitude,
|
||||
longitude,
|
||||
0);
|
||||
};
|
||||
|
||||
logger = std::make_unique<SondeLogger>();
|
||||
if (logger)
|
||||
logger->append(u"sonde.txt");
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
SondeView::~SondeView() {
|
||||
@@ -92,19 +109,25 @@ void SondeView::focus() {
|
||||
field_vga.focus();
|
||||
}
|
||||
|
||||
void SondeView::on_packet(const baseband::Packet& packet) {
|
||||
std::string bin_string;
|
||||
void SondeView::on_packet(const sonde::Packet& packet) {
|
||||
//const auto hex_formatted = packet.symbols_formatted();
|
||||
|
||||
for (size_t i = 0; i < 30; i++) {
|
||||
bin_string += to_string_dec_uint(packet[i]);
|
||||
text_signature.set(packet.signature());
|
||||
text_serial.set(packet.serial_number());
|
||||
text_voltage.set(unit_auto_scale(packet.battery_voltage(), 2, 3) + "V");
|
||||
|
||||
altitude = packet.GPS_altitude();
|
||||
latitude = packet.GPS_latitude();
|
||||
longitude = packet.GPS_longitude();
|
||||
|
||||
geopos.set_altitude(altitude);
|
||||
geopos.set_lat(latitude);
|
||||
geopos.set_lon(longitude);
|
||||
|
||||
if (logger && logging) {
|
||||
logger->on_packet(packet);
|
||||
}
|
||||
|
||||
text_debug.set(bin_string);
|
||||
|
||||
/*if( logger ) {
|
||||
logger->on_packet(packet);
|
||||
}*/
|
||||
|
||||
/*if( packet.crc_ok() ) {
|
||||
}*/
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "ui_navigation.hpp"
|
||||
#include "ui_receiver.hpp"
|
||||
#include "ui_rssi.hpp"
|
||||
#include "ui_channel.hpp"
|
||||
#include "ui_geomap.hpp"
|
||||
|
||||
#include "event_m0.hpp"
|
||||
|
||||
@@ -34,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);
|
||||
@@ -49,7 +47,7 @@ public:
|
||||
|
||||
private:
|
||||
LogFile log_file { };
|
||||
};*/
|
||||
};
|
||||
|
||||
namespace ui {
|
||||
|
||||
@@ -66,8 +64,18 @@ public:
|
||||
std::string title() const override { return "Radiosonde RX"; };
|
||||
|
||||
private:
|
||||
//std::unique_ptr<SondeLogger> logger { };
|
||||
uint32_t target_frequency_ { };
|
||||
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 {
|
||||
{ { 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 {
|
||||
{ 0 * 8, 0 * 8 },
|
||||
@@ -88,23 +96,45 @@ private:
|
||||
{ 21 * 8, 0, 6 * 8, 4 },
|
||||
};
|
||||
|
||||
Text text_debug {
|
||||
{ 0, 32, 240, 16 },
|
||||
"Waiting for frame..."
|
||||
Checkbox check_log {
|
||||
{ 22 * 8, 2 * 16 + 12 },
|
||||
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 },
|
||||
"..."
|
||||
};
|
||||
|
||||
GeoPos geopos {
|
||||
{ 0, 6 * 16 },
|
||||
GeoPos::alt_unit::METERS
|
||||
};
|
||||
|
||||
Button button_see_map {
|
||||
{ 8 * 8, 10 * 16, 14 * 8, 3 * 16 },
|
||||
"See on map"
|
||||
};
|
||||
|
||||
MessageHandlerRegistration message_handler_packet {
|
||||
Message::ID::SondePacket,
|
||||
[this](Message* const p) {
|
||||
const auto message = static_cast<const SondePacketMessage*>(p);
|
||||
//const sonde::Packet packet { message->type, message->packet };
|
||||
//this->on_packet(packet);
|
||||
this->on_packet(message->packet);
|
||||
const sonde::Packet packet { message->packet, message->type };
|
||||
this->on_packet(packet);
|
||||
}
|
||||
};
|
||||
|
||||
//void on_packet(const sonde::Packet& packet);
|
||||
void on_packet(const baseband::Packet& packet);
|
||||
void on_packet(const sonde::Packet& packet);
|
||||
void set_target_frequency(const uint32_t new_value);
|
||||
uint32_t tuning_frequency() const;
|
||||
};
|
||||
|
||||
123
firmware/application/ui_test.cpp
Normal file
123
firmware/application/ui_test.cpp
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2017 Furrtek
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "ui_test.hpp"
|
||||
#include "baseband_api.hpp"
|
||||
|
||||
#include "portapack.hpp"
|
||||
using namespace portapack;
|
||||
|
||||
#include "string_format.hpp"
|
||||
|
||||
namespace ui {
|
||||
|
||||
TestView::TestView(NavigationView& nav) {
|
||||
baseband::run_image(portapack::spi_flash::image_tag_test);
|
||||
|
||||
add_children({
|
||||
&labels,
|
||||
&field_frequency,
|
||||
&field_rf_amp,
|
||||
&field_lna,
|
||||
&field_vga,
|
||||
&rssi,
|
||||
&text_debug_a,
|
||||
&text_debug_b
|
||||
});
|
||||
|
||||
field_frequency.set_value(target_frequency_);
|
||||
field_frequency.set_step(10000);
|
||||
field_frequency.on_change = [this](rf::Frequency f) {
|
||||
set_target_frequency(f);
|
||||
field_frequency.set_value(f);
|
||||
};
|
||||
field_frequency.on_edit = [this, &nav]() {
|
||||
// TODO: Provide separate modal method/scheme?
|
||||
auto new_view = nav.push<FrequencyKeypadView>(receiver_model.tuning_frequency());
|
||||
new_view->on_changed = [this](rf::Frequency f) {
|
||||
set_target_frequency(f);
|
||||
field_frequency.set_value(f);
|
||||
};
|
||||
};
|
||||
|
||||
radio::enable({
|
||||
tuning_frequency(),
|
||||
sampling_rate,
|
||||
baseband_bandwidth,
|
||||
rf::Direction::Receive,
|
||||
receiver_model.rf_amp(),
|
||||
static_cast<int8_t>(receiver_model.lna()),
|
||||
static_cast<int8_t>(receiver_model.vga()),
|
||||
});
|
||||
}
|
||||
|
||||
TestView::~TestView() {
|
||||
radio::disable();
|
||||
baseband::shutdown();
|
||||
}
|
||||
|
||||
void TestView::focus() {
|
||||
field_vga.focus();
|
||||
}
|
||||
|
||||
void TestView::on_packet(const testapp::Packet& packet) {
|
||||
const auto hex_formatted = packet.symbols_formatted();
|
||||
auto v = packet.value();
|
||||
|
||||
packet_count++;
|
||||
uint32_t diff = ((v - 1) - prev_v);
|
||||
if (diff < 20)
|
||||
packets_lost += diff;
|
||||
prev_v = v;
|
||||
|
||||
text_debug_a.set(hex_formatted.data.substr(0, 30));
|
||||
|
||||
text_debug_b.set(to_string_dec_uint((packets_lost * 1000) / packet_count) + " per 1000");
|
||||
|
||||
display.draw_pixel(Point(cur_x, 4 * 16 + (256 - packet.alt())), Color::white());
|
||||
|
||||
cur_x++;
|
||||
if (cur_x >= 240) {
|
||||
display.fill_rectangle(Rect(0, 4 * 16, 240, 256), Color::black());
|
||||
cur_x = 0;
|
||||
}
|
||||
|
||||
//radio::disable();
|
||||
|
||||
/*text_serial.set(packet.serial_number());
|
||||
text_voltage.set(unit_auto_scale(packet.battery_voltage(), 2, 3) + "V");
|
||||
|
||||
altitude = packet.GPS_altitude();
|
||||
latitude = packet.GPS_latitude();
|
||||
longitude = packet.GPS_longitude();*/
|
||||
}
|
||||
|
||||
void TestView::set_target_frequency(const uint32_t new_value) {
|
||||
target_frequency_ = new_value;
|
||||
radio::set_tuning_frequency(tuning_frequency());
|
||||
}
|
||||
|
||||
uint32_t TestView::tuning_frequency() const {
|
||||
return target_frequency_ - (sampling_rate / 4);
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
||||
106
firmware/application/ui_test.hpp
Normal file
106
firmware/application/ui_test.hpp
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2017 Furrtek
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __UI_TEST_H__
|
||||
#define __UI_TEST_H__
|
||||
|
||||
#include "ui_navigation.hpp"
|
||||
#include "ui_receiver.hpp"
|
||||
#include "ui_rssi.hpp"
|
||||
|
||||
#include "event_m0.hpp"
|
||||
|
||||
#include "test_packet.hpp"
|
||||
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
|
||||
namespace ui {
|
||||
|
||||
class TestView : public View {
|
||||
public:
|
||||
static constexpr uint32_t sampling_rate = 2457600;
|
||||
static constexpr uint32_t baseband_bandwidth = 1750000;
|
||||
|
||||
TestView(NavigationView& nav);
|
||||
~TestView();
|
||||
|
||||
void focus() override;
|
||||
|
||||
std::string title() const override { return "Test app"; };
|
||||
|
||||
private:
|
||||
uint32_t target_frequency_ { 439255000 };
|
||||
Coord cur_x { 0 };
|
||||
uint32_t packet_count { 0 };
|
||||
uint32_t packets_lost { 0 };
|
||||
uint32_t prev_v { 0 };
|
||||
|
||||
Labels labels {
|
||||
{ { 0 * 8, 1 * 16 }, "Data:", Color::light_grey() }
|
||||
};
|
||||
|
||||
FrequencyField field_frequency {
|
||||
{ 0 * 8, 0 * 8 },
|
||||
};
|
||||
RFAmpField field_rf_amp {
|
||||
{ 13 * 8, 0 * 16 }
|
||||
};
|
||||
|
||||
LNAGainField field_lna {
|
||||
{ 15 * 8, 0 * 16 }
|
||||
};
|
||||
|
||||
VGAGainField field_vga {
|
||||
{ 18 * 8, 0 * 16 }
|
||||
};
|
||||
|
||||
RSSI rssi {
|
||||
{ 21 * 8, 0, 6 * 8, 4 },
|
||||
};
|
||||
|
||||
Text text_debug_a {
|
||||
{ 0 * 8, 2 * 16, 30 * 8, 16 },
|
||||
"..."
|
||||
};
|
||||
Text text_debug_b {
|
||||
{ 0 * 8, 3 * 16, 30 * 8, 16 },
|
||||
"..."
|
||||
};
|
||||
|
||||
MessageHandlerRegistration message_handler_packet {
|
||||
Message::ID::TestAppPacket,
|
||||
[this](Message* const p) {
|
||||
const auto message = static_cast<const TestAppPacketMessage*>(p);
|
||||
const testapp::Packet packet { message->packet };
|
||||
this->on_packet(packet);
|
||||
}
|
||||
};
|
||||
|
||||
void on_packet(const testapp::Packet& packet);
|
||||
void set_target_frequency(const uint32_t new_value);
|
||||
uint32_t tuning_frequency() const;
|
||||
};
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
#endif/*__UI_TEST_H__*/
|
||||
Reference in New Issue
Block a user