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.
This commit is contained in:
Mark Thompson 2023-05-12 11:48:32 -05:00 committed by GitHub
parent 1e4ea753ba
commit 730e7ad72b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 deletions

View File

@ -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=");

View File

@ -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;