diff --git a/firmware/application/apps/ert_app.cpp b/firmware/application/apps/ert_app.cpp index e476c966..7745d923 100644 --- a/firmware/application/apps/ert_app.cpp +++ b/firmware/application/apps/ert_app.cpp @@ -65,9 +65,13 @@ std::string commodity_type(CommodityType value) { } /* namespace ert */ -void ERTLogger::on_packet(const ert::Packet& packet) { +void ERTLogger::on_packet(const ert::Packet& packet, const uint32_t target_frequency) { const auto formatted = packet.symbols_formatted(); - std::string entry = ert::format::type(packet.type()) + " " + formatted.data + "/" + formatted.errors; + + // TODO: function doesn't take uint64_t, so when >= 1<<32, weirdness will ensue! + const auto target_frequency_str = to_string_dec_uint(target_frequency, 10); + + std::string entry = target_frequency_str + " " + ert::format::type(packet.type()) + " " + formatted.data + "/" + formatted.errors; log_file.write_entry(packet.received_at(), entry); } @@ -99,10 +103,12 @@ void RecentEntriesTable::draw( painter.draw_string(target_rect.location(), style, line); } -ERTAppView::ERTAppView(NavigationView&) { +ERTAppView::ERTAppView(NavigationView& nav) + : nav_{nav} { baseband::run_image(portapack::spi_flash::image_tag_ert); add_children({ + &field_frequency, &field_rf_amp, &field_lna, &field_vga, @@ -110,6 +116,8 @@ ERTAppView::ERTAppView(NavigationView&) { &recent_entries_view, }); + field_frequency.set_step(1000000); + receiver_model.enable(); logger = std::make_unique(); @@ -134,7 +142,7 @@ void ERTAppView::set_parent_rect(const Rect new_parent_rect) { void ERTAppView::on_packet(const ert::Packet& packet) { if (logger) { - logger->on_packet(packet); + logger->on_packet(packet, receiver_model.target_frequency()); } if (packet.crc_ok()) { diff --git a/firmware/application/apps/ert_app.hpp b/firmware/application/apps/ert_app.hpp index ab22bf4f..cc306008 100644 --- a/firmware/application/apps/ert_app.hpp +++ b/firmware/application/apps/ert_app.hpp @@ -24,6 +24,7 @@ #include "ui_navigation.hpp" #include "ui_receiver.hpp" +#include "ui_freq_field.hpp" #include "ui_rssi.hpp" #include "ui_channel.hpp" @@ -95,7 +96,7 @@ class ERTLogger { return log_file.append(filename); } - void on_packet(const ert::Packet& packet); + void on_packet(const ert::Packet& packet, const uint32_t target_frequency); private: LogFile log_file{}; @@ -126,6 +127,7 @@ class ERTAppView : public View { ERTRecentEntries recent{}; std::unique_ptr logger{}; + NavigationView& nav_; RxRadioState radio_state_{ 911600000 /* frequency */, 2500000 /* bandwidth */, @@ -143,6 +145,10 @@ class ERTAppView : public View { static constexpr auto header_height = 1 * 16; + RxFrequencyField field_frequency{ + {5 * 8, 0 * 16}, + nav_}; + RFAmpField field_rf_amp{ {13 * 8, 0 * 16}};