2021-03-07 17:05:23 -05:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
|
|
|
* Copyright (C) 2017 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 __UI_APRS_RX_H__
|
|
|
|
#define __UI_APRS_RX_H__
|
|
|
|
|
|
|
|
#include "ui.hpp"
|
|
|
|
#include "ui_navigation.hpp"
|
|
|
|
#include "ui_receiver.hpp"
|
2023-06-18 15:11:04 -04:00
|
|
|
#include "ui_freq_field.hpp"
|
|
|
|
#include "ui_record_view.hpp"
|
2021-03-07 17:05:23 -05:00
|
|
|
#include "ui_geomap.hpp"
|
2022-04-15 08:43:44 -04:00
|
|
|
#include "app_settings.hpp"
|
2023-06-14 03:57:20 -04:00
|
|
|
#include "radio_state.hpp"
|
2021-03-07 17:05:23 -05:00
|
|
|
#include "recent_entries.hpp"
|
|
|
|
#include "ui_tabview.hpp"
|
|
|
|
|
|
|
|
#include "log_file.hpp"
|
|
|
|
#include "utility.hpp"
|
2024-03-25 03:44:49 -04:00
|
|
|
#include "file_path.hpp"
|
2021-03-07 17:05:23 -05:00
|
|
|
|
|
|
|
class APRSLogger {
|
2023-05-18 16:16:05 -04:00
|
|
|
public:
|
2024-03-25 03:44:49 -04:00
|
|
|
Optional<File::Error> append(const std::filesystem::path& filename) {
|
2023-05-18 16:16:05 -04:00
|
|
|
return log_file.append(filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
void log_raw_data(const std::string& data);
|
|
|
|
|
|
|
|
private:
|
|
|
|
LogFile log_file{};
|
2021-03-07 17:05:23 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
namespace ui {
|
|
|
|
|
|
|
|
struct APRSRecentEntry {
|
2023-05-18 16:16:05 -04:00
|
|
|
using Key = uint64_t;
|
|
|
|
|
|
|
|
static constexpr Key invalid_key = 0xffffffffffffffff;
|
|
|
|
|
|
|
|
uint16_t hits{0};
|
|
|
|
uint32_t age{0};
|
|
|
|
|
|
|
|
uint64_t source{0};
|
|
|
|
std::string source_formatted{" "};
|
|
|
|
std::string time_string{""};
|
|
|
|
std::string info_string{""};
|
|
|
|
|
|
|
|
aprs::aprs_pos pos{0, 0, 0, 0};
|
|
|
|
bool has_position = false;
|
|
|
|
APRSRecentEntry(uint64_t src) {
|
|
|
|
source = src;
|
|
|
|
}
|
|
|
|
|
|
|
|
Key key() const {
|
|
|
|
return source;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_source_formatted(std::string& new_source) {
|
|
|
|
source_formatted = new_source;
|
|
|
|
}
|
|
|
|
|
|
|
|
void inc_hit() {
|
|
|
|
hits++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_info_string(std::string& new_info_string) {
|
|
|
|
info_string = new_info_string;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_time_string(std::string& new_time_string) {
|
|
|
|
time_string = new_time_string;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_pos(aprs::aprs_pos pos_in) {
|
|
|
|
pos = pos_in;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_has_position(bool has_pos) {
|
|
|
|
has_position = has_pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
void reset_age() {
|
|
|
|
age = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void inc_age() {
|
|
|
|
age++;
|
|
|
|
}
|
2021-03-07 17:05:23 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
class APRSDetailsView : public View {
|
2023-05-18 16:16:05 -04:00
|
|
|
public:
|
|
|
|
APRSDetailsView(NavigationView&);
|
|
|
|
~APRSDetailsView();
|
|
|
|
|
|
|
|
APRSDetailsView(const APRSDetailsView&) = delete;
|
|
|
|
APRSDetailsView(APRSDetailsView&&) = delete;
|
|
|
|
APRSDetailsView& operator=(const APRSDetailsView&) = delete;
|
|
|
|
APRSDetailsView& operator=(APRSDetailsView&&) = delete;
|
|
|
|
|
|
|
|
void focus() override;
|
|
|
|
|
|
|
|
void update();
|
|
|
|
void set_entry(const APRSRecentEntry& entry);
|
|
|
|
|
|
|
|
const APRSRecentEntry& entry() const { return entry_copy; };
|
|
|
|
|
|
|
|
std::string title() const override { return "Details"; };
|
|
|
|
std::function<void(void)> on_close{};
|
|
|
|
|
|
|
|
private:
|
|
|
|
APRSRecentEntry entry_copy{0};
|
|
|
|
GeoMapView* geomap_view{nullptr};
|
|
|
|
bool send_updates{false};
|
|
|
|
|
|
|
|
Console console{
|
|
|
|
{0, 0 * 16, 240, 224}};
|
|
|
|
|
|
|
|
Button button_done{
|
|
|
|
{160, 14 * 16, 8 * 8, 3 * 16},
|
|
|
|
"Close"};
|
|
|
|
|
|
|
|
Button button_see_map{
|
|
|
|
{80, 14 * 16, 8 * 8, 3 * 16},
|
|
|
|
"Map"};
|
2021-03-07 17:05:23 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
using APRSRecentEntries = RecentEntries<APRSRecentEntry>;
|
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
class APRSTableView : public View {
|
|
|
|
public:
|
|
|
|
APRSTableView(NavigationView& nav, Rect parent_rec);
|
|
|
|
~APRSTableView();
|
|
|
|
|
|
|
|
void on_show() override;
|
|
|
|
void on_hide() override;
|
|
|
|
void focus() override;
|
|
|
|
void on_pkt(const APRSPacketMessage* message);
|
|
|
|
|
|
|
|
std::string title() const override { return "Stations"; };
|
|
|
|
|
|
|
|
private:
|
|
|
|
NavigationView& nav_;
|
|
|
|
const RecentEntriesColumns columns{{{"Source", 9},
|
|
|
|
{"Loc", 6},
|
|
|
|
{"Hits", 4},
|
|
|
|
{"Time", 8}}};
|
|
|
|
APRSRecentEntries recent{};
|
|
|
|
RecentEntriesView<RecentEntries<APRSRecentEntry>> recent_entries_view{columns, recent};
|
|
|
|
APRSDetailsView details_view{nav_};
|
|
|
|
uint32_t detailed_entry_key{0};
|
|
|
|
bool send_updates{false};
|
|
|
|
|
|
|
|
void on_show_list();
|
|
|
|
void on_show_detail(const APRSRecentEntry& entry);
|
2021-03-07 17:05:23 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
class APRSRxView : public View {
|
2023-05-18 16:16:05 -04:00
|
|
|
public:
|
|
|
|
APRSRxView(NavigationView& nav, Rect parent_rect);
|
|
|
|
~APRSRxView();
|
|
|
|
|
|
|
|
void on_show() override;
|
|
|
|
void focus() override;
|
|
|
|
|
|
|
|
std::string title() const override { return "APRS RX"; };
|
|
|
|
void on_packet(const APRSPacketMessage* message);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void on_data(uint32_t value, bool is_data);
|
|
|
|
bool reset_console = false;
|
|
|
|
|
2023-06-18 15:11:04 -04:00
|
|
|
NavigationView& nav_;
|
2023-10-14 12:33:52 -04:00
|
|
|
RxRadioState radio_state_{
|
|
|
|
144390000 /* frequency */,
|
|
|
|
1750000 /* bandwidth */,
|
|
|
|
3072000 /* sampling rate */
|
|
|
|
};
|
2023-06-11 14:47:13 -04:00
|
|
|
app_settings::SettingsManager settings_{
|
|
|
|
"rx_aprs", app_settings::Mode::RX};
|
2023-05-18 16:16:05 -04:00
|
|
|
|
|
|
|
uint8_t console_color{0};
|
|
|
|
std::string str_log{""};
|
|
|
|
|
|
|
|
RFAmpField field_rf_amp{
|
|
|
|
{13 * 8, 0 * 16}};
|
|
|
|
LNAGainField field_lna{
|
|
|
|
{15 * 8, 0 * 16}};
|
|
|
|
VGAGainField field_vga{
|
|
|
|
{18 * 8, 0 * 16}};
|
|
|
|
RSSI rssi{
|
2023-06-18 15:11:04 -04:00
|
|
|
{21 * 8, 0, 6 * 8, 4}};
|
2023-05-18 16:16:05 -04:00
|
|
|
Channel channel{
|
2023-06-18 15:11:04 -04:00
|
|
|
{21 * 8, 5, 6 * 8, 4}};
|
2023-05-18 16:16:05 -04:00
|
|
|
|
2023-06-05 14:09:50 -04:00
|
|
|
AudioVolumeField field_volume{
|
|
|
|
{28 * 8, 0 * 16}};
|
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
OptionsField options_region{
|
|
|
|
{0 * 8, 0 * 8},
|
|
|
|
3,
|
|
|
|
{{"NA ", 0},
|
|
|
|
{"EUR", 1},
|
|
|
|
{"AUS", 2},
|
2024-01-25 15:10:43 -05:00
|
|
|
{"NZ ", 3},
|
|
|
|
{"ISS", 4}}};
|
2023-05-18 16:16:05 -04:00
|
|
|
|
2023-06-18 15:11:04 -04:00
|
|
|
RxFrequencyField field_frequency{
|
2023-05-18 16:16:05 -04:00
|
|
|
{3 * 8, 0 * 16},
|
2023-06-18 15:11:04 -04:00
|
|
|
nav_};
|
2023-05-18 16:16:05 -04:00
|
|
|
|
|
|
|
// DEBUG
|
|
|
|
RecordView record_view{
|
|
|
|
{0 * 8, 1 * 16, 30 * 8, 1 * 16},
|
|
|
|
u"AFS_????.WAV",
|
2024-03-25 03:44:49 -04:00
|
|
|
aprs_dir,
|
2023-05-18 16:16:05 -04:00
|
|
|
RecordView::FileType::WAV,
|
|
|
|
4096,
|
|
|
|
4};
|
|
|
|
|
|
|
|
Console console{
|
|
|
|
{0, 2 * 16, 240, 240}};
|
|
|
|
|
|
|
|
std::unique_ptr<APRSLogger> logger{};
|
2021-03-07 17:05:23 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
class APRSRXView : public View {
|
2023-05-18 16:16:05 -04:00
|
|
|
public:
|
|
|
|
APRSRXView(NavigationView& nav);
|
|
|
|
~APRSRXView();
|
|
|
|
|
|
|
|
void focus() override;
|
|
|
|
|
|
|
|
std::string title() const override { return "APRS RX"; };
|
|
|
|
|
|
|
|
private:
|
|
|
|
NavigationView& nav_;
|
|
|
|
Rect view_rect = {0, 3 * 8, 240, 280};
|
|
|
|
|
|
|
|
APRSRxView view_stream{nav_, view_rect};
|
|
|
|
APRSTableView view_table{nav_, view_rect};
|
|
|
|
|
|
|
|
TabView tab_view{
|
|
|
|
{"Stream", Color::cyan(), &view_stream},
|
|
|
|
{"List", Color::yellow(), &view_table}};
|
|
|
|
|
|
|
|
MessageHandlerRegistration message_handler_packet{
|
|
|
|
Message::ID::APRSPacket,
|
|
|
|
[this](Message* const p) {
|
|
|
|
const auto message = static_cast<const APRSPacketMessage*>(p);
|
|
|
|
this->view_stream.on_packet(message);
|
|
|
|
this->view_table.on_pkt(message);
|
|
|
|
}};
|
2021-03-07 17:05:23 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace ui */
|
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
#endif /*__UI_APRS_RX_H__*/
|