diff --git a/firmware/application/tpms_app.cpp b/firmware/application/tpms_app.cpp index aa03ba686..878ba1f29 100644 --- a/firmware/application/tpms_app.cpp +++ b/firmware/application/tpms_app.cpp @@ -167,6 +167,7 @@ TPMSAppView::TPMSAppView(NavigationView&) { add_children({ { &rssi, &channel, + &options_band, &field_rf_amp, &field_lna, &field_vga, @@ -190,6 +191,11 @@ TPMSAppView::TPMSAppView(NavigationView&) { .decimation_factor = 1, }); + options_band.on_change = [this](size_t, OptionsField::value_t v) { + this->on_band_changed(v); + }; + options_band.set_by_value(target_frequency()); + logger = std::make_unique(); if( logger ) { logger->append("tpms.txt"); @@ -228,8 +234,17 @@ void TPMSAppView::on_show_list() { recent_entries_view.focus(); } +void TPMSAppView::on_band_changed(const uint32_t new_band_frequency) { + set_target_frequency(new_band_frequency); +} + +void TPMSAppView::set_target_frequency(const uint32_t new_value) { + target_frequency_ = new_value; + radio::set_tuning_frequency(tuning_frequency()); +} + uint32_t TPMSAppView::target_frequency() const { - return initial_target_frequency; + return target_frequency_; } uint32_t TPMSAppView::tuning_frequency() const { diff --git a/firmware/application/tpms_app.hpp b/firmware/application/tpms_app.hpp index 707208c71..84aacd61f 100644 --- a/firmware/application/tpms_app.hpp +++ b/firmware/application/tpms_app.hpp @@ -129,6 +129,15 @@ private: { 21 * 8, 5, 6 * 8, 4 }, }; + OptionsField options_band { + { 0 * 8, 0 * 16 }, + 3, + { + { "315", 315000000 }, + { "434", 433920000 }, + } + }; + RFAmpField field_rf_amp { { 13 * 8, 0 * 16 } }; @@ -146,10 +155,16 @@ private: TPMSRecentEntriesView recent_entries_view { recent }; + uint32_t target_frequency_ = initial_target_frequency; + void on_packet(const tpms::Packet& packet); void on_show_list(); + void on_band_changed(const uint32_t new_band_frequency); + uint32_t target_frequency() const; + void set_target_frequency(const uint32_t new_value); + uint32_t tuning_frequency() const; };