diff --git a/firmware/application/apps/pocsag_app.cpp b/firmware/application/apps/pocsag_app.cpp index 7fd814c0..e710f242 100644 --- a/firmware/application/apps/pocsag_app.cpp +++ b/firmware/application/apps/pocsag_app.cpp @@ -54,35 +54,32 @@ POCSAGSettingsView::POCSAGSettingsView( POCSAGSettings& settings) : settings_{settings} { add_children( - {&check_beta, + {&labels, &check_log, &check_log_raw, &check_small_font, &check_hide_bad, &check_hide_addr_only, - &check_ignore, - &field_ignore, + &opt_filter_mode, + &field_filter_address, &button_save}); - check_beta.set_value(settings_.use_new_proc); check_log.set_value(settings_.enable_logging); check_log_raw.set_value(settings_.enable_raw_log); check_small_font.set_value(settings_.enable_small_font); check_hide_bad.set_value(settings_.hide_bad_data); check_hide_addr_only.set_value(settings_.hide_addr_only); - check_ignore.set_value(settings_.enable_ignore); - - field_ignore.set_value(settings_.address_to_ignore); + opt_filter_mode.set_by_value(settings_.filter_mode); + field_filter_address.set_value(settings_.filter_address); button_save.on_select = [this, &nav](Button&) { - settings_.use_new_proc = check_beta.value(); settings_.enable_logging = check_log.value(); settings_.enable_raw_log = check_log_raw.value(); settings_.enable_small_font = check_small_font.value(); settings_.hide_bad_data = check_hide_bad.value(); settings_.hide_addr_only = check_hide_addr_only.value(); - settings_.enable_ignore = check_ignore.value(); - settings_.address_to_ignore = field_ignore.to_integer(); + settings_.filter_mode = opt_filter_mode.selected_index_value(); + settings_.filter_address = field_filter_address.to_integer(); nav.pop(); }; @@ -90,10 +87,7 @@ POCSAGSettingsView::POCSAGSettingsView( POCSAGAppView::POCSAGAppView(NavigationView& nav) : nav_{nav} { - if (settings_.use_new_proc) - baseband::run_image(portapack::spi_flash::image_tag_pocsag2); - else - baseband::run_image(portapack::spi_flash::image_tag_pocsag); + baseband::run_image(portapack::spi_flash::image_tag_pocsag2); add_children( {&rssi, @@ -109,14 +103,16 @@ POCSAGAppView::POCSAGAppView(NavigationView& nav) &widget_baud, &widget_bits, &widget_frames, - &button_ignore_last, + &button_filter_last, &button_config, &console}); // No app settings, use fallbacks from pmem. if (!app_settings_.loaded()) { - settings_.address_to_ignore = pmem::pocsag_ignore_address(); - settings_.enable_ignore = settings_.address_to_ignore > 0; + settings_.filter_address = pmem::pocsag_ignore_address(); + settings_.filter_mode = (settings_.filter_address == 0) + ? FILTER_NONE + : FILTER_DROP; } if (!app_settings_.radio_loaded()) { field_frequency.set_value(initial_target_frequency); @@ -129,9 +125,11 @@ POCSAGAppView::POCSAGAppView(NavigationView& nav) receiver_model.set_squelch_level(v); }; - button_ignore_last.on_select = [this](Button&) { - settings_.enable_ignore = true; - settings_.address_to_ignore = last_address; + button_filter_last.on_select = [this](Button&) { + if (settings_.filter_mode == FILTER_NONE) + settings_.filter_mode = FILTER_DROP; + settings_.filter_address = last_address; + refresh_ui(); }; button_config.on_select = [this](Button&) { @@ -155,15 +153,48 @@ POCSAGAppView::~POCSAGAppView() { baseband::shutdown(); // Save pmem settings. - pmem::set_pocsag_ignore_address(settings_.address_to_ignore); + pmem::set_pocsag_ignore_address(settings_.filter_address); pmem::set_pocsag_last_address(last_address); // For POCSAG TX. } void POCSAGAppView::refresh_ui() { + // Set console font style. console.set_style( settings_.enable_small_font ? &Styles::white_small : &Styles::white); + + // Update filter button text. + std::string btn_text = "Filter Last"; + switch (settings_.filter_mode) { + case FILTER_DROP: + btn_text = "Ignore Last"; + break; + + case FILTER_KEEP: + btn_text = "Keep Last"; + break; + + case FILTER_NONE: + default: + btn_text = "Filter Last"; + break; + } + button_filter_last.set_text(btn_text); +} + +bool POCSAGAppView::ignore_address(uint32_t address) const { + switch (settings_.filter_mode) { + case FILTER_DROP: + return address == settings_.filter_address; + + case FILTER_KEEP: + return address != settings_.filter_address; + + case FILTER_NONE: + default: + return false; + } } void POCSAGAppView::handle_decoded(Timestamp timestamp, const std::string& prefix) { @@ -176,8 +207,8 @@ void POCSAGAppView::handle_decoded(Timestamp timestamp, const std::string& prefi return; } - // Ignored address. - if (ignore() && pocsag_state.address == settings_.address_to_ignore) { + // Ignore address? TODO: could filter earlier. + if (ignore_address(pocsag_state.address)) { console.write("\n" STR_COLOR_CYAN + prefix + " Ignored: " + to_string_dec_uint(pocsag_state.address)); last_address = pocsag_state.address; return; diff --git a/firmware/application/apps/pocsag_app.hpp b/firmware/application/apps/pocsag_app.hpp index ae7960c8..1bf9ba71 100644 --- a/firmware/application/apps/pocsag_app.hpp +++ b/firmware/application/apps/pocsag_app.hpp @@ -114,15 +114,20 @@ class FrameIndicator : public Widget { bool has_sync_ = false; }; +enum POCSAGFilter : uint8_t { + FILTER_NONE, + FILTER_DROP, + FILTER_KEEP +}; + struct POCSAGSettings { bool enable_small_font = false; bool enable_logging = false; bool enable_raw_log = false; - bool enable_ignore = false; bool hide_bad_data = false; bool hide_addr_only = false; - uint32_t address_to_ignore = 0; - bool use_new_proc = false; + uint8_t filter_mode = false; + uint32_t filter_address = 0; }; class POCSAGSettingsView : public View { @@ -135,11 +140,10 @@ class POCSAGSettingsView : public View { private: POCSAGSettings& settings_; - Checkbox check_beta{ - {0 * 8 + 2, 18 * 16 - 4}, - 6, - "Beta", - true /*small*/}; + Labels labels{ + {{2 * 8, 12 * 16}, "Filter Mode:", Color::light_grey()}, + {{2 * 8, 13 * 16}, "Filter Addr:", Color::light_grey()}, + }; Checkbox check_log{ {2 * 8, 2 * 16}, @@ -166,13 +170,15 @@ class POCSAGSettingsView : public View { 22, "Hide Addr Only"}; - Checkbox check_ignore{ - {2 * 8, 12 * 16}, - 22, - "Enable Ignored Address"}; + OptionsField opt_filter_mode{ + {15 * 8, 12 * 16}, + 4, + {{"None", FILTER_NONE}, + {"Drop", FILTER_DROP}, + {"Keep", FILTER_KEEP}}}; - SymField field_ignore{ - {7 * 8, 13 * 16 + 8}, + SymField field_filter_address{ + {15 * 8, 13 * 16}, 7, SymField::Type::Dec, true /*explicit_edit*/}; @@ -194,7 +200,6 @@ class POCSAGAppView : public View { static constexpr uint32_t initial_target_frequency = 466'175'000; bool logging() const { return settings_.enable_logging; }; bool logging_raw() const { return settings_.enable_raw_log; }; - bool ignore() const { return settings_.enable_ignore; }; bool hide_bad_data() const { return settings_.hide_bad_data; }; bool hide_addr_only() const { return settings_.hide_addr_only; }; @@ -210,14 +215,14 @@ class POCSAGAppView : public View { {"small_font"sv, &settings_.enable_small_font}, {"enable_logging"sv, &settings_.enable_logging}, {"enable_raw_log"sv, &settings_.enable_raw_log}, - {"enable_ignore"sv, &settings_.enable_ignore}, - {"address_to_ignore"sv, &settings_.address_to_ignore}, + {"filter_mode"sv, &settings_.filter_mode}, + {"filter_address"sv, &settings_.filter_address}, {"hide_bad_data"sv, &settings_.hide_bad_data}, {"hide_addr_only"sv, &settings_.hide_addr_only}, - {"use_new_proc"sv, &settings_.use_new_proc}, }}; void refresh_ui(); + bool ignore_address(uint32_t address) const; void handle_decoded(Timestamp timestamp, const std::string& prefix); void on_packet(const POCSAGPacketMessage* message); void on_stats(const POCSAGStatsMessage* stats); @@ -273,9 +278,9 @@ class POCSAGAppView : public View { BaudIndicator widget_baud{ {8 * 9 + 1, 1 * 16 + 2}}; - Button button_ignore_last{ + Button button_filter_last{ {10 * 8, 1 * 16, 12 * 8, 20}, - "Ignore Last"}; + "Filter Last"}; Button button_config{ {22 * 8, 1 * 16, 8 * 8, 20}, diff --git a/firmware/baseband/CMakeLists.txt b/firmware/baseband/CMakeLists.txt index 85d689d5..c6ae7d68 100644 --- a/firmware/baseband/CMakeLists.txt +++ b/firmware/baseband/CMakeLists.txt @@ -437,12 +437,12 @@ set(MODE_CPPSRC ) DeclareTargets(POOK ook) -### POCSAG RX - -set(MODE_CPPSRC - proc_pocsag.cpp -) -DeclareTargets(PPOC pocsag) +#### POCSAG RX +# +#set(MODE_CPPSRC +# proc_pocsag.cpp +#) +#DeclareTargets(PPOC pocsag) ### POCSAG2 RX