Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Revision:
20:82836745332e
Parent:
17:f713758f6238
Child:
26:d20f1adac2d3
--- a/main.h	Mon May 15 00:54:41 2017 +0000
+++ b/main.h	Wed May 17 02:01:34 2017 +0000
@@ -85,4 +85,31 @@
 QEI encoder0( PA_5, PB_3, NC, PULSES, QEI::X4_ENCODING );
 QEI encoder1( PA_1, PA_0, NC, PULSES, QEI::X4_ENCODING );
 
+#define F_WALL 0x1
+#define L_WALL 0x2
+#define R_WALL 0x4
+#define B_WALL 0x8
+
+int currDir = 100;              // modulo this to keep track of the current direction of the mouse!
+int wallArray[16][16] = {0};    // array to keep track of the walls
+int mouseLoc[16][16] = {0};     // array to keep track of the mouse's current location
+int manhattanDist[16][16] = {
+                                  {14, 13, 12, 11, 10, 9, 8, 7, 7, 8, 9, 10, 11, 12, 13, 14},
+                                  {13, 12, 11, 10, 9, 8, 7, 6, 6, 7, 8, 9, 10, 11, 12, 13},
+                                  {12, 11, 10, 9, 8, 7, 6, 5, 5, 6, 7, 8, 9, 10, 11, 12},
+                                  {11, 10, 9, 8, 7, 6, 5, 4, 4, 5, 6, 7, 8, 9, 10, 11},
+                                  {10, 9, 8, 7, 6, 5, 4, 3, 3, 4, 5, 6, 7, 8, 9, 10},
+                                  {9, 8, 7, 6, 5, 4, 3, 2, 2, 3, 4, 5, 6, 7, 8, 9},
+                                  {8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8},
+                                  {7, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 7},
+                                  {7, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 7},
+                                  {8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8},
+                                  {9, 8, 7, 6, 5, 4, 3, 2, 2, 3, 4, 5, 6, 7, 8, 9},
+                                  {10, 9, 8, 7, 6, 5, 4, 3, 3, 4, 5, 6, 7, 8, 9, 10},
+                                  {11, 10, 9, 8, 7, 6, 5, 4, 4, 5, 6, 7, 8, 9, 10, 11},
+                                  {12, 11, 10, 9, 8, 7, 6, 5, 5, 6, 7, 8, 9, 10, 11, 12},
+                                  {13, 12, 11, 10, 9, 8, 7, 6, 6, 7, 8, 9, 10, 11, 12, 13},
+                                  {14, 13, 12, 11, 10, 9, 8, 7, 7, 8, 9, 10, 11, 12, 13, 14},
+                          };
+
 #endif
\ No newline at end of file