2015-07-08 11:39:24 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
2016-12-09 12:21:47 -05:00
|
|
|
* Copyright (C) 2016 Furrtek
|
2023-05-22 16:17:28 -04:00
|
|
|
* Copyright (C) 2023 gullradriel, Nilorea Studio Inc.
|
2015-07-08 11:39:24 -04:00
|
|
|
*
|
|
|
|
* This file is part of PortaPack.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2018-05-16 04:45:13 -04:00
|
|
|
#include "ui_settings.hpp"
|
2016-02-04 04:27:53 -05:00
|
|
|
|
2016-12-26 07:49:23 -05:00
|
|
|
#include "ui_navigation.hpp"
|
2016-07-27 17:15:21 -04:00
|
|
|
#include "ui_touch_calibration.hpp"
|
|
|
|
|
2015-08-04 13:03:18 -04:00
|
|
|
#include "portapack_persistent_memory.hpp"
|
2015-07-08 11:39:24 -04:00
|
|
|
#include "lpc43xx_cpp.hpp"
|
|
|
|
using namespace lpc43xx;
|
2016-01-31 03:34:24 -05:00
|
|
|
|
2020-06-07 19:23:23 -04:00
|
|
|
#include "audio.hpp"
|
2016-01-31 03:34:24 -05:00
|
|
|
#include "portapack.hpp"
|
|
|
|
using portapack::receiver_model;
|
2016-07-26 21:03:40 -04:00
|
|
|
using namespace portapack;
|
2016-01-23 14:32:10 -05:00
|
|
|
|
2016-07-26 21:03:40 -04:00
|
|
|
#include "string_format.hpp"
|
|
|
|
#include "ui_font_fixed_8x16.hpp"
|
2016-07-17 18:56:24 -04:00
|
|
|
#include "cpld_update.hpp"
|
2015-07-08 11:39:24 -04:00
|
|
|
|
2023-03-22 03:46:58 -04:00
|
|
|
#include "freqman.hpp"
|
|
|
|
|
2015-07-08 11:39:24 -04:00
|
|
|
namespace ui {
|
2023-05-18 16:16:05 -04:00
|
|
|
SetDateTimeView::SetDateTimeView(
|
|
|
|
NavigationView& nav) {
|
|
|
|
button_save.on_select = [&nav, this](Button&) {
|
|
|
|
const auto model = this->form_collect();
|
|
|
|
const rtc::RTC new_datetime{
|
|
|
|
model.year, model.month, model.day,
|
|
|
|
model.hour, model.minute, model.second};
|
|
|
|
rtcSetTime(&RTCD1, &new_datetime);
|
|
|
|
nav.pop();
|
|
|
|
},
|
|
|
|
|
|
|
|
button_cancel.on_select = [&nav](Button&) {
|
|
|
|
nav.pop();
|
|
|
|
},
|
|
|
|
|
|
|
|
add_children({
|
|
|
|
&labels,
|
|
|
|
&field_year,
|
|
|
|
&field_month,
|
|
|
|
&field_day,
|
|
|
|
&field_hour,
|
|
|
|
&field_minute,
|
|
|
|
&field_second,
|
|
|
|
&button_save,
|
|
|
|
&button_cancel,
|
|
|
|
});
|
|
|
|
|
|
|
|
rtc::RTC datetime;
|
|
|
|
rtcGetTime(&RTCD1, &datetime);
|
|
|
|
SetDateTimeModel model{
|
|
|
|
datetime.year(),
|
|
|
|
datetime.month(),
|
|
|
|
datetime.day(),
|
|
|
|
datetime.hour(),
|
|
|
|
datetime.minute(),
|
|
|
|
datetime.second()};
|
|
|
|
|
|
|
|
form_init(model);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetDateTimeView::focus() {
|
|
|
|
button_cancel.focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetDateTimeView::form_init(const SetDateTimeModel& model) {
|
|
|
|
field_year.set_value(model.year);
|
|
|
|
field_month.set_value(model.month);
|
|
|
|
field_day.set_value(model.day);
|
|
|
|
field_hour.set_value(model.hour);
|
|
|
|
field_minute.set_value(model.minute);
|
|
|
|
field_second.set_value(model.second);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetDateTimeModel SetDateTimeView::form_collect() {
|
|
|
|
return {
|
|
|
|
.year = static_cast<uint16_t>(field_year.value()),
|
|
|
|
.month = static_cast<uint8_t>(field_month.value()),
|
|
|
|
.day = static_cast<uint8_t>(field_day.value()),
|
|
|
|
.hour = static_cast<uint8_t>(field_hour.value()),
|
|
|
|
.minute = static_cast<uint8_t>(field_minute.value()),
|
|
|
|
.second = static_cast<uint8_t>(field_second.value())};
|
|
|
|
}
|
|
|
|
|
|
|
|
SetRadioView::SetRadioView(
|
|
|
|
NavigationView& nav) {
|
|
|
|
button_cancel.on_select = [&nav](Button&) {
|
|
|
|
nav.pop();
|
|
|
|
};
|
|
|
|
|
|
|
|
const auto reference = portapack::clock_manager.get_reference();
|
|
|
|
|
|
|
|
std::string source_name("---");
|
|
|
|
switch (reference.source) {
|
|
|
|
case ClockManager::ReferenceSource::Xtal:
|
|
|
|
source_name = "HackRF";
|
|
|
|
break;
|
|
|
|
case ClockManager::ReferenceSource::PortaPack:
|
|
|
|
source_name = "PortaPack";
|
|
|
|
break;
|
|
|
|
case ClockManager::ReferenceSource::External:
|
|
|
|
source_name = "External";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
value_source.set(source_name);
|
|
|
|
value_source_frequency.set(to_string_dec_uint(reference.frequency / 1000000, 2) + "." + to_string_dec_uint((reference.frequency % 1000000) / 100, 4, '0') + " MHz");
|
|
|
|
|
|
|
|
label_source.set_style(&style_text);
|
|
|
|
value_source.set_style(&style_text);
|
|
|
|
value_source_frequency.set_style(&style_text);
|
|
|
|
|
|
|
|
add_children({
|
|
|
|
&label_source,
|
|
|
|
&value_source,
|
|
|
|
&value_source_frequency,
|
|
|
|
});
|
|
|
|
|
|
|
|
if (reference.source == ClockManager::ReferenceSource::Xtal) {
|
|
|
|
add_children({
|
|
|
|
&labels_correction,
|
|
|
|
&field_ppm,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
add_children({&check_clkout,
|
|
|
|
&field_clkout_freq,
|
|
|
|
&labels_clkout_khz,
|
|
|
|
&value_freq_step,
|
|
|
|
&labels_bias,
|
|
|
|
&check_bias,
|
|
|
|
&button_save,
|
|
|
|
&button_cancel});
|
|
|
|
|
|
|
|
SetFrequencyCorrectionModel model{
|
|
|
|
static_cast<int8_t>(portapack::persistent_memory::correction_ppb() / 1000), 0};
|
|
|
|
|
|
|
|
form_init(model);
|
|
|
|
|
|
|
|
check_clkout.set_value(portapack::persistent_memory::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);
|
|
|
|
};
|
|
|
|
|
|
|
|
field_clkout_freq.set_value(portapack::persistent_memory::clkout_freq());
|
|
|
|
value_freq_step.set_style(&style_text);
|
|
|
|
|
|
|
|
field_clkout_freq.on_select = [this](NumberField&) {
|
|
|
|
freq_step_khz++;
|
|
|
|
if (freq_step_khz > 3) {
|
|
|
|
freq_step_khz = 0;
|
|
|
|
}
|
|
|
|
switch (freq_step_khz) {
|
|
|
|
case 0:
|
|
|
|
value_freq_step.set(" |");
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
value_freq_step.set(" | ");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
value_freq_step.set(" | ");
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
value_freq_step.set("| ");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
field_clkout_freq.set_step(pow(10, freq_step_khz));
|
|
|
|
};
|
|
|
|
|
|
|
|
check_bias.set_value(portapack::get_antenna_bias());
|
|
|
|
check_bias.on_select = [this](Checkbox&, bool v) {
|
|
|
|
portapack::set_antenna_bias(v);
|
2023-05-24 00:22:30 -04:00
|
|
|
|
|
|
|
// Update the radio.
|
|
|
|
receiver_model.set_antenna_bias();
|
|
|
|
transmitter_model.set_antenna_bias();
|
|
|
|
// The models won't actually disable this if they are not 'enabled_'.
|
|
|
|
// Be extra sure this is turned off.
|
|
|
|
if (!v)
|
|
|
|
radio::set_antenna_bias(false);
|
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
StatusRefreshMessage message{};
|
|
|
|
EventDispatcher::send_message(message);
|
|
|
|
};
|
|
|
|
|
|
|
|
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());
|
|
|
|
nav.pop();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetRadioView::focus() {
|
|
|
|
button_save.focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetRadioView::form_init(const SetFrequencyCorrectionModel& model) {
|
|
|
|
field_ppm.set_value(model.ppm);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetFrequencyCorrectionModel SetRadioView::form_collect() {
|
|
|
|
return {
|
|
|
|
.ppm = static_cast<int8_t>(field_ppm.value()),
|
|
|
|
.freq = static_cast<uint32_t>(field_clkout_freq.value()),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
SetUIView::SetUIView(NavigationView& nav) {
|
|
|
|
add_children({&checkbox_disable_touchscreen,
|
|
|
|
&checkbox_speaker,
|
|
|
|
&checkbox_bloff,
|
|
|
|
&options_bloff,
|
|
|
|
&checkbox_showsplash,
|
|
|
|
&checkbox_showclock,
|
|
|
|
&options_clockformat,
|
|
|
|
&checkbox_guireturnflag,
|
|
|
|
&button_save,
|
|
|
|
&button_cancel});
|
|
|
|
|
|
|
|
checkbox_disable_touchscreen.set_value(persistent_memory::disable_touchscreen());
|
|
|
|
checkbox_speaker.set_value(persistent_memory::config_speaker());
|
|
|
|
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());
|
|
|
|
|
|
|
|
const auto backlight_config = persistent_memory::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()) {
|
|
|
|
options_clockformat.set_selected_index(1);
|
|
|
|
} else {
|
|
|
|
options_clockformat.set_selected_index(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
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()});
|
|
|
|
|
|
|
|
if (checkbox_showclock.value()) {
|
|
|
|
if (options_clockformat.selected_index() == 1)
|
|
|
|
persistent_memory::set_clock_with_date(true);
|
|
|
|
else
|
|
|
|
persistent_memory::set_clock_with_date(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (checkbox_speaker.value()) audio::output::speaker_mute(); // Just mute audio if speaker is disabled
|
|
|
|
persistent_memory::set_config_speaker(checkbox_speaker.value()); // Store Speaker status
|
|
|
|
StatusRefreshMessage message{}; // Refresh status bar with/out speaker
|
|
|
|
EventDispatcher::send_message(message);
|
|
|
|
|
|
|
|
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());
|
|
|
|
nav.pop();
|
|
|
|
};
|
|
|
|
button_cancel.on_select = [&nav, this](Button&) {
|
|
|
|
nav.pop();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetUIView::focus() {
|
|
|
|
button_save.focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
// Appl. Settings
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
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());
|
|
|
|
|
|
|
|
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());
|
|
|
|
nav.pop();
|
|
|
|
};
|
|
|
|
button_cancel.on_select = [&nav, this](Button&) {
|
|
|
|
nav.pop();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetAppSettingsView::focus() {
|
|
|
|
button_save.focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
// Converter Settings
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
SetConverterSettingsView::SetConverterSettingsView(NavigationView& nav) {
|
|
|
|
add_children({&check_show_converter,
|
|
|
|
&check_converter,
|
|
|
|
&converter_mode,
|
|
|
|
&button_converter_freq,
|
2023-05-20 03:30:08 -04:00
|
|
|
&button_return});
|
2023-05-18 16:16:05 -04:00
|
|
|
|
|
|
|
check_show_converter.set_value(!portapack::persistent_memory::config_hide_converter());
|
|
|
|
check_show_converter.on_select = [this](Checkbox&, bool v) {
|
|
|
|
portapack::persistent_memory::set_config_hide_converter(!v);
|
|
|
|
if (!v) {
|
|
|
|
check_converter.set_value(false);
|
|
|
|
}
|
|
|
|
// Retune to take converter change in account
|
|
|
|
receiver_model.set_tuning_frequency(portapack::persistent_memory::tuned_frequency());
|
|
|
|
// Refresh status bar with/out converter
|
|
|
|
StatusRefreshMessage message{};
|
|
|
|
EventDispatcher::send_message(message);
|
|
|
|
};
|
|
|
|
|
|
|
|
check_converter.set_value(portapack::persistent_memory::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);
|
|
|
|
}
|
|
|
|
portapack::persistent_memory::set_config_converter(v);
|
|
|
|
// Retune to take converter change in account
|
|
|
|
receiver_model.set_tuning_frequency(portapack::persistent_memory::tuned_frequency());
|
|
|
|
// Refresh status bar with/out converter
|
|
|
|
StatusRefreshMessage message{};
|
|
|
|
EventDispatcher::send_message(message);
|
|
|
|
};
|
|
|
|
|
|
|
|
converter_mode.set_by_value(portapack::persistent_memory::config_updown_converter());
|
|
|
|
converter_mode.on_change = [this](size_t, OptionsField::value_t v) {
|
|
|
|
portapack::persistent_memory::set_config_updown_converter(v);
|
|
|
|
// Refresh status bar with icon up or down
|
|
|
|
StatusRefreshMessage message{};
|
|
|
|
EventDispatcher::send_message(message);
|
|
|
|
};
|
|
|
|
|
|
|
|
button_converter_freq.set_text(to_string_short_freq(portapack::persistent_memory::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());
|
|
|
|
new_view->on_changed = [this, &button](rf::Frequency f) {
|
|
|
|
portapack::persistent_memory::set_config_converter_freq(f);
|
|
|
|
// Retune to take converter change in account
|
|
|
|
receiver_model.set_tuning_frequency(portapack::persistent_memory::tuned_frequency());
|
|
|
|
button_converter_freq.set_text("<" + to_string_short_freq(f) + " MHz>");
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-05-20 03:30:08 -04:00
|
|
|
button_return.on_select = [&nav, this](Button&) {
|
2023-05-18 16:16:05 -04:00
|
|
|
nav.pop();
|
|
|
|
};
|
2023-05-20 03:30:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetConverterSettingsView::focus() {
|
|
|
|
button_return.focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
// Frequency Correction Settings
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
SetFrequencyCorrectionView::SetFrequencyCorrectionView(NavigationView& nav) {
|
|
|
|
add_children({&text_freqCorrection_about,
|
|
|
|
&frequency_rx_correction_mode,
|
|
|
|
&frequency_tx_correction_mode,
|
|
|
|
&button_freq_rx_correction,
|
|
|
|
&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.on_change = [this](size_t, OptionsField::value_t v) {
|
|
|
|
portapack::persistent_memory::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.on_change = [this](size_t, OptionsField::value_t v) {
|
|
|
|
portapack::persistent_memory::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.on_select = [this, &nav](Button& button) {
|
|
|
|
auto new_view = nav.push<FrequencyKeypadView>(portapack::persistent_memory::config_converter_freq());
|
|
|
|
new_view->on_changed = [this, &button](rf::Frequency f) {
|
2023-05-21 17:47:02 -04:00
|
|
|
if (f >= MAX_FREQ_CORRECTION)
|
|
|
|
f = MAX_FREQ_CORRECTION;
|
2023-05-20 03:30:08 -04:00
|
|
|
portapack::persistent_memory::set_config_freq_rx_correction(f);
|
|
|
|
// Retune to take converter change in account
|
|
|
|
receiver_model.set_tuning_frequency(portapack::persistent_memory::tuned_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.on_select = [this, &nav](Button& button) {
|
|
|
|
auto new_view = nav.push<FrequencyKeypadView>(portapack::persistent_memory::config_converter_freq());
|
|
|
|
new_view->on_changed = [this, &button](rf::Frequency f) {
|
2023-05-21 17:47:02 -04:00
|
|
|
if (f >= MAX_FREQ_CORRECTION)
|
|
|
|
f = MAX_FREQ_CORRECTION;
|
2023-05-20 03:30:08 -04:00
|
|
|
portapack::persistent_memory::set_config_freq_tx_correction(f);
|
|
|
|
// Retune to take converter change in account
|
|
|
|
receiver_model.set_tuning_frequency(portapack::persistent_memory::tuned_frequency());
|
|
|
|
button_freq_tx_correction.set_text("<" + to_string_short_freq(f) + " MHz>");
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
button_return.on_select = [&nav, this](Button&) {
|
2023-05-18 16:16:05 -04:00
|
|
|
nav.pop();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-05-20 03:30:08 -04:00
|
|
|
void SetFrequencyCorrectionView::focus() {
|
|
|
|
button_return.focus();
|
2023-05-18 16:16:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
// Persistent Memory Settings
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
SetPersistentMemoryView::SetPersistentMemoryView(NavigationView& nav) {
|
|
|
|
add_children({&text_pmem_about,
|
|
|
|
&text_pmem_informations,
|
|
|
|
&text_pmem_status,
|
2023-06-04 15:25:25 -04:00
|
|
|
&check_use_sdcard_for_pmem,
|
2023-05-18 16:16:05 -04:00
|
|
|
&button_save_mem_to_file,
|
|
|
|
&button_load_mem_from_file,
|
|
|
|
&button_load_mem_defaults,
|
|
|
|
&button_return});
|
|
|
|
|
2023-06-04 15:25:25 -04:00
|
|
|
check_use_sdcard_for_pmem.set_value(portapack::persistent_memory::should_use_sdcard_for_pmem());
|
|
|
|
check_use_sdcard_for_pmem.on_select = [this](Checkbox&, bool v) {
|
2023-05-18 16:16:05 -04:00
|
|
|
File pmem_flag_file_handle;
|
2023-06-04 15:25:25 -04:00
|
|
|
std::string pmem_flag_file = PMEM_FILEFLAG;
|
2023-05-18 16:16:05 -04:00
|
|
|
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 {
|
|
|
|
text_pmem_status.set("pmem flag already present");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
auto result = delete_file(pmem_flag_file);
|
|
|
|
if (result.code() != FR_OK) {
|
|
|
|
text_pmem_status.set("!err. deleting pmem flagfile!");
|
|
|
|
} else {
|
|
|
|
text_pmem_status.set("pmem flag file deleted");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
button_save_mem_to_file.on_select = [&nav, this](Button&) {
|
2023-06-04 15:25:25 -04:00
|
|
|
if (!portapack::persistent_memory::save_persistent_settings_to_file()) {
|
2023-05-18 16:16:05 -04:00
|
|
|
text_pmem_status.set("!problem saving settings!");
|
|
|
|
} else {
|
|
|
|
text_pmem_status.set("settings saved");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
button_load_mem_from_file.on_select = [&nav, this](Button&) {
|
2023-06-04 15:25:25 -04:00
|
|
|
if (!portapack::persistent_memory::load_persistent_settings_from_file()) {
|
2023-05-18 16:16:05 -04:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
button_load_mem_defaults.on_select = [&nav, this](Button&) {
|
|
|
|
nav.push<ModalMessageView>(
|
|
|
|
"Warning!",
|
|
|
|
"This will reset the p.mem\nand set the default settings",
|
|
|
|
YESNO,
|
|
|
|
[this](bool choice) {
|
|
|
|
if (choice) {
|
|
|
|
portapack::persistent_memory::cache::defaults();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
button_return.on_select = [&nav, this](Button&) {
|
|
|
|
nav.pop();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetPersistentMemoryView::focus() {
|
|
|
|
button_return.focus();
|
|
|
|
}
|
|
|
|
|
Support for Rotary Encoder Dial sensitivity levels, issue #965 (#1057)
* Support for 3 levels of rotary encoder sensitivity #965
Backend support; UI will still need to call set function to configure.
* Support for 3 levels of rotary encoder sensitivity #965
Backend support only. UI will still need to be changed to call the set_sensitivity() function to configure.
* Removed trailing space
* Deleted blank lines to see if format checker will be happier
* Simpler support for multiple levels of encoder sensitivity, for issue #965
Removed the convoluted code :-) and instead just using a 2-dimensional array to choose which transition map to use. For now I only have 2 (vs 3) levels enabled as well, to save code space and because high-sensitivity is very touchy.
* Simpler version of configurable encoder sensitivity, issue #965
* Formatting
* Formatting test for Clang
* Formatting test
* Formatting (removed helpful comment)
* Formatting test (remove commented-out code)
* Formatting & swapping medium/low so default mode=0
* Swapped medium/low so default mode=0
* Adding UI & PMEM support to make encoder dial sensitivity configurable, issue #965
* Adding UI & PMEM support to make encoder dial sensitivity configurable, issue #965
* Adding UI & PMEM support to make encoder dial sensitivity configurable, issue #965
* Adding UI & PMEM support to make encoder dial sensitivity configurable, issue #965
* Adding UI & PMEM support to make encoder dial sensitivity configurable, issue #965
* Adding UI & PMEM support to make encoder dial sensitivity configurable, issue #965
* Removed unneeded range check (trusting in pmem checksum)
2023-05-24 22:32:12 -04:00
|
|
|
// ---------------------------------------------------------
|
|
|
|
// Audio Settings
|
|
|
|
// ---------------------------------------------------------
|
2023-05-18 16:16:05 -04:00
|
|
|
SetAudioView::SetAudioView(NavigationView& nav) {
|
|
|
|
add_children({&labels,
|
|
|
|
&field_tone_mix,
|
|
|
|
&button_save,
|
|
|
|
&button_cancel});
|
|
|
|
|
|
|
|
field_tone_mix.set_value(persistent_memory::tone_mix());
|
|
|
|
|
|
|
|
button_save.on_select = [&nav, this](Button&) {
|
|
|
|
persistent_memory::set_tone_mix(field_tone_mix.value());
|
|
|
|
nav.pop();
|
|
|
|
};
|
|
|
|
|
|
|
|
button_cancel.on_select = [&nav, this](Button&) {
|
|
|
|
nav.pop();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetAudioView::focus() {
|
|
|
|
button_save.focus();
|
|
|
|
}
|
|
|
|
|
Support for Rotary Encoder Dial sensitivity levels, issue #965 (#1057)
* Support for 3 levels of rotary encoder sensitivity #965
Backend support; UI will still need to call set function to configure.
* Support for 3 levels of rotary encoder sensitivity #965
Backend support only. UI will still need to be changed to call the set_sensitivity() function to configure.
* Removed trailing space
* Deleted blank lines to see if format checker will be happier
* Simpler support for multiple levels of encoder sensitivity, for issue #965
Removed the convoluted code :-) and instead just using a 2-dimensional array to choose which transition map to use. For now I only have 2 (vs 3) levels enabled as well, to save code space and because high-sensitivity is very touchy.
* Simpler version of configurable encoder sensitivity, issue #965
* Formatting
* Formatting test for Clang
* Formatting test
* Formatting (removed helpful comment)
* Formatting test (remove commented-out code)
* Formatting & swapping medium/low so default mode=0
* Swapped medium/low so default mode=0
* Adding UI & PMEM support to make encoder dial sensitivity configurable, issue #965
* Adding UI & PMEM support to make encoder dial sensitivity configurable, issue #965
* Adding UI & PMEM support to make encoder dial sensitivity configurable, issue #965
* Adding UI & PMEM support to make encoder dial sensitivity configurable, issue #965
* Adding UI & PMEM support to make encoder dial sensitivity configurable, issue #965
* Adding UI & PMEM support to make encoder dial sensitivity configurable, issue #965
* Removed unneeded range check (trusting in pmem checksum)
2023-05-24 22:32:12 -04:00
|
|
|
// ---------------------------------------------------------
|
|
|
|
// QR Code Settings
|
|
|
|
// ------------------------------------------------------
|
2023-05-18 16:16:05 -04:00
|
|
|
SetQRCodeView::SetQRCodeView(NavigationView& nav) {
|
|
|
|
add_children({&checkbox_bigger_qr,
|
|
|
|
&button_save,
|
|
|
|
&button_cancel});
|
|
|
|
|
|
|
|
checkbox_bigger_qr.set_value(persistent_memory::show_bigger_qr_code());
|
|
|
|
|
|
|
|
button_save.on_select = [&nav, this](Button&) {
|
|
|
|
persistent_memory::set_show_bigger_qr_code(checkbox_bigger_qr.value());
|
|
|
|
nav.pop();
|
|
|
|
};
|
|
|
|
|
|
|
|
button_cancel.on_select = [&nav, this](Button&) {
|
|
|
|
nav.pop();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetQRCodeView::focus() {
|
|
|
|
button_save.focus();
|
|
|
|
}
|
|
|
|
|
Support for Rotary Encoder Dial sensitivity levels, issue #965 (#1057)
* Support for 3 levels of rotary encoder sensitivity #965
Backend support; UI will still need to call set function to configure.
* Support for 3 levels of rotary encoder sensitivity #965
Backend support only. UI will still need to be changed to call the set_sensitivity() function to configure.
* Removed trailing space
* Deleted blank lines to see if format checker will be happier
* Simpler support for multiple levels of encoder sensitivity, for issue #965
Removed the convoluted code :-) and instead just using a 2-dimensional array to choose which transition map to use. For now I only have 2 (vs 3) levels enabled as well, to save code space and because high-sensitivity is very touchy.
* Simpler version of configurable encoder sensitivity, issue #965
* Formatting
* Formatting test for Clang
* Formatting test
* Formatting (removed helpful comment)
* Formatting test (remove commented-out code)
* Formatting & swapping medium/low so default mode=0
* Swapped medium/low so default mode=0
* Adding UI & PMEM support to make encoder dial sensitivity configurable, issue #965
* Adding UI & PMEM support to make encoder dial sensitivity configurable, issue #965
* Adding UI & PMEM support to make encoder dial sensitivity configurable, issue #965
* Adding UI & PMEM support to make encoder dial sensitivity configurable, issue #965
* Adding UI & PMEM support to make encoder dial sensitivity configurable, issue #965
* Adding UI & PMEM support to make encoder dial sensitivity configurable, issue #965
* Removed unneeded range check (trusting in pmem checksum)
2023-05-24 22:32:12 -04:00
|
|
|
// ---------------------------------------------------------
|
|
|
|
// Rotary Encoder Dial Settings
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
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());
|
|
|
|
|
|
|
|
button_save.on_select = [&nav, this](Button&) {
|
|
|
|
persistent_memory::set_encoder_dial_sensitivity(field_encoder_dial_sensitivity.selected_index_value());
|
|
|
|
nav.pop();
|
|
|
|
};
|
|
|
|
|
|
|
|
button_cancel.on_select = [&nav, this](Button&) {
|
|
|
|
nav.pop();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetEncoderDialView::focus() {
|
|
|
|
button_save.focus();
|
|
|
|
}
|
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
// ---------------------------------------------------------
|
|
|
|
// Settings main menu
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
SettingsMenuView::SettingsMenuView(NavigationView& nav) {
|
|
|
|
if (portapack::persistent_memory::show_gui_return_icon()) {
|
|
|
|
add_items({{"..", ui::Color::light_grey(), &bitmap_icon_previous, [&nav]() { nav.pop(); }}});
|
|
|
|
}
|
|
|
|
add_items({
|
|
|
|
{"Audio", ui::Color::dark_cyan(), &bitmap_icon_speaker, [&nav]() { nav.push<SetAudioView>(); }},
|
|
|
|
{"Radio", ui::Color::dark_cyan(), &bitmap_icon_options_radio, [&nav]() { nav.push<SetRadioView>(); }},
|
|
|
|
{"User Interface", ui::Color::dark_cyan(), &bitmap_icon_options_ui, [&nav]() { nav.push<SetUIView>(); }},
|
|
|
|
{"Date/Time", ui::Color::dark_cyan(), &bitmap_icon_options_datetime, [&nav]() { nav.push<SetDateTimeView>(); }},
|
|
|
|
{"Calibration", ui::Color::dark_cyan(), &bitmap_icon_options_touch, [&nav]() { nav.push<TouchCalibrationView>(); }},
|
|
|
|
{"App Settings", ui::Color::dark_cyan(), &bitmap_icon_setup, [&nav]() { nav.push<SetAppSettingsView>(); }},
|
|
|
|
{"Converter", ui::Color::dark_cyan(), &bitmap_icon_options_radio, [&nav]() { nav.push<SetConverterSettingsView>(); }},
|
2023-05-20 03:30:08 -04:00
|
|
|
{"FreqCorrection", ui::Color::dark_cyan(), &bitmap_icon_options_radio, [&nav]() { nav.push<SetFrequencyCorrectionView>(); }},
|
2023-05-18 16:16:05 -04:00
|
|
|
{"QR Code", ui::Color::dark_cyan(), &bitmap_icon_qr_code, [&nav]() { nav.push<SetQRCodeView>(); }},
|
|
|
|
{"P.Memory Mgmt", ui::Color::dark_cyan(), &bitmap_icon_memory, [&nav]() { nav.push<SetPersistentMemoryView>(); }},
|
Support for Rotary Encoder Dial sensitivity levels, issue #965 (#1057)
* Support for 3 levels of rotary encoder sensitivity #965
Backend support; UI will still need to call set function to configure.
* Support for 3 levels of rotary encoder sensitivity #965
Backend support only. UI will still need to be changed to call the set_sensitivity() function to configure.
* Removed trailing space
* Deleted blank lines to see if format checker will be happier
* Simpler support for multiple levels of encoder sensitivity, for issue #965
Removed the convoluted code :-) and instead just using a 2-dimensional array to choose which transition map to use. For now I only have 2 (vs 3) levels enabled as well, to save code space and because high-sensitivity is very touchy.
* Simpler version of configurable encoder sensitivity, issue #965
* Formatting
* Formatting test for Clang
* Formatting test
* Formatting (removed helpful comment)
* Formatting test (remove commented-out code)
* Formatting & swapping medium/low so default mode=0
* Swapped medium/low so default mode=0
* Adding UI & PMEM support to make encoder dial sensitivity configurable, issue #965
* Adding UI & PMEM support to make encoder dial sensitivity configurable, issue #965
* Adding UI & PMEM support to make encoder dial sensitivity configurable, issue #965
* Adding UI & PMEM support to make encoder dial sensitivity configurable, issue #965
* Adding UI & PMEM support to make encoder dial sensitivity configurable, issue #965
* Adding UI & PMEM support to make encoder dial sensitivity configurable, issue #965
* Removed unneeded range check (trusting in pmem checksum)
2023-05-24 22:32:12 -04:00
|
|
|
{"Encoder Dial", ui::Color::dark_cyan(), &bitmap_icon_setup, [&nav]() { nav.push<SetEncoderDialView>(); }},
|
2023-05-18 16:16:05 -04:00
|
|
|
});
|
|
|
|
set_max_rows(2); // allow wider buttons
|
|
|
|
}
|
2015-07-08 11:39:24 -04:00
|
|
|
|
|
|
|
} /* namespace ui */
|