Pocsag UX Revamp (#1408)

* Set bandwidth_filter in pogsac

* WIP pocsag UI revamp

* Settings UI, better console, UI Revamp

* Add baud rate to error messages

* Reset last_addr in error cases

* Show malformed messages as different color vs hiding

* Use light grey to indicate low quality decode

---------

Co-authored-by: kallanreed <kallanreed@noreply.github.com>
This commit is contained in:
Kyle Reed 2023-08-25 14:45:02 -07:00 committed by GitHub
parent f4496d8f45
commit 9af1308e29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 247 additions and 115 deletions

View file

@ -27,12 +27,15 @@
#include "ui_freq_field.hpp"
#include "ui_receiver.hpp"
#include "ui_rssi.hpp"
#include "ui_styles.hpp"
#include "log_file.hpp"
#include "app_settings.hpp"
#include "radio_state.hpp"
#include "log_file.hpp"
#include "pocsag.hpp"
#include "pocsag_packet.hpp"
#include "radio_state.hpp"
#include <functional>
class POCSAGLogger {
public:
@ -49,6 +52,59 @@ class POCSAGLogger {
namespace ui {
struct POCSAGSettings {
bool enable_small_font = false;
bool enable_logging = false;
bool enable_raw_log = false;
bool enable_ignore = false;
uint32_t address_to_ignore = 0;
};
class POCSAGSettingsView : public View {
public:
POCSAGSettingsView(NavigationView& nav, POCSAGSettings& settings);
std::string title() const override { return "POCSAG Config"; };
private:
POCSAGSettings& settings_;
Checkbox check_log{
{2 * 8, 2 * 16},
10,
"Enable Log",
false};
Checkbox check_log_raw{
{2 * 8, 4 * 16},
12,
"Log Raw Data",
false};
Checkbox check_small_font{
{2 * 8, 6 * 16},
4,
"Use Small Font",
false};
Checkbox check_ignore{
{2 * 8, 8 * 16},
22,
"Enable Ignored Address",
false};
NumberField field_ignore{
{7 * 8, 9 * 16 + 8},
7,
{0, 9999999},
1,
'0'};
Button button_save{
{12 * 8, 16 * 16, 10 * 8, 2 * 16},
"Save"};
};
class POCSAGAppView : public View {
public:
POCSAGAppView(NavigationView& nav);
@ -58,21 +114,36 @@ class POCSAGAppView : public View {
void focus() override;
private:
static constexpr uint32_t initial_target_frequency = 466175000;
bool logging() const { return check_log.value(); };
bool ignore() const { return check_ignore.value(); };
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; };
NavigationView& nav_;
RxRadioState radio_state_{};
RxRadioState radio_state_{
12'500, // POCSAG is FSK +/- 4.5MHz, 12k5 is a good filter.
3'072'000, // Match baseband_fs in proc_pocsag.
};
// Settings
bool enable_logging = false;
app_settings::SettingsManager settings_{
POCSAGSettings settings_{};
app_settings::SettingsManager app_settings_{
"rx_pocsag"sv,
app_settings::Mode::RX,
{{"enable_logging"sv, &enable_logging}}};
{
{"small_font"sv, &settings_.enable_small_font},
{"enable_logging"sv, &settings_.enable_logging},
{"enable_ignore"sv, &settings_.enable_ignore},
}};
void refresh_ui();
void on_packet(const POCSAGPacketMessage* message);
void on_stats(const POCSAGStatsMessage* stats);
uint32_t last_address = 0xFFFFFFFF;
pocsag::POCSAGState pocsag_state{};
POCSAGLogger logger{};
bool packet_toggle = false;
RFAmpField field_rf_amp{
{13 * 8, 0 * 16}};
@ -81,41 +152,32 @@ class POCSAGAppView : public View {
VGAGainField field_vga{
{18 * 8, 0 * 16}};
RSSI rssi{
{21 * 8, 0, 6 * 8, 4}};
Channel channel{
{21 * 8, 5, 6 * 8, 4}};
{21 * 8, 3, 6 * 8, 4}};
Audio audio{
{21 * 8, 10, 6 * 8, 4}};
{21 * 8, 8, 6 * 8, 4}};
RxFrequencyField field_frequency{
{0 * 8, 0 * 8},
nav_};
AudioVolumeField field_volume{
{28 * 8, 0 * 16}};
Checkbox check_ignore{
{0 * 8, 21},
8,
"Ign addr",
false};
SymField sym_ignore{
{13 * 8, 25},
7,
SymField::SYMFIELD_DEC};
Image image_status{
{7 * 8, 1 * 16 + 2, 16, 16},
&bitmap_icon_pocsag,
Color::white(),
Color::black()};
Checkbox check_log{
{240 - 8 * 8, 21},
3,
"Log",
false};
Button button_ignore_last{
{10 * 8, 1 * 16, 12 * 8, 20},
"Ignore Last"};
Button button_config{
{22 * 8, 1 * 16, 8 * 8, 20},
"Config"};
Console console{
{0, 3 * 16, 240, 256}};
std::unique_ptr<POCSAGLogger> logger{};
void on_packet(const POCSAGPacketMessage* message);
{0, 2 * 16 + 6, screen_width, screen_height - 56}};
MessageHandlerRegistration message_handler_packet{
Message::ID::POCSAGPacket,
@ -123,6 +185,13 @@ class POCSAGAppView : public View {
const auto message = static_cast<const POCSAGPacketMessage*>(p);
this->on_packet(message);
}};
MessageHandlerRegistration message_handler_stats{
Message::ID::POCSAGStats,
[this](Message* const p) {
const auto stats = static_cast<const POCSAGStatsMessage*>(p);
this->on_stats(stats);
}};
};
} /* namespace ui */