From 7ceefb1b812423be7360bce954135dc669a12777 Mon Sep 17 00:00:00 2001 From: Mark Thompson <129641948+NotherNgineer@users.noreply.github.com> Date: Wed, 29 Nov 2023 10:37:01 -0600 Subject: [PATCH] Weather app tweaks (#1610) * Add files via upload * Add files via upload * Add files via upload * Add files via upload * Add files via upload --- .../application/apps/ui_weatherstation.cpp | 19 +++++++++++-------- .../application/apps/ui_weatherstation.hpp | 16 ++++++++++++++-- firmware/application/ui_navigation.cpp | 2 +- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/firmware/application/apps/ui_weatherstation.cpp b/firmware/application/apps/ui_weatherstation.cpp index c0989f54..60c75239 100644 --- a/firmware/application/apps/ui_weatherstation.cpp +++ b/firmware/application/apps/ui_weatherstation.cpp @@ -36,7 +36,7 @@ void WeatherRecentEntryDetailView::update_data() { // set text elements text_type.set(WeatherView::getWeatherSensorTypeName((FPROTO_WEATHER_SENSOR)entry_.sensorType)); text_id.set("0x" + to_string_hex(entry_.id)); - text_temp.set(to_string_decimal(entry_.temp, 2)); + text_temp.set(weather_units_fahr ? to_string_decimal((entry_.temp * 9 / 5) + 32, 1) + STR_DEGREES_F : to_string_decimal(entry_.temp, 2) + STR_DEGREES_C); text_hum.set(to_string_dec_uint(entry_.humidity) + "%"); text_ch.set(to_string_dec_uint(entry_.channel)); text_batt.set(to_string_dec_uint(entry_.battery_low) + " " + ((entry_.battery_low == 0) ? "OK" : "LOW")); @@ -81,6 +81,7 @@ WeatherView::WeatherView(NavigationView& nav) &field_lna, &field_vga, &field_frequency, + &options_temperature, &button_clear_list, &recent_entries_view}); @@ -90,17 +91,19 @@ WeatherView::WeatherView(NavigationView& nav) recent.clear(); recent_entries_view.set_dirty(); }; - field_frequency.set_value(433920000); - field_frequency.set_step(1000); + field_frequency.set_step(100000); + + options_temperature.on_change = [this](size_t, int32_t i) { + weather_units_fahr = (bool)i; + recent_entries_view.set_dirty(); + }; + options_temperature.set_selected_index(weather_units_fahr, false); + const Rect content_rect{0, header_height, screen_width, screen_height - header_height}; recent_entries_view.set_parent_rect(content_rect); recent_entries_view.on_select = [this](const WeatherRecentEntry& entry) { nav_.push(entry); }; - receiver_model.set_target_frequency(433'920'000); - receiver_model.set_sampling_rate(2'000'000); - receiver_model.set_baseband_bandwidth(1'750'000); - receiver_model.set_modulation(ReceiverModel::Mode::AMAudio); baseband::set_weather(); receiver_model.enable(); } @@ -190,7 +193,7 @@ void RecentEntriesTable::draw( line = truncate(line, 13); } - std::string temp = to_string_decimal(entry.temp, 2); + std::string temp = (weather_units_fahr ? to_string_decimal((entry.temp * 9 / 5) + 32, 1) : to_string_decimal(entry.temp, 2)); std::string humStr = to_string_dec_uint(entry.humidity) + "%"; std::string chStr = to_string_dec_uint(entry.channel); diff --git a/firmware/application/apps/ui_weatherstation.hpp b/firmware/application/apps/ui_weatherstation.hpp index a2f3da33..ef964a24 100644 --- a/firmware/application/apps/ui_weatherstation.hpp +++ b/firmware/application/apps/ui_weatherstation.hpp @@ -37,6 +37,8 @@ using namespace ui; namespace ui { +static bool weather_units_fahr{false}; + struct WeatherRecentEntry { using Key = uint64_t; static constexpr Key invalid_key = 0x0fffffff; // todo calc the invalid all @@ -92,12 +94,22 @@ class WeatherView : public View { 433'920'000 /* frequency */, 1'750'000 /* bandwidth */, 2'000'000 /* sampling rate */, - ReceiverModel::Mode::SpectrumAnalysis}; + ReceiverModel::Mode::AMAudio}; app_settings::SettingsManager settings_{ - "rx_weather", app_settings::Mode::RX}; + "rx_weather", + app_settings::Mode::RX, + { + {"units_fahr"sv, &weather_units_fahr}, + }}; WeatherRecentEntries recent{}; + OptionsField options_temperature{ + {10 * 8, 0 * 16}, + 2, + {{STR_DEGREES_C, 0}, + {STR_DEGREES_F, 1}}}; + RFAmpField field_rf_amp{ {13 * 8, 0 * 16}}; LNAGainField field_lna{ diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index 3bfae650..e05845a9 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -566,7 +566,7 @@ ReceiversMenuView::ReceiversMenuView(NavigationView& nav) { {"Recon", Color::green(), &bitmap_icon_scanner, [&nav]() { nav.push(); }}, {"Search", Color::yellow(), &bitmap_icon_search, [&nav]() { nav.push(); }}, {"TPMS Cars", Color::green(), &bitmap_icon_tpms, [&nav]() { nav.push(); }}, - {"Weather", Color::green(), &bitmap_icon_lge, [&nav]() { nav.push(); }}, + {"Weather", Color::yellow(), &bitmap_icon_lge, [&nav]() { nav.push(); }}, // {"FSK RX", Color::yellow(), &bitmap_icon_remote, [&nav]() { nav.push(); }}, // {"DMR", Color::dark_grey(), &bitmap_icon_dmr, [&nav](){ nav.push(); }}, // {"SIGFOX", Color::dark_grey(), &bitmap_icon_fox, [&nav](){ nav.push(); }},