From 730e7ad72b2c9c20b47d8e4425bed2bb18312072 Mon Sep 17 00:00:00 2001 From: Mark Thompson <129641948+NotherNgineer@users.noreply.github.com> Date: Fri, 12 May 2023 11:48:32 -0500 Subject: [PATCH] Two minor patches - freqman file processing & NumberField "can_loop" option (#981) -Enhanced frequency file reading: Correctly read freq files that contain a mix of SINGLE and RANGE or HAM_RADIO types (strstr in file processing was ignoring EOL and was therefore finding the f= on the next line). Also changed to simply ignore blank or unrecognized lines versus adding them as SIMPLE entries to freq table. This allow comments and white line in freqman files. -Fixed "can_loop" option in NumberField: When NumberField range.first was non-zero, and can_loop was true, turning the encoder dial in the downward direction did not result in numbers looping back to range.second as was expected. This fix allows looping in downward direction in the case where range.first is non-zero. --- firmware/application/freqman.cpp | 7 +++---- firmware/common/ui_widget.cpp | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/firmware/application/freqman.cpp b/firmware/application/freqman.cpp index ad74330bc..8176b2ba3 100644 --- a/firmware/application/freqman.cpp +++ b/firmware/application/freqman.cpp @@ -146,17 +146,15 @@ bool load_freqman_file_ex(std::string& file_stem, freqman_db& db, bool load_freq // Reset line_start to beginning of buffer line_start = file_data; - if (!strstr(file_data, "f=") && !strstr(file_data, "a=") && !strstr(file_data, "r=") ) - break; - // Look for complete lines in buffer while ((line_end = strstr(line_start, "\x0A"))) { + *line_end = 0; // Stop strstr() searches below at EOL modulation = -1 ; bandwidth = -1 ; step = -1 ; tone = -1 ; - type=SINGLE ; + type = ERROR_TYPE; frequency_a = frequency_b = 0; // Read frequency @@ -164,6 +162,7 @@ bool load_freqman_file_ex(std::string& file_stem, freqman_db& db, bool load_freq if(pos) { pos += 2; frequency_a = strtoll(pos, nullptr, 10); + type = SINGLE; } else { // ...or range pos = strstr(line_start, "a="); diff --git a/firmware/common/ui_widget.cpp b/firmware/common/ui_widget.cpp index 0eb0dba6c..413ee37bc 100644 --- a/firmware/common/ui_widget.cpp +++ b/firmware/common/ui_widget.cpp @@ -1700,7 +1700,7 @@ int32_t NumberField::value() const { void NumberField::set_value(int32_t new_value, bool trigger_change) { if (can_loop) { - if (new_value >= 0) + if (new_value >= range.first) new_value = new_value % (range.second + 1); else new_value = range.second + new_value + 1;