Weather app tweaks (#1610)

* Add files via upload

* Add files via upload

* Add files via upload

* Add files via upload

* Add files via upload
This commit is contained in:
Mark Thompson 2023-11-29 10:37:01 -06:00 committed by GitHub
parent 861f684d00
commit 7ceefb1b81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 11 deletions

View File

@ -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<WeatherRecentEntryDetailView>(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<ui::WeatherRecentEntries>::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);

View File

@ -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{

View File

@ -566,7 +566,7 @@ ReceiversMenuView::ReceiversMenuView(NavigationView& nav) {
{"Recon", Color::green(), &bitmap_icon_scanner, [&nav]() { nav.push<ReconView>(); }},
{"Search", Color::yellow(), &bitmap_icon_search, [&nav]() { nav.push<SearchView>(); }},
{"TPMS Cars", Color::green(), &bitmap_icon_tpms, [&nav]() { nav.push<TPMSAppView>(); }},
{"Weather", Color::green(), &bitmap_icon_lge, [&nav]() { nav.push<WeatherView>(); }},
{"Weather", Color::yellow(), &bitmap_icon_lge, [&nav]() { nav.push<WeatherView>(); }},
// {"FSK RX", Color::yellow(), &bitmap_icon_remote, [&nav]() { nav.push<FskxRxMainView>(); }},
// {"DMR", Color::dark_grey(), &bitmap_icon_dmr, [&nav](){ nav.push<NotImplementedView>(); }},
// {"SIGFOX", Color::dark_grey(), &bitmap_icon_fox, [&nav](){ nav.push<NotImplementedView>(); }},