Esempio n. 1
0
File: Maze.c Progetto: FlavioK/intro
/*!
 * \brief Performs a turn.
 * \return Returns TRUE while turn is still in progress.
 */
uint8_t MAZE_EvaluteTurn(bool *finished, bool lefthand) {
	REF_LineKind historyLineKind, currLineKind;
	TURN_Kind turn;

	*finished = FALSE;
	currLineKind = REF_GetLineKind();
	if (currLineKind == REF_LINE_NONE) { /* nothing, must be dead end */
		turn = TURN_LEFT180;
	} else {
		MAZE_ClearSensorHistory(); /* clear history values */
		MAZE_SampleSensorHistory(); /* store current values */
		TURN_Turn(TURN_STEP_LINE_FW_POST_LINE, MAZE_SampleTurnStopFunction); /* do the line and beyond in one step */
		historyLineKind = MAZE_HistoryLineKind(); /* new read new values */
		currLineKind = REF_GetLineKind();
		turn = MAZE_SelectTurn(historyLineKind, currLineKind, lefthand);
	}
	if(turn != TURN_FINISHED){
		MAZE_AddPath(turn);
	}
	if (turn == TURN_FINISHED) {
		MAZE_SimplifyPath();
		MAZE_RevertPath();
		MAZE_SetSolved();
		TURN_Turn(TURN_LEFT180, NULL);
		*finished = TRUE;
		SHELL_SendString((unsigned char*) "MAZE: finished!\r\n");

		return ERR_OK;
	} else if (turn == TURN_STRAIGHT) {
		/*! \todo Extend if necessary */
		SHELL_SendString((unsigned char*) "going straight\r\n");
		return ERR_OK;
	} else if (turn == TURN_STOP) { /* should not happen here? */
		//LF_StopFollowing();
		SHELL_SendString((unsigned char*) "Failure, stopped!!!\r\n");
		return ERR_FAILED; /* error case */
	} else { /* turn or do something */
		/*! \todo Extend if necessary */
		TURN_Turn(turn, NULL);
		return ERR_OK; /* turn finished */
	}
}
Esempio n. 2
0
void MAZE_SetSolved(void) {
  isSolved = TRUE;
  /*! \todo here the path could be reverted */
  MAZE_RevertPath();
  MAZE_AddPath(TURN_STOP); /* add an action to stop */
}
Esempio n. 3
0
void MAZE_SetSolved(void) {
	MAZE_SimplifyPath();
	MAZE_RevertPath();
	isSolved = TRUE;
}
Esempio n. 4
0
void MAZE_SetSolved(void) {
  isSolved = TRUE;
  MAZE_RevertPath();
  MAZE_AddPath(TURN_STOP); /* add an action to stop */
}
Esempio n. 5
0
void MAZE_SetSolved(void) {
  isSolved = TRUE;
  MAZE_RevertPath();								// Pfad umkehren
  MAZE_SimplifyPath();								// Pfad vereinfachen
  indexPath = 0;									// Pfad Index Null
}