mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-09-04 22:09:03 +00:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1edd3716a1 | |||
| bc1ad5598c | |||
| 8cae998146 | |||
| 9a22a760ad | |||
| 909b00bdae | |||
| 58e731c56e | |||
| 04e77e0ee8 | |||
| 55b93a7044 | |||
| f22046eccc | |||
| dfadd38e32 | |||
| 3cb927c840 |
@@ -13,6 +13,7 @@
|
||||
/sdcard/FREQMAN/BHT*
|
||||
/sdcard/FREQMAN/R.TXT
|
||||
/sdcard/FREQMAN/XXX.TXT
|
||||
/armbin
|
||||
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
|
||||
@@ -36,6 +36,8 @@ using namespace tonekey;
|
||||
|
||||
#include "string_format.hpp"
|
||||
|
||||
#include "freqman.hpp"
|
||||
|
||||
namespace ui {
|
||||
|
||||
/* AMOptionsView *********************************************************/
|
||||
@@ -51,6 +53,7 @@ AMOptionsView::AMOptionsView(
|
||||
&options_config,
|
||||
});
|
||||
|
||||
freqman_set_bandwidth_option( AM_MODULATION , options_config );
|
||||
options_config.set_selected_index(receiver_model.am_configuration());
|
||||
options_config.on_change = [this](size_t n, OptionsField::value_t) {
|
||||
receiver_model.set_am_configuration(n);
|
||||
@@ -72,6 +75,7 @@ NBFMOptionsView::NBFMOptionsView(
|
||||
&field_squelch
|
||||
});
|
||||
|
||||
freqman_set_bandwidth_option( NFM_MODULATION , options_config );
|
||||
options_config.set_selected_index(receiver_model.nbfm_configuration());
|
||||
options_config.on_change = [this](size_t n, OptionsField::value_t) {
|
||||
receiver_model.set_nbfm_configuration(n);
|
||||
@@ -83,6 +87,27 @@ NBFMOptionsView::NBFMOptionsView(
|
||||
};
|
||||
}
|
||||
|
||||
/* WFMOptionsView *******************************************************/
|
||||
|
||||
WFMOptionsView::WFMOptionsView(
|
||||
const Rect parent_rect, const Style* const style
|
||||
) : View { parent_rect }
|
||||
{
|
||||
set_style(style);
|
||||
|
||||
add_children({
|
||||
&label_config,
|
||||
&options_config,
|
||||
});
|
||||
|
||||
freqman_set_bandwidth_option( WFM_MODULATION , options_config );
|
||||
options_config.set_selected_index(receiver_model.wfm_configuration());
|
||||
options_config.on_change = [this](size_t n, OptionsField::value_t) {
|
||||
receiver_model.set_wfm_configuration(n);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/* SPECOptionsView *******************************************************/
|
||||
|
||||
SPECOptionsView::SPECOptionsView(
|
||||
@@ -346,6 +371,7 @@ void AnalogAudioView::on_show_options_modulation() {
|
||||
break;
|
||||
|
||||
case ReceiverModel::Mode::WidebandFMAudio:
|
||||
widget = std::make_unique<WFMOptionsView>(options_view_rect, &style_options_group);
|
||||
waterfall.show_audio_spectrum_view(true);
|
||||
text_ctcss.hidden(true);
|
||||
break;
|
||||
|
||||
@@ -55,11 +55,6 @@ private:
|
||||
{ 3 * 8, 0 * 16 },
|
||||
5,
|
||||
{
|
||||
{ "DSB 9k ", 0 },
|
||||
{ "DSB 6k ", 0 },
|
||||
{ "USB+3k ", 0 },
|
||||
{ "LSB-3k ", 0 },
|
||||
{ "CW ", 0 },
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -77,9 +72,6 @@ private:
|
||||
{ 3 * 8, 0 * 16 },
|
||||
4,
|
||||
{
|
||||
{ " 8k5", 0 },
|
||||
{ "11k ", 0 },
|
||||
{ "16k ", 0 },
|
||||
}
|
||||
};
|
||||
|
||||
@@ -96,6 +88,24 @@ private:
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
class WFMOptionsView : public View {
|
||||
public:
|
||||
WFMOptionsView(const Rect parent_rect, const Style* const style);
|
||||
|
||||
private:
|
||||
Text label_config {
|
||||
{ 0 * 8, 0 * 16, 2 * 8, 1 * 16 },
|
||||
"BW",
|
||||
};
|
||||
OptionsField options_config {
|
||||
{ 3 * 8, 0 * 16 },
|
||||
3,
|
||||
{
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
class AnalogAudioView;
|
||||
|
||||
class SPECOptionsView : public View {
|
||||
|
||||
@@ -64,8 +64,8 @@ private:
|
||||
std::app_settings settings { };
|
||||
std::app_settings::AppSettings app_settings { };
|
||||
|
||||
bool logging { true };
|
||||
bool ignore { true };
|
||||
bool logging { false };
|
||||
bool ignore { false };
|
||||
uint32_t last_address = 0xFFFFFFFF;
|
||||
pocsag::POCSAGState pocsag_state { };
|
||||
|
||||
@@ -91,13 +91,7 @@ private:
|
||||
FrequencyField field_frequency {
|
||||
{ 0 * 8, 0 * 8 },
|
||||
};
|
||||
Checkbox check_log {
|
||||
{ 24 * 8, 21 },
|
||||
3,
|
||||
"LOG",
|
||||
true
|
||||
};
|
||||
NumberField field_volume{
|
||||
NumberField field_volume{
|
||||
{ 28 * 8, 0 * 16 },
|
||||
2,
|
||||
{ 0, 99 },
|
||||
@@ -106,16 +100,22 @@ private:
|
||||
};
|
||||
|
||||
Checkbox check_ignore {
|
||||
{ 1 * 8, 21 },
|
||||
12,
|
||||
"Ignore addr:",
|
||||
true
|
||||
{ 0 * 8, 21 },
|
||||
8,
|
||||
"Ign addr",
|
||||
false
|
||||
};
|
||||
SymField sym_ignore {
|
||||
{ 16 * 8, 21 },
|
||||
{ 13 * 8, 25 },
|
||||
7,
|
||||
SymField::SYMFIELD_DEC
|
||||
};
|
||||
Checkbox check_log {
|
||||
{ 240 - 8 * 8, 21 },
|
||||
3,
|
||||
"LOG",
|
||||
false
|
||||
};
|
||||
|
||||
Console console {
|
||||
{ 0, 3 * 16, 240, 256 }
|
||||
|
||||
@@ -60,9 +60,9 @@ AFSKRxView::AFSKRxView(NavigationView& nav) {
|
||||
&field_lna,
|
||||
&field_vga,
|
||||
&field_frequency,
|
||||
&check_log,
|
||||
&text_debug,
|
||||
&button_modem_setup,
|
||||
&record_view,
|
||||
&console
|
||||
});
|
||||
|
||||
@@ -74,13 +74,6 @@ AFSKRxView::AFSKRxView(NavigationView& nav) {
|
||||
field_rf_amp.set_value(app_settings.rx_amp);
|
||||
}
|
||||
|
||||
|
||||
// DEBUG
|
||||
record_view.on_error = [&nav](std::string message) {
|
||||
nav.display_modal("Error", message);
|
||||
};
|
||||
record_view.set_sampling_rate(24000);
|
||||
|
||||
// Auto-configure modem for LCR RX (will be removed later)
|
||||
update_freq(467225500); // 462713300
|
||||
auto def_bell202 = &modem_defs[0];
|
||||
@@ -105,6 +98,11 @@ AFSKRxView::AFSKRxView(NavigationView& nav) {
|
||||
};
|
||||
};
|
||||
|
||||
check_log.set_value(logging);
|
||||
check_log.on_select = [this](Checkbox&, bool v) {
|
||||
logging = v;
|
||||
};
|
||||
|
||||
button_modem_setup.on_select = [&nav](Button&) {
|
||||
nav.push<ModemSetupView>();
|
||||
};
|
||||
@@ -153,22 +151,23 @@ void AFSKRxView::on_data(uint32_t value, bool is_data) {
|
||||
|
||||
console.write(str_console);
|
||||
|
||||
if (logger) str_log += str_byte;
|
||||
if (logger && logging) str_log += str_byte;
|
||||
|
||||
if ((value != 0x7F) && (prev_value == 0x7F)) {
|
||||
// Message split
|
||||
console.writeln("");
|
||||
console_color++;
|
||||
|
||||
if (logger) {
|
||||
if (logger && logging) {
|
||||
logger->log_raw_data(str_log);
|
||||
str_log = "";
|
||||
}
|
||||
}
|
||||
prev_value = value;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Baudrate estimation
|
||||
text_debug.set("~" + to_string_dec_uint(value));
|
||||
text_debug.set("Baudrate estimation: ~" + to_string_dec_uint(value));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ private:
|
||||
uint8_t console_color { 0 };
|
||||
uint32_t prev_value { 0 };
|
||||
std::string str_log { "" };
|
||||
bool logging { false };
|
||||
|
||||
RFAmpField field_rf_amp {
|
||||
{ 13 * 8, 0 * 16 }
|
||||
@@ -85,23 +86,23 @@ private:
|
||||
{ 0 * 8, 0 * 16 },
|
||||
};
|
||||
|
||||
Text text_debug {
|
||||
{ 0 * 8, 1 * 16, 10 * 8, 16 },
|
||||
Checkbox check_log {
|
||||
{ 0 * 8, 1 * 16 },
|
||||
3,
|
||||
"LOG",
|
||||
false
|
||||
};
|
||||
|
||||
Text text_debug {
|
||||
{ 0 * 8, 12 + 2 * 16, 240, 16 },
|
||||
"DEBUG"
|
||||
};
|
||||
|
||||
|
||||
Button button_modem_setup {
|
||||
{ 12 * 8, 1 * 16, 96, 24 },
|
||||
{ 240 - 12 * 8, 1 * 16, 96, 24 },
|
||||
"Modem setup"
|
||||
};
|
||||
|
||||
// DEBUG
|
||||
RecordView record_view {
|
||||
{ 0 * 8, 3 * 16, 30 * 8, 1 * 16 },
|
||||
u"AFS_????", RecordView::FileType::WAV, 4096, 4
|
||||
};
|
||||
|
||||
Console console {
|
||||
{ 0, 4 * 16, 240, 240 }
|
||||
};
|
||||
|
||||
@@ -54,9 +54,7 @@ BTLERxView::BTLERxView(NavigationView& nav) {
|
||||
&field_lna,
|
||||
&field_vga,
|
||||
&field_frequency,
|
||||
&text_debug,
|
||||
&button_modem_setup,
|
||||
&record_view,
|
||||
&console
|
||||
});
|
||||
|
||||
@@ -68,13 +66,6 @@ BTLERxView::BTLERxView(NavigationView& nav) {
|
||||
field_rf_amp.set_value(app_settings.rx_amp);
|
||||
}
|
||||
|
||||
|
||||
// DEBUG
|
||||
record_view.on_error = [&nav](std::string message) {
|
||||
nav.display_modal("Error", message);
|
||||
};
|
||||
record_view.set_sampling_rate(24000);
|
||||
|
||||
// Auto-configure modem for LCR RX (will be removed later)
|
||||
update_freq(2426000000);
|
||||
auto def_bell202 = &modem_defs[0];
|
||||
@@ -103,7 +94,6 @@ BTLERxView::BTLERxView(NavigationView& nav) {
|
||||
nav.push<ModemSetupView>();
|
||||
};
|
||||
|
||||
|
||||
// Auto-configure modem for LCR RX (will be removed later)
|
||||
baseband::set_btle(persistent_memory::modem_baudrate(), 8, 0, false);
|
||||
|
||||
|
||||
@@ -53,7 +53,6 @@ private:
|
||||
|
||||
uint8_t console_color { 0 };
|
||||
uint32_t prev_value { 0 };
|
||||
std::string str_log { "" };
|
||||
|
||||
RFAmpField field_rf_amp {
|
||||
{ 13 * 8, 0 * 16 }
|
||||
@@ -75,23 +74,11 @@ private:
|
||||
{ 0 * 8, 0 * 16 },
|
||||
};
|
||||
|
||||
Text text_debug {
|
||||
{ 0 * 8, 1 * 16, 10 * 8, 16 },
|
||||
"DEBUG"
|
||||
};
|
||||
|
||||
|
||||
Button button_modem_setup {
|
||||
{ 12 * 8, 1 * 16, 96, 24 },
|
||||
{ 240 - 12 * 8, 1 * 16, 96, 24 },
|
||||
"Modem setup"
|
||||
};
|
||||
|
||||
// DEBUG
|
||||
RecordView record_view {
|
||||
{ 0 * 8, 3 * 16, 30 * 8, 1 * 16 },
|
||||
u"AFS_????", RecordView::FileType::WAV, 4096, 4
|
||||
};
|
||||
|
||||
Console console {
|
||||
{ 0, 4 * 16, 240, 240 }
|
||||
};
|
||||
|
||||
@@ -192,8 +192,8 @@ const fileman_entry& FileManBaseView::get_selected_entry() const {
|
||||
FileManBaseView::FileManBaseView(
|
||||
NavigationView& nav,
|
||||
std::string filter
|
||||
) : nav_ (nav),
|
||||
extension_filter { filter }
|
||||
) : nav_{ nav },
|
||||
extension_filter{ filter }
|
||||
{
|
||||
add_children({
|
||||
&labels,
|
||||
@@ -206,7 +206,7 @@ FileManBaseView::FileManBaseView(
|
||||
};
|
||||
|
||||
if (!sdcIsCardInserted(&SDCD1)) {
|
||||
empty_root = true;
|
||||
empty_ = EmptyReason::NoSDC;
|
||||
text_current.set("NO SD CARD!");
|
||||
return;
|
||||
}
|
||||
@@ -214,7 +214,7 @@ FileManBaseView::FileManBaseView(
|
||||
load_directory_contents(current_path);
|
||||
|
||||
if (!entry_list.size()) {
|
||||
empty_root = true;
|
||||
empty_ = EmptyReason::NoFiles;
|
||||
text_current.set("EMPTY SD CARD!");
|
||||
} else {
|
||||
menu_view.on_left = [this]() {
|
||||
@@ -224,7 +224,7 @@ FileManBaseView::FileManBaseView(
|
||||
}
|
||||
|
||||
void FileManBaseView::focus() {
|
||||
if (empty_root) {
|
||||
if (empty_ != EmptyReason::NotEmpty) {
|
||||
button_exit.focus();
|
||||
} else {
|
||||
menu_view.focus();
|
||||
@@ -310,34 +310,8 @@ const FileManBaseView::file_assoc_t& FileManBaseView::get_assoc(
|
||||
return file_types[index];
|
||||
}
|
||||
|
||||
/*void FileSaveView::on_save_name() {
|
||||
text_prompt(nav_, &filename_buffer, 8, [this](std::string * buffer) {
|
||||
nav_.pop();
|
||||
});
|
||||
}
|
||||
FileSaveView::FileSaveView(
|
||||
NavigationView& nav
|
||||
) : FileManBaseView(nav)
|
||||
{
|
||||
name_buffer.clear();
|
||||
|
||||
add_children({
|
||||
&text_save,
|
||||
&button_save_name,
|
||||
&live_timestamp
|
||||
});
|
||||
|
||||
button_save_name.on_select = [this, &nav](Button&) {
|
||||
on_save_name();
|
||||
};
|
||||
}*/
|
||||
|
||||
/* FileLoadView **************************************************************/
|
||||
|
||||
void FileLoadView::refresh_widgets(const bool) {
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
FileLoadView::FileLoadView(
|
||||
NavigationView& nav,
|
||||
std::string filter
|
||||
@@ -367,6 +341,68 @@ FileLoadView::FileLoadView(
|
||||
};
|
||||
}
|
||||
|
||||
void FileLoadView::refresh_widgets(const bool) {
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
/* FileSaveView **************************************************************/
|
||||
/*
|
||||
FileSaveView::FileSaveView(
|
||||
NavigationView& nav,
|
||||
const fs::path& path,
|
||||
const fs::path& file
|
||||
) : nav_{ nav },
|
||||
path_{ path },
|
||||
file_{ file }
|
||||
{
|
||||
add_children({
|
||||
&labels,
|
||||
&text_path,
|
||||
&button_edit_path,
|
||||
&text_name,
|
||||
&button_edit_name,
|
||||
&button_save,
|
||||
&button_cancel,
|
||||
});
|
||||
|
||||
button_edit_path.on_select = [this](Button&) {
|
||||
buffer_ = path_.string();
|
||||
text_prompt(nav_, buffer_, max_filename_length,
|
||||
[this](std::string&) {
|
||||
path_ = buffer_;
|
||||
refresh_widgets();
|
||||
});
|
||||
};
|
||||
|
||||
button_edit_name.on_select = [this](Button&) {
|
||||
buffer_ = file_.string();
|
||||
text_prompt(nav_, buffer_, max_filename_length,
|
||||
[this](std::string&) {
|
||||
file_ = buffer_;
|
||||
refresh_widgets();
|
||||
});
|
||||
};
|
||||
|
||||
button_save.on_select = [this](Button&) {
|
||||
if (on_save)
|
||||
on_save(path_ / file_);
|
||||
else
|
||||
nav_.pop();
|
||||
};
|
||||
|
||||
button_cancel.on_select = [this](Button&) {
|
||||
nav_.pop();
|
||||
};
|
||||
|
||||
refresh_widgets();
|
||||
}
|
||||
|
||||
void FileSaveView::refresh_widgets() {
|
||||
text_path.set(truncate(path_, 30));
|
||||
text_name.set(truncate(file_, 30));
|
||||
set_dirty();
|
||||
}
|
||||
*/
|
||||
/* FileManagerView ***********************************************************/
|
||||
|
||||
void FileManagerView::on_rename() {
|
||||
@@ -429,6 +465,30 @@ void FileManagerView::on_new_dir() {
|
||||
});
|
||||
}
|
||||
|
||||
void FileManagerView::on_paste() {
|
||||
auto stem = copy_path.stem();
|
||||
auto ext = copy_path.extension();
|
||||
auto serial = 1;
|
||||
fs::path new_path = copy_path.filename();
|
||||
|
||||
// Create a unique name.
|
||||
while (fs::file_exists(current_path / new_path)) {
|
||||
new_path = stem;
|
||||
new_path += fs::path{ u"_" };
|
||||
new_path += to_string_dec_int(serial++);
|
||||
new_path += ext;
|
||||
}
|
||||
|
||||
// TODO: handle partner file. Need to fix nav stack first.
|
||||
auto result = copy_file(copy_path, current_path / new_path);
|
||||
if (result.code() != FR_OK)
|
||||
nav_.display_modal("Paste Failed", result.what());
|
||||
|
||||
copy_path = fs::path{ };
|
||||
menu_view.focus();
|
||||
reload_current();
|
||||
}
|
||||
|
||||
bool FileManagerView::selected_is_valid() const {
|
||||
return !entry_list.empty() &&
|
||||
get_selected_entry().path != parent_dir_path;
|
||||
@@ -438,62 +498,79 @@ void FileManagerView::refresh_widgets(const bool v) {
|
||||
button_rename.hidden(v);
|
||||
button_delete.hidden(v);
|
||||
button_new_dir.hidden(v);
|
||||
button_copy.hidden(v);
|
||||
button_paste.hidden(v);
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
FileManagerView::~FileManagerView() {
|
||||
}
|
||||
|
||||
FileManagerView::FileManagerView(
|
||||
NavigationView& nav
|
||||
) : FileManBaseView(nav, "")
|
||||
{
|
||||
if (!empty_root) {
|
||||
on_refresh_widgets = [this](bool v) {
|
||||
refresh_widgets(v);
|
||||
};
|
||||
|
||||
add_children({
|
||||
&menu_view,
|
||||
&labels,
|
||||
&text_date,
|
||||
&button_rename,
|
||||
&button_delete,
|
||||
&button_new_dir,
|
||||
});
|
||||
|
||||
menu_view.on_highlight = [this]() {
|
||||
// TODO: enable/disable buttons.
|
||||
if (selected_is_valid())
|
||||
text_date.set(to_string_FAT_timestamp(file_created_date(get_selected_full_path())));
|
||||
else
|
||||
text_date.set("");
|
||||
};
|
||||
|
||||
refresh_list();
|
||||
// Don't bother with the UI in the case of no SDC.
|
||||
if (empty_ == EmptyReason::NoSDC)
|
||||
return;
|
||||
|
||||
on_refresh_widgets = [this](bool v) {
|
||||
refresh_widgets(v);
|
||||
};
|
||||
|
||||
on_select_entry = [this](KeyEvent key) {
|
||||
if (key == KeyEvent::Select && get_selected_entry().is_directory) {
|
||||
push_dir(get_selected_entry().path);
|
||||
} else {
|
||||
button_rename.focus();
|
||||
}
|
||||
};
|
||||
|
||||
button_rename.on_select = [this](Button&) {
|
||||
if (selected_is_valid())
|
||||
on_rename();
|
||||
};
|
||||
add_children({
|
||||
&menu_view,
|
||||
&labels,
|
||||
&text_date,
|
||||
&button_rename,
|
||||
&button_delete,
|
||||
&button_new_dir,
|
||||
&button_copy,
|
||||
&button_paste
|
||||
});
|
||||
|
||||
menu_view.on_highlight = [this]() {
|
||||
// TODO: enable/disable buttons.
|
||||
if (selected_is_valid())
|
||||
text_date.set(to_string_FAT_timestamp(file_created_date(get_selected_full_path())));
|
||||
else
|
||||
text_date.set("");
|
||||
};
|
||||
|
||||
refresh_list();
|
||||
|
||||
button_delete.on_select = [this](Button&) {
|
||||
if (selected_is_valid())
|
||||
on_delete();
|
||||
};
|
||||
on_select_entry = [this](KeyEvent key) {
|
||||
if (key == KeyEvent::Select && get_selected_entry().is_directory) {
|
||||
push_dir(get_selected_entry().path);
|
||||
} else {
|
||||
button_rename.focus();
|
||||
}
|
||||
};
|
||||
|
||||
button_rename.on_select = [this](Button&) {
|
||||
if (selected_is_valid())
|
||||
on_rename();
|
||||
};
|
||||
|
||||
button_new_dir.on_select = [this](Button&) {
|
||||
on_new_dir();
|
||||
};
|
||||
}
|
||||
button_delete.on_select = [this](Button&) {
|
||||
if (selected_is_valid())
|
||||
on_delete();
|
||||
};
|
||||
|
||||
button_new_dir.on_select = [this](Button&) {
|
||||
on_new_dir();
|
||||
};
|
||||
|
||||
button_copy.on_select = [this](Button&) {
|
||||
if (selected_is_valid() && !get_selected_entry().is_directory)
|
||||
copy_path = get_selected_full_path();
|
||||
else
|
||||
nav_.display_modal("Copy", "Can't copy that.");
|
||||
};
|
||||
|
||||
button_paste.on_select = [this](Button&) {
|
||||
if (!copy_path.empty())
|
||||
on_paste();
|
||||
else
|
||||
nav_.display_modal("Paste", "Copy a file first.");
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,6 +36,12 @@ struct fileman_entry {
|
||||
bool is_directory { };
|
||||
};
|
||||
|
||||
enum class EmptyReason : uint8_t {
|
||||
NotEmpty,
|
||||
NoFiles,
|
||||
NoSDC
|
||||
};
|
||||
|
||||
class FileManBaseView : public View {
|
||||
public:
|
||||
FileManBaseView(
|
||||
@@ -43,11 +49,13 @@ public:
|
||||
std::string filter
|
||||
);
|
||||
|
||||
virtual ~FileManBaseView() { }
|
||||
|
||||
void focus() override;
|
||||
std::string title() const override { return "Fileman"; };
|
||||
|
||||
protected:
|
||||
static constexpr size_t max_filename_length = 50;
|
||||
static constexpr size_t max_filename_length = 64;
|
||||
|
||||
struct file_assoc_t {
|
||||
std::filesystem::path extension;
|
||||
@@ -65,7 +73,6 @@ protected:
|
||||
{ u"", &bitmap_icon_file, ui::Color::light_grey() } // NB: Must be last.
|
||||
};
|
||||
|
||||
|
||||
std::filesystem::path get_selected_full_path() const;
|
||||
const fileman_entry& get_selected_entry() const;
|
||||
|
||||
@@ -78,7 +85,7 @@ protected:
|
||||
|
||||
NavigationView& nav_;
|
||||
|
||||
bool empty_root { false };
|
||||
EmptyReason empty_ { EmptyReason::NotEmpty };
|
||||
std::function<void(KeyEvent)> on_select_entry { nullptr };
|
||||
std::function<void(bool)> on_refresh_widgets { nullptr };
|
||||
|
||||
@@ -104,57 +111,96 @@ protected:
|
||||
};
|
||||
|
||||
Button button_exit {
|
||||
{ 16 * 8, 34 * 8, 14 * 8, 32 },
|
||||
{ 21 * 8, 34 * 8, 9 * 8, 32 },
|
||||
"Exit"
|
||||
};
|
||||
};
|
||||
|
||||
/*class FileSaveView : public FileManBaseView {
|
||||
public:
|
||||
FileSaveView(NavigationView& nav);
|
||||
~FileSaveView();
|
||||
|
||||
private:
|
||||
std::string name_buffer { };
|
||||
|
||||
void on_save_name();
|
||||
|
||||
Text text_save {
|
||||
{ 4 * 8, 15 * 8, 8 * 8, 16 },
|
||||
"Save as:",
|
||||
};
|
||||
Button button_save_name {
|
||||
{ 4 * 8, 18 * 8, 12 * 8, 32 },
|
||||
"Name (set)"
|
||||
};
|
||||
LiveDateTime live_timestamp {
|
||||
{ 17 * 8, 24 * 8, 11 * 8, 16 }
|
||||
};
|
||||
};*/
|
||||
|
||||
class FileLoadView : public FileManBaseView {
|
||||
public:
|
||||
std::function<void(std::filesystem::path)> on_changed { };
|
||||
|
||||
FileLoadView(NavigationView& nav, std::string filter);
|
||||
virtual ~FileLoadView() { }
|
||||
|
||||
private:
|
||||
void refresh_widgets(const bool v);
|
||||
};
|
||||
|
||||
/*
|
||||
// It would be nice to be able to launch FileLoadView
|
||||
// but it will OOM if launched from within FileManager.
|
||||
class FileSaveView : public View {
|
||||
public:
|
||||
FileSaveView(
|
||||
NavigationView& nav,
|
||||
const std::filesystem::path& path,
|
||||
const std::filesystem::path& file);
|
||||
|
||||
std::function<void(std::filesystem::path)> on_save { };
|
||||
|
||||
private:
|
||||
static constexpr size_t max_filename_length = 64;
|
||||
|
||||
void refresh_widgets();
|
||||
|
||||
NavigationView& nav_;
|
||||
std::filesystem::path path_;
|
||||
std::filesystem::path file_;
|
||||
std::string buffer_ { };
|
||||
|
||||
Labels labels {
|
||||
{ { 0 * 8, 1 * 16 }, "Path:", Color::light_grey() },
|
||||
{ { 0 * 8, 6 * 16 }, "Filename:", Color::light_grey() },
|
||||
};
|
||||
|
||||
Text text_path {
|
||||
{ 0 * 8, 2 * 16, 30 * 8, 16 },
|
||||
"",
|
||||
};
|
||||
|
||||
Button button_edit_path {
|
||||
{ 18 * 8, 3 * 16, 11 * 8, 32 },
|
||||
"Edit Path"
|
||||
};
|
||||
|
||||
Text text_name {
|
||||
{ 0 * 8, 7 * 16, 30 * 8, 16 },
|
||||
"",
|
||||
};
|
||||
|
||||
Button button_edit_name {
|
||||
{ 18 * 8, 8 * 16, 11 * 8, 32 },
|
||||
"Edit Name"
|
||||
};
|
||||
|
||||
Button button_save {
|
||||
{ 10 * 8, 16 * 16, 9 * 8, 32 },
|
||||
"Save"
|
||||
};
|
||||
|
||||
Button button_cancel {
|
||||
{ 20 * 8, 16 * 16, 9 * 8, 32 },
|
||||
"Cancel"
|
||||
};
|
||||
};
|
||||
*/
|
||||
|
||||
class FileManagerView : public FileManBaseView {
|
||||
public:
|
||||
FileManagerView(NavigationView& nav);
|
||||
~FileManagerView();
|
||||
virtual ~FileManagerView() { }
|
||||
|
||||
private:
|
||||
// Passed by ref to other views needing lifetime extension.
|
||||
std::string name_buffer { };
|
||||
std::filesystem::path copy_path { };
|
||||
|
||||
void refresh_widgets(const bool v);
|
||||
void on_rename();
|
||||
void on_delete();
|
||||
void on_new_dir();
|
||||
void on_paste();
|
||||
|
||||
// True if the selected entry is a real file item.
|
||||
bool selected_is_valid() const;
|
||||
@@ -169,19 +215,29 @@ private:
|
||||
};
|
||||
|
||||
Button button_rename {
|
||||
{ 0 * 8, 29 * 8, 14 * 8, 32 },
|
||||
{ 0 * 8, 29 * 8, 9 * 8, 32 },
|
||||
"Rename"
|
||||
};
|
||||
|
||||
Button button_delete {
|
||||
{ 16 * 8, 29 * 8, 14 * 8, 32 },
|
||||
{ 21 * 4, 29 * 8, 9 * 8, 32 },
|
||||
"Delete"
|
||||
};
|
||||
|
||||
Button button_new_dir {
|
||||
{ 0 * 8, 34 * 8, 14 * 8, 32 },
|
||||
{ 21 * 8, 29 * 8, 9 * 8, 32 },
|
||||
"New Dir"
|
||||
};
|
||||
|
||||
Button button_copy {
|
||||
{ 0 * 8, 34 * 8, 9 * 8, 32 },
|
||||
"Copy"
|
||||
};
|
||||
|
||||
Button button_paste {
|
||||
{ 21 * 4, 34 * 8, 9 * 8, 32 },
|
||||
"Paste"
|
||||
};
|
||||
};
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
@@ -54,9 +54,7 @@ NRFRxView::NRFRxView(NavigationView& nav) {
|
||||
&field_lna,
|
||||
&field_vga,
|
||||
&field_frequency,
|
||||
&text_debug,
|
||||
&button_modem_setup,
|
||||
&record_view,
|
||||
&console
|
||||
});
|
||||
|
||||
@@ -68,12 +66,6 @@ NRFRxView::NRFRxView(NavigationView& nav) {
|
||||
field_rf_amp.set_value(app_settings.rx_amp);
|
||||
}
|
||||
|
||||
// DEBUG
|
||||
record_view.on_error = [&nav](std::string message) {
|
||||
nav.display_modal("Error", message);
|
||||
};
|
||||
record_view.set_sampling_rate(24000);
|
||||
|
||||
// Auto-configure modem for LCR RX (will be removed later)
|
||||
update_freq(2480000000);
|
||||
auto def_bell202 = &modem_defs[0];
|
||||
|
||||
@@ -52,7 +52,6 @@ private:
|
||||
|
||||
uint8_t console_color { 0 };
|
||||
uint32_t prev_value { 0 };
|
||||
std::string str_log { "" };
|
||||
|
||||
RFAmpField field_rf_amp {
|
||||
{ 13 * 8, 0 * 16 }
|
||||
@@ -74,23 +73,11 @@ private:
|
||||
{ 0 * 8, 0 * 16 },
|
||||
};
|
||||
|
||||
Text text_debug {
|
||||
{ 0 * 8, 1 * 16, 10 * 8, 16 },
|
||||
"DEBUG"
|
||||
};
|
||||
|
||||
|
||||
Button button_modem_setup {
|
||||
{ 12 * 8, 1 * 16, 96, 24 },
|
||||
{ 240 - 12 * 8, 1 * 16, 96, 24 },
|
||||
"Modem setup"
|
||||
};
|
||||
|
||||
// DEBUG
|
||||
RecordView record_view {
|
||||
{ 0 * 8, 3 * 16, 30 * 8, 1 * 16 },
|
||||
u"AFS_????", RecordView::FileType::WAV, 4096, 4
|
||||
};
|
||||
|
||||
Console console {
|
||||
{ 0, 4 * 16, 240, 240 }
|
||||
};
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
|
||||
void focus() override;
|
||||
|
||||
std::string title() const override { return "Flash Utility"; };
|
||||
std::string title() const override { return "SD over USB"; };
|
||||
|
||||
private:
|
||||
NavigationView& nav_;
|
||||
|
||||
@@ -73,8 +73,8 @@ void NBFMConfig::apply(const uint8_t squelch_level) const {
|
||||
|
||||
void WFMConfig::apply() const {
|
||||
const WFMConfigureMessage message {
|
||||
taps_200k_wfm_decim_0,
|
||||
taps_200k_wfm_decim_1,
|
||||
decim_0, // taps_200k_decim_0 , taps_180k_wfm_decim_0, taps_40k_wfm_decim_0
|
||||
decim_1, // taps_200k_decim_1 or taps_180k_wfm_decim_1, taps_40k_wfm_decim_1
|
||||
taps_64_lp_156_198,
|
||||
75000,
|
||||
audio_48k_hpf_30hz_config,
|
||||
@@ -84,6 +84,7 @@ void WFMConfig::apply() const {
|
||||
audio::set_rate(audio::Rate::Hz_48000);
|
||||
}
|
||||
|
||||
|
||||
void set_tone(const uint32_t index, const uint32_t delta, const uint32_t duration) {
|
||||
shared_memory.bb_data.tones_data.tone_defs[index].delta = delta;
|
||||
shared_memory.bb_data.tones_data.tone_defs[index].duration = duration;
|
||||
|
||||
@@ -53,6 +53,9 @@ struct NBFMConfig {
|
||||
};
|
||||
|
||||
struct WFMConfig {
|
||||
const fir_taps_real<24> decim_0; // To handle both WFM filters , 200k and 40K for NOAA APT
|
||||
const fir_taps_real<16> decim_1;
|
||||
|
||||
void apply() const;
|
||||
};
|
||||
|
||||
|
||||
@@ -205,6 +205,35 @@ uint32_t rename_file(const std::filesystem::path& file_path, const std::filesyst
|
||||
return f_rename(reinterpret_cast<const TCHAR*>(file_path.c_str()), reinterpret_cast<const TCHAR*>(new_name.c_str()));
|
||||
}
|
||||
|
||||
std::filesystem::filesystem_error copy_file(
|
||||
const std::filesystem::path& file_path,
|
||||
const std::filesystem::path& dest_path)
|
||||
{
|
||||
File src;
|
||||
File dst;
|
||||
constexpr size_t buffer_size = 512;
|
||||
uint8_t buffer[buffer_size];
|
||||
|
||||
auto error = src.open(file_path);
|
||||
if (error.is_valid()) return error.value();
|
||||
|
||||
error = dst.create(dest_path);
|
||||
if (error.is_valid()) return error.value();
|
||||
|
||||
while (true) {
|
||||
auto result = src.read(buffer, buffer_size);
|
||||
if (result.is_error()) return result.error();
|
||||
|
||||
result = dst.write(buffer, result.value());
|
||||
if (result.is_error()) return result.error();
|
||||
|
||||
if (result.value() < buffer_size)
|
||||
break;
|
||||
}
|
||||
|
||||
return { };
|
||||
}
|
||||
|
||||
FATTimestamp file_created_date(const std::filesystem::path& file_path) {
|
||||
FILINFO filinfo;
|
||||
|
||||
|
||||
@@ -254,6 +254,7 @@ struct FATTimestamp {
|
||||
|
||||
uint32_t delete_file(const std::filesystem::path& file_path);
|
||||
uint32_t rename_file(const std::filesystem::path& file_path, const std::filesystem::path& new_name);
|
||||
std::filesystem::filesystem_error copy_file(const std::filesystem::path& file_path, const std::filesystem::path& dest_path);
|
||||
FATTimestamp file_created_date(const std::filesystem::path& file_path);
|
||||
uint32_t make_new_directory(const std::filesystem::path& dir_path);
|
||||
|
||||
|
||||
@@ -47,44 +47,46 @@ options_t freqman_entry_bandwidths[ 4 ] = {
|
||||
},
|
||||
{ //WFM
|
||||
{ "200k" , 0 },
|
||||
{ "180k" , 1 },
|
||||
{ "40k" , 2 },
|
||||
}
|
||||
};
|
||||
|
||||
options_t freqman_entry_steps = {
|
||||
{ "0.1KHz " , 100 },
|
||||
{ "1KHz " , 1000 },
|
||||
{ "5KHz (SA AM)" , 5000 },
|
||||
{ "6.25KHz(NFM)" , 6250 },
|
||||
{ "8.33KHz(AIR)" , 8330 },
|
||||
{ "9KHz (EU AM)" , 9000 },
|
||||
{ "10KHz(US AM)" , 10000 },
|
||||
{ "12.5KHz(NFM)" , 12500 },
|
||||
{ "15KHz (HFM)" , 15000 },
|
||||
{ "25KHz (N1)" , 25000 },
|
||||
{ "30KHz (OIRT)" , 30000 },
|
||||
{ "50KHz (FM1)" , 50000 },
|
||||
{ "100KHz (FM2)" , 100000 },
|
||||
{ "250KHz (N2)" , 250000 },
|
||||
{ "500KHz (WFM)" , 500000 },
|
||||
{ "0.1kHz " , 100 },
|
||||
{ "1kHz " , 1000 },
|
||||
{ "5kHz (SA AM)" , 5000 },
|
||||
{ "6.25kHz(NFM)" , 6250 },
|
||||
{ "8.33kHz(AIR)" , 8330 },
|
||||
{ "9kHz (EU AM)" , 9000 },
|
||||
{ "10kHz(US AM)" , 10000 },
|
||||
{ "12.5kHz(NFM)" , 12500 },
|
||||
{ "15kHz (HFM)" , 15000 },
|
||||
{ "25kHz (N1)" , 25000 },
|
||||
{ "30kHz (OIRT)" , 30000 },
|
||||
{ "50kHz (FM1)" , 50000 },
|
||||
{ "100kHz (FM2)" , 100000 },
|
||||
{ "250kHz (N2)" , 250000 },
|
||||
{ "500kHz (WFM)" , 500000 },
|
||||
{ "1MHz " , 1000000 }
|
||||
};
|
||||
|
||||
options_t freqman_entry_steps_short = {
|
||||
{ "0.1KHz" , 100 },
|
||||
{ "1KHz" , 1000 },
|
||||
{ "5KHz" , 5000 },
|
||||
{ "6.25KHz" , 6250 },
|
||||
{ "8.33KHz" , 8330 },
|
||||
{ "9KHz" , 9000 },
|
||||
{ "10KHz" , 10000 },
|
||||
{ "12.5KHz" , 12500 },
|
||||
{ "15KHz" , 15000 },
|
||||
{ "25KHz" , 25000 },
|
||||
{ "30KHz" , 30000 },
|
||||
{ "50KHz" , 50000 },
|
||||
{ "100KHz" , 100000 },
|
||||
{ "250KHz" , 250000 },
|
||||
{ "500KHz" , 500000 },
|
||||
{ "0.1kHz" , 100 },
|
||||
{ "1kHz" , 1000 },
|
||||
{ "5kHz" , 5000 },
|
||||
{ "6.25kHz" , 6250 },
|
||||
{ "8.33kHz" , 8330 },
|
||||
{ "9kHz" , 9000 },
|
||||
{ "10kHz" , 10000 },
|
||||
{ "12.5kHz" , 12500 },
|
||||
{ "15kHz" , 15000 },
|
||||
{ "25kHz" , 25000 },
|
||||
{ "30kHz" , 30000 },
|
||||
{ "50kHz" , 50000 },
|
||||
{ "100kHz" , 100000 },
|
||||
{ "250kHz" , 250000 },
|
||||
{ "500kHz" , 500000 },
|
||||
{ "1MHz" , 1000000 }
|
||||
};
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ struct freqman_entry {
|
||||
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,...
|
||||
freqman_index_t step { }; // 5khz (SA AM,...
|
||||
tone_index tone { }; // 0XZ, 11 1ZB,...
|
||||
};
|
||||
|
||||
|
||||
@@ -52,8 +52,10 @@ static constexpr std::array<baseband::NBFMConfig, 3> nbfm_configs { {
|
||||
{ taps_16k0_decim_0, taps_16k0_decim_1, taps_16k0_channel, 5000 },
|
||||
} };
|
||||
|
||||
static constexpr std::array<baseband::WFMConfig, 1> wfm_configs { {
|
||||
{ },
|
||||
static constexpr std::array<baseband::WFMConfig, 3> wfm_configs { {
|
||||
{taps_200k_wfm_decim_0, taps_200k_wfm_decim_1 },
|
||||
{taps_180k_wfm_decim_0, taps_180k_wfm_decim_1 },
|
||||
{taps_40k_wfm_decim_0, taps_40k_wfm_decim_1 },
|
||||
} };
|
||||
|
||||
} /* namespace */
|
||||
|
||||
@@ -87,7 +87,22 @@ bool FrequencyField::on_key(const ui::KeyEvent event) {
|
||||
}
|
||||
|
||||
bool FrequencyField::on_encoder(const EncoderEvent delta) {
|
||||
set_value(value() + (delta * step));
|
||||
if (step == 0) { // 'Auto' mode.'
|
||||
auto ms = RTT2MS(halGetCounterValue());
|
||||
auto delta_ms = last_ms_ <= ms ? ms - last_ms_ : ms;
|
||||
last_ms_ = ms;
|
||||
|
||||
// The goal is to map 'scale' to a range of about 10 to 10M.
|
||||
// The faster the encoder is rotated, the larger the step.
|
||||
// Linear doesn't feel right. Hyperbolic felt better.
|
||||
// To get these magic numbers, I graphed the function until the
|
||||
// curve shape seemed about right then tested on device.
|
||||
delta_ms = std::min(145ull, delta_ms) + 5; // Prevent DIV/0
|
||||
int64_t scale = 200'000'000 / (0.001'55 * pow(delta_ms, 5.45)) + 8;
|
||||
set_value(value() + (delta * scale));
|
||||
} else {
|
||||
set_value(value() + (delta * step));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ private:
|
||||
const range_t range;
|
||||
rf::Frequency value_ { 0 };
|
||||
rf::Frequency step { 25000 };
|
||||
uint64_t last_ms_ { 0 };
|
||||
|
||||
rf::Frequency clamp_value(rf::Frequency value);
|
||||
};
|
||||
@@ -247,6 +248,7 @@ public:
|
||||
parent_pos,
|
||||
5,
|
||||
{
|
||||
{ " Auto", 0 }, /* Faster == larger step. */
|
||||
{ " 10", 10 }, /* Fine tuning SSB voice pitch,in HF and QO-100 sat #669 */
|
||||
{ " 50", 50 }, /* added 50Hz/10Hz,but we do not increase GUI digit decimal */
|
||||
{ " 100", 100 },
|
||||
|
||||
@@ -61,137 +61,6 @@ void text_prompt(
|
||||
}*/
|
||||
}
|
||||
|
||||
/* TextField ***********************************************************/
|
||||
|
||||
TextField::TextField(
|
||||
std::string& str,
|
||||
size_t max_length,
|
||||
Point position,
|
||||
uint32_t length
|
||||
) : Widget{ { position, { 8 * static_cast<int>(length), 16 } } },
|
||||
text_{ str },
|
||||
max_length_{ std::max<size_t>(max_length, str.length()) },
|
||||
char_count_{ std::max<uint32_t>(length, 1) },
|
||||
cursor_pos_{ text_.length() },
|
||||
insert_mode_{ true }
|
||||
{
|
||||
set_focusable(true);
|
||||
}
|
||||
|
||||
const std::string& TextField::value() const {
|
||||
return text_;
|
||||
}
|
||||
|
||||
void TextField::set_cursor(uint32_t pos) {
|
||||
cursor_pos_ = std::min<size_t>(pos, text_.length());
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
void TextField::set_insert_mode() {
|
||||
insert_mode_ = true;
|
||||
}
|
||||
|
||||
void TextField::set_overwrite_mode() {
|
||||
insert_mode_ = false;
|
||||
}
|
||||
|
||||
void TextField::char_add(char c) {
|
||||
// Don't add if inserting and at max_length and
|
||||
// don't overwrite if past the end of the text.
|
||||
if ((text_.length() >= max_length_ && insert_mode_) ||
|
||||
(cursor_pos_ >= text_.length() && !insert_mode_))
|
||||
return;
|
||||
|
||||
if (insert_mode_)
|
||||
text_.insert(cursor_pos_, 1, c);
|
||||
else
|
||||
text_[cursor_pos_] = c;
|
||||
|
||||
cursor_pos_++;
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
void TextField::char_delete() {
|
||||
if (cursor_pos_ == 0)
|
||||
return;
|
||||
|
||||
cursor_pos_--;
|
||||
text_.erase(cursor_pos_, 1);
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
void TextField::paint(Painter& painter) {
|
||||
constexpr int char_width = 8;
|
||||
|
||||
auto rect = screen_rect();
|
||||
auto text_style = has_focus() ? style().invert() : style();
|
||||
auto offset = 0;
|
||||
|
||||
// Does the string need to be shifted?
|
||||
if (cursor_pos_ >= char_count_)
|
||||
offset = cursor_pos_ - char_count_ + 1;
|
||||
|
||||
// Clear the control.
|
||||
painter.fill_rectangle(rect, text_style.background);
|
||||
|
||||
// Draw the text starting at the offset.
|
||||
for (uint32_t i = 0; i < char_count_ && i + offset < text_.length(); i++) {
|
||||
painter.draw_char(
|
||||
{ rect.location().x() + (static_cast<int>(i) * char_width), rect.location().y() },
|
||||
text_style,
|
||||
text_[i + offset]
|
||||
);
|
||||
}
|
||||
|
||||
// Determine cursor position on screen (either the cursor position or the last char).
|
||||
int32_t cursor_x = char_width * (offset > 0 ? char_count_ - 1 : cursor_pos_);
|
||||
Point cursor_point{ screen_pos().x() + cursor_x, screen_pos().y() };
|
||||
auto cursor_style = text_style.invert();
|
||||
|
||||
// Invert the cursor character when in overwrite mode.
|
||||
if (!insert_mode_ && (cursor_pos_) < text_.length())
|
||||
painter.draw_char(cursor_point, cursor_style, text_[cursor_pos_]);
|
||||
|
||||
// Draw the cursor.
|
||||
Rect cursor_box{ cursor_point, { char_width, 16 } };
|
||||
painter.draw_rectangle(cursor_box, cursor_style.background);
|
||||
}
|
||||
|
||||
bool TextField::on_key(const KeyEvent key) {
|
||||
if (key == KeyEvent::Left && cursor_pos_ > 0)
|
||||
cursor_pos_--;
|
||||
else if (key == KeyEvent::Right && cursor_pos_ < text_.length())
|
||||
cursor_pos_++;
|
||||
else if (key == KeyEvent::Select)
|
||||
insert_mode_ = !insert_mode_;
|
||||
else
|
||||
return false;
|
||||
|
||||
set_dirty();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TextField::on_encoder(const EncoderEvent delta) {
|
||||
int32_t new_pos = cursor_pos_ + delta;
|
||||
|
||||
// Let the encoder wrap around the ends of the text.
|
||||
if (new_pos < 0)
|
||||
new_pos = text_.length();
|
||||
else if (static_cast<size_t>(new_pos) > text_.length())
|
||||
new_pos = 0;
|
||||
|
||||
set_cursor(new_pos);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TextField::on_touch(const TouchEvent event) {
|
||||
if (event.type == TouchEvent::Type::Start)
|
||||
focus();
|
||||
|
||||
set_dirty();
|
||||
return true;
|
||||
}
|
||||
|
||||
/* TextEntryView ***********************************************************/
|
||||
|
||||
void TextEntryView::char_delete() {
|
||||
|
||||
@@ -28,52 +28,6 @@
|
||||
|
||||
namespace ui {
|
||||
|
||||
// A TextField is bound to a string reference and allows the string
|
||||
// to be manipulated. The field itself does not provide the UI for
|
||||
// setting the value. It provides the UI of rendering the text,
|
||||
// a cursor, and an API to edit the string content.
|
||||
class TextField : public Widget {
|
||||
public:
|
||||
TextField(std::string& str, Point position, uint32_t length = 30)
|
||||
: TextField{str, 64, position, length} { }
|
||||
|
||||
// Str: the string containing the content to edit.
|
||||
// Max_length: max length the string is allowed to use.
|
||||
// Position: the top-left corner of the control.
|
||||
// Length: the number of characters to display.
|
||||
// - Characters are 8 pixels wide.
|
||||
// - The screen can show 30 characters max.
|
||||
// - The control is 16 pixels tall.
|
||||
TextField(std::string& str, size_t max_length, Point position, uint32_t length = 30);
|
||||
|
||||
TextField(const TextField&) = delete;
|
||||
TextField(TextField&&) = delete;
|
||||
TextField& operator=(const TextField&) = delete;
|
||||
TextField& operator=(TextField&&) = delete;
|
||||
|
||||
const std::string& value() const;
|
||||
|
||||
void set_cursor(uint32_t pos);
|
||||
void set_insert_mode();
|
||||
void set_overwrite_mode();
|
||||
|
||||
void char_add(char c);
|
||||
void char_delete();
|
||||
|
||||
void paint(Painter& painter) override;
|
||||
|
||||
bool on_key(const KeyEvent key) override;
|
||||
bool on_encoder(const EncoderEvent delta) override;
|
||||
bool on_touch(const TouchEvent event) override;
|
||||
|
||||
protected:
|
||||
std::string& text_;
|
||||
size_t max_length_;
|
||||
uint32_t char_count_;
|
||||
uint32_t cursor_pos_;
|
||||
bool insert_mode_;
|
||||
};
|
||||
|
||||
class TextEntryView : public View {
|
||||
public:
|
||||
std::function<void(std::string&)> on_changed { };
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace ui
|
||||
Color::dark_grey()};
|
||||
|
||||
ImageButton button_back{
|
||||
{0, 0 * 16, 12 * 8, 16},//back button is long enough to cover the title area to make it easier to touch
|
||||
{0, 0 * 16, 12 * 8, 16}, // Back button also covers the title for easier touch.
|
||||
&bitmap_icon_previous,
|
||||
Color::white(),
|
||||
Color::dark_grey()};
|
||||
|
||||
@@ -67,7 +67,7 @@ void SigGenProcessor::execute(const buffer_c8_t& buffer) {
|
||||
// 16 bits LFSR .taps: 16, 15, 13, 4 ;feedback polynomial: x^16 + x^15 + x^13 + x^4 + 1
|
||||
// Periode 65535= 2^n-1, quite continuous .
|
||||
if (counter == 0) { // we slow down the shift register, because the pseudo random noise clock freq was too high for modulator.
|
||||
bit_16 = ((lfsr_16 >> 0) ^ (lfsr_16 >> 1) ^ (lfsr_16 >> 3) ^ (lfsr_16 >> 4) ^ (lfsr_16 >> 12) & 1);
|
||||
bit_16 = ((lfsr_16 >> 0) ^ (lfsr_16 >> 1) ^ (lfsr_16 >> 3) ^ (lfsr_16 >> 4) ^ ((lfsr_16 >> 12) & 1) );
|
||||
lfsr_16 = (lfsr_16 >> 1) | (bit_16 << 15);
|
||||
sample = (lfsr_16 & 0x00FF); // main pseudo random noise generator.
|
||||
}
|
||||
|
||||
@@ -450,6 +450,59 @@ constexpr fir_taps_real<64> taps_64_lp_156_198 {
|
||||
} },
|
||||
};
|
||||
|
||||
// WFM 180kHZ General purpose filter with sharp transition , it improves Commercial WFM S/N in weak signals //////////////////////////////////////////////
|
||||
|
||||
// IFIR image-reject filter: fs=3072000, pass=90000, stop=250000, decim=4, fout=768000
|
||||
constexpr fir_taps_real<24> taps_180k_wfm_decim_0 = {
|
||||
.low_frequency_normalized = -90000.0f / 3072000.0f,
|
||||
.high_frequency_normalized = 90000.0f / 3072000.0f,
|
||||
.transition_normalized = 160000.0f / 3072000.0f,
|
||||
.taps = { {
|
||||
55, 122, 244, 424, 666, 965, 1308, 1669,
|
||||
2019, 2321, 2544, 2663, 2663, 2544, 2321, 2019,
|
||||
1669, 1308, 965, 666, 424, 244, 122, 55,
|
||||
} },
|
||||
};
|
||||
|
||||
// IFIR prototype filter: fs=768000, pass=90000, stop=110000, decim=2, fout=384000
|
||||
constexpr fir_taps_real<16> taps_180k_wfm_decim_1 = {
|
||||
.low_frequency_normalized = -90000.0f / 768000.0f,
|
||||
.high_frequency_normalized = 90000.0f / 768000.0f,
|
||||
.transition_normalized = 20000.0f / 768000.0f,
|
||||
.taps = { {
|
||||
55, 19, -356, -916, -529, 2139, 6695, 10392,
|
||||
10392, 6695, 2139, -529, -916, -356, 19, 55,
|
||||
} },
|
||||
};
|
||||
|
||||
|
||||
|
||||
// WFM 40kHZ filter for NOAA APT reception in 137Mhz band with sharp transition //////////////////////////////////////////////
|
||||
|
||||
// IFIR image-reject filter: fs=3072000, pass=20000, stop=97000, decim=4, fout=768000
|
||||
constexpr fir_taps_real<24> taps_40k_wfm_decim_0 = {
|
||||
.low_frequency_normalized = -20000.0f / 3072000.0f,
|
||||
.high_frequency_normalized = 20000.0f / 3072000.0f,
|
||||
.transition_normalized = 67000.0f / 3072000.0f,
|
||||
.taps = { {
|
||||
46, 112, 230, 408, 650, 953, 1301, 1671,
|
||||
2029, 2340, 2570, 2692, 2692, 2570, 2340, 2029,
|
||||
1671, 1301, 953, 650, 408, 230, 112, 46,
|
||||
} },
|
||||
};
|
||||
|
||||
// IFIR prototype filter: fs=768000, pass=20000, stop=55000, decim=2, fout=384000
|
||||
constexpr fir_taps_real<16> taps_40k_wfm_decim_1 = {
|
||||
.low_frequency_normalized = -20000.0f / 768000.0f,
|
||||
.high_frequency_normalized = 20000.0f / 768000.0f,
|
||||
.transition_normalized = 35000.0f / 768000.0f,
|
||||
.taps = { {
|
||||
83, 299, 743, 1456, 2396, 3418, 4297, 4808,
|
||||
4808, 4297, 3418, 2396, 1456, 743, 299, 83,
|
||||
} },
|
||||
};
|
||||
|
||||
|
||||
// TPMS decimation filters ////////////////////////////////////////////////
|
||||
|
||||
// IFIR image-reject filter: fs=2457600, pass=100000, stop=407200, decim=4, fout=614400
|
||||
|
||||
@@ -1535,6 +1535,137 @@ bool OptionsField::on_touch(const TouchEvent event) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* TextField ***********************************************************/
|
||||
|
||||
TextField::TextField(
|
||||
std::string& str,
|
||||
size_t max_length,
|
||||
Point position,
|
||||
uint32_t length
|
||||
) : Widget{ { position, { 8 * static_cast<int>(length), 16 } } },
|
||||
text_{ str },
|
||||
max_length_{ std::max<size_t>(max_length, str.length()) },
|
||||
char_count_{ std::max<uint32_t>(length, 1) },
|
||||
cursor_pos_{ text_.length() },
|
||||
insert_mode_{ true }
|
||||
{
|
||||
set_focusable(true);
|
||||
}
|
||||
|
||||
const std::string& TextField::value() const {
|
||||
return text_;
|
||||
}
|
||||
|
||||
void TextField::set_cursor(uint32_t pos) {
|
||||
cursor_pos_ = std::min<size_t>(pos, text_.length());
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
void TextField::set_insert_mode() {
|
||||
insert_mode_ = true;
|
||||
}
|
||||
|
||||
void TextField::set_overwrite_mode() {
|
||||
insert_mode_ = false;
|
||||
}
|
||||
|
||||
void TextField::char_add(char c) {
|
||||
// Don't add if inserting and at max_length and
|
||||
// don't overwrite if past the end of the text.
|
||||
if ((text_.length() >= max_length_ && insert_mode_) ||
|
||||
(cursor_pos_ >= text_.length() && !insert_mode_))
|
||||
return;
|
||||
|
||||
if (insert_mode_)
|
||||
text_.insert(cursor_pos_, 1, c);
|
||||
else
|
||||
text_[cursor_pos_] = c;
|
||||
|
||||
cursor_pos_++;
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
void TextField::char_delete() {
|
||||
if (cursor_pos_ == 0)
|
||||
return;
|
||||
|
||||
cursor_pos_--;
|
||||
text_.erase(cursor_pos_, 1);
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
void TextField::paint(Painter& painter) {
|
||||
constexpr int char_width = 8;
|
||||
|
||||
auto rect = screen_rect();
|
||||
auto text_style = has_focus() ? style().invert() : style();
|
||||
auto offset = 0;
|
||||
|
||||
// Does the string need to be shifted?
|
||||
if (cursor_pos_ >= char_count_)
|
||||
offset = cursor_pos_ - char_count_ + 1;
|
||||
|
||||
// Clear the control.
|
||||
painter.fill_rectangle(rect, text_style.background);
|
||||
|
||||
// Draw the text starting at the offset.
|
||||
for (uint32_t i = 0; i < char_count_ && i + offset < text_.length(); i++) {
|
||||
painter.draw_char(
|
||||
{ rect.location().x() + (static_cast<int>(i) * char_width), rect.location().y() },
|
||||
text_style,
|
||||
text_[i + offset]
|
||||
);
|
||||
}
|
||||
|
||||
// Determine cursor position on screen (either the cursor position or the last char).
|
||||
int32_t cursor_x = char_width * (offset > 0 ? char_count_ - 1 : cursor_pos_);
|
||||
Point cursor_point{ screen_pos().x() + cursor_x, screen_pos().y() };
|
||||
auto cursor_style = text_style.invert();
|
||||
|
||||
// Invert the cursor character when in overwrite mode.
|
||||
if (!insert_mode_ && (cursor_pos_) < text_.length())
|
||||
painter.draw_char(cursor_point, cursor_style, text_[cursor_pos_]);
|
||||
|
||||
// Draw the cursor.
|
||||
Rect cursor_box{ cursor_point, { char_width, 16 } };
|
||||
painter.draw_rectangle(cursor_box, cursor_style.background);
|
||||
}
|
||||
|
||||
bool TextField::on_key(const KeyEvent key) {
|
||||
if (key == KeyEvent::Left && cursor_pos_ > 0)
|
||||
cursor_pos_--;
|
||||
else if (key == KeyEvent::Right && cursor_pos_ < text_.length())
|
||||
cursor_pos_++;
|
||||
else if (key == KeyEvent::Select)
|
||||
insert_mode_ = !insert_mode_;
|
||||
else
|
||||
return false;
|
||||
|
||||
set_dirty();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TextField::on_encoder(const EncoderEvent delta) {
|
||||
int32_t new_pos = cursor_pos_ + delta;
|
||||
|
||||
// Let the encoder wrap around the ends of the text.
|
||||
if (new_pos < 0)
|
||||
new_pos = text_.length();
|
||||
else if (static_cast<size_t>(new_pos) > text_.length())
|
||||
new_pos = 0;
|
||||
|
||||
set_cursor(new_pos);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TextField::on_touch(const TouchEvent event) {
|
||||
if (event.type == TouchEvent::Type::Start)
|
||||
focus();
|
||||
|
||||
set_dirty();
|
||||
return true;
|
||||
}
|
||||
|
||||
/* NumberField ***********************************************************/
|
||||
|
||||
NumberField::NumberField(
|
||||
|
||||
@@ -414,7 +414,6 @@ private:
|
||||
bool instant_exec_ { false };
|
||||
};
|
||||
|
||||
|
||||
class ButtonWithEncoder : public Widget {
|
||||
public:
|
||||
std::function<void(ButtonWithEncoder&)> on_select { };
|
||||
@@ -457,8 +456,6 @@ private:
|
||||
bool instant_exec_ { false };
|
||||
};
|
||||
|
||||
|
||||
|
||||
class NewButton : public Widget {
|
||||
public:
|
||||
std::function<void(void)> on_select { };
|
||||
@@ -610,6 +607,52 @@ private:
|
||||
size_t selected_index_ { 0 };
|
||||
};
|
||||
|
||||
// A TextField is bound to a string reference and allows the string
|
||||
// to be manipulated. The field itself does not provide the UI for
|
||||
// setting the value. It provides the UI of rendering the text,
|
||||
// a cursor, and an API to edit the string content.
|
||||
class TextField : public Widget {
|
||||
public:
|
||||
TextField(std::string& str, Point position, uint32_t length = 30)
|
||||
: TextField{str, 64, position, length} { }
|
||||
|
||||
// Str: the string containing the content to edit.
|
||||
// Max_length: max length the string is allowed to use.
|
||||
// Position: the top-left corner of the control.
|
||||
// Length: the number of characters to display.
|
||||
// - Characters are 8 pixels wide.
|
||||
// - The screen can show 30 characters max.
|
||||
// - The control is 16 pixels tall.
|
||||
TextField(std::string& str, size_t max_length, Point position, uint32_t length = 30);
|
||||
|
||||
TextField(const TextField&) = delete;
|
||||
TextField(TextField&&) = delete;
|
||||
TextField& operator=(const TextField&) = delete;
|
||||
TextField& operator=(TextField&&) = delete;
|
||||
|
||||
const std::string& value() const;
|
||||
|
||||
void set_cursor(uint32_t pos);
|
||||
void set_insert_mode();
|
||||
void set_overwrite_mode();
|
||||
|
||||
void char_add(char c);
|
||||
void char_delete();
|
||||
|
||||
void paint(Painter& painter) override;
|
||||
|
||||
bool on_key(const KeyEvent key) override;
|
||||
bool on_encoder(const EncoderEvent delta) override;
|
||||
bool on_touch(const TouchEvent event) override;
|
||||
|
||||
protected:
|
||||
std::string& text_;
|
||||
size_t max_length_;
|
||||
uint32_t char_count_;
|
||||
uint32_t cursor_pos_;
|
||||
bool insert_mode_;
|
||||
};
|
||||
|
||||
class NumberField : public Widget {
|
||||
public:
|
||||
std::function<void(NumberField&)> on_select { };
|
||||
|
||||
Binary file not shown.
Binary file not shown.
+15
-15
@@ -1,6 +1,6 @@
|
||||
a=150000,b=285000,m=AM,bw=DSB,s=5KHz,d=Longwave broadcast band|BCB (EU)
|
||||
a=525000,b=1605000,m=AM,bw=DSB,s=5KHz,d=AM broadcast band|BCB (EU & J)
|
||||
a=530000,b=1710000,m=AM,bw=DSB,s=5KHz,d=AM broadcast band|BCB (US)
|
||||
a=150000,b=285000,m=AM,bw=DSB,s=5kHz,d=Longwave broadcast band|BCB (EU)
|
||||
a=525000,b=1605000,m=AM,bw=DSB,s=5kHz,d=AM broadcast band|BCB (EU & J)
|
||||
a=530000,b=1710000,m=AM,bw=DSB,s=5kHz,d=AM broadcast band|BCB (US)
|
||||
a=1800000,b=29700000,m=WFM,bw=16k,d=Amateur_radio|Amateur
|
||||
a=26900000,b=27400000,m=WFM,bw=16k,d=Citizens_band_radio|Citizens band
|
||||
a=28000000,b=30000000,m=WFM,bw=16k,d=Amateur_radio|Amateur
|
||||
@@ -8,15 +8,15 @@ a=29000000,b=54000000,m=WFM,bw=16k,d=Land mobile
|
||||
a=50000000,b=54000000,m=WFM,bw=16k,d=Amateur_radio|Amateur
|
||||
a=65000000,b=85000000,m=WFM,bw=16k,d=Land mobile (EU)
|
||||
a=108000000,b=136000000,m=WFM,bw=16k,d=Aircraft
|
||||
a=120000000,b=160000000,m=WFM,bw=16k,s=50KHz,d=Land mobile (EU)
|
||||
a=132000000,b=174000000,m=WFM,bw=16k,s=50KHz,d=Land mobile
|
||||
a=142000000,b=170000000,m=WFM,bw=16k,s=50KHz,d=Land mobile (J)
|
||||
a=144000000,b=148000000,m=WFM,bw=16k,s=50KHz,d=Amateur_radio|Amateur
|
||||
a=216000000,b=222000000,m=WFM,bw=16k,s=50KHz,d=Land mobile
|
||||
a=222000000,b=225000000,m=WFM,bw=16k,s=50KHz,d=Amateur_radio|Amateur
|
||||
a=335000000,b=384000000,m=WFM,bw=16k,s=50KHz,d=Land mobile (J)
|
||||
a=406000000,b=512000000,m=WFM,bw=16k,s=50KHz,d=Land mobile
|
||||
a=450000000,b=470000000,m=WFM,bw=16k,s=50KHz,d=Land mobile (J)
|
||||
a=430000000,b=450000000,m=WFM,bw=16k,s=50KHz,d=Amateur_radio|Amateur
|
||||
a=806000000,b=947000000,m=WFM,bw=16k,s=50KHz,d=Land mobile
|
||||
a=1200000000,b=1600000000,m=WFM,bw=16k,s=50KHz,d=Amateur|Land mobile|GPS
|
||||
a=120000000,b=160000000,m=WFM,bw=16k,s=50kHz,d=Land mobile (EU)
|
||||
a=132000000,b=174000000,m=WFM,bw=16k,s=50kHz,d=Land mobile
|
||||
a=142000000,b=170000000,m=WFM,bw=16k,s=50kHz,d=Land mobile (J)
|
||||
a=144000000,b=148000000,m=WFM,bw=16k,s=50kHz,d=Amateur_radio|Amateur
|
||||
a=216000000,b=222000000,m=WFM,bw=16k,s=50kHz,d=Land mobile
|
||||
a=222000000,b=225000000,m=WFM,bw=16k,s=50kHz,d=Amateur_radio|Amateur
|
||||
a=335000000,b=384000000,m=WFM,bw=16k,s=50kHz,d=Land mobile (J)
|
||||
a=406000000,b=512000000,m=WFM,bw=16k,s=50kHz,d=Land mobile
|
||||
a=450000000,b=470000000,m=WFM,bw=16k,s=50kHz,d=Land mobile (J)
|
||||
a=430000000,b=450000000,m=WFM,bw=16k,s=50kHz,d=Amateur_radio|Amateur
|
||||
a=806000000,b=947000000,m=WFM,bw=16k,s=50kHz,d=Land mobile
|
||||
a=1200000000,b=1600000000,m=WFM,bw=16k,s=50kHz,d=Amateur|Land mobile|GPS
|
||||
|
||||
@@ -2,21 +2,50 @@
|
||||
# (Freq range in MHz, min separation 3MHz)
|
||||
# (Description up to 20 char)
|
||||
# (fields comma delimiter)
|
||||
140,380,VHF MICS AND MARINE
|
||||
260,500,315/433 MHz KEYFOBS
|
||||
390,420,RADIOSONDES
|
||||
420,660,UHF MICS
|
||||
# WATER METERS
|
||||
850,900,Water meters
|
||||
902,928,ISM 900MHz
|
||||
# PAGERS https://www.fcc.gov/wireless/bureau-divisions/mobility-division/paging
|
||||
34,36,USA PAGERS 35
|
||||
43,45,USA PAGERS 44
|
||||
151,153,USA PAGERS 152
|
||||
453,454,USA PAGERS 454
|
||||
929,931,USA PAGERS 930
|
||||
# KEYFOBS
|
||||
260,500,315/433 MHz KEYFOBS
|
||||
# MICS, RADIOSONDES, LEYFOB
|
||||
140,380,VHF MICS AND MARINE
|
||||
390,420,RADIOSONDES
|
||||
420,660,UHF MICS
|
||||
# LoRa
|
||||
433,435,LoRa 443EU
|
||||
863,870,LoRa 868EU
|
||||
902,928,LoRa 915US
|
||||
779,787,LoRa 780CN
|
||||
# BROADCAST RADIO
|
||||
65,74,FM BROADCAST RUSSIA
|
||||
76,95,FM BROADCAST JAPAN
|
||||
76,108,FM BROADCAST BRAZIL
|
||||
87,108,FM BROADCAST
|
||||
# AVIATION
|
||||
108,137,AVIATION 108
|
||||
960,1215,AVIATION 960
|
||||
# HAM RADIO
|
||||
28,30,HAM 10-METER
|
||||
50,54,HAM 6-METER
|
||||
144,148,HAM 2-METER
|
||||
219,225,HAM 1.25-METER
|
||||
420,450,HAM 70-CM
|
||||
902,928,HAM 33-CM
|
||||
1240,1300,HAM 23-CM
|
||||
# WATER METERS
|
||||
850,900,Water meters
|
||||
902,928,ISM 900MHz
|
||||
# WIFI
|
||||
2320,2560,BL / WIFI 2.4GHz
|
||||
5160,5900,WIFI 5GHz
|
||||
# ITU-DEFINED BANDS
|
||||
1,3,MF BAND
|
||||
3,30,HF BAND
|
||||
30,300,VHF BAND
|
||||
300,3000,UHF BAND
|
||||
3000,7250,SHF BAND
|
||||
# FULL
|
||||
10,7250,FULL RANGE
|
||||
|
||||
Reference in New Issue
Block a user