ref power save off

main
Simon Frei 4 years ago
parent d26a5b5a5a
commit bdf8e1c4e6
  1. 44
      ADIS_Sumo/Sumo/Application.c
  2. 7
      ADIS_Sumo/Sumo/Reflectance.c

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

@ -605,11 +605,12 @@ uint8_t REF_ParseCommand(const unsigned char *cmd, bool *handled, const McuShell
return ERR_OK; return ERR_OK;
} else if (McuUtility_strcmp((char*)cmd, "ref save power on")==0) { } else if (McuUtility_strcmp((char*)cmd, "ref save power on")==0) {
REF_Sensor.savePower = true; REF_Sensor.savePower = true;
McuGPIO_SetLow(REF_Sensor.irOn);; /* turn IR LED's off */ McuGPIO_SetLow(REF_Sensor.irOn); /* turn IR LED's off */
*handled = TRUE; *handled = TRUE;
return ERR_OK; return ERR_OK;
} else if (McuUtility_strcmp((char*)cmd, "ref save power off")==0) { } else if (McuUtility_strcmp((char*)cmd, "ref save power off")==0) {
REF_Sensor.savePower = false; REF_Sensor.savePower = false;
McuGPIO_SetHigh(REF_Sensor.irOn);
*handled = TRUE; *handled = TRUE;
return ERR_OK; return ERR_OK;
} }
@ -754,14 +755,14 @@ void REF_Init(void) {
}; };
REF_Sensor.isEnabled = true; REF_Sensor.isEnabled = true;
REF_Sensor.savePower = true; /* turn off, as this extends the ref sensor task time by around 200 us */ REF_Sensor.savePower = false; /* turn off, as this extends the ref sensor task time by around 200 us */
McuGPIO_GetDefaultConfig(&gpioConfig); McuGPIO_GetDefaultConfig(&gpioConfig);
/* IR on/off: PTD1, high active */ /* IR on/off: PTD1, high active */
gpioConfig.hw.gpio = GPIOD; gpioConfig.hw.gpio = GPIOD;
gpioConfig.hw.port = PORTD; gpioConfig.hw.port = PORTD;
gpioConfig.hw.pin = 1; gpioConfig.hw.pin = 1;
gpioConfig.isInput = false; gpioConfig.isInput = false;
gpioConfig.isHighOnInit = false; gpioConfig.isHighOnInit = true;
REF_Sensor.irOn = McuGPIO_InitGPIO(&gpioConfig); REF_Sensor.irOn = McuGPIO_InitGPIO(&gpioConfig);
REF_LedOn = false; REF_LedOn = false;
/* IR sensors */ /* IR sensors */

Loading…
Cancel
Save