mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-09-13 18:19:33 +00:00
Compare commits
47 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fcb681f4ae | |||
| 8530fa8194 | |||
| 89e8956df1 | |||
| 82ba35c162 | |||
| d750afe38f | |||
| 9b665a43c5 | |||
| 80c769b97d | |||
| 44dd8fd083 | |||
| 4e128e8930 | |||
| c2279e297c | |||
| cdd524b9f3 | |||
| 99809c7919 | |||
| 2390d79111 | |||
| 3b41d73ddd | |||
| 3d46c28911 | |||
| ca7840557b | |||
| ceaa115025 | |||
| 8dbcefbc75 | |||
| b28b96fb4a | |||
| e15a8ed2d8 | |||
| 19b77bf03b | |||
| 7b1541d2e8 | |||
| 830fea63ed | |||
| 3d59de55f8 | |||
| 5c1f5a7d2e | |||
| 4e985420d4 | |||
| 3e584a9652 | |||
| 39acaf846a | |||
| 76948cffa8 | |||
| 4ea8abb53b | |||
| 32085f317b | |||
| faa4367295 | |||
| 3f8a4957af | |||
| b5ea81cf96 | |||
| e14fa5eab0 | |||
| 960ecf616c | |||
| 996ccb0e40 | |||
| 407fee23b9 | |||
| 199570d4a5 | |||
| 5cd9c377d2 | |||
| e08273b8b8 | |||
| 6b0f90c321 | |||
| 0dea488e98 | |||
| e60c4dc34b | |||
| 0c75713820 | |||
| 6a28987a36 | |||
| 7331979107 |
@@ -1 +1 @@
|
||||
v1.7.1
|
||||
v1.7.2
|
||||
|
||||
@@ -1 +1 @@
|
||||
v1.7.2
|
||||
v1.7.3
|
||||
|
||||
@@ -287,7 +287,7 @@ set(CPPSRC
|
||||
apps/ert_app.cpp
|
||||
apps/lge_app.cpp
|
||||
apps/pocsag_app.cpp
|
||||
apps/replay_app.cpp
|
||||
# apps/replay_app.cpp
|
||||
apps/ui_playlist.cpp
|
||||
apps/gps_sim_app.cpp
|
||||
apps/soundboard_app.cpp
|
||||
|
||||
@@ -114,6 +114,8 @@ ResultCode load_settings(const std::string& app_name, AppSettings& settings) {
|
||||
|
||||
if (flags_enabled(settings.mode, Mode::RX)) {
|
||||
read_setting(*data, setting::rx_frequency, settings.rx_frequency);
|
||||
read_setting(*data, setting::lna, settings.lna);
|
||||
read_setting(*data, setting::vga, settings.vga);
|
||||
read_setting(*data, setting::rx_amp, settings.rx_amp);
|
||||
read_setting(*data, setting::modulation, settings.modulation);
|
||||
read_setting(*data, setting::am_config_index, settings.am_config_index);
|
||||
@@ -124,8 +126,6 @@ ResultCode load_settings(const std::string& app_name, AppSettings& settings) {
|
||||
|
||||
read_setting(*data, setting::baseband_bandwidth, settings.baseband_bandwidth);
|
||||
read_setting(*data, setting::sampling_rate, settings.sampling_rate);
|
||||
read_setting(*data, setting::lna, settings.lna);
|
||||
read_setting(*data, setting::vga, settings.vga);
|
||||
read_setting(*data, setting::step, settings.step);
|
||||
read_setting(*data, setting::volume, settings.volume);
|
||||
|
||||
@@ -153,6 +153,8 @@ ResultCode save_settings(const std::string& app_name, AppSettings& settings) {
|
||||
|
||||
if (flags_enabled(settings.mode, Mode::RX)) {
|
||||
write_setting(settings_file, setting::rx_frequency, settings.rx_frequency);
|
||||
write_setting(settings_file, setting::lna, settings.lna);
|
||||
write_setting(settings_file, setting::vga, settings.vga);
|
||||
write_setting(settings_file, setting::rx_amp, settings.rx_amp);
|
||||
write_setting(settings_file, setting::modulation, settings.modulation);
|
||||
write_setting(settings_file, setting::am_config_index, settings.am_config_index);
|
||||
@@ -163,8 +165,6 @@ ResultCode save_settings(const std::string& app_name, AppSettings& settings) {
|
||||
|
||||
write_setting(settings_file, setting::baseband_bandwidth, settings.baseband_bandwidth);
|
||||
write_setting(settings_file, setting::sampling_rate, settings.sampling_rate);
|
||||
write_setting(settings_file, setting::lna, settings.lna);
|
||||
write_setting(settings_file, setting::vga, settings.vga);
|
||||
write_setting(settings_file, setting::step, settings.step);
|
||||
write_setting(settings_file, setting::volume, settings.volume);
|
||||
|
||||
@@ -173,6 +173,7 @@ ResultCode save_settings(const std::string& app_name, AppSettings& settings) {
|
||||
|
||||
void copy_to_radio_model(const AppSettings& settings) {
|
||||
// NB: Don't actually adjust the radio here or it will hang.
|
||||
// Specifically 'modulation' which requires a running baseband.
|
||||
|
||||
if (flags_enabled(settings.mode, Mode::TX)) {
|
||||
if (!flags_enabled(settings.options, Options::UseGlobalTargetFrequency))
|
||||
@@ -203,14 +204,10 @@ void copy_from_radio_model(AppSettings& settings) {
|
||||
if (flags_enabled(settings.mode, Mode::TX)) {
|
||||
settings.tx_frequency = transmitter_model.target_frequency();
|
||||
settings.baseband_bandwidth = transmitter_model.baseband_bandwidth();
|
||||
settings.sampling_rate = transmitter_model.sampling_rate();
|
||||
settings.tx_amp = transmitter_model.rf_amp();
|
||||
settings.tx_gain = transmitter_model.tx_gain();
|
||||
settings.channel_bandwidth = transmitter_model.channel_bandwidth();
|
||||
|
||||
// TODO: Do these make sense for TX?
|
||||
settings.sampling_rate = transmitter_model.sampling_rate();
|
||||
settings.lna = transmitter_model.lna();
|
||||
settings.vga = transmitter_model.vga();
|
||||
}
|
||||
|
||||
if (flags_enabled(settings.mode, Mode::RX)) {
|
||||
|
||||
@@ -31,8 +31,6 @@
|
||||
#include "string_format.hpp"
|
||||
#include "utility.hpp"
|
||||
|
||||
#include "debug.hpp"
|
||||
|
||||
using namespace portapack;
|
||||
using namespace tonekey;
|
||||
|
||||
@@ -135,8 +133,7 @@ SPECOptionsView::SPECOptionsView(
|
||||
AnalogAudioView::AnalogAudioView(
|
||||
NavigationView& nav)
|
||||
: nav_(nav) {
|
||||
// A baseband image _must_ be running before
|
||||
// interacting with the waterfall view.
|
||||
// A baseband image _must_ be running before add waterfall view.
|
||||
baseband::run_image(portapack::spi_flash::image_tag_wideband_spectrum);
|
||||
|
||||
add_children({&rssi,
|
||||
@@ -194,6 +191,15 @@ AnalogAudioView::AnalogAudioView(
|
||||
on_modulation_changed(modulation);
|
||||
}
|
||||
|
||||
AnalogAudioView::AnalogAudioView(
|
||||
NavigationView& nav,
|
||||
ReceiverModel::settings_t override)
|
||||
: AnalogAudioView(nav) {
|
||||
// TODO: Which other settings make sense to override?
|
||||
on_frequency_step_changed(override.frequency_step);
|
||||
options_modulation.set_by_value(toUType(override.mode));
|
||||
}
|
||||
|
||||
size_t AnalogAudioView::get_spec_bw_index() {
|
||||
return spec_bw_index;
|
||||
}
|
||||
@@ -404,24 +410,7 @@ void AnalogAudioView::update_modulation(ReceiverModel::Mode modulation) {
|
||||
}
|
||||
|
||||
void AnalogAudioView::handle_coded_squelch(uint32_t value) {
|
||||
float diff, min_diff = value;
|
||||
size_t min_idx{0};
|
||||
size_t c;
|
||||
|
||||
// Find nearest match
|
||||
for (c = 0; c < tone_keys.size(); c++) {
|
||||
diff = abs(((float)value / 100.0) - tone_keys[c].second);
|
||||
if (diff < min_diff) {
|
||||
min_idx = c;
|
||||
min_diff = diff;
|
||||
}
|
||||
}
|
||||
|
||||
// Arbitrary confidence threshold
|
||||
if (min_diff < 40)
|
||||
text_ctcss.set("CTCSS " + tone_keys[min_idx].first);
|
||||
else
|
||||
text_ctcss.set("???");
|
||||
text_ctcss.set(tone_key_string_by_value(value, text_ctcss.parent_rect().width() / 8));
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
@@ -71,10 +71,10 @@ class NBFMOptionsView : public View {
|
||||
}};
|
||||
|
||||
Text text_squelch{
|
||||
{9 * 8, 0 * 16, 8 * 8, 1 * 16},
|
||||
{7 * 8, 0 * 16, 8 * 8, 1 * 16},
|
||||
"SQ /99"};
|
||||
NumberField field_squelch{
|
||||
{12 * 8, 0 * 16},
|
||||
{10 * 8, 0 * 16},
|
||||
2,
|
||||
{0, 99},
|
||||
1,
|
||||
@@ -138,6 +138,7 @@ class SPECOptionsView : public View {
|
||||
class AnalogAudioView : public View {
|
||||
public:
|
||||
AnalogAudioView(NavigationView& nav);
|
||||
AnalogAudioView(NavigationView& nav, ReceiverModel::settings_t override);
|
||||
~AnalogAudioView();
|
||||
|
||||
void set_parent_rect(Rect new_parent_rect) override;
|
||||
@@ -200,7 +201,7 @@ class AnalogAudioView : public View {
|
||||
{28 * 8, 0 * 16}};
|
||||
|
||||
Text text_ctcss{
|
||||
{19 * 8, 1 * 16, 11 * 8, 1 * 16},
|
||||
{16 * 8, 1 * 16, 14 * 8, 1 * 16},
|
||||
""};
|
||||
|
||||
std::unique_ptr<Widget> options_widget{};
|
||||
@@ -213,7 +214,7 @@ class AnalogAudioView : public View {
|
||||
4096,
|
||||
4};
|
||||
|
||||
spectrum::WaterfallWidget waterfall{true};
|
||||
spectrum::WaterfallView waterfall{true};
|
||||
|
||||
void on_baseband_bandwidth_changed(uint32_t bandwidth_hz);
|
||||
void on_modulation_changed(ReceiverModel::Mode modulation);
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace ui {
|
||||
|
||||
CaptureAppView::CaptureAppView(NavigationView& nav)
|
||||
: nav_{nav} {
|
||||
freqman_set_bandwidth_option(SPEC_MODULATION, option_bandwidth);
|
||||
baseband::run_image(portapack::spi_flash::image_tag_capture);
|
||||
|
||||
add_children({
|
||||
@@ -59,41 +60,8 @@ CaptureAppView::CaptureAppView(NavigationView& nav)
|
||||
/* ex. recording 500kHz BW to .C16 file, base_rate clock 500kHz x2(I,Q) x 2 bytes (int signed) =2MB/sec rate SD Card */
|
||||
waterfall.on_hide();
|
||||
|
||||
/* Set up proper anti aliasing BPF bandwith in MAX2837 before ADC sampling according to the new added BW Options . */
|
||||
switch (sampling_rate) { // we use the var fs (sampling_rate) , to set up BPF aprox < fs_max/2 by Nyquist theorem.
|
||||
|
||||
case 0 ... 2000000: // BW Captured range (0 <= 250kHz max ) fs = 8 x 250 kHz
|
||||
anti_alias_baseband_bandwidth_filter = 1750000; // Minimum BPF MAX2837 for all those lower BW options.
|
||||
break;
|
||||
|
||||
case 4000000 ... 6000000: // BW capture range (500k ... 750kHz max ) fs_max = 8 x 750kHz = 6Mhz
|
||||
// BW 500k ... 750kHz , ex. 500kHz (fs = 8*BW = 4Mhz) , BW 600kHz (fs = 4,8Mhz) , BW 750 kHz (fs = 6Mhz)
|
||||
anti_alias_baseband_bandwidth_filter = 2500000; // in some IC MAX2837 appear 2250000 , but both works similar.
|
||||
break;
|
||||
|
||||
case 8800000: // BW capture 1,1Mhz fs = 8 x 1,1Mhz = 8,8Mhz . (1Mhz showed slightly higher noise background).
|
||||
anti_alias_baseband_bandwidth_filter = 3500000;
|
||||
break;
|
||||
|
||||
case 14000000: // BW capture 1,75Mhz , fs = 8 x 1,75Mhz = 14Mhz
|
||||
// good BPF, good matching, but LCD making flicker , refresh rate should be < 20 Hz , but reasonable picture
|
||||
anti_alias_baseband_bandwidth_filter = 5000000;
|
||||
break;
|
||||
|
||||
case 16000000: // BW capture 2Mhz , fs = 8 x 2Mhz = 16Mhz
|
||||
// good BPF, good matching, but LCD making flicker , refresh rate should be < 20 Hz , but reasonable picture
|
||||
anti_alias_baseband_bandwidth_filter = 6000000;
|
||||
break;
|
||||
|
||||
case 20000000: // BW capture 2,5Mhz , fs= 8 x 2,5 Mhz = 20Mhz
|
||||
// good BPF, good matching, but LCD making flicker , refresh rate should be < 20 Hz , but reasonable picture
|
||||
anti_alias_baseband_bandwidth_filter = 7000000;
|
||||
break;
|
||||
|
||||
default: // BW capture 2,75Mhz, fs = 8 x 2,75Mhz= 22Mhz max ADC sampling) and others.
|
||||
// We tested also 9Mhz FPB stightly too much noise floor, better 8Mhz
|
||||
anti_alias_baseband_bandwidth_filter = 8000000;
|
||||
}
|
||||
/* Set up proper anti aliasing BPF bandwith in MAX2837 before ADC sampling according to the new added BW Options. */
|
||||
auto anti_alias_baseband_bandwidth_filter = filter_bandwidth_for_sampling_rate(sampling_rate);
|
||||
|
||||
record_view.set_sampling_rate(sampling_rate);
|
||||
receiver_model.set_sampling_rate(sampling_rate);
|
||||
@@ -103,8 +71,6 @@ CaptureAppView::CaptureAppView(NavigationView& nav)
|
||||
};
|
||||
|
||||
option_bandwidth.set_selected_index(7); // Preselected default option 500kHz.
|
||||
|
||||
receiver_model.set_modulation(ReceiverModel::Mode::Capture);
|
||||
receiver_model.enable();
|
||||
|
||||
record_view.on_error = [&nav](std::string message) {
|
||||
@@ -113,8 +79,6 @@ CaptureAppView::CaptureAppView(NavigationView& nav)
|
||||
}
|
||||
|
||||
CaptureAppView::~CaptureAppView() {
|
||||
// Most other apps can't handle "Capture" mode, set to something standard.
|
||||
receiver_model.set_modulation(ReceiverModel::Mode::WidebandFMAudio);
|
||||
receiver_model.disable();
|
||||
baseband::shutdown();
|
||||
}
|
||||
|
||||
@@ -31,23 +31,7 @@
|
||||
#include "ui_spectrum.hpp"
|
||||
#include "app_settings.hpp"
|
||||
#include "radio_state.hpp"
|
||||
|
||||
#define BW_OPTIONS \
|
||||
{" 8k5", 8500}, \
|
||||
{" 11k", 11000}, \
|
||||
{" 16k", 16000}, \
|
||||
{" 25k", 25000}, \
|
||||
{" 50k", 50000}, \
|
||||
{" 100k", 100000}, \
|
||||
{" 250k", 250000}, \
|
||||
{" 500k", 500000}, /* Previous Limit bandwith Option with perfect micro SD write .C16 format operaton.*/ \
|
||||
{" 600k", 600000}, /* That extended option is still possible to record with FW version Mayhem v1.41 (< 2,5MB/sec) */ \
|
||||
{" 750k", 750000}, /* From this BW onwards, the LCD is ok, but the recorded file is decimated, (not real file size) */ \
|
||||
{"1100k", 1100000}, \
|
||||
{"1750k", 1750000}, \
|
||||
{"2000k", 2000000}, \
|
||||
{"2500k", 2500000}, \
|
||||
{"2750k", 2750000}, // That is our max Capture option, to keep using later / 8 decimation (22Mhz sampling ADC)
|
||||
#include "freqman.hpp"
|
||||
|
||||
namespace ui {
|
||||
|
||||
@@ -66,13 +50,12 @@ class CaptureAppView : public View {
|
||||
static constexpr ui::Dim header_height = 3 * 16;
|
||||
|
||||
NavigationView& nav_;
|
||||
RxRadioState radio_state_{};
|
||||
RxRadioState radio_state_{ReceiverModel::Mode::Capture};
|
||||
app_settings::SettingsManager settings_{
|
||||
"rx_capture", app_settings::Mode::RX,
|
||||
app_settings::Options::UseGlobalTargetFrequency};
|
||||
|
||||
uint32_t sampling_rate = 0;
|
||||
uint32_t anti_alias_baseband_bandwidth_filter = 2500000;
|
||||
|
||||
Labels labels{
|
||||
{{0 * 8, 1 * 16}, "Rate:", Color::light_grey()},
|
||||
@@ -103,7 +86,7 @@ class CaptureAppView : public View {
|
||||
OptionsField option_bandwidth{
|
||||
{5 * 8, 1 * 16},
|
||||
5,
|
||||
{BW_OPTIONS}};
|
||||
{}};
|
||||
|
||||
RecordView record_view{
|
||||
{0 * 8, 2 * 16, 30 * 8, 1 * 16},
|
||||
@@ -113,7 +96,7 @@ class CaptureAppView : public View {
|
||||
16384,
|
||||
3};
|
||||
|
||||
spectrum::WaterfallWidget waterfall{};
|
||||
spectrum::WaterfallView waterfall{};
|
||||
};
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
@@ -130,8 +130,7 @@ class ERTAppView : public View {
|
||||
|
||||
RxRadioState radio_state_{
|
||||
2500000 /* bandwidth */,
|
||||
4194304 /* sampling rate */
|
||||
};
|
||||
4194304 /* sampling rate */};
|
||||
app_settings::SettingsManager settings_{
|
||||
"rx_ert", app_settings::Mode::RX};
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ class GpsSimAppView : public View {
|
||||
Color::green(),
|
||||
Color::black()};
|
||||
|
||||
spectrum::WaterfallWidget waterfall{};
|
||||
spectrum::WaterfallView waterfall{};
|
||||
|
||||
MessageHandlerRegistration message_handler_replay_thread_error{
|
||||
Message::ID::ReplayThreadDone,
|
||||
|
||||
@@ -71,7 +71,6 @@ POCSAGAppView::POCSAGAppView(NavigationView& nav)
|
||||
if (!settings_.loaded())
|
||||
field_frequency.set_value(initial_target_frequency);
|
||||
|
||||
receiver_model.set_modulation(ReceiverModel::Mode::NarrowbandFMAudio);
|
||||
receiver_model.enable();
|
||||
|
||||
// TODO: app setting instead?
|
||||
|
||||
@@ -121,7 +121,7 @@ class ReplayAppView : public View {
|
||||
Color::green(),
|
||||
Color::black()};
|
||||
|
||||
spectrum::WaterfallWidget waterfall{};
|
||||
spectrum::WaterfallView waterfall{};
|
||||
|
||||
MessageHandlerRegistration message_handler_replay_thread_error{
|
||||
Message::ID::ReplayThreadDone,
|
||||
|
||||
@@ -32,7 +32,7 @@ class SpectrumAnalysisModel {
|
||||
|
||||
namespace ui {
|
||||
|
||||
class SpectrumAnalysisView : public spectrum::WaterfallWidget {
|
||||
class SpectrumAnalysisView : public spectrum::WaterfallView {
|
||||
public:
|
||||
private:
|
||||
SpectrumAnalysisModel model;
|
||||
|
||||
@@ -106,8 +106,7 @@ class TPMSAppView : public View {
|
||||
|
||||
RxRadioState radio_state_{
|
||||
1750000 /* bandwidth */,
|
||||
2457600 /* sampling rate */
|
||||
};
|
||||
2457600 /* sampling rate */};
|
||||
app_settings::SettingsManager settings_{
|
||||
"rx_tpms", app_settings::Mode::RX};
|
||||
|
||||
|
||||
@@ -513,8 +513,7 @@ ADSBRxView::ADSBRxView(NavigationView& nav) {
|
||||
|
||||
baseband::set_adsb();
|
||||
|
||||
receiver_model.set_target_frequency(1090000000);
|
||||
receiver_model.set_modulation(ReceiverModel::Mode::SpectrumAnalysis);
|
||||
receiver_model.set_target_frequency(1'090'000'000);
|
||||
receiver_model.enable();
|
||||
}
|
||||
|
||||
|
||||
@@ -343,8 +343,8 @@ class ADSBRxView : public View {
|
||||
private:
|
||||
RxRadioState radio_state_{
|
||||
2500000 /* bandwidth */,
|
||||
2000000 /* sampling rate */
|
||||
};
|
||||
2000000 /* sampling rate */,
|
||||
ReceiverModel::Mode::SpectrumAnalysis};
|
||||
app_settings::SettingsManager settings_{
|
||||
"rx_adsb", app_settings::Mode::RX};
|
||||
|
||||
|
||||
@@ -91,7 +91,6 @@ AFSKRxView::AFSKRxView(NavigationView& nav)
|
||||
audio::set_rate(audio::Rate::Hz_24000);
|
||||
audio::output::start();
|
||||
|
||||
receiver_model.set_modulation(ReceiverModel::Mode::NarrowbandFMAudio);
|
||||
receiver_model.enable();
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,6 @@ APRSRxView::APRSRxView(NavigationView& nav, Rect parent_rect)
|
||||
audio::set_rate(audio::Rate::Hz_24000);
|
||||
audio::output::start();
|
||||
|
||||
receiver_model.set_modulation(ReceiverModel::Mode::NarrowbandFMAudio);
|
||||
receiver_model.enable();
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,6 @@ BTLERxView::BTLERxView(NavigationView& nav)
|
||||
audio::set_rate(audio::Rate::Hz_24000);
|
||||
audio::output::start();
|
||||
|
||||
receiver_model.set_modulation(ReceiverModel::Mode::WidebandFMAudio);
|
||||
receiver_model.enable();
|
||||
}
|
||||
|
||||
|
||||
@@ -51,8 +51,8 @@ class BTLERxView : public View {
|
||||
NavigationView& nav_;
|
||||
RxRadioState radio_state_{
|
||||
4000000 /* bandwidth */,
|
||||
4000000 /* sampling rate */
|
||||
};
|
||||
4000000 /* sampling rate */,
|
||||
ReceiverModel::Mode::WidebandFMAudio};
|
||||
app_settings::SettingsManager settings_{
|
||||
"rx_btle", app_settings::Mode::RX};
|
||||
|
||||
|
||||
@@ -248,6 +248,7 @@ void ControlsSwitchesWidget::on_show() {
|
||||
|
||||
bool ControlsSwitchesWidget::on_key(const KeyEvent key) {
|
||||
key_event_mask = 1 << toUType(key);
|
||||
long_press_key_event_mask = switch_long_press_occurred((size_t)key) ? key_event_mask : 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -325,6 +326,14 @@ void ControlsSwitchesWidget::paint(Painter& painter) {
|
||||
|
||||
switches_event >>= 1;
|
||||
}
|
||||
|
||||
switches_event = long_press_key_event_mask;
|
||||
for (const auto r : events_rects) {
|
||||
if (switches_event & 1)
|
||||
painter.fill_rectangle(r + pos, Color::cyan());
|
||||
|
||||
switches_event >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
void ControlsSwitchesWidget::on_frame_sync() {
|
||||
@@ -335,12 +344,21 @@ void ControlsSwitchesWidget::on_frame_sync() {
|
||||
|
||||
DebugControlsView::DebugControlsView(NavigationView& nav) {
|
||||
add_children({
|
||||
&text_title,
|
||||
&labels,
|
||||
&switches_widget,
|
||||
&options_switches_mode,
|
||||
&button_done,
|
||||
});
|
||||
|
||||
button_done.on_select = [&nav](Button&) { nav.pop(); };
|
||||
button_done.on_select = [&nav](Button&) {
|
||||
switches_long_press_enable(0);
|
||||
nav.pop();
|
||||
};
|
||||
|
||||
options_switches_mode.on_change = [this](size_t, OptionsField::value_t v) {
|
||||
(void)v;
|
||||
switches_long_press_enable(options_switches_mode.selected_index_value());
|
||||
};
|
||||
}
|
||||
|
||||
void DebugControlsView::focus() {
|
||||
@@ -383,6 +401,7 @@ DebugMenuView::DebugMenuView(NavigationView& nav) {
|
||||
{"Temperature", ui::Color::dark_cyan(), &bitmap_icon_temperature, [&nav]() { nav.push<TemperatureView>(); }},
|
||||
{"Buttons Test", ui::Color::dark_cyan(), &bitmap_icon_controls, [&nav]() { nav.push<DebugControlsView>(); }},
|
||||
{"P.Memory", ui::Color::dark_cyan(), &bitmap_icon_memory, [&nav]() { nav.push<DebugPmemView>(); }},
|
||||
{"Debug Dump", ui::Color::dark_cyan(), &bitmap_icon_memory, [&nav]() { portapack::persistent_memory::debug_dump(); }},
|
||||
});
|
||||
set_max_rows(2); // allow wider buttons
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "rffc507x.hpp"
|
||||
#include "portapack.hpp"
|
||||
#include "memory_map.hpp"
|
||||
#include "irq_controls.hpp"
|
||||
|
||||
#include <functional>
|
||||
#include <utility>
|
||||
@@ -220,7 +221,8 @@ class ControlsSwitchesWidget : public Widget {
|
||||
ControlsSwitchesWidget(
|
||||
Rect parent_rect)
|
||||
: Widget{parent_rect},
|
||||
key_event_mask(0) {
|
||||
key_event_mask(0),
|
||||
long_press_key_event_mask{0} {
|
||||
set_focusable(true);
|
||||
}
|
||||
|
||||
@@ -231,6 +233,7 @@ class ControlsSwitchesWidget : public Widget {
|
||||
|
||||
private:
|
||||
uint8_t key_event_mask;
|
||||
uint8_t long_press_key_event_mask;
|
||||
|
||||
MessageHandlerRegistration message_handler_frame_sync{
|
||||
Message::ID::DisplayFrameSync,
|
||||
@@ -250,15 +253,22 @@ class DebugControlsView : public View {
|
||||
std::string title() const override { return "Buttons Test"; };
|
||||
|
||||
private:
|
||||
Text text_title{
|
||||
{64, 16, 184, 16},
|
||||
"Controls State",
|
||||
};
|
||||
Labels labels{
|
||||
{{8 * 8, 1 * 16}, "Controls State", Color::white()},
|
||||
{{0 * 8, 14 * 16}, "Long-Press Mode:", Color::grey()}};
|
||||
|
||||
ControlsSwitchesWidget switches_widget{
|
||||
{80, 80, 80, 112},
|
||||
};
|
||||
|
||||
OptionsField options_switches_mode{
|
||||
{17 * 8, 14 * 16},
|
||||
8,
|
||||
{
|
||||
{"Disabled", 0},
|
||||
{"Enabled", 0xFF}, // all KeyEvent bits to long-press mode
|
||||
}};
|
||||
|
||||
Button button_done{
|
||||
{72, 264, 96, 24},
|
||||
"Done"};
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "ui_dfu_menu.hpp"
|
||||
#include "portapack_shared_memory.hpp"
|
||||
#include "performance_counter.hpp"
|
||||
#include "portapack.hpp"
|
||||
|
||||
namespace ui {
|
||||
|
||||
@@ -80,4 +81,57 @@ void DfuMenu::paint(Painter& painter) {
|
||||
ui::Color::dark_cyan());
|
||||
}
|
||||
|
||||
DfuMenu2::DfuMenu2(NavigationView& nav)
|
||||
: nav_(nav) {
|
||||
add_children({&text_head,
|
||||
&labels,
|
||||
&text_info_line_1,
|
||||
&text_info_line_2,
|
||||
&text_info_line_3,
|
||||
&text_info_line_4,
|
||||
&text_info_line_5,
|
||||
&text_info_line_6,
|
||||
&text_info_line_7,
|
||||
&text_info_line_8});
|
||||
}
|
||||
|
||||
void DfuMenu2::paint(Painter& painter) {
|
||||
text_info_line_1.set(to_string_dec_uint(portapack::receiver_model.target_frequency(), 10));
|
||||
text_info_line_2.set(to_string_dec_uint(portapack::receiver_model.baseband_bandwidth(), 10));
|
||||
text_info_line_3.set(to_string_dec_uint(portapack::receiver_model.sampling_rate(), 10));
|
||||
text_info_line_4.set(to_string_dec_uint((uint32_t)portapack::receiver_model.modulation(), 10));
|
||||
text_info_line_5.set(to_string_dec_uint(portapack::receiver_model.am_configuration(), 10));
|
||||
text_info_line_6.set(to_string_dec_uint(portapack::receiver_model.nbfm_configuration(), 10));
|
||||
text_info_line_7.set(to_string_dec_uint(portapack::receiver_model.wfm_configuration(), 10));
|
||||
text_info_line_8.set("");
|
||||
|
||||
constexpr auto margin = 5;
|
||||
constexpr auto lines = 8 + 2;
|
||||
|
||||
painter.fill_rectangle(
|
||||
{{5 * CHARACTER_WIDTH - margin, 3 * LINE_HEIGHT - margin},
|
||||
{19 * CHARACTER_WIDTH + margin * 2, lines * LINE_HEIGHT + margin * 2}},
|
||||
ui::Color::black());
|
||||
|
||||
painter.fill_rectangle(
|
||||
{{4 * CHARACTER_WIDTH - margin, 3 * LINE_HEIGHT - margin},
|
||||
{CHARACTER_WIDTH, lines * LINE_HEIGHT + margin * 2}},
|
||||
ui::Color::dark_cyan());
|
||||
|
||||
painter.fill_rectangle(
|
||||
{{24 * CHARACTER_WIDTH + margin, 3 * LINE_HEIGHT - margin},
|
||||
{CHARACTER_WIDTH, lines * LINE_HEIGHT + margin * 2}},
|
||||
ui::Color::dark_cyan());
|
||||
|
||||
painter.fill_rectangle(
|
||||
{{4 * CHARACTER_WIDTH - margin, 3 * LINE_HEIGHT - margin - 8},
|
||||
{21 * CHARACTER_WIDTH + margin * 2, 8}},
|
||||
ui::Color::dark_cyan());
|
||||
|
||||
painter.fill_rectangle(
|
||||
{{4 * CHARACTER_WIDTH - margin, (lines + 3) * LINE_HEIGHT + margin},
|
||||
{21 * CHARACTER_WIDTH + margin * 2, 8}},
|
||||
ui::Color::dark_cyan());
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
@@ -67,6 +67,38 @@ class DfuMenu : public View {
|
||||
Text text_info_line_8{{15 * CHARACTER_WIDTH, 12 * LINE_HEIGHT, 5 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""};
|
||||
};
|
||||
|
||||
class DfuMenu2 : public View {
|
||||
public:
|
||||
DfuMenu2(NavigationView& nav);
|
||||
~DfuMenu2() = default;
|
||||
|
||||
void paint(Painter& painter) override;
|
||||
|
||||
private:
|
||||
NavigationView& nav_;
|
||||
|
||||
Text text_head{{6 * CHARACTER_WIDTH, 3 * LINE_HEIGHT, 8 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, "Receiver"};
|
||||
|
||||
Labels labels{
|
||||
{{5 * CHARACTER_WIDTH, 5 * LINE_HEIGHT}, "Tgt freq:", Color::dark_cyan()},
|
||||
{{5 * CHARACTER_WIDTH, 6 * LINE_HEIGHT}, "Bandwidt:", Color::dark_cyan()},
|
||||
{{5 * CHARACTER_WIDTH, 7 * LINE_HEIGHT}, "Sampl Rt:", Color::dark_cyan()},
|
||||
{{5 * CHARACTER_WIDTH, 8 * LINE_HEIGHT}, "Modulatn:", Color::dark_cyan()},
|
||||
{{5 * CHARACTER_WIDTH, 9 * LINE_HEIGHT}, "AM cfg:", Color::dark_cyan()},
|
||||
{{5 * CHARACTER_WIDTH, 10 * LINE_HEIGHT}, "NBFM cfg:", Color::dark_cyan()},
|
||||
{{5 * CHARACTER_WIDTH, 11 * LINE_HEIGHT}, "WFM cfg:", Color::dark_cyan()},
|
||||
{{5 * CHARACTER_WIDTH, 12 * LINE_HEIGHT}, "", Color::dark_cyan()}};
|
||||
|
||||
Text text_info_line_1{{14 * CHARACTER_WIDTH, 5 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""};
|
||||
Text text_info_line_2{{14 * CHARACTER_WIDTH, 6 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""};
|
||||
Text text_info_line_3{{14 * CHARACTER_WIDTH, 7 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""};
|
||||
Text text_info_line_4{{14 * CHARACTER_WIDTH, 8 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""};
|
||||
Text text_info_line_5{{14 * CHARACTER_WIDTH, 9 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""};
|
||||
Text text_info_line_6{{14 * CHARACTER_WIDTH, 10 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""};
|
||||
Text text_info_line_7{{14 * CHARACTER_WIDTH, 11 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""};
|
||||
Text text_info_line_8{{14 * CHARACTER_WIDTH, 12 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""};
|
||||
};
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
#endif /*__UI_DFU_MENU_H__*/
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include "ui_fileman.hpp"
|
||||
#include "ui_playlist.hpp"
|
||||
#include "ui_ss_viewer.hpp"
|
||||
#include "ui_text_editor.hpp"
|
||||
#include "string_format.hpp"
|
||||
@@ -35,6 +36,14 @@
|
||||
using namespace portapack;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace ui {
|
||||
static const fs::path txt_ext{u".TXT"};
|
||||
static const fs::path ppl_ext{u".PPL"};
|
||||
static const fs::path c16_ext{u".C16"};
|
||||
static const fs::path png_ext{u".PNG"};
|
||||
static const fs::path bmp_ext{u".BMP"};
|
||||
} // namespace ui
|
||||
|
||||
namespace {
|
||||
using namespace ui;
|
||||
|
||||
@@ -47,25 +56,6 @@ std::string truncate(const fs::path& path, size_t max_length) {
|
||||
return ::truncate(path.string(), max_length);
|
||||
}
|
||||
|
||||
// Case insensitive path equality on underlying "native" string.
|
||||
bool iequal(
|
||||
const fs::path& lhs,
|
||||
const fs::path& rhs) {
|
||||
const auto& lhs_str = lhs.native();
|
||||
const auto& rhs_str = rhs.native();
|
||||
|
||||
// NB: Not correct for Unicode/locales.
|
||||
if (lhs_str.length() == rhs_str.length()) {
|
||||
for (size_t i = 0; i < lhs_str.length(); ++i)
|
||||
if (towupper(lhs_str[i]) != towupper(rhs_str[i]))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Inserts the entry into the entry list sorted directories first then by file name.
|
||||
void insert_sorted(std::vector<fileman_entry>& entries, fileman_entry&& entry) {
|
||||
auto it = std::lower_bound(
|
||||
@@ -86,15 +76,12 @@ void insert_sorted(std::vector<fileman_entry>& entries, fileman_entry&& entry) {
|
||||
fs::path get_partner_file(fs::path path) {
|
||||
if (fs::is_directory(path))
|
||||
return {};
|
||||
|
||||
const fs::path txt_path{u".TXT"};
|
||||
const fs::path c16_path{u".C16"};
|
||||
auto ext = path.extension();
|
||||
|
||||
if (iequal(ext, txt_path))
|
||||
ext = c16_path;
|
||||
else if (iequal(ext, c16_path))
|
||||
ext = txt_path;
|
||||
if (path_iequal(ext, txt_ext))
|
||||
ext = c16_ext;
|
||||
else if (path_iequal(ext, c16_ext))
|
||||
ext = txt_ext;
|
||||
else
|
||||
return {};
|
||||
|
||||
@@ -163,7 +150,7 @@ void FileManBaseView::load_directory_contents(const fs::path& dir_path) {
|
||||
continue;
|
||||
|
||||
if (fs::is_regular_file(entry.status())) {
|
||||
if (!filtering || iequal(entry.path().extension(), extension_filter))
|
||||
if (!filtering || path_iequal(entry.path().extension(), extension_filter))
|
||||
insert_sorted(entry_list, {entry.path(), (uint32_t)entry.size(), false});
|
||||
} else if (fs::is_directory(entry.status())) {
|
||||
insert_sorted(entry_list, {entry.path(), 0, true});
|
||||
@@ -301,7 +288,7 @@ const FileManBaseView::file_assoc_t& FileManBaseView::get_assoc(
|
||||
size_t index = 0;
|
||||
|
||||
for (; index < file_types.size() - 1; ++index)
|
||||
if (iequal(ext, file_types[index].extension))
|
||||
if (path_iequal(ext, file_types[index].extension))
|
||||
return file_types[index];
|
||||
|
||||
// Default to last entry in the list.
|
||||
@@ -507,12 +494,20 @@ bool FileManagerView::handle_file_open() {
|
||||
auto path = get_selected_full_path();
|
||||
auto ext = path.extension();
|
||||
|
||||
if (iequal(u".TXT", ext) || iequal(u".PPL", ext)) {
|
||||
if (path_iequal(txt_ext, ext)) {
|
||||
nav_.push<TextEditorView>(path);
|
||||
return true;
|
||||
} else if (iequal(u".PNG", ext)) {
|
||||
} else if (path_iequal(c16_ext, ext) || path_iequal(ppl_ext, ext)) {
|
||||
// TODO: Enough memory to push?
|
||||
nav_.push<PlaylistView>(path);
|
||||
return true;
|
||||
} else if (path_iequal(png_ext, ext)) {
|
||||
nav_.push<ScreenshotViewer>(path);
|
||||
return true;
|
||||
} else if (path_iequal(bmp_ext, ext)) {
|
||||
nav_.push<SplashViewer>(path);
|
||||
reload_current();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
|
||||
namespace ui {
|
||||
|
||||
static const char16_t* firmware_folder = u"/FIRMWARE";
|
||||
|
||||
Thread* FlashUtilityView::thread{nullptr};
|
||||
static constexpr size_t max_filename_length = 26;
|
||||
|
||||
@@ -35,7 +37,9 @@ FlashUtilityView::FlashUtilityView(NavigationView& nav)
|
||||
|
||||
menu_view.set_parent_rect({0, 3 * 8, 240, 33 * 8});
|
||||
|
||||
for (const auto& entry : std::filesystem::directory_iterator(u"FIRMWARE", u"*.bin")) {
|
||||
ensure_directory(firmware_folder);
|
||||
|
||||
for (const auto& entry : std::filesystem::directory_iterator(firmware_folder, u"*.bin")) {
|
||||
auto filename = entry.path().filename();
|
||||
auto path = entry.path().native();
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class FlashUtilityView : public View {
|
||||
|
||||
void focus() override;
|
||||
|
||||
std::string title() const override { return "FlashUtility"; }; // Removed the space because the title and speaker icon overlapped.
|
||||
std::string title() const override { return "Flash Utility"; };
|
||||
|
||||
private:
|
||||
NavigationView& nav_;
|
||||
|
||||
@@ -81,14 +81,11 @@ void FreqManBaseView::change_category(int32_t category_id) {
|
||||
|
||||
if (file_list.empty()) return;
|
||||
|
||||
std::vector<freqman_entry>().swap(database);
|
||||
|
||||
if (!load_freqman_file(file_list[categories[category_id].second], database)) {
|
||||
error_ = ERROR_ACCESS;
|
||||
}
|
||||
menu_view.set_db(database);
|
||||
freqlist_view.set_db(database);
|
||||
text_empty.hidden(!database.empty());
|
||||
menu_view.set_dirty();
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
@@ -162,10 +159,14 @@ FrequencySaveView::FrequencySaveView(
|
||||
};
|
||||
}
|
||||
|
||||
FrequencyLoadView::~FrequencyLoadView() {
|
||||
std::vector<freqman_entry>().swap(database);
|
||||
}
|
||||
|
||||
void FrequencyLoadView::refresh_widgets(const bool v) {
|
||||
menu_view.hidden(v);
|
||||
freqlist_view.hidden(v);
|
||||
text_empty.hidden(!v);
|
||||
// display.fill_rectangle(menu_view.screen_rect(), Color::black());
|
||||
// display.fill_rectangle(freqlist_view.screen_rect(), Color::black());
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
@@ -176,17 +177,14 @@ FrequencyLoadView::FrequencyLoadView(
|
||||
refresh_widgets(v);
|
||||
};
|
||||
|
||||
add_children({&menu_view,
|
||||
add_children({&freqlist_view,
|
||||
&text_empty});
|
||||
|
||||
// Resize menu view to fill screen
|
||||
menu_view.set_parent_rect({0, 3 * 8, 240, 30 * 8});
|
||||
|
||||
menu_view.on_select = [&nav, this](FreqManUIList&) {
|
||||
nav_.pop();
|
||||
|
||||
auto& entry = database[menu_view.get_index()];
|
||||
freqlist_view.set_parent_rect({0, 3 * 8, 240, 30 * 8});
|
||||
|
||||
freqlist_view.on_select = [&nav, this](FreqManUIList&) {
|
||||
auto& entry = database[freqlist_view.get_index()];
|
||||
if (entry.type == RANGE) {
|
||||
// User chose a frequency range entry
|
||||
if (on_range_loaded)
|
||||
@@ -199,18 +197,21 @@ FrequencyLoadView::FrequencyLoadView(
|
||||
if (on_frequency_loaded)
|
||||
on_frequency_loaded(entry.frequency_a);
|
||||
}
|
||||
// swap with empty vector to ensure memory is immediately released
|
||||
std::vector<freqman_entry>().swap(database);
|
||||
nav_.pop();
|
||||
};
|
||||
}
|
||||
|
||||
void FrequencyManagerView::on_edit_freq(rf::Frequency f) {
|
||||
database[menu_view.get_index()].frequency_a = f;
|
||||
database[freqlist_view.get_index()].frequency_a = f;
|
||||
save_freqman_file(file_list[categories[current_category_id].second], database);
|
||||
change_category(current_category_id);
|
||||
}
|
||||
|
||||
void FrequencyManagerView::on_edit_desc(NavigationView& nav) {
|
||||
text_prompt(nav, desc_buffer, 28, [this](std::string& buffer) {
|
||||
database[menu_view.get_index()].description = buffer;
|
||||
database[freqlist_view.get_index()].description = buffer;
|
||||
save_freqman_file(file_list[categories[current_category_id].second], database);
|
||||
change_category(current_category_id);
|
||||
});
|
||||
@@ -230,7 +231,7 @@ void FrequencyManagerView::on_delete() {
|
||||
delete_freqman_file(file_list[categories[current_category_id].second]);
|
||||
refresh_list();
|
||||
} else {
|
||||
database.erase(database.begin() + menu_view.get_index());
|
||||
database.erase(database.begin() + freqlist_view.get_index());
|
||||
save_freqman_file(file_list[categories[current_category_id].second], database);
|
||||
}
|
||||
change_category(current_category_id);
|
||||
@@ -241,10 +242,9 @@ void FrequencyManagerView::refresh_widgets(const bool v) {
|
||||
button_edit_desc.hidden(v);
|
||||
button_delete.hidden(v);
|
||||
text_empty.hidden(!v);
|
||||
menu_view.hidden(v);
|
||||
menu_view.set_dirty();
|
||||
freqlist_view.hidden(v);
|
||||
labels.hidden(v);
|
||||
// display.fill_rectangle(menu_view.screen_rect(), Color::black());
|
||||
// display.fill_rectangle(freqlist_view.screen_rect(), Color::black());
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
@@ -261,13 +261,13 @@ FrequencyManagerView::FrequencyManagerView(
|
||||
|
||||
add_children({&labels,
|
||||
&button_new_category,
|
||||
&menu_view,
|
||||
&freqlist_view,
|
||||
&text_empty,
|
||||
&button_edit_freq,
|
||||
&button_edit_desc,
|
||||
&button_delete});
|
||||
|
||||
menu_view.on_select = [this](FreqManUIList&) {
|
||||
freqlist_view.on_select = [this](FreqManUIList&) {
|
||||
button_edit_freq.focus();
|
||||
};
|
||||
|
||||
@@ -280,7 +280,7 @@ FrequencyManagerView::FrequencyManagerView(
|
||||
if (database.empty()) {
|
||||
database.push_back({0, 0, "", SINGLE});
|
||||
}
|
||||
auto new_view = nav.push<FrequencyKeypadView>(database[menu_view.get_index()].frequency_a);
|
||||
auto new_view = nav.push<FrequencyKeypadView>(database[freqlist_view.get_index()].frequency_a);
|
||||
new_view->on_changed = [this](rf::Frequency f) {
|
||||
on_edit_freq(f);
|
||||
};
|
||||
@@ -290,7 +290,7 @@ FrequencyManagerView::FrequencyManagerView(
|
||||
if (database.empty()) {
|
||||
database.push_back({0, 0, "", SINGLE});
|
||||
}
|
||||
desc_buffer = database[menu_view.get_index()].description;
|
||||
desc_buffer = database[freqlist_view.get_index()].description;
|
||||
on_edit_desc(nav);
|
||||
};
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ class FreqManBaseView : public View {
|
||||
14,
|
||||
{}};
|
||||
|
||||
FreqManUIList menu_view{
|
||||
FreqManUIList freqlist_view{
|
||||
{0, 3 * 8, 240, 23 * 8}};
|
||||
|
||||
Text text_empty{
|
||||
@@ -116,6 +116,7 @@ class FrequencyLoadView : public FreqManBaseView {
|
||||
std::function<void(rf::Frequency, rf::Frequency)> on_range_loaded{};
|
||||
|
||||
FrequencyLoadView(NavigationView& nav);
|
||||
~FrequencyLoadView();
|
||||
|
||||
std::string title() const override { return "Load freq."; };
|
||||
|
||||
|
||||
@@ -199,6 +199,16 @@ size_t LevelView::change_mode(freqman_index_t new_mod) {
|
||||
field_bw.on_change = [this](size_t, OptionsField::value_t n) { receiver_model.set_wfm_configuration(n); };
|
||||
text_ctcss.set(" ");
|
||||
break;
|
||||
case SPEC_MODULATION:
|
||||
freqman_set_bandwidth_option(new_mod, field_bw);
|
||||
baseband::run_image(portapack::spi_flash::image_tag_capture);
|
||||
receiver_model.set_modulation(ReceiverModel::Mode::Capture);
|
||||
field_bw.set_by_value(0);
|
||||
field_bw.on_change = [this](size_t, OptionsField::value_t sampling_rate) {
|
||||
auto anti_alias_baseband_bandwidth_filter = filter_bandwidth_for_sampling_rate(sampling_rate);
|
||||
receiver_model.set_sampling_rate(sampling_rate);
|
||||
receiver_model.set_baseband_bandwidth(anti_alias_baseband_bandwidth_filter);
|
||||
};
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -206,34 +216,10 @@ size_t LevelView::change_mode(freqman_index_t new_mod) {
|
||||
}
|
||||
|
||||
void LevelView::handle_coded_squelch(const uint32_t value) {
|
||||
static int32_t last_idx = -1;
|
||||
|
||||
float diff, min_diff = value;
|
||||
size_t min_idx{0};
|
||||
size_t c;
|
||||
|
||||
if (field_mode.selected_index() != NFM_MODULATION) {
|
||||
text_ctcss.set(" ");
|
||||
return;
|
||||
}
|
||||
|
||||
// Find nearest match
|
||||
for (c = 0; c < tone_keys.size(); c++) {
|
||||
diff = abs(((float)value / 100.0) - tone_keys[c].second);
|
||||
if (diff < min_diff) {
|
||||
min_idx = c;
|
||||
min_diff = diff;
|
||||
}
|
||||
}
|
||||
|
||||
// Arbitrary confidence threshold
|
||||
if (last_idx < 0 || (unsigned)last_idx != min_idx) {
|
||||
last_idx = min_idx;
|
||||
if (min_diff < 40)
|
||||
text_ctcss.set("T: " + tone_keys[min_idx].first);
|
||||
else
|
||||
text_ctcss.set(" ");
|
||||
}
|
||||
if (field_mode.selected_index() == NFM_MODULATION)
|
||||
text_ctcss.set(tone_key_string_by_value(value, text_ctcss.parent_rect().width() / 8));
|
||||
else
|
||||
text_ctcss.set(" ");
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
@@ -91,7 +91,7 @@ class LevelView : public View {
|
||||
|
||||
OptionsField field_mode{
|
||||
{15 * 8, 1 * 16},
|
||||
3,
|
||||
4,
|
||||
{}};
|
||||
|
||||
OptionsField step_mode{
|
||||
@@ -114,7 +114,7 @@ class LevelView : public View {
|
||||
}};
|
||||
|
||||
Text text_ctcss{
|
||||
{22 * 8, 3 * 16 + 4, 14 * 8, 1 * 8},
|
||||
{22 * 8, 3 * 16 + 4, 8 * 8, 1 * 8},
|
||||
""};
|
||||
|
||||
// RSSI: XX/XX/XXX,dt: XX
|
||||
|
||||
@@ -471,9 +471,9 @@ GlassView::GlassView(
|
||||
|
||||
button_marker.on_select = [this](ButtonWithEncoder&) {
|
||||
receiver_model.set_target_frequency(marker); // Center tune rx in marker freq.
|
||||
receiver_model.set_frequency_step(MHZ_DIV); // Preset a 1 MHz frequency step into RX -> AUDIO
|
||||
nav_.pop();
|
||||
nav_.push<AnalogAudioView>(); // Jump into audio view
|
||||
auto settings = receiver_model.settings();
|
||||
settings.frequency_step = MHZ_DIV; // Preset a 1 MHz frequency step into RX -> AUDIO
|
||||
nav_.replace<AnalogAudioView>(settings); // Jump into audio view
|
||||
};
|
||||
|
||||
field_trigger.on_change = [this](int32_t v) {
|
||||
@@ -495,9 +495,9 @@ GlassView::GlassView(
|
||||
|
||||
button_jump.on_select = [this](Button&) {
|
||||
receiver_model.set_target_frequency(max_freq_hold); // Center tune rx in marker freq.
|
||||
receiver_model.set_frequency_step(MHZ_DIV); // Preset a 1 MHz frequency step into RX -> AUDIO
|
||||
nav_.pop();
|
||||
nav_.push<AnalogAudioView>(); // Jump into audio view
|
||||
auto settings = receiver_model.settings();
|
||||
settings.frequency_step = MHZ_DIV; // Preset a 1 MHz frequency step into RX -> AUDIO
|
||||
nav_.replace<AnalogAudioView>(settings); // Jump into audio view
|
||||
};
|
||||
|
||||
button_rst.on_select = [this](Button&) {
|
||||
@@ -513,7 +513,6 @@ GlassView::GlassView(
|
||||
marker_pixel_index = 120;
|
||||
on_range_changed();
|
||||
|
||||
receiver_model.set_modulation(ReceiverModel::Mode::SpectrumAnalysis);
|
||||
receiver_model.set_sampling_rate(looking_glass_sampling_rate); // 20mhz
|
||||
receiver_model.set_baseband_bandwidth(looking_glass_bandwidth); // possible values: 1.75/2.5/3.5/5/5.5/6/7/8/9/10/12/14/15/20/24/28MHz
|
||||
receiver_model.set_squelch_level(0);
|
||||
|
||||
@@ -63,7 +63,7 @@ class GlassView : public View {
|
||||
GlassView& operator=(const GlassView& nav);
|
||||
|
||||
~GlassView();
|
||||
std::string title() const override { return "LookingGlass"; };
|
||||
std::string title() const override { return "Looking Glass"; };
|
||||
|
||||
void on_show() override;
|
||||
void on_hide() override;
|
||||
@@ -71,7 +71,7 @@ class GlassView : public View {
|
||||
|
||||
private:
|
||||
NavigationView& nav_;
|
||||
RxRadioState radio_state_{};
|
||||
RxRadioState radio_state_{ReceiverModel::Mode::SpectrumAnalysis};
|
||||
app_settings::SettingsManager settings_{
|
||||
"rx_glass", app_settings::Mode::RX};
|
||||
|
||||
|
||||
@@ -145,25 +145,25 @@ void MicTXView::rxaudio(bool is_on) {
|
||||
audio::input::stop();
|
||||
baseband::shutdown();
|
||||
|
||||
if (enable_am || enable_usb || enable_lsb || enable_dsb) { // "NFM/FM",0 ," WFM ",1 , " AM ",2, " USB ", 3, " LSB ",4, " DSB-SC", 5
|
||||
if (enable_am || enable_usb || enable_lsb || enable_dsb) { // "NFM/FM", 0, " WFM ", 1, " AM ", 2, " USB ", 3, " LSB ", 4, " DSB-SC", 5
|
||||
baseband::run_image(portapack::spi_flash::image_tag_am_audio);
|
||||
receiver_model.set_modulation(ReceiverModel::Mode::AMAudio); // that AM demodulation engine is common to all Amplitude mod : AM/USB/LSB/DSB (2,3,4,5)
|
||||
if (options_mode.selected_index() < 5) // We will be called here with 2,3,4,5 . We treat here demod. filter 2,3,4; (excluding DSB-C case (5) it is treated more down).
|
||||
receiver_model.set_am_configuration(options_mode.selected_index() - 1); // selecting proper filter(2,3,4). 2-1=1=>6k-AM(1) , 3-1=2=>+3k-USB(2), 4-1=3=>-3K-LSB(3),
|
||||
} else { // We are in NFM/FM or WFM (NFM BW:8k5 or 11k / FM BW 16k / WFM BW:200k)
|
||||
if (options_mode.selected_index() < 5) // We will be called here with 2,3,4,5. We treat here demod. filter 2,3,4; (excluding DSB-C case (5) it is treated more down).
|
||||
receiver_model.set_am_configuration(options_mode.selected_index() - 1); // selecting proper filter(2,3,4). 2-1=1=>6k-AM(1), 3-1=2=>+3k-USB(2), 4-1=3=>-3K-LSB(3),
|
||||
} else { // We are in NFM/FM or WFM (NFM BW:8k5 or 11k / FM BW 16k / WFM BW:200k)
|
||||
|
||||
if (enable_wfm) { // WFM , BW 200Khz aprox , or the two new addional BW filters (180k, 40k)
|
||||
if (enable_wfm) { // WFM, BW 200Khz aprox, or the two new addional BW filters (180k, 40k)
|
||||
baseband::run_image(portapack::spi_flash::image_tag_wfm_audio);
|
||||
receiver_model.set_modulation(ReceiverModel::Mode::WidebandFMAudio);
|
||||
// receiver_model.set_wfm_configuration(n); // it is called above , depending user's selection (200k, 180k,40k).
|
||||
} else { // NFM BW:8k5 or 11k / FM BW 16k
|
||||
// receiver_model.set_wfm_configuration(n); // it is called above, depending user's selection (200k, 180k, 0k).
|
||||
} else { // NFM BW:8k5 or 11k / FM BW 16k
|
||||
baseband::run_image(portapack::spi_flash::image_tag_nfm_audio);
|
||||
receiver_model.set_modulation(ReceiverModel::Mode::NarrowbandFMAudio); //
|
||||
// receiver_model.set_nbfm_configuration(n); is called above , depending user's selection (8k5, 11k, 16k).
|
||||
// receiver_model.set_nbfm_configuration(n); is called above, depending user's selection (8k5, 11k, 16k).
|
||||
}
|
||||
}
|
||||
|
||||
if (bool_same_F_tx_rx_enabled) // when stop TX ,define to which freq RX we return
|
||||
if (bool_same_F_tx_rx_enabled) // when stop TX, define to which freq RX we return
|
||||
receiver_model.set_target_frequency(tx_frequency); // Update freq also for RX = TX
|
||||
else
|
||||
receiver_model.set_target_frequency(rx_frequency); // Now with separate freq controls!
|
||||
@@ -196,7 +196,7 @@ MicTXView::MicTXView(
|
||||
baseband::run_image(portapack::spi_flash::image_tag_mic_tx);
|
||||
|
||||
if (audio::debug::codec_name() == "WM8731") {
|
||||
add_children({&labels_WM8731, // we have audio codec WM8731, same MIC menu as original.
|
||||
add_children({&labels_WM8731, // we have audio codec WM8731, same MIC menu as original.
|
||||
&vumeter,
|
||||
&options_gain, // MIC GAIN float factor on the GUI.
|
||||
&options_wm8731_boost_mode,
|
||||
@@ -260,7 +260,7 @@ MicTXView::MicTXView(
|
||||
mic_gain = v / 10.0;
|
||||
configure_baseband();
|
||||
};
|
||||
options_gain.set_selected_index(1); // x1.0 preselected default.
|
||||
options_gain.set_selected_index(1); // x1.0 preselected default.
|
||||
|
||||
if (audio::debug::codec_name() == "WM8731") {
|
||||
options_wm8731_boost_mode.on_change = [this](size_t, int8_t v) {
|
||||
@@ -268,30 +268,30 @@ MicTXView::MicTXView(
|
||||
case 0: // +12 dB’s respect reference level orig fw 1.5.x fw FM : when +20dB's boost ON) and shift bits (>>8),
|
||||
shift_bits_s16 = 6; // now mic-boost on (+20dBs) and shift bits (>>6), +20+12=32 dB’s (orig fw +20 dBs+ 0dBs)=> +12dB's respect ref.
|
||||
break;
|
||||
case 1: // +06 dB’s reference level , (when +20dB's boost ON)
|
||||
case 1: // +06 dB’s reference level, (when +20dB's boost ON)
|
||||
shift_bits_s16 = 7; // now mic-boost on (+20dBs) and shift bits (>>7), +20+06=26 dB’s (orig fw +20 dBs+ 0dBs) => +06dB's respect ref.
|
||||
break;
|
||||
case 2:
|
||||
shift_bits_s16 = 4; // +04 dB’s respect ref level , (when +20dB's boost OFF)
|
||||
shift_bits_s16 = 4; // +04 dB’s respect ref level, (when +20dB's boost OFF)
|
||||
break; // now mic-boost off (+00dBs) shift bits (4) (+0+24dB's)=24 dBs => +04dB's respect ref.
|
||||
case 3:
|
||||
shift_bits_s16 = 5; // -02 dB’s respect ref level , (when +20dB's boost OFF)
|
||||
shift_bits_s16 = 5; // -02 dB’s respect ref level, (when +20dB's boost OFF)
|
||||
break; // now mic-boost off (+00dBs) shift bits (5) (+0+18dB's)=18 dBs => -02dB's respect ref.
|
||||
case 4:
|
||||
shift_bits_s16 = 6; // -08 dB’s respect ref level , (when +20dB's boost OFF)
|
||||
shift_bits_s16 = 6; // -08 dB’s respect ref level, (when +20dB's boost OFF)
|
||||
break; // now mic-boost off (+00dBs) shift bits (6) (+0+12dB's)=12 dBs => -08dB's respect ref.
|
||||
}
|
||||
ak4951_alc_and_wm8731_boost_GUI = v; // 0,..4 WM8731_boost dB's options, (combination boost on/off , and effective gain in captured data >>x)
|
||||
audio::input::start(ak4951_alc_and_wm8731_boost_GUI); // Detected (WM8731) , set up the proper wm_boost on/off , 0..4 (0,1) boost_on , (2,3,4) boost_0ff
|
||||
configure_baseband(); // to update in real time, sending msg , var-parameters >>shift_bits FM msg ,to audio_tx from M0 to M4 Proc -
|
||||
ak4951_alc_and_wm8731_boost_GUI = v; // 0..4, WM8731_boost dB's options, (combination boost on/off, and effective gain in captured data >>x)
|
||||
audio::input::start(ak4951_alc_and_wm8731_boost_GUI); // Detected (WM8731), set up the proper wm_boost on/off, 0..4 (0,1) boost_on, (2,3,4) boost_off
|
||||
configure_baseband(); // to update in real time, sending msg, var-parameters >>shift_bits FM msg, to audio_tx from M0 to M4 Proc -
|
||||
};
|
||||
options_wm8731_boost_mode.set_selected_index(3); // preset GUI index 3 as default WM -> -02 dB's .
|
||||
options_wm8731_boost_mode.set_selected_index(3); // preset GUI index 3 as default WM -> -02 dB's.
|
||||
} else {
|
||||
shift_bits_s16 = 8; // Initialized default fixed >>8_FM for FM tx mod , shift audio data for AK4951 ,using top 8 bits s16 data (>>8)
|
||||
shift_bits_s16 = 8; // Initialized default fixed >>8_FM for FM tx mod, shift audio data for AK4951, using top 8 bits s16 data (>>8)
|
||||
options_ak4951_alc_mode.on_change = [this](size_t, int8_t v) {
|
||||
ak4951_alc_and_wm8731_boost_GUI = v; // 0,..11, AK4951 Mic -Automatic volume Level Control options,
|
||||
ak4951_alc_and_wm8731_boost_GUI = v; // 0..11, AK4951 Mic -Automatic volume Level Control options,
|
||||
audio::input::start(ak4951_alc_and_wm8731_boost_GUI); // Detected (AK4951) ==> Set up proper ALC mode from 0..11 options
|
||||
configure_baseband(); // sending fixed >>8_FM , var-parameters msg , to audiotx from this M0 to M4 process.
|
||||
configure_baseband(); // sending fixed >>8_FM, var-parameters msg, to audiotx from this M0 to M4 process.
|
||||
};
|
||||
}
|
||||
|
||||
@@ -329,11 +329,11 @@ MicTXView::MicTXView(
|
||||
field_bw.on_change = [this](uint32_t v) {
|
||||
transmitter_model.set_channel_bandwidth(v * 1000);
|
||||
};
|
||||
field_bw.set_value(10); // pre-default first time, TX deviation FM for NFM / FM
|
||||
field_bw.set_value(10); // pre-default first time, TX deviation FM for NFM / FM
|
||||
|
||||
// now , no need direct update , field_rfgain , field_rfamp (it is done in ui_transmitter.cpp)
|
||||
// now, no need direct update, field_rfgain, field_rfamp (it is done in ui_transmitter.cpp)
|
||||
|
||||
options_mode.on_change = [this](size_t, int32_t v) { //{ "NFM/FM", 0 }, { " WFM ", 1 },{ "AM", 2 },{ "USB", 3 },{ "LSB", 4 },{ "DSB", 5 }
|
||||
options_mode.on_change = [this](size_t, int32_t v) { // { "NFM/FM", 0 }, { " WFM ", 1 }, { "AM", 2 }, { "USB", 3 }, { "LSB", 4 }, { "DSB", 5 }
|
||||
enable_am = false;
|
||||
enable_usb = false;
|
||||
enable_lsb = false;
|
||||
@@ -342,7 +342,7 @@ MicTXView::MicTXView(
|
||||
|
||||
using option_t = std::pair<std::string, int32_t>;
|
||||
using options_t = std::vector<option_t>;
|
||||
options_t rxbw; // Aux structure to change dynamically field_rxbw contents,
|
||||
options_t rxbw; // Aux structure to change dynamically field_rxbw contents,
|
||||
|
||||
switch (v) {
|
||||
case 0: //{ "FM", 0 }
|
||||
@@ -354,15 +354,15 @@ MicTXView::MicTXView(
|
||||
// field_bw.set_value(transmitter_model.channel_bandwidth() / 1000);
|
||||
// if (rx_enabled)
|
||||
rxaudio(rx_enabled); // Update now if we have RX audio on
|
||||
options_tone_key.hidden(0); // we are in FM mode , we should have active the Key-tones & CTCSS option.
|
||||
options_tone_key.hidden(0); // we are in FM mode, we should have active the Key-tones & CTCSS option.
|
||||
|
||||
rxbw.emplace_back(" NFM1:8k5 ", 0); // restore the original dynamic field_rxbw value.
|
||||
rxbw.emplace_back(" NFM2:11k ", 1);
|
||||
rxbw.emplace_back(" FM :16k ", 2);
|
||||
field_rxbw.set_options(rxbw); // store that aux GUI option to the field_rxbw.
|
||||
|
||||
field_rxbw.hidden(0); // we are in FM mode, we need to allow the user set up of the RX NFM BW selection (8K5, 11K, 16K)
|
||||
field_bw.hidden(0); // we are in FM mode, we need to allow FM deviation parameter , in non FM mode.
|
||||
field_rxbw.hidden(0); // we are in FM mode, we need to allow the user set up of the RX NFM BW selection (8K5, 11K, 16K)
|
||||
field_bw.hidden(0); // we are in FM mode, we need to allow FM deviation parameter, in non FM mode.
|
||||
break;
|
||||
case 1: //{ "WFM", 1 }
|
||||
enable_am = false;
|
||||
@@ -374,38 +374,38 @@ MicTXView::MicTXView(
|
||||
// field_bw.set_value(transmitter_model.channel_bandwidth() / 1000);
|
||||
// if (rx_enabled)
|
||||
rxaudio(rx_enabled); // Update now if we have RX audio on
|
||||
options_tone_key.hidden(0); // we are in WFM mode , we should have active the Key-tones & CTCSS option.
|
||||
options_tone_key.hidden(0); // we are in WFM mode, we should have active the Key-tones & CTCSS option.
|
||||
|
||||
rxbw.emplace_back(" 200k-WFM ", 0); // We allow the user selection of the 3 x WFM BW filters, (0) WFM-200K, (1) WFM-180K , (2) WFM-40K .
|
||||
rxbw.emplace_back(" 200k-WFM ", 0); // We allow the user selection of the 3 x WFM BW filters, (0) WFM-200K, (1) WFM-180K, (2) WFM-40K.
|
||||
rxbw.emplace_back(" 180k-WFM ", 1);
|
||||
rxbw.emplace_back(" 40k-WFM ", 2);
|
||||
field_rxbw.set_options(rxbw); // store that aux GUI option to the field_rxbw.
|
||||
|
||||
field_rxbw.hidden(0); // we are in WFM mode, we need to show to the user the selected BW WFM filter .
|
||||
field_bw.hidden(0); // we are in WFM mode, we need to allow WFM deviation parameter , in non FM mode.
|
||||
field_rxbw.hidden(0); // we are in WFM mode, we need to show to the user the selected BW WFM filter.
|
||||
field_bw.hidden(0); // we are in WFM mode, we need to allow WFM deviation parameter, in non FM mode.
|
||||
break;
|
||||
case 2: //{ "AM", 2 }
|
||||
enable_am = true;
|
||||
rxaudio(rx_enabled); // Update now if we have RX audio on
|
||||
options_tone_key.set_selected_index(0); // we are NOT in FM mode , we reset the possible previous key-tones &CTCSS selection.
|
||||
options_tone_key.set_selected_index(0); // we are NOT in FM mode, we reset the possible previous key-tones &CTCSS selection.
|
||||
set_dirty(); // Refresh display
|
||||
options_tone_key.hidden(1); // we hide that Key-tones & CTCSS input selecction, (no meaning in AM/DSB/SSB).
|
||||
|
||||
rxbw.emplace_back(" DSB1-9k ", 0); // we offer in AM DSB two audio BW 9k / 6k .
|
||||
rxbw.emplace_back(" DSB1-9k ", 0); // we offer in AM DSB two audio BW 9k / 6k.
|
||||
rxbw.emplace_back(" DSB2-6k ", 1);
|
||||
field_rxbw.set_options(rxbw); // store that aux GUI option to the field_rxbw.
|
||||
|
||||
field_rxbw.hidden(0); // we show fixed RX AM BW 6Khz
|
||||
field_bw.hidden(1); // we hide the FM TX deviation parameter , in non FM mode.
|
||||
field_rxbw.hidden(0); // we show fixed RX AM BW 6Khz
|
||||
field_bw.hidden(1); // we hide the FM TX deviation parameter, in non FM mode.
|
||||
check_rogerbeep.hidden(0); // make visible again the "rogerbeep" selection.
|
||||
break;
|
||||
case 3: //{ "USB", 3 }
|
||||
enable_usb = true;
|
||||
rxaudio(rx_enabled); // Update now if we have RX audio on
|
||||
check_rogerbeep.set_value(false); // reset the possible activation of roger beep, because it is not compatible with SSB , by now.
|
||||
check_rogerbeep.set_value(false); // reset the possible activation of roger beep, because it is not compatible with SSB, by now.
|
||||
check_rogerbeep.hidden(1); // hide that roger beep selection.
|
||||
|
||||
rxbw.emplace_back(" USB+3k ", 0); // locked a fixed option , to display it .
|
||||
rxbw.emplace_back(" USB+3k ", 0); // locked a fixed option, to display it.
|
||||
field_rxbw.set_options(rxbw); // store that aux GUI option to the field_rxbw.
|
||||
|
||||
set_dirty(); // Refresh display
|
||||
@@ -413,10 +413,10 @@ MicTXView::MicTXView(
|
||||
case 4: //{ "LSB", 4 }
|
||||
enable_lsb = true;
|
||||
rxaudio(rx_enabled); // Update now if we have RX audio on
|
||||
check_rogerbeep.set_value(false); // reset the possible activation of roger beep, because it is not compatible with SSB , by now.
|
||||
check_rogerbeep.set_value(false); // reset the possible activation of roger beep, because it is not compatible with SSB, by now.
|
||||
check_rogerbeep.hidden(1); // hide that roger beep selection.
|
||||
|
||||
rxbw.emplace_back(" LSB-3k ", 0); // locked a fixed option , to display it .
|
||||
rxbw.emplace_back(" LSB-3k ", 0); // locked a fixed option, to display it.
|
||||
field_rxbw.set_options(rxbw); // store that aux GUI option to the field_rxbw.
|
||||
|
||||
set_dirty(); // Refresh display
|
||||
@@ -426,7 +426,7 @@ MicTXView::MicTXView(
|
||||
rxaudio(rx_enabled); // Update now if we have RX audio on
|
||||
check_rogerbeep.hidden(0); // make visible again the "rogerbeep" selection.
|
||||
|
||||
rxbw.emplace_back("SSB1:USB+3k", 0); // added dynamically two options (index 0,1) to that DSB-C case to the field_rxbw value.
|
||||
rxbw.emplace_back("SSB1:USB+3k", 0); // added dynamically two options (index 0,1) to that DSB-C case to the field_rxbw value.
|
||||
rxbw.emplace_back("SSB2:LSB-3k", 1);
|
||||
|
||||
field_rxbw.set_options(rxbw); // store that aux GUI option to the field_rxbw.
|
||||
@@ -479,7 +479,7 @@ MicTXView::MicTXView(
|
||||
|
||||
check_common_freq_tx_rx.on_select = [this](Checkbox&, bool v) {
|
||||
bool_same_F_tx_rx_enabled = v;
|
||||
field_rxfrequency.hidden(v); // Hide or show separated freq RX field . (When no hide user can enter down indep. freq for RX)
|
||||
field_rxfrequency.hidden(v); // Hide or show separated freq RX field. (When no hide user can enter down indep. freq for RX)
|
||||
set_dirty(); // Refresh GUI interface
|
||||
receiver_model.set_target_frequency(v ? tx_frequency : rx_frequency); // To go to the proper tuned freq. when toggling it
|
||||
};
|
||||
@@ -510,17 +510,17 @@ MicTXView::MicTXView(
|
||||
|
||||
field_rxbw.on_change = [this](size_t, int32_t v) {
|
||||
if (!(enable_am || enable_usb || enable_lsb || enable_dsb || enable_wfm)) {
|
||||
// In Previous fw versions, that nbfm_configuration(n) was done in any mode (FM/AM/SSB/DSB)...strictly speaking only need it in (NFM/FM)
|
||||
receiver_model.set_nbfm_configuration(v); // we are in NFM/FM case, we need to select proper NFM/FM RX channel filter , NFM BW 8K5(0), NFM BW 11K(1) , FM BW 16K (2)
|
||||
} else { // we are not in NFM/FM mode .(we could be in any of the rest : AM /USB/LSB/DSB-SC)
|
||||
if (enable_am) { // we are in AM TX mode , we will allow both independent RX audio BW : AM 9K (9K00AE3 / AM 6K (6K00AE3). (In AM option v can be 0 (9k) , 1 (6k)
|
||||
receiver_model.set_am_configuration(v); // we are in AM TX mode , we need to select proper AM full path config AM-9K filter. 0+0 =>AM-9K(0), 0+1=1 =>AM-6K(1),
|
||||
// In Previous fw versions, that nbfm_configuration(n) was done in any mode (FM/AM/SSB/DSB)...strictly speaking only need it in (NFM/FM)
|
||||
receiver_model.set_nbfm_configuration(v); // we are in NFM/FM case, we need to select proper NFM/FM RX channel filter, NFM BW 8K5(0), NFM BW 11K(1), FM BW 16K (2)
|
||||
} else { // we are not in NFM/FM mode. (we could be in any of the rest : AM /USB/LSB/DSB-SC)
|
||||
if (enable_am) { // we are in AM TX mode, we will allow both independent RX audio BW : AM 9K (9K00AE3 / AM 6K (6K00AE3). (In AM option v can be 0 (9k), 1 (6k)
|
||||
receiver_model.set_am_configuration(v); // we are in AM TX mode, we need to select proper AM full path config AM-9K filter. 0+0 =>AM-9K(0), 0+1=1 =>AM-6K(1),
|
||||
}
|
||||
if (enable_dsb) { // we are in DSB-SC in TX mode , we will allow both independent RX SSB demodulation (USB / LSB side band). in that submenu, v is 0 (SSB1 USB) or 1 (SSB2 LSB)
|
||||
receiver_model.set_am_configuration(v + 2); // we are in DSB-SC TX mode , we need to select proper SSB filter. 0+2 =>usb(2), 1+2=3 =>lsb(3),
|
||||
if (enable_dsb) { // we are in DSB-SC in TX mode, we will allow both independent RX SSB demodulation (USB / LSB side band). in that submenu, v is 0 (SSB1 USB) or 1 (SSB2 LSB)
|
||||
receiver_model.set_am_configuration(v + 2); // we are in DSB-SC TX mode, we need to select proper SSB filter. 0+2 =>usb(2), 1+2=3 =>lsb(3),
|
||||
}
|
||||
if (enable_wfm) {
|
||||
receiver_model.set_wfm_configuration(v); // we are in WFM case, we need to select proper WFB RX BW filter , WFM BW 200K(0), WFM BW 180K(1) , WFM BW 40K(2)
|
||||
receiver_model.set_wfm_configuration(v); // we are in WFM case, we need to select proper WFB RX BW filter, WFM BW 200K(0), WFM BW 180K(1), WFM BW 40K(2)
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -607,6 +607,36 @@ MicTXView::MicTXView(
|
||||
audio::input::start(ak4951_alc_and_wm8731_boost_GUI); // When detected AK4951 => set up ALC mode; when detected WM8731 => set up mic_boost ON/OFF.
|
||||
}
|
||||
|
||||
MicTXView::MicTXView(
|
||||
NavigationView& nav,
|
||||
ReceiverModel::settings_t override)
|
||||
: MicTXView(nav) {
|
||||
// Try to use the modulation/bandwidth from RX settings.
|
||||
// TODO: These concepts should be merged so there's only one.
|
||||
// TODO: enums/constants for these indexes.
|
||||
switch (override.mode) {
|
||||
case ReceiverModel::Mode::AMAudio:
|
||||
options_mode.set_selected_index(2);
|
||||
break;
|
||||
case ReceiverModel::Mode::NarrowbandFMAudio:
|
||||
options_mode.set_selected_index(0);
|
||||
break;
|
||||
case ReceiverModel::Mode::WidebandFMAudio:
|
||||
options_mode.set_selected_index(1);
|
||||
break;
|
||||
|
||||
// Unsupported modulations.
|
||||
case ReceiverModel::Mode::SpectrumAnalysis:
|
||||
case ReceiverModel::Mode::Capture:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// TODO: bandwidth selection is tied too tightly to the UI
|
||||
// controls. It's not possible to set the bandwidth here without
|
||||
// refactoring. Also options_mode seems to have a category error.
|
||||
}
|
||||
|
||||
MicTXView::~MicTXView() {
|
||||
audio::input::stop();
|
||||
transmitter_model.set_target_frequency(tx_frequency); // Save Tx frequency instead of Rx. Or maybe we need some "System Wide" changes to seperate Tx and Rx frequency.
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
// TODO: Consolidate Modulation/Bandwidth modes/settings with freqman/receiver_model.
|
||||
|
||||
#ifndef __UI_MICTX_H__
|
||||
#define __UI_MICTX_H__
|
||||
|
||||
@@ -43,6 +45,7 @@ namespace ui {
|
||||
class MicTXView : public View {
|
||||
public:
|
||||
MicTXView(NavigationView& nav);
|
||||
MicTXView(NavigationView& nav, ReceiverModel::settings_t override);
|
||||
~MicTXView();
|
||||
|
||||
MicTXView(const MicTXView&) = delete;
|
||||
@@ -117,18 +120,19 @@ class MicTXView : public View {
|
||||
uint8_t shift_bits_s16{4}; // shift bits factor to the captured ADC S16 audio sample.
|
||||
|
||||
// AM TX Stuff
|
||||
// TODO: Some of this stuff is mutually exclusive. Need a better representation.
|
||||
bool enable_am{false};
|
||||
bool enable_dsb{false};
|
||||
bool enable_usb{false};
|
||||
bool enable_lsb{false};
|
||||
bool enable_wfm{false}; // added to distinguish in the FM mode , RX BW : NFM (8K5, 11K), FM (16K), WFM(200K)
|
||||
bool enable_wfm{false}; // added to distinguish in the FM mode, RX BW : NFM (8K5, 11K), FM (16K), WFM(200K)
|
||||
|
||||
Labels labels_WM8731{
|
||||
{{3 * 8, 1 * 8}, "MIC-GAIN:", Color::light_grey()},
|
||||
{{17 * 8, 1 * 8}, "Boost", Color::light_grey()},
|
||||
{{3 * 8, 3 * 8}, "F:", Color::light_grey()},
|
||||
{{15 * 8, 3 * 8}, "FM TXBW: kHz", Color::light_grey()}, // to be more symetric and consistent to the below FM RXBW
|
||||
{{18 * 8, (5 * 8)}, "Mode:", Color::light_grey()}, // now , no need to handle GAIN , Amp here It is handled by ui_transmitter.cpp
|
||||
{{18 * 8, (5 * 8)}, "Mode:", Color::light_grey()}, // now, no need to handle GAIN, Amp here It is handled by ui_transmitter.cpp
|
||||
{{3 * 8, 8 * 8}, "TX Activation:", Color::light_grey()}, // we delete { { 3 * 8, 5 * 8 }, "GAIN:", Color::light_grey() },
|
||||
{{4 * 8, 10 * 8}, "LVL:", Color::light_grey()}, // we delete { {11 * 8, 5 * 8 }, "Amp:", Color::light_grey() },
|
||||
{{12 * 8, 10 * 8}, "ATT:", Color::light_grey()},
|
||||
@@ -147,7 +151,7 @@ class MicTXView : public View {
|
||||
{{17 * 8, 1 * 8}, "ALC", Color::light_grey()},
|
||||
{{3 * 8, 3 * 8}, "F:", Color::light_grey()},
|
||||
{{15 * 8, 3 * 8}, "FM TXBW: kHz", Color::light_grey()},
|
||||
{{18 * 8, (5 * 8)}, "Mode:", Color::light_grey()}, // now , no need to handle GAIN , Amp here It is handled by ui_transmitter.cpp
|
||||
{{18 * 8, (5 * 8)}, "Mode:", Color::light_grey()}, // now, no need to handle GAIN, Amp here It is handled by ui_transmitter.cpp
|
||||
{{3 * 8, 8 * 8}, "TX Activation:", Color::light_grey()}, // we delete { { 3 * 8, 5 * 8 }, "GAIN:", Color::light_grey() },
|
||||
{{4 * 8, 10 * 8}, "LVL:", Color::light_grey()}, // we delete { {11 * 8, 5 * 8 }, "Amp:", Color::light_grey() },
|
||||
{{12 * 8, 10 * 8}, "ATT:", Color::light_grey()},
|
||||
@@ -176,15 +180,15 @@ class MicTXView : public View {
|
||||
{"x2.0", 20}}};
|
||||
|
||||
OptionsField options_ak4951_alc_mode{
|
||||
{20 * 8, 1 * 8}, // Coordinates are: int:x (px), int:y (px)
|
||||
{20 * 8, 1 * 8},
|
||||
11,
|
||||
{
|
||||
{" OFF-12kHz", 0}, // Nothing changed from ORIGINAL,keeping ALL programmable AK4951 Digital Block->OFF, sampling 24Khz)
|
||||
{" OFF-12kHz", 0}, // Nothing changed from ORIGINAL, keeping ALL programmable AK4951 Digital Block->OFF, sampling 24Khz)
|
||||
{"+12dB-6kHz", 1}, // ALC-> on, (+12dB's) Auto Vol max + Wind Noise cancel + LPF 6kHz + Pre-amp Mic (+21dB=original)
|
||||
{"+09dB-6kHz", 2}, // ALC-> on, (+09dB's) Auto Vol max + Wind Noise cancel + LPF 6kHz + Pre-amp Mic (+21dB=original)
|
||||
{"+06dB-6kHz", 3}, // ALC-> on, (+06dB's) Auto Vol max + Wind Noise cancel + LPF 6kHz + Pre-amp Mic (+21dB=original)
|
||||
{"+03dB-2kHz", 4}, // ALC-> on, (+03dB's) Auto Vol max + Wind Noise cancel + LPF 3,5k + Pre-amp Mic (+21dB=original)+ EQ boosting ~<2kHz (f0~1k1,fb:1,7K, k=1,8)
|
||||
{"+03dB-4kHz", 5}, // ALC-> on, (+03dB's) Auto Vol max + Wind Noise cancel + LPF 4kHz + Pre-amp Mic (+21dB=original)+ EQ boosting ~<3kHz (f0~1k4,fb~2,4k, k=1,8)
|
||||
{"+03dB-2kHz", 4}, // ALC-> on, (+03dB's) Auto Vol max + Wind Noise cancel + LPF 3,5k + Pre-amp Mic (+21dB=original)+ EQ boosting ~<2kHz (f0~1k1, fb:1,7K, k=1,8)
|
||||
{"+03dB-4kHz", 5}, // ALC-> on, (+03dB's) Auto Vol max + Wind Noise cancel + LPF 4kHz + Pre-amp Mic (+21dB=original)+ EQ boosting ~<3kHz (f0~1k4, fb~2,4k, k=1,8)
|
||||
{"+03dB-6kHz", 6}, // ALC-> on, (+03dB's) Auto Vol max + Wind Noise cancel + LPF 6kHz + Pre-amp Mic (+21dB=original)
|
||||
{"+00dB-6kHz", 7}, // ALC-> on, (+00dB's) Auto Vol max + Wind Noise cancel + LPF 6kHz + Pre-amp Mic (+21dB=original)
|
||||
{"-03dB-6kHz", 8}, // ALC-> on, (-03dB's) Auto Vol max + Wind Noise cancel + LPF 6kHz + Pre-amp Mic (+21dB=original)
|
||||
@@ -194,14 +198,14 @@ class MicTXView : public View {
|
||||
}};
|
||||
|
||||
OptionsField options_wm8731_boost_mode{
|
||||
{22 * 8, 1 * 8}, // Coordinates are: int:x (px), int:y (px)
|
||||
{22 * 8, 1 * 8},
|
||||
5,
|
||||
{
|
||||
{"ON +12dB", 0}, // WM8731 Mic Boost ON ,original+12dBs condition, easy to saturate ADC sat in high voice ,relative G = +12 dB's respect ref level
|
||||
{"ON +06dB", 1}, // WM8731 Mic Boost ON ,original+6 dBs condition, easy to saturate ADC sat in high voice ,relative G = +06 dB's respect ref level
|
||||
{"OFF+04dB", 2}, // WM8731 Mic Boost OFF to avoid ADC sat in high voice ,relative G = +04 dB's (respect ref level) , always effective sampling 24khz
|
||||
{"OFF-02dB", 3}, // WM8731 Mic Boost OFF to avoid ADC sat in high voice ,relative G = -02 dB's (respect ref level)
|
||||
{"OFF-08dB", 4}, // WM8731 Mic Boost OFF to avoid ADC sat in high voice ,relative G = -12 dB's (respect ref level)
|
||||
{"ON +12dB", 0}, // WM8731 Mic Boost ON, original+12dBs condition, easy to saturate ADC sat in high voice, relative G = +12 dB's respect ref level
|
||||
{"ON +06dB", 1}, // WM8731 Mic Boost ON, original+6 dBs condition, easy to saturate ADC sat in high voice, relative G = +06 dB's respect ref level
|
||||
{"OFF+04dB", 2}, // WM8731 Mic Boost OFF to avoid ADC sat in high voice, relative G = +04 dB's (respect ref level), always effective sampling 24khz
|
||||
{"OFF-02dB", 3}, // WM8731 Mic Boost OFF to avoid ADC sat in high voice, relative G = -02 dB's (respect ref level)
|
||||
{"OFF-08dB", 4}, // WM8731 Mic Boost OFF to avoid ADC sat in high voice, relative G = -12 dB's (respect ref level)
|
||||
}};
|
||||
|
||||
// TODO: Use TxFrequencyField
|
||||
@@ -227,7 +231,7 @@ class MicTXView : public View {
|
||||
{
|
||||
{"NFM/FM", 0},
|
||||
{" WFM ", 1},
|
||||
{" AM ", 2}, // in fact that TX mode = AM -DSB with carrier .
|
||||
{" AM ", 2}, // in fact that TX mode = AM -DSB with carrier.
|
||||
{" USB ", 3},
|
||||
{" LSB ", 4},
|
||||
{"DSB-SC", 5} // We are TX Double Side AM Band with suppressed carrier, and allowing in RX both indep SSB lateral band (USB/LSB).
|
||||
@@ -269,7 +273,7 @@ class MicTXView : public View {
|
||||
|
||||
OptionsField options_tone_key{
|
||||
{12 * 8, (13 * 8) - 5},
|
||||
23,
|
||||
18,
|
||||
{}};
|
||||
|
||||
Checkbox check_rogerbeep{
|
||||
|
||||
@@ -76,7 +76,6 @@ NRFRxView::NRFRxView(NavigationView& nav)
|
||||
audio::set_rate(audio::Rate::Hz_24000);
|
||||
audio::output::start();
|
||||
|
||||
receiver_model.set_modulation(ReceiverModel::Mode::WidebandFMAudio);
|
||||
receiver_model.enable();
|
||||
}
|
||||
|
||||
|
||||
@@ -51,8 +51,8 @@ class NRFRxView : public View {
|
||||
NavigationView& nav_;
|
||||
RxRadioState radio_state_{
|
||||
4000000 /* bandwidth */,
|
||||
4000000 /* sampling rate */
|
||||
};
|
||||
4000000 /* sampling rate */,
|
||||
ReceiverModel::Mode::WidebandFMAudio};
|
||||
app_settings::SettingsManager settings_{
|
||||
"rx_nrf", app_settings::Mode::RX};
|
||||
|
||||
|
||||
@@ -23,11 +23,12 @@
|
||||
*/
|
||||
|
||||
#include "ui_playlist.hpp"
|
||||
|
||||
#include "convert.hpp"
|
||||
#include "file_reader.hpp"
|
||||
#include "io_file.hpp"
|
||||
#include "string_format.hpp"
|
||||
#include "ui_fileman.hpp"
|
||||
#include "io_file.hpp"
|
||||
#include "utility.hpp"
|
||||
|
||||
#include "baseband_api.hpp"
|
||||
@@ -39,13 +40,17 @@
|
||||
using namespace portapack;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
/* TODO: wouldn't it be easier if the playlist were just a list of C16 files
|
||||
* (and maybe delays) and then read the metadata file next to the C16 file?
|
||||
* TODO: use metadata_file.hpp to read the metadata.
|
||||
* TODO: change PPL format to only allow paths, and !<number> for delay. */
|
||||
/* TODO
|
||||
* - Should frequency overrides be saved in the playlist?
|
||||
* - Start playing from current track (vs start over)?
|
||||
*/
|
||||
|
||||
namespace ui {
|
||||
|
||||
// TODO: consolidate extesions into a shared header?
|
||||
static const fs::path c16_ext = u".C16";
|
||||
static const fs::path ppl_ext = u".PPL";
|
||||
|
||||
void PlaylistView::load_file(const fs::path& playlist_path) {
|
||||
File playlist_file;
|
||||
auto error = playlist_file.open(playlist_path.string());
|
||||
@@ -59,57 +64,154 @@ void PlaylistView::load_file(const fs::path& playlist_path) {
|
||||
continue; // Empty or comment line.
|
||||
|
||||
auto cols = split_string(line, ',');
|
||||
if (cols.size() < 3)
|
||||
continue; // Line doesn't have enough columns.
|
||||
auto entry = load_entry(trim(cols[0]));
|
||||
|
||||
playlist_entry entry{};
|
||||
if (!entry)
|
||||
continue;
|
||||
|
||||
parse_int(cols[0], entry.replay_frequency);
|
||||
parse_int(cols[2], entry.sample_rate);
|
||||
if (entry.replay_frequency == 0 || entry.sample_rate == 0)
|
||||
continue; // Invalid freq or rate.
|
||||
// Read optional delay value.
|
||||
if (cols.size() > 1)
|
||||
parse_int(cols[1], entry->ms_delay);
|
||||
|
||||
entry.replay_file = fs::path{u"/"} + std::string{cols[1]};
|
||||
|
||||
if (cols.size() == 4) // Optional delay value.
|
||||
parse_int(cols[3], entry.initial_delay);
|
||||
|
||||
playlist_db_.emplace_back(std::move(entry));
|
||||
playlist_db_.emplace_back(*std::move(entry));
|
||||
}
|
||||
}
|
||||
|
||||
Optional<PlaylistView::playlist_entry> PlaylistView::load_entry(fs::path&& path) {
|
||||
File capture_file;
|
||||
|
||||
auto error = capture_file.open(path);
|
||||
if (error)
|
||||
return {};
|
||||
|
||||
// Read metafile if it exists.
|
||||
auto metadata_path = get_metadata_path(path);
|
||||
auto metadata = read_metadata_file(metadata_path);
|
||||
|
||||
// If no metadata found, fallback to the TX frequency.
|
||||
if (!metadata)
|
||||
metadata = {transmitter_model.target_frequency(), 500'000};
|
||||
|
||||
return playlist_entry{
|
||||
std::move(path),
|
||||
*metadata,
|
||||
capture_file.size(),
|
||||
0u};
|
||||
}
|
||||
|
||||
void PlaylistView::on_file_changed(const fs::path& new_file_path) {
|
||||
stop();
|
||||
reset();
|
||||
|
||||
current_index_ = 0;
|
||||
playlist_path_ = new_file_path;
|
||||
playlist_db_.clear();
|
||||
load_file(playlist_path_);
|
||||
|
||||
update_ui();
|
||||
button_play.focus();
|
||||
|
||||
// TODO: fix in UI framework with 'try_focus()'?
|
||||
// Hack around focus getting called by ctor before parent is set.
|
||||
if (parent())
|
||||
button_play.focus();
|
||||
}
|
||||
|
||||
void PlaylistView::reset() {
|
||||
current_track_ = 0;
|
||||
current_entry_ = nullptr;
|
||||
current_entry_size_ = 0;
|
||||
void PlaylistView::open_file(bool prompt_save) {
|
||||
if (playlist_dirty_ && prompt_save) {
|
||||
nav_.display_modal(
|
||||
"Save?", "Save changes?", YESNO,
|
||||
[this](bool choice) {
|
||||
if (choice)
|
||||
save_file(false);
|
||||
});
|
||||
nav_.set_on_pop([this]() { open_file(false); });
|
||||
return;
|
||||
}
|
||||
|
||||
auto open_view = nav_.push<FileLoadView>(".PPL");
|
||||
open_view->push_dir(u"PLAYLIST");
|
||||
open_view->on_changed = [this](fs::path new_file_path) {
|
||||
on_file_changed(new_file_path);
|
||||
};
|
||||
}
|
||||
|
||||
void PlaylistView::save_file(bool show_dialogs) {
|
||||
if (!playlist_dirty_ || playlist_path_.empty())
|
||||
return;
|
||||
|
||||
ensure_directory(playlist_path_.parent_path());
|
||||
|
||||
File playlist_file;
|
||||
auto error = playlist_file.create(playlist_path_.string());
|
||||
|
||||
if (error) {
|
||||
if (show_dialogs)
|
||||
nav_.display_modal(
|
||||
"Save Error",
|
||||
"Could not save file\n" + playlist_path_.string());
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto& entry : playlist_db_) {
|
||||
playlist_file.write_line(
|
||||
entry.path.string() + "," +
|
||||
to_string_dec_uint(entry.ms_delay));
|
||||
}
|
||||
|
||||
playlist_dirty_ = false;
|
||||
|
||||
if (show_dialogs)
|
||||
nav_.display_modal(
|
||||
"Save",
|
||||
"Saved playlist\n" + playlist_path_.string());
|
||||
}
|
||||
|
||||
void PlaylistView::add_entry(fs::path&& path) {
|
||||
if (playlist_path_.empty()) {
|
||||
playlist_path_ = next_filename_matching_pattern(u"/PLAYLIST/PLAY_????.PPL");
|
||||
|
||||
// Hack around focus getting called by ctor before parent is set.
|
||||
if (parent())
|
||||
button_play.focus();
|
||||
}
|
||||
|
||||
auto entry = load_entry(std::move(path));
|
||||
if (entry) {
|
||||
playlist_db_.emplace_back(*std::move(entry));
|
||||
current_index_ = playlist_db_.size() - 1;
|
||||
playlist_dirty_ = true;
|
||||
}
|
||||
|
||||
update_ui();
|
||||
}
|
||||
|
||||
void PlaylistView::delete_entry() {
|
||||
if (playlist_db_.empty())
|
||||
return;
|
||||
|
||||
// Ugh, the STL is gross.
|
||||
playlist_db_.erase(playlist_db_.begin() + current_index_);
|
||||
|
||||
if (current_index_ > 0)
|
||||
--current_index_;
|
||||
|
||||
playlist_dirty_ = true;
|
||||
update_ui();
|
||||
}
|
||||
|
||||
void PlaylistView::show_file_error(const fs::path& path, const std::string& message) {
|
||||
nav_.display_modal("Error", "Error opening file \n" + path.string() + "\n" + message);
|
||||
}
|
||||
|
||||
PlaylistView::playlist_entry* PlaylistView::current() {
|
||||
return playlist_db_.empty() ? nullptr : &playlist_db_[current_index_];
|
||||
}
|
||||
|
||||
bool PlaylistView::is_active() const {
|
||||
return replay_thread_ != nullptr;
|
||||
}
|
||||
|
||||
bool PlaylistView::loop() const {
|
||||
return check_loop.value();
|
||||
}
|
||||
|
||||
bool PlaylistView::is_done() const {
|
||||
return current_track_ >= playlist_db_.size();
|
||||
bool PlaylistView::at_end() const {
|
||||
return current_index_ >= playlist_db_.size();
|
||||
}
|
||||
|
||||
void PlaylistView::toggle() {
|
||||
@@ -120,25 +222,24 @@ void PlaylistView::toggle() {
|
||||
}
|
||||
|
||||
void PlaylistView::start() {
|
||||
reset();
|
||||
|
||||
if (playlist_db_.empty())
|
||||
return; // Nothing to do.
|
||||
|
||||
if (next_track())
|
||||
send_current_track();
|
||||
current_index_ = 0u;
|
||||
send_current_track();
|
||||
}
|
||||
|
||||
/* Advance to the next track in the playlist. */
|
||||
bool PlaylistView::next_track() {
|
||||
if (is_done()) {
|
||||
if (loop())
|
||||
current_track_ = 0;
|
||||
else
|
||||
return false; // All done.
|
||||
++current_index_;
|
||||
|
||||
// Reset to the 0 once at the end to prevent current_index_
|
||||
// from being outside the bounds of playlist_db_ when painting.
|
||||
if (at_end()) {
|
||||
current_index_ = 0;
|
||||
return check_loop.value(); // Keep going if looping.
|
||||
}
|
||||
current_entry_ = &playlist_db_[current_track_];
|
||||
current_track_++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -149,30 +250,25 @@ void PlaylistView::send_current_track() {
|
||||
transmitter_model.disable();
|
||||
ready_signal_ = false;
|
||||
|
||||
if (!current_entry_)
|
||||
if (!current())
|
||||
return;
|
||||
|
||||
// TODO: Use a timer so the UI isn't frozen.
|
||||
if (current()->ms_delay > 0)
|
||||
chThdSleepMilliseconds(current()->ms_delay);
|
||||
|
||||
// Open the sample file to send.
|
||||
auto reader = std::make_unique<FileReader>();
|
||||
auto error = reader->open(current_entry_->replay_file);
|
||||
auto error = reader->open(current()->path);
|
||||
if (error) {
|
||||
show_file_error(current_entry_->replay_file, "Can't open file to send.");
|
||||
show_file_error(current()->path, "Can't open file to send.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the sample file size for the progress bar.
|
||||
current_entry_size_ = reader->file().size();
|
||||
progressbar_transmit.set_value(0);
|
||||
|
||||
// Wait a bit before sending if specified.
|
||||
// TODO: this pauses the main thread, move into ReplayThread instead.
|
||||
if (current_entry_->initial_delay > 0)
|
||||
chThdSleepMilliseconds(current_entry_->initial_delay);
|
||||
|
||||
// ReplayThread starts immediately on contruction so
|
||||
// ReplayThread starts immediately on construction so
|
||||
// these need to be set before creating the ReplayThread.
|
||||
transmitter_model.set_target_frequency(current_entry_->replay_frequency);
|
||||
transmitter_model.set_sampling_rate(current_entry_->sample_rate * 8);
|
||||
transmitter_model.set_target_frequency(current()->metadata.center_frequency);
|
||||
transmitter_model.set_sampling_rate(current()->metadata.sample_rate * 8);
|
||||
transmitter_model.set_baseband_bandwidth(baseband_bandwidth);
|
||||
transmitter_model.enable();
|
||||
|
||||
@@ -180,6 +276,9 @@ void PlaylistView::send_current_track() {
|
||||
// TODO: Why doesn't the transmitter_model just handle this?
|
||||
baseband::set_sample_rate(transmitter_model.sampling_rate());
|
||||
|
||||
// Reset the transmit progress bar.
|
||||
progressbar_transmit.set_value(0);
|
||||
|
||||
// Use the ReplayThread class to send the data.
|
||||
replay_thread_ = std::make_unique<ReplayThread>(
|
||||
std::move(reader),
|
||||
@@ -199,37 +298,48 @@ void PlaylistView::stop() {
|
||||
// This terminates the underlying chThread.
|
||||
replay_thread_.reset();
|
||||
transmitter_model.disable();
|
||||
|
||||
// Reset the transmit progress bar.
|
||||
progressbar_transmit.set_value(0);
|
||||
update_ui();
|
||||
}
|
||||
|
||||
void PlaylistView::update_ui() {
|
||||
if (playlist_db_.empty()) {
|
||||
text_track.set("Open a playlist file.");
|
||||
} else {
|
||||
text_track.set(
|
||||
to_string_dec_uint(current_track_) + "/" +
|
||||
to_string_dec_uint(playlist_db_.size()) + " " +
|
||||
playlist_path_.filename().string());
|
||||
}
|
||||
|
||||
button_play.set_bitmap(is_active() ? &bitmap_stop : &bitmap_play);
|
||||
|
||||
progressbar_track.set_value(current_track_);
|
||||
progressbar_track.set_max(playlist_db_.size());
|
||||
progressbar_transmit.set_max(current_entry_size_);
|
||||
|
||||
if (current_entry_) {
|
||||
auto duration = ms_duration(current_entry_size_, current_entry_->sample_rate, 4);
|
||||
text_filename.set(truncate(current_entry_->replay_file.filename().string(), 12));
|
||||
text_sample_rate.set(unit_auto_scale(current_entry_->sample_rate, 3, 0) + "Hz");
|
||||
text_duration.set(to_string_time_ms(duration));
|
||||
text_frequency.set(to_string_short_freq(current_entry_->replay_frequency));
|
||||
} else {
|
||||
text_filename.set("-");
|
||||
text_sample_rate.set("-");
|
||||
text_duration.set("-");
|
||||
text_frequency.set("-");
|
||||
|
||||
if (playlist_path_.empty())
|
||||
text_track.set("Open playlist or add capture.");
|
||||
else
|
||||
text_track.set(playlist_path_.filename().string());
|
||||
|
||||
progressbar_track.set_value(0);
|
||||
progressbar_track.set_max(0);
|
||||
progressbar_transmit.set_max(0);
|
||||
|
||||
} else {
|
||||
chDbgAssert(!at_end(), "update_ui #1", "current_index_ invalid");
|
||||
|
||||
text_filename.set(current()->path.filename().string());
|
||||
text_sample_rate.set(unit_auto_scale(current()->metadata.sample_rate, 3, 0) + "Hz");
|
||||
|
||||
auto duration = ms_duration(current()->file_size, current()->metadata.sample_rate, 4);
|
||||
text_duration.set(to_string_time_ms(duration));
|
||||
field_frequency.set_value(current()->metadata.center_frequency);
|
||||
|
||||
text_track.set(
|
||||
to_string_dec_uint(current_index_ + 1) + "/" +
|
||||
to_string_dec_uint(playlist_db_.size()) + " " +
|
||||
playlist_path_.filename().string());
|
||||
|
||||
progressbar_track.set_max(playlist_db_.size() - 1);
|
||||
progressbar_track.set_value(current_index_);
|
||||
progressbar_transmit.set_max(current()->file_size);
|
||||
}
|
||||
|
||||
button_play.set_bitmap(is_active() ? &bitmap_stop : &bitmap_play);
|
||||
}
|
||||
|
||||
void PlaylistView::on_tx_progress(uint32_t progress) {
|
||||
@@ -245,7 +355,7 @@ void PlaylistView::handle_replay_thread_done(uint32_t return_code) {
|
||||
}
|
||||
|
||||
if (return_code == ReplayThread::READ_ERROR)
|
||||
show_file_error(current_entry_->replay_file, "Replay read failed.");
|
||||
show_file_error(current()->path, "Replay read failed.");
|
||||
|
||||
stop();
|
||||
}
|
||||
@@ -256,36 +366,103 @@ PlaylistView::PlaylistView(
|
||||
baseband::run_image(portapack::spi_flash::image_tag_replay);
|
||||
|
||||
add_children({
|
||||
&button_open,
|
||||
&text_filename,
|
||||
&text_sample_rate,
|
||||
&text_duration,
|
||||
&progressbar_track,
|
||||
&progressbar_transmit,
|
||||
&text_frequency,
|
||||
&field_frequency,
|
||||
&tx_view,
|
||||
&check_loop,
|
||||
&button_play,
|
||||
&text_track,
|
||||
&button_prev,
|
||||
&button_add,
|
||||
&button_delete,
|
||||
&button_open,
|
||||
&button_save,
|
||||
&button_next,
|
||||
&waterfall,
|
||||
});
|
||||
|
||||
waterfall.show_audio_spectrum_view(false);
|
||||
|
||||
field_frequency.set_value(100'000'000);
|
||||
field_frequency.on_change = [this](rf::Frequency f) {
|
||||
if (current())
|
||||
current()->metadata.center_frequency = f;
|
||||
};
|
||||
field_frequency.on_edit = [this]() {
|
||||
auto freq_view = nav_.push<FrequencyKeypadView>(field_frequency.value());
|
||||
freq_view->on_changed = [this](rf::Frequency f) {
|
||||
field_frequency.set_value(f);
|
||||
};
|
||||
};
|
||||
|
||||
button_play.on_select = [this](ImageButton&) {
|
||||
toggle();
|
||||
};
|
||||
|
||||
button_open.on_select = [this, &nav](Button&) {
|
||||
auto open_view = nav.push<FileLoadView>(".PPL");
|
||||
open_view->on_changed = [this](std::filesystem::path new_file_path) {
|
||||
on_file_changed(new_file_path);
|
||||
button_add.on_select = [this, &nav]() {
|
||||
if (is_active())
|
||||
return;
|
||||
auto open_view = nav_.push<FileLoadView>(".C16");
|
||||
open_view->push_dir(u"CAPTURES");
|
||||
open_view->on_changed = [this](fs::path path) {
|
||||
add_entry(std::move(path));
|
||||
};
|
||||
};
|
||||
|
||||
button_delete.on_select = [this, &nav]() {
|
||||
if (is_active())
|
||||
return;
|
||||
delete_entry();
|
||||
};
|
||||
|
||||
button_open.on_select = [this, &nav]() {
|
||||
if (is_active())
|
||||
stop();
|
||||
open_file();
|
||||
};
|
||||
|
||||
button_save.on_select = [this]() {
|
||||
if (is_active())
|
||||
stop();
|
||||
save_file();
|
||||
};
|
||||
|
||||
button_prev.on_select = [this]() {
|
||||
if (is_active())
|
||||
return;
|
||||
--current_index_;
|
||||
if (at_end())
|
||||
current_index_ = playlist_db_.size() - 1;
|
||||
update_ui();
|
||||
};
|
||||
|
||||
button_next.on_select = [this]() {
|
||||
if (is_active())
|
||||
return;
|
||||
++current_index_;
|
||||
if (at_end())
|
||||
current_index_ = 0;
|
||||
update_ui();
|
||||
};
|
||||
|
||||
update_ui();
|
||||
}
|
||||
|
||||
PlaylistView::PlaylistView(
|
||||
NavigationView& nav,
|
||||
const fs::path& path)
|
||||
: PlaylistView(nav) {
|
||||
auto ext = path.extension();
|
||||
if (path_iequal(ext, ppl_ext))
|
||||
on_file_changed(path);
|
||||
else if (path_iequal(ext, c16_ext))
|
||||
add_entry(fs::path{path});
|
||||
}
|
||||
|
||||
PlaylistView::~PlaylistView() {
|
||||
transmitter_model.disable();
|
||||
baseband::shutdown();
|
||||
@@ -294,20 +471,23 @@ PlaylistView::~PlaylistView() {
|
||||
void PlaylistView::set_parent_rect(Rect new_parent_rect) {
|
||||
View::set_parent_rect(new_parent_rect);
|
||||
|
||||
const ui::Rect waterfall_rect{
|
||||
ui::Rect waterfall_rect{
|
||||
0, header_height, new_parent_rect.width(),
|
||||
new_parent_rect.height() - header_height};
|
||||
waterfall.set_parent_rect(waterfall_rect);
|
||||
}
|
||||
|
||||
void PlaylistView::focus() {
|
||||
if (playlist_path_.empty())
|
||||
button_add.focus();
|
||||
else
|
||||
button_play.focus();
|
||||
}
|
||||
|
||||
void PlaylistView::on_hide() {
|
||||
stop();
|
||||
waterfall.on_hide();
|
||||
View::on_hide();
|
||||
}
|
||||
|
||||
void PlaylistView::focus() {
|
||||
button_open.focus();
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
@@ -25,13 +25,16 @@
|
||||
#define NORMAL_UI false
|
||||
|
||||
#include "app_settings.hpp"
|
||||
#include "bitmap.hpp"
|
||||
#include "file.hpp"
|
||||
#include "metadata_file.hpp"
|
||||
#include "radio_state.hpp"
|
||||
#include "ui_widget.hpp"
|
||||
#include "replay_thread.hpp"
|
||||
#include "ui_navigation.hpp"
|
||||
#include "ui_receiver.hpp"
|
||||
#include "replay_thread.hpp"
|
||||
#include "ui_spectrum.hpp"
|
||||
#include "ui_transmitter.hpp"
|
||||
#include "ui_widget.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
@@ -42,17 +45,15 @@ namespace ui {
|
||||
class PlaylistView : public View {
|
||||
public:
|
||||
PlaylistView(NavigationView& nav);
|
||||
PlaylistView(NavigationView& nav, const std::filesystem::path& path);
|
||||
~PlaylistView();
|
||||
|
||||
// Disable copy to make -Weffc++ happy.
|
||||
PlaylistView(const PlaylistView&) = delete;
|
||||
PlaylistView& operator=(const PlaylistView&) = delete;
|
||||
|
||||
// Following 2 called by 'NavigationView::update_view' after view is created.
|
||||
void set_parent_rect(Rect new_parent_rect) override;
|
||||
void on_hide() override;
|
||||
void focus() override;
|
||||
void on_hide() override;
|
||||
|
||||
std::string title() const override { return "Playlist"; };
|
||||
std::string title() const override { return "Replay"; };
|
||||
|
||||
private:
|
||||
NavigationView& nav_;
|
||||
@@ -61,35 +62,40 @@ class PlaylistView : public View {
|
||||
"tx_playlist", app_settings::Mode::TX};
|
||||
|
||||
// More header == less spectrum view.
|
||||
static constexpr ui::Dim header_height = 4 * 16;
|
||||
static constexpr ui::Dim header_height = 6 * 16;
|
||||
static constexpr uint32_t baseband_bandwidth = 2500000;
|
||||
|
||||
struct playlist_entry {
|
||||
rf::Frequency replay_frequency{0};
|
||||
std::filesystem::path replay_file{};
|
||||
uint32_t sample_rate{};
|
||||
uint32_t initial_delay{};
|
||||
std::filesystem::path path{};
|
||||
capture_metadata metadata{};
|
||||
File::Size file_size{};
|
||||
uint32_t ms_delay{};
|
||||
};
|
||||
|
||||
std::unique_ptr<ReplayThread> replay_thread_{};
|
||||
bool ready_signal_{}; // Used to signal the ReplayThread.
|
||||
|
||||
size_t current_track_{0};
|
||||
const playlist_entry* current_entry_{};
|
||||
size_t current_entry_size_{0};
|
||||
size_t current_index_{0};
|
||||
bool playlist_dirty_{};
|
||||
std::vector<playlist_entry> playlist_db_{};
|
||||
std::filesystem::path playlist_path_{};
|
||||
|
||||
void load_file(const std::filesystem::path& path);
|
||||
Optional<playlist_entry> load_entry(std::filesystem::path&& path);
|
||||
void on_file_changed(const std::filesystem::path& path);
|
||||
void open_file(bool prompt_save = true);
|
||||
void save_file(bool show_dialogs = true);
|
||||
void add_entry(std::filesystem::path&& path);
|
||||
void delete_entry();
|
||||
void reset();
|
||||
void show_file_error(
|
||||
const std::filesystem::path& path,
|
||||
const std::string& message);
|
||||
|
||||
playlist_entry* current();
|
||||
|
||||
bool is_active() const;
|
||||
bool loop() const;
|
||||
bool is_done() const;
|
||||
bool at_end() const;
|
||||
|
||||
void toggle();
|
||||
void start();
|
||||
@@ -103,31 +109,33 @@ class PlaylistView : public View {
|
||||
void on_tx_progress(uint32_t progress);
|
||||
void handle_replay_thread_done(uint32_t return_code);
|
||||
|
||||
Button button_open{
|
||||
{0 * 8, 0 * 16, 10 * 8, 2 * 16},
|
||||
"Open PPL"};
|
||||
|
||||
Text text_filename{
|
||||
{11 * 8, 0 * 16, 12 * 8, 16}};
|
||||
{0 * 8, 0 * 16, 30 * 8, 16}};
|
||||
|
||||
FrequencyField field_frequency{
|
||||
{0 * 8, 1 * 16}};
|
||||
|
||||
Text text_sample_rate{
|
||||
{24 * 8, 0 * 16, 6 * 8, 16}};
|
||||
{10 * 8, 1 * 16, 7 * 8, 16}};
|
||||
|
||||
Text text_duration{
|
||||
{11 * 8, 1 * 16, 6 * 8, 16}};
|
||||
/*v making there's 1px line (instead of two) between two progress bars,
|
||||
* by letting 1px overlapped.
|
||||
* So, since they overlapped 1px, they are visually same, and looks better.
|
||||
*/
|
||||
|
||||
ProgressBar progressbar_track{
|
||||
{18 * 8, 1 * 16, 12 * 8, 8}};
|
||||
{18 * 8, 1 * 16, 12 * 8, 8 + 1}};
|
||||
|
||||
ProgressBar progressbar_transmit{
|
||||
{18 * 8, 3 * 8, 12 * 8, 8}};
|
||||
{18 * 8, 3 * 8 - 1, 12 * 8, 8}};
|
||||
|
||||
Text text_frequency{
|
||||
{0 * 8, 2 * 16, 9 * 8, 16}};
|
||||
Text text_duration{
|
||||
{0 * 8, 2 * 16, 5 * 8, 16}};
|
||||
|
||||
// TODO: delay duration field.
|
||||
|
||||
TransmitterView2 tx_view{
|
||||
74, 1 * 8, SHORT_UI // x(columns), y (line) position.
|
||||
};
|
||||
9 * 8, 1 * 8, SHORT_UI};
|
||||
|
||||
Checkbox check_loop{
|
||||
{21 * 8, 2 * 16},
|
||||
@@ -144,7 +152,43 @@ class PlaylistView : public View {
|
||||
Text text_track{
|
||||
{0 * 8, 3 * 16, 30 * 8, 16}};
|
||||
|
||||
spectrum::WaterfallWidget waterfall{};
|
||||
NewButton button_prev{
|
||||
{2 * 8, 4 * 16, 4 * 8, 2 * 16},
|
||||
"",
|
||||
&bitmap_arrow_left,
|
||||
Color::dark_grey()};
|
||||
|
||||
NewButton button_next{
|
||||
{6 * 8, 4 * 16, 4 * 8, 2 * 16},
|
||||
"",
|
||||
&bitmap_arrow_right,
|
||||
Color::dark_grey()};
|
||||
|
||||
NewButton button_add{
|
||||
{11 * 8, 4 * 16, 4 * 8, 2 * 16},
|
||||
"",
|
||||
&bitmap_icon_new_file,
|
||||
Color::orange()};
|
||||
|
||||
NewButton button_delete{
|
||||
{15 * 8, 4 * 16, 4 * 8, 2 * 16},
|
||||
"",
|
||||
&bitmap_icon_delete,
|
||||
Color::orange()};
|
||||
|
||||
NewButton button_open{
|
||||
{20 * 8, 4 * 16, 4 * 8, 2 * 16},
|
||||
"",
|
||||
&bitmap_icon_load,
|
||||
Color::dark_blue()};
|
||||
|
||||
NewButton button_save{
|
||||
{24 * 8, 4 * 16, 4 * 8, 2 * 16},
|
||||
"",
|
||||
&bitmap_icon_save,
|
||||
Color::dark_blue()};
|
||||
|
||||
spectrum::WaterfallView waterfall{};
|
||||
|
||||
MessageHandlerRegistration message_handler_replay_thread_error{
|
||||
Message::ID::ReplayThreadDone,
|
||||
|
||||
@@ -80,8 +80,7 @@ bool POCSAGTXView::start_tx() {
|
||||
progressbar.set_max(total_frames);
|
||||
|
||||
transmitter_model.set_rf_amp(true);
|
||||
transmitter_model.set_lna(40);
|
||||
transmitter_model.set_vga(40);
|
||||
transmitter_model.set_tx_gain(40);
|
||||
transmitter_model.enable();
|
||||
|
||||
uint8_t* data_ptr = shared_memory.bb_data.data;
|
||||
|
||||
@@ -36,18 +36,27 @@ void ReconView::set_loop_config(bool v) {
|
||||
persistent_memory::set_recon_continuous(continuous);
|
||||
}
|
||||
|
||||
void ReconView::recon_stop_recording() {
|
||||
if (is_recording) {
|
||||
button_audio_app.set_style(&Styles::white);
|
||||
record_view->stop();
|
||||
button_config.set_style(&Styles::white); // disable config while recording as it's causing an IO error pop up at exit
|
||||
is_recording = false;
|
||||
}
|
||||
}
|
||||
|
||||
void ReconView::clear_freqlist_for_ui_action() {
|
||||
audio::output::stop();
|
||||
recon_stop_recording();
|
||||
if (field_mode.selected_index_value() != SPEC_MODULATION)
|
||||
audio::output::stop();
|
||||
// flag to detect and reload frequency_list
|
||||
freqlist_cleared_for_ui_action = true;
|
||||
// if in manual mode, there is enough memory to load freqman files, else we have to unload/reload
|
||||
if (!manual_mode) {
|
||||
// clear and shrink_to_fit are not enough to really start with a new, clean, empty vector
|
||||
// swap is the only way to achieve a perfect memory liberation
|
||||
std::vector<freqman_entry>().swap(frequency_list);
|
||||
} else {
|
||||
} else
|
||||
frequency_list.shrink_to_fit();
|
||||
}
|
||||
freqlist_cleared_for_ui_action = true;
|
||||
}
|
||||
|
||||
void ReconView::reset_indexes() {
|
||||
@@ -234,8 +243,8 @@ bool ReconView::recon_save_config_to_sd() {
|
||||
|
||||
make_new_directory(u"SETTINGS");
|
||||
|
||||
auto result = settings_file.create(RECON_CFG_FILE);
|
||||
if (result.is_valid())
|
||||
auto error = settings_file.create(RECON_CFG_FILE);
|
||||
if (error)
|
||||
return false;
|
||||
settings_file.write_line(input_file);
|
||||
settings_file.write_line(output_file);
|
||||
@@ -248,7 +257,8 @@ bool ReconView::recon_save_config_to_sd() {
|
||||
}
|
||||
|
||||
void ReconView::audio_output_start() {
|
||||
audio::output::start();
|
||||
if (field_mode.selected_index_value() != SPEC_MODULATION)
|
||||
audio::output::start();
|
||||
receiver_model.set_headphone_volume(receiver_model.headphone_volume()); // WM8731 hack.
|
||||
}
|
||||
|
||||
@@ -281,10 +291,6 @@ void ReconView::recon_redraw() {
|
||||
} else if (freq_lock >= recon_lock_nb_match) {
|
||||
big_display.set_style(&Styles::green);
|
||||
button_pause.set_text("<UNLOCK>");
|
||||
// FREQ IS STRONG: GREEN and recon will pause when on_statistics_update()
|
||||
if ((!scanner_mode) && autosave && frequency_list.size() > 0) {
|
||||
recon_save_freq(freq_file_path, current_index, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (last_db != db || last_list_size != frequency_list.size()) {
|
||||
@@ -356,16 +362,20 @@ void ReconView::focus() {
|
||||
}
|
||||
|
||||
ReconView::~ReconView() {
|
||||
// Save recon config.
|
||||
recon_stop_recording();
|
||||
recon_save_config_to_sd();
|
||||
|
||||
audio::output::stop();
|
||||
if (field_mode.selected_index_value() != SPEC_MODULATION)
|
||||
audio::output::stop();
|
||||
receiver_model.disable();
|
||||
baseband::shutdown();
|
||||
}
|
||||
|
||||
ReconView::ReconView(NavigationView& nav)
|
||||
: nav_{nav} {
|
||||
chrono_start = chTimeNow();
|
||||
record_view = std::make_unique<RecordView>(Rect{0, 0, 30 * 8, 1 * 16},
|
||||
u"AUTO_AUDIO_", u"AUDIO",
|
||||
RecordView::FileType::WAV, 4096, 4);
|
||||
add_children({&labels,
|
||||
&field_lna,
|
||||
&field_vga,
|
||||
@@ -401,7 +411,14 @@ ReconView::ReconView(NavigationView& nav)
|
||||
&button_dir,
|
||||
&button_restart,
|
||||
&button_mic_app,
|
||||
&button_remove});
|
||||
&button_remove,
|
||||
record_view.get()});
|
||||
|
||||
record_view->hidden(true);
|
||||
record_view->set_filename_date_frequency(true);
|
||||
record_view->on_error = [&nav](std::string message) {
|
||||
nav.display_modal("Error", message);
|
||||
};
|
||||
|
||||
def_step = 0;
|
||||
// HELPER: Pre-setting a manual range, based on stored frequency
|
||||
@@ -426,6 +443,7 @@ ReconView::ReconView(NavigationView& nav)
|
||||
load_ranges = persistent_memory::recon_load_ranges();
|
||||
load_hamradios = persistent_memory::recon_load_hamradios();
|
||||
update_ranges = persistent_memory::recon_update_ranges_when_recon();
|
||||
auto_record_locked = persistent_memory::recon_auto_record_locked();
|
||||
|
||||
button_manual_start.on_select = [this, &nav](ButtonWithEncoder& button) {
|
||||
clear_freqlist_for_ui_action();
|
||||
@@ -530,8 +548,9 @@ ReconView::ReconView(NavigationView& nav)
|
||||
};
|
||||
|
||||
button_audio_app.on_select = [this](Button&) {
|
||||
nav_.pop();
|
||||
nav_.push<AnalogAudioView>();
|
||||
auto settings = receiver_model.settings();
|
||||
settings.frequency_step = step_mode.selected_index_value();
|
||||
nav_.replace<AnalogAudioView>(settings);
|
||||
};
|
||||
|
||||
button_loop_config.on_select = [this](Button&) {
|
||||
@@ -550,9 +569,9 @@ ReconView::ReconView(NavigationView& nav)
|
||||
button_mic_app.on_select = [this](Button&) {
|
||||
if (frequency_list.size() > 0 && current_index >= 0 && (unsigned)current_index < frequency_list.size()) {
|
||||
if (frequency_list[current_index].type == HAMRADIO) {
|
||||
// if it's a HAMRADIO entry, then frequency_a is the freq at which the repeater reveive, so we have to set it in transmit in mic app
|
||||
// if it's a HAMRADIO entry, then frequency_a is the freq at which the repeater receives, so we have to set it in transmit in mic app
|
||||
transmitter_model.set_target_frequency(frequency_list[current_index].frequency_a);
|
||||
// if it's a HAMRADIO entry, then frequency_b is the freq at which the repeater transmit, so we have to set it in receive in mic app
|
||||
// if it's a HAMRADIO entry, then frequency_b is the freq at which the repeater transmits, so we have to set it in receive in mic app
|
||||
receiver_model.set_target_frequency(frequency_list[current_index].frequency_b);
|
||||
} else {
|
||||
// it's single or range so we us actual tuned frequency
|
||||
@@ -560,9 +579,9 @@ ReconView::ReconView(NavigationView& nav)
|
||||
receiver_model.set_target_frequency(freq);
|
||||
}
|
||||
}
|
||||
// there is no way yet to set modulation and bandwidth from Recon to MicApp
|
||||
nav_.pop();
|
||||
nav_.push<MicTXView>();
|
||||
|
||||
// MicTX wants Modulation and Bandwidth overrides, but that's only stored on the RX model.
|
||||
nav_.replace<MicTXView>(receiver_model.settings());
|
||||
};
|
||||
|
||||
button_remove.on_select = [this](ButtonWithEncoder&) {
|
||||
@@ -682,8 +701,8 @@ ReconView::ReconView(NavigationView& nav)
|
||||
} else if (frequency_range.min > frequency_range.max) {
|
||||
nav_.display_modal("Error", "END freq\nis lower than START");
|
||||
} else {
|
||||
audio::output::stop();
|
||||
|
||||
if (field_mode.selected_index_value() != SPEC_MODULATION)
|
||||
audio::output::stop();
|
||||
// clear and shrink_to_fit are not enough to really start with a new, clean, empty vector
|
||||
// swap is the only way to achieve a perfect memory liberation
|
||||
std::vector<freqman_entry>().swap(frequency_list);
|
||||
@@ -712,7 +731,7 @@ ReconView::ReconView(NavigationView& nav)
|
||||
text_cycle.set_text("1");
|
||||
text_max.set("/1");
|
||||
button_scanner_mode.set_style(&Styles::white);
|
||||
button_scanner_mode.set_text("MSEARCH");
|
||||
button_scanner_mode.set_text("MANUAL");
|
||||
file_name.set_style(&Styles::white);
|
||||
file_name.set("MANUAL RANGE RECON");
|
||||
desc_cycle.set_style(&Styles::white);
|
||||
@@ -757,12 +776,15 @@ ReconView::ReconView(NavigationView& nav)
|
||||
if (scanner_mode) {
|
||||
file_name.set_style(&Styles::red);
|
||||
button_scanner_mode.set_style(&Styles::red);
|
||||
button_scanner_mode.set_text("SCANNER");
|
||||
button_scanner_mode.set_text("SCAN");
|
||||
} else {
|
||||
file_name.set_style(&Styles::blue);
|
||||
button_scanner_mode.set_style(&Styles::blue);
|
||||
button_scanner_mode.set_text("RECON");
|
||||
}
|
||||
if (frequency_list.size() > FREQMAN_MAX_PER_FILE) {
|
||||
file_name.set_style(&Styles::yellow);
|
||||
}
|
||||
};
|
||||
|
||||
button_add.on_select = [this](ButtonWithEncoder&) { // frequency_list[current_index]
|
||||
@@ -786,7 +808,7 @@ ReconView::ReconView(NavigationView& nav)
|
||||
} else {
|
||||
scanner_mode = true;
|
||||
button_scanner_mode.set_style(&Styles::red);
|
||||
button_scanner_mode.set_text("SCANNER");
|
||||
button_scanner_mode.set_text("SCAN");
|
||||
button_scanner_mode.set_text("REMOVE");
|
||||
}
|
||||
frequency_file_load(true);
|
||||
@@ -798,11 +820,13 @@ ReconView::ReconView(NavigationView& nav)
|
||||
};
|
||||
|
||||
button_config.on_select = [this, &nav](Button&) {
|
||||
if (is_recording) // disabling config while recording
|
||||
return;
|
||||
clear_freqlist_for_ui_action();
|
||||
|
||||
freq_lock = 0;
|
||||
timer = 0;
|
||||
auto open_view = nav.push<ReconSetupView>(input_file, output_file);
|
||||
open_view->on_changed = [this](std::vector<std::string> result) {
|
||||
freqlist_cleared_for_ui_action = false;
|
||||
input_file = result[0];
|
||||
output_file = result[1];
|
||||
freq_file_path = "/FREQMAN/" + output_file + ".TXT";
|
||||
@@ -815,8 +839,10 @@ ReconView::ReconView(NavigationView& nav)
|
||||
load_ranges = persistent_memory::recon_load_ranges();
|
||||
load_hamradios = persistent_memory::recon_load_hamradios();
|
||||
update_ranges = persistent_memory::recon_update_ranges_when_recon();
|
||||
auto_record_locked = persistent_memory::recon_auto_record_locked();
|
||||
|
||||
frequency_file_load(false);
|
||||
freqlist_cleared_for_ui_action = false;
|
||||
|
||||
if (autostart) {
|
||||
recon_resume();
|
||||
@@ -833,6 +859,9 @@ ReconView::ReconView(NavigationView& nav)
|
||||
|
||||
field_wait.on_change = [this](int32_t v) {
|
||||
wait = v;
|
||||
// replacing -100 by 200 else it's freezing the device
|
||||
if (wait == -100)
|
||||
wait = -200;
|
||||
colorize_waits();
|
||||
};
|
||||
|
||||
@@ -891,40 +920,36 @@ ReconView::ReconView(NavigationView& nav)
|
||||
|
||||
void ReconView::frequency_file_load(bool stop_all_before) {
|
||||
(void)(stop_all_before);
|
||||
audio::output::stop();
|
||||
if (field_mode.selected_index_value() != SPEC_MODULATION)
|
||||
audio::output::stop();
|
||||
|
||||
def_step = step_mode.selected_index(); // use def_step from manual selector
|
||||
// clear and shrink_to_fit are not enough to really start with a new, clean, empty vector
|
||||
// swap is the only way to achieve a perfect memory liberation
|
||||
std::vector<freqman_entry>().swap(frequency_list); // clear the existing frequency list (expected behavior)
|
||||
std::string file_input = input_file; // default recon mode
|
||||
std::string file_input = input_file; // default recon mode
|
||||
if (scanner_mode) {
|
||||
file_input = output_file;
|
||||
file_name.set_style(&Styles::red);
|
||||
button_scanner_mode.set_style(&Styles::red);
|
||||
button_scanner_mode.set_text("SCANNER");
|
||||
desc_cycle.set_style(&Styles::red);
|
||||
button_scanner_mode.set_text("SCAN");
|
||||
} else {
|
||||
file_name.set_style(&Styles::blue);
|
||||
button_scanner_mode.set_style(&Styles::blue);
|
||||
desc_cycle.set_style(&Styles::blue);
|
||||
button_scanner_mode.set_text("RECON");
|
||||
}
|
||||
desc_cycle.set_style(&Styles::white);
|
||||
if (!load_freqman_file_ex(file_input, frequency_list, load_freqs, load_ranges, load_hamradios, RECON_FREQMAN_MAX_PER_FILE)) {
|
||||
if (!load_freqman_file(file_input, frequency_list, load_freqs, load_ranges, load_hamradios)) {
|
||||
file_name.set_style(&Styles::red);
|
||||
desc_cycle.set_style(&Styles::red);
|
||||
desc_cycle.set(" NO " + file_input + ".TXT FILE ...");
|
||||
file_name.set("=> NO DATA");
|
||||
} else {
|
||||
file_name.set(file_input + "=>" + output_file);
|
||||
if (frequency_list.size() == 0) {
|
||||
file_name.set_style(&Styles::red);
|
||||
desc_cycle.set_style(&Styles::red);
|
||||
desc_cycle.set("/0 no entries in list");
|
||||
file_name.set("BadOrEmpty " + file_input);
|
||||
} else {
|
||||
if (frequency_list.size() > RECON_FREQMAN_MAX_PER_FILE) {
|
||||
if (frequency_list.size() > FREQMAN_MAX_PER_FILE) {
|
||||
file_name.set_style(&Styles::yellow);
|
||||
desc_cycle.set_style(&Styles::yellow);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -998,6 +1023,25 @@ void ReconView::frequency_file_load(bool stop_all_before) {
|
||||
}
|
||||
|
||||
void ReconView::on_statistics_update(const ChannelStatistics& statistics) {
|
||||
systime_t time_interval = 100;
|
||||
uint32_t local_recon_lock_duration = recon_lock_duration;
|
||||
|
||||
chrono_end = chTimeNow();
|
||||
if (field_mode.selected_index_value() == SPEC_MODULATION) {
|
||||
time_interval = chrono_end - chrono_start;
|
||||
// capping here to avoid double check a frequency because time_interval is more than exactly 100 by a few units
|
||||
// this is because we are making a measurement and not using a fixed value
|
||||
if (time_interval > 100)
|
||||
time_interval = 100;
|
||||
if (field_lock_wait.value() == 0) {
|
||||
if (time_interval <= 1) // capping here to avoid freeze because too quick
|
||||
local_recon_lock_duration = 2; // minimum working tested value
|
||||
else
|
||||
local_recon_lock_duration = time_interval;
|
||||
}
|
||||
}
|
||||
chrono_start = chrono_end;
|
||||
|
||||
// hack to reload the list if it was cleared by going into CONFIG
|
||||
if (freqlist_cleared_for_ui_action) {
|
||||
if (!manual_mode) {
|
||||
@@ -1016,7 +1060,7 @@ void ReconView::on_statistics_update(const ChannelStatistics& statistics) {
|
||||
status = 0;
|
||||
continuous_lock = false;
|
||||
freq_lock = 0;
|
||||
timer = recon_lock_duration;
|
||||
timer = local_recon_lock_duration;
|
||||
big_display.set_style(&Styles::white);
|
||||
}
|
||||
if (freq_lock < recon_lock_nb_match) // LOCKING
|
||||
@@ -1024,7 +1068,9 @@ void ReconView::on_statistics_update(const ChannelStatistics& statistics) {
|
||||
if (status != 1) {
|
||||
status = 1;
|
||||
if (wait != 0) {
|
||||
audio::output::stop();
|
||||
recon_stop_recording();
|
||||
if (field_mode.selected_index_value() != SPEC_MODULATION)
|
||||
audio::output::stop();
|
||||
}
|
||||
}
|
||||
if (db > squelch) // MATCHING LEVEL
|
||||
@@ -1046,8 +1092,24 @@ void ReconView::on_statistics_update(const ChannelStatistics& statistics) {
|
||||
if (status != 2) {
|
||||
continuous_lock = false;
|
||||
status = 2;
|
||||
// FREQ IS STRONG: GREEN and recon will pause when on_statistics_update()
|
||||
if ((!scanner_mode) && autosave && frequency_list.size() > 0) {
|
||||
recon_save_freq(freq_file_path, current_index, false);
|
||||
}
|
||||
if (wait != 0) {
|
||||
audio_output_start();
|
||||
if (field_mode.selected_index_value() != SPEC_MODULATION)
|
||||
audio_output_start();
|
||||
// contents of a possible recon_start_recording(), but not yet since it's only called once
|
||||
if (auto_record_locked && !is_recording) {
|
||||
button_audio_app.set_style(&Styles::red);
|
||||
record_view->start();
|
||||
button_config.set_style(&Styles::light_grey); // disable config while recording as it's causing an IO error pop up at exit
|
||||
is_recording = true;
|
||||
}
|
||||
// FREQ IS STRONG: GREEN and recon will pause when on_statistics_update()
|
||||
if ((!scanner_mode) && autosave && frequency_list.size() > 0) {
|
||||
recon_save_freq(freq_file_path, current_index, false);
|
||||
}
|
||||
}
|
||||
if (wait >= 0) {
|
||||
timer = wait;
|
||||
@@ -1066,8 +1128,9 @@ void ReconView::on_statistics_update(const ChannelStatistics& statistics) {
|
||||
text_timer.set("TIMER: " + to_string_dec_int(timer));
|
||||
}
|
||||
if (timer) {
|
||||
if (!continuous_lock || recon_match_mode == RECON_MATCH_SPARSE)
|
||||
timer -= STATS_UPDATE_INTERVAL;
|
||||
if (!continuous_lock || recon_match_mode == RECON_MATCH_SPARSE) {
|
||||
timer -= time_interval;
|
||||
}
|
||||
if (timer < 0) {
|
||||
timer = 0;
|
||||
}
|
||||
@@ -1078,7 +1141,6 @@ void ReconView::on_statistics_update(const ChannelStatistics& statistics) {
|
||||
if (frequency_list.size() > 0) {
|
||||
has_looped = false;
|
||||
entry_has_changed = false;
|
||||
|
||||
if (recon || stepper != 0 || index_stepper != 0) {
|
||||
if (index_stepper == 0) {
|
||||
/* we are doing a range */
|
||||
@@ -1178,7 +1240,8 @@ void ReconView::on_statistics_update(const ChannelStatistics& statistics) {
|
||||
|
||||
entry_has_changed = true;
|
||||
|
||||
if (!recon) // for some motive, audio output gets stopped.
|
||||
// for some motive, audio output gets stopped.
|
||||
if (!recon && field_mode.selected_index_value() != SPEC_MODULATION)
|
||||
audio_output_start();
|
||||
}
|
||||
// reload entry if changed
|
||||
@@ -1230,7 +1293,8 @@ void ReconView::recon_pause() {
|
||||
continuous_lock = false;
|
||||
recon = false;
|
||||
|
||||
audio_output_start();
|
||||
if (field_mode.selected_index_value() != SPEC_MODULATION)
|
||||
audio_output_start();
|
||||
|
||||
big_display.set_style(&Styles::white);
|
||||
button_pause.set_text("<RESUME>"); // PAUSED, show resume
|
||||
@@ -1242,7 +1306,8 @@ void ReconView::recon_resume() {
|
||||
continuous_lock = false;
|
||||
recon = true;
|
||||
|
||||
audio::output::stop();
|
||||
if (field_mode.selected_index_value() != SPEC_MODULATION)
|
||||
audio::output::stop();
|
||||
|
||||
big_display.set_style(&Styles::white);
|
||||
button_pause.set_text("<PAUSE>");
|
||||
@@ -1283,10 +1348,28 @@ void ReconView::on_stepper_delta(int32_t v) {
|
||||
size_t ReconView::change_mode(freqman_index_t new_mod) {
|
||||
field_mode.on_change = [this](size_t, OptionsField::value_t) {};
|
||||
field_bw.on_change = [this](size_t, OptionsField::value_t) {};
|
||||
|
||||
recon_stop_recording();
|
||||
remove_child(record_view.get());
|
||||
record_view.reset();
|
||||
if (new_mod == SPEC_MODULATION) {
|
||||
audio::output::stop();
|
||||
record_view = std::make_unique<RecordView>(Rect{0, 0, 30 * 8, 1 * 16},
|
||||
u"AUTO_RAW_", u"CAPTURES",
|
||||
RecordView::FileType::RawS16, 16384, 3);
|
||||
} else {
|
||||
record_view = std::make_unique<RecordView>(Rect{0, 0, 30 * 8, 1 * 16},
|
||||
u"AUTO_AUDIO_", u"AUDIO",
|
||||
RecordView::FileType::WAV, 4096, 4);
|
||||
}
|
||||
add_child(record_view.get());
|
||||
record_view->hidden(true);
|
||||
record_view->set_filename_date_frequency(true);
|
||||
record_view->on_error = [this](std::string message) {
|
||||
nav_.display_modal("Error", message);
|
||||
};
|
||||
receiver_model.disable();
|
||||
baseband::shutdown();
|
||||
|
||||
size_t recording_sampling_rate = 0;
|
||||
switch (new_mod) {
|
||||
case AM_MODULATION:
|
||||
freqman_set_bandwidth_option(new_mod, field_bw);
|
||||
@@ -1297,6 +1380,7 @@ size_t ReconView::change_mode(freqman_index_t new_mod) {
|
||||
receiver_model.set_am_configuration(field_bw.selected_index_value());
|
||||
field_bw.on_change = [this](size_t, OptionsField::value_t n) { receiver_model.set_am_configuration(n); };
|
||||
text_ctcss.set(" ");
|
||||
recording_sampling_rate = 12000;
|
||||
break;
|
||||
case NFM_MODULATION:
|
||||
freqman_set_bandwidth_option(new_mod, field_bw);
|
||||
@@ -1306,6 +1390,7 @@ size_t ReconView::change_mode(freqman_index_t new_mod) {
|
||||
receiver_model.set_modulation(ReceiverModel::Mode::NarrowbandFMAudio);
|
||||
receiver_model.set_nbfm_configuration(field_bw.selected_index_value());
|
||||
field_bw.on_change = [this](size_t, OptionsField::value_t n) { receiver_model.set_nbfm_configuration(n); };
|
||||
recording_sampling_rate = 24000;
|
||||
break;
|
||||
case WFM_MODULATION:
|
||||
freqman_set_bandwidth_option(new_mod, field_bw);
|
||||
@@ -1316,18 +1401,40 @@ size_t ReconView::change_mode(freqman_index_t new_mod) {
|
||||
receiver_model.set_wfm_configuration(field_bw.selected_index_value());
|
||||
field_bw.on_change = [this](size_t, OptionsField::value_t n) { receiver_model.set_wfm_configuration(n); };
|
||||
text_ctcss.set(" ");
|
||||
recording_sampling_rate = 48000;
|
||||
break;
|
||||
case SPEC_MODULATION:
|
||||
freqman_set_bandwidth_option(new_mod, field_bw);
|
||||
// bw 200k (0) default
|
||||
baseband::run_image(portapack::spi_flash::image_tag_capture);
|
||||
receiver_model.set_modulation(ReceiverModel::Mode::Capture);
|
||||
field_bw.set_by_value(0);
|
||||
field_bw.on_change = [this](size_t, OptionsField::value_t sampling_rate) {
|
||||
auto anti_alias_baseband_bandwidth_filter = filter_bandwidth_for_sampling_rate(sampling_rate);
|
||||
record_view->set_sampling_rate(sampling_rate);
|
||||
receiver_model.set_sampling_rate(sampling_rate);
|
||||
receiver_model.set_baseband_bandwidth(anti_alias_baseband_bandwidth_filter);
|
||||
};
|
||||
text_ctcss.set(" ");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (new_mod != SPEC_MODULATION) {
|
||||
record_view->set_sampling_rate(recording_sampling_rate);
|
||||
// reset receiver model to fix bug when going from SPEC to audio, the sound is distorded
|
||||
receiver_model.set_sampling_rate(3072000);
|
||||
receiver_model.set_baseband_bandwidth(1750000);
|
||||
}
|
||||
|
||||
field_mode.set_selected_index(new_mod);
|
||||
field_mode.on_change = [this](size_t, OptionsField::value_t v) {
|
||||
if (v != -1) {
|
||||
change_mode(v);
|
||||
}
|
||||
};
|
||||
|
||||
if (!recon) // for some motive, audio output gets stopped.
|
||||
// for some motive, audio output gets stopped.
|
||||
if (!recon && field_mode.selected_index_value() != SPEC_MODULATION)
|
||||
audio::output::start(); // so if recon was stopped we resume audio
|
||||
receiver_model.enable();
|
||||
|
||||
@@ -1335,32 +1442,10 @@ size_t ReconView::change_mode(freqman_index_t new_mod) {
|
||||
}
|
||||
|
||||
void ReconView::handle_coded_squelch(const uint32_t value) {
|
||||
float diff{0.0};
|
||||
float min_diff{(float)value};
|
||||
size_t min_idx{0};
|
||||
size_t c{0};
|
||||
|
||||
if (field_mode.selected_index() != NFM_MODULATION) {
|
||||
if (field_mode.selected_index() == NFM_MODULATION)
|
||||
text_ctcss.set(tone_key_string_by_value(value, text_ctcss.parent_rect().width() / 8));
|
||||
else
|
||||
text_ctcss.set(" ");
|
||||
return;
|
||||
}
|
||||
|
||||
// Find nearest match
|
||||
for (c = 0; c < tone_keys.size(); c++) {
|
||||
diff = abs(((float)value / 100.0) - tone_keys[c].second);
|
||||
if (diff < min_diff) {
|
||||
min_idx = c;
|
||||
min_diff = diff;
|
||||
}
|
||||
}
|
||||
|
||||
// Arbitrary confidence threshold
|
||||
if (last_squelch_index < 0 || (unsigned)last_squelch_index != min_idx) {
|
||||
last_squelch_index = min_idx;
|
||||
if (min_diff < 40)
|
||||
text_ctcss.set("T: " + tone_keys[min_idx].first);
|
||||
else
|
||||
text_ctcss.set(" ");
|
||||
}
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
namespace ui {
|
||||
|
||||
#define RECON_CFG_FILE "SETTINGS/recon.cfg"
|
||||
#define RECON_FREQMAN_MAX_PER_FILE 99 // maximum tested limit for load frequency from freqman to work
|
||||
|
||||
class ReconView : public View {
|
||||
public:
|
||||
@@ -85,6 +84,8 @@ class ReconView : public View {
|
||||
bool recon_load_config_from_sd();
|
||||
bool recon_save_config_to_sd();
|
||||
bool recon_save_freq(const std::string& freq_file_path, size_t index, bool warn_if_exists);
|
||||
// placeholder for possible void recon_start_recording();
|
||||
void recon_stop_recording();
|
||||
|
||||
jammer::jammer_range_t frequency_range{false, 0, MAX_UFREQ}; // perfect for manual recon task too...
|
||||
int32_t squelch{0};
|
||||
@@ -109,6 +110,8 @@ class ReconView : public View {
|
||||
bool fwd{true};
|
||||
bool recon{true};
|
||||
bool user_pause{false};
|
||||
bool auto_record_locked{false};
|
||||
bool is_recording{false};
|
||||
uint32_t recon_lock_nb_match{3};
|
||||
uint32_t recon_lock_duration{RECON_MIN_LOCK_DURATION};
|
||||
uint32_t recon_match_mode{RECON_MATCH_CONTINUOUS};
|
||||
@@ -119,10 +122,7 @@ class ReconView : public View {
|
||||
int32_t index_stepper{0};
|
||||
int64_t freq{0};
|
||||
uint32_t step{0};
|
||||
freqman_index_t def_modulation{0};
|
||||
freqman_index_t def_bandwidth{0};
|
||||
freqman_index_t def_step{0};
|
||||
tone_index tone{0};
|
||||
freqman_entry last_entry{};
|
||||
bool entry_has_changed{false};
|
||||
uint32_t freq_lock{0};
|
||||
@@ -139,16 +139,19 @@ class ReconView : public View {
|
||||
int8_t last_rssi_med{-127};
|
||||
int8_t last_rssi_max{-127};
|
||||
int32_t last_index{-1};
|
||||
int32_t last_squelch_index{-1};
|
||||
int64_t last_freq{0};
|
||||
std::string freq_file_path{};
|
||||
systime_t chrono_start{};
|
||||
systime_t chrono_end{};
|
||||
|
||||
std::unique_ptr<RecordView> record_view{};
|
||||
|
||||
Labels labels{
|
||||
{{0 * 8, 0 * 16}, "LNA: VGA: AMP: VOL: ", Color::light_grey()},
|
||||
{{3 * 8, 8 * 16}, "START END", Color::light_grey()},
|
||||
{{0 * 8, (22 * 8)}, " S: ", Color::light_grey()},
|
||||
{{0 * 8, (24 * 8) + 4}, "NBLCKS:x W,L: , ", Color::light_grey()},
|
||||
{{0 * 8, (26 * 8) + 4}, "MODE: , SQUELCH: ", Color::light_grey()}};
|
||||
{{0 * 8, (26 * 8) + 4}, "MODE: , SQUELCH: ", Color::light_grey()}};
|
||||
|
||||
LNAGainField field_lna{
|
||||
{4 * 8, 0 * 16}};
|
||||
@@ -266,18 +269,18 @@ class ReconView : public View {
|
||||
NumberField field_lock_wait{
|
||||
{25 * 8, 24 * 8 + 4},
|
||||
4,
|
||||
{RECON_MIN_LOCK_DURATION, RECON_MAX_LOCK_DURATION},
|
||||
{0, RECON_MAX_LOCK_DURATION},
|
||||
STATS_UPDATE_INTERVAL,
|
||||
' ',
|
||||
};
|
||||
|
||||
OptionsField field_mode{
|
||||
{6 * 8, (26 * 8) + 4},
|
||||
3,
|
||||
4,
|
||||
{}};
|
||||
|
||||
OptionsField field_bw{
|
||||
{10 * 8, (26 * 8) + 4},
|
||||
{11 * 8, (26 * 8) + 4},
|
||||
6,
|
||||
{}};
|
||||
|
||||
|
||||
@@ -103,6 +103,7 @@ void ReconSetupViewMore::save() {
|
||||
persistent_memory::set_recon_load_ranges(checkbox_load_ranges.value());
|
||||
persistent_memory::set_recon_load_hamradios(checkbox_load_hamradios.value());
|
||||
persistent_memory::set_recon_update_ranges_when_recon(checkbox_update_ranges_when_recon.value());
|
||||
persistent_memory::set_recon_auto_record_locked(checkbox_auto_record_locked.value());
|
||||
};
|
||||
|
||||
void ReconSetupViewMain::focus() {
|
||||
@@ -117,12 +118,14 @@ ReconSetupViewMore::ReconSetupViewMore(NavigationView& nav, Rect parent_rect)
|
||||
add_children({&checkbox_load_freqs,
|
||||
&checkbox_load_ranges,
|
||||
&checkbox_load_hamradios,
|
||||
&checkbox_update_ranges_when_recon});
|
||||
&checkbox_update_ranges_when_recon,
|
||||
&checkbox_auto_record_locked});
|
||||
|
||||
checkbox_load_freqs.set_value(persistent_memory::recon_load_freqs());
|
||||
checkbox_load_ranges.set_value(persistent_memory::recon_load_ranges());
|
||||
checkbox_load_hamradios.set_value(persistent_memory::recon_load_hamradios());
|
||||
checkbox_update_ranges_when_recon.set_value(persistent_memory::recon_update_ranges_when_recon());
|
||||
checkbox_auto_record_locked.set_value(persistent_memory::recon_auto_record_locked());
|
||||
};
|
||||
|
||||
void ReconSetupViewMore::focus() {
|
||||
|
||||
@@ -132,6 +132,10 @@ class ReconSetupViewMore : public View {
|
||||
{1 * 8, 102},
|
||||
3,
|
||||
"auto update m-ranges"};
|
||||
Checkbox checkbox_auto_record_locked{
|
||||
{1 * 8, 132},
|
||||
3,
|
||||
"record locked periods"};
|
||||
};
|
||||
|
||||
class ReconSetupView : public View {
|
||||
|
||||
@@ -392,16 +392,17 @@ ScannerView::ScannerView(
|
||||
button_audio_app.on_select = [this](Button&) {
|
||||
if (scan_thread)
|
||||
scan_thread->stop();
|
||||
nav_.pop();
|
||||
nav_.push<AnalogAudioView>();
|
||||
auto settings = receiver_model.settings();
|
||||
settings.frequency_step = field_step.selected_index_value();
|
||||
nav_.replace<AnalogAudioView>(settings);
|
||||
};
|
||||
|
||||
// Button to switch to Mic app
|
||||
button_mic_app.on_select = [this](Button&) {
|
||||
if (scan_thread)
|
||||
scan_thread->stop();
|
||||
nav_.pop();
|
||||
nav_.push<MicTXView>();
|
||||
// MicTX wants Modulation and Bandwidth overrides, but that's only stored on the RX model.
|
||||
nav_.replace<MicTXView>(receiver_model.settings());
|
||||
};
|
||||
|
||||
// Button to delete current frequency from scan Freq List
|
||||
@@ -447,6 +448,16 @@ ScannerView::ScannerView(
|
||||
|
||||
// Mode field was changed (AM/NFM/WFM)
|
||||
field_mode.on_change = [this](size_t, OptionsField::value_t v) {
|
||||
static freqman_index_t last_mode = AM_MODULATION;
|
||||
// unsupported SPEC mode fix
|
||||
if (v == SPEC_MODULATION) {
|
||||
if (last_mode == AM_MODULATION)
|
||||
v = WFM_MODULATION;
|
||||
else
|
||||
v = AM_MODULATION;
|
||||
field_mode.set_selected_index(v);
|
||||
}
|
||||
last_mode = v;
|
||||
receiver_model.disable();
|
||||
baseband::shutdown();
|
||||
change_mode((freqman_index_t)v);
|
||||
|
||||
@@ -122,17 +122,7 @@ void SearchView::do_detection() {
|
||||
locked = true;
|
||||
locked_bin = bin_max;
|
||||
|
||||
// TODO
|
||||
/*nav_.pop();
|
||||
receiver_model.disable();
|
||||
baseband::shutdown();
|
||||
nav_.pop();*/
|
||||
|
||||
/*if (options_goto.selected_index() == 1)
|
||||
nav_.push<AnalogAudioView>(false);
|
||||
else if (options_goto.selected_index() == 2)
|
||||
nav_.push<POCSAGAppView>();
|
||||
*/
|
||||
// TODO: open Audio.
|
||||
} else
|
||||
text_infos.set("Out of range");
|
||||
}
|
||||
@@ -414,7 +404,6 @@ SearchView::SearchView(
|
||||
|
||||
on_range_changed();
|
||||
|
||||
receiver_model.set_modulation(ReceiverModel::Mode::SpectrumAnalysis);
|
||||
receiver_model.enable();
|
||||
}
|
||||
|
||||
|
||||
@@ -92,8 +92,8 @@ class SearchView : public View {
|
||||
NavigationView& nav_;
|
||||
RxRadioState radio_state_{
|
||||
2500000 /* bandwidth */,
|
||||
SEARCH_SLICE_WIDTH /* sampling rate */
|
||||
};
|
||||
SEARCH_SLICE_WIDTH /* sampling rate */,
|
||||
ReceiverModel::Mode::SpectrumAnalysis};
|
||||
|
||||
struct slice_t {
|
||||
rf::Frequency center_frequency;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "ui_settings.hpp"
|
||||
|
||||
#include "ui_navigation.hpp"
|
||||
#include "ui_receiver.hpp"
|
||||
#include "ui_touch_calibration.hpp"
|
||||
|
||||
#include "portapack_persistent_memory.hpp"
|
||||
@@ -32,16 +33,27 @@ using namespace lpc43xx;
|
||||
|
||||
#include "audio.hpp"
|
||||
#include "portapack.hpp"
|
||||
using portapack::receiver_model;
|
||||
using namespace portapack;
|
||||
|
||||
#include "file.hpp"
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
#include "string_format.hpp"
|
||||
#include "ui_styles.hpp"
|
||||
#include "cpld_update.hpp"
|
||||
|
||||
#include "freqman.hpp"
|
||||
namespace pmem = portapack::persistent_memory;
|
||||
|
||||
namespace ui {
|
||||
|
||||
/* Sends a UI refresh message to cause the status bar to redraw. */
|
||||
static void send_system_refresh() {
|
||||
StatusRefreshMessage message{};
|
||||
EventDispatcher::send_message(message);
|
||||
}
|
||||
|
||||
/* SetDateTimeView ***************************************/
|
||||
|
||||
SetDateTimeView::SetDateTimeView(
|
||||
NavigationView& nav) {
|
||||
button_save.on_select = [&nav, this](Button&) {
|
||||
@@ -105,13 +117,15 @@ SetDateTimeModel SetDateTimeView::form_collect() {
|
||||
.second = static_cast<uint8_t>(field_second.value())};
|
||||
}
|
||||
|
||||
/* SetRadioView ******************************************/
|
||||
|
||||
SetRadioView::SetRadioView(
|
||||
NavigationView& nav) {
|
||||
button_cancel.on_select = [&nav](Button&) {
|
||||
nav.pop();
|
||||
};
|
||||
|
||||
const auto reference = portapack::clock_manager.get_reference();
|
||||
const auto reference = clock_manager.get_reference();
|
||||
|
||||
std::string source_name("---");
|
||||
switch (reference.source) {
|
||||
@@ -156,19 +170,18 @@ SetRadioView::SetRadioView(
|
||||
&button_cancel});
|
||||
|
||||
SetFrequencyCorrectionModel model{
|
||||
static_cast<int8_t>(portapack::persistent_memory::correction_ppb() / 1000), 0};
|
||||
static_cast<int8_t>(pmem::correction_ppb() / 1000), 0};
|
||||
|
||||
form_init(model);
|
||||
|
||||
check_clkout.set_value(portapack::persistent_memory::clkout_enabled());
|
||||
check_clkout.set_value(pmem::clkout_enabled());
|
||||
check_clkout.on_select = [this](Checkbox&, bool v) {
|
||||
clock_manager.enable_clock_output(v);
|
||||
portapack::persistent_memory::set_clkout_enabled(v);
|
||||
StatusRefreshMessage message{};
|
||||
EventDispatcher::send_message(message);
|
||||
pmem::set_clkout_enabled(v);
|
||||
send_system_refresh();
|
||||
};
|
||||
|
||||
field_clkout_freq.set_value(portapack::persistent_memory::clkout_freq());
|
||||
field_clkout_freq.set_value(pmem::clkout_freq());
|
||||
value_freq_step.set_style(&Styles::light_grey);
|
||||
|
||||
field_clkout_freq.on_select = [this](NumberField&) {
|
||||
@@ -193,9 +206,9 @@ SetRadioView::SetRadioView(
|
||||
field_clkout_freq.set_step(pow(10, freq_step_khz));
|
||||
};
|
||||
|
||||
check_bias.set_value(portapack::get_antenna_bias());
|
||||
check_bias.set_value(get_antenna_bias());
|
||||
check_bias.on_select = [this](Checkbox&, bool v) {
|
||||
portapack::set_antenna_bias(v);
|
||||
set_antenna_bias(v);
|
||||
|
||||
// Update the radio.
|
||||
receiver_model.set_antenna_bias();
|
||||
@@ -205,15 +218,14 @@ SetRadioView::SetRadioView(
|
||||
if (!v)
|
||||
radio::set_antenna_bias(false);
|
||||
|
||||
StatusRefreshMessage message{};
|
||||
EventDispatcher::send_message(message);
|
||||
send_system_refresh();
|
||||
};
|
||||
|
||||
button_save.on_select = [this, &nav](Button&) {
|
||||
const auto model = this->form_collect();
|
||||
portapack::persistent_memory::set_correction_ppb(model.ppm * 1000);
|
||||
portapack::persistent_memory::set_clkout_freq(model.freq);
|
||||
clock_manager.enable_clock_output(portapack::persistent_memory::clkout_enabled());
|
||||
pmem::set_correction_ppb(model.ppm * 1000);
|
||||
pmem::set_clkout_freq(model.freq);
|
||||
clock_manager.enable_clock_output(pmem::clkout_enabled());
|
||||
nav.pop();
|
||||
};
|
||||
}
|
||||
@@ -233,6 +245,8 @@ SetFrequencyCorrectionModel SetRadioView::form_collect() {
|
||||
};
|
||||
}
|
||||
|
||||
/* SetUIView *********************************************/
|
||||
|
||||
SetUIView::SetUIView(NavigationView& nav) {
|
||||
add_children({&checkbox_disable_touchscreen,
|
||||
&checkbox_bloff,
|
||||
@@ -241,39 +255,76 @@ SetUIView::SetUIView(NavigationView& nav) {
|
||||
&checkbox_showclock,
|
||||
&options_clockformat,
|
||||
&checkbox_guireturnflag,
|
||||
&labels,
|
||||
&toggle_camera,
|
||||
&toggle_sleep,
|
||||
&toggle_stealth,
|
||||
&toggle_converter,
|
||||
&toggle_bias_tee,
|
||||
&toggle_clock,
|
||||
&toggle_mute,
|
||||
&toggle_sd_card,
|
||||
&button_save,
|
||||
&button_cancel});
|
||||
|
||||
checkbox_disable_touchscreen.set_value(persistent_memory::disable_touchscreen());
|
||||
checkbox_showsplash.set_value(persistent_memory::config_splash());
|
||||
checkbox_showclock.set_value(!persistent_memory::hide_clock());
|
||||
checkbox_guireturnflag.set_value(persistent_memory::show_gui_return_icon());
|
||||
// Display "Disable speaker" option only if AK4951 Codec which has separate speaker/headphone control
|
||||
if (audio::speaker_disable_supported()) {
|
||||
add_child(&toggle_speaker);
|
||||
}
|
||||
|
||||
const auto backlight_config = persistent_memory::config_backlight_timer();
|
||||
checkbox_disable_touchscreen.set_value(pmem::disable_touchscreen());
|
||||
checkbox_showsplash.set_value(pmem::config_splash());
|
||||
checkbox_showclock.set_value(!pmem::hide_clock());
|
||||
checkbox_guireturnflag.set_value(pmem::show_gui_return_icon());
|
||||
|
||||
const auto backlight_config = pmem::config_backlight_timer();
|
||||
checkbox_bloff.set_value(backlight_config.timeout_enabled());
|
||||
options_bloff.set_by_value(backlight_config.timeout_enum());
|
||||
|
||||
if (persistent_memory::clock_with_date()) {
|
||||
if (pmem::clock_with_date()) {
|
||||
options_clockformat.set_selected_index(1);
|
||||
} else {
|
||||
options_clockformat.set_selected_index(0);
|
||||
}
|
||||
|
||||
// NB: Invert so "active" == "not hidden"
|
||||
toggle_camera.set_value(!pmem::ui_hide_camera());
|
||||
toggle_sleep.set_value(!pmem::ui_hide_sleep());
|
||||
toggle_stealth.set_value(!pmem::ui_hide_stealth());
|
||||
toggle_converter.set_value(!pmem::ui_hide_converter());
|
||||
toggle_bias_tee.set_value(!pmem::ui_hide_bias_tee());
|
||||
toggle_clock.set_value(!pmem::ui_hide_clock());
|
||||
toggle_speaker.set_value(!pmem::ui_hide_speaker());
|
||||
toggle_mute.set_value(!pmem::ui_hide_mute());
|
||||
toggle_sd_card.set_value(!pmem::ui_hide_sd_card());
|
||||
|
||||
button_save.on_select = [&nav, this](Button&) {
|
||||
persistent_memory::set_config_backlight_timer({(persistent_memory::backlight_timeout_t)options_bloff.selected_index_value(),
|
||||
checkbox_bloff.value()});
|
||||
pmem::set_config_backlight_timer({(pmem::backlight_timeout_t)options_bloff.selected_index_value(),
|
||||
checkbox_bloff.value()});
|
||||
|
||||
if (checkbox_showclock.value()) {
|
||||
if (options_clockformat.selected_index() == 1)
|
||||
persistent_memory::set_clock_with_date(true);
|
||||
pmem::set_clock_with_date(true);
|
||||
else
|
||||
persistent_memory::set_clock_with_date(false);
|
||||
pmem::set_clock_with_date(false);
|
||||
}
|
||||
|
||||
persistent_memory::set_config_splash(checkbox_showsplash.value());
|
||||
persistent_memory::set_clock_hidden(!checkbox_showclock.value());
|
||||
persistent_memory::set_gui_return_icon(checkbox_guireturnflag.value());
|
||||
persistent_memory::set_disable_touchscreen(checkbox_disable_touchscreen.value());
|
||||
pmem::set_config_splash(checkbox_showsplash.value());
|
||||
pmem::set_clock_hidden(!checkbox_showclock.value());
|
||||
pmem::set_gui_return_icon(checkbox_guireturnflag.value());
|
||||
pmem::set_disable_touchscreen(checkbox_disable_touchscreen.value());
|
||||
|
||||
pmem::set_ui_hide_camera(!toggle_camera.value());
|
||||
pmem::set_ui_hide_sleep(!toggle_sleep.value());
|
||||
pmem::set_ui_hide_stealth(!toggle_stealth.value());
|
||||
pmem::set_ui_hide_converter(!toggle_converter.value());
|
||||
pmem::set_ui_hide_bias_tee(!toggle_bias_tee.value());
|
||||
pmem::set_ui_hide_clock(!toggle_clock.value());
|
||||
pmem::set_ui_hide_speaker(!toggle_speaker.value());
|
||||
pmem::set_ui_hide_mute(!toggle_mute.value());
|
||||
pmem::set_ui_hide_sd_card(!toggle_sd_card.value());
|
||||
send_system_refresh();
|
||||
|
||||
nav.pop();
|
||||
};
|
||||
button_cancel.on_select = [&nav, this](Button&) {
|
||||
@@ -285,21 +336,20 @@ void SetUIView::focus() {
|
||||
button_save.focus();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// Appl. Settings
|
||||
// ---------------------------------------------------------
|
||||
/* SetAppSettingsView ************************************/
|
||||
|
||||
SetAppSettingsView::SetAppSettingsView(NavigationView& nav) {
|
||||
add_children({&checkbox_load_app_settings,
|
||||
&checkbox_save_app_settings,
|
||||
&button_save,
|
||||
&button_cancel});
|
||||
|
||||
checkbox_load_app_settings.set_value(persistent_memory::load_app_settings());
|
||||
checkbox_save_app_settings.set_value(persistent_memory::save_app_settings());
|
||||
checkbox_load_app_settings.set_value(pmem::load_app_settings());
|
||||
checkbox_save_app_settings.set_value(pmem::save_app_settings());
|
||||
|
||||
button_save.on_select = [&nav, this](Button&) {
|
||||
persistent_memory::set_load_app_settings(checkbox_load_app_settings.value());
|
||||
persistent_memory::set_save_app_settings(checkbox_save_app_settings.value());
|
||||
pmem::set_load_app_settings(checkbox_load_app_settings.value());
|
||||
pmem::set_save_app_settings(checkbox_save_app_settings.value());
|
||||
nav.pop();
|
||||
};
|
||||
button_cancel.on_select = [&nav, this](Button&) {
|
||||
@@ -311,9 +361,8 @@ void SetAppSettingsView::focus() {
|
||||
button_save.focus();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// Converter Settings
|
||||
// ---------------------------------------------------------
|
||||
/* SetConverterSettingsView ******************************/
|
||||
|
||||
SetConverterSettingsView::SetConverterSettingsView(NavigationView& nav) {
|
||||
add_children({&check_show_converter,
|
||||
&check_converter,
|
||||
@@ -321,46 +370,43 @@ SetConverterSettingsView::SetConverterSettingsView(NavigationView& nav) {
|
||||
&button_converter_freq,
|
||||
&button_return});
|
||||
|
||||
check_show_converter.set_value(!portapack::persistent_memory::config_hide_converter());
|
||||
check_show_converter.set_value(!pmem::ui_hide_converter());
|
||||
check_show_converter.on_select = [this](Checkbox&, bool v) {
|
||||
portapack::persistent_memory::set_config_hide_converter(!v);
|
||||
pmem::set_ui_hide_converter(!v);
|
||||
if (!v) {
|
||||
check_converter.set_value(false);
|
||||
}
|
||||
// Retune to take converter change in account.
|
||||
receiver_model.set_target_frequency(receiver_model.target_frequency());
|
||||
// Refresh status bar with/out converter
|
||||
StatusRefreshMessage message{};
|
||||
EventDispatcher::send_message(message);
|
||||
send_system_refresh();
|
||||
};
|
||||
|
||||
check_converter.set_value(portapack::persistent_memory::config_converter());
|
||||
check_converter.set_value(pmem::config_converter());
|
||||
check_converter.on_select = [this](Checkbox&, bool v) {
|
||||
if (v) {
|
||||
check_show_converter.set_value(true);
|
||||
portapack::persistent_memory::set_config_hide_converter(false);
|
||||
pmem::set_ui_hide_converter(false);
|
||||
}
|
||||
portapack::persistent_memory::set_config_converter(v);
|
||||
pmem::set_config_converter(v);
|
||||
// Retune to take converter change in account
|
||||
receiver_model.set_target_frequency(receiver_model.target_frequency());
|
||||
// Refresh status bar with/out converter
|
||||
StatusRefreshMessage message{};
|
||||
EventDispatcher::send_message(message);
|
||||
send_system_refresh();
|
||||
};
|
||||
|
||||
converter_mode.set_by_value(portapack::persistent_memory::config_updown_converter());
|
||||
converter_mode.set_by_value(pmem::config_updown_converter());
|
||||
converter_mode.on_change = [this](size_t, OptionsField::value_t v) {
|
||||
portapack::persistent_memory::set_config_updown_converter(v);
|
||||
pmem::set_config_updown_converter(v);
|
||||
// Refresh status bar with icon up or down
|
||||
StatusRefreshMessage message{};
|
||||
EventDispatcher::send_message(message);
|
||||
send_system_refresh();
|
||||
};
|
||||
|
||||
button_converter_freq.set_text(to_string_short_freq(portapack::persistent_memory::config_converter_freq()) + "MHz");
|
||||
button_converter_freq.set_text(to_string_short_freq(pmem::config_converter_freq()) + "MHz");
|
||||
button_converter_freq.on_select = [this, &nav](Button& button) {
|
||||
auto new_view = nav.push<FrequencyKeypadView>(portapack::persistent_memory::config_converter_freq());
|
||||
auto new_view = nav.push<FrequencyKeypadView>(pmem::config_converter_freq());
|
||||
new_view->on_changed = [this, &button](rf::Frequency f) {
|
||||
portapack::persistent_memory::set_config_converter_freq(f);
|
||||
pmem::set_config_converter_freq(f);
|
||||
// Retune to take converter change in account
|
||||
receiver_model.set_target_frequency(receiver_model.target_frequency());
|
||||
button_converter_freq.set_text("<" + to_string_short_freq(f) + " MHz>");
|
||||
@@ -376,9 +422,8 @@ void SetConverterSettingsView::focus() {
|
||||
button_return.focus();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// Frequency Correction Settings
|
||||
// ---------------------------------------------------------
|
||||
/* SetFrequencyCorrectionView ****************************/
|
||||
|
||||
SetFrequencyCorrectionView::SetFrequencyCorrectionView(NavigationView& nav) {
|
||||
add_children({&text_freqCorrection_about,
|
||||
&frequency_rx_correction_mode,
|
||||
@@ -387,36 +432,36 @@ SetFrequencyCorrectionView::SetFrequencyCorrectionView(NavigationView& nav) {
|
||||
&button_freq_tx_correction,
|
||||
&button_return});
|
||||
|
||||
frequency_rx_correction_mode.set_by_value(portapack::persistent_memory::config_freq_rx_correction_updown());
|
||||
frequency_rx_correction_mode.set_by_value(pmem::config_freq_rx_correction_updown());
|
||||
frequency_rx_correction_mode.on_change = [this](size_t, OptionsField::value_t v) {
|
||||
portapack::persistent_memory::set_freq_rx_correction_updown(v);
|
||||
pmem::set_freq_rx_correction_updown(v);
|
||||
};
|
||||
|
||||
frequency_tx_correction_mode.set_by_value(portapack::persistent_memory::config_freq_rx_correction_updown());
|
||||
frequency_tx_correction_mode.set_by_value(pmem::config_freq_rx_correction_updown());
|
||||
frequency_tx_correction_mode.on_change = [this](size_t, OptionsField::value_t v) {
|
||||
portapack::persistent_memory::set_freq_tx_correction_updown(v);
|
||||
pmem::set_freq_tx_correction_updown(v);
|
||||
};
|
||||
|
||||
button_freq_rx_correction.set_text(to_string_short_freq(portapack::persistent_memory::config_freq_rx_correction()) + "MHz (Rx)");
|
||||
button_freq_rx_correction.set_text(to_string_short_freq(pmem::config_freq_rx_correction()) + "MHz (Rx)");
|
||||
button_freq_rx_correction.on_select = [this, &nav](Button& button) {
|
||||
auto new_view = nav.push<FrequencyKeypadView>(portapack::persistent_memory::config_converter_freq());
|
||||
auto new_view = nav.push<FrequencyKeypadView>(pmem::config_converter_freq());
|
||||
new_view->on_changed = [this, &button](rf::Frequency f) {
|
||||
if (f >= MAX_FREQ_CORRECTION)
|
||||
f = MAX_FREQ_CORRECTION;
|
||||
portapack::persistent_memory::set_config_freq_rx_correction(f);
|
||||
pmem::set_config_freq_rx_correction(f);
|
||||
// Retune to take converter change in account
|
||||
receiver_model.set_target_frequency(receiver_model.target_frequency());
|
||||
button_freq_rx_correction.set_text("<" + to_string_short_freq(f) + " MHz>");
|
||||
};
|
||||
};
|
||||
|
||||
button_freq_tx_correction.set_text(to_string_short_freq(portapack::persistent_memory::config_freq_tx_correction()) + "MHz (Tx)");
|
||||
button_freq_tx_correction.set_text(to_string_short_freq(pmem::config_freq_tx_correction()) + "MHz (Tx)");
|
||||
button_freq_tx_correction.on_select = [this, &nav](Button& button) {
|
||||
auto new_view = nav.push<FrequencyKeypadView>(portapack::persistent_memory::config_converter_freq());
|
||||
auto new_view = nav.push<FrequencyKeypadView>(pmem::config_converter_freq());
|
||||
new_view->on_changed = [this, &button](rf::Frequency f) {
|
||||
if (f >= MAX_FREQ_CORRECTION)
|
||||
f = MAX_FREQ_CORRECTION;
|
||||
portapack::persistent_memory::set_config_freq_tx_correction(f);
|
||||
pmem::set_config_freq_tx_correction(f);
|
||||
// Retune to take converter change in account
|
||||
receiver_model.set_target_frequency(receiver_model.target_frequency());
|
||||
button_freq_tx_correction.set_text("<" + to_string_short_freq(f) + " MHz>");
|
||||
@@ -432,9 +477,8 @@ void SetFrequencyCorrectionView::focus() {
|
||||
button_return.focus();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// Persistent Memory Settings
|
||||
// ---------------------------------------------------------
|
||||
/* SetPersistentMemoryView *******************************/
|
||||
|
||||
SetPersistentMemoryView::SetPersistentMemoryView(NavigationView& nav) {
|
||||
add_children({&text_pmem_about,
|
||||
&text_pmem_informations,
|
||||
@@ -445,48 +489,42 @@ SetPersistentMemoryView::SetPersistentMemoryView(NavigationView& nav) {
|
||||
&button_load_mem_defaults,
|
||||
&button_return});
|
||||
|
||||
check_use_sdcard_for_pmem.set_value(portapack::persistent_memory::should_use_sdcard_for_pmem());
|
||||
check_use_sdcard_for_pmem.set_value(pmem::should_use_sdcard_for_pmem());
|
||||
check_use_sdcard_for_pmem.on_select = [this](Checkbox&, bool v) {
|
||||
File pmem_flag_file_handle;
|
||||
std::string pmem_flag_file = PMEM_FILEFLAG;
|
||||
if (v) {
|
||||
auto result = pmem_flag_file_handle.open(pmem_flag_file);
|
||||
if (result.is_valid()) {
|
||||
auto result = pmem_flag_file_handle.create(pmem_flag_file); // third: create if it is not there
|
||||
if (!result.is_valid()) {
|
||||
text_pmem_status.set("pmem flag file created");
|
||||
} else {
|
||||
text_pmem_status.set("!err. creating pmem flagfile!");
|
||||
}
|
||||
} else {
|
||||
if (fs::file_exists(PMEM_FILEFLAG)) {
|
||||
text_pmem_status.set("pmem flag already present");
|
||||
} else {
|
||||
auto error = pmem_flag_file_handle.create(PMEM_FILEFLAG);
|
||||
if (error)
|
||||
text_pmem_status.set("!err. creating pmem flagfile!");
|
||||
else
|
||||
text_pmem_status.set("pmem flag file created");
|
||||
}
|
||||
} else {
|
||||
auto result = delete_file(pmem_flag_file);
|
||||
if (result.code() != FR_OK) {
|
||||
auto result = delete_file(PMEM_FILEFLAG);
|
||||
if (result.code() != FR_OK)
|
||||
text_pmem_status.set("!err. deleting pmem flagfile!");
|
||||
} else {
|
||||
else
|
||||
text_pmem_status.set("pmem flag file deleted");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
button_save_mem_to_file.on_select = [&nav, this](Button&) {
|
||||
if (!portapack::persistent_memory::save_persistent_settings_to_file()) {
|
||||
if (!pmem::save_persistent_settings_to_file())
|
||||
text_pmem_status.set("!problem saving settings!");
|
||||
} else {
|
||||
else
|
||||
text_pmem_status.set("settings saved");
|
||||
}
|
||||
};
|
||||
|
||||
button_load_mem_from_file.on_select = [&nav, this](Button&) {
|
||||
if (!portapack::persistent_memory::load_persistent_settings_from_file()) {
|
||||
if (!pmem::load_persistent_settings_from_file()) {
|
||||
text_pmem_status.set("!problem loading settings!");
|
||||
} else {
|
||||
text_pmem_status.set("settings loaded");
|
||||
// Refresh status bar with icon up or down
|
||||
StatusRefreshMessage message{};
|
||||
EventDispatcher::send_message(message);
|
||||
send_system_refresh();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -497,7 +535,7 @@ SetPersistentMemoryView::SetPersistentMemoryView(NavigationView& nav) {
|
||||
YESNO,
|
||||
[this](bool choice) {
|
||||
if (choice) {
|
||||
portapack::persistent_memory::cache::defaults();
|
||||
pmem::cache::defaults();
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -511,22 +549,18 @@ void SetPersistentMemoryView::focus() {
|
||||
button_return.focus();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// Audio Settings
|
||||
// ---------------------------------------------------------
|
||||
/* SetAudioView ******************************************/
|
||||
|
||||
SetAudioView::SetAudioView(NavigationView& nav) {
|
||||
add_children({&labels,
|
||||
&field_tone_mix,
|
||||
&checkbox_speaker_disable,
|
||||
&button_save,
|
||||
&button_cancel});
|
||||
|
||||
field_tone_mix.set_value(persistent_memory::tone_mix());
|
||||
checkbox_speaker_disable.set_value(persistent_memory::config_speaker_disable());
|
||||
field_tone_mix.set_value(pmem::tone_mix());
|
||||
|
||||
button_save.on_select = [&nav, this](Button&) {
|
||||
persistent_memory::set_tone_mix(field_tone_mix.value());
|
||||
persistent_memory::set_config_speaker_disable(checkbox_speaker_disable.value());
|
||||
pmem::set_tone_mix(field_tone_mix.value());
|
||||
audio::output::update_audio_mute();
|
||||
nav.pop();
|
||||
};
|
||||
@@ -540,18 +574,17 @@ void SetAudioView::focus() {
|
||||
button_save.focus();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// QR Code Settings
|
||||
// ------------------------------------------------------
|
||||
/* SetQRCodeView *****************************************/
|
||||
|
||||
SetQRCodeView::SetQRCodeView(NavigationView& nav) {
|
||||
add_children({&checkbox_bigger_qr,
|
||||
&button_save,
|
||||
&button_cancel});
|
||||
|
||||
checkbox_bigger_qr.set_value(persistent_memory::show_bigger_qr_code());
|
||||
checkbox_bigger_qr.set_value(pmem::show_bigger_qr_code());
|
||||
|
||||
button_save.on_select = [&nav, this](Button&) {
|
||||
persistent_memory::set_show_bigger_qr_code(checkbox_bigger_qr.value());
|
||||
pmem::set_show_bigger_qr_code(checkbox_bigger_qr.value());
|
||||
nav.pop();
|
||||
};
|
||||
|
||||
@@ -564,19 +597,18 @@ void SetQRCodeView::focus() {
|
||||
button_save.focus();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// Rotary Encoder Dial Settings
|
||||
// ---------------------------------------------------------
|
||||
/* SetEncoderDialView ************************************/
|
||||
|
||||
SetEncoderDialView::SetEncoderDialView(NavigationView& nav) {
|
||||
add_children({&labels,
|
||||
&field_encoder_dial_sensitivity,
|
||||
&button_save,
|
||||
&button_cancel});
|
||||
|
||||
field_encoder_dial_sensitivity.set_by_value(persistent_memory::config_encoder_dial_sensitivity());
|
||||
field_encoder_dial_sensitivity.set_by_value(pmem::config_encoder_dial_sensitivity());
|
||||
|
||||
button_save.on_select = [&nav, this](Button&) {
|
||||
persistent_memory::set_encoder_dial_sensitivity(field_encoder_dial_sensitivity.selected_index_value());
|
||||
pmem::set_encoder_dial_sensitivity(field_encoder_dial_sensitivity.selected_index_value());
|
||||
nav.pop();
|
||||
};
|
||||
|
||||
@@ -589,11 +621,10 @@ void SetEncoderDialView::focus() {
|
||||
button_save.focus();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// Settings main menu
|
||||
// ---------------------------------------------------------
|
||||
/* SettingsMenuView **************************************/
|
||||
|
||||
SettingsMenuView::SettingsMenuView(NavigationView& nav) {
|
||||
if (portapack::persistent_memory::show_gui_return_icon()) {
|
||||
if (pmem::show_gui_return_icon()) {
|
||||
add_items({{"..", ui::Color::light_grey(), &bitmap_icon_previous, [&nav]() { nav.pop(); }}});
|
||||
}
|
||||
add_items({
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "ui_widget.hpp"
|
||||
#include "ui_menu.hpp"
|
||||
#include "ui_navigation.hpp"
|
||||
#include "bitmap.hpp"
|
||||
#include "ff.h"
|
||||
#include "portapack_persistent_memory.hpp"
|
||||
|
||||
@@ -34,7 +35,7 @@
|
||||
|
||||
namespace ui {
|
||||
|
||||
#define MAX_FREQ_CORRECTION 4294967295 // maximum possible for an uint32_t
|
||||
#define MAX_FREQ_CORRECTION INT32_MAX
|
||||
|
||||
struct SetDateTimeModel {
|
||||
uint16_t year;
|
||||
@@ -208,16 +209,16 @@ class SetUIView : public View {
|
||||
|
||||
private:
|
||||
Checkbox checkbox_disable_touchscreen{
|
||||
{3 * 8, 2 * 16},
|
||||
{3 * 8, 1 * 16},
|
||||
20,
|
||||
"Disable touchscreen"};
|
||||
|
||||
Checkbox checkbox_bloff{
|
||||
{3 * 8, 4 * 16},
|
||||
{3 * 8, 3 * 16},
|
||||
20,
|
||||
"Backlight off after:"};
|
||||
OptionsField options_bloff{
|
||||
{60, 5 * 16 + 8},
|
||||
{60, 4 * 16 + 8},
|
||||
20,
|
||||
{
|
||||
{"5 seconds", backlight_timeout_t::Timeout5Sec},
|
||||
@@ -231,25 +232,65 @@ class SetUIView : public View {
|
||||
}};
|
||||
|
||||
Checkbox checkbox_showsplash{
|
||||
{3 * 8, 7 * 16},
|
||||
{3 * 8, 6 * 16},
|
||||
20,
|
||||
"Show splash"};
|
||||
|
||||
Checkbox checkbox_showclock{
|
||||
{3 * 8, 9 * 16},
|
||||
{3 * 8, 8 * 16},
|
||||
20,
|
||||
"Show clock with:"};
|
||||
|
||||
OptionsField options_clockformat{
|
||||
{60, 10 * 16 + 8},
|
||||
{60, 9 * 16 + 8},
|
||||
20,
|
||||
{{"time only", 0},
|
||||
{"time and date", 1}}};
|
||||
|
||||
Checkbox checkbox_guireturnflag{
|
||||
{3 * 8, 12 * 16},
|
||||
25,
|
||||
"Show return icon in GUI"};
|
||||
{3 * 8, 11 * 16},
|
||||
20,
|
||||
"Back button in menu"};
|
||||
|
||||
Labels labels{
|
||||
{{3 * 8, 13 * 16}, "Show/Hide Status Icons", Color::light_grey()},
|
||||
};
|
||||
|
||||
ImageToggle toggle_camera{
|
||||
{7 * 8, 14 * 16 + 2, 16, 16},
|
||||
&bitmap_icon_camera};
|
||||
|
||||
ImageToggle toggle_sleep{
|
||||
{9 * 8, 14 * 16 + 2, 16, 16},
|
||||
&bitmap_icon_sleep};
|
||||
|
||||
ImageToggle toggle_stealth{
|
||||
{11 * 8, 14 * 16 + 2, 16, 16},
|
||||
&bitmap_icon_stealth};
|
||||
|
||||
ImageToggle toggle_converter{
|
||||
{13 * 8, 14 * 16 + 2, 16, 16},
|
||||
&bitmap_icon_upconvert};
|
||||
|
||||
ImageToggle toggle_bias_tee{
|
||||
{15 * 8, 14 * 16 + 2, 16, 16},
|
||||
&bitmap_icon_biast_off};
|
||||
|
||||
ImageToggle toggle_clock{
|
||||
{17 * 8, 14 * 16 + 2, 8, 16},
|
||||
&bitmap_icon_clk_ext};
|
||||
|
||||
ImageToggle toggle_mute{
|
||||
{18 * 8, 14 * 16 + 2, 16, 16},
|
||||
&bitmap_icon_speaker_and_headphones_mute};
|
||||
|
||||
ImageToggle toggle_speaker{
|
||||
{20 * 8, 14 * 16 + 2, 16, 16},
|
||||
&bitmap_icon_speaker_mute};
|
||||
|
||||
ImageToggle toggle_sd_card{
|
||||
{22 * 8, 14 * 16 + 2, 16, 16},
|
||||
&bitmap_sd_card_ok};
|
||||
|
||||
Button button_save{
|
||||
{2 * 8, 16 * 16, 12 * 8, 32},
|
||||
@@ -388,11 +429,6 @@ class SetAudioView : public View {
|
||||
1,
|
||||
'0'};
|
||||
|
||||
Checkbox checkbox_speaker_disable{
|
||||
{2 * 8, 6 * 16},
|
||||
25,
|
||||
"Disable AK speaker amp"};
|
||||
|
||||
Button button_save{
|
||||
{2 * 8, 16 * 16, 12 * 8, 32},
|
||||
"Save"};
|
||||
|
||||
@@ -57,6 +57,8 @@ SpectrumPainterView::SpectrumPainterView(
|
||||
input_image.set_parent_rect(view_rect);
|
||||
input_text.set_parent_rect(view_rect);
|
||||
|
||||
freqman_set_bandwidth_option(SPEC_MODULATION, option_bandwidth);
|
||||
|
||||
field_frequency.set_step(5000);
|
||||
|
||||
tx_gain = transmitter_model.tx_gain();
|
||||
|
||||
@@ -127,7 +127,7 @@ class SpectrumPainterView : public View {
|
||||
OptionsField option_bandwidth{
|
||||
{4 * 8, footer_location + 2 * 16},
|
||||
5,
|
||||
{BW_OPTIONS}};
|
||||
{}};
|
||||
|
||||
NumberField field_duration{
|
||||
{13 * 8, footer_location + 2 * 16},
|
||||
|
||||
@@ -26,6 +26,8 @@ namespace fs = std::filesystem;
|
||||
|
||||
namespace ui {
|
||||
|
||||
const std::filesystem::path splash_dot_bmp{u"/splash.bmp"};
|
||||
|
||||
ScreenshotViewer::ScreenshotViewer(
|
||||
NavigationView& nav,
|
||||
const std::filesystem::path& path)
|
||||
@@ -40,11 +42,9 @@ bool ScreenshotViewer::on_key(KeyEvent) {
|
||||
}
|
||||
|
||||
void ScreenshotViewer::paint(Painter& painter) {
|
||||
constexpr size_t pixel_width = 240;
|
||||
constexpr size_t pixel_height = 320;
|
||||
File file{};
|
||||
|
||||
painter.fill_rectangle({0, 0, pixel_width, pixel_height}, Color::black());
|
||||
painter.fill_rectangle({0, 0, screen_width, screen_height}, Color::black());
|
||||
|
||||
auto show_invalid = [&]() {
|
||||
painter.draw_string({10, 160}, Styles::white, "Not a valid screenshot.");
|
||||
@@ -65,19 +65,19 @@ void ScreenshotViewer::paint(Painter& painter) {
|
||||
constexpr size_t read_chunk = 80; // NB: must be a factor of pixel_width.
|
||||
constexpr size_t buffer_size = sizeof(ColorRGB888) * read_chunk;
|
||||
uint8_t buffer[buffer_size];
|
||||
std::array<Color, pixel_width> pixel_data;
|
||||
std::array<Color, screen_width> pixel_data;
|
||||
|
||||
// Seek past all the headers.
|
||||
file.seek(43);
|
||||
|
||||
for (auto line = 0u; line < pixel_height; ++line) {
|
||||
for (auto line = 0u; line < screen_height; ++line) {
|
||||
// Seek past the per-line header.
|
||||
file.seek(file.tell() + 6);
|
||||
|
||||
// Per comment in PNGWriter, read in chunks of 80.
|
||||
// NB: Reading in one large chunk caused corruption so there's
|
||||
// likely a bug lurking in the SD Card/FatFs layer.
|
||||
for (auto offset = 0u; offset < pixel_width; offset += read_chunk) {
|
||||
for (auto offset = 0u; offset < screen_width; offset += read_chunk) {
|
||||
auto read = file.read(buffer, buffer_size);
|
||||
|
||||
if (!read || *read != buffer_size) {
|
||||
@@ -92,8 +92,42 @@ void ScreenshotViewer::paint(Painter& painter) {
|
||||
}
|
||||
}
|
||||
|
||||
display.draw_pixels({0, (int)line, pixel_width, 1}, pixel_data);
|
||||
display.draw_pixels({0, (int)line, screen_width, 1}, pixel_data);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
SplashViewer::SplashViewer(
|
||||
NavigationView& nav,
|
||||
const std::filesystem::path& path)
|
||||
: nav_{nav},
|
||||
path_{path} {
|
||||
valid_image = false;
|
||||
set_focusable(true);
|
||||
}
|
||||
|
||||
bool SplashViewer::on_key(const KeyEvent key) {
|
||||
if (valid_image && key == KeyEvent::Right) {
|
||||
delete_file(splash_dot_bmp);
|
||||
copy_file(path_, splash_dot_bmp);
|
||||
}
|
||||
|
||||
nav_.pop();
|
||||
return true;
|
||||
}
|
||||
|
||||
void SplashViewer::paint(Painter& painter) {
|
||||
painter.fill_rectangle({0, 0, screen_width, screen_height}, Color::black());
|
||||
|
||||
if (!portapack::display.drawBMP2({0, 0}, path_)) {
|
||||
painter.draw_string({10, 160}, Styles::white, "Not a valid splash image.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Show option to set splash screen if it's not already the splash screen
|
||||
if (!path_iequal(path_, splash_dot_bmp)) {
|
||||
painter.draw_string({0, 0}, Styles::white, "*RIGHT BUTTON UPDATES SPLASH*");
|
||||
valid_image = true;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
|
||||
namespace ui {
|
||||
|
||||
extern const std::filesystem::path splash_dot_bmp;
|
||||
|
||||
class ScreenshotViewer : public View {
|
||||
public:
|
||||
ScreenshotViewer(NavigationView& nav, const std::filesystem::path& path);
|
||||
@@ -42,6 +44,19 @@ class ScreenshotViewer : public View {
|
||||
std::filesystem::path path_{};
|
||||
};
|
||||
|
||||
class SplashViewer : public View {
|
||||
public:
|
||||
SplashViewer(NavigationView& nav, const std::filesystem::path& path);
|
||||
bool on_key(KeyEvent key) override;
|
||||
void paint(Painter& painter) override;
|
||||
void update_ss(void);
|
||||
|
||||
private:
|
||||
NavigationView& nav_;
|
||||
std::filesystem::path path_{};
|
||||
bool valid_image{};
|
||||
};
|
||||
|
||||
} // namespace ui
|
||||
|
||||
#endif // __UI_SS_VIEWER_H__
|
||||
|
||||
@@ -42,10 +42,9 @@ namespace ui {
|
||||
/* TextViewer *******************************************************/
|
||||
|
||||
TextViewer::TextViewer(Rect parent_rect)
|
||||
: Widget(parent_rect),
|
||||
max_line{static_cast<uint8_t>(parent_rect.height() / char_height)},
|
||||
max_col{static_cast<uint8_t>(parent_rect.width() / char_width)} {
|
||||
: Widget(parent_rect) {
|
||||
set_focusable(true);
|
||||
set_font_zoom(false);
|
||||
}
|
||||
|
||||
void TextViewer::paint(Painter& painter) {
|
||||
@@ -138,6 +137,16 @@ uint32_t TextViewer::offset() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void TextViewer::cursor_home() {
|
||||
cursor_.col = 0;
|
||||
redraw();
|
||||
}
|
||||
|
||||
void TextViewer::cursor_end() {
|
||||
cursor_.col = line_length() - 1;
|
||||
redraw();
|
||||
}
|
||||
|
||||
uint16_t TextViewer::line_length() {
|
||||
return file_->line_length(cursor_.line);
|
||||
}
|
||||
@@ -158,18 +167,14 @@ bool TextViewer::apply_scrolling_constraints(int16_t delta_line, int16_t delta_c
|
||||
++new_line;
|
||||
}
|
||||
|
||||
// Snap to first/last to make navigating easier.
|
||||
if (new_line < 0 && new_col > 0) {
|
||||
// Snap to first/last line to make navigating easier.
|
||||
if (new_line < 0 && cursor_.line > 0) {
|
||||
new_line = 0;
|
||||
new_col = 0;
|
||||
} else if (new_line >= (int32_t)file_->line_count()) {
|
||||
auto last_line = file_->line_count() - 1;
|
||||
int32_t last_col = file_->line_length(last_line) - 1;
|
||||
|
||||
if (new_col < last_col) {
|
||||
if (cursor_.line < last_line)
|
||||
new_line = last_line;
|
||||
new_col = last_col;
|
||||
}
|
||||
}
|
||||
|
||||
if (new_line < 0 || (uint32_t)new_line >= file_->line_count())
|
||||
@@ -177,7 +182,6 @@ bool TextViewer::apply_scrolling_constraints(int16_t delta_line, int16_t delta_c
|
||||
|
||||
new_line_length = file_->line_length(new_line);
|
||||
|
||||
// TODO: don't wrap with encoder?
|
||||
// Wrap or clamp column.
|
||||
if (new_line_length == 0)
|
||||
new_col = 0;
|
||||
@@ -207,7 +211,7 @@ void TextViewer::paint_text(Painter& painter, uint32_t line, uint16_t col) {
|
||||
if (result && *result > 0)
|
||||
painter.draw_string(
|
||||
{0, r.top() + (int)i * char_height},
|
||||
Styles::white_small, {buffer, *result});
|
||||
style(), {buffer, *result});
|
||||
|
||||
// Clear empty line sections. This is less visually jarring than full clear.
|
||||
int32_t clear_width = max_col - (result ? *result : 0);
|
||||
@@ -216,7 +220,7 @@ void TextViewer::paint_text(Painter& painter, uint32_t line, uint16_t col) {
|
||||
{(max_col - clear_width) * char_width,
|
||||
r.top() + (int)i * char_height,
|
||||
clear_width * char_width, char_height},
|
||||
Styles::white_small.background);
|
||||
style().background);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,8 +241,8 @@ void TextViewer::paint_cursor(Painter& painter) {
|
||||
};
|
||||
|
||||
// Clear old cursor. CONSIDER: XOR cursor?
|
||||
draw_cursor(paint_state_.line, paint_state_.col, Styles::white_small.background);
|
||||
draw_cursor(cursor_.line, cursor_.col, Styles::white_small.foreground);
|
||||
draw_cursor(paint_state_.line, paint_state_.col, style().background);
|
||||
draw_cursor(cursor_.line, cursor_.col, style().foreground);
|
||||
paint_state_.line = cursor_.line;
|
||||
paint_state_.col = cursor_.col;
|
||||
}
|
||||
@@ -252,6 +256,15 @@ void TextViewer::reset_file(FileWrapper* file) {
|
||||
redraw(true);
|
||||
}
|
||||
|
||||
void TextViewer::set_font_zoom(bool zoom) {
|
||||
font_zoom = zoom;
|
||||
font_style = font_zoom ? &Styles::white : &Styles::white_small;
|
||||
char_height = style().font.line_height();
|
||||
char_width = style().font.char_width();
|
||||
max_line = (uint8_t)(parent_rect().height() / char_height);
|
||||
max_col = (uint8_t)(parent_rect().width() / char_width);
|
||||
}
|
||||
|
||||
/* TextEditorMenu ***************************************************/
|
||||
|
||||
TextEditorMenu::TextEditorMenu()
|
||||
@@ -259,9 +272,9 @@ TextEditorMenu::TextEditorMenu()
|
||||
add_children(
|
||||
{
|
||||
&rect_frame,
|
||||
&button_cut,
|
||||
&button_paste,
|
||||
&button_copy,
|
||||
&button_home,
|
||||
&button_end,
|
||||
&button_zoom,
|
||||
&button_delline,
|
||||
&button_edit,
|
||||
&button_addline,
|
||||
@@ -310,14 +323,20 @@ TextEditorView::TextEditorView(NavigationView& nav)
|
||||
};
|
||||
|
||||
menu.hidden(true);
|
||||
menu.on_cut() = [this]() {
|
||||
show_nyi();
|
||||
menu.on_home() = [this]() {
|
||||
viewer.cursor_home();
|
||||
hide_menu(true);
|
||||
};
|
||||
menu.on_paste() = [this]() {
|
||||
show_nyi();
|
||||
|
||||
menu.on_end() = [this]() {
|
||||
viewer.cursor_end();
|
||||
hide_menu(true);
|
||||
};
|
||||
menu.on_copy() = [this]() {
|
||||
show_nyi();
|
||||
|
||||
menu.on_zoom() = [this]() {
|
||||
viewer.toggle_font_zoom();
|
||||
refresh_ui();
|
||||
hide_menu(true);
|
||||
};
|
||||
|
||||
menu.on_delete_line() = [this]() {
|
||||
@@ -490,10 +509,6 @@ void TextEditorView::show_edit_line() {
|
||||
});
|
||||
}
|
||||
|
||||
void TextEditorView::show_nyi() {
|
||||
nav_.display_modal("Soon...", "Coming soon.");
|
||||
}
|
||||
|
||||
void TextEditorView::show_save_prompt(std::function<void()> continuation) {
|
||||
if (!file_dirty_) {
|
||||
if (continuation)
|
||||
|
||||
@@ -72,15 +72,23 @@ class TextViewer : public Widget {
|
||||
uint32_t col() const { return cursor_.col; }
|
||||
uint32_t offset() const;
|
||||
|
||||
void cursor_home();
|
||||
void cursor_end();
|
||||
|
||||
// Gets the length of the current line.
|
||||
uint16_t line_length();
|
||||
|
||||
private:
|
||||
static constexpr int8_t char_width = 5;
|
||||
static constexpr int8_t char_height = 8;
|
||||
const Style& style() { return *font_style; }
|
||||
void set_font_zoom(bool zoom);
|
||||
void toggle_font_zoom() { set_font_zoom(!font_zoom); };
|
||||
|
||||
const uint8_t max_line = 32;
|
||||
const uint8_t max_col = 48;
|
||||
private:
|
||||
bool font_zoom{};
|
||||
const Style* font_style{};
|
||||
int8_t char_width{};
|
||||
int8_t char_height{};
|
||||
uint8_t max_line{};
|
||||
uint8_t max_col{};
|
||||
|
||||
/* Returns true if the cursor was updated. */
|
||||
bool apply_scrolling_constraints(
|
||||
@@ -120,14 +128,12 @@ class TextEditorMenu : public View {
|
||||
void on_show() override;
|
||||
void on_hide() override;
|
||||
|
||||
std::function<void()>& on_cut() { return button_cut.on_select; }
|
||||
std::function<void()>& on_paste() { return button_paste.on_select; }
|
||||
std::function<void()>& on_copy() { return button_copy.on_select; }
|
||||
|
||||
std::function<void()>& on_home() { return button_home.on_select; }
|
||||
std::function<void()>& on_end() { return button_end.on_select; }
|
||||
std::function<void()>& on_zoom() { return button_zoom.on_select; }
|
||||
std::function<void()>& on_delete_line() { return button_delline.on_select; }
|
||||
std::function<void()>& on_edit_line() { return button_edit.on_select; }
|
||||
std::function<void()>& on_add_line() { return button_addline.on_select; }
|
||||
|
||||
std::function<void()>& on_open() { return button_open.on_select; }
|
||||
std::function<void()>& on_save() { return button_save.on_select; }
|
||||
std::function<void()>& on_exit() { return button_exit.on_select; }
|
||||
@@ -139,23 +145,23 @@ class TextEditorMenu : public View {
|
||||
{0 * 8, 0 * 8, 23 * 8, 23 * 8},
|
||||
Color::dark_grey()};
|
||||
|
||||
NewButton button_cut{
|
||||
NewButton button_home{
|
||||
{1 * 8, 1 * 8, 7 * 8, 7 * 8},
|
||||
"Cut",
|
||||
&bitmap_icon_cut,
|
||||
"Home",
|
||||
&bitmap_arrow_left,
|
||||
Color::dark_grey()};
|
||||
|
||||
NewButton button_paste{
|
||||
NewButton button_end{
|
||||
{8 * 8, 1 * 8, 7 * 8, 7 * 8},
|
||||
"Paste",
|
||||
&bitmap_icon_paste,
|
||||
"End",
|
||||
&bitmap_arrow_right,
|
||||
Color::dark_grey()};
|
||||
|
||||
NewButton button_copy{
|
||||
NewButton button_zoom{
|
||||
{15 * 8, 1 * 8, 7 * 8, 7 * 8},
|
||||
"Copy",
|
||||
&bitmap_icon_copy,
|
||||
Color::dark_grey()};
|
||||
"Zoom",
|
||||
&bitmap_icon_search,
|
||||
Color::orange()};
|
||||
|
||||
NewButton button_delline{
|
||||
{1 * 8, 8 * 8, 7 * 8, 7 * 8},
|
||||
@@ -220,7 +226,6 @@ class TextEditorView : public View {
|
||||
void hide_menu(bool hidden = true);
|
||||
void show_file_picker(bool immediate = true);
|
||||
void show_edit_line();
|
||||
void show_nyi();
|
||||
void show_save_prompt(std::function<void()> continuation);
|
||||
|
||||
void prepare_for_write();
|
||||
@@ -258,4 +263,4 @@ class TextEditorView : public View {
|
||||
|
||||
} // namespace ui
|
||||
|
||||
#endif // __UI_TEXT_EDITOR_H__
|
||||
#endif // __UI_TEXT_EDITOR_H__
|
||||
|
||||
@@ -184,6 +184,9 @@ void speaker_unmute() {
|
||||
|
||||
void update_audio_mute() {
|
||||
cfg_speaker_disable = portapack::persistent_memory::config_speaker_disable();
|
||||
if (cfg_speaker_disable) {
|
||||
audio_codec->speaker_disable();
|
||||
}
|
||||
|
||||
if (portapack::persistent_memory::config_audio_mute())
|
||||
speaker_mute();
|
||||
@@ -269,4 +272,8 @@ void set_rate(const Rate rate) {
|
||||
clock_manager.set_base_audio_clock_divider(toUType(rate));
|
||||
}
|
||||
|
||||
bool speaker_disable_supported() {
|
||||
return audio_codec->speaker_disable_supported();
|
||||
}
|
||||
|
||||
} /* namespace audio */
|
||||
|
||||
@@ -43,6 +43,7 @@ class Codec {
|
||||
|
||||
virtual void speaker_enable() = 0;
|
||||
virtual void speaker_disable() = 0;
|
||||
virtual bool speaker_disable_supported() const = 0;
|
||||
|
||||
virtual void headphone_enable() = 0;
|
||||
virtual void headphone_disable() = 0;
|
||||
@@ -107,6 +108,7 @@ size_t reg_bits();
|
||||
|
||||
void init(audio::Codec* const codec);
|
||||
void shutdown();
|
||||
bool speaker_disable_supported();
|
||||
|
||||
enum class Rate {
|
||||
Hz_12000 = 4,
|
||||
|
||||
@@ -5341,6 +5341,234 @@ static constexpr Bitmap bitmap_icon_new_dir{
|
||||
{16, 16},
|
||||
bitmap_icon_new_dir_data};
|
||||
|
||||
static constexpr uint8_t bitmap_icon_paint_data[] = {
|
||||
0xFE,
|
||||
0x3F,
|
||||
0xFF,
|
||||
0x3F,
|
||||
0xFF,
|
||||
0xFF,
|
||||
0xFF,
|
||||
0xBF,
|
||||
0xFE,
|
||||
0xBF,
|
||||
0x00,
|
||||
0x80,
|
||||
0x80,
|
||||
0xFF,
|
||||
0x80,
|
||||
0x00,
|
||||
0x80,
|
||||
0x00,
|
||||
0xC0,
|
||||
0x01,
|
||||
0xC0,
|
||||
0x01,
|
||||
0xC0,
|
||||
0x01,
|
||||
0xC0,
|
||||
0x01,
|
||||
0xC0,
|
||||
0x01,
|
||||
0xC0,
|
||||
0x01,
|
||||
0xC0,
|
||||
0x01,
|
||||
};
|
||||
static constexpr Bitmap bitmap_icon_paint{
|
||||
{16, 16},
|
||||
bitmap_icon_paint_data};
|
||||
|
||||
static constexpr uint8_t bitmap_icon_touchtunes_data[] = {
|
||||
0xE0,
|
||||
0x07,
|
||||
0x30,
|
||||
0x0C,
|
||||
0x7C,
|
||||
0x3E,
|
||||
0xC4,
|
||||
0x23,
|
||||
0x26,
|
||||
0x64,
|
||||
0x12,
|
||||
0x48,
|
||||
0x0F,
|
||||
0xF3,
|
||||
0x09,
|
||||
0x95,
|
||||
0x0F,
|
||||
0xF1,
|
||||
0x09,
|
||||
0x91,
|
||||
0x0F,
|
||||
0xF1,
|
||||
0xC9,
|
||||
0x91,
|
||||
0xE9,
|
||||
0x91,
|
||||
0xC9,
|
||||
0x90,
|
||||
0x0F,
|
||||
0xF0,
|
||||
0xFF,
|
||||
0xFF,
|
||||
};
|
||||
static constexpr Bitmap bitmap_icon_touchtunes{
|
||||
{16, 16},
|
||||
bitmap_icon_touchtunes_data};
|
||||
|
||||
static constexpr uint8_t bitmap_arrow_left_data[] = {
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x20,
|
||||
0x00,
|
||||
0x30,
|
||||
0x00,
|
||||
0x38,
|
||||
0x00,
|
||||
0xFC,
|
||||
0x7F,
|
||||
0xFE,
|
||||
0x7F,
|
||||
0xFC,
|
||||
0x7F,
|
||||
0x38,
|
||||
0x00,
|
||||
0x30,
|
||||
0x00,
|
||||
0x20,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
};
|
||||
static constexpr Bitmap bitmap_arrow_left{
|
||||
{16, 16},
|
||||
bitmap_arrow_left_data};
|
||||
|
||||
static constexpr uint8_t bitmap_arrow_right_data[] = {
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x04,
|
||||
0x00,
|
||||
0x0C,
|
||||
0x00,
|
||||
0x1C,
|
||||
0xFE,
|
||||
0x3F,
|
||||
0xFE,
|
||||
0x7F,
|
||||
0xFE,
|
||||
0x3F,
|
||||
0x00,
|
||||
0x1C,
|
||||
0x00,
|
||||
0x0C,
|
||||
0x00,
|
||||
0x04,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
};
|
||||
static constexpr Bitmap bitmap_arrow_right{
|
||||
{16, 16},
|
||||
bitmap_arrow_right_data};
|
||||
|
||||
static constexpr uint8_t bitmap_icon_speaker_and_headphones_data[] = {
|
||||
0x20,
|
||||
0x10,
|
||||
0x30,
|
||||
0x20,
|
||||
0x38,
|
||||
0x44,
|
||||
0x3E,
|
||||
0x48,
|
||||
0x3E,
|
||||
0x91,
|
||||
0x3E,
|
||||
0x92,
|
||||
0x38,
|
||||
0x92,
|
||||
0x30,
|
||||
0x92,
|
||||
0x20,
|
||||
0x92,
|
||||
0x00,
|
||||
0x92,
|
||||
0x30,
|
||||
0x91,
|
||||
0x48,
|
||||
0x48,
|
||||
0x84,
|
||||
0x44,
|
||||
0x84,
|
||||
0x20,
|
||||
0x86,
|
||||
0x11,
|
||||
0x86,
|
||||
0x01,
|
||||
};
|
||||
static constexpr Bitmap bitmap_icon_speaker_and_headphones{
|
||||
{16, 16},
|
||||
bitmap_icon_speaker_and_headphones_data};
|
||||
|
||||
static constexpr uint8_t bitmap_icon_speaker_and_headphones_mute_data[] = {
|
||||
0x40,
|
||||
0x00,
|
||||
0x60,
|
||||
0x44,
|
||||
0x70,
|
||||
0x6C,
|
||||
0x7C,
|
||||
0x38,
|
||||
0x7C,
|
||||
0x10,
|
||||
0x7C,
|
||||
0x38,
|
||||
0x70,
|
||||
0x6C,
|
||||
0x60,
|
||||
0x44,
|
||||
0x40,
|
||||
0x00,
|
||||
0x00,
|
||||
0x44,
|
||||
0x30,
|
||||
0x6C,
|
||||
0x48,
|
||||
0x38,
|
||||
0x84,
|
||||
0x10,
|
||||
0x84,
|
||||
0x38,
|
||||
0x86,
|
||||
0x6D,
|
||||
0x86,
|
||||
0x45,
|
||||
};
|
||||
static constexpr Bitmap bitmap_icon_speaker_and_headphones_mute{
|
||||
{16, 16},
|
||||
bitmap_icon_speaker_and_headphones_mute_data};
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
#endif /*__BITMAP_HPP__*/
|
||||
|
||||
@@ -488,6 +488,24 @@ path operator/(const path& lhs, const path& rhs) {
|
||||
return result;
|
||||
}
|
||||
|
||||
bool path_iequal(
|
||||
const path& lhs,
|
||||
const path& rhs) {
|
||||
const auto& lhs_str = lhs.native();
|
||||
const auto& rhs_str = rhs.native();
|
||||
|
||||
// NB: Not correct for Unicode/locales.
|
||||
if (lhs_str.length() == rhs_str.length()) {
|
||||
for (size_t i = 0; i < lhs_str.length(); ++i)
|
||||
if (towupper(lhs_str[i]) != towupper(rhs_str[i]))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
directory_iterator::directory_iterator(
|
||||
std::filesystem::path path,
|
||||
std::filesystem::path wild)
|
||||
|
||||
@@ -168,6 +168,9 @@ bool operator>(const path& lhs, const path& rhs);
|
||||
path operator+(const path& lhs, const path& rhs);
|
||||
path operator/(const path& lhs, const path& rhs);
|
||||
|
||||
/* Case insensitive path equality on underlying "native" string. */
|
||||
bool path_iequal(const path& lhs, const path& rhs);
|
||||
|
||||
using file_status = BYTE;
|
||||
|
||||
static_assert(sizeof(path::value_type) == 2, "sizeof(std::filesystem::path::value_type) != 2");
|
||||
|
||||
@@ -27,10 +27,13 @@
|
||||
using option_t = std::pair<std::string, int32_t>;
|
||||
using options_t = std::vector<option_t>;
|
||||
|
||||
// TODO: Consolidate with receiver_model.
|
||||
// These definitions are spread all over and stiched together with indices.
|
||||
options_t freqman_entry_modulations = {
|
||||
{"AM", 0},
|
||||
{"NFM", 1},
|
||||
{"WFM", 2}};
|
||||
{"WFM", 2},
|
||||
{"SPEC", 3}};
|
||||
|
||||
options_t freqman_entry_bandwidths[4] = {
|
||||
{// AM
|
||||
@@ -48,6 +51,25 @@ options_t freqman_entry_bandwidths[4] = {
|
||||
{"40k", 2},
|
||||
{"180k", 1},
|
||||
{"200k", 0},
|
||||
},
|
||||
{
|
||||
// SPEC
|
||||
{"8k5", 8500},
|
||||
{"11k", 11000},
|
||||
{"16k", 16000},
|
||||
{"25k", 25000},
|
||||
{"50k", 50000},
|
||||
{"100k", 100000},
|
||||
{"250k", 250000},
|
||||
{"500k", 500000}, /* Previous Limit bandwith Option with perfect micro SD write .C16 format operaton.*/
|
||||
{"600k", 600000}, /* That extended option is still possible to record with FW version Mayhem v1.41 (< 2,5MB/sec) */
|
||||
{"650k", 650000},
|
||||
{"750k", 750000}, /* From this BW onwards, the LCD is ok, but the recorded file is decimated, (not real file size) */
|
||||
{"1100k", 1100000},
|
||||
{"1750k", 1750000},
|
||||
{"2000k", 2000000},
|
||||
{"2500k", 2500000},
|
||||
{"2750k", 2750000}, // That is our max Capture option, to keep using later / 8 decimation (22Mhz sampling ADC)
|
||||
}};
|
||||
|
||||
options_t freqman_entry_steps = {
|
||||
@@ -86,27 +108,24 @@ options_t freqman_entry_steps_short = {
|
||||
{"500kHz", 500000},
|
||||
{"1MHz", 1000000}};
|
||||
|
||||
bool load_freqman_file(std::string& file_stem, freqman_db& db) {
|
||||
return load_freqman_file_ex(file_stem, db, true, true, true, FREQMAN_MAX_PER_FILE);
|
||||
}
|
||||
|
||||
bool load_freqman_file_ex(std::string& file_stem, freqman_db& db, bool load_freqs, bool load_ranges, bool load_hamradios, uint8_t max_num_freqs = FREQMAN_MAX_PER_FILE) {
|
||||
bool load_freqman_file(std::string& file_stem, freqman_db& db, bool load_freqs, bool load_ranges, bool load_hamradios, uint8_t max_num_freqs) {
|
||||
// swap with empty vector to ensure memory is immediately released
|
||||
std::vector<freqman_entry>().swap(db);
|
||||
|
||||
File freqman_file;
|
||||
size_t length, n = 0, file_position = 0;
|
||||
char* pos;
|
||||
char* line_start;
|
||||
char* line_end;
|
||||
std::string description;
|
||||
rf::Frequency frequency_a, frequency_b;
|
||||
char file_data[FREQMAN_READ_BUF_SIZE + 1];
|
||||
freqman_entry_type type;
|
||||
freqman_index_t modulation = 0;
|
||||
freqman_index_t bandwidth = 0;
|
||||
freqman_index_t step = 0;
|
||||
freqman_index_t tone = 0;
|
||||
File freqman_file{};
|
||||
size_t length = 0, n = 0, file_position = 0;
|
||||
char* pos = NULL;
|
||||
char* line_start = NULL;
|
||||
char* line_end = NULL;
|
||||
std::string description{NULL};
|
||||
rf::Frequency frequency_a = 0, frequency_b = 0;
|
||||
char file_data[FREQMAN_READ_BUF_SIZE + 1] = {0};
|
||||
freqman_entry_type type = NOTYPE;
|
||||
freqman_index_t modulation = -1;
|
||||
freqman_index_t bandwidth = -1;
|
||||
freqman_index_t step = -1;
|
||||
freqman_index_t tone = -1;
|
||||
uint32_t tone_freq;
|
||||
char c;
|
||||
|
||||
auto result = freqman_file.open("FREQMAN/" + file_stem + ".TXT");
|
||||
if (result.is_valid())
|
||||
@@ -137,7 +156,7 @@ bool load_freqman_file_ex(std::string& file_stem, freqman_db& db, bool load_freq
|
||||
bandwidth = -1;
|
||||
step = -1;
|
||||
tone = -1;
|
||||
type = ERROR_TYPE;
|
||||
type = NOTYPE;
|
||||
|
||||
frequency_a = frequency_b = 0;
|
||||
// Read frequency
|
||||
@@ -195,21 +214,37 @@ bool load_freqman_file_ex(std::string& file_stem, freqman_db& db, bool load_freq
|
||||
step = freqman_entry_get_step_from_str_short(pos);
|
||||
}
|
||||
// ctcss tone if any
|
||||
/* disabled until better form
|
||||
pos = strstr(line_start, "c=");
|
||||
if (pos) {
|
||||
pos += 2;
|
||||
tone = tone_key_index_by_value( strtoll( pos , nullptr , 10 ) );
|
||||
} */
|
||||
pos = strstr(line_start, "c=");
|
||||
if (pos) {
|
||||
pos += 2;
|
||||
// find decimal point and replace with 0 if there is one, for strtoll
|
||||
length = strcspn(pos, ".,\x0A");
|
||||
if (pos + length <= line_end) {
|
||||
c = *(pos + length);
|
||||
*(pos + length) = 0;
|
||||
// ASCII Hz to integer Hz x 100
|
||||
tone_freq = strtoll(pos, nullptr, 10) * 100;
|
||||
// stuff saved character back into string in case it was not a decimal point
|
||||
*(pos + length) = c;
|
||||
// now get first digit after decimal point (10ths of Hz)
|
||||
pos += length + 1;
|
||||
if (c == '.' && *pos >= '0' && *pos <= '9')
|
||||
tone_freq += (*pos - '0') * 10;
|
||||
// convert tone_freq (100x the freq in Hz) to a tone_key index
|
||||
tone = tone_key_index_by_value(tone_freq);
|
||||
}
|
||||
}
|
||||
// Read description until , or LF
|
||||
pos = strstr(line_start, "d=");
|
||||
if (pos) {
|
||||
pos += 2;
|
||||
length = std::min(strcspn(pos, ",\x0A"), (size_t)FREQMAN_DESC_MAX_LEN);
|
||||
description = string(pos, length);
|
||||
description.shrink_to_fit();
|
||||
}
|
||||
if ((type == SINGLE && load_freqs) || (type == RANGE && load_ranges) || (type == HAMRADIO && load_hamradios)) {
|
||||
db.push_back({frequency_a, frequency_b, description, type, modulation, bandwidth, step, tone});
|
||||
freqman_entry entry = {frequency_a, frequency_b, std::move(description), type, modulation, bandwidth, step, tone};
|
||||
db.emplace_back(entry);
|
||||
n++;
|
||||
if (n > max_num_freqs) return true;
|
||||
}
|
||||
@@ -243,6 +278,7 @@ bool load_freqman_file_ex(std::string& file_stem, freqman_db& db, bool load_freq
|
||||
}
|
||||
}
|
||||
}
|
||||
db.shrink_to_fit();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -266,7 +302,7 @@ bool get_freq_string(freqman_entry& entry, std::string& item_string) {
|
||||
item_string = "r=" + to_string_dec_uint(frequency_a / 1000) + to_string_dec_uint(frequency_a % 1000UL, 3, '0');
|
||||
item_string += ",t=" + to_string_dec_uint(frequency_b / 1000) + to_string_dec_uint(frequency_b % 1000UL, 3, '0');
|
||||
if (entry.tone >= 0) {
|
||||
item_string += ",c=" + tone_key_string(entry.tone);
|
||||
item_string += ",c=" + tone_key_value_string(entry.tone);
|
||||
}
|
||||
}
|
||||
if (entry.modulation >= 0 && (unsigned)entry.modulation < freqman_entry_modulations.size()) {
|
||||
|
||||
@@ -32,11 +32,11 @@
|
||||
#include "string_format.hpp"
|
||||
#include "ui_widget.hpp"
|
||||
|
||||
#define FREQMAN_DESC_MAX_LEN 24 // This is the number of characters that can be drawn in front of "R: TEXT..." before taking a full screen line
|
||||
#define FREQMAN_MAX_PER_FILE 100 // Maximum of entries we can read. This is a hardware limit
|
||||
// It was tested and lowered to leave a bit of space to the caller
|
||||
#define FREQMAN_DESC_MAX_LEN 24 // This is the number of characters that can be drawn in front of "R: TEXT..." before taking a full screen line
|
||||
#define FREQMAN_MAX_PER_FILE 90 // Maximum of entries we can read. This is a hardware limit
|
||||
// It was tested and lowered to leave a bit of space to the caller
|
||||
|
||||
#define FREQMAN_READ_BUF_SIZE 96 // max freqman line size including desc is 90, +6 for a bit of space
|
||||
#define FREQMAN_READ_BUF_SIZE 96 // max freqman line size including desc is 90, + a bit of space
|
||||
|
||||
using namespace ui;
|
||||
using namespace std;
|
||||
@@ -45,58 +45,54 @@ using namespace tonekey;
|
||||
// needs to be signed as -1 means not set
|
||||
typedef int8_t freqman_index_t;
|
||||
|
||||
enum freqman_error {
|
||||
enum freqman_error : int8_t {
|
||||
NO_ERROR = 0,
|
||||
ERROR_ACCESS,
|
||||
ERROR_NOFILES,
|
||||
ERROR_DUPLICATE
|
||||
};
|
||||
|
||||
enum freqman_entry_type : uint8_t {
|
||||
enum freqman_entry_type : int8_t {
|
||||
SINGLE = 0, // f=
|
||||
RANGE, // a=,b=
|
||||
HAMRADIO, // r=,t=
|
||||
ERROR_TYPE
|
||||
NOTYPE // undetected
|
||||
};
|
||||
|
||||
enum freqman_entry_modulation {
|
||||
enum freqman_entry_modulation : uint8_t {
|
||||
AM_MODULATION = 0,
|
||||
NFM_MODULATION,
|
||||
WFM_MODULATION,
|
||||
MODULATION_DEF,
|
||||
ERROR_MODULATION
|
||||
SPEC_MODULATION,
|
||||
};
|
||||
|
||||
// Entry step placed for AlainD freqman version (or any other enhanced version)
|
||||
enum freqman_entry_step {
|
||||
STEP_DEF = -1, // default
|
||||
AM_US, // 10 kHz AM/CB
|
||||
AM_EUR, // 9 kHz LW/MW
|
||||
NFM_1, // 12,5 kHz (Analogic PMR 446)
|
||||
NFM_2, // 6,25 kHz (Digital PMR 446)
|
||||
FM_1, // 100 kHz
|
||||
FM_2, // 50 kHz
|
||||
N_1, // 25 kHz
|
||||
N_2, // 250 kHz
|
||||
AIRBAND, // AIRBAND 8,33 kHz
|
||||
ERROR_STEP
|
||||
enum freqman_entry_step : int8_t {
|
||||
AM_US, // 10 kHz AM/CB
|
||||
AM_EUR, // 9 kHz LW/MW
|
||||
NFM_1, // 12,5 kHz (Analogic PMR 446)
|
||||
NFM_2, // 6,25 kHz (Digital PMR 446)
|
||||
FM_1, // 100 kHz
|
||||
FM_2, // 50 kHz
|
||||
N_1, // 25 kHz
|
||||
N_2, // 250 kHz
|
||||
AIRBAND, // AIRBAND 8,33 kHz
|
||||
};
|
||||
|
||||
struct freqman_entry {
|
||||
rf::Frequency frequency_a{0}; // 'f=freq' or 'a=freq_start' or 'r=recv_freq'
|
||||
rf::Frequency frequency_b{0}; // 'b=freq_end' or 't=tx_freq'
|
||||
std::string description{}; // 'd=desc'
|
||||
freqman_entry_type type{}; // SINGLE,RANGE,HAMRADIO
|
||||
freqman_index_t modulation{}; // AM,NFM,WFM
|
||||
freqman_index_t bandwidth{}; // AM_DSB, ...
|
||||
freqman_index_t step{}; // 5khz (SA AM,...
|
||||
tone_index tone{}; // 0XZ, 11 1ZB,...
|
||||
rf::Frequency frequency_a{0}; // 'f=freq' or 'a=freq_start' or 'r=recv_freq'
|
||||
rf::Frequency frequency_b{0}; // 'b=freq_end' or 't=tx_freq'
|
||||
std::string description{NULL}; // 'd=desc'
|
||||
freqman_entry_type type{SINGLE}; // SINGLE,RANGE,HAMRADIO
|
||||
freqman_index_t modulation{AM_MODULATION}; // AM,NFM,WFM
|
||||
freqman_index_t bandwidth{0}; // AM_DSB, ...
|
||||
freqman_index_t step{0}; // 5khz (SA AM,...
|
||||
tone_index tone{0}; // 0XZ, 11 1ZB,...
|
||||
};
|
||||
|
||||
using freqman_db = std::vector<freqman_entry>;
|
||||
|
||||
bool load_freqman_file(std::string& file_stem, freqman_db& db);
|
||||
bool load_freqman_file_ex(std::string& file_stem, freqman_db& db, bool load_freqs, bool load_ranges, bool load_hamradios, uint8_t limit);
|
||||
bool load_freqman_file(std::string& file_stem, freqman_db& db, bool load_freqs = true, bool load_ranges = true, bool load_hamradios = true, uint8_t max_num_freqs = FREQMAN_MAX_PER_FILE);
|
||||
bool get_freq_string(freqman_entry& entry, std::string& item_string);
|
||||
bool delete_freqman_file(std::string& file_stem);
|
||||
bool save_freqman_file(std::string& file_stem, freqman_db& db);
|
||||
|
||||
@@ -30,7 +30,7 @@ bool Debounce::feed(const uint8_t bit) {
|
||||
// "Repeat" handling - simulated button release
|
||||
if (repeat_ctr_) {
|
||||
// Make sure the button is still being held continuously
|
||||
if (history_ == 0xFF) {
|
||||
if ((history_ == 0xFF) && !long_press_enabled_) {
|
||||
// Simulate button press every REPEAT_SUBSEQUENT_DELAY ticks
|
||||
if (--repeat_ctr_ == 0) {
|
||||
state_ = !state_;
|
||||
@@ -49,29 +49,59 @@ bool Debounce::feed(const uint8_t bit) {
|
||||
if ((history_ & DEBOUNCE_MASK) == DEBOUNCE_MASK) {
|
||||
state_ = 1;
|
||||
held_time_ = 0;
|
||||
|
||||
// If long_press_enabled_, state() function masks the button press until it's released
|
||||
// or until LONG_PRESS_DELAY is reached
|
||||
if (long_press_enabled_) {
|
||||
pulse_upon_release_ = true;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// Previous button state was 1 (pressed);
|
||||
// Has button been released for DEBOUNCE_COUNT ticks?
|
||||
if ((history_ & DEBOUNCE_MASK) == 0) {
|
||||
state_ = 0;
|
||||
// Button has been released when long_press_enabled_ and before LONG_PRESS_DELAY was reached;
|
||||
// allow state() function to finally return a single press indication
|
||||
// (in long press mode, apps won't see button press until the button is released)
|
||||
if (pulse_upon_release_) {
|
||||
// leaving state_==1 for one cycle
|
||||
pulse_upon_release_ = 0;
|
||||
} else {
|
||||
state_ = 0;
|
||||
}
|
||||
|
||||
// Reset long_press_occurred_ flag after button is released
|
||||
long_press_occurred_ = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Repeat support is limited to the 4 directional buttons
|
||||
if (repeat_enabled_) {
|
||||
// Has button been held continuously for DEBOUNCE_REPEAT_DELAY?
|
||||
if (history_ == 0xFF) {
|
||||
if (++held_time_ == REPEAT_INITIAL_DELAY) {
|
||||
// Has button been held continuously?
|
||||
if (history_ == 0xFF) {
|
||||
held_time_++;
|
||||
if (pulse_upon_release_) {
|
||||
// Button is being held down and long_press support is enabled for this key:
|
||||
// if LONG_PRESS_DELAY is reached then finally report that switch is pressed and set flag
|
||||
// indicating it was a LONG press
|
||||
// (note that repease_support and long_press support are mutually exclusive)
|
||||
if (held_time_ == LONG_PRESS_DELAY) {
|
||||
long_press_occurred_ = true;
|
||||
pulse_upon_release_ = 0;
|
||||
held_time_ = 0;
|
||||
return true;
|
||||
}
|
||||
} else if (repeat_enabled_ && !long_press_enabled_) {
|
||||
// Repeat support -- 4 directional buttons only (unless long_press is enabled)
|
||||
if (held_time_ == REPEAT_INITIAL_DELAY) {
|
||||
// Delay reached; trigger repeat code on NEXT tick
|
||||
repeat_ctr_ = 1;
|
||||
held_time_ = 0;
|
||||
}
|
||||
} else {
|
||||
// Button not continuously pressed; reset counter
|
||||
held_time_ = 0;
|
||||
}
|
||||
} else {
|
||||
// Button not continuously pressed; reset counter
|
||||
held_time_ = 0;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -31,25 +31,39 @@
|
||||
// # of timer0 ticks before a held button starts being counted as repeated presses
|
||||
#define REPEAT_INITIAL_DELAY 250
|
||||
#define REPEAT_SUBSEQUENT_DELAY 92
|
||||
#define LONG_PRESS_DELAY 1000
|
||||
|
||||
class Debounce {
|
||||
public:
|
||||
bool feed(const uint8_t bit);
|
||||
|
||||
uint8_t state() const {
|
||||
return state_;
|
||||
return (pulse_upon_release_) ? 0 : state_;
|
||||
}
|
||||
|
||||
void enable_repeat() {
|
||||
repeat_enabled_ = true;
|
||||
}
|
||||
|
||||
void set_long_press_support(bool v) {
|
||||
long_press_enabled_ = v;
|
||||
}
|
||||
|
||||
bool long_press_occurred() {
|
||||
bool v = long_press_occurred_;
|
||||
long_press_occurred_ = false;
|
||||
return v;
|
||||
}
|
||||
|
||||
private:
|
||||
uint8_t history_{0};
|
||||
uint8_t state_{0};
|
||||
bool repeat_enabled_{0};
|
||||
uint16_t repeat_ctr_{0};
|
||||
uint16_t held_time_{0};
|
||||
bool pulse_upon_release_{0};
|
||||
bool long_press_enabled_{0};
|
||||
bool long_press_occurred_{0};
|
||||
};
|
||||
|
||||
#endif /*__DEBOUNCE_H__*/
|
||||
|
||||
@@ -195,16 +195,33 @@ void controls_init() {
|
||||
|
||||
SwitchesState get_switches_state() {
|
||||
SwitchesState result;
|
||||
|
||||
// Right, Left, Down, Up, & Select switches
|
||||
for (size_t i = 0; i < result.size() - 1; i++) {
|
||||
// TODO: Ignore multiple keys at the same time?
|
||||
result[i] = switch_debounce[i].state();
|
||||
}
|
||||
|
||||
result[result.size() - 1] = switch_debounce[switch_debounce.size() - 1].state();
|
||||
|
||||
// Grab Dfu switch from bit 7 and return in bit 5 so that all switches are grouped together in this 6-bit result
|
||||
result[(size_t)Switch::Dfu] = switch_debounce[7].state();
|
||||
return result;
|
||||
}
|
||||
|
||||
// Configure which switches support long press (note those switches will not support Repeat function)
|
||||
void switches_long_press_enable(SwitchesState switches_long_press_enabled) {
|
||||
// Right, Left, Down, Up, & Select switches
|
||||
for (size_t i = 0; i < switches_long_press_enabled.size() - 1; i++) {
|
||||
switch_debounce[i].set_long_press_support(switches_long_press_enabled[i]);
|
||||
}
|
||||
|
||||
// Dfu switch
|
||||
switch_debounce[7].set_long_press_support(switches_long_press_enabled[(size_t)Switch::Dfu]);
|
||||
}
|
||||
|
||||
bool switch_long_press_occurred(size_t v) {
|
||||
return (v == (size_t)Switch::Dfu) ? switch_debounce[7].long_press_occurred() : switch_debounce[v].long_press_occurred();
|
||||
}
|
||||
|
||||
EncoderPosition get_encoder_position() {
|
||||
return encoder_position;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "touch.hpp"
|
||||
|
||||
// Must be same values as in ui::KeyEvent
|
||||
enum class Switch {
|
||||
Right = 0,
|
||||
Left = 1,
|
||||
@@ -44,6 +45,8 @@ void controls_init();
|
||||
SwitchesState get_switches_state();
|
||||
EncoderPosition get_encoder_position();
|
||||
touch::Frame get_touch_frame();
|
||||
void switches_long_press_enable(SwitchesState v);
|
||||
bool switch_long_press_occurred(size_t v);
|
||||
|
||||
namespace control {
|
||||
namespace debug {
|
||||
|
||||
@@ -28,38 +28,47 @@
|
||||
#include "receiver_model.hpp"
|
||||
#include "transmitter_model.hpp"
|
||||
|
||||
/* Stashes current radio bandwidth and sampling rate.
|
||||
* Inits to defaults, and restores previous when destroyed.
|
||||
* The idea here is that an app will eventually call enable
|
||||
* on the model which will sync all of the model state into
|
||||
* the radio. We tried lazily setting these using the
|
||||
* set_configuration_without_update function, but there are
|
||||
* still various UI components (mainly Waterfall) that need
|
||||
* the radio set in order to load properly.
|
||||
/* Reinitialized model with defaults so each app can start
|
||||
* with a clean, default model instance. We tried lazily
|
||||
* setting these using the set_configuration_without_update
|
||||
* function, but there are still various UI components
|
||||
* (e.g. Waterfall) that need the radio set in order to load.
|
||||
* NB: This member must be added before SettingsManager. */
|
||||
template <typename TModel, TModel* model>
|
||||
class RadioState {
|
||||
public:
|
||||
RadioState()
|
||||
: RadioState(max2837::filter::bandwidth_minimum, 3072000) {
|
||||
RadioState() {
|
||||
model->initialize();
|
||||
}
|
||||
|
||||
RadioState(uint32_t new_bandwidth, uint32_t new_sampling_rate)
|
||||
: prev_bandwidth_{model->baseband_bandwidth()},
|
||||
prev_sampling_rate_{model->sampling_rate()} {
|
||||
// Update the new settings in the radio.
|
||||
RadioState(uint32_t new_bandwidth, uint32_t new_sampling_rate) {
|
||||
model->initialize();
|
||||
model->set_sampling_rate(new_sampling_rate);
|
||||
model->set_baseband_bandwidth(new_bandwidth);
|
||||
}
|
||||
|
||||
~RadioState() {
|
||||
model->set_configuration_without_update(
|
||||
prev_bandwidth_, prev_sampling_rate_);
|
||||
// NB: only enabled for RX model.
|
||||
template <
|
||||
typename U = TModel,
|
||||
typename Mode = std::enable_if_t<sizeof(typename U::Mode), typename U::Mode> >
|
||||
RadioState(Mode new_mode) {
|
||||
model->initialize();
|
||||
model->settings().mode = new_mode;
|
||||
}
|
||||
|
||||
private:
|
||||
const uint32_t prev_bandwidth_;
|
||||
const uint32_t prev_sampling_rate_;
|
||||
// NB: only enabled for RX model.
|
||||
template <
|
||||
typename U = TModel,
|
||||
typename Mode = std::enable_if_t<sizeof(typename U::Mode), typename U::Mode> >
|
||||
RadioState(
|
||||
uint32_t new_bandwidth,
|
||||
uint32_t new_sampling_rate,
|
||||
Mode new_mode) {
|
||||
model->initialize();
|
||||
model->set_sampling_rate(new_sampling_rate);
|
||||
model->set_baseband_bandwidth(new_bandwidth);
|
||||
model->settings().mode = new_mode;
|
||||
}
|
||||
};
|
||||
|
||||
using RxRadioState = RadioState<ReceiverModel, &portapack::receiver_model>;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2023 Kyle Reed
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
@@ -39,9 +40,9 @@ using namespace portapack;
|
||||
namespace {
|
||||
|
||||
static constexpr std::array<baseband::AMConfig, 5> am_configs{{
|
||||
// we config here all the non COMMON parameters to each AM modulation type in RX.
|
||||
{taps_9k0_decim_2, taps_9k0_dsb_channel, AMConfigureMessage::Modulation::DSB}, // AM DSB-C BW 9khz (+-4k5) commercial EU bandwidth .
|
||||
{taps_6k0_decim_2, taps_6k0_dsb_channel, AMConfigureMessage::Modulation::DSB}, // AM DSB-C BW 6khz (+-3k0) narrow AM , ham equipments.
|
||||
// we config here all the non COMMON parameters to each AM modulation type in RX.
|
||||
{taps_9k0_decim_2, taps_9k0_dsb_channel, AMConfigureMessage::Modulation::DSB}, // AM DSB-C BW 9khz (+-4k5) commercial EU bandwidth .
|
||||
{taps_6k0_decim_2, taps_6k0_dsb_channel, AMConfigureMessage::Modulation::DSB}, // AM DSB-C BW 6khz (+-3k0) narrow AM , ham equipments.
|
||||
{taps_6k0_decim_2, taps_2k8_usb_channel, AMConfigureMessage::Modulation::SSB}, // SSB USB BW 2K8 (+ 2K8)
|
||||
{taps_6k0_decim_2, taps_2k8_lsb_channel, AMConfigureMessage::Modulation::SSB}, // SSB LSB BW 2K8 (- 2K8)
|
||||
{taps_6k0_decim_2, taps_0k7_usb_channel, AMConfigureMessage::Modulation::SSB}, // SSB USB BW 0K7 (+ 0K7) used to get audio tone from CW Morse, assuming tx shifted +700hz aprox
|
||||
@@ -70,72 +71,114 @@ void ReceiverModel::set_target_frequency(rf::Frequency f) {
|
||||
update_tuning_frequency();
|
||||
}
|
||||
|
||||
uint32_t ReceiverModel::baseband_bandwidth() const {
|
||||
return settings_.baseband_bandwidth;
|
||||
}
|
||||
|
||||
void ReceiverModel::set_baseband_bandwidth(uint32_t v) {
|
||||
settings_.baseband_bandwidth = v;
|
||||
update_baseband_bandwidth();
|
||||
}
|
||||
|
||||
uint32_t ReceiverModel::sampling_rate() const {
|
||||
return settings_.sampling_rate;
|
||||
}
|
||||
|
||||
void ReceiverModel::set_sampling_rate(uint32_t v) {
|
||||
settings_.sampling_rate = v;
|
||||
update_sampling_rate();
|
||||
}
|
||||
|
||||
rf::Frequency ReceiverModel::frequency_step() const {
|
||||
return frequency_step_;
|
||||
return settings_.frequency_step;
|
||||
}
|
||||
|
||||
void ReceiverModel::set_frequency_step(rf::Frequency f) {
|
||||
frequency_step_ = f;
|
||||
settings_.frequency_step = f;
|
||||
}
|
||||
|
||||
uint8_t ReceiverModel::lna() const {
|
||||
return settings_.lna_gain_db;
|
||||
}
|
||||
|
||||
void ReceiverModel::set_lna(uint8_t v_db) {
|
||||
settings_.lna_gain_db = v_db;
|
||||
update_lna();
|
||||
}
|
||||
|
||||
uint8_t ReceiverModel::vga() const {
|
||||
return settings_.vga_gain_db;
|
||||
}
|
||||
|
||||
void ReceiverModel::set_vga(uint8_t v_db) {
|
||||
settings_.vga_gain_db = v_db;
|
||||
update_vga();
|
||||
}
|
||||
|
||||
bool ReceiverModel::rf_amp() const {
|
||||
return settings_.rf_amp;
|
||||
}
|
||||
|
||||
void ReceiverModel::set_rf_amp(bool enabled) {
|
||||
settings_.rf_amp = enabled;
|
||||
update_rf_amp();
|
||||
}
|
||||
|
||||
ReceiverModel::Mode ReceiverModel::modulation() const {
|
||||
return settings_.mode;
|
||||
}
|
||||
|
||||
void ReceiverModel::set_modulation(Mode v) {
|
||||
settings_.mode = v;
|
||||
update_modulation();
|
||||
}
|
||||
|
||||
uint8_t ReceiverModel::am_configuration() const {
|
||||
return settings_.am_config_index;
|
||||
}
|
||||
|
||||
void ReceiverModel::set_am_configuration(uint8_t n) {
|
||||
if (n < am_configs.size()) {
|
||||
settings_.am_config_index = n;
|
||||
update_modulation();
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t ReceiverModel::nbfm_configuration() const {
|
||||
return settings_.nbfm_config_index;
|
||||
}
|
||||
|
||||
void ReceiverModel::set_nbfm_configuration(uint8_t n) {
|
||||
if (n < nbfm_configs.size()) {
|
||||
settings_.nbfm_config_index = n;
|
||||
update_modulation();
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t ReceiverModel::wfm_configuration() const {
|
||||
return settings_.wfm_config_index;
|
||||
}
|
||||
|
||||
void ReceiverModel::set_wfm_configuration(uint8_t n) {
|
||||
if (n < wfm_configs.size()) {
|
||||
settings_.wfm_config_index = n;
|
||||
update_modulation();
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t ReceiverModel::squelch_level() const {
|
||||
return settings_.squelch_level;
|
||||
}
|
||||
|
||||
void ReceiverModel::set_squelch_level(uint8_t v) {
|
||||
settings_.squelch_level = v;
|
||||
update_modulation();
|
||||
}
|
||||
|
||||
void ReceiverModel::set_antenna_bias() {
|
||||
update_antenna_bias();
|
||||
}
|
||||
|
||||
bool ReceiverModel::rf_amp() const {
|
||||
return rf_amp_;
|
||||
}
|
||||
|
||||
void ReceiverModel::set_rf_amp(bool enabled) {
|
||||
rf_amp_ = enabled;
|
||||
update_rf_amp();
|
||||
}
|
||||
|
||||
int32_t ReceiverModel::lna() const {
|
||||
return lna_gain_db_;
|
||||
}
|
||||
|
||||
void ReceiverModel::set_lna(int32_t v_db) {
|
||||
lna_gain_db_ = v_db;
|
||||
update_lna();
|
||||
}
|
||||
|
||||
uint32_t ReceiverModel::baseband_bandwidth() const {
|
||||
return baseband_bandwidth_;
|
||||
}
|
||||
|
||||
void ReceiverModel::set_baseband_bandwidth(uint32_t v) {
|
||||
baseband_bandwidth_ = v;
|
||||
update_baseband_bandwidth();
|
||||
}
|
||||
|
||||
int32_t ReceiverModel::vga() const {
|
||||
return vga_gain_db_;
|
||||
}
|
||||
|
||||
void ReceiverModel::set_vga(int32_t v_db) {
|
||||
vga_gain_db_ = v_db;
|
||||
update_vga();
|
||||
}
|
||||
|
||||
uint32_t ReceiverModel::sampling_rate() const {
|
||||
return sampling_rate_;
|
||||
}
|
||||
|
||||
void ReceiverModel::set_sampling_rate(uint32_t v) {
|
||||
sampling_rate_ = v;
|
||||
update_sampling_rate();
|
||||
}
|
||||
|
||||
ReceiverModel::Mode ReceiverModel::modulation() const {
|
||||
return mode_;
|
||||
}
|
||||
|
||||
void ReceiverModel::set_modulation(const Mode v) {
|
||||
mode_ = v;
|
||||
update_modulation();
|
||||
}
|
||||
|
||||
volume_t ReceiverModel::headphone_volume() const {
|
||||
return persistent_memory::headphone_volume();
|
||||
}
|
||||
@@ -157,15 +200,6 @@ void ReceiverModel::set_normalized_headphone_volume(uint8_t v) {
|
||||
set_headphone_volume(new_volume);
|
||||
}
|
||||
|
||||
uint8_t ReceiverModel::squelch_level() const {
|
||||
return squelch_level_;
|
||||
}
|
||||
|
||||
void ReceiverModel::set_squelch_level(uint8_t v) {
|
||||
squelch_level_ = v;
|
||||
update_modulation();
|
||||
}
|
||||
|
||||
void ReceiverModel::enable() {
|
||||
enabled_ = true;
|
||||
radio::set_direction(rf::Direction::Receive);
|
||||
@@ -193,6 +227,35 @@ void ReceiverModel::disable() {
|
||||
led_rx.off();
|
||||
}
|
||||
|
||||
void ReceiverModel::initialize() {
|
||||
settings_ = settings_t{};
|
||||
}
|
||||
|
||||
void ReceiverModel::set_configuration_without_update(
|
||||
Mode new_mode,
|
||||
rf::Frequency new_frequency_step,
|
||||
size_t new_am_config_index,
|
||||
size_t new_nbfm_config_index,
|
||||
size_t new_wfm_config_index,
|
||||
uint8_t new_squelch_level) {
|
||||
settings_.mode = new_mode;
|
||||
settings_.frequency_step = new_frequency_step;
|
||||
settings_.am_config_index = new_am_config_index;
|
||||
settings_.nbfm_config_index = new_nbfm_config_index;
|
||||
settings_.wfm_config_index = new_wfm_config_index;
|
||||
settings_.squelch_level = new_squelch_level;
|
||||
}
|
||||
|
||||
void ReceiverModel::configure_from_app_settings(
|
||||
const app_settings::AppSettings& settings) {
|
||||
settings_.baseband_bandwidth = settings.baseband_bandwidth;
|
||||
settings_.sampling_rate = settings.sampling_rate;
|
||||
settings_.lna_gain_db = settings.lna;
|
||||
settings_.vga_gain_db = settings.vga;
|
||||
settings_.rf_amp = settings.rx_amp;
|
||||
settings_.squelch_level = settings.squelch;
|
||||
}
|
||||
|
||||
int32_t ReceiverModel::tuning_offset() {
|
||||
if ((modulation() == Mode::SpectrumAnalysis)) {
|
||||
return 0;
|
||||
@@ -206,78 +269,8 @@ void ReceiverModel::update_tuning_frequency() {
|
||||
radio::set_tuning_frequency(target_frequency() + tuning_offset());
|
||||
}
|
||||
|
||||
void ReceiverModel::update_antenna_bias() {
|
||||
if (enabled_)
|
||||
radio::set_antenna_bias(portapack::get_antenna_bias());
|
||||
}
|
||||
|
||||
void ReceiverModel::update_rf_amp() {
|
||||
radio::set_rf_amp(rf_amp_);
|
||||
}
|
||||
|
||||
void ReceiverModel::update_lna() {
|
||||
radio::set_lna_gain(lna_gain_db_);
|
||||
}
|
||||
|
||||
void ReceiverModel::update_baseband_bandwidth() {
|
||||
radio::set_baseband_filter_bandwidth(baseband_bandwidth_);
|
||||
}
|
||||
|
||||
void ReceiverModel::update_vga() {
|
||||
radio::set_vga_gain(vga_gain_db_);
|
||||
}
|
||||
|
||||
void ReceiverModel::set_am_configuration(const size_t n) {
|
||||
if (n < am_configs.size()) {
|
||||
am_config_index = n;
|
||||
update_modulation();
|
||||
}
|
||||
}
|
||||
|
||||
void ReceiverModel::set_nbfm_configuration(const size_t n) {
|
||||
if (n < nbfm_configs.size()) {
|
||||
nbfm_config_index = n;
|
||||
update_modulation();
|
||||
}
|
||||
}
|
||||
|
||||
void ReceiverModel::set_wfm_configuration(const size_t n) {
|
||||
if (n < wfm_configs.size()) {
|
||||
wfm_config_index = n;
|
||||
update_modulation();
|
||||
}
|
||||
}
|
||||
|
||||
void ReceiverModel::set_configuration_without_update(
|
||||
uint32_t baseband_bandwidth,
|
||||
uint32_t sampling_rate) {
|
||||
baseband_bandwidth_ = baseband_bandwidth;
|
||||
sampling_rate_ = sampling_rate;
|
||||
}
|
||||
|
||||
void ReceiverModel::set_configuration_without_update(
|
||||
Mode new_mode,
|
||||
rf::Frequency new_frequency_step,
|
||||
size_t new_am_config_index,
|
||||
size_t new_nbfm_config_index,
|
||||
size_t new_wfm_config_index,
|
||||
uint8_t new_squelch_level) {
|
||||
mode_ = new_mode;
|
||||
frequency_step_ = new_frequency_step;
|
||||
am_config_index = new_am_config_index;
|
||||
nbfm_config_index = new_nbfm_config_index;
|
||||
wfm_config_index = new_wfm_config_index;
|
||||
squelch_level_ = new_squelch_level;
|
||||
}
|
||||
|
||||
void ReceiverModel::configure_from_app_settings(
|
||||
const app_settings::AppSettings& settings) {
|
||||
baseband_bandwidth_ = settings.baseband_bandwidth;
|
||||
sampling_rate_ = settings.sampling_rate;
|
||||
lna_gain_db_ = settings.lna;
|
||||
vga_gain_db_ = settings.vga;
|
||||
rf_amp_ = settings.rx_amp;
|
||||
squelch_level_ = settings.squelch;
|
||||
radio::set_baseband_filter_bandwidth(baseband_bandwidth());
|
||||
}
|
||||
|
||||
void ReceiverModel::update_sampling_rate() {
|
||||
@@ -290,8 +283,16 @@ void ReceiverModel::update_sampling_rate() {
|
||||
update_tuning_frequency();
|
||||
}
|
||||
|
||||
void ReceiverModel::update_headphone_volume() {
|
||||
audio::headphone::set_volume(headphone_volume());
|
||||
void ReceiverModel::update_lna() {
|
||||
radio::set_lna_gain(lna());
|
||||
}
|
||||
|
||||
void ReceiverModel::update_vga() {
|
||||
radio::set_vga_gain(vga());
|
||||
}
|
||||
|
||||
void ReceiverModel::update_rf_amp() {
|
||||
radio::set_rf_amp(rf_amp());
|
||||
}
|
||||
|
||||
void ReceiverModel::update_modulation() {
|
||||
@@ -315,26 +316,23 @@ void ReceiverModel::update_modulation() {
|
||||
}
|
||||
}
|
||||
|
||||
size_t ReceiverModel::am_configuration() const {
|
||||
return am_config_index;
|
||||
}
|
||||
|
||||
void ReceiverModel::update_am_configuration() {
|
||||
am_configs[am_config_index].apply();
|
||||
}
|
||||
|
||||
size_t ReceiverModel::nbfm_configuration() const {
|
||||
return nbfm_config_index;
|
||||
am_configs[am_configuration()].apply();
|
||||
}
|
||||
|
||||
void ReceiverModel::update_nbfm_configuration() {
|
||||
nbfm_configs[nbfm_config_index].apply(squelch_level_);
|
||||
}
|
||||
|
||||
size_t ReceiverModel::wfm_configuration() const {
|
||||
return wfm_config_index;
|
||||
nbfm_configs[nbfm_configuration()].apply(squelch_level());
|
||||
}
|
||||
|
||||
void ReceiverModel::update_wfm_configuration() {
|
||||
wfm_configs[wfm_config_index].apply();
|
||||
wfm_configs[wfm_configuration()].apply();
|
||||
}
|
||||
|
||||
void ReceiverModel::update_antenna_bias() {
|
||||
if (enabled_)
|
||||
radio::set_antenna_bias(portapack::get_antenna_bias());
|
||||
}
|
||||
|
||||
void ReceiverModel::update_headphone_volume() {
|
||||
audio::headphone::set_volume(headphone_volume());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2023 Kyle Reed
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
@@ -26,16 +27,16 @@
|
||||
#include <cstddef>
|
||||
|
||||
#include "app_settings.hpp"
|
||||
#include "max283x.hpp"
|
||||
#include "message.hpp"
|
||||
#include "rf_path.hpp"
|
||||
#include "max283x.hpp"
|
||||
#include "volume.hpp"
|
||||
|
||||
// TODO: consider a base class for ReceiverModel & TransmitterModel.
|
||||
// There are multiple values that are actually shared by both.
|
||||
class ReceiverModel {
|
||||
public:
|
||||
enum class Mode {
|
||||
enum class Mode : uint8_t {
|
||||
AMAudio = 0,
|
||||
NarrowbandFMAudio = 1,
|
||||
WidebandFMAudio = 2,
|
||||
@@ -43,33 +44,59 @@ class ReceiverModel {
|
||||
Capture = 4
|
||||
};
|
||||
|
||||
struct settings_t {
|
||||
uint32_t baseband_bandwidth = max283x::filter::bandwidth_minimum;
|
||||
uint32_t sampling_rate = 3'072'000;
|
||||
rf::Frequency frequency_step = 25'000;
|
||||
uint8_t lna_gain_db = 32;
|
||||
uint8_t vga_gain_db = 32;
|
||||
bool rf_amp = false;
|
||||
Mode mode = Mode::NarrowbandFMAudio;
|
||||
uint8_t am_config_index = 0;
|
||||
uint8_t nbfm_config_index = 0;
|
||||
uint8_t wfm_config_index = 0;
|
||||
uint8_t squelch_level = 80;
|
||||
};
|
||||
|
||||
/* The frequency to receive (no offset). */
|
||||
rf::Frequency target_frequency() const;
|
||||
void set_target_frequency(rf::Frequency f);
|
||||
|
||||
rf::Frequency frequency_step() const;
|
||||
void set_frequency_step(rf::Frequency f);
|
||||
|
||||
void set_antenna_bias();
|
||||
|
||||
bool rf_amp() const;
|
||||
void set_rf_amp(bool enabled);
|
||||
|
||||
int32_t lna() const;
|
||||
void set_lna(int32_t v_db);
|
||||
|
||||
uint32_t baseband_bandwidth() const;
|
||||
void set_baseband_bandwidth(uint32_t v);
|
||||
|
||||
int32_t vga() const;
|
||||
void set_vga(int32_t v_db);
|
||||
|
||||
uint32_t sampling_rate() const;
|
||||
void set_sampling_rate(uint32_t v);
|
||||
|
||||
rf::Frequency frequency_step() const;
|
||||
void set_frequency_step(rf::Frequency f);
|
||||
|
||||
uint8_t lna() const;
|
||||
void set_lna(uint8_t v_db);
|
||||
|
||||
uint8_t vga() const;
|
||||
void set_vga(uint8_t v_db);
|
||||
|
||||
bool rf_amp() const;
|
||||
void set_rf_amp(bool enabled);
|
||||
|
||||
Mode modulation() const;
|
||||
void set_modulation(Mode v);
|
||||
|
||||
uint8_t am_configuration() const;
|
||||
void set_am_configuration(uint8_t n);
|
||||
|
||||
uint8_t nbfm_configuration() const;
|
||||
void set_nbfm_configuration(uint8_t n);
|
||||
|
||||
uint8_t wfm_configuration() const;
|
||||
void set_wfm_configuration(uint8_t n);
|
||||
|
||||
uint8_t squelch_level() const;
|
||||
void set_squelch_level(uint8_t v);
|
||||
|
||||
void set_antenna_bias();
|
||||
|
||||
volume_t headphone_volume() const;
|
||||
void set_headphone_volume(volume_t v);
|
||||
|
||||
@@ -77,25 +104,11 @@ class ReceiverModel {
|
||||
uint8_t normalized_headphone_volume() const;
|
||||
void set_normalized_headphone_volume(uint8_t v);
|
||||
|
||||
uint8_t squelch_level() const;
|
||||
void set_squelch_level(uint8_t v);
|
||||
|
||||
void enable();
|
||||
void disable();
|
||||
|
||||
size_t am_configuration() const;
|
||||
void set_am_configuration(const size_t n);
|
||||
|
||||
size_t nbfm_configuration() const;
|
||||
void set_nbfm_configuration(const size_t n);
|
||||
|
||||
size_t wfm_configuration() const;
|
||||
void set_wfm_configuration(const size_t n);
|
||||
|
||||
/* Sets the model values without updating the radio. */
|
||||
void set_configuration_without_update(
|
||||
uint32_t baseband_bandwidth,
|
||||
uint32_t sampling_rate);
|
||||
/* Resets some members back to default. */
|
||||
void initialize();
|
||||
|
||||
void set_configuration_without_update(
|
||||
Mode new_mode,
|
||||
@@ -107,35 +120,30 @@ class ReceiverModel {
|
||||
|
||||
void configure_from_app_settings(const app_settings::AppSettings& settings);
|
||||
|
||||
/* Get access to the underlying settings to allow
|
||||
* values to be set directly without calling update. */
|
||||
settings_t& settings() { return settings_; }
|
||||
|
||||
private:
|
||||
rf::Frequency frequency_step_{25000};
|
||||
bool enabled_{false};
|
||||
bool rf_amp_{false};
|
||||
int32_t lna_gain_db_{32};
|
||||
uint32_t baseband_bandwidth_{max283x::filter::bandwidth_minimum};
|
||||
int32_t vga_gain_db_{32};
|
||||
Mode mode_{Mode::NarrowbandFMAudio};
|
||||
uint32_t sampling_rate_{3072000};
|
||||
size_t am_config_index = 0;
|
||||
size_t nbfm_config_index = 0;
|
||||
size_t wfm_config_index = 0;
|
||||
uint8_t squelch_level_{80};
|
||||
settings_t settings_{};
|
||||
bool enabled_ = false;
|
||||
|
||||
int32_t tuning_offset();
|
||||
|
||||
void update_tuning_frequency();
|
||||
void update_antenna_bias();
|
||||
void update_rf_amp();
|
||||
void update_lna();
|
||||
void update_baseband_bandwidth();
|
||||
void update_vga();
|
||||
void update_sampling_rate();
|
||||
void update_headphone_volume();
|
||||
void update_lna();
|
||||
void update_vga();
|
||||
void update_rf_amp();
|
||||
|
||||
void update_modulation();
|
||||
void update_am_configuration();
|
||||
void update_nbfm_configuration();
|
||||
void update_wfm_configuration();
|
||||
|
||||
void update_antenna_bias();
|
||||
void update_headphone_volume();
|
||||
};
|
||||
|
||||
#endif /*__RECEIVER_MODEL_H__*/
|
||||
|
||||
@@ -286,7 +286,7 @@ static const char* whitespace_str = " \t\r\n";
|
||||
std::string trim(std::string_view str) {
|
||||
auto first = str.find_first_not_of(whitespace_str);
|
||||
auto last = str.find_last_not_of(whitespace_str);
|
||||
return std::string{str.substr(first, last - first)};
|
||||
return std::string{str.substr(first, last - first + 1)};
|
||||
}
|
||||
|
||||
std::string trimr(std::string_view str) {
|
||||
@@ -296,4 +296,4 @@ std::string trimr(std::string_view str) {
|
||||
|
||||
std::string truncate(std::string_view str, size_t length) {
|
||||
return std::string{str.length() <= length ? str : str.substr(0, length)};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,63 +25,68 @@
|
||||
|
||||
namespace tonekey {
|
||||
|
||||
// Keep list in ascending order by tone frequency
|
||||
const tone_key_t tone_keys = {
|
||||
{"None", 0.0},
|
||||
{"0 XZ", 67.000},
|
||||
{"1 WZ", 69.400},
|
||||
{"2 XA", 71.900},
|
||||
{"3 WA", 74.400},
|
||||
{"4 XB", 77.000},
|
||||
{"5 WB", 79.700},
|
||||
{"6 YZ", 82.500},
|
||||
{"7 YA", 85.400},
|
||||
{"8 YB", 88.500},
|
||||
{"9 ZZ", 91.500},
|
||||
{"10 ZA", 94.800},
|
||||
{"11 ZB", 97.400},
|
||||
{"12 1Z", 100.000},
|
||||
{"13 1A", 103.500},
|
||||
{"14 1B", 107.200},
|
||||
{"15 2Z", 110.900},
|
||||
{"16 2A", 114.800},
|
||||
{"17 2B", 118.800},
|
||||
{"18 3Z", 123.000},
|
||||
{"19 3A", 127.300},
|
||||
{"20 3B", 131.800},
|
||||
{"21 4Z", 136.500},
|
||||
{"22 4A", 141.300},
|
||||
{"23 4B", 146.200},
|
||||
{"24 5Z", 151.400},
|
||||
{"25 5A", 156.700},
|
||||
{"40 --", 159.800},
|
||||
{"26 5B", 162.200},
|
||||
{"41 --", 165.500},
|
||||
{"27 6Z", 167.900},
|
||||
{"42 --", 171.300},
|
||||
{"28 6A", 173.800},
|
||||
{"43 --", 177.300},
|
||||
{"29 6B", 179.900},
|
||||
{"44 --", 183.500},
|
||||
{"30 7Z", 186.200},
|
||||
{"45 --", 189.900},
|
||||
{"31 7A", 192.800},
|
||||
{"46 --", 196.600},
|
||||
{"47 --", 199.500},
|
||||
{"32 M1", 203.500},
|
||||
{"48 8Z", 206.500},
|
||||
{"33 M2", 210.700},
|
||||
{"34 M3", 218.100},
|
||||
{"35 M4", 225.700},
|
||||
{"49 9Z", 229.100},
|
||||
{"36 --", 233.600},
|
||||
{"37 --", 241.800},
|
||||
{"38 --", 250.300},
|
||||
{"50 0Z", 254.100},
|
||||
{"Axient 28kHz", 28000.0},
|
||||
{"Senn. 32.768k", 32768.0},
|
||||
{"Senn. 32.000k", 32000.0},
|
||||
{"Sony 32.382k", 32382.0},
|
||||
{"Shure 19kHz", 19000.0}};
|
||||
{"None", F2Ix100(0.0)},
|
||||
{"1 XZ", F2Ix100(67.0)},
|
||||
{"39 WZ", F2Ix100(69.3)},
|
||||
{"2 XA", F2Ix100(71.9)},
|
||||
{"3 WA", F2Ix100(74.4)},
|
||||
{"4 XB", F2Ix100(77.0)},
|
||||
{"5 WB", F2Ix100(79.7)},
|
||||
{"6 YZ", F2Ix100(82.5)},
|
||||
{"7 YA", F2Ix100(85.4)},
|
||||
{"8 YB", F2Ix100(88.5)},
|
||||
{"9 ZZ", F2Ix100(91.5)},
|
||||
{"10 ZA", F2Ix100(94.8)},
|
||||
{"11 ZB", F2Ix100(97.4)},
|
||||
{"12 1Z", F2Ix100(100.0)},
|
||||
{"13 1A", F2Ix100(103.5)},
|
||||
{"14 1B", F2Ix100(107.2)},
|
||||
{"15 2Z", F2Ix100(110.9)},
|
||||
{"16 2A", F2Ix100(114.8)},
|
||||
{"17 2B", F2Ix100(118.8)},
|
||||
{"18 3Z", F2Ix100(123.0)},
|
||||
{"19 3A", F2Ix100(127.3)},
|
||||
{"20 3B", F2Ix100(131.8)},
|
||||
{"21 4Z", F2Ix100(136.5)},
|
||||
{"22 4A", F2Ix100(141.3)},
|
||||
{"23 4B", F2Ix100(146.2)},
|
||||
{"24 5Z", F2Ix100(151.4)},
|
||||
{"25 5A", F2Ix100(156.7)},
|
||||
{"40 --", F2Ix100(159.8)},
|
||||
{"26 5B", F2Ix100(162.2)},
|
||||
{"41 --", F2Ix100(165.5)},
|
||||
{"27 6Z", F2Ix100(167.9)},
|
||||
{"42 --", F2Ix100(171.3)},
|
||||
{"28 6A", F2Ix100(173.8)},
|
||||
{"43 --", F2Ix100(177.3)},
|
||||
{"29 6B", F2Ix100(179.9)},
|
||||
{"44 --", F2Ix100(183.5)},
|
||||
{"30 7Z", F2Ix100(186.2)},
|
||||
{"45 --", F2Ix100(189.9)},
|
||||
{"31 7A", F2Ix100(192.8)},
|
||||
{"46 --", F2Ix100(196.6)},
|
||||
{"47 --", F2Ix100(199.5)},
|
||||
{"32 M1", F2Ix100(203.5)},
|
||||
{"48 8Z", F2Ix100(206.5)},
|
||||
{"33 M2", F2Ix100(210.7)},
|
||||
{"34 M3", F2Ix100(218.1)},
|
||||
{"35 M4", F2Ix100(225.7)},
|
||||
{"49 9Z", F2Ix100(229.1)},
|
||||
{"36 M5", F2Ix100(233.6)},
|
||||
{"37 M6", F2Ix100(241.8)},
|
||||
{"38 M7", F2Ix100(250.3)},
|
||||
{"50 0Z", F2Ix100(254.1)},
|
||||
{"Shure 19kHz", F2Ix100(19000.0)},
|
||||
{"Axient 28kHz", F2Ix100(28000.0)},
|
||||
{"Senn. 32.000k", F2Ix100(32000.0)},
|
||||
{"Sony 32.382k", F2Ix100(32382.0)},
|
||||
{"Senn. 32.768k", F2Ix100(32768.0)}};
|
||||
|
||||
std::string fx100_string(uint32_t f) {
|
||||
return to_string_dec_uint(f / 100) + "." + to_string_dec_uint((f / 10) % 10);
|
||||
}
|
||||
|
||||
void tone_keys_populate(OptionsField& field) {
|
||||
using option_t = std::pair<std::string, int32_t>;
|
||||
@@ -90,12 +95,11 @@ void tone_keys_populate(OptionsField& field) {
|
||||
std::string tone_name;
|
||||
|
||||
for (size_t c = 0; c < tone_keys.size(); c++) {
|
||||
if (c && c < 51) {
|
||||
auto f = tone_keys[c].second;
|
||||
tone_name = "CTCSS " + tone_keys[c].first + " " + to_string_dec_uint(f) + "." + to_string_dec_uint((uint32_t)(f * 10) % 10);
|
||||
} else {
|
||||
auto f = tone_keys[c].second;
|
||||
if ((c != 0) && (f < 1000 * 100))
|
||||
tone_name = "CTCSS " + fx100_string(f) + " #" + tone_keys[c].first;
|
||||
else
|
||||
tone_name = tone_keys[c].first;
|
||||
}
|
||||
|
||||
tone_key_options.emplace_back(tone_name, c);
|
||||
}
|
||||
@@ -103,8 +107,8 @@ void tone_keys_populate(OptionsField& field) {
|
||||
field.set_options(tone_key_options);
|
||||
}
|
||||
|
||||
float tone_key_frequency(const tone_index index) {
|
||||
return tone_keys[index].second;
|
||||
float tone_key_frequency(tone_index index) {
|
||||
return float(tone_keys[index].second) / 100.0;
|
||||
}
|
||||
|
||||
std::string tone_key_string(tone_index index) {
|
||||
@@ -113,6 +117,81 @@ std::string tone_key_string(tone_index index) {
|
||||
return tone_keys[index].first;
|
||||
}
|
||||
|
||||
// Return string showing frequency only from specific table index
|
||||
std::string tone_key_value_string(tone_index index) {
|
||||
if (index < 0 || (unsigned)index >= tone_keys.size())
|
||||
return std::string("");
|
||||
return fx100_string(tone_keys[index].second);
|
||||
}
|
||||
|
||||
// Return variable-length string showing CTCSS tone from tone frequency
|
||||
// Value is in 0.01 Hz units
|
||||
std::string tone_key_string_by_value(uint32_t value, size_t max_length) {
|
||||
static uint8_t tone_display_toggle{0};
|
||||
static uint32_t last_value;
|
||||
tone_index idx;
|
||||
std::string freq_str;
|
||||
|
||||
// If >10Hz difference between consecutive samples, it's probably noise, so ignore
|
||||
if (abs(value - last_value) > 10 * 100) {
|
||||
last_value = value;
|
||||
tone_display_toggle = 0;
|
||||
return " ";
|
||||
}
|
||||
last_value = value;
|
||||
|
||||
// Only display 1/10 Hz accuracy if <1000 Hz; max 5 characters
|
||||
if (value < 1000 * 100)
|
||||
freq_str = "T:" + fx100_string(value);
|
||||
else
|
||||
freq_str = "T:" + to_string_dec_uint(value / 100);
|
||||
|
||||
// Check field length is enough for character counts in the string below
|
||||
if (max_length >= 7 + 2 + 5) {
|
||||
idx = tone_key_index_by_value(value);
|
||||
if (idx != -1)
|
||||
return freq_str + " #" + tone_key_string(idx);
|
||||
} else {
|
||||
// Not enough space; toggle between display of tone received and tone code #
|
||||
if (tone_display_toggle++ >= TONE_DISPLAY_TOGGLE_COUNTER) {
|
||||
if (tone_display_toggle >= TONE_DISPLAY_TOGGLE_COUNTER * 2) tone_display_toggle = 0;
|
||||
|
||||
// Look for a match in the table (otherwise just display frequency)
|
||||
idx = tone_key_index_by_value(value);
|
||||
if (idx != -1)
|
||||
return "T:" + tone_key_string(idx);
|
||||
}
|
||||
}
|
||||
return freq_str;
|
||||
}
|
||||
|
||||
// Search tone_key table for tone frequency value
|
||||
// Value is in 0.01 Hz units
|
||||
tone_index tone_key_index_by_value(uint32_t value) {
|
||||
uint32_t diff;
|
||||
uint32_t min_diff{value * 2};
|
||||
tone_index min_idx{-1};
|
||||
tone_index idx;
|
||||
|
||||
// Find nearest match
|
||||
for (idx = 0; idx < (tone_index)tone_keys.size(); idx++) {
|
||||
diff = abs(value - tone_keys[idx].second);
|
||||
if (diff < min_diff) {
|
||||
min_idx = idx;
|
||||
min_diff = diff;
|
||||
} else {
|
||||
// list is sorted in frequency order; if diff is getting larger than we've passed it
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Arbitrary confidence threshold
|
||||
if (min_diff < TONE_FREQ_TOLERANCE_CENTIHZ)
|
||||
return min_idx;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
tone_index tone_key_index_by_string(char* str) {
|
||||
if (!str)
|
||||
return -1;
|
||||
@@ -123,9 +202,4 @@ tone_index tone_key_index_by_string(char* str) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* tone_index tone_key_index_by_value( int32_t freq )
|
||||
{
|
||||
return -1 ;
|
||||
} */
|
||||
|
||||
} // namespace tonekey
|
||||
|
||||
@@ -30,18 +30,23 @@ using namespace ui;
|
||||
|
||||
namespace tonekey {
|
||||
|
||||
typedef int16_t tone_index;
|
||||
#define TONE_FREQ_TOLERANCE_CENTIHZ (4 * 100)
|
||||
#define TONE_DISPLAY_TOGGLE_COUNTER 3
|
||||
#define F2Ix100(x) (int32_t)(x * 100.0)
|
||||
|
||||
using tone_key_t = std::vector<std::pair<std::string, float>>;
|
||||
typedef int32_t tone_index;
|
||||
|
||||
using tone_key_t = std::vector<std::pair<std::string, uint32_t>>;
|
||||
|
||||
extern const tone_key_t tone_keys;
|
||||
|
||||
void tone_keys_populate(OptionsField& field);
|
||||
float tone_key_frequency(const tone_index index);
|
||||
float tone_key_frequency(tone_index index);
|
||||
|
||||
std::string tone_key_string(const tone_index index);
|
||||
tone_index tone_key_index_by_string(char* str);
|
||||
// tone_index tone_key_index_by_value( int32_t freq );
|
||||
std::string tone_key_string(tone_index index);
|
||||
std::string tone_key_value_string(tone_index index);
|
||||
std::string tone_key_string_by_value(uint32_t value, size_t max_length);
|
||||
tone_index tone_key_index_by_value(uint32_t value);
|
||||
|
||||
} // namespace tonekey
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2016 Furrtek
|
||||
* Copyright (C) 2023 Kyle Reed
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
@@ -22,15 +23,13 @@
|
||||
|
||||
#include "transmitter_model.hpp"
|
||||
|
||||
#include "audio.hpp"
|
||||
#include "baseband_api.hpp"
|
||||
|
||||
#include "portapack_persistent_memory.hpp"
|
||||
#include "event_m0.hpp"
|
||||
#include "hackrf_gpio.hpp"
|
||||
#include "portapack.hpp"
|
||||
#include "rtc_time.hpp"
|
||||
#include "event_m0.hpp"
|
||||
#include "portapack_persistent_memory.hpp"
|
||||
#include "radio.hpp"
|
||||
#include "audio.hpp"
|
||||
|
||||
using namespace hackrf::one;
|
||||
using namespace portapack;
|
||||
@@ -44,75 +43,52 @@ void TransmitterModel::set_target_frequency(rf::Frequency f) {
|
||||
update_tuning_frequency();
|
||||
}
|
||||
|
||||
void TransmitterModel::set_antenna_bias() {
|
||||
update_antenna_bias();
|
||||
}
|
||||
|
||||
bool TransmitterModel::rf_amp() const {
|
||||
return rf_amp_;
|
||||
}
|
||||
|
||||
void TransmitterModel::set_rf_amp(bool enabled) {
|
||||
rf_amp_ = enabled;
|
||||
update_rf_amp();
|
||||
}
|
||||
|
||||
int32_t TransmitterModel::lna() const {
|
||||
return lna_gain_db_;
|
||||
}
|
||||
|
||||
void TransmitterModel::set_lna(int32_t v_db) {
|
||||
lna_gain_db_ = v_db;
|
||||
update_lna();
|
||||
}
|
||||
|
||||
uint32_t TransmitterModel::baseband_bandwidth() const {
|
||||
return baseband_bandwidth_;
|
||||
return settings_.baseband_bandwidth;
|
||||
}
|
||||
|
||||
void TransmitterModel::set_baseband_bandwidth(uint32_t v) {
|
||||
baseband_bandwidth_ = v;
|
||||
settings_.baseband_bandwidth = v;
|
||||
update_baseband_bandwidth();
|
||||
}
|
||||
|
||||
int32_t TransmitterModel::vga() const {
|
||||
return vga_gain_db_;
|
||||
}
|
||||
|
||||
void TransmitterModel::set_vga(int32_t v_db) {
|
||||
vga_gain_db_ = v_db;
|
||||
update_vga();
|
||||
}
|
||||
|
||||
uint32_t TransmitterModel::channel_bandwidth() const {
|
||||
return channel_bandwidth_;
|
||||
}
|
||||
|
||||
void TransmitterModel::set_channel_bandwidth(uint32_t v) {
|
||||
channel_bandwidth_ = v;
|
||||
}
|
||||
|
||||
uint32_t TransmitterModel::sampling_rate() const {
|
||||
return sampling_rate_;
|
||||
return settings_.sampling_rate;
|
||||
}
|
||||
|
||||
void TransmitterModel::set_sampling_rate(uint32_t v) {
|
||||
sampling_rate_ = v;
|
||||
settings_.sampling_rate = v;
|
||||
update_sampling_rate();
|
||||
}
|
||||
|
||||
int32_t TransmitterModel::tx_gain() const {
|
||||
return tx_gain_db_;
|
||||
uint32_t TransmitterModel::channel_bandwidth() const {
|
||||
return settings_.channel_bandwidth;
|
||||
}
|
||||
|
||||
void TransmitterModel::set_tx_gain(int32_t v_db) {
|
||||
tx_gain_db_ = v_db;
|
||||
void TransmitterModel::set_channel_bandwidth(uint32_t v) {
|
||||
settings_.channel_bandwidth = v;
|
||||
}
|
||||
|
||||
uint8_t TransmitterModel::tx_gain() const {
|
||||
return settings_.tx_gain_db;
|
||||
}
|
||||
|
||||
void TransmitterModel::set_tx_gain(uint8_t v_db) {
|
||||
settings_.tx_gain_db = v_db;
|
||||
update_tx_gain();
|
||||
}
|
||||
|
||||
void TransmitterModel::on_tick_second() {
|
||||
if (portapack::persistent_memory::stealth_mode())
|
||||
led_tx.toggle();
|
||||
bool TransmitterModel::rf_amp() const {
|
||||
return settings_.rf_amp;
|
||||
}
|
||||
|
||||
void TransmitterModel::set_rf_amp(bool enabled) {
|
||||
settings_.rf_amp = enabled;
|
||||
update_rf_amp();
|
||||
}
|
||||
|
||||
void TransmitterModel::set_antenna_bias() {
|
||||
update_antenna_bias();
|
||||
}
|
||||
|
||||
void TransmitterModel::enable() {
|
||||
@@ -121,8 +97,6 @@ void TransmitterModel::enable() {
|
||||
update_tuning_frequency();
|
||||
update_antenna_bias();
|
||||
update_rf_amp();
|
||||
update_lna();
|
||||
update_vga();
|
||||
update_baseband_bandwidth();
|
||||
update_sampling_rate();
|
||||
update_tx_gain();
|
||||
@@ -147,53 +121,25 @@ void TransmitterModel::disable() {
|
||||
led_tx.off();
|
||||
}
|
||||
|
||||
void TransmitterModel::set_configuration_without_update(
|
||||
uint32_t baseband_bandwidth,
|
||||
uint32_t sampling_rate) {
|
||||
baseband_bandwidth_ = baseband_bandwidth;
|
||||
sampling_rate_ = sampling_rate;
|
||||
void TransmitterModel::initialize() {
|
||||
settings_ = settings_t{};
|
||||
}
|
||||
|
||||
void TransmitterModel::configure_from_app_settings(
|
||||
const app_settings::AppSettings& settings) {
|
||||
baseband_bandwidth_ = settings.baseband_bandwidth;
|
||||
channel_bandwidth_ = settings.channel_bandwidth;
|
||||
tx_gain_db_ = settings.tx_gain;
|
||||
rf_amp_ = settings.tx_amp;
|
||||
|
||||
// TODO: Do these make sense for TX?
|
||||
lna_gain_db_ = settings.lna;
|
||||
vga_gain_db_ = settings.vga;
|
||||
sampling_rate_ = settings.sampling_rate;
|
||||
settings_.baseband_bandwidth = settings.baseband_bandwidth;
|
||||
settings_.sampling_rate = settings.sampling_rate;
|
||||
settings_.channel_bandwidth = settings.channel_bandwidth;
|
||||
settings_.tx_gain_db = settings.tx_gain;
|
||||
settings_.rf_amp = settings.tx_amp;
|
||||
}
|
||||
|
||||
void TransmitterModel::update_tuning_frequency() {
|
||||
radio::set_tuning_frequency(target_frequency());
|
||||
}
|
||||
|
||||
void TransmitterModel::update_antenna_bias() {
|
||||
if (enabled_)
|
||||
radio::set_antenna_bias(portapack::get_antenna_bias());
|
||||
}
|
||||
|
||||
void TransmitterModel::update_rf_amp() {
|
||||
radio::set_rf_amp(rf_amp_);
|
||||
}
|
||||
|
||||
void TransmitterModel::update_lna() {
|
||||
radio::set_lna_gain(lna_gain_db_);
|
||||
}
|
||||
|
||||
void TransmitterModel::update_baseband_bandwidth() {
|
||||
radio::set_baseband_filter_bandwidth(baseband_bandwidth_);
|
||||
}
|
||||
|
||||
void TransmitterModel::update_vga() {
|
||||
radio::set_vga_gain(vga_gain_db_);
|
||||
}
|
||||
|
||||
void TransmitterModel::update_tx_gain() {
|
||||
radio::set_tx_gain(tx_gain_db_);
|
||||
radio::set_baseband_filter_bandwidth(baseband_bandwidth());
|
||||
}
|
||||
|
||||
void TransmitterModel::update_sampling_rate() {
|
||||
@@ -206,3 +152,21 @@ void TransmitterModel::update_sampling_rate() {
|
||||
radio::set_baseband_rate(sampling_rate());
|
||||
update_tuning_frequency();
|
||||
}
|
||||
|
||||
void TransmitterModel::update_tx_gain() {
|
||||
radio::set_tx_gain(tx_gain());
|
||||
}
|
||||
|
||||
void TransmitterModel::update_rf_amp() {
|
||||
radio::set_rf_amp(rf_amp());
|
||||
}
|
||||
|
||||
void TransmitterModel::update_antenna_bias() {
|
||||
if (enabled_)
|
||||
radio::set_antenna_bias(portapack::get_antenna_bias());
|
||||
}
|
||||
|
||||
void TransmitterModel::on_tick_second() {
|
||||
if (portapack::persistent_memory::stealth_mode())
|
||||
led_tx.toggle();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2016 Furrtek
|
||||
* Copyright (C) 2023 Kyle Reed
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
@@ -26,77 +27,68 @@
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
#include "receiver_model.hpp"
|
||||
#include "app_settings.hpp"
|
||||
#include "message.hpp"
|
||||
#include "rf_path.hpp"
|
||||
#include "max2837.hpp"
|
||||
#include "volume.hpp"
|
||||
#include "message.hpp"
|
||||
#include "receiver_model.hpp"
|
||||
#include "rf_path.hpp"
|
||||
#include "signal.hpp"
|
||||
|
||||
class TransmitterModel {
|
||||
public:
|
||||
struct settings_t {
|
||||
uint32_t baseband_bandwidth = max283x::filter::bandwidth_minimum;
|
||||
uint32_t sampling_rate = 3'072'000;
|
||||
uint32_t channel_bandwidth = 1;
|
||||
/* 35 should give approx 1m transmission range. */
|
||||
uint8_t tx_gain_db = 35;
|
||||
bool rf_amp = false;
|
||||
};
|
||||
|
||||
/* The frequency to transmit on. */
|
||||
rf::Frequency target_frequency() const;
|
||||
void set_target_frequency(rf::Frequency f);
|
||||
|
||||
void set_antenna_bias();
|
||||
|
||||
bool rf_amp() const;
|
||||
void set_rf_amp(bool enabled);
|
||||
|
||||
// TODO: does this make sense on TX?
|
||||
int32_t lna() const;
|
||||
void set_lna(int32_t v_db);
|
||||
|
||||
uint32_t baseband_bandwidth() const;
|
||||
void set_baseband_bandwidth(uint32_t v);
|
||||
|
||||
// TODO: does this make sense on TX?
|
||||
int32_t vga() const;
|
||||
void set_vga(int32_t v_db);
|
||||
|
||||
int32_t tx_gain() const;
|
||||
void set_tx_gain(int32_t v_db);
|
||||
|
||||
// TODO: Doesn't actually affect radio.
|
||||
uint32_t channel_bandwidth() const;
|
||||
void set_channel_bandwidth(uint32_t v);
|
||||
|
||||
// TODO: does this make sense on TX?
|
||||
uint32_t sampling_rate() const;
|
||||
void set_sampling_rate(uint32_t v);
|
||||
|
||||
uint8_t tx_gain() const;
|
||||
void set_tx_gain(uint8_t v_db);
|
||||
|
||||
bool rf_amp() const;
|
||||
void set_rf_amp(bool enabled);
|
||||
|
||||
void set_antenna_bias();
|
||||
|
||||
void enable();
|
||||
void disable();
|
||||
|
||||
/* Sets the model values without updating the radio. */
|
||||
void set_configuration_without_update(
|
||||
uint32_t baseband_bandwidth,
|
||||
uint32_t sampling_rate);
|
||||
void initialize();
|
||||
|
||||
void configure_from_app_settings(const app_settings::AppSettings& settings);
|
||||
|
||||
/* Get access to the underlying settings to allow
|
||||
* values to be set directly without calling update. */
|
||||
settings_t& settings() { return settings_; }
|
||||
|
||||
private:
|
||||
bool enabled_{false};
|
||||
bool rf_amp_{false};
|
||||
int32_t lna_gain_db_{0};
|
||||
uint32_t channel_bandwidth_{1};
|
||||
uint32_t baseband_bandwidth_{max2837::filter::bandwidth_minimum};
|
||||
int32_t vga_gain_db_{8};
|
||||
/* 35 should give approx 1m transmission range. */
|
||||
int32_t tx_gain_db_{35};
|
||||
uint32_t sampling_rate_{3072000};
|
||||
settings_t settings_{};
|
||||
bool enabled_ = false;
|
||||
SignalToken signal_token_tick_second{};
|
||||
|
||||
void update_tuning_frequency();
|
||||
void update_antenna_bias();
|
||||
void update_rf_amp();
|
||||
void update_lna();
|
||||
void update_baseband_bandwidth();
|
||||
void update_vga();
|
||||
void update_tx_gain();
|
||||
void update_sampling_rate();
|
||||
void update_tx_gain();
|
||||
void update_rf_amp();
|
||||
void update_antenna_bias();
|
||||
void on_tick_second();
|
||||
};
|
||||
|
||||
|
||||
@@ -37,9 +37,13 @@ AlphanumView::AlphanumView(
|
||||
: TextEntryView(nav, str, max_length) {
|
||||
size_t n;
|
||||
|
||||
add_children({&button_mode,
|
||||
&text_raw,
|
||||
&field_raw});
|
||||
add_children({
|
||||
&labels,
|
||||
&field_raw,
|
||||
&text_raw_to_char,
|
||||
&button_delete,
|
||||
&button_mode,
|
||||
});
|
||||
|
||||
const auto button_fn = [this](Button& button) {
|
||||
this->on_button(button);
|
||||
@@ -65,10 +69,19 @@ AlphanumView::AlphanumView(
|
||||
set_mode(mode + 1);
|
||||
};
|
||||
|
||||
button_delete.on_select = [this](Button&) {
|
||||
char_delete();
|
||||
};
|
||||
|
||||
field_raw.set_value('0');
|
||||
field_raw.on_select = [this](NumberField&) {
|
||||
char_add(field_raw.value());
|
||||
};
|
||||
|
||||
// make text_raw_to_char widget display the char value from field_raw
|
||||
field_raw.on_change = [this](auto) {
|
||||
text_raw_to_char.set(std::string{static_cast<char>(field_raw.value())});
|
||||
};
|
||||
}
|
||||
|
||||
void AlphanumView::set_mode(const uint32_t new_mode) {
|
||||
@@ -96,11 +109,7 @@ void AlphanumView::set_mode(const uint32_t new_mode) {
|
||||
|
||||
void AlphanumView::on_button(Button& button) {
|
||||
const auto c = button.text()[0];
|
||||
|
||||
if (c == '<')
|
||||
char_delete();
|
||||
else
|
||||
char_add(c);
|
||||
char_add(c);
|
||||
}
|
||||
|
||||
bool AlphanumView::on_encoder(const EncoderEvent delta) {
|
||||
|
||||
@@ -43,14 +43,14 @@ class AlphanumView : public TextEntryView {
|
||||
bool on_encoder(const EncoderEvent delta) override;
|
||||
|
||||
private:
|
||||
const char* const keys_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ, .<";
|
||||
const char* const keys_lower = "abcdefghijklmnopqrstuvwxyz, .<";
|
||||
const char* const keys_digit = "0123456789!\"#'()*+-/:;=>?@[\\]<";
|
||||
const char* const keys_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ, ._";
|
||||
const char* const keys_lower = "abcdefghijklmnopqrstuvwxyz, ._";
|
||||
const char* const keys_digit = "0123456789!\"#'()*+-/:;=<>@[\\]?";
|
||||
|
||||
const std::pair<std::string, const char*> key_sets[3] = {
|
||||
{"Upper", keys_upper},
|
||||
{"Lower", keys_lower},
|
||||
{"Digit", keys_digit}};
|
||||
{"ABC", keys_upper},
|
||||
{"abc", keys_lower},
|
||||
{"123", keys_digit}};
|
||||
|
||||
int16_t focused_button = 0;
|
||||
uint32_t mode = 0; // Uppercase
|
||||
@@ -60,13 +60,10 @@ class AlphanumView : public TextEntryView {
|
||||
|
||||
std::array<Button, 30> buttons{};
|
||||
|
||||
Button button_mode{
|
||||
{21 * 8, 33 * 8, 8 * 8, 32},
|
||||
""};
|
||||
Labels labels{
|
||||
{{1 * 8, 33 * 8}, "Raw:", Color::light_grey()},
|
||||
{{1 * 8, 35 * 8}, "AKA:", Color::light_grey()}};
|
||||
|
||||
Text text_raw{
|
||||
{1 * 8, 33 * 8, 4 * 8, 16},
|
||||
"Raw:"};
|
||||
NumberField field_raw{
|
||||
{5 * 8, 33 * 8},
|
||||
3,
|
||||
@@ -74,9 +71,17 @@ class AlphanumView : public TextEntryView {
|
||||
1,
|
||||
'0'};
|
||||
|
||||
Button button_ok{
|
||||
{10 * 8, 33 * 8, 9 * 8, 32},
|
||||
"OK"};
|
||||
Text text_raw_to_char{
|
||||
{5 * 8, 35 * 8, 4 * 8, 16},
|
||||
"0"};
|
||||
|
||||
Button button_delete{
|
||||
{9 * 8, 33 * 8, 6 * 8, 32},
|
||||
"<DEL"};
|
||||
|
||||
Button button_mode{
|
||||
{16 * 8, 33 * 8, 5 * 8, 32},
|
||||
""};
|
||||
};
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
@@ -280,7 +280,7 @@ FrequencyOptionsView::FrequencyOptionsView(
|
||||
}
|
||||
|
||||
void FrequencyOptionsView::set_step(rf::Frequency f) {
|
||||
field_step.set_by_value(f);
|
||||
field_step.set_by_nearest_value(f);
|
||||
}
|
||||
|
||||
void FrequencyOptionsView::set_reference_ppm_correction(int32_t v) {
|
||||
|
||||
@@ -36,7 +36,7 @@ using namespace portapack;
|
||||
namespace ui {
|
||||
namespace spectrum {
|
||||
|
||||
/* AudioSpectrumView******************************************************/
|
||||
/* AudioSpectrumView ******************************************************/
|
||||
|
||||
AudioSpectrumView::AudioSpectrumView(
|
||||
const Rect parent_rect)
|
||||
@@ -247,28 +247,25 @@ void FrequencyScale::on_tick_second() {
|
||||
_blink = !_blink;
|
||||
}
|
||||
|
||||
/* WaterfallView *********************************************************/
|
||||
/* WaterfallWidget *********************************************************/
|
||||
// TODO: buffer and use "paint" instead of immediate drawing would help with
|
||||
// preventing flicker from drawing. Would use more RAM however.
|
||||
|
||||
void WaterfallView::on_show() {
|
||||
void WaterfallWidget::on_show() {
|
||||
clear();
|
||||
|
||||
const auto screen_r = screen_rect();
|
||||
display.scroll_set_area(screen_r.top(), screen_r.bottom());
|
||||
}
|
||||
|
||||
void WaterfallView::on_hide() {
|
||||
void WaterfallWidget::on_hide() {
|
||||
/* TODO: Clear region to eliminate brief flash of content at un-shifted
|
||||
* position?
|
||||
*/
|
||||
display.scroll_disable();
|
||||
}
|
||||
|
||||
void WaterfallView::paint(Painter& painter) {
|
||||
// Do nothing.
|
||||
(void)painter;
|
||||
}
|
||||
|
||||
void WaterfallView::on_channel_spectrum(
|
||||
void WaterfallWidget::on_channel_spectrum(
|
||||
const ChannelSpectrum& spectrum) {
|
||||
/* TODO: static_assert that message.spectrum.db.size() >= pixel_row.size() */
|
||||
|
||||
@@ -290,16 +287,16 @@ void WaterfallView::on_channel_spectrum(
|
||||
pixel_row);
|
||||
}
|
||||
|
||||
void WaterfallView::clear() {
|
||||
void WaterfallWidget::clear() {
|
||||
display.fill_rectangle(
|
||||
screen_rect(),
|
||||
Color::black());
|
||||
}
|
||||
|
||||
/* WaterfallWidget *******************************************************/
|
||||
/* WaterfallView *******************************************************/
|
||||
|
||||
WaterfallWidget::WaterfallWidget(const bool cursor) {
|
||||
add_children({&waterfall_view,
|
||||
WaterfallView::WaterfallView(const bool cursor) {
|
||||
add_children({&waterfall_widget,
|
||||
&frequency_scale});
|
||||
|
||||
frequency_scale.set_focusable(cursor);
|
||||
@@ -310,17 +307,17 @@ WaterfallWidget::WaterfallWidget(const bool cursor) {
|
||||
};
|
||||
}
|
||||
|
||||
void WaterfallWidget::on_show() {
|
||||
void WaterfallView::on_show() {
|
||||
// TODO: Assert that baseband is not shutdown.
|
||||
baseband::spectrum_streaming_start();
|
||||
}
|
||||
|
||||
void WaterfallWidget::on_hide() {
|
||||
void WaterfallView::on_hide() {
|
||||
// TODO: Assert that baseband is not shutdown.
|
||||
baseband::spectrum_streaming_stop();
|
||||
}
|
||||
|
||||
void WaterfallWidget::show_audio_spectrum_view(const bool show) {
|
||||
void WaterfallView::show_audio_spectrum_view(const bool show) {
|
||||
if ((audio_spectrum_view && show) || (!audio_spectrum_view && !show)) return;
|
||||
|
||||
if (show) {
|
||||
@@ -335,18 +332,18 @@ void WaterfallWidget::show_audio_spectrum_view(const bool show) {
|
||||
}
|
||||
}
|
||||
|
||||
void WaterfallWidget::update_widgets_rect() {
|
||||
void WaterfallView::update_widgets_rect() {
|
||||
if (audio_spectrum_view) {
|
||||
frequency_scale.set_parent_rect({0, audio_spectrum_height, screen_rect().width(), scale_height});
|
||||
waterfall_view.set_parent_rect(waterfall_reduced_rect);
|
||||
waterfall_widget.set_parent_rect(waterfall_reduced_rect);
|
||||
} else {
|
||||
frequency_scale.set_parent_rect({0, 0, screen_rect().width(), scale_height});
|
||||
waterfall_view.set_parent_rect(waterfall_normal_rect);
|
||||
waterfall_widget.set_parent_rect(waterfall_normal_rect);
|
||||
}
|
||||
waterfall_view.on_show();
|
||||
waterfall_widget.on_show();
|
||||
}
|
||||
|
||||
void WaterfallWidget::set_parent_rect(const Rect new_parent_rect) {
|
||||
void WaterfallView::set_parent_rect(const Rect new_parent_rect) {
|
||||
View::set_parent_rect(new_parent_rect);
|
||||
|
||||
waterfall_normal_rect = {0, scale_height, new_parent_rect.width(), new_parent_rect.height() - scale_height};
|
||||
@@ -355,13 +352,8 @@ void WaterfallWidget::set_parent_rect(const Rect new_parent_rect) {
|
||||
update_widgets_rect();
|
||||
}
|
||||
|
||||
void WaterfallWidget::paint(Painter& painter) {
|
||||
// TODO:
|
||||
(void)painter;
|
||||
}
|
||||
|
||||
void WaterfallWidget::on_channel_spectrum(const ChannelSpectrum& spectrum) {
|
||||
waterfall_view.on_channel_spectrum(spectrum);
|
||||
void WaterfallView::on_channel_spectrum(const ChannelSpectrum& spectrum) {
|
||||
waterfall_widget.on_channel_spectrum(spectrum);
|
||||
sampling_rate = spectrum.sampling_rate;
|
||||
frequency_scale.set_spectrum_sampling_rate(sampling_rate);
|
||||
frequency_scale.set_channel_filter(
|
||||
@@ -370,9 +362,40 @@ void WaterfallWidget::on_channel_spectrum(const ChannelSpectrum& spectrum) {
|
||||
spectrum.channel_filter_transition);
|
||||
}
|
||||
|
||||
void WaterfallWidget::on_audio_spectrum() {
|
||||
void WaterfallView::on_audio_spectrum() {
|
||||
audio_spectrum_view->on_audio_spectrum(audio_spectrum_data);
|
||||
}
|
||||
|
||||
} /* namespace spectrum */
|
||||
|
||||
uint32_t filter_bandwidth_for_sampling_rate(int32_t sampling_rate) {
|
||||
switch (sampling_rate) { // Use the var fs (sampling_rate) to set up BPF aprox < fs_max / 2 by Nyquist theorem.
|
||||
case 0 ... 2000000: // BW Captured range (0 <= 250kHz max) fs = 8 x 250 kHz.
|
||||
return 1750000; // Minimum BPF MAX2837 for all those lower BW options.
|
||||
|
||||
case 4000000 ... 6000000: // BW capture range (500k...750kHz max) fs_max = 8 x 750kHz = 6Mhz
|
||||
// BW 500k...750kHz, ex. 500kHz (fs = 8 x BW = 4Mhz), BW 600kHz (fs = 4,8Mhz), BW 750 kHz (fs = 6Mhz).
|
||||
return 2500000; // In some IC, MAX2837 appears as 2250000, but both work similarly.
|
||||
|
||||
case 8800000: // BW capture 1,1Mhz fs = 8 x 1,1Mhz = 8,8Mhz. (1Mhz showed slightly higher noise background).
|
||||
return 3500000;
|
||||
|
||||
case 14000000: // BW capture 1,75Mhz, fs = 8 x 1,75Mhz = 14Mhz
|
||||
// Good BPF, good matching, but LCD flickers, refresh rate should be < 20 Hz, reasonable picture.
|
||||
return 5000000;
|
||||
|
||||
case 16000000: // BW capture 2Mhz, fs = 8 x 2Mhz = 16Mhz
|
||||
// Good BPF, good matching, but LCD flickers, refresh rate should be < 20 Hz, reasonable picture.
|
||||
return 6000000;
|
||||
|
||||
case 20000000: // BW capture 2,5Mhz, fs = 8 x 2,5 Mhz = 20Mhz
|
||||
// Good BPF, good matching, but LCD flickers, refresh rate should be < 20 Hz, reasonable picture.
|
||||
return 7000000;
|
||||
|
||||
default: // BW capture 2,75Mhz, fs = 8 x 2,75Mhz = 22Mhz max ADC sampling and others.
|
||||
// We tested also 9Mhz FPB slightly too much noise floor, better at 8Mhz.
|
||||
return 8000000;
|
||||
}
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
@@ -108,12 +108,11 @@ class FrequencyScale : public Widget {
|
||||
* If the baseband is shutdown or otherwise not running when interacting
|
||||
* with these, they will almost certainly hang the device. */
|
||||
|
||||
class WaterfallView : public Widget {
|
||||
class WaterfallWidget : public Widget {
|
||||
public:
|
||||
void on_show() override;
|
||||
void on_hide() override;
|
||||
|
||||
void paint(Painter& painter) override;
|
||||
void paint(Painter&) override {}
|
||||
|
||||
void on_channel_spectrum(const ChannelSpectrum& spectrum);
|
||||
|
||||
@@ -121,16 +120,16 @@ class WaterfallView : public Widget {
|
||||
void clear();
|
||||
};
|
||||
|
||||
class WaterfallWidget : public View {
|
||||
class WaterfallView : public View {
|
||||
public:
|
||||
std::function<void(int32_t offset)> on_select{};
|
||||
|
||||
WaterfallWidget(const bool cursor = false);
|
||||
WaterfallView(const bool cursor = false);
|
||||
|
||||
WaterfallWidget(const WaterfallWidget&) = delete;
|
||||
WaterfallWidget(WaterfallWidget&&) = delete;
|
||||
WaterfallWidget& operator=(const WaterfallWidget&) = delete;
|
||||
WaterfallWidget& operator=(WaterfallWidget&&) = delete;
|
||||
WaterfallView(const WaterfallView&) = delete;
|
||||
WaterfallView(WaterfallView&&) = delete;
|
||||
WaterfallView& operator=(const WaterfallView&) = delete;
|
||||
WaterfallView& operator=(WaterfallView&&) = delete;
|
||||
|
||||
void on_show() override;
|
||||
void on_hide() override;
|
||||
@@ -139,8 +138,6 @@ class WaterfallWidget : public View {
|
||||
|
||||
void show_audio_spectrum_view(const bool show);
|
||||
|
||||
void paint(Painter& painter) override;
|
||||
|
||||
private:
|
||||
void update_widgets_rect();
|
||||
|
||||
@@ -148,7 +145,7 @@ class WaterfallWidget : public View {
|
||||
static constexpr Dim audio_spectrum_height = 16 * 2 + 20;
|
||||
static constexpr Dim scale_height = 20;
|
||||
|
||||
WaterfallView waterfall_view{};
|
||||
WaterfallWidget waterfall_widget{};
|
||||
FrequencyScale frequency_scale{};
|
||||
|
||||
ChannelSpectrumFIFO* channel_fifo{nullptr};
|
||||
@@ -195,6 +192,10 @@ class WaterfallWidget : public View {
|
||||
};
|
||||
|
||||
} /* namespace spectrum */
|
||||
|
||||
/* Calculates the best anti_alias_baseband_bandwidth_filter for the given sampling rate. */
|
||||
uint32_t filter_bandwidth_for_sampling_rate(int32_t sampling_rate);
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
#endif /*__UI_SPECTRUM_H__*/
|
||||
|
||||
@@ -50,7 +50,7 @@ class TextEntryView : public View {
|
||||
|
||||
TextField text_input;
|
||||
Button button_ok{
|
||||
{10 * 8, 33 * 8, 9 * 8, 32},
|
||||
{22 * 8, 33 * 8, 7 * 8, 32},
|
||||
"OK"};
|
||||
};
|
||||
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
#include "ui_flash_utility.hpp"
|
||||
#include "ui_sd_over_usb.hpp"
|
||||
#include "ui_spectrum_painter.hpp"
|
||||
#include "ui_ss_viewer.hpp"
|
||||
|
||||
// #include "acars_app.hpp"
|
||||
#include "ais_app.hpp"
|
||||
@@ -98,9 +99,51 @@
|
||||
|
||||
using portapack::receiver_model;
|
||||
using portapack::transmitter_model;
|
||||
namespace pmem = portapack::persistent_memory;
|
||||
|
||||
namespace ui {
|
||||
|
||||
/* StatusTray ************************************************************/
|
||||
|
||||
StatusTray::StatusTray(Point pos)
|
||||
: View{{pos, {0, height}}},
|
||||
pos_(pos) {
|
||||
set_focusable(false);
|
||||
}
|
||||
|
||||
void StatusTray::add(Widget* child) {
|
||||
width_ += child->parent_rect().width();
|
||||
add_child(child);
|
||||
}
|
||||
|
||||
void StatusTray::update_layout() {
|
||||
// Widen the tray's parent rect.
|
||||
auto rect = parent_rect();
|
||||
set_parent_rect({{rect.left() - width_, rect.top()}, {rect.right() + width_, height}});
|
||||
|
||||
// Update the children.
|
||||
auto x = 0;
|
||||
for (auto child : children()) {
|
||||
auto size = child->parent_rect().size();
|
||||
child->set_parent_rect({{x, 0}, size});
|
||||
x += size.width();
|
||||
}
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
void StatusTray::clear() {
|
||||
// More efficient than 'remove_children'.
|
||||
for (auto child : children())
|
||||
child->set_parent(nullptr);
|
||||
children_.clear();
|
||||
width_ = 0;
|
||||
set_parent_rect({pos_, {width_, height}});
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
void StatusTray::paint(Painter&) {
|
||||
}
|
||||
|
||||
/* SystemStatusView ******************************************************/
|
||||
|
||||
SystemStatusView::SystemStatusView(
|
||||
@@ -111,48 +154,19 @@ SystemStatusView::SystemStatusView(
|
||||
&button_back,
|
||||
&title,
|
||||
&button_title,
|
||||
&button_converter,
|
||||
&button_speaker,
|
||||
&button_stealth,
|
||||
//&button_textentry,
|
||||
&button_camera,
|
||||
&button_sleep,
|
||||
&button_bias_tee,
|
||||
&button_clock_status,
|
||||
&sd_card_status_view,
|
||||
&status_icons,
|
||||
});
|
||||
|
||||
if (portapack::persistent_memory::should_use_sdcard_for_pmem()) {
|
||||
portapack::persistent_memory::load_persistent_settings_from_file();
|
||||
}
|
||||
|
||||
if (portapack::persistent_memory::config_hide_converter()) {
|
||||
button_converter.hidden(true);
|
||||
} else {
|
||||
button_converter.hidden(false);
|
||||
if (portapack::persistent_memory::config_converter()) {
|
||||
button_converter.set_foreground(Color::red());
|
||||
} else {
|
||||
button_converter.set_foreground(Color::light_grey());
|
||||
}
|
||||
if (pmem::should_use_sdcard_for_pmem()) {
|
||||
pmem::load_persistent_settings_from_file();
|
||||
}
|
||||
|
||||
button_back.id = -1; // Special ID used by FocusManager
|
||||
title.set_style(&Styles::bg_dark_grey);
|
||||
|
||||
if (portapack::persistent_memory::stealth_mode())
|
||||
button_stealth.set_foreground(ui::Color::green());
|
||||
|
||||
/*if (!portapack::persistent_memory::ui_config_textentry())
|
||||
button_textentry.set_bitmap(&bitmap_icon_keyboard);
|
||||
else
|
||||
button_textentry.set_bitmap(&bitmap_icon_unistroke);*/
|
||||
|
||||
refresh();
|
||||
|
||||
button_back.on_select = [this](ImageButton&) {
|
||||
if (portapack::persistent_memory::should_use_sdcard_for_pmem()) {
|
||||
portapack::persistent_memory::save_persistent_settings_to_file();
|
||||
if (pmem::should_use_sdcard_for_pmem()) {
|
||||
pmem::save_persistent_settings_to_file();
|
||||
}
|
||||
if (this->on_back)
|
||||
this->on_back();
|
||||
@@ -166,22 +180,27 @@ SystemStatusView::SystemStatusView(
|
||||
this->on_converter();
|
||||
};
|
||||
|
||||
button_speaker.on_select = [this](ImageButton&) {
|
||||
this->on_speaker();
|
||||
toggle_speaker.on_change = [this](bool v) {
|
||||
pmem::set_config_speaker_disable(v);
|
||||
audio::output::update_audio_mute();
|
||||
refresh();
|
||||
};
|
||||
|
||||
button_stealth.on_select = [this](ImageButton&) {
|
||||
this->on_stealth();
|
||||
toggle_mute.on_change = [this](bool v) {
|
||||
pmem::set_config_audio_mute(v);
|
||||
audio::output::update_audio_mute();
|
||||
refresh();
|
||||
};
|
||||
|
||||
toggle_stealth.on_change = [this](bool v) {
|
||||
pmem::set_stealth_mode(v);
|
||||
refresh();
|
||||
};
|
||||
|
||||
button_bias_tee.on_select = [this](ImageButton&) {
|
||||
this->on_bias_tee();
|
||||
};
|
||||
|
||||
/*button_textentry.on_select = [this](ImageButton&) {
|
||||
this->on_textentry();
|
||||
};*/
|
||||
|
||||
button_camera.on_select = [this](ImageButton&) {
|
||||
this->on_camera();
|
||||
};
|
||||
@@ -195,53 +214,50 @@ SystemStatusView::SystemStatusView(
|
||||
this->on_clk();
|
||||
};
|
||||
|
||||
// Initialize toggle buttons
|
||||
toggle_speaker.set_value(pmem::config_speaker_disable());
|
||||
toggle_mute.set_value(pmem::config_audio_mute());
|
||||
toggle_stealth.set_value(pmem::stealth_mode());
|
||||
|
||||
audio::output::update_audio_mute();
|
||||
refresh();
|
||||
}
|
||||
|
||||
void SystemStatusView::refresh() {
|
||||
if (portapack::persistent_memory::config_hide_converter()) {
|
||||
button_converter.hidden(true);
|
||||
} else {
|
||||
if (portapack::persistent_memory::config_updown_converter()) {
|
||||
button_converter.set_bitmap(&bitmap_icon_downconvert);
|
||||
} else {
|
||||
button_converter.set_bitmap(&bitmap_icon_upconvert);
|
||||
}
|
||||
button_converter.hidden(false);
|
||||
if (portapack::persistent_memory::config_converter()) {
|
||||
button_converter.set_foreground(Color::red());
|
||||
} else {
|
||||
button_converter.set_foreground(Color::light_grey());
|
||||
}
|
||||
}
|
||||
// NB: Order of insertion is the display order Left->Right.
|
||||
// TODO: Might be better to support hide and only add once.
|
||||
status_icons.clear();
|
||||
if (!pmem::ui_hide_camera()) status_icons.add(&button_camera);
|
||||
if (!pmem::ui_hide_sleep()) status_icons.add(&button_sleep);
|
||||
if (!pmem::ui_hide_stealth()) status_icons.add(&toggle_stealth);
|
||||
if (!pmem::ui_hide_converter()) status_icons.add(&button_converter);
|
||||
if (!pmem::ui_hide_bias_tee()) status_icons.add(&button_bias_tee);
|
||||
if (!pmem::ui_hide_clock()) status_icons.add(&button_clock_status);
|
||||
if (!pmem::ui_hide_mute()) status_icons.add(&toggle_mute);
|
||||
|
||||
if (portapack::persistent_memory::config_audio_mute()) {
|
||||
button_speaker.set_foreground(Color::light_grey());
|
||||
button_speaker.set_bitmap(&bitmap_icon_speaker_mute);
|
||||
} else {
|
||||
button_speaker.set_foreground(Color::green());
|
||||
button_speaker.set_bitmap(&bitmap_icon_speaker);
|
||||
}
|
||||
// Display "Disable speaker" icon only if AK4951 Codec which has separate speaker/headphone control
|
||||
if (audio::speaker_disable_supported() && !pmem::ui_hide_speaker()) status_icons.add(&toggle_speaker);
|
||||
|
||||
if (!pmem::ui_hide_sd_card()) status_icons.add(&sd_card_status_view);
|
||||
status_icons.update_layout();
|
||||
|
||||
// Clock status
|
||||
bool external_clk = portapack::clock_manager.get_reference().source == ClockManager::ReferenceSource::External;
|
||||
button_clock_status.set_bitmap(external_clk ? &bitmap_icon_clk_ext : &bitmap_icon_clk_int);
|
||||
button_clock_status.set_foreground(pmem::clkout_enabled() ? Color::green() : Color::light_grey());
|
||||
|
||||
// Antenna DC Bias
|
||||
if (portapack::get_antenna_bias()) {
|
||||
button_bias_tee.set_bitmap(&bitmap_icon_biast_on);
|
||||
button_bias_tee.set_foreground(ui::Color::yellow());
|
||||
button_bias_tee.set_foreground(Color::yellow());
|
||||
} else {
|
||||
button_bias_tee.set_bitmap(&bitmap_icon_biast_off);
|
||||
button_bias_tee.set_foreground(ui::Color::light_grey());
|
||||
button_bias_tee.set_foreground(Color::light_grey());
|
||||
}
|
||||
|
||||
if (portapack::clock_manager.get_reference().source == ClockManager::ReferenceSource::External) {
|
||||
button_clock_status.set_bitmap(&bitmap_icon_clk_ext);
|
||||
} else {
|
||||
button_clock_status.set_bitmap(&bitmap_icon_clk_int);
|
||||
}
|
||||
|
||||
if (portapack::persistent_memory::clkout_enabled()) {
|
||||
button_clock_status.set_foreground(ui::Color::green());
|
||||
} else {
|
||||
button_clock_status.set_foreground(ui::Color::light_grey());
|
||||
}
|
||||
// Converter
|
||||
button_converter.set_bitmap(pmem::config_updown_converter() ? &bitmap_icon_downconvert : &bitmap_icon_upconvert);
|
||||
button_converter.set_foreground(pmem::config_converter() ? Color::red() : Color::light_grey());
|
||||
|
||||
set_dirty();
|
||||
}
|
||||
@@ -266,49 +282,36 @@ void SystemStatusView::set_title(const std::string new_value) {
|
||||
if (new_value.empty()) {
|
||||
title.set(default_title);
|
||||
} else {
|
||||
title.set(new_value);
|
||||
// Limit length of title string to prevent partial characters if too many StatusView icons
|
||||
size_t max_len = (status_icons.parent_rect().left() - title.parent_rect().left()) / 8;
|
||||
title.set(truncate(new_value, max_len));
|
||||
}
|
||||
}
|
||||
|
||||
void SystemStatusView::on_converter() {
|
||||
if (!portapack::persistent_memory::config_converter()) {
|
||||
portapack::persistent_memory::set_config_converter(true);
|
||||
button_converter.set_foreground(Color::red());
|
||||
} else {
|
||||
portapack::persistent_memory::set_config_converter(false);
|
||||
button_converter.set_foreground(Color::light_grey());
|
||||
}
|
||||
pmem::set_config_converter(!pmem::config_converter());
|
||||
|
||||
// Poke to update tuning
|
||||
// NOTE: Code assumes here that a TX app isn't active, since RX & TX have diff tuning offsets
|
||||
// (and there's only one tuner in the radio so can't update tuner for both).
|
||||
// TODO: Maybe expose the 'enabled_' flag on models.
|
||||
receiver_model.set_target_frequency(receiver_model.target_frequency());
|
||||
}
|
||||
|
||||
void SystemStatusView::on_speaker() {
|
||||
portapack::persistent_memory::set_config_audio_mute(!portapack::persistent_memory::config_audio_mute());
|
||||
audio::output::update_audio_mute();
|
||||
refresh();
|
||||
}
|
||||
|
||||
void SystemStatusView::on_stealth() {
|
||||
bool mode = not portapack::persistent_memory::stealth_mode();
|
||||
|
||||
portapack::persistent_memory::set_stealth_mode(mode);
|
||||
|
||||
button_stealth.set_foreground(mode ? Color::green() : Color::light_grey());
|
||||
}
|
||||
|
||||
void SystemStatusView::on_bias_tee() {
|
||||
if (!portapack::get_antenna_bias()) {
|
||||
nav_.display_modal("Bias voltage", "Enable DC voltage on\nantenna connector?", YESNO, [this](bool v) {
|
||||
if (v) {
|
||||
portapack::set_antenna_bias(true);
|
||||
receiver_model.set_antenna_bias();
|
||||
transmitter_model.set_antenna_bias();
|
||||
refresh();
|
||||
}
|
||||
});
|
||||
nav_.display_modal("Bias voltage",
|
||||
"Enable DC voltage on\nantenna connector?",
|
||||
YESNO,
|
||||
[this](bool v) {
|
||||
if (v) {
|
||||
portapack::set_antenna_bias(true);
|
||||
receiver_model.set_antenna_bias();
|
||||
transmitter_model.set_antenna_bias();
|
||||
refresh();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
portapack::set_antenna_bias(false);
|
||||
receiver_model.set_antenna_bias();
|
||||
@@ -321,48 +324,28 @@ void SystemStatusView::on_bias_tee() {
|
||||
}
|
||||
}
|
||||
|
||||
/*void SystemStatusView::on_textentry() {
|
||||
uint8_t cfg;
|
||||
|
||||
cfg = portapack::persistent_memory::ui_config_textentry();
|
||||
portapack::persistent_memory::set_config_textentry(cfg ^ 1);
|
||||
|
||||
if (!cfg)
|
||||
button_textentry.set_bitmap(&bitmap_icon_unistroke);
|
||||
else
|
||||
button_textentry.set_bitmap(&bitmap_icon_keyboard);
|
||||
}*/
|
||||
|
||||
void SystemStatusView::on_camera() {
|
||||
ensure_directory("SCREENSHOTS");
|
||||
auto path = next_filename_matching_pattern(u"SCREENSHOTS/SCR_????.PNG");
|
||||
|
||||
if (path.empty()) {
|
||||
if (path.empty())
|
||||
return;
|
||||
}
|
||||
|
||||
PNGWriter png;
|
||||
auto create_error = png.create(path);
|
||||
if (create_error.is_valid()) {
|
||||
auto error = png.create(path);
|
||||
if (error)
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 320; i++) {
|
||||
std::array<ColorRGB888, 240> row;
|
||||
portapack::display.read_pixels({0, i, 240, 1}, row);
|
||||
for (int i = 0; i < screen_height; i++) {
|
||||
std::array<ColorRGB888, screen_width> row;
|
||||
portapack::display.read_pixels({0, i, screen_width, 1}, row);
|
||||
png.write_scanline(row);
|
||||
}
|
||||
}
|
||||
|
||||
void SystemStatusView::on_clk() {
|
||||
bool v = portapack::persistent_memory::clkout_enabled();
|
||||
if (v) {
|
||||
v = false;
|
||||
} else {
|
||||
v = true;
|
||||
}
|
||||
portapack::clock_manager.enable_clock_output(v);
|
||||
portapack::persistent_memory::set_clkout_enabled(v);
|
||||
pmem::set_clkout_enabled(!pmem::clkout_enabled());
|
||||
portapack::clock_manager.enable_clock_output(pmem::clkout_enabled());
|
||||
refresh();
|
||||
}
|
||||
|
||||
@@ -390,17 +373,17 @@ InformationView::InformationView(
|
||||
|
||||
version.set_style(&style_infobar);
|
||||
|
||||
ltime.set_hide_clock(portapack::persistent_memory::hide_clock());
|
||||
ltime.set_hide_clock(pmem::hide_clock());
|
||||
ltime.set_style(&style_infobar);
|
||||
ltime.set_seconds_enabled(true);
|
||||
ltime.set_date_enabled(portapack::persistent_memory::clock_with_date());
|
||||
ltime.set_date_enabled(pmem::clock_with_date());
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
void InformationView::refresh() {
|
||||
ltime.set_hide_clock(portapack::persistent_memory::hide_clock());
|
||||
ltime.set_hide_clock(pmem::hide_clock());
|
||||
ltime.set_seconds_enabled(true);
|
||||
ltime.set_date_enabled(portapack::persistent_memory::clock_with_date());
|
||||
ltime.set_date_enabled(pmem::clock_with_date());
|
||||
}
|
||||
|
||||
/* Navigation ************************************************************/
|
||||
@@ -510,36 +493,36 @@ bool NavigationView::set_on_pop(std::function<void()> on_pop) {
|
||||
/* ReceiversMenuView *****************************************************/
|
||||
|
||||
ReceiversMenuView::ReceiversMenuView(NavigationView& nav) {
|
||||
if (portapack::persistent_memory::show_gui_return_icon()) {
|
||||
add_items({{"..", ui::Color::light_grey(), &bitmap_icon_previous, [&nav]() { nav.pop(); }}});
|
||||
if (pmem::show_gui_return_icon()) {
|
||||
add_items({{"..", Color::light_grey(), &bitmap_icon_previous, [&nav]() { nav.pop(); }}});
|
||||
}
|
||||
add_items({
|
||||
{
|
||||
"ADS-B",
|
||||
ui::Color::green(),
|
||||
Color::green(),
|
||||
&bitmap_icon_adsb,
|
||||
[&nav]() { nav.push<ADSBRxView>(); },
|
||||
},
|
||||
//{ "ACARS", ui::Color::yellow(), &bitmap_icon_adsb, [&nav](){ nav.push<ACARSAppView>(); }, },
|
||||
{"AIS Boats", ui::Color::green(), &bitmap_icon_ais, [&nav]() { nav.push<AISAppView>(); }},
|
||||
{"AFSK", ui::Color::yellow(), &bitmap_icon_modem, [&nav]() { nav.push<AFSKRxView>(); }},
|
||||
{"BTLE", ui::Color::yellow(), &bitmap_icon_btle, [&nav]() { nav.push<BTLERxView>(); }},
|
||||
{"NRF", ui::Color::yellow(), &bitmap_icon_nrf, [&nav]() { nav.push<NRFRxView>(); }},
|
||||
{"Audio", ui::Color::green(), &bitmap_icon_speaker, [&nav]() { nav.push<AnalogAudioView>(); }},
|
||||
{"Analog TV", ui::Color::yellow(), &bitmap_icon_sstv, [&nav]() { nav.push<AnalogTvView>(); }},
|
||||
{"ERT Meter", ui::Color::green(), &bitmap_icon_ert, [&nav]() { nav.push<ERTAppView>(); }},
|
||||
{"POCSAG", ui::Color::green(), &bitmap_icon_pocsag, [&nav]() { nav.push<POCSAGAppView>(); }},
|
||||
{"Radiosnde", ui::Color::green(), &bitmap_icon_sonde, [&nav]() { nav.push<SondeView>(); }},
|
||||
{"TPMS Cars", ui::Color::green(), &bitmap_icon_tpms, [&nav]() { nav.push<TPMSAppView>(); }},
|
||||
{"Recon", ui::Color::green(), &bitmap_icon_scanner, [&nav]() { nav.push<ReconView>(); }},
|
||||
{"Level", ui::Color::green(), &bitmap_icon_options_radio, [&nav]() { nav.push<LevelView>(); }},
|
||||
{"APRS", ui::Color::green(), &bitmap_icon_aprs, [&nav]() { nav.push<APRSRXView>(); }}
|
||||
//{ "ACARS", Color::yellow(), &bitmap_icon_adsb, [&nav](){ nav.push<ACARSAppView>(); }, },
|
||||
{"AIS Boats", Color::green(), &bitmap_icon_ais, [&nav]() { nav.push<AISAppView>(); }},
|
||||
{"AFSK", Color::yellow(), &bitmap_icon_modem, [&nav]() { nav.push<AFSKRxView>(); }},
|
||||
{"BTLE", Color::yellow(), &bitmap_icon_btle, [&nav]() { nav.push<BTLERxView>(); }},
|
||||
{"NRF", Color::yellow(), &bitmap_icon_nrf, [&nav]() { nav.push<NRFRxView>(); }},
|
||||
{"Audio", Color::green(), &bitmap_icon_speaker, [&nav]() { nav.push<AnalogAudioView>(); }},
|
||||
{"Analog TV", Color::yellow(), &bitmap_icon_sstv, [&nav]() { nav.push<AnalogTvView>(); }},
|
||||
{"ERT Meter", Color::green(), &bitmap_icon_ert, [&nav]() { nav.push<ERTAppView>(); }},
|
||||
{"POCSAG", Color::green(), &bitmap_icon_pocsag, [&nav]() { nav.push<POCSAGAppView>(); }},
|
||||
{"Radiosnde", Color::green(), &bitmap_icon_sonde, [&nav]() { nav.push<SondeView>(); }},
|
||||
{"TPMS Cars", Color::green(), &bitmap_icon_tpms, [&nav]() { nav.push<TPMSAppView>(); }},
|
||||
{"Recon", Color::green(), &bitmap_icon_scanner, [&nav]() { nav.push<ReconView>(); }},
|
||||
{"Level", Color::green(), &bitmap_icon_options_radio, [&nav]() { nav.push<LevelView>(); }},
|
||||
{"APRS", Color::green(), &bitmap_icon_aprs, [&nav]() { nav.push<APRSRXView>(); }}
|
||||
/*
|
||||
{ "DMR", ui::Color::dark_grey(), &bitmap_icon_dmr, [&nav](){ nav.push<NotImplementedView>(); } },
|
||||
{ "SIGFOX", ui::Color::dark_grey(), &bitmap_icon_fox, [&nav](){ nav.push<NotImplementedView>(); } }, // SIGFRXView
|
||||
{ "LoRa", ui::Color::dark_grey(), &bitmap_icon_lora, [&nav](){ nav.push<NotImplementedView>(); } },
|
||||
{ "SSTV", ui::Color::dark_grey(), &bitmap_icon_sstv, [&nav](){ nav.push<NotImplementedView>(); } },
|
||||
{ "TETRA", ui::Color::dark_grey(), &bitmap_icon_tetra, [&nav](){ nav.push<NotImplementedView>(); } },*/
|
||||
{ "DMR", Color::dark_grey(), &bitmap_icon_dmr, [&nav](){ nav.push<NotImplementedView>(); } },
|
||||
{ "SIGFOX", Color::dark_grey(), &bitmap_icon_fox, [&nav](){ nav.push<NotImplementedView>(); } }, // SIGFRXView
|
||||
{ "LoRa", Color::dark_grey(), &bitmap_icon_lora, [&nav](){ nav.push<NotImplementedView>(); } },
|
||||
{ "SSTV", Color::dark_grey(), &bitmap_icon_sstv, [&nav](){ nav.push<NotImplementedView>(); } },
|
||||
{ "TETRA", Color::dark_grey(), &bitmap_icon_tetra, [&nav](){ nav.push<NotImplementedView>(); } },*/
|
||||
});
|
||||
|
||||
// set_highlighted(0); // Default selection is "Audio"
|
||||
@@ -548,14 +531,14 @@ ReceiversMenuView::ReceiversMenuView(NavigationView& nav) {
|
||||
/* TransmittersMenuView **************************************************/
|
||||
|
||||
TransmittersMenuView::TransmittersMenuView(NavigationView& nav) {
|
||||
if (portapack::persistent_memory::show_gui_return_icon()) {
|
||||
add_items({{"..", ui::Color::light_grey(), &bitmap_icon_previous, [&nav]() { nav.pop(); }}});
|
||||
if (pmem::show_gui_return_icon()) {
|
||||
add_items({{"..", Color::light_grey(), &bitmap_icon_previous, [&nav]() { nav.pop(); }}});
|
||||
}
|
||||
add_items({
|
||||
{"ADS-B [S]", ui::Color::yellow(), &bitmap_icon_adsb, [&nav]() { nav.push<ADSBTxView>(); }},
|
||||
{"ADS-B [S]", ui::Color::green(), &bitmap_icon_adsb, [&nav]() { nav.push<ADSBTxView>(); }},
|
||||
{"APRS", ui::Color::green(), &bitmap_icon_aprs, [&nav]() { nav.push<APRSTXView>(); }},
|
||||
{"BHT Xy/EP", ui::Color::green(), &bitmap_icon_bht, [&nav]() { nav.push<BHTView>(); }},
|
||||
{"GPS Sim", ui::Color::yellow(), &bitmap_icon_gps_sim, [&nav]() { nav.push<GpsSimAppView>(); }},
|
||||
{"GPS Sim", ui::Color::green(), &bitmap_icon_gps_sim, [&nav]() { nav.push<GpsSimAppView>(); }},
|
||||
{"Jammer", ui::Color::green(), &bitmap_icon_jammer, [&nav]() { nav.push<JammerView>(); }},
|
||||
//{ "Key fob", ui::Color::orange(), &bitmap_icon_keyfob, [&nav](){ nav.push<KeyfobView>(); } },
|
||||
{"LGE tool", ui::Color::yellow(), &bitmap_icon_lge, [&nav]() { nav.push<LGEView>(); }},
|
||||
@@ -568,9 +551,9 @@ TransmittersMenuView::TransmittersMenuView(NavigationView& nav) {
|
||||
{"Soundbrd", ui::Color::green(), &bitmap_icon_soundboard, [&nav]() { nav.push<SoundBoardView>(); }},
|
||||
{"SSTV", ui::Color::green(), &bitmap_icon_sstv, [&nav]() { nav.push<SSTVTXView>(); }},
|
||||
{"TEDI/LCR", ui::Color::yellow(), &bitmap_icon_lcr, [&nav]() { nav.push<LCRView>(); }},
|
||||
{"TouchTune", ui::Color::yellow(), &bitmap_icon_remote, [&nav]() { nav.push<TouchTunesView>(); }},
|
||||
{"Playlist", ui::Color::green(), &bitmap_icon_scanner, [&nav]() { nav.push<PlaylistView>(); }},
|
||||
{"S.Painter", ui::Color::orange(), &bitmap_icon_morse, [&nav]() { nav.push<SpectrumPainterView>(); }},
|
||||
{"TouchTune", ui::Color::green(), &bitmap_icon_touchtunes, [&nav]() { nav.push<TouchTunesView>(); }},
|
||||
//{"Playlist", ui::Color::green(), &bitmap_icon_scanner, [&nav]() { nav.push<PlaylistView>(); }},
|
||||
{"S.Painter", ui::Color::orange(), &bitmap_icon_paint, [&nav]() { nav.push<SpectrumPainterView>(); }},
|
||||
//{ "Remote", ui::Color::dark_grey(), &bitmap_icon_remote, [&nav](){ nav.push<RemoteView>(); } },
|
||||
});
|
||||
}
|
||||
@@ -578,22 +561,22 @@ TransmittersMenuView::TransmittersMenuView(NavigationView& nav) {
|
||||
/* UtilitiesMenuView *****************************************************/
|
||||
|
||||
UtilitiesMenuView::UtilitiesMenuView(NavigationView& nav) {
|
||||
if (portapack::persistent_memory::show_gui_return_icon()) {
|
||||
add_items({{"..", ui::Color::light_grey(), &bitmap_icon_previous, [&nav]() { nav.pop(); }}});
|
||||
if (pmem::show_gui_return_icon()) {
|
||||
add_items({{"..", Color::light_grey(), &bitmap_icon_previous, [&nav]() { nav.pop(); }}});
|
||||
}
|
||||
add_items({
|
||||
//{ "Test app", ui::Color::dark_grey(), nullptr, [&nav](){ nav.push<TestView>(); } },
|
||||
{"Freq. manager", ui::Color::green(), &bitmap_icon_freqman, [&nav]() { nav.push<FrequencyManagerView>(); }},
|
||||
{"File manager", ui::Color::yellow(), &bitmap_icon_dir, [&nav]() { nav.push<FileManagerView>(); }},
|
||||
{"Notepad", ui::Color::dark_cyan(), &bitmap_icon_notepad, [&nav]() { nav.push<TextEditorView>(); }},
|
||||
{"Signal gen", ui::Color::green(), &bitmap_icon_cwgen, [&nav]() { nav.push<SigGenView>(); }},
|
||||
//{ "Tone search", ui::Color::dark_grey(), nullptr, [&nav](){ nav.push<ToneSearchView>(); } },
|
||||
{"Wav viewer", ui::Color::yellow(), &bitmap_icon_soundboard, [&nav]() { nav.push<ViewWavView>(); }},
|
||||
{"Antenna length", ui::Color::green(), &bitmap_icon_tools_antenna, [&nav]() { nav.push<WhipCalcView>(); }},
|
||||
//{ "Test app", Color::dark_grey(), nullptr, [&nav](){ nav.push<TestView>(); } },
|
||||
{"Freq. manager", Color::green(), &bitmap_icon_freqman, [&nav]() { nav.push<FrequencyManagerView>(); }},
|
||||
{"File manager", Color::green(), &bitmap_icon_dir, [&nav]() { nav.push<FileManagerView>(); }},
|
||||
{"Notepad", Color::dark_cyan(), &bitmap_icon_notepad, [&nav]() { nav.push<TextEditorView>(); }},
|
||||
{"Signal gen", Color::green(), &bitmap_icon_cwgen, [&nav]() { nav.push<SigGenView>(); }},
|
||||
//{ "Tone search", Color::dark_grey(), nullptr, [&nav](){ nav.push<ToneSearchView>(); } },
|
||||
{"Wav viewer", Color::yellow(), &bitmap_icon_soundboard, [&nav]() { nav.push<ViewWavView>(); }},
|
||||
{"Antenna length", Color::green(), &bitmap_icon_tools_antenna, [&nav]() { nav.push<WhipCalcView>(); }},
|
||||
|
||||
{"Wipe SD card", ui::Color::red(), &bitmap_icon_tools_wipesd, [&nav]() { nav.push<WipeSDView>(); }},
|
||||
{"Flash Utility", ui::Color::red(), &bitmap_icon_temperature, [&nav]() { nav.push<FlashUtilityView>(); }},
|
||||
{"SD over USB", ui::Color::yellow(), &bitmap_icon_hackrf, [&nav]() { nav.push<SdOverUsbView>(); }},
|
||||
{"Wipe SD card", Color::red(), &bitmap_icon_tools_wipesd, [&nav]() { nav.push<WipeSDView>(); }},
|
||||
{"Flash Utility", Color::red(), &bitmap_icon_temperature, [&nav]() { nav.push<FlashUtilityView>(); }},
|
||||
{"SD over USB", Color::yellow(), &bitmap_icon_hackrf, [&nav]() { nav.push<SdOverUsbView>(); }},
|
||||
});
|
||||
set_max_rows(2); // allow wider buttons
|
||||
}
|
||||
@@ -611,20 +594,20 @@ void SystemMenuView::hackrf_mode(NavigationView& nav) {
|
||||
|
||||
SystemMenuView::SystemMenuView(NavigationView& nav) {
|
||||
add_items({
|
||||
//{ "Play dead", ui::Color::red(), &bitmap_icon_playdead, [&nav](){ nav.push<PlayDeadView>(); } },
|
||||
{"Receive", ui::Color::cyan(), &bitmap_icon_receivers, [&nav]() { nav.push<ReceiversMenuView>(); }},
|
||||
{"Transmit", ui::Color::cyan(), &bitmap_icon_transmit, [&nav]() { nav.push<TransmittersMenuView>(); }},
|
||||
{"Capture", ui::Color::red(), &bitmap_icon_capture, [&nav]() { nav.push<CaptureAppView>(); }},
|
||||
{"Replay", ui::Color::green(), &bitmap_icon_replay, [&nav]() { nav.push<ReplayAppView>(); }},
|
||||
{"Search", ui::Color::yellow(), &bitmap_icon_search, [&nav]() { nav.push<SearchView>(); }},
|
||||
{"Scanner", ui::Color::yellow(), &bitmap_icon_scanner, [&nav]() { nav.push<ScannerView>(); }},
|
||||
{"Microphone", ui::Color::yellow(), &bitmap_icon_microphone, [&nav]() { nav.push<MicTXView>(); }},
|
||||
{"Looking Glass", ui::Color::yellow(), &bitmap_icon_looking, [&nav]() { nav.push<GlassView>(); }},
|
||||
{"Utilities", ui::Color::cyan(), &bitmap_icon_utilities, [&nav]() { nav.push<UtilitiesMenuView>(); }},
|
||||
{"Settings", ui::Color::cyan(), &bitmap_icon_setup, [&nav]() { nav.push<SettingsMenuView>(); }},
|
||||
{"Debug", ui::Color::light_grey(), &bitmap_icon_debug, [&nav]() { nav.push<DebugMenuView>(); }},
|
||||
{"HackRF", ui::Color::cyan(), &bitmap_icon_hackrf, [this, &nav]() { hackrf_mode(nav); }},
|
||||
//{ "About", ui::Color::cyan(), nullptr, [&nav](){ nav.push<AboutView>(); } }
|
||||
//{ "Play dead", Color::red(), &bitmap_icon_playdead, [&nav](){ nav.push<PlayDeadView>(); } },
|
||||
{"Receive", Color::cyan(), &bitmap_icon_receivers, [&nav]() { nav.push<ReceiversMenuView>(); }},
|
||||
{"Transmit", Color::cyan(), &bitmap_icon_transmit, [&nav]() { nav.push<TransmittersMenuView>(); }},
|
||||
{"Capture", Color::red(), &bitmap_icon_capture, [&nav]() { nav.push<CaptureAppView>(); }},
|
||||
{"Replay", Color::green(), &bitmap_icon_replay, [&nav]() { nav.push<PlaylistView>(); }},
|
||||
{"Search", Color::yellow(), &bitmap_icon_search, [&nav]() { nav.push<SearchView>(); }},
|
||||
{"Scanner", Color::green(), &bitmap_icon_scanner, [&nav]() { nav.push<ScannerView>(); }},
|
||||
{"Microphone", Color::green(), &bitmap_icon_microphone, [&nav]() { nav.push<MicTXView>(); }},
|
||||
{"Looking Glass", Color::green(), &bitmap_icon_looking, [&nav]() { nav.push<GlassView>(); }},
|
||||
{"Utilities", Color::cyan(), &bitmap_icon_utilities, [&nav]() { nav.push<UtilitiesMenuView>(); }},
|
||||
{"Settings", Color::cyan(), &bitmap_icon_setup, [&nav]() { nav.push<SettingsMenuView>(); }},
|
||||
{"Debug", Color::light_grey(), &bitmap_icon_debug, [&nav]() { nav.push<DebugMenuView>(); }},
|
||||
{"HackRF", Color::cyan(), &bitmap_icon_hackrf, [this, &nav]() { hackrf_mode(nav); }},
|
||||
//{ "About", Color::cyan(), nullptr, [&nav](){ nav.push<AboutView>(); } }
|
||||
});
|
||||
set_max_rows(2); // allow wider buttons
|
||||
set_arrow_enabled(false);
|
||||
@@ -638,10 +621,10 @@ SystemView::SystemView(
|
||||
const Rect parent_rect)
|
||||
: View{parent_rect},
|
||||
context_(context) {
|
||||
set_style(&ui::Styles::white);
|
||||
set_style(&Styles::white);
|
||||
|
||||
constexpr ui::Dim status_view_height = 16;
|
||||
constexpr ui::Dim info_view_height = 16;
|
||||
constexpr Dim status_view_height = 16;
|
||||
constexpr Dim info_view_height = 16;
|
||||
|
||||
add_child(&status_view);
|
||||
status_view.set_parent_rect({{0, 0},
|
||||
@@ -652,7 +635,7 @@ SystemView::SystemView(
|
||||
|
||||
add_child(&navigation_view);
|
||||
navigation_view.set_parent_rect({{0, status_view_height},
|
||||
{parent_rect.width(), static_cast<ui::Dim>(parent_rect.height() - status_view_height)}});
|
||||
{parent_rect.width(), static_cast<Dim>(parent_rect.height() - status_view_height)}});
|
||||
|
||||
add_child(&info_view);
|
||||
info_view.set_parent_rect({{0, 19 * 16},
|
||||
@@ -672,17 +655,17 @@ SystemView::SystemView(
|
||||
this->status_view.set_dirty();
|
||||
};
|
||||
|
||||
// portapack::persistent_memory::set_playdead_sequence(0x8D1);
|
||||
// pmem::set_playdead_sequence(0x8D1);
|
||||
|
||||
// Initial view
|
||||
/*if ((portapack::persistent_memory::playing_dead() == 0x5920C1DF) || // Enable code
|
||||
(portapack::persistent_memory::ui_config() & 16)) { // Login option
|
||||
/*if ((pmem::playing_dead() == 0x5920C1DF) || // Enable code
|
||||
(pmem::ui_config() & 16)) { // Login option
|
||||
navigation_view.push<PlayDeadView>();
|
||||
} else {*/
|
||||
|
||||
navigation_view.push<SystemMenuView>();
|
||||
|
||||
if (portapack::persistent_memory::config_splash()) {
|
||||
if (pmem::config_splash()) {
|
||||
navigation_view.push<BMPView>();
|
||||
}
|
||||
status_view.set_back_enabled(false);
|
||||
@@ -699,20 +682,27 @@ Context& SystemView::context() const {
|
||||
}
|
||||
|
||||
void SystemView::toggle_overlay() {
|
||||
if (overlay_active) {
|
||||
this->remove_child(&this->overlay);
|
||||
this->set_dirty();
|
||||
shared_memory.request_m4_performance_counter = 0;
|
||||
} else {
|
||||
this->add_child(&this->overlay);
|
||||
this->set_dirty();
|
||||
shared_memory.request_m4_performance_counter = 1;
|
||||
shared_memory.m4_cpu_usage = 0;
|
||||
shared_memory.m4_heap_usage = 0;
|
||||
shared_memory.m4_stack_usage = 0;
|
||||
switch (++overlay_active) {
|
||||
case 1:
|
||||
this->add_child(&this->overlay);
|
||||
this->set_dirty();
|
||||
shared_memory.request_m4_performance_counter = 1;
|
||||
shared_memory.m4_cpu_usage = 0;
|
||||
shared_memory.m4_heap_usage = 0;
|
||||
shared_memory.m4_stack_usage = 0;
|
||||
break;
|
||||
case 2:
|
||||
this->remove_child(&this->overlay);
|
||||
this->add_child(&this->overlay2);
|
||||
this->set_dirty();
|
||||
shared_memory.request_m4_performance_counter = 0;
|
||||
break;
|
||||
case 3:
|
||||
this->remove_child(&this->overlay2);
|
||||
this->set_dirty();
|
||||
overlay_active = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
overlay_active = !overlay_active;
|
||||
}
|
||||
|
||||
void SystemView::paint_overlay() {
|
||||
@@ -723,7 +713,10 @@ void SystemView::paint_overlay() {
|
||||
return;
|
||||
|
||||
last_paint_state = !last_paint_state;
|
||||
this->overlay.set_dirty();
|
||||
if (overlay_active == 1)
|
||||
this->overlay.set_dirty();
|
||||
else
|
||||
this->overlay2.set_dirty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -742,7 +735,7 @@ BMPView::BMPView(NavigationView& nav) {
|
||||
}
|
||||
|
||||
void BMPView::paint(Painter&) {
|
||||
if (!portapack::display.drawBMP2({0, 0}, "splash.bmp"))
|
||||
if (!portapack::display.drawBMP2({0, 0}, splash_dot_bmp))
|
||||
portapack::display.drawBMP({(240 - 230) / 2, (320 - 50) / 2 - 10}, splash_bmp, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -120,6 +120,32 @@ class NavigationView : public View {
|
||||
View* push_view(std::unique_ptr<View> new_view);
|
||||
};
|
||||
|
||||
/* Holds widgets and grows dynamically toward the left.
|
||||
* 16px tall fixed and right-aligns all children in the
|
||||
* order in which they were added. */
|
||||
// TODO: Could make this a generic "StackPanel" control.
|
||||
class StatusTray : public View {
|
||||
public:
|
||||
StatusTray(Point pos);
|
||||
|
||||
StatusTray(const StatusTray&) = delete;
|
||||
StatusTray& operator=(const StatusTray&) = delete;
|
||||
|
||||
void add_button(ImageButton* child);
|
||||
void add(Widget* child);
|
||||
void update_layout();
|
||||
void clear();
|
||||
void paint(Painter& painter) override;
|
||||
uint8_t width() { return width_; };
|
||||
|
||||
private:
|
||||
static constexpr uint8_t height = 16;
|
||||
// This control grow to the left, so keep
|
||||
// track of the right edge.
|
||||
const Point pos_{};
|
||||
uint8_t width_{};
|
||||
};
|
||||
|
||||
class SystemStatusView : public View {
|
||||
public:
|
||||
std::function<void(void)> on_back{};
|
||||
@@ -136,7 +162,7 @@ class SystemStatusView : public View {
|
||||
NavigationView& nav_;
|
||||
|
||||
Rectangle backdrop{
|
||||
{0 * 8, 0 * 16, 240, 16},
|
||||
{0 * 8, 0 * 16, ui::screen_width, 16},
|
||||
Color::dark_grey()};
|
||||
|
||||
ImageButton button_back{
|
||||
@@ -156,63 +182,65 @@ class SystemStatusView : public View {
|
||||
Color::white(),
|
||||
Color::dark_grey()};
|
||||
|
||||
ImageButton button_speaker{
|
||||
{15 * 8, 0, 2 * 8, 1 * 16},
|
||||
StatusTray status_icons{{screen_width, 0}};
|
||||
|
||||
ImageToggle toggle_speaker{
|
||||
{0, 0, 2 * 8, 1 * 16},
|
||||
&bitmap_icon_speaker_mute,
|
||||
&bitmap_icon_speaker,
|
||||
Color::light_grey(),
|
||||
Color::dark_grey(),
|
||||
Color::green(),
|
||||
Color::dark_grey()};
|
||||
|
||||
ImageToggle toggle_mute{
|
||||
{0, 0, 2 * 8, 1 * 16},
|
||||
&bitmap_icon_speaker_and_headphones_mute,
|
||||
&bitmap_icon_speaker_and_headphones,
|
||||
Color::light_grey(),
|
||||
Color::dark_grey(),
|
||||
Color::green(),
|
||||
Color::dark_grey()};
|
||||
|
||||
ImageButton button_converter{
|
||||
{17 * 8, 0, 2 * 8, 1 * 16},
|
||||
{0, 0, 2 * 8, 1 * 16},
|
||||
&bitmap_icon_upconvert,
|
||||
Color::light_grey(),
|
||||
Color::dark_grey()};
|
||||
|
||||
ImageButton button_stealth{
|
||||
{19 * 8, 0, 2 * 8, 1 * 16},
|
||||
&bitmap_icon_stealth,
|
||||
Color::light_grey(),
|
||||
Color::dark_grey()};
|
||||
|
||||
/*ImageButton button_textentry {
|
||||
{ 170, 0, 2 * 8, 1 * 16 },
|
||||
&bitmap_icon_unistroke,
|
||||
Color::white(),
|
||||
Color::dark_grey()
|
||||
};*/
|
||||
ImageToggle toggle_stealth{
|
||||
{0, 0, 2 * 8, 1 * 16},
|
||||
&bitmap_icon_stealth};
|
||||
|
||||
ImageButton button_camera{
|
||||
{21 * 8, 0, 2 * 8, 1 * 16},
|
||||
{0, 0, 2 * 8, 1 * 16},
|
||||
&bitmap_icon_camera,
|
||||
Color::white(),
|
||||
Color::dark_grey()};
|
||||
|
||||
ImageButton button_sleep{
|
||||
{23 * 8, 0, 2 * 8, 1 * 16},
|
||||
{0, 0, 2 * 8, 1 * 16},
|
||||
&bitmap_icon_sleep,
|
||||
Color::white(),
|
||||
Color::dark_grey()};
|
||||
|
||||
ImageButton button_bias_tee{
|
||||
{25 * 8, 0, 12, 1 * 16},
|
||||
{0, 0, 2 * 8, 1 * 16},
|
||||
&bitmap_icon_biast_off,
|
||||
Color::light_grey(),
|
||||
Color::dark_grey()};
|
||||
|
||||
ImageButton button_clock_status{
|
||||
{27 * 8, 0 * 16, 2 * 8, 1 * 16},
|
||||
{0, 0 * 16, 8, 1 * 16},
|
||||
&bitmap_icon_clk_int,
|
||||
Color::light_grey(),
|
||||
Color::dark_grey()};
|
||||
|
||||
SDCardStatusView sd_card_status_view{
|
||||
{28 * 8, 0 * 16, 2 * 8, 1 * 16}};
|
||||
{0, 0 * 16, 2 * 8, 1 * 16}};
|
||||
|
||||
void on_converter();
|
||||
void on_speaker();
|
||||
void on_stealth();
|
||||
void on_bias_tee();
|
||||
// void on_textentry();
|
||||
void on_camera();
|
||||
void on_title();
|
||||
void refresh();
|
||||
@@ -300,11 +328,12 @@ class SystemView : public View {
|
||||
void paint_overlay();
|
||||
|
||||
private:
|
||||
bool overlay_active{false};
|
||||
uint8_t overlay_active{0};
|
||||
|
||||
SystemStatusView status_view{navigation_view};
|
||||
InformationView info_view{navigation_view};
|
||||
DfuMenu overlay{navigation_view};
|
||||
DfuMenu2 overlay2{navigation_view};
|
||||
NavigationView navigation_view{};
|
||||
Context& context_;
|
||||
};
|
||||
|
||||
@@ -53,7 +53,9 @@ void NarrowbandFMAudio::execute(const buffer_c8_t& buffer) {
|
||||
if (ctcss_detect_enabled) {
|
||||
/* 24kHz int16_t[16]
|
||||
* -> FIR filter, <300Hz pass, >300Hz stop, gain of 1
|
||||
* -> 12kHz int16_t[8] */
|
||||
* -> 12kHz int16_t[8]
|
||||
*
|
||||
* Note we're only processing a small section of the wave each time this fn is called */
|
||||
auto audio_ctcss = ctcss_filter.execute(audio, work_audio_buffer);
|
||||
|
||||
// s16 to f32 for hpf
|
||||
@@ -72,16 +74,18 @@ void NarrowbandFMAudio::execute(const buffer_c8_t& buffer) {
|
||||
cur_sample = audio_f[c];
|
||||
if (cur_sample * prev_sample < 0.0) {
|
||||
z_acc += z_timer;
|
||||
z_timer = 0;
|
||||
z_timer = 1;
|
||||
z_count++;
|
||||
} else
|
||||
z_timer++;
|
||||
prev_sample = cur_sample;
|
||||
}
|
||||
|
||||
if (z_count >= 30) {
|
||||
z_filter_count++;
|
||||
if ((z_filter_count >= Z_MIN_FILTER_COUNT) && (z_count >= Z_MIN_ZERO_CROSSINGS)) {
|
||||
ctcss_message.value = (100 * 12000 / 2 * z_count) / z_acc;
|
||||
shared_memory.application_queue.push(ctcss_message);
|
||||
z_filter_count = 0;
|
||||
z_count = 0;
|
||||
z_acc = 0;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,9 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#define Z_MIN_FILTER_COUNT 224
|
||||
#define Z_MIN_ZERO_CROSSINGS 20
|
||||
|
||||
class NarrowbandFMAudio : public BasebandProcessor {
|
||||
public:
|
||||
void execute(const buffer_c8_t& buffer) override;
|
||||
@@ -88,7 +91,7 @@ class NarrowbandFMAudio : public BasebandProcessor {
|
||||
bool pitch_rssi_enabled{false};
|
||||
|
||||
float cur_sample{}, prev_sample{};
|
||||
uint32_t z_acc{0}, z_timer{0}, z_count{0};
|
||||
uint32_t z_acc{0}, z_timer{0}, z_count{0}, z_filter_count{0};
|
||||
bool ctcss_detect_enabled{true};
|
||||
static constexpr float k = 32768.0f;
|
||||
static constexpr float ki = 1.0f / k;
|
||||
|
||||
@@ -837,6 +837,10 @@ class AK4951 : public audio::Codec {
|
||||
void speaker_enable();
|
||||
void speaker_disable();
|
||||
|
||||
bool speaker_disable_supported() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
void set_headphone_volume(const volume_t volume) override;
|
||||
void headphone_mute();
|
||||
|
||||
|
||||
@@ -412,7 +412,7 @@ void ILI9341::drawBMP(const ui::Point p, const uint8_t* bitmap, const bool trans
|
||||
24bpp RGB
|
||||
32bpp ARGB
|
||||
*/
|
||||
bool ILI9341::drawBMP2(const ui::Point p, const std::string file) {
|
||||
bool ILI9341::drawBMP2(const ui::Point p, const std::filesystem::path& file) {
|
||||
File bmpimage;
|
||||
size_t file_pos = 0;
|
||||
uint16_t pointer = 0;
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "ui.hpp"
|
||||
#include "ui_text.hpp"
|
||||
#include "file.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <array>
|
||||
@@ -58,7 +59,7 @@ class ILI9341 {
|
||||
|
||||
void draw_pixel(const ui::Point p, const ui::Color color);
|
||||
void drawBMP(const ui::Point p, const uint8_t* bitmap, const bool transparency);
|
||||
bool drawBMP2(const ui::Point p, const std::string file);
|
||||
bool drawBMP2(const ui::Point p, const std::filesystem::path& file);
|
||||
void render_line(const ui::Point p, const uint8_t count, const ui::Color* line_buffer);
|
||||
void render_box(const ui::Point p, const ui::Size s, const ui::Color* line_buffer);
|
||||
|
||||
|
||||
@@ -34,6 +34,17 @@ class Optional {
|
||||
constexpr Optional(T&& value)
|
||||
: value_{std::move(value)}, valid_{true} {}
|
||||
|
||||
constexpr Optional& operator=(const T& value) {
|
||||
value_ = value;
|
||||
valid_ = true;
|
||||
return *this;
|
||||
}
|
||||
constexpr Optional& operator=(T&& value) {
|
||||
value_ = std::move(value);
|
||||
valid_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool is_valid() const { return valid_; }
|
||||
operator bool() const { return valid_; }
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -34,9 +34,10 @@
|
||||
#include "volume.hpp"
|
||||
|
||||
// persistant memory from/to sdcard flag file
|
||||
#define PMEM_FILEFLAG "/SETTINGS/PMEM_FILEFLAG"
|
||||
#define PMEM_FILEFLAG u"/SETTINGS/PMEM_FILEFLAG"
|
||||
|
||||
// persistant memory from/to sdcard flag file
|
||||
#define PMEM_SETTING_FILE "/SETTINGS/pmem_settings"
|
||||
#define PMEM_SETTING_FILE u"/SETTINGS/pmem_settings"
|
||||
|
||||
using namespace modems;
|
||||
using namespace serializer;
|
||||
@@ -173,7 +174,6 @@ uint8_t config_cpld();
|
||||
void set_config_cpld(uint8_t i);
|
||||
|
||||
bool config_splash();
|
||||
bool config_hide_converter();
|
||||
bool config_converter();
|
||||
bool config_updown_converter();
|
||||
int64_t config_converter_freq();
|
||||
@@ -194,11 +194,9 @@ void set_load_app_settings(bool v);
|
||||
void set_save_app_settings(bool v);
|
||||
void set_show_bigger_qr_code(bool v);
|
||||
void set_config_splash(bool v);
|
||||
bool config_hide_converter();
|
||||
bool config_converter();
|
||||
bool config_updown_converter();
|
||||
int64_t config_converter_freq();
|
||||
void set_config_hide_converter(bool v);
|
||||
void set_config_converter(bool v);
|
||||
void set_config_updown_converter(bool v);
|
||||
void set_config_converter_freq(int64_t v);
|
||||
@@ -220,9 +218,6 @@ void set_disable_touchscreen(bool v);
|
||||
uint8_t config_encoder_dial_sensitivity();
|
||||
void set_encoder_dial_sensitivity(uint8_t v);
|
||||
|
||||
// uint8_t ui_config_textentry();
|
||||
// void set_config_textentry(uint8_t new_value);
|
||||
|
||||
uint32_t pocsag_last_address();
|
||||
void set_pocsag_last_address(uint32_t address);
|
||||
|
||||
@@ -231,8 +226,8 @@ void set_pocsag_ignore_address(uint32_t address);
|
||||
|
||||
bool clkout_enabled();
|
||||
void set_clkout_enabled(bool v);
|
||||
uint32_t clkout_freq();
|
||||
void set_clkout_freq(uint32_t freq);
|
||||
uint16_t clkout_freq();
|
||||
void set_clkout_freq(uint16_t freq);
|
||||
|
||||
/* Recon app */
|
||||
bool recon_autosave_freqs();
|
||||
@@ -242,6 +237,7 @@ bool recon_clear_output();
|
||||
bool recon_load_freqs();
|
||||
bool recon_load_ranges();
|
||||
bool recon_update_ranges_when_recon();
|
||||
bool recon_auto_record_locked();
|
||||
bool recon_load_hamradios();
|
||||
bool recon_match_mode();
|
||||
void set_recon_autosave_freqs(const bool v);
|
||||
@@ -251,9 +247,30 @@ void set_recon_clear_output(const bool v);
|
||||
void set_recon_load_freqs(const bool v);
|
||||
void set_recon_load_ranges(const bool v);
|
||||
void set_recon_update_ranges_when_recon(const bool v);
|
||||
void set_recon_auto_record_locked(const bool v);
|
||||
void set_recon_load_hamradios(const bool v);
|
||||
void set_recon_match_mode(const bool v);
|
||||
|
||||
/* UI Config 2 */
|
||||
bool ui_hide_speaker();
|
||||
bool ui_hide_mute();
|
||||
bool ui_hide_converter();
|
||||
bool ui_hide_stealth();
|
||||
bool ui_hide_camera();
|
||||
bool ui_hide_sleep();
|
||||
bool ui_hide_bias_tee();
|
||||
bool ui_hide_clock();
|
||||
bool ui_hide_sd_card();
|
||||
void set_ui_hide_speaker(bool v);
|
||||
void set_ui_hide_mute(bool v);
|
||||
void set_ui_hide_converter(bool v);
|
||||
void set_ui_hide_stealth(bool v);
|
||||
void set_ui_hide_camera(bool v);
|
||||
void set_ui_hide_sleep(bool v);
|
||||
void set_ui_hide_bias_tee(bool v);
|
||||
void set_ui_hide_clock(bool v);
|
||||
void set_ui_hide_sd_card(bool v);
|
||||
|
||||
// sd persisting settings
|
||||
bool should_use_sdcard_for_pmem();
|
||||
int save_persistent_settings_to_file();
|
||||
@@ -261,6 +278,8 @@ int load_persistent_settings_from_file();
|
||||
|
||||
size_t data_size();
|
||||
|
||||
bool debug_dump();
|
||||
|
||||
} /* namespace persistent_memory */
|
||||
|
||||
} /* namespace portapack */
|
||||
|
||||
+15
-4
@@ -31,6 +31,9 @@ namespace ui {
|
||||
using Coord = int16_t;
|
||||
using Dim = int16_t;
|
||||
|
||||
constexpr uint16_t screen_width = 240;
|
||||
constexpr uint16_t screen_height = 320;
|
||||
|
||||
struct Color {
|
||||
uint16_t v; // rrrrrGGGGGGbbbbb
|
||||
|
||||
@@ -53,15 +56,20 @@ struct Color {
|
||||
}
|
||||
|
||||
uint8_t to_greyscale() {
|
||||
uint32_t r = ((v >> 11) & 31U) << 3;
|
||||
uint32_t g = ((v >> 5) & 63U) << 2;
|
||||
uint32_t b = (v & 31U) << 3;
|
||||
uint32_t r = (v >> 8) & 0xf8;
|
||||
uint32_t g = (v >> 3) & 0xfc;
|
||||
uint32_t b = (v << 3) & 0xf8;
|
||||
|
||||
uint32_t grey = (r * 299 + g * 587 + b * 114) / 1000;
|
||||
uint32_t grey = ((r * 306) + (g * 601) + (b * 117)) >> 10;
|
||||
|
||||
return (uint8_t)grey;
|
||||
}
|
||||
|
||||
uint16_t dark() {
|
||||
// stripping bits 4 & 5 from each of the colors R/G/B
|
||||
return (v & ((0xc8 << 8) | (0xcc << 3) | (0xc8 >> 3)));
|
||||
}
|
||||
|
||||
Color operator-() const {
|
||||
return (v ^ 0xffff);
|
||||
}
|
||||
@@ -132,6 +140,9 @@ struct Color {
|
||||
static constexpr Color dark_grey() {
|
||||
return {63, 63, 63};
|
||||
}
|
||||
static constexpr Color darker_grey() {
|
||||
return {31, 31, 31};
|
||||
}
|
||||
|
||||
static constexpr Color purple() {
|
||||
return {204, 0, 102};
|
||||
|
||||
@@ -79,6 +79,10 @@ int Painter::draw_string(
|
||||
}
|
||||
|
||||
void Painter::draw_bitmap(Point p, const Bitmap& bitmap, Color foreground, Color background) {
|
||||
// If bright foreground colors on white background, darken the foreground color to improve visibility
|
||||
if ((background.v == ui::Color::white().v) && (foreground.to_greyscale() > 146))
|
||||
foreground = foreground.dark();
|
||||
|
||||
display.draw_bitmap(p, bitmap.size, bitmap.data, foreground, background);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,10 @@ Dim Font::line_height() const {
|
||||
return h;
|
||||
}
|
||||
|
||||
Dim Font::char_width() const {
|
||||
return w;
|
||||
}
|
||||
|
||||
Size Font::size_of(const std::string s) const {
|
||||
Size size;
|
||||
|
||||
|
||||
@@ -86,6 +86,8 @@ class Font {
|
||||
Glyph glyph(const char c) const;
|
||||
|
||||
Dim line_height() const;
|
||||
Dim char_width() const;
|
||||
|
||||
Size size_of(const std::string s) const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -177,6 +177,8 @@ const std::vector<Widget*>& Widget::children() const {
|
||||
}
|
||||
|
||||
Context& Widget::context() const {
|
||||
chDbgAssert(parent_, "parent_ is null",
|
||||
"Check that parent isn't null before deref.");
|
||||
return parent()->context();
|
||||
}
|
||||
|
||||
@@ -1323,6 +1325,68 @@ bool ImageButton::on_touch(const TouchEvent event) {
|
||||
}
|
||||
}
|
||||
|
||||
/* ImageToggle ***********************************************************/
|
||||
ImageToggle::ImageToggle(
|
||||
Rect parent_rect,
|
||||
const Bitmap* bitmap_)
|
||||
: ImageToggle{parent_rect,
|
||||
bitmap_,
|
||||
Color::green(),
|
||||
Color::light_grey(),
|
||||
Color::dark_grey()} {}
|
||||
|
||||
ImageToggle::ImageToggle(
|
||||
Rect parent_rect,
|
||||
const Bitmap* bitmap_,
|
||||
Color foreground_true,
|
||||
Color foreground_false,
|
||||
Color background_)
|
||||
: ImageToggle{parent_rect,
|
||||
bitmap_,
|
||||
bitmap_,
|
||||
foreground_true,
|
||||
background_,
|
||||
foreground_false,
|
||||
background_} {}
|
||||
|
||||
ImageToggle::ImageToggle(
|
||||
Rect parent_rect,
|
||||
const Bitmap* bitmap_true,
|
||||
const Bitmap* bitmap_false,
|
||||
Color foreground_true,
|
||||
Color background_true,
|
||||
Color foreground_false,
|
||||
Color background_false)
|
||||
: ImageButton{parent_rect, bitmap_false, foreground_false, background_false},
|
||||
bitmap_true_{bitmap_true},
|
||||
bitmap_false_{bitmap_false},
|
||||
foreground_true_{foreground_true},
|
||||
background_true_{background_true},
|
||||
foreground_false_{foreground_false},
|
||||
background_false_{background_false},
|
||||
value_{false} {
|
||||
ImageButton::on_select = [this](ImageButton&) {
|
||||
set_value(!value());
|
||||
};
|
||||
}
|
||||
|
||||
bool ImageToggle::value() const {
|
||||
return value_;
|
||||
}
|
||||
|
||||
void ImageToggle::set_value(bool b) {
|
||||
if (b == value_)
|
||||
return;
|
||||
|
||||
value_ = b;
|
||||
set_bitmap(b ? bitmap_true_ : bitmap_false_);
|
||||
set_foreground(b ? foreground_true_ : foreground_false_);
|
||||
set_background(b ? background_true_ : background_false_);
|
||||
|
||||
if (on_change)
|
||||
on_change(b);
|
||||
}
|
||||
|
||||
/* ImageOptionsField *****************************************************/
|
||||
|
||||
ImageOptionsField::ImageOptionsField(
|
||||
@@ -1460,6 +1524,24 @@ void OptionsField::set_by_value(value_t v) {
|
||||
set_selected_index(0);
|
||||
}
|
||||
|
||||
void OptionsField::set_by_nearest_value(value_t v) {
|
||||
size_t new_index = 0;
|
||||
size_t curr_index = 0;
|
||||
int32_t min_diff = INT32_MAX;
|
||||
|
||||
for (const auto& option : options) {
|
||||
auto diff = abs(v - option.second);
|
||||
if (diff < min_diff) {
|
||||
min_diff = diff;
|
||||
new_index = curr_index;
|
||||
}
|
||||
|
||||
curr_index++;
|
||||
}
|
||||
|
||||
set_selected_index(new_index);
|
||||
}
|
||||
|
||||
void OptionsField::set_options(options_t new_options) {
|
||||
options = new_options;
|
||||
|
||||
|
||||
@@ -448,7 +448,7 @@ class ButtonWithEncoder : public Widget {
|
||||
class NewButton : public Widget {
|
||||
public:
|
||||
std::function<void(void)> on_select{};
|
||||
// std::function<void(NewButton&)> on_select { };
|
||||
// std::function<void(NewButton&)> on_select{};
|
||||
std::function<bool(NewButton&, KeyEvent)> on_dir{};
|
||||
std::function<void(NewButton&)> on_highlight{};
|
||||
|
||||
@@ -500,6 +500,8 @@ class Image : public Widget {
|
||||
|
||||
void paint(Painter& painter) override;
|
||||
|
||||
const Bitmap& bitmap() & { return *bitmap_; }
|
||||
|
||||
private:
|
||||
const Bitmap* bitmap_;
|
||||
Color foreground_;
|
||||
@@ -520,6 +522,49 @@ class ImageButton : public Image {
|
||||
bool on_touch(const TouchEvent event) override;
|
||||
};
|
||||
|
||||
/* A button that toggles between two images when set. */
|
||||
class ImageToggle : public ImageButton {
|
||||
public:
|
||||
std::function<void(bool value)> on_change{};
|
||||
|
||||
ImageToggle(
|
||||
Rect parent_rect,
|
||||
const Bitmap* bitmap_);
|
||||
|
||||
ImageToggle(
|
||||
Rect parent_rect,
|
||||
const Bitmap* bitmap_,
|
||||
Color foreground_true,
|
||||
Color foreground_false,
|
||||
Color background_);
|
||||
|
||||
ImageToggle(
|
||||
Rect parent_rect,
|
||||
const Bitmap* bitmap_true,
|
||||
const Bitmap* bitmap_false,
|
||||
Color foreground_true,
|
||||
Color background_true,
|
||||
Color foreground_false,
|
||||
Color background_false);
|
||||
|
||||
ImageToggle(const ImageToggle&) = delete;
|
||||
ImageToggle& operator=(const ImageToggle&) = delete;
|
||||
|
||||
bool value() const;
|
||||
void set_value(bool b);
|
||||
|
||||
private:
|
||||
// Hide this field.
|
||||
using ImageButton::on_select;
|
||||
const Bitmap* bitmap_true_;
|
||||
const Bitmap* bitmap_false_;
|
||||
const Color foreground_true_;
|
||||
const Color background_true_;
|
||||
const Color foreground_false_;
|
||||
const Color background_false_;
|
||||
bool value_;
|
||||
};
|
||||
|
||||
class ImageOptionsField : public Widget {
|
||||
public:
|
||||
using value_t = int32_t;
|
||||
@@ -579,6 +624,7 @@ class OptionsField : public Widget {
|
||||
void set_selected_index(const size_t new_index, bool trigger_change = true);
|
||||
|
||||
void set_by_value(value_t v);
|
||||
void set_by_nearest_value(value_t v);
|
||||
|
||||
void paint(Painter& painter) override;
|
||||
|
||||
|
||||
@@ -345,6 +345,9 @@ class WM8731 : public audio::Codec {
|
||||
|
||||
void speaker_enable(){};
|
||||
void speaker_disable(){};
|
||||
bool speaker_disable_supported() const override {
|
||||
return false;
|
||||
}
|
||||
|
||||
void microphone_enable(int8_t wm8731_boost_GUI) override {
|
||||
microphone_mute(true); // c/m to reduce "plop noise" when changing wm8731_boost_GUI.
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 252 B |
Binary file not shown.
|
After Width: | Height: | Size: 252 B |
Binary file not shown.
|
After Width: | Height: | Size: 152 B |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user