Skip to content

Commit 061f952

Browse files
committed
Refactor Setup - add double tap to select
1 parent 3a4ad32 commit 061f952

File tree

5 files changed

+246
-277
lines changed

5 files changed

+246
-277
lines changed

Firmware/RTK_Everywhere/Display.ino

Lines changed: 38 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -1773,7 +1773,8 @@ void paintRTCM(std::vector<iconPropertyBlinking> *iconList)
17731773
paintResets();
17741774
}
17751775

1776-
// Show connecting to NTRIP caster service
1776+
// Show connecting to NTRIP caster service.
1777+
// Note: NOT USED. TODO: if this is used, the text position needs to be changed for 128x64
17771778
void paintConnectingToNtripCaster()
17781779
{
17791780
int yPos = 18;
@@ -2436,168 +2437,58 @@ void paintSystemTest()
24362437
}
24372438
}
24382439

2439-
// Display the setup profiles
2440-
void paintDisplaySetupProfile(const char *firstState)
2440+
// Show different menu 'buttons'.
2441+
// The first button is always highlighted, ready for selection. The user needs to double tap it to select it
2442+
void paintDisplaySetup()
24412443
{
2442-
int index;
2443-
int itemsDisplayed;
2444-
char profileName[8 + 1];
2444+
constructSetupDisplay(&setupButtons); // Construct the vector (linked list) of buttons
24452445

2446-
// Display the first state if this is the first profile
2447-
itemsDisplayed = 0;
2448-
if (displayProfile == 0)
2449-
{
2450-
printTextCenter(firstState, 12 * itemsDisplayed, QW_FONT_8X16, 1, false);
2451-
itemsDisplayed++;
2452-
}
2446+
uint8_t maxButtons = ((present.display_type == DISPLAY_128x64) ? 5 : 4);
24532447

2454-
// Display Bubble if this is the second profile
2455-
if (displayProfile <= 1)
2456-
{
2457-
printTextCenter("Bubble", 12 * itemsDisplayed, QW_FONT_8X16, 1, false);
2458-
itemsDisplayed++;
2459-
}
2448+
uint8_t printedButtons = 0;
24602449

2461-
// Display Config if this is the third profile
2462-
if (displayProfile <= 2)
2463-
{
2464-
printTextCenter("Config", 12 * itemsDisplayed, QW_FONT_8X16, 1, false);
2465-
itemsDisplayed++;
2466-
}
2450+
uint8_t thisIsButton = 0;
24672451

2468-
// displayProfile itemsDisplayed index
2469-
// 0 3 0
2470-
// 1 2 0
2471-
// 2 1 0
2472-
// 3 0 0
2473-
// 4 0 1
2474-
// 5 0 2
2475-
// n >= 3 0 n - 3
2476-
2477-
// Display the profile names
2478-
for (index = (displayProfile >= 3) ? displayProfile - 3 : 0; itemsDisplayed < 4; itemsDisplayed++)
2452+
for (auto it = setupButtons.begin(); it != setupButtons.end(); it = std::next(it))
24792453
{
2480-
// Lookup next available profile, limit to 8 characters
2481-
getProfileNameFromUnit(index, profileName, sizeof(profileName));
2482-
2483-
profileName[6] = 0; // Shorten profileName to 6 characters
2454+
setupButton theButton = *it;
24842455

2485-
char miniProfileName[16] = {0};
2486-
snprintf(miniProfileName, sizeof(miniProfileName), "%d_%s", index, profileName); // Prefix with index #
2487-
2488-
printTextCenter(miniProfileName, 12 * itemsDisplayed, QW_FONT_8X16, 1, itemsDisplayed == 3);
2489-
index++;
2490-
}
2491-
}
2492-
2493-
// Show different menu 'buttons' to allow user to pause on one to select it
2494-
void paintDisplaySetup()
2495-
{
2496-
if (setupState == STATE_ROVER_NOT_STARTED)
2497-
{
2498-
if (present.ethernet_ws5500 == true)
2499-
{
2500-
printTextCenter("Base", 12 * 0, QW_FONT_8X16, 1, false); // string, y, font type, kerning, inverted
2501-
printTextCenter("Rover", 12 * 1, QW_FONT_8X16, 1, true);
2502-
printTextCenter("NTP", 12 * 2, QW_FONT_8X16, 1, false);
2503-
printTextCenter("Cfg Eth", 12 * 3, QW_FONT_8X16, 1, false);
2504-
}
2505-
else
2506-
{
2507-
printTextCenter("Mark", 12 * 0, QW_FONT_8X16, 1, false);
2508-
printTextCenter("Rover", 12 * 1, QW_FONT_8X16, 1, true);
2509-
printTextCenter("Base", 12 * 2, QW_FONT_8X16, 1, false);
2510-
printTextCenter("Config", 12 * 3, QW_FONT_8X16, 1, false);
2511-
}
2512-
}
2513-
else if (setupState == STATE_BASE_NOT_STARTED)
2514-
{
2515-
if (present.ethernet_ws5500 == true)
2516-
{
2517-
printTextCenter("Base", 12 * 0, QW_FONT_8X16, 1, true); // string, y, font type, kerning, inverted
2518-
printTextCenter("Rover", 12 * 1, QW_FONT_8X16, 1, false);
2519-
printTextCenter("NTP", 12 * 2, QW_FONT_8X16, 1, false);
2520-
printTextCenter("Cfg Eth", 12 * 3, QW_FONT_8X16, 1, false);
2521-
}
2522-
else
2523-
{
2524-
printTextCenter("Mark", 12 * 0, QW_FONT_8X16, 1, false); // string, y, font type, kerning, inverted
2525-
printTextCenter("Rover", 12 * 1, QW_FONT_8X16, 1, false);
2526-
printTextCenter("Base", 12 * 2, QW_FONT_8X16, 1, true);
2527-
printTextCenter("Config", 12 * 3, QW_FONT_8X16, 1, false);
2528-
}
2529-
}
2530-
else if (setupState == STATE_NTPSERVER_NOT_STARTED)
2531-
{
2532-
{
2533-
printTextCenter("Base", 12 * 0, QW_FONT_8X16, 1, false); // string, y, font type, kerning, inverted
2534-
printTextCenter("Rover", 12 * 1, QW_FONT_8X16, 1, false);
2535-
printTextCenter("NTP", 12 * 2, QW_FONT_8X16, 1, true);
2536-
printTextCenter("Cfg Eth", 12 * 3, QW_FONT_8X16, 1, false);
2537-
}
2538-
}
2539-
else if (setupState == STATE_CONFIG_VIA_ETH_NOT_STARTED)
2540-
{
2541-
printTextCenter("Base", 12 * 0, QW_FONT_8X16, 1, false); // string, y, font type, kerning, inverted
2542-
printTextCenter("Rover", 12 * 1, QW_FONT_8X16, 1, false);
2543-
printTextCenter("NTP", 12 * 2, QW_FONT_8X16, 1, false);
2544-
printTextCenter("Cfg Eth", 12 * 3, QW_FONT_8X16, 1, true);
2545-
}
2546-
else if (setupState == STATE_WIFI_CONFIG_NOT_STARTED)
2547-
{
2548-
if (present.ethernet_ws5500 == true)
2456+
if (thisIsButton >= setupSelectedButton) // Should we display this button based on the global setupSelectedButton?
25492457
{
2550-
printTextCenter("Rover", 12 * 0, QW_FONT_8X16, 1, false); // string, y, font type, kerning, inverted
2551-
printTextCenter("NTP", 12 * 1, QW_FONT_8X16, 1, false);
2552-
printTextCenter("Cfg Eth", 12 * 2, QW_FONT_8X16, 1, false);
2553-
printTextCenter("CfgWiFi", 12 * 3, QW_FONT_8X16, 1, true);
2554-
}
2555-
else
2556-
{
2557-
printTextCenter("Mark", 12 * 0, QW_FONT_8X16, 1, false);
2558-
printTextCenter("Rover", 12 * 1, QW_FONT_8X16, 1, false);
2559-
printTextCenter("Base", 12 * 2, QW_FONT_8X16, 1, false);
2560-
printTextCenter("Config", 12 * 3, QW_FONT_8X16, 1, true);
2458+
if (printedButtons < maxButtons) // Do we have room to display it?
2459+
{
2460+
if (theButton.newState == STATE_PROFILE)
2461+
{
2462+
int nameWidth = ((present.display_type == DISPLAY_128x64) ? 17 : 9);
2463+
char miniProfileName[nameWidth] = {0};
2464+
snprintf(miniProfileName, sizeof(miniProfileName), "%d_%s", theButton.newProfile, theButton.name); // Prefix with index #
2465+
printTextCenter(miniProfileName, 12 * printedButtons, QW_FONT_8X16, 1, printedButtons == 0);
2466+
}
2467+
else
2468+
printTextCenter(theButton.name, 12 * printedButtons, QW_FONT_8X16, 1, printedButtons == 0);
2469+
printedButtons++;
2470+
}
25612471
}
2562-
}
25632472

2564-
// If we are on an L-Band unit, display GetKeys option
2565-
else if (setupState == STATE_KEYS_NEEDED)
2566-
{
2567-
printTextCenter("Rover", 12 * 0, QW_FONT_8X16, 1, false);
2568-
printTextCenter("Base", 12 * 1, QW_FONT_8X16, 1, false);
2569-
printTextCenter("Config", 12 * 2, QW_FONT_8X16, 1, false);
2570-
printTextCenter("GetKeys", 12 * 3, QW_FONT_8X16, 1, true);
2473+
thisIsButton++;
25712474
}
25722475

2573-
else if (setupState == STATE_ESPNOW_PAIRING_NOT_STARTED)
2476+
if (printedButtons < maxButtons) // If we printed less than maxButtons, print more
25742477
{
2575-
if (present.ethernet_ws5500 == true)
2576-
{
2577-
printTextCenter("NTP", 12 * 0, QW_FONT_8X16, 1, false); // string, y, font type, kerning, inverted
2578-
printTextCenter("Cfg Eth", 12 * 1, QW_FONT_8X16, 1, false);
2579-
printTextCenter("CfgWiFi", 12 * 2, QW_FONT_8X16, 1, false);
2580-
printTextCenter("E-Pair", 12 * 3, QW_FONT_8X16, 1, true);
2581-
}
2582-
else if (settings.pointPerfectCorrectionsSource != POINTPERFECT_CORRECTIONS_DISABLED)
2583-
{
2584-
// If we are on an L-Band unit, scroll GetKeys option
2585-
printTextCenter("Base", 12 * 0, QW_FONT_8X16, 1, false);
2586-
printTextCenter("Config", 12 * 1, QW_FONT_8X16, 1, false);
2587-
printTextCenter("GetKeys", 12 * 2, QW_FONT_8X16, 1, false);
2588-
printTextCenter("E-Pair", 12 * 3, QW_FONT_8X16, 1, true);
2589-
}
2590-
else
2478+
for (auto it = setupButtons.begin(); it != setupButtons.end(); it = std::next(it))
25912479
{
2592-
printTextCenter("Rover", 12 * 0, QW_FONT_8X16, 1, false);
2593-
printTextCenter("Base", 12 * 1, QW_FONT_8X16, 1, false);
2594-
printTextCenter("Config", 12 * 2, QW_FONT_8X16, 1, false);
2595-
printTextCenter("E-Pair", 12 * 3, QW_FONT_8X16, 1, true);
2480+
setupButton theButton = *it;
2481+
2482+
if (printedButtons < maxButtons) // Do we have room to display it?
2483+
{
2484+
printTextCenter(theButton.name, 12 * printedButtons, QW_FONT_8X16, 1, printedButtons == 0);
2485+
printedButtons++;
2486+
}
2487+
2488+
if (printedButtons == maxButtons)
2489+
break;
25962490
}
25972491
}
2598-
2599-
else if (setupState == STATE_PROFILE)
2600-
paintDisplaySetupProfile("Base");
26012492
}
26022493

26032494
// Given text, and location, print text center of the screen

Firmware/RTK_Everywhere/RTK_Everywhere.ino

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,8 +675,11 @@ uint32_t rtcmLastReceived;
675675

676676
uint32_t maxSurveyInWait_s = 60L * 15L; // Re-start survey-in after X seconds
677677

678-
uint32_t lastSetupMenuChange; // Auto-selects the setup menu option after 1500ms
678+
uint32_t lastSetupMenuChange; // Limits how much time is spent in the setup menu
679679
uint32_t lastTestMenuChange; // Avoids exiting the test menu for at least 1 second
680+
bool setupDoubleTapRequired = false; // In buttonCheckTask, require a double tap to proceed
681+
uint8_t setupSelectedButton = 0; // In Display Setup, start displaying at this button. This is the selected (highlighted) button.
682+
std::vector<setupButton> setupButtons; // A vector (linked list) of the setup 'butttons'
680683

681684
bool firstRoverStart; // Used to detect if the user is toggling the power button at POR to enter the test menu
682685

Firmware/RTK_Everywhere/States.ino

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,10 +407,11 @@ void stateUpdate()
407407
break;
408408

409409
case (STATE_DISPLAY_SETUP): {
410-
if (millis() - lastSetupMenuChange > 1500)
410+
if (millis() - lastSetupMenuChange > 30000)
411411
{
412-
forceSystemStateUpdate = true; // Immediately go to this new state
413-
changeState(setupState); // Change to last setup state
412+
//forceSystemStateUpdate = true; // Immediately go to this new state
413+
setupDoubleTapRequired = false;
414+
changeState(lastSystemState); // Return to the last system state
414415
}
415416
}
416417
break;
@@ -1203,3 +1204,54 @@ bool inNtpMode()
12031204
return (true);
12041205
return (false);
12051206
}
1207+
1208+
void addSetupButton(std::vector<setupButton> *buttons, const char *name, SystemState newState)
1209+
{
1210+
setupButton button;
1211+
button.name = name;
1212+
button.newState = newState;
1213+
buttons->push_back(button);
1214+
}
1215+
1216+
// Construct menu 'buttons' to allow user to pause on one and double tap to select it
1217+
void constructSetupDisplay(std::vector<setupButton> *buttons)
1218+
{
1219+
buttons->clear();
1220+
1221+
// It looks like we don't need "Mark"? TODO: check this!
1222+
addSetupButton(buttons, "Base", STATE_BASE_NOT_STARTED);
1223+
addSetupButton(buttons, "Rover", STATE_ROVER_NOT_STARTED);
1224+
if (present.ethernet_ws5500 == true)
1225+
{
1226+
addSetupButton(buttons, "NTP", STATE_NTPSERVER_NOT_STARTED);
1227+
addSetupButton(buttons, "Cfg Eth", STATE_CONFIG_VIA_ETH_NOT_STARTED);
1228+
addSetupButton(buttons, "Cfg WiFi", STATE_WIFI_CONFIG_NOT_STARTED);
1229+
}
1230+
else
1231+
{
1232+
addSetupButton(buttons, "Config", STATE_WIFI_CONFIG_NOT_STARTED);
1233+
}
1234+
if (settings.pointPerfectCorrectionsSource != POINTPERFECT_CORRECTIONS_DISABLED)
1235+
{
1236+
addSetupButton(buttons, "Get Keys", STATE_KEYS_NEEDED);
1237+
}
1238+
addSetupButton(buttons, "E-Pair", STATE_ESPNOW_PAIRING_NOT_STARTED);
1239+
// If only one active profile do not show any profiles
1240+
if (getProfileNumberFromUnit(1) > 0)
1241+
{
1242+
for (int x = 0; x < MAX_PROFILE_COUNT; x++)
1243+
{
1244+
int activeProfile = getProfileNumberFromUnit(x);
1245+
if ((x == 0) || (activeProfile > 0))
1246+
{
1247+
setupButton button;
1248+
button.name = &profileNames[activeProfile][0];
1249+
button.newState = STATE_PROFILE;
1250+
button.newProfile = x;
1251+
buttons->push_back(button);
1252+
}
1253+
}
1254+
}
1255+
addSetupButton(buttons, "Exit", STATE_NOT_SET);
1256+
}
1257+

0 commit comments

Comments
 (0)