|
|
|
|
@ -291,11 +291,11 @@ static void StateMachine(bool buttonPress) { |
|
|
|
|
if (buttonPress) { |
|
|
|
|
#if (PL_CONFIG_APP_LINE_FOLLOWING || PL_CONFIG_APP_LINE_MAZE) && !PL_APP_MINT /* Mint application handles buttons itself */ |
|
|
|
|
if (LF_IsFollowing()) { |
|
|
|
|
LF_StopFollowing(); |
|
|
|
|
appState = APP_STATE_IDLE; |
|
|
|
|
// LF_StopFollowing();
|
|
|
|
|
// appState = APP_STATE_IDLE;
|
|
|
|
|
} else { |
|
|
|
|
LF_StartFollowing(); |
|
|
|
|
appState = APP_STATE_FOLLOW_LINE; |
|
|
|
|
// LF_StartFollowing();
|
|
|
|
|
// appState = APP_STATE_FOLLOW_LINE;
|
|
|
|
|
} |
|
|
|
|
#elif PL_APP_FOLLOW_OBSTACLE |
|
|
|
|
followObstacle = TRUE; |
|
|
|
|
@ -354,9 +354,9 @@ static void StateMachine(bool buttonPress) { |
|
|
|
|
McuLED_Off(LEDS_Left); |
|
|
|
|
McuLED_Off(LEDS_Right); |
|
|
|
|
#endif |
|
|
|
|
if (!LF_IsFollowing()) { |
|
|
|
|
appState = APP_STATE_IDLE; |
|
|
|
|
} |
|
|
|
|
// if (!LF_IsFollowing()) {
|
|
|
|
|
// appState = APP_STATE_IDLE;
|
|
|
|
|
// }
|
|
|
|
|
if (buttonPress) { |
|
|
|
|
LF_StopFollowing();
|
|
|
|
|
appState = APP_STATE_IDLE; |
|
|
|
|
@ -370,20 +370,23 @@ static void StateMachine(bool buttonPress) { |
|
|
|
|
appState = APP_STATE_AUTO; |
|
|
|
|
mazeFailure = 0; |
|
|
|
|
MAZE_ResetPresentCount(); |
|
|
|
|
presentCnt = MAZE_GetPresentCount(); |
|
|
|
|
presentCnt = 0; |
|
|
|
|
MAZE_ClearSolution(); |
|
|
|
|
LF_StartFollowing(); |
|
|
|
|
McuShell_SendStr((unsigned char*)"mqtt publish \"/mobile/status/mode/\" \"AUTO\"", McuESP32_GetTxToESPStdio()->stdOut); |
|
|
|
|
McuShell_SendStr((unsigned char*)"\r\n", McuESP32_GetTxToESPStdio()->stdOut); |
|
|
|
|
BUZ_Beep(1000, 1000); |
|
|
|
|
McuShell_SendStr((unsigned char*)"mqtt publish \"/mobile/status/mode/\" \"AUTO\"\r\n", McuESP32_GetTxToESPStdio()->stdOut); |
|
|
|
|
// McuShell_SendStr((unsigned char*)"\r\n", McuESP32_GetTxToESPStdio()->stdOut);
|
|
|
|
|
} |
|
|
|
|
vTaskDelay(pdMS_TO_TICKS(10)); |
|
|
|
|
break; |
|
|
|
|
case APP_STATE_AUTO: |
|
|
|
|
if(!LF_IsFollowing() && MAZE_IsSolved()){ |
|
|
|
|
//done
|
|
|
|
|
SHELL_SendString((unsigned char*)"MAZE: done, stopped!!!\r\n"); |
|
|
|
|
McuShell_SendStr((unsigned char*)"mqtt publish \"/mobile/status/mode/\" \"FINAL\"", McuESP32_GetTxToESPStdio()->stdOut); |
|
|
|
|
McuShell_SendStr((unsigned char*)"\r\n", McuESP32_GetTxToESPStdio()->stdOut); |
|
|
|
|
McuShell_SendStr((unsigned char*)"mqtt publish \"/mobile/status/mode/\" \"FINAL\"\r\n", McuESP32_GetTxToESPStdio()->stdOut); |
|
|
|
|
// McuShell_SendStr((unsigned char*)"\r\n", McuESP32_GetTxToESPStdio()->stdOut);
|
|
|
|
|
appState = APP_STATE_IDLE; |
|
|
|
|
mazeFailure=0; |
|
|
|
|
}else if(!LF_IsFollowing() && !MAZE_IsSolved() && mazeFailure < 5){ |
|
|
|
|
// failed
|
|
|
|
|
mazeFailure++; |
|
|
|
|
@ -392,20 +395,19 @@ static void StateMachine(bool buttonPress) { |
|
|
|
|
DRV_SetMode(DRV_MODE_SPEED); |
|
|
|
|
LF_StartFollowing(); |
|
|
|
|
}else if(!LF_IsFollowing() && !MAZE_IsSolved() && mazeFailure >= 5){ |
|
|
|
|
BUZ_Beep(1000, 1000); |
|
|
|
|
McuShell_SendStr((unsigned char*)"mqtt publish \"/mobile/status/mode/\" \"FAILURE\"\r\n", McuESP32_GetTxToESPStdio()->stdOut); |
|
|
|
|
// McuShell_SendStr((unsigned char*)"\r\n", McuESP32_GetTxToESPStdio()->stdOut);
|
|
|
|
|
appState = APP_STATE_IDLE; |
|
|
|
|
McuShell_SendStr((unsigned char*)"mqtt publish \"/mobile/status/mode/\" \"FAILURE\"", McuESP32_GetTxToESPStdio()->stdOut); |
|
|
|
|
McuShell_SendStr((unsigned char*)"\r\n", McuESP32_GetTxToESPStdio()->stdOut); |
|
|
|
|
} |
|
|
|
|
if(MAZE_GetPresentCount() != presentCnt){ |
|
|
|
|
presentCnt = MAZE_GetPresentCount(); |
|
|
|
|
//publish
|
|
|
|
|
uint8_t counter[5] = ""; |
|
|
|
|
McuUtility_Num8uToStr(counter, sizeof(counter), presentCnt); |
|
|
|
|
SHELL_SendString((unsigned char*)counter); |
|
|
|
|
SHELL_SendString((unsigned char*)"\r\n"); |
|
|
|
|
McuShell_SendStr((unsigned char*)"mqtt publish \"/mobile/status/present/\" \"true\"", McuESP32_GetTxToESPStdio()->stdOut); |
|
|
|
|
McuShell_SendStr((unsigned char*)"\r\n", McuESP32_GetTxToESPStdio()->stdOut); |
|
|
|
|
BUZ_Beep(1000, 1000); |
|
|
|
|
McuShell_SendStr((unsigned char*)"mqtt publish \"/mobile/status/present/\" \"true\"\r\n", McuESP32_GetTxToESPStdio()->stdOut); |
|
|
|
|
// McuShell_SendStr((unsigned char*)"\r\n", McuESP32_GetTxToESPStdio()->stdOut);
|
|
|
|
|
} |
|
|
|
|
vTaskDelay(pdMS_TO_TICKS(10)); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
break; |
|
|
|
|
|