From 9df1cfa670e103bc83536b96e1ceab5bdbc90fe5 Mon Sep 17 00:00:00 2001 From: jLynx Date: Wed, 23 Mar 2022 20:51:10 +1300 Subject: [PATCH 1/9] Added NZ to APRS --- firmware/application/apps/ui_aprs_rx.cpp | 3 +++ firmware/application/apps/ui_aprs_rx.hpp | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/firmware/application/apps/ui_aprs_rx.cpp b/firmware/application/apps/ui_aprs_rx.cpp index 6732e6262..71e46fb2e 100644 --- a/firmware/application/apps/ui_aprs_rx.cpp +++ b/firmware/application/apps/ui_aprs_rx.cpp @@ -115,6 +115,9 @@ APRSRxView::APRSRxView(NavigationView& nav, Rect parent_rect) : View(parent_rect if(i == 2){ field_frequency.set_value(145175000); } + if(i == 3){ + field_frequency.set_value(144575000); + } }; field_frequency.set_value(receiver_model.tuning_frequency()); diff --git a/firmware/application/apps/ui_aprs_rx.hpp b/firmware/application/apps/ui_aprs_rx.hpp index e392e62fe..b7670e3d3 100644 --- a/firmware/application/apps/ui_aprs_rx.hpp +++ b/firmware/application/apps/ui_aprs_rx.hpp @@ -217,7 +217,8 @@ private: { { "NA ", 0 }, { "EUR", 1 }, - { "AUS", 2 } + { "AUS", 2 }, + { "NZ", 3 } } }; From 1c81c7a8ba7d08124f48392418342d0edee8ef0a Mon Sep 17 00:00:00 2001 From: jLynx Date: Wed, 23 Mar 2022 21:32:32 +1300 Subject: [PATCH 2/9] Revert "Added NZ to APRS" This reverts commit 9df1cfa670e103bc83536b96e1ceab5bdbc90fe5. --- firmware/application/apps/ui_aprs_rx.cpp | 3 --- firmware/application/apps/ui_aprs_rx.hpp | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/firmware/application/apps/ui_aprs_rx.cpp b/firmware/application/apps/ui_aprs_rx.cpp index 71e46fb2e..6732e6262 100644 --- a/firmware/application/apps/ui_aprs_rx.cpp +++ b/firmware/application/apps/ui_aprs_rx.cpp @@ -115,9 +115,6 @@ APRSRxView::APRSRxView(NavigationView& nav, Rect parent_rect) : View(parent_rect if(i == 2){ field_frequency.set_value(145175000); } - if(i == 3){ - field_frequency.set_value(144575000); - } }; field_frequency.set_value(receiver_model.tuning_frequency()); diff --git a/firmware/application/apps/ui_aprs_rx.hpp b/firmware/application/apps/ui_aprs_rx.hpp index b7670e3d3..e392e62fe 100644 --- a/firmware/application/apps/ui_aprs_rx.hpp +++ b/firmware/application/apps/ui_aprs_rx.hpp @@ -217,8 +217,7 @@ private: { { "NA ", 0 }, { "EUR", 1 }, - { "AUS", 2 }, - { "NZ", 3 } + { "AUS", 2 } } }; From 0523aabe9112d3d44229a084426da9896059f7d9 Mon Sep 17 00:00:00 2001 From: jLynx Date: Thu, 24 Mar 2022 16:10:55 +1300 Subject: [PATCH 3/9] WIP PSI selector --- firmware/application/apps/tpms_app.cpp | 12 ++++++++++++ firmware/application/apps/tpms_app.hpp | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/firmware/application/apps/tpms_app.cpp b/firmware/application/apps/tpms_app.cpp index 82cdbd3f0..62c04c8f3 100644 --- a/firmware/application/apps/tpms_app.cpp +++ b/firmware/application/apps/tpms_app.cpp @@ -142,6 +142,7 @@ TPMSAppView::TPMSAppView(NavigationView&) { &field_rf_amp, &field_lna, &field_vga, + &options_type, &recent_entries_view, }); @@ -160,6 +161,17 @@ TPMSAppView::TPMSAppView(NavigationView&) { }; options_band.set_by_value(target_frequency()); + options_type.on_change = [this](size_t, int32_t i) { + if (i == 0){ + // field_frequency.set_value(144390000); + } + if(i == 1){ + // field_frequency.set_value(144800000); + } + }; + + options_type.set_selected_index(0, true); + logger = std::make_unique(); if( logger ) { logger->append(u"tpms.txt"); diff --git a/firmware/application/apps/tpms_app.hpp b/firmware/application/apps/tpms_app.hpp index ee17c6eb2..993af22fe 100644 --- a/firmware/application/apps/tpms_app.hpp +++ b/firmware/application/apps/tpms_app.hpp @@ -138,6 +138,15 @@ private: } }; + OptionsField options_type { + { 5 * 8, 0 * 16 }, + 3, + { + { "kPa", 0 }, + { "PSI", 1 } + } + }; + RFAmpField field_rf_amp { { 13 * 8, 0 * 16 } }; From 2030118d9fb18cccaa967a029713e6a98de62aad Mon Sep 17 00:00:00 2001 From: jLynx Date: Thu, 24 Mar 2022 17:05:38 +1300 Subject: [PATCH 4/9] WIP can now switch between kPa and PSI --- firmware/application/apps/tpms_app.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/firmware/application/apps/tpms_app.cpp b/firmware/application/apps/tpms_app.cpp index 62c04c8f3..4d55bec01 100644 --- a/firmware/application/apps/tpms_app.cpp +++ b/firmware/application/apps/tpms_app.cpp @@ -34,6 +34,8 @@ namespace tpms { namespace format { +static bool use_kpa = true; + std::string type(Reading::Type type) { return to_string_dec_uint(toUType(type), 2); } @@ -43,7 +45,11 @@ std::string id(TransponderID id) { } std::string pressure(Pressure pressure) { - return to_string_dec_int(pressure.kilopascal(), 3); + if(use_kpa){ + return to_string_dec_int(pressure.kilopascal(), 3); + } + return to_string_dec_int(pressure.psi(), 3); + } std::string temperature(Temperature temperature) { @@ -163,10 +169,10 @@ TPMSAppView::TPMSAppView(NavigationView&) { options_type.on_change = [this](size_t, int32_t i) { if (i == 0){ - // field_frequency.set_value(144390000); + tpms::format::use_kpa = true; } if(i == 1){ - // field_frequency.set_value(144800000); + tpms::format::use_kpa = false; } }; From 32f957cead14ed051a807a98effb690f92fe694a Mon Sep 17 00:00:00 2001 From: jLynx Date: Thu, 24 Mar 2022 19:08:07 +1300 Subject: [PATCH 5/9] WIP updating header --- firmware/application/apps/tpms_app.cpp | 31 +++++++++++++++++++++----- firmware/application/apps/tpms_app.hpp | 10 +++++++++ 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/firmware/application/apps/tpms_app.cpp b/firmware/application/apps/tpms_app.cpp index 4d55bec01..4362247e0 100644 --- a/firmware/application/apps/tpms_app.cpp +++ b/firmware/application/apps/tpms_app.cpp @@ -149,9 +149,15 @@ TPMSAppView::TPMSAppView(NavigationView&) { &field_lna, &field_vga, &options_type, - &recent_entries_view, + // &recent_entries_view, + // &recent_entries_view_psi, }); + // remove_children({ + // &recent_entries_view, + // // &recent_entries_view_psi, + // }); + radio::enable({ tuning_frequency(), sampling_rate, @@ -169,10 +175,14 @@ TPMSAppView::TPMSAppView(NavigationView&) { options_type.on_change = [this](size_t, int32_t i) { if (i == 0){ - tpms::format::use_kpa = true; + tpms::format::use_kpa = true; + remove_child(&recent_entries_view_psi); + add_child(&recent_entries_view); } if(i == 1){ tpms::format::use_kpa = false; + remove_child(&recent_entries_view); + add_child(&recent_entries_view_psi); } }; @@ -197,6 +207,7 @@ void TPMSAppView::focus() { void TPMSAppView::set_parent_rect(const Rect new_parent_rect) { View::set_parent_rect(new_parent_rect); recent_entries_view.set_parent_rect({ 0, header_height, new_parent_rect.width(), new_parent_rect.height() - header_height }); + recent_entries_view_psi.set_parent_rect({ 0, header_height, new_parent_rect.width(), new_parent_rect.height() - header_height }); } void TPMSAppView::on_packet(const tpms::Packet& packet) { @@ -209,13 +220,23 @@ void TPMSAppView::on_packet(const tpms::Packet& packet) { const auto reading = reading_opt.value(); auto& entry = ::on_packet(recent, TPMSRecentEntry::Key { reading.type(), reading.id() }); entry.update(reading); - recent_entries_view.set_dirty(); + + if(tpms::format::use_kpa){ + recent_entries_view.set_dirty(); + } else { + recent_entries_view_psi.set_dirty(); + } } } void TPMSAppView::on_show_list() { - recent_entries_view.hidden(false); - recent_entries_view.focus(); + if(tpms::format::use_kpa){ + recent_entries_view.hidden(false); + recent_entries_view.focus(); + } else { + recent_entries_view_psi.hidden(false); + recent_entries_view_psi.focus(); + } } void TPMSAppView::on_band_changed(const uint32_t new_band_frequency) { diff --git a/firmware/application/apps/tpms_app.hpp b/firmware/application/apps/tpms_app.hpp index 993af22fe..55e709144 100644 --- a/firmware/application/apps/tpms_app.hpp +++ b/firmware/application/apps/tpms_app.hpp @@ -172,6 +172,16 @@ private: } }; TPMSRecentEntriesView recent_entries_view { columns, recent }; + const RecentEntriesColumns columns_psi { { + { "Tp", 2 }, + { "ID", 8 }, + { "PSI", 3 }, + { "C", 3 }, + { "Cnt", 3 }, + { "Fl", 2 }, + } }; + TPMSRecentEntriesView recent_entries_view_psi { columns_psi, recent }; + uint32_t target_frequency_ = initial_target_frequency; void on_packet(const tpms::Packet& packet); From 0025ad250718f0195340ee1acfddf460da812675 Mon Sep 17 00:00:00 2001 From: jLynx Date: Thu, 24 Mar 2022 19:19:02 +1300 Subject: [PATCH 6/9] refactoring --- firmware/application/apps/tpms_app.cpp | 42 +++++++++++--------------- firmware/application/apps/tpms_app.hpp | 4 +-- 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/firmware/application/apps/tpms_app.cpp b/firmware/application/apps/tpms_app.cpp index 4362247e0..d260d9b45 100644 --- a/firmware/application/apps/tpms_app.cpp +++ b/firmware/application/apps/tpms_app.cpp @@ -149,15 +149,8 @@ TPMSAppView::TPMSAppView(NavigationView&) { &field_lna, &field_vga, &options_type, - // &recent_entries_view, - // &recent_entries_view_psi, }); - // remove_children({ - // &recent_entries_view, - // // &recent_entries_view_psi, - // }); - radio::enable({ tuning_frequency(), sampling_rate, @@ -173,19 +166,6 @@ TPMSAppView::TPMSAppView(NavigationView&) { }; options_band.set_by_value(target_frequency()); - options_type.on_change = [this](size_t, int32_t i) { - if (i == 0){ - tpms::format::use_kpa = true; - remove_child(&recent_entries_view_psi); - add_child(&recent_entries_view); - } - if(i == 1){ - tpms::format::use_kpa = false; - remove_child(&recent_entries_view); - add_child(&recent_entries_view_psi); - } - }; - options_type.set_selected_index(0, true); logger = std::make_unique(); @@ -206,7 +186,21 @@ void TPMSAppView::focus() { void TPMSAppView::set_parent_rect(const Rect new_parent_rect) { View::set_parent_rect(new_parent_rect); - recent_entries_view.set_parent_rect({ 0, header_height, new_parent_rect.width(), new_parent_rect.height() - header_height }); + + options_type.on_change = [this](size_t, int32_t i) { + if (i == 0){ + tpms::format::use_kpa = true; + remove_child(&recent_entries_view_psi); + add_child(&recent_entries_view_kpa); + } + if(i == 1){ + tpms::format::use_kpa = false; + remove_child(&recent_entries_view_kpa); + add_child(&recent_entries_view_psi); + } + }; + + recent_entries_view_kpa.set_parent_rect({ 0, header_height, new_parent_rect.width(), new_parent_rect.height() - header_height }); recent_entries_view_psi.set_parent_rect({ 0, header_height, new_parent_rect.width(), new_parent_rect.height() - header_height }); } @@ -222,7 +216,7 @@ void TPMSAppView::on_packet(const tpms::Packet& packet) { entry.update(reading); if(tpms::format::use_kpa){ - recent_entries_view.set_dirty(); + recent_entries_view_kpa.set_dirty(); } else { recent_entries_view_psi.set_dirty(); } @@ -231,8 +225,8 @@ void TPMSAppView::on_packet(const tpms::Packet& packet) { void TPMSAppView::on_show_list() { if(tpms::format::use_kpa){ - recent_entries_view.hidden(false); - recent_entries_view.focus(); + recent_entries_view_kpa.hidden(false); + recent_entries_view_kpa.focus(); } else { recent_entries_view_psi.hidden(false); recent_entries_view_psi.focus(); diff --git a/firmware/application/apps/tpms_app.hpp b/firmware/application/apps/tpms_app.hpp index 55e709144..44b4b15df 100644 --- a/firmware/application/apps/tpms_app.hpp +++ b/firmware/application/apps/tpms_app.hpp @@ -162,7 +162,7 @@ private: TPMSRecentEntries recent { }; std::unique_ptr logger { }; - const RecentEntriesColumns columns { { + const RecentEntriesColumns columns_kpa { { { "Tp", 2 }, { "ID", 8 }, { "kPa", 3 }, @@ -170,7 +170,7 @@ private: { "Cnt", 3 }, { "Fl", 2 }, } }; - TPMSRecentEntriesView recent_entries_view { columns, recent }; + TPMSRecentEntriesView recent_entries_view_kpa { columns_kpa, recent }; const RecentEntriesColumns columns_psi { { { "Tp", 2 }, From d1d1198b1b40da5bad845681f0991024fbfe49b9 Mon Sep 17 00:00:00 2001 From: jLynx Date: Thu, 24 Mar 2022 19:43:26 +1300 Subject: [PATCH 7/9] refactoring --- firmware/application/apps/tpms_app.cpp | 44 ++++++++++++++++++-------- firmware/application/apps/tpms_app.hpp | 3 ++ 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/firmware/application/apps/tpms_app.cpp b/firmware/application/apps/tpms_app.cpp index d260d9b45..279c8a97d 100644 --- a/firmware/application/apps/tpms_app.cpp +++ b/firmware/application/apps/tpms_app.cpp @@ -166,6 +166,22 @@ TPMSAppView::TPMSAppView(NavigationView&) { }; options_band.set_by_value(target_frequency()); + options_type.on_change = [this](size_t, int32_t i) { + if (i == 0){ + tpms::format::use_kpa = true; + // remove_child(&recent_entries_view_psi); + // add_child(&recent_entries_view_kpa); + // recent_entries_view_kpa.set_parent_rect(view_normal_rect); + } + if(i == 1){ + tpms::format::use_kpa = false; + // remove_child(&recent_entries_view_kpa); + // add_child(&recent_entries_view_psi); + // recent_entries_view_psi.set_parent_rect(view_normal_rect); + } + update_type(); + }; + options_type.set_selected_index(0, true); logger = std::make_unique(); @@ -184,24 +200,24 @@ void TPMSAppView::focus() { options_band.focus(); } +void TPMSAppView::update_type() { + if (tpms::format::use_kpa){ + remove_child(&recent_entries_view_psi); + add_child(&recent_entries_view_kpa); + recent_entries_view_kpa.set_parent_rect(view_normal_rect); + } else { + remove_child(&recent_entries_view_kpa); + add_child(&recent_entries_view_psi); + recent_entries_view_psi.set_parent_rect(view_normal_rect); + } +} + void TPMSAppView::set_parent_rect(const Rect new_parent_rect) { View::set_parent_rect(new_parent_rect); - options_type.on_change = [this](size_t, int32_t i) { - if (i == 0){ - tpms::format::use_kpa = true; - remove_child(&recent_entries_view_psi); - add_child(&recent_entries_view_kpa); - } - if(i == 1){ - tpms::format::use_kpa = false; - remove_child(&recent_entries_view_kpa); - add_child(&recent_entries_view_psi); - } - }; + view_normal_rect = { 0, header_height, new_parent_rect.width(), new_parent_rect.height() - header_height }; - recent_entries_view_kpa.set_parent_rect({ 0, header_height, new_parent_rect.width(), new_parent_rect.height() - header_height }); - recent_entries_view_psi.set_parent_rect({ 0, header_height, new_parent_rect.width(), new_parent_rect.height() - header_height }); + update_type(); } void TPMSAppView::on_packet(const tpms::Packet& packet) { diff --git a/firmware/application/apps/tpms_app.hpp b/firmware/application/apps/tpms_app.hpp index 44b4b15df..648c5b495 100644 --- a/firmware/application/apps/tpms_app.hpp +++ b/firmware/application/apps/tpms_app.hpp @@ -121,6 +121,8 @@ private: static constexpr ui::Dim header_height = 1 * 16; + ui::Rect view_normal_rect { }; + RSSI rssi { { 21 * 8, 0, 6 * 8, 4 }, }; @@ -186,6 +188,7 @@ private: void on_packet(const tpms::Packet& packet); void on_show_list(); + void update_type(); void on_band_changed(const uint32_t new_band_frequency); From 165efd7355d7397fbc861bd36dae103d2b8558c4 Mon Sep 17 00:00:00 2001 From: jLynx Date: Thu, 24 Mar 2022 19:44:26 +1300 Subject: [PATCH 8/9] refactoring --- firmware/application/apps/tpms_app.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/firmware/application/apps/tpms_app.cpp b/firmware/application/apps/tpms_app.cpp index 279c8a97d..750bc6e88 100644 --- a/firmware/application/apps/tpms_app.cpp +++ b/firmware/application/apps/tpms_app.cpp @@ -169,15 +169,9 @@ TPMSAppView::TPMSAppView(NavigationView&) { options_type.on_change = [this](size_t, int32_t i) { if (i == 0){ tpms::format::use_kpa = true; - // remove_child(&recent_entries_view_psi); - // add_child(&recent_entries_view_kpa); - // recent_entries_view_kpa.set_parent_rect(view_normal_rect); } if(i == 1){ tpms::format::use_kpa = false; - // remove_child(&recent_entries_view_kpa); - // add_child(&recent_entries_view_psi); - // recent_entries_view_psi.set_parent_rect(view_normal_rect); } update_type(); }; From 4a8458d812b7d8dcf9c01a1bb6c46be5dc7f0304 Mon Sep 17 00:00:00 2001 From: jLynx Date: Thu, 24 Mar 2022 19:51:08 +1300 Subject: [PATCH 9/9] refactoring --- firmware/application/apps/tpms_app.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/firmware/application/apps/tpms_app.cpp b/firmware/application/apps/tpms_app.cpp index 750bc6e88..7858d7a21 100644 --- a/firmware/application/apps/tpms_app.cpp +++ b/firmware/application/apps/tpms_app.cpp @@ -169,8 +169,7 @@ TPMSAppView::TPMSAppView(NavigationView&) { options_type.on_change = [this](size_t, int32_t i) { if (i == 0){ tpms::format::use_kpa = true; - } - if(i == 1){ + } else if (i == 1){ tpms::format::use_kpa = false; } update_type();