Skip to content

Commit 4b24eeb

Browse files
committed
Adding Pair submenu
1 parent d9c1ba0 commit 4b24eeb

File tree

5 files changed

+48
-1
lines changed

5 files changed

+48
-1
lines changed

Firmware/RTK_Surveyor/Display.ino

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,10 @@ void updateDisplay()
331331
//Do nothing. Quick, fall through state.
332332
break;
333333

334+
case (STATE_ESPNOW_PAIR):
335+
paintEspNowPair();
336+
break;
337+
334338
case (STATE_SHUTDOWN):
335339
displayShutdown();
336340
break;
@@ -2147,6 +2151,13 @@ void paintDisplaySetup()
21472151
printTextCenter("Bubble", 12 * 2, QW_FONT_8X16, 1, false);
21482152
printTextCenter("Config", 12 * 3, QW_FONT_8X16, 1, true);
21492153
}
2154+
else if (setupState == STATE_ESPNOW_PAIR)
2155+
{
2156+
printTextCenter("Base", 12 * 0, QW_FONT_8X16, 1, false);
2157+
printTextCenter("Bubble", 12 * 1, QW_FONT_8X16, 1, false);
2158+
printTextCenter("Config", 12 * 2, QW_FONT_8X16, 1, false);
2159+
printTextCenter("Pair", 12 * 3, QW_FONT_8X16, 1, true);
2160+
}
21502161
else if (setupState == STATE_PROFILE)
21512162
paintDisplaySetupProfile("Base");
21522163
} //end type F9P
@@ -2180,6 +2191,13 @@ void paintDisplaySetup()
21802191
printTextCenter("Bubble", 12 * 2, QW_FONT_8X16, 1, false);
21812192
printTextCenter("Config", 12 * 3, QW_FONT_8X16, 1, true);
21822193
}
2194+
else if (setupState == STATE_ESPNOW_PAIR)
2195+
{
2196+
printTextCenter("Rover", 12 * 0, QW_FONT_8X16, 1, false);
2197+
printTextCenter("Bubble", 12 * 1, QW_FONT_8X16, 1, false);
2198+
printTextCenter("Config", 12 * 2, QW_FONT_8X16, 1, false);
2199+
printTextCenter("Pair", 12 * 3, QW_FONT_8X16, 1, true);
2200+
}
21832201
else if (setupState == STATE_PROFILE)
21842202
paintDisplaySetupProfile("Rover");
21852203
} //end type F9R
@@ -2501,3 +2519,9 @@ void paintKeyProvisionFail(uint16_t displayTime)
25012519
delay(displayTime);
25022520
}
25032521
}
2522+
2523+
//Show screen while ESP-Now is pairing
2524+
void paintEspNowPair()
2525+
{
2526+
displayMessage("ESP-Now Pairing", 0);
2527+
}

Firmware/RTK_Surveyor/ESPNOW.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ void espnowStop()
188188
void espnowBeginPairing()
189189
{
190190
espnowStart();
191-
Serial.println("1");
192191

193192
// To begin pairing, we must add the broadcast MAC to the peer list
194193
uint8_t broadcastMac[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};

Firmware/RTK_Surveyor/States.ino

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,17 @@ void updateSystemState()
898898
}
899899
break;
900900

901+
case (STATE_ESPNOW_PAIR):
902+
{
903+
if(espnowState == ESPNOW_OFF)
904+
{
905+
espnowBeginPairing();
906+
}
907+
908+
//Display 'ESP-Now Pairing' while we wait
909+
}
910+
break;
911+
901912
case (STATE_SHUTDOWN):
902913
{
903914
forceDisplayUpdate = true;
@@ -1038,6 +1049,10 @@ void changeState(SystemState newState)
10381049
Serial.print("State: Keys Provision - WiFi Timeout");
10391050
break;
10401051

1052+
case (STATE_ESPNOW_PAIR):
1053+
Serial.print("State: ESP-Now Pair");
1054+
break;
1055+
10411056
case (STATE_SHUTDOWN):
10421057
Serial.print("State: Shut Down");
10431058
break;

Firmware/RTK_Surveyor/Tasks.ino

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ void ButtonCheckTask(void *e)
412412
case STATE_BUBBLE_LEVEL:
413413
case STATE_WIFI_CONFIG_NOT_STARTED:
414414
case STATE_WIFI_CONFIG:
415+
case STATE_ESPNOW_PAIR:
415416
lastSystemState = systemState; //Remember this state to return after we mark an event
416417
requestChangeState(STATE_DISPLAY_SETUP);
417418
setupState = STATE_MARK_EVENT;
@@ -463,6 +464,9 @@ void ButtonCheckTask(void *e)
463464
setupState = STATE_WIFI_CONFIG_NOT_STARTED;
464465
break;
465466
case STATE_WIFI_CONFIG_NOT_STARTED:
467+
setupState = STATE_ESPNOW_PAIR;
468+
break;
469+
case STATE_ESPNOW_PAIR:
466470
//If only one active profile do not show any profiles
467471
index = getProfileNumberFromUnit(0);
468472
displayProfile = getProfileNumberFromUnit(1);
@@ -527,6 +531,7 @@ void ButtonCheckTask(void *e)
527531
case STATE_BUBBLE_LEVEL:
528532
case STATE_WIFI_CONFIG_NOT_STARTED:
529533
case STATE_WIFI_CONFIG:
534+
case STATE_ESPNOW_PAIR:
530535
lastSystemState = systemState; //Remember this state to return after we mark an event
531536
requestChangeState(STATE_DISPLAY_SETUP);
532537
setupState = STATE_MARK_EVENT;
@@ -578,6 +583,9 @@ void ButtonCheckTask(void *e)
578583
setupState = STATE_WIFI_CONFIG_NOT_STARTED;
579584
break;
580585
case STATE_WIFI_CONFIG_NOT_STARTED:
586+
setupState = STATE_ESPNOW_PAIR;
587+
break;
588+
case STATE_ESPNOW_PAIR:
581589
//If only one active profile do not show any profiles
582590
index = getProfileNumberFromUnit(0);
583591
displayProfile = getProfileNumberFromUnit(1);

Firmware/RTK_Surveyor/settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ typedef enum
3333
STATE_KEYS_PROVISION_WIFI_STARTED,
3434
STATE_KEYS_PROVISION_WIFI_CONNECTED,
3535
STATE_KEYS_PROVISION_WIFI_TIMEOUT,
36+
STATE_ESPNOW_PAIR,
3637
STATE_SHUTDOWN,
3738
} SystemState;
3839
volatile SystemState systemState = STATE_ROVER_NOT_STARTED;

0 commit comments

Comments
 (0)