Skip to content

Commit ef2991d

Browse files
committed
Correct use of prioritySettingsEnd - for Flex
1 parent b3b0492 commit ef2991d

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

Firmware/RTK_Everywhere/menuCommands.ino

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,8 +594,8 @@ int commandLookupSettingNameSelective(bool inCommands, const char *settingName,
594594
prioritySettingsEnd = findEndOfPrioritySettings();
595595
// If "endOfPrioritySettings" is not found, prioritySettingsEnd will be zero
596596

597-
// Remove one because while rtkSettingsEntries[] contains detectedGnssReceiver, the command table does not
598-
prioritySettingsEnd--;
597+
// Adjust prioritySettingsEnd if needed - depending on platform type
598+
prioritySettingsEnd = adjustEndOfPrioritySettings(prioritySettingsEnd);
599599

600600
// Loop through the valid command entries - starting at prioritySettingsEnd
601601
for (int i = prioritySettingsEnd; i < commandCount; i++)
@@ -3783,6 +3783,23 @@ int findEndOfPrioritySettings()
37833783
return prioritySettingsEnd;
37843784
}
37853785

3786+
int adjustEndOfPrioritySettings(int prioritySettingsEnd)
3787+
{
3788+
// If prioritySettingsEnd is zero, don't adjust
3789+
if (prioritySettingsEnd == 0)
3790+
return 0;
3791+
3792+
// Check which of the priority settings are possible on this platform
3793+
// Deduct the ones which are not
3794+
for (int i = 0; i < prioritySettingsEnd; i++)
3795+
{
3796+
if (!settingPossibleOnPlatform(i))
3797+
prioritySettingsEnd--;
3798+
}
3799+
3800+
return prioritySettingsEnd;
3801+
}
3802+
37863803
// Allocate and fill the commandIndex table
37873804
bool commandIndexFillPossible()
37883805
{
@@ -3860,6 +3877,9 @@ bool commandIndexFill(bool usePossibleSettings)
38603877
// If "endOfPrioritySettings" is not found, prioritySettingsEnd will be zero
38613878
// and all settings will be sorted. Just like the good old days...
38623879

3880+
// Adjust prioritySettingsEnd if needed - depending on platform type
3881+
prioritySettingsEnd = adjustEndOfPrioritySettings(prioritySettingsEnd);
3882+
38633883
if (settings.debugSettings || settings.debugCLI)
38643884
{
38653885
systemPrintf("commandCount %d\r\n", commandCount);

Firmware/RTK_Everywhere/settings.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,12 @@ const RTK_Settings_Entry rtkSettingsEntries[] =
12601260
// i d i v V i c n r e X
12611261
// g s x k 2 c h d d x 2 Type Qual Variable Name
12621262

1263-
// Detected GNSS Receiver - for Flex. Save / load first so settingAvailableOnPlatform is correct on Flex
1263+
1264+
// =======================================================================================================
1265+
// Priority Settings which are not alphabetized in commandIndex
1266+
// =======================================================================================================
1267+
1268+
// Detected GNSS Receiver - only for Flex. Save / load first so settingAvailableOnPlatform is correct on Flex
12641269
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, ALL, 0, tGnssReceiver, 0, & settings.detectedGnssReceiver, "detectedGnssReceiver", },
12651270

12661271
// Common settings which use the same name on multiple Flex platforms
@@ -1281,6 +1286,7 @@ const RTK_Settings_Entry rtkSettingsEntries[] =
12811286

12821287
// <--- Insert any new essential "priority" (non-sorted) settings above this line --->
12831288

1289+
// endOfPrioritySettings is a special 'null' entry which does not appear in commandIndex
12841290
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, NON, 0, _bool, 0, nullptr, "endOfPrioritySettings", },
12851291

12861292
// =======================================================================================================

0 commit comments

Comments
 (0)