Code to run the microcontrollers on the R5 competition bot

Dependencies:   LineSensors mbed

Revision:
15:150ec9448efc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/navcontroller.h	Sat Apr 18 02:54:55 2015 +0000
@@ -0,0 +1,47 @@
+#ifndef NAVCONTROLLER_H
+#define NAVCONTROLLER_H
+
+#include "r5map.h"
+#include <stack>
+#include <vector>
+
+#define SENS_FORWARD 7
+#define SENS_RIGHT 0
+#define SENS_BACK 2
+#define SENS_LEFT 3
+#define STEP 4
+#define STEP_DIR 5
+#define FRDM_ADD 0x0A
+
+class NavController
+{
+	public:
+	NavController(int mapSize = 5);
+	void explore(); 					//moves bot through the unknown maze
+	void goBack(); 						//returns bot to the origin
+	void saveMap();						//saves map information to file
+	void pinWrite(int, int);
+	void waitingForInterrupt(int, int);
+	void testWithDelay();
+	void tesetWithoutDelay();
+
+	private:
+	typename ::position end;
+	typename ::direction nextExploreMove(); 		//calculates the next move in maze exploration
+	void sendMove(typename ::direction next);					//sends a move command to the freedom board via i2c
+	void updateMap();					//records all the sensor information into the map object
+	bool readSensor(typename ::direction wall);	//returns true if there is a wall in direction "wall"
+	char readWall(typename ::direction wall);		//returns the character written on the wall in the direction of 'wall'
+	vector<char> readWalls();			//returns a char vector of the symbols on the walls
+
+	typename ::R5Map map;
+	typename ::direction orient;					//current orientation of the bot
+	typename ::direction camorient;
+	stack<typename ::direction> path;				//a record of the bots path
+	int frdm_i2c;
+	void initIO();
+	void turnCam(typename ::direction wall);
+	void resetCam();
+};
+
+#endif