Compare commits

...

4 Commits

Author SHA1 Message Date
sommermorgentraum
31082c63af theme fix again (#2611)
* theme fix again

* _
2025-04-05 16:58:12 +08:00
gullradriel
ff14008b43 prevent long life var for audio app - AM (#2610)
* static vars so no external linkage is possible

* persistent settings and no more global living variables

---------

Co-authored-by: gullradriel <gullradriel@no-mail.com>
2025-04-04 21:43:26 +08:00
sommermorgentraum
1377516dce make the ptext_prompt func can define which keyboard to enter (#2608)
* _

* format

* use define
2025-04-04 15:41:12 +02:00
Brumi-2021
4162820409 solving_Audio_App_AM_GUI_Problem_issue_2604 (#2609) 2025-04-04 14:04:06 +02:00
29 changed files with 87 additions and 30 deletions

View File

@@ -52,20 +52,20 @@ AMOptionsView::AMOptionsView(
&zoom_config,
});
zoom_config.on_change = [this, view](size_t, OptionsField::value_t n) {
receiver_model.set_am_configuration(previous_filter_array_index + n);
zoom_config.on_change = [this, view](size_t, OptionsField::value_t n) { // n , has two option values. when GUI =zoom+1 => (0), when GUI=zoom+2 (6)
receiver_model.set_am_configuration(view->get_previous_AM_mode_option() + n); // n (0 or 6)
view->set_zoom_factor(AM_MODULATION, n);
view->set_previous_zoom_option(n);
};
// restore zoom selection
zoom_config.set_by_value(view->get_zoom_factor(AM_MODULATION));
freqman_set_bandwidth_option(AM_MODULATION, options_config); // adding the common message from freqman.cpp to the options_config
options_config.set_by_value(receiver_model.am_configuration());
freqman_set_bandwidth_option(AM_MODULATION, options_config); // freqman.cpp to the options_config, only allowing 5 modes freqman_bandwidths[AM] {"DSB 9k", 0}, {"DSB 6k", 1}, {"USB+3k", 2}, {"LSB-3k", 3}, {"CW", 4},
options_config.set_by_value(receiver_model.am_configuration() - view->get_previous_zoom_option()); // restore AM GUI option mode , AM FIR index filters (0..11) values , <baseband::AMConfig, 12> am_configs has 12 fir index elements.
options_config.on_change = [this, view](size_t, OptionsField::value_t n) {
receiver_model.set_am_configuration(n);
previous_filter_array_index = n;
zoom_config.set_by_value(view->get_zoom_factor(AM_MODULATION));
receiver_model.set_am_configuration(n + view->get_previous_zoom_option()); // we select proper FIR AM filter (0..11), = 0..4 GUI AM modes + offset +6 (if zoom+2)
view->set_previous_AM_mode_option(n); // (0..4) allowing 5 AM modes (DSB9K, DSB6K, USB,LSB, CW)
};
}
@@ -282,6 +282,22 @@ void AnalogAudioView::set_zoom_factor(uint8_t mode, uint8_t zoom) { // define a
zoom_factor_amfm = zoom;
}
uint8_t AnalogAudioView::get_previous_AM_mode_option() {
return previous_AM_mode_option;
}
void AnalogAudioView::set_previous_AM_mode_option(uint8_t mode) {
previous_AM_mode_option = mode;
}
uint8_t AnalogAudioView::get_previous_zoom_option() {
return previous_zoom;
}
void AnalogAudioView::set_previous_zoom_option(uint8_t zoom) {
previous_zoom = zoom;
}
uint8_t AnalogAudioView::get_spec_iq_phase_calibration_value() { // define accessor functions inside AnalogAudioView to read iq_phase_calibration_value
return iq_phase_calibration_value;
}

View File

@@ -40,7 +40,6 @@ class AnalogAudioView;
class AMOptionsView : public View {
public:
AMOptionsView(AnalogAudioView* view, Rect parent_rect, const Style* style);
int16_t previous_filter_array_index = 0;
private:
Text label_config{
@@ -59,7 +58,7 @@ class AMOptionsView : public View {
{23 * 8, 0 * 16},
7,
{{"ZOOM x1", 0},
{"ZOOM x2", 6}} // offset index array filters.
{"ZOOM x2", 6}} // offset index AM modes array FIR filters.
};
};
@@ -200,6 +199,12 @@ class AnalogAudioView : public View {
uint8_t get_zoom_factor(uint8_t mode);
void set_zoom_factor(uint8_t mode, uint8_t zoom);
uint8_t get_previous_AM_mode_option();
void set_previous_AM_mode_option(uint8_t mode);
uint8_t get_previous_zoom_option();
void set_previous_zoom_option(uint8_t zoom);
private:
static constexpr ui::Dim header_height = 3 * 16;
@@ -208,6 +213,9 @@ class AnalogAudioView : public View {
uint8_t iq_phase_calibration_value{15}; // initial default RX IQ phase calibration value , used for both max2837 & max2839
uint8_t zoom_factor_am{0}; // initial zoom factor in AM mode
uint8_t zoom_factor_amfm{0}; // initial zoom factor in AMFM mode
uint8_t previous_AM_mode_option{0}; // GUI 5 AM modes : (0..4 ) (DSB9K, DSB6K, USB,LSB, CW). Used to select proper FIR filter (0..11) AM mode + offset 0 (zoom+1) or +6 (if zoom+2)
uint8_t previous_zoom{0}; // GUI ZOOM+1, ZOOM+2 , equivalent to two values offset 0 (zoom+1) or +6 (if zoom+2)
//
app_settings::SettingsManager settings_{
"rx_audio",
app_settings::Mode::RX,
@@ -215,6 +223,8 @@ class AnalogAudioView : public View {
{"iq_phase_calibration"sv, &iq_phase_calibration_value}, // we are saving and restoring that CAL from Settings.
{"zoom_factor_am"sv, &zoom_factor_am}, // we are saving and restoring AM ZOOM factor from Settings.
{"zoom_factor_amfm"sv, &zoom_factor_amfm}, // we are saving and restoring AMFM ZOOM factor from Settings.
{"previous_AM_mode_option"sv, &previous_AM_mode_option}, // we are saving and restoring AMFM ZOOM factor from Settings.
{"previous_zoom"sv, &previous_zoom}, // we are saving and restoring AMFM ZOOM factor from Settings.
}};
const Rect options_view_rect{0 * 8, 1 * 16, 30 * 8, 1 * 16};

View File

@@ -203,6 +203,7 @@ BleRecentEntryDetailView::BleRecentEntryDetailView(NavigationView& nav, const Bl
nav,
packetFileBuffer,
64,
ENTER_KEYBOARD_MODE_ALPHA,
[this, packetToSave](std::string& buffer) {
on_save_file(buffer, packetToSave);
});
@@ -471,6 +472,7 @@ BLERxView::BLERxView(NavigationView& nav)
nav_,
filterBuffer,
64,
ENTER_KEYBOARD_MODE_ALPHA,
[this](std::string& buffer) {
on_filter_change(buffer);
});
@@ -493,6 +495,7 @@ BLERxView::BLERxView(NavigationView& nav)
nav,
listFileBuffer,
64,
ENTER_KEYBOARD_MODE_ALPHA,
[this](std::string& buffer) {
on_save_file(buffer);
});

View File

@@ -399,6 +399,7 @@ BLETxView::BLETxView(NavigationView& nav)
nav,
packetFileBuffer,
64,
ENTER_KEYBOARD_MODE_ALPHA,
[this](std::string& buffer) {
on_save_file(buffer);
});

View File

@@ -94,6 +94,7 @@ APRSTXView::APRSTXView(NavigationView& nav) {
nav,
payload,
30,
ENTER_KEYBOARD_MODE_ALPHA,
[this](std::string& s) {
text_payload.set(s);
});

View File

@@ -499,7 +499,7 @@ FileSaveView::FileSaveView(
button_edit_path.on_select = [this](Button&) {
buffer_ = path_.string();
text_prompt(nav_, buffer_, max_filename_length,
text_prompt(nav_, buffer_, max_filename_length,ENTER_KEYBOARD_MODE_ALPHA,
[this](std::string&) {
path_ = buffer_;
refresh_widgets();
@@ -508,7 +508,7 @@ FileSaveView::FileSaveView(
button_edit_name.on_select = [this](Button&) {
buffer_ = file_.string();
text_prompt(nav_, buffer_, max_filename_length,
text_prompt(nav_, buffer_, max_filename_length,ENTER_KEYBOARD_MODE_ALPHA,
[this](std::string&) {
file_ = buffer_;
refresh_widgets();
@@ -566,7 +566,7 @@ void FileManagerView::on_rename(std::string_view hint) {
cursor_pos = pos;
text_prompt(
nav_, name_buffer, cursor_pos, max_filename_length,
nav_, name_buffer, cursor_pos, max_filename_length, ENTER_KEYBOARD_MODE_ALPHA,
[this](std::string& renamed) {
auto renamed_path = fs::path{renamed};
rename_file(get_selected_full_path(), current_path / renamed_path);
@@ -640,7 +640,7 @@ void FileManagerView::on_clean() {
void FileManagerView::on_new_dir() {
name_buffer = "";
text_prompt(nav_, name_buffer, max_filename_length, [this](std::string& dir_name) {
text_prompt(nav_, name_buffer, max_filename_length, ENTER_KEYBOARD_MODE_ALPHA, [this](std::string& dir_name) {
make_new_directory(current_path / dir_name);
reload_current(true);
});
@@ -671,7 +671,7 @@ void FileManagerView::on_paste() {
void FileManagerView::on_new_file() {
name_buffer = "";
text_prompt(nav_, name_buffer, max_filename_length, [this](std::string& file_name) {
text_prompt(nav_, name_buffer, max_filename_length, ENTER_KEYBOARD_MODE_ALPHA, [this](std::string& file_name) {
make_new_file(current_path / file_name);
reload_current(true);
});

View File

@@ -240,7 +240,7 @@ void FrequencyManagerView::on_edit_freq() {
void FrequencyManagerView::on_edit_desc() {
temp_buffer_ = current_entry().description;
text_prompt(nav_, temp_buffer_, freqman_max_desc_size, [this](std::string& new_desc) {
text_prompt(nav_, temp_buffer_, freqman_max_desc_size, ENTER_KEYBOARD_MODE_ALPHA, [this](std::string& new_desc) {
auto entry = current_entry();
entry.description = std::move(new_desc);
db_.replace_entry(current_index(), entry);
@@ -250,7 +250,7 @@ void FrequencyManagerView::on_edit_desc() {
void FrequencyManagerView::on_add_category() {
temp_buffer_.clear();
text_prompt(nav_, temp_buffer_, 20, [this](std::string& new_name) {
text_prompt(nav_, temp_buffer_, 20, ENTER_KEYBOARD_MODE_ALPHA, [this](std::string& new_name) {
if (!new_name.empty()) {
create_freqman_file(new_name);
refresh_categories();

View File

@@ -153,7 +153,7 @@ void POCSAGTXView::paint(Painter&) {
}
void POCSAGTXView::on_set_text(NavigationView& nav) {
text_prompt(nav, buffer, MAX_POCSAG_LENGTH);
text_prompt(nav, buffer, MAX_POCSAG_LENGTH, ENTER_KEYBOARD_MODE_ALPHA);
}
POCSAGTXView::POCSAGTXView(

View File

@@ -65,6 +65,7 @@ RDSPSNView::RDSPSNView(
nav,
PSN,
8,
ENTER_KEYBOARD_MODE_ALPHA,
[this](std::string& s) {
text_psn.set(s);
});
@@ -86,6 +87,7 @@ RDSRadioTextView::RDSRadioTextView(
nav,
radiotext,
28,
ENTER_KEYBOARD_MODE_ALPHA,
[this](std::string& s) {
text_radiotext.set(s);
});

View File

@@ -82,7 +82,7 @@ ReconSetupViewMain::ReconSetupViewMain(NavigationView& nav, Rect parent_rect, st
};
button_choose_output_name.on_select = [this, &nav](Button&) {
text_prompt(nav, _output_file, 28, [this](std::string& buffer) {
text_prompt(nav, _output_file, 28, ENTER_KEYBOARD_MODE_ALPHA, [this](std::string& buffer) {
_output_file = buffer;
button_choose_output_name.set_text(_output_file);
});

View File

@@ -617,6 +617,7 @@ void TextEditorView::show_edit_line() {
edit_line_buffer_,
viewer.col(),
max_edit_length,
ENTER_KEYBOARD_MODE_ALPHA,
[this](std::string& buffer) {
auto range = file_->line_range(viewer.line());
if (!range)

View File

@@ -25,6 +25,7 @@
#include "ui.hpp"
#include "ui_navigation.hpp"
#include "ui_widget.hpp"
#include "ui_textentry.hpp"
namespace ui {
@@ -105,7 +106,7 @@ void bind(TextField& field, T& value, NavigationView& nav, Fn fn = Fn{}) {
// Capture a new string and make the lambda mutable so it can be modified.
field.on_select = [&nav, buf = std::string{}](TextField& tf) mutable {
buf = tf.get_text();
text_prompt(nav, buf, /*max_length*/ 255,
text_prompt(nav, buf, /*max_length*/ 255, ENTER_KEYBOARD_MODE_ALPHA,
[&tf](std::string& str) {
tf.set_text(str);
});

View File

@@ -131,6 +131,7 @@ ADSBCallsignView::ADSBCallsignView(
nav,
callsign,
8,
ENTER_KEYBOARD_MODE_ALPHA,
[this](std::string& s) {
button_callsign.set_text(s);
});

View File

@@ -227,6 +227,7 @@ void HopperView::save_list() {
nav_,
filename_buffer,
64,
ENTER_KEYBOARD_MODE_ALPHA,
[this](std::string& value) {
auto path = hopper_dir / (value + ".PHOP");

View File

@@ -189,6 +189,7 @@ void LCRView::on_button_set_am(NavigationView& nav, int16_t button_id) {
nav,
litteral[button_id],
7,
ENTER_KEYBOARD_MODE_ALPHA,
[this, button_id](std::string& buffer) {
texts[button_id].set(buffer);
});
@@ -257,6 +258,7 @@ LCRView::LCRView(NavigationView& nav) {
nav,
rgsb,
4,
ENTER_KEYBOARD_MODE_ALPHA,
[this](std::string& buffer) {
button_set_rgsb.set_text(buffer);
});

View File

@@ -311,6 +311,7 @@ LGEView::LGEView(NavigationView& nav) {
nav,
nickname,
15,
ENTER_KEYBOARD_MODE_ALPHA,
[this](std::string& buffer) {
button_text.set_text(buffer);
});

View File

@@ -212,6 +212,7 @@ MetronomeTapTempoView::MetronomeTapTempoView(NavigationView& nav, uint16_t bpm)
nav_,
input_buffer,
3,
ENTER_KEYBOARD_MODE_DIGITS,
[this](std::string& buffer) {
if (buffer.empty()) {
return;

View File

@@ -99,7 +99,7 @@ static msg_t loopthread_fn(void* arg) {
}
void MorseView::on_set_text(NavigationView& nav) {
text_prompt(nav, buffer, 28);
text_prompt(nav, buffer, 28, ENTER_KEYBOARD_MODE_ALPHA);
}
void MorseView::focus() {

View File

@@ -210,6 +210,7 @@ OOKEditorAppView::OOKEditorAppView(NavigationView& nav)
nav,
outputFileBuffer,
64,
ENTER_KEYBOARD_MODE_ALPHA,
[this](std::string& buffer) {
on_save_file(buffer);
});
@@ -263,6 +264,7 @@ OOKEditorAppView::OOKEditorAppView(NavigationView& nav)
nav,
ook_data.payload,
100,
ENTER_KEYBOARD_MODE_DIGITS,
[this](std::string& s) {
text_payload.set(s);
draw_waveform();

View File

@@ -83,6 +83,7 @@ OOKBruteView::OOKBruteView(NavigationView& nav)
nav_,
text_input_buffer,
8, // currently longest is princeton
ENTER_KEYBOARD_MODE_DIGITS,
[this](std::string& buffer) {
field_start.set_value(atoi(buffer.c_str()));
validate_start_stop();
@@ -100,6 +101,7 @@ OOKBruteView::OOKBruteView(NavigationView& nav)
nav_,
text_input_buffer,
8, // currently longest is princeton
ENTER_KEYBOARD_MODE_DIGITS,
[this](std::string& buffer) {
field_stop.set_value(atoi(buffer.c_str()));
validate_start_stop();

View File

@@ -122,6 +122,7 @@ bool PlaylistEditorView::on_create_ppl() {
nav_,
current_ppl_name_buffer,
100,
ENTER_KEYBOARD_MODE_ALPHA,
[&](std::string& s) {
current_ppl_name_buffer = s;
@@ -307,6 +308,7 @@ PlaylistItemEditView::PlaylistItemEditView(
nav_,
delay_str,
100,
ENTER_KEYBOARD_MODE_ALPHA,
[&](std::string& s) {
delay_ = atoi(s.c_str());
field_delay.set_value(delay_);

View File

@@ -330,7 +330,7 @@ RemoteAppView::RemoteAppView(
field_title.on_select = [this, &nav](TextField&) {
temp_buffer_ = model_.name;
text_prompt(nav_, temp_buffer_, text_edit_max, [this](std::string& new_name) {
text_prompt(nav_, temp_buffer_, text_edit_max, ENTER_KEYBOARD_MODE_ALPHA, [this](std::string& new_name) {
model_.name = new_name;
refresh_ui();
set_needs_save();
@@ -339,7 +339,7 @@ RemoteAppView::RemoteAppView(
field_filename.on_select = [this, &nav](TextField&) {
temp_buffer_ = remote_path_.stem().string();
text_prompt(nav_, temp_buffer_, text_edit_max, [this](std::string& new_name) {
text_prompt(nav_, temp_buffer_, text_edit_max, ENTER_KEYBOARD_MODE_ALPHA, [this](std::string& new_name) {
rename_remote(new_name);
refresh_ui();
});

View File

@@ -56,7 +56,7 @@ SpectrumInputTextView::~SpectrumInputTextView() {
}
void SpectrumInputTextView::on_set_text(NavigationView& nav) {
text_prompt(nav, buffer, 300);
text_prompt(nav, buffer, 300, ENTER_KEYBOARD_MODE_DIGITS);
}
void SpectrumInputTextView::focus() {

View File

@@ -32,7 +32,8 @@ namespace ui {
AlphanumView::AlphanumView(
NavigationView& nav,
std::string& str,
size_t max_length)
size_t max_length,
uint8_t enter_mode)
: TextEntryView(nav, str, max_length) {
size_t n;
@@ -76,7 +77,7 @@ AlphanumView::AlphanumView(
n++;
}
set_mode(mode);
set_mode(enter_mode);
button_mode.on_select = [this](Button&) {
set_mode(mode + 1);

View File

@@ -37,7 +37,7 @@ namespace ui {
class AlphanumView : public TextEntryView {
public:
AlphanumView(NavigationView& nav, std::string& str, size_t max_length);
AlphanumView(NavigationView& nav, std::string& str, size_t max_length, uint8_t enter_mode);
AlphanumView(const AlphanumView&) = delete;
AlphanumView(AlphanumView&&) = delete;

View File

@@ -31,8 +31,9 @@ void text_prompt(
NavigationView& nav,
std::string& str,
size_t max_length,
uint8_t mode,
std::function<void(std::string&)> on_done) {
text_prompt(nav, str, str.length(), max_length, on_done);
text_prompt(nav, str, str.length(), max_length, mode, on_done);
}
void text_prompt(
@@ -40,8 +41,9 @@ void text_prompt(
std::string& str,
uint32_t cursor_pos,
size_t max_length,
uint8_t mode,
std::function<void(std::string&)> on_done) {
auto te_view = nav.push<AlphanumView>(str, max_length);
auto te_view = nav.push<AlphanumView>(str, max_length, mode);
te_view->set_cursor(cursor_pos);
te_view->on_changed = [on_done](std::string& value) {
if (on_done)

View File

@@ -26,6 +26,11 @@
#include "ui.hpp"
#include "ui_navigation.hpp"
#define ENTER_KEYBOARD_MODE_ALPHA 0
#define ENTER_KEYBOARD_MODE_DIGITS 1
#define ENTER_KEYBOARD_MODE_SYMBOLS 2
#define ENTER_KEYBOARD_MODE_HEX 3
namespace ui {
class TextEntryView : public View {
@@ -62,6 +67,7 @@ void text_prompt(
NavigationView& nav,
std::string& str,
size_t max_length,
uint8_t mode,
std::function<void(std::string&)> on_done = nullptr);
void text_prompt(
@@ -69,6 +75,7 @@ void text_prompt(
std::string& str,
uint32_t cursor_pos,
size_t max_length,
uint8_t mode, // enter mode: 123 abc etc
std::function<void(std::string&)> on_done = nullptr);
} /* namespace ui */

View File

@@ -146,7 +146,7 @@ const NavigationView::AppList NavigationView::appList = {
{"rdstx", "RDS", TX, ui::Color::green(), &bitmap_icon_rds, new ViewFactory<RDSView>()},
{"soundbrd", "Soundbrd", TX, ui::Color::green(), &bitmap_icon_soundboard, new ViewFactory<SoundBoardView>()},
{"touchtune", "TouchTune", TX, ui::Color::green(), &bitmap_icon_touchtunes, new ViewFactory<TouchTunesView>()},
{"signalgen", "Signal Gen", TX, Color::green(), &bitmap_icon_cwgen, new ViewFactory<SigGenView>()},
{"signalgen", "SignalGen", TX, Color::green(), &bitmap_icon_cwgen, new ViewFactory<SigGenView>()},
/* UTILITIES *************************************************************/
{"filemanager", "File Manager", UTILITIES, Color::green(), &bitmap_icon_dir, new ViewFactory<FileManagerView>()},
{"freqman", "Freq. Manager", UTILITIES, Color::green(), &bitmap_icon_freqman, new ViewFactory<FrequencyManagerView>()},

View File

@@ -1136,7 +1136,7 @@ void ButtonWithEncoder::paint(Painter& painter) {
const Style paint_style = {style().font, bg, fg};
painter.draw_rectangle({r.location(), {r.size().width(), 1}}, Theme::getInstance()->fg_light->foreground);
painter.draw_rectangle({r.location(), {r.size().width(), 1}}, Theme::getInstance()->bg_light->background);
painter.draw_rectangle({r.location().x(), r.location().y() + r.size().height() - 1, r.size().width(), 1}, Theme::getInstance()->bg_dark->background);
painter.draw_rectangle({r.location().x() + r.size().width() - 1, r.location().y(), 1, r.size().height()}, Theme::getInstance()->bg_dark->background);