2023-03-10 08:25:38 -05:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
|
|
|
* Copyright (C) 2018 Furrtek
|
2023-05-22 16:17:28 -04:00
|
|
|
* Copyright (C) 2023 gullradriel, Nilorea Studio Inc.
|
2023-03-10 08:25:38 -05:00
|
|
|
*
|
|
|
|
* 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_LEVEL
|
|
|
|
#define _UI_LEVEL
|
|
|
|
|
|
|
|
#include "analog_audio_app.hpp"
|
2023-07-17 14:43:37 -04:00
|
|
|
#include "app_settings.hpp"
|
2023-03-10 08:25:38 -05:00
|
|
|
#include "audio.hpp"
|
|
|
|
#include "baseband_api.hpp"
|
|
|
|
#include "file.hpp"
|
2023-07-17 14:43:37 -04:00
|
|
|
#include "freqman_db.hpp"
|
|
|
|
#include "portapack_persistent_memory.hpp"
|
2023-06-14 03:57:20 -04:00
|
|
|
#include "radio_state.hpp"
|
2023-07-17 14:43:37 -04:00
|
|
|
#include "receiver_model.hpp"
|
|
|
|
#include "string_format.hpp"
|
|
|
|
#include "ui.hpp"
|
|
|
|
#include "ui_mictx.hpp"
|
|
|
|
#include "ui_receiver.hpp"
|
|
|
|
#include "ui_spectrum.hpp"
|
|
|
|
#include "ui_styles.hpp"
|
2023-03-10 08:25:38 -05:00
|
|
|
|
|
|
|
namespace ui {
|
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
class LevelView : public View {
|
|
|
|
public:
|
|
|
|
LevelView(NavigationView& nav);
|
|
|
|
~LevelView();
|
|
|
|
|
|
|
|
void focus() override;
|
|
|
|
|
|
|
|
std::string title() const override { return "Level"; };
|
|
|
|
|
|
|
|
private:
|
|
|
|
NavigationView& nav_;
|
|
|
|
|
2023-06-14 03:57:20 -04:00
|
|
|
RxRadioState radio_state_{};
|
2023-06-11 14:47:13 -04:00
|
|
|
|
2024-03-24 17:32:13 -04:00
|
|
|
int32_t map(int32_t value, int32_t fromLow, int32_t fromHigh, int32_t toLow, int32_t toHigh);
|
2023-05-18 16:16:05 -04:00
|
|
|
size_t change_mode(freqman_index_t mod_type);
|
|
|
|
void on_statistics_update(const ChannelStatistics& statistics);
|
|
|
|
void set_display_freq(int64_t freq);
|
2024-03-23 14:27:05 -04:00
|
|
|
void m4_manage_stat_update(); // to finely adjust the RxSaturation usage
|
2023-05-18 16:16:05 -04:00
|
|
|
|
2023-06-11 14:47:13 -04:00
|
|
|
rf::Frequency freq_ = {0};
|
2024-03-23 14:27:05 -04:00
|
|
|
bool beep = false;
|
|
|
|
uint8_t radio_mode = 0;
|
|
|
|
uint8_t radio_bw = 0;
|
|
|
|
uint8_t audio_mode = 0;
|
|
|
|
int32_t beep_squelch = 0;
|
|
|
|
audio::Rate audio_sampling_rate = audio::Rate::Hz_48000;
|
|
|
|
|
|
|
|
app_settings::SettingsManager settings_{
|
|
|
|
"rx_level",
|
|
|
|
app_settings::Mode::RX,
|
|
|
|
{
|
|
|
|
{"beep_squelch"sv, &beep_squelch},
|
|
|
|
{"audio_mode"sv, &audio_mode},
|
|
|
|
{"radio_mode"sv, &radio_mode},
|
|
|
|
{"radio_bw"sv, &radio_bw},
|
|
|
|
}};
|
2023-05-18 16:16:05 -04:00
|
|
|
|
|
|
|
Labels labels{
|
|
|
|
{{0 * 8, 0 * 16}, "LNA: VGA: AMP: VOL: ", Color::light_grey()},
|
|
|
|
{{0 * 8, 1 * 16}, "BW: MODE: S: ", Color::light_grey()},
|
|
|
|
};
|
|
|
|
|
|
|
|
LNAGainField field_lna{
|
|
|
|
{4 * 8, 0 * 16}};
|
|
|
|
|
|
|
|
VGAGainField field_vga{
|
|
|
|
{11 * 8, 0 * 16}};
|
|
|
|
|
|
|
|
RFAmpField field_rf_amp{
|
|
|
|
{18 * 8, 0 * 16}};
|
|
|
|
|
2023-06-04 15:56:46 -04:00
|
|
|
AudioVolumeField field_volume{
|
|
|
|
{24 * 8, 0 * 16}};
|
2023-05-18 16:16:05 -04:00
|
|
|
|
|
|
|
OptionsField field_bw{
|
|
|
|
{3 * 8, 1 * 16},
|
|
|
|
6,
|
|
|
|
{}};
|
|
|
|
|
|
|
|
OptionsField field_mode{
|
|
|
|
{15 * 8, 1 * 16},
|
2023-06-27 04:02:04 -04:00
|
|
|
4,
|
2023-05-18 16:16:05 -04:00
|
|
|
{}};
|
|
|
|
|
|
|
|
OptionsField step_mode{
|
|
|
|
{16 * 8, 2 * 16 + 4},
|
|
|
|
12,
|
|
|
|
{}};
|
|
|
|
|
|
|
|
ButtonWithEncoder button_frequency{
|
|
|
|
{0 * 8, 2 * 16 + 8, 15 * 8, 1 * 8},
|
|
|
|
""};
|
|
|
|
|
2024-03-23 14:27:05 -04:00
|
|
|
OptionsField field_audio_mode{
|
2023-05-18 16:16:05 -04:00
|
|
|
{21 * 8, 1 * 16},
|
|
|
|
9,
|
2024-03-23 14:27:05 -04:00
|
|
|
{{"audio off", 0},
|
|
|
|
{"audio on", 1}}};
|
|
|
|
|
|
|
|
Text text_beep_squelch{
|
|
|
|
{21 * 8, 3 * 16 + 4, 4 * 8, 1 * 8},
|
|
|
|
"Bip>"};
|
|
|
|
|
|
|
|
NumberField field_beep_squelch{
|
|
|
|
{25 * 8, 3 * 16 + 4},
|
2024-03-23 16:01:48 -04:00
|
|
|
4,
|
2024-03-24 17:32:13 -04:00
|
|
|
{-100, 20},
|
2024-03-23 14:27:05 -04:00
|
|
|
1,
|
|
|
|
' ',
|
|
|
|
};
|
2023-05-18 16:16:05 -04:00
|
|
|
|
2024-03-23 14:27:05 -04:00
|
|
|
// RSSI: XX/XX/XXX
|
2023-05-18 16:16:05 -04:00
|
|
|
Text freq_stats_rssi{
|
2024-03-23 14:27:05 -04:00
|
|
|
{0 * 8, 3 * 16 + 4, 15 * 8, 1 * 16},
|
2023-05-18 16:16:05 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// Power: -XXX db
|
|
|
|
Text freq_stats_db{
|
2024-03-10 13:29:21 -04:00
|
|
|
{0 * 8, 4 * 16 + 4, 15 * 8, 1 * 16},
|
2023-05-18 16:16:05 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
OptionsField peak_mode{
|
|
|
|
{40 + 10 * 8, 4 * 16 + 4},
|
|
|
|
10,
|
|
|
|
{
|
|
|
|
{"peak:none", 0},
|
|
|
|
{"peak:0.25s", 250},
|
|
|
|
{"peak:0.5s", 500},
|
|
|
|
{"peak:1s", 1000},
|
|
|
|
{"peak:3s", 3000},
|
|
|
|
{"peak:5s", 5000},
|
|
|
|
{"peak:10s", 10000},
|
|
|
|
}};
|
2024-03-09 09:26:56 -05:00
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
OptionsField rssi_resolution{
|
|
|
|
{44 + 20 * 8, 4 * 16 + 4},
|
|
|
|
4,
|
|
|
|
{
|
|
|
|
{"16x", 16},
|
|
|
|
{"32x", 32},
|
|
|
|
{"64x", 64},
|
|
|
|
{"128x", 128},
|
|
|
|
{"240x", 240},
|
|
|
|
}};
|
|
|
|
|
2024-03-09 09:26:56 -05:00
|
|
|
// RxSat: XX%
|
|
|
|
Text freq_stats_rx{
|
2024-03-10 13:29:21 -04:00
|
|
|
{0 * 8, 5 * 16 + 4, 10 * 8, 1 * 16},
|
2024-03-09 09:26:56 -05:00
|
|
|
};
|
|
|
|
|
2024-03-23 14:27:05 -04:00
|
|
|
Text text_ctcss{
|
|
|
|
{12 * 8, 5 * 16 + 4, 8 * 8, 1 * 8},
|
|
|
|
""};
|
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
RSSIGraph rssi_graph{
|
|
|
|
// 240x320 =>
|
2024-03-23 14:27:05 -04:00
|
|
|
{0, 6 * 16 + 8, 240 - 5 * 8, 320 - (6 * 16)},
|
2023-05-18 16:16:05 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
RSSI rssi{
|
|
|
|
// 240x320 =>
|
2024-03-23 14:27:05 -04:00
|
|
|
{240 - 5 * 8, 6 * 16 + 8, 5 * 8, 320 - (6 * 16)},
|
2023-05-18 16:16:05 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
void handle_coded_squelch(const uint32_t value);
|
|
|
|
|
|
|
|
MessageHandlerRegistration message_handler_coded_squelch{
|
|
|
|
Message::ID::CodedSquelch,
|
|
|
|
[this](const Message* const p) {
|
|
|
|
const auto message = *reinterpret_cast<const CodedSquelchMessage*>(p);
|
|
|
|
this->handle_coded_squelch(message.value);
|
|
|
|
}};
|
|
|
|
|
|
|
|
MessageHandlerRegistration message_handler_stats{
|
|
|
|
Message::ID::ChannelStatistics,
|
|
|
|
[this](const Message* const p) {
|
|
|
|
this->on_statistics_update(static_cast<const ChannelStatisticsMessage*>(p)->statistics);
|
|
|
|
}};
|
|
|
|
};
|
2023-03-10 08:25:38 -05:00
|
|
|
|
|
|
|
} /* namespace ui */
|
|
|
|
|
|
|
|
#endif
|