2016-08-23 06:45:33 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
|
|
|
* Copyright (C) 2016 Furrtek
|
|
|
|
*
|
|
|
|
* This file is part of PortaPack.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __POCSAG_APP_H__
|
|
|
|
#define __POCSAG_APP_H__
|
|
|
|
|
|
|
|
#include "ui_widget.hpp"
|
2023-06-18 19:11:04 +00:00
|
|
|
#include "ui_freq_field.hpp"
|
2016-08-23 06:45:33 +00:00
|
|
|
#include "ui_receiver.hpp"
|
|
|
|
#include "ui_rssi.hpp"
|
2023-08-25 21:45:02 +00:00
|
|
|
#include "ui_styles.hpp"
|
2016-08-23 06:45:33 +00:00
|
|
|
|
2022-04-15 12:43:44 +00:00
|
|
|
#include "app_settings.hpp"
|
2023-08-25 21:45:02 +00:00
|
|
|
#include "log_file.hpp"
|
2017-02-05 20:57:20 +00:00
|
|
|
#include "pocsag.hpp"
|
2016-08-23 06:45:33 +00:00
|
|
|
#include "pocsag_packet.hpp"
|
2023-08-25 21:45:02 +00:00
|
|
|
#include "radio_state.hpp"
|
|
|
|
|
|
|
|
#include <functional>
|
2016-08-23 06:45:33 +00:00
|
|
|
|
|
|
|
class POCSAGLogger {
|
2023-05-18 20:16:05 +00:00
|
|
|
public:
|
|
|
|
Optional<File::Error> append(const std::string& filename) {
|
|
|
|
return log_file.append(filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
void log_raw_data(const pocsag::POCSAGPacket& packet, const uint32_t frequency);
|
2023-08-26 18:43:34 +00:00
|
|
|
void log_decoded(Timestamp timestamp, const std::string& text);
|
2023-05-18 20:16:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
LogFile log_file{};
|
2016-08-23 06:45:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
namespace ui {
|
|
|
|
|
2023-09-08 17:41:09 +00:00
|
|
|
class BaudIndicator : public Widget {
|
|
|
|
public:
|
|
|
|
BaudIndicator(Point position)
|
|
|
|
: Widget{{position, {5, height}}} {}
|
|
|
|
|
|
|
|
void paint(Painter& painter) override;
|
|
|
|
void set_rate(uint16_t rate) {
|
|
|
|
if (rate != rate_) {
|
|
|
|
rate_ = rate;
|
|
|
|
set_dirty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
static constexpr uint8_t height = 16;
|
|
|
|
uint16_t rate_ = 0;
|
|
|
|
};
|
|
|
|
|
2023-09-04 04:49:44 +00:00
|
|
|
class BitsIndicator : public Widget {
|
|
|
|
public:
|
|
|
|
BitsIndicator(Point position)
|
|
|
|
: Widget{{position, {2, height}}} {}
|
|
|
|
|
|
|
|
void paint(Painter& painter) override;
|
|
|
|
void set_bits(uint32_t bits) {
|
|
|
|
if (bits != bits_) {
|
|
|
|
bits_ = bits;
|
|
|
|
set_dirty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
static constexpr uint8_t height = 16;
|
|
|
|
uint32_t bits_ = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FrameIndicator : public Widget {
|
|
|
|
public:
|
|
|
|
FrameIndicator(Point position)
|
|
|
|
: Widget{{position, {4, height}}} {}
|
|
|
|
|
|
|
|
void paint(Painter& painter) override;
|
|
|
|
void set_frames(uint8_t frame_count) {
|
|
|
|
if (frame_count != frame_count_) {
|
|
|
|
frame_count_ = frame_count;
|
|
|
|
set_dirty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_sync(bool has_sync) {
|
|
|
|
if (has_sync != has_sync_) {
|
|
|
|
has_sync_ = has_sync;
|
|
|
|
set_dirty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
static constexpr uint8_t height = 16;
|
|
|
|
uint8_t frame_count_ = 0;
|
|
|
|
bool has_sync_ = false;
|
|
|
|
};
|
|
|
|
|
2023-09-19 09:46:30 +00:00
|
|
|
enum POCSAGFilter : uint8_t {
|
|
|
|
FILTER_NONE,
|
|
|
|
FILTER_DROP,
|
|
|
|
FILTER_KEEP
|
|
|
|
};
|
|
|
|
|
2023-08-25 21:45:02 +00:00
|
|
|
struct POCSAGSettings {
|
|
|
|
bool enable_small_font = false;
|
|
|
|
bool enable_logging = false;
|
|
|
|
bool enable_raw_log = false;
|
2023-08-26 18:43:34 +00:00
|
|
|
bool hide_bad_data = false;
|
2023-08-27 02:32:02 +00:00
|
|
|
bool hide_addr_only = false;
|
2023-09-19 09:46:30 +00:00
|
|
|
uint8_t filter_mode = false;
|
|
|
|
uint32_t filter_address = 0;
|
2023-08-25 21:45:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class POCSAGSettingsView : public View {
|
|
|
|
public:
|
|
|
|
POCSAGSettingsView(NavigationView& nav, POCSAGSettings& settings);
|
|
|
|
|
|
|
|
std::string title() const override { return "POCSAG Config"; };
|
2023-08-31 06:05:49 +00:00
|
|
|
void focus() override { button_save.focus(); }
|
2023-08-25 21:45:02 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
POCSAGSettings& settings_;
|
|
|
|
|
2023-09-19 09:46:30 +00:00
|
|
|
Labels labels{
|
|
|
|
{{2 * 8, 12 * 16}, "Filter Mode:", Color::light_grey()},
|
|
|
|
{{2 * 8, 13 * 16}, "Filter Addr:", Color::light_grey()},
|
|
|
|
};
|
2023-08-31 06:05:49 +00:00
|
|
|
|
2023-08-25 21:45:02 +00:00
|
|
|
Checkbox check_log{
|
|
|
|
{2 * 8, 2 * 16},
|
|
|
|
10,
|
2023-08-31 06:05:49 +00:00
|
|
|
"Enable Log"};
|
2023-08-25 21:45:02 +00:00
|
|
|
|
|
|
|
Checkbox check_log_raw{
|
|
|
|
{2 * 8, 4 * 16},
|
|
|
|
12,
|
2023-08-31 06:05:49 +00:00
|
|
|
"Log Raw Data"};
|
2023-08-25 21:45:02 +00:00
|
|
|
|
|
|
|
Checkbox check_small_font{
|
|
|
|
{2 * 8, 6 * 16},
|
|
|
|
4,
|
2023-08-31 06:05:49 +00:00
|
|
|
"Use Small Font"};
|
2023-08-25 21:45:02 +00:00
|
|
|
|
2023-08-27 02:32:02 +00:00
|
|
|
Checkbox check_hide_bad{
|
2023-08-25 21:45:02 +00:00
|
|
|
{2 * 8, 8 * 16},
|
|
|
|
22,
|
2023-08-31 06:05:49 +00:00
|
|
|
"Hide Bad Data"};
|
2023-08-26 18:43:34 +00:00
|
|
|
|
2023-08-27 02:32:02 +00:00
|
|
|
Checkbox check_hide_addr_only{
|
2023-08-26 18:43:34 +00:00
|
|
|
{2 * 8, 10 * 16},
|
|
|
|
22,
|
2023-08-31 06:05:49 +00:00
|
|
|
"Hide Addr Only"};
|
2023-08-27 02:32:02 +00:00
|
|
|
|
2023-09-19 09:46:30 +00:00
|
|
|
OptionsField opt_filter_mode{
|
|
|
|
{15 * 8, 12 * 16},
|
|
|
|
4,
|
|
|
|
{{"None", FILTER_NONE},
|
|
|
|
{"Drop", FILTER_DROP},
|
|
|
|
{"Keep", FILTER_KEEP}}};
|
2023-08-25 21:45:02 +00:00
|
|
|
|
2023-09-19 09:46:30 +00:00
|
|
|
SymField field_filter_address{
|
|
|
|
{15 * 8, 13 * 16},
|
2023-08-25 21:45:02 +00:00
|
|
|
7,
|
2023-09-12 19:38:19 +00:00
|
|
|
SymField::Type::Dec,
|
|
|
|
true /*explicit_edit*/};
|
2023-08-25 21:45:02 +00:00
|
|
|
|
|
|
|
Button button_save{
|
2023-08-31 06:05:49 +00:00
|
|
|
{11 * 8, 16 * 16, 10 * 8, 2 * 16},
|
2023-08-25 21:45:02 +00:00
|
|
|
"Save"};
|
|
|
|
};
|
|
|
|
|
2016-08-23 06:45:33 +00:00
|
|
|
class POCSAGAppView : public View {
|
2023-05-18 20:16:05 +00:00
|
|
|
public:
|
|
|
|
POCSAGAppView(NavigationView& nav);
|
|
|
|
~POCSAGAppView();
|
|
|
|
|
|
|
|
std::string title() const override { return "POCSAG RX"; };
|
2023-06-11 18:47:13 +00:00
|
|
|
void focus() override;
|
2023-05-18 20:16:05 +00:00
|
|
|
|
|
|
|
private:
|
2023-08-25 21:45:02 +00:00
|
|
|
bool logging() const { return settings_.enable_logging; };
|
|
|
|
bool logging_raw() const { return settings_.enable_raw_log; };
|
2023-08-26 18:43:34 +00:00
|
|
|
bool hide_bad_data() const { return settings_.hide_bad_data; };
|
2023-08-27 02:32:02 +00:00
|
|
|
bool hide_addr_only() const { return settings_.hide_addr_only; };
|
2023-06-04 19:56:46 +00:00
|
|
|
|
2023-06-18 19:11:04 +00:00
|
|
|
NavigationView& nav_;
|
2023-10-14 16:33:52 +00:00
|
|
|
RxRadioState radio_state_{
|
|
|
|
466175000 /* frequency*/,
|
|
|
|
max283x::filter::bandwidth_minimum /* bandwidth */,
|
|
|
|
3072000 /* sampling rate */
|
|
|
|
};
|
2023-08-25 21:45:02 +00:00
|
|
|
|
2023-08-18 19:35:41 +00:00
|
|
|
// Settings
|
2023-08-25 21:45:02 +00:00
|
|
|
POCSAGSettings settings_{};
|
|
|
|
app_settings::SettingsManager app_settings_{
|
2023-08-19 16:02:26 +00:00
|
|
|
"rx_pocsag"sv,
|
|
|
|
app_settings::Mode::RX,
|
2023-08-25 21:45:02 +00:00
|
|
|
{
|
|
|
|
{"small_font"sv, &settings_.enable_small_font},
|
|
|
|
{"enable_logging"sv, &settings_.enable_logging},
|
2023-09-08 19:20:26 +00:00
|
|
|
{"enable_raw_log"sv, &settings_.enable_raw_log},
|
2023-09-19 09:46:30 +00:00
|
|
|
{"filter_mode"sv, &settings_.filter_mode},
|
|
|
|
{"filter_address"sv, &settings_.filter_address},
|
2023-08-26 18:43:34 +00:00
|
|
|
{"hide_bad_data"sv, &settings_.hide_bad_data},
|
2023-08-27 02:32:02 +00:00
|
|
|
{"hide_addr_only"sv, &settings_.hide_addr_only},
|
2023-08-25 21:45:02 +00:00
|
|
|
}};
|
|
|
|
|
|
|
|
void refresh_ui();
|
2023-09-19 09:46:30 +00:00
|
|
|
bool ignore_address(uint32_t address) const;
|
2023-08-26 18:43:34 +00:00
|
|
|
void handle_decoded(Timestamp timestamp, const std::string& prefix);
|
2023-08-25 21:45:02 +00:00
|
|
|
void on_packet(const POCSAGPacketMessage* message);
|
|
|
|
void on_stats(const POCSAGStatsMessage* stats);
|
2023-05-18 20:16:05 +00:00
|
|
|
|
2023-09-12 19:38:19 +00:00
|
|
|
uint32_t last_address = 0;
|
2023-08-27 22:56:40 +00:00
|
|
|
pocsag::EccContainer ecc{};
|
|
|
|
pocsag::POCSAGState pocsag_state{&ecc};
|
2023-08-25 21:45:02 +00:00
|
|
|
POCSAGLogger logger{};
|
2023-08-26 18:43:34 +00:00
|
|
|
uint16_t packet_count = 0;
|
2023-05-18 20:16:05 +00:00
|
|
|
|
2023-08-27 22:56:40 +00:00
|
|
|
RxFrequencyField field_frequency{
|
|
|
|
{0 * 8, 0 * 8},
|
|
|
|
nav_};
|
|
|
|
|
2023-05-18 20:16:05 +00:00
|
|
|
RFAmpField field_rf_amp{
|
2023-08-27 22:56:40 +00:00
|
|
|
{11 * 8, 0 * 16}};
|
2023-05-18 20:16:05 +00:00
|
|
|
LNAGainField field_lna{
|
2023-08-27 22:56:40 +00:00
|
|
|
{13 * 8, 0 * 16}};
|
2023-05-18 20:16:05 +00:00
|
|
|
VGAGainField field_vga{
|
2023-08-27 22:56:40 +00:00
|
|
|
{16 * 8, 0 * 16}};
|
|
|
|
|
2023-05-18 20:16:05 +00:00
|
|
|
RSSI rssi{
|
2023-08-27 22:56:40 +00:00
|
|
|
{19 * 8 - 4, 3, 6 * 8, 4}};
|
2023-05-18 20:16:05 +00:00
|
|
|
Audio audio{
|
2023-08-27 22:56:40 +00:00
|
|
|
{19 * 8 - 4, 8, 6 * 8, 4}};
|
2023-05-18 20:16:05 +00:00
|
|
|
|
2023-08-27 22:56:40 +00:00
|
|
|
NumberField field_squelch{
|
|
|
|
{25 * 8, 0 * 16},
|
|
|
|
2,
|
|
|
|
{0, 99},
|
|
|
|
1,
|
2023-09-04 04:49:44 +00:00
|
|
|
' ',
|
|
|
|
true /*wrap*/};
|
2023-06-04 19:56:46 +00:00
|
|
|
AudioVolumeField field_volume{
|
|
|
|
{28 * 8, 0 * 16}};
|
2023-05-18 20:16:05 +00:00
|
|
|
|
2023-08-25 21:45:02 +00:00
|
|
|
Image image_status{
|
2023-08-26 18:43:34 +00:00
|
|
|
{0 * 8 + 4, 1 * 16 + 2, 16, 16},
|
2023-08-25 21:45:02 +00:00
|
|
|
&bitmap_icon_pocsag,
|
|
|
|
Color::white(),
|
|
|
|
Color::black()};
|
2023-05-18 20:16:05 +00:00
|
|
|
|
2023-08-26 18:43:34 +00:00
|
|
|
Text text_packet_count{
|
|
|
|
{3 * 8, 1 * 16 + 2, 5 * 8, 16},
|
|
|
|
"0"};
|
|
|
|
|
2023-09-04 04:49:44 +00:00
|
|
|
BitsIndicator widget_bits{
|
2023-09-08 17:41:09 +00:00
|
|
|
{8 * 8 + 1, 1 * 16 + 2}};
|
2023-09-04 04:49:44 +00:00
|
|
|
|
|
|
|
FrameIndicator widget_frames{
|
2023-09-08 17:41:09 +00:00
|
|
|
{8 * 8 + 4, 1 * 16 + 2}};
|
|
|
|
|
|
|
|
BaudIndicator widget_baud{
|
|
|
|
{8 * 9 + 1, 1 * 16 + 2}};
|
2023-09-04 04:49:44 +00:00
|
|
|
|
2023-09-19 09:46:30 +00:00
|
|
|
Button button_filter_last{
|
2023-08-25 21:45:02 +00:00
|
|
|
{10 * 8, 1 * 16, 12 * 8, 20},
|
2023-09-19 09:46:30 +00:00
|
|
|
"Filter Last"};
|
2023-05-18 20:16:05 +00:00
|
|
|
|
2023-08-25 21:45:02 +00:00
|
|
|
Button button_config{
|
|
|
|
{22 * 8, 1 * 16, 8 * 8, 20},
|
|
|
|
"Config"};
|
2023-05-18 20:16:05 +00:00
|
|
|
|
2023-09-14 18:20:40 +00:00
|
|
|
// 54 == status bar (16) + top controls (2 * 16 + 6).
|
2023-08-25 21:45:02 +00:00
|
|
|
Console console{
|
2023-09-14 18:20:40 +00:00
|
|
|
{0, 2 * 16 + 6, screen_width, screen_height - 54}};
|
2023-05-18 20:16:05 +00:00
|
|
|
|
|
|
|
MessageHandlerRegistration message_handler_packet{
|
|
|
|
Message::ID::POCSAGPacket,
|
|
|
|
[this](Message* const p) {
|
|
|
|
const auto message = static_cast<const POCSAGPacketMessage*>(p);
|
|
|
|
this->on_packet(message);
|
|
|
|
}};
|
2023-08-25 21:45:02 +00:00
|
|
|
|
|
|
|
MessageHandlerRegistration message_handler_stats{
|
|
|
|
Message::ID::POCSAGStats,
|
|
|
|
[this](Message* const p) {
|
|
|
|
const auto stats = static_cast<const POCSAGStatsMessage*>(p);
|
|
|
|
this->on_stats(stats);
|
|
|
|
}};
|
2016-08-23 06:45:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace ui */
|
|
|
|
|
2023-05-18 20:16:05 +00:00
|
|
|
#endif /*__POCSAG_APP_H__*/
|