asdf

Dependencies:   L3GD20 LSM303DLHC mbed

Committer:
goy5022
Date:
Thu Apr 03 23:57:31 2014 +0000
Revision:
7:95ebadc83fc7
gal's about to fuck with it

Who changed what in which revision?

UserRevisionLine numberNew contents of line
goy5022 7:95ebadc83fc7 1 #ifndef Movement_H
goy5022 7:95ebadc83fc7 2 #define Movement_H
goy5022 7:95ebadc83fc7 3
goy5022 7:95ebadc83fc7 4 #include "Sensors.h"
goy5022 7:95ebadc83fc7 5 #include "Motors.h"
goy5022 7:95ebadc83fc7 6
goy5022 7:95ebadc83fc7 7
goy5022 7:95ebadc83fc7 8
goy5022 7:95ebadc83fc7 9 void moveNORTH()
goy5022 7:95ebadc83fc7 10 {
goy5022 7:95ebadc83fc7 11 switch(orientation)
goy5022 7:95ebadc83fc7 12 {
goy5022 7:95ebadc83fc7 13 case NORTH:
goy5022 7:95ebadc83fc7 14 // go forward...
goy5022 7:95ebadc83fc7 15 break;
goy5022 7:95ebadc83fc7 16 case WEST:
goy5022 7:95ebadc83fc7 17 // turn right then forward
goy5022 7:95ebadc83fc7 18 break;
goy5022 7:95ebadc83fc7 19 case SOUTH:
goy5022 7:95ebadc83fc7 20 // turn around then forward
goy5022 7:95ebadc83fc7 21 break;
goy5022 7:95ebadc83fc7 22 case EAST:
goy5022 7:95ebadc83fc7 23 // turn left then forward
goy5022 7:95ebadc83fc7 24 break;
goy5022 7:95ebadc83fc7 25 }
goy5022 7:95ebadc83fc7 26 orientation = NORTH;
goy5022 7:95ebadc83fc7 27 }
goy5022 7:95ebadc83fc7 28 void moveSOUTH()
goy5022 7:95ebadc83fc7 29 {
goy5022 7:95ebadc83fc7 30 switch(orientation)
goy5022 7:95ebadc83fc7 31 {
goy5022 7:95ebadc83fc7 32 case NORTH:
goy5022 7:95ebadc83fc7 33 // turn around then forward...
goy5022 7:95ebadc83fc7 34 break;
goy5022 7:95ebadc83fc7 35 case WEST:
goy5022 7:95ebadc83fc7 36 // turn left then forward
goy5022 7:95ebadc83fc7 37 break;
goy5022 7:95ebadc83fc7 38 case SOUTH:
goy5022 7:95ebadc83fc7 39 // go forward
goy5022 7:95ebadc83fc7 40 break;
goy5022 7:95ebadc83fc7 41 case EAST:
goy5022 7:95ebadc83fc7 42 // turn right then forward
goy5022 7:95ebadc83fc7 43 break;
goy5022 7:95ebadc83fc7 44 }
goy5022 7:95ebadc83fc7 45 orientation = SOUTH;
goy5022 7:95ebadc83fc7 46 }
goy5022 7:95ebadc83fc7 47 void moveEAST()
goy5022 7:95ebadc83fc7 48 {
goy5022 7:95ebadc83fc7 49 switch(orientation)
goy5022 7:95ebadc83fc7 50 {
goy5022 7:95ebadc83fc7 51 case NORTH:
goy5022 7:95ebadc83fc7 52 // turn right then forward...
goy5022 7:95ebadc83fc7 53 break;
goy5022 7:95ebadc83fc7 54 case WEST:
goy5022 7:95ebadc83fc7 55 // turn around then foward
goy5022 7:95ebadc83fc7 56 break;
goy5022 7:95ebadc83fc7 57 case SOUTH:
goy5022 7:95ebadc83fc7 58 // turn left then forward
goy5022 7:95ebadc83fc7 59 break;
goy5022 7:95ebadc83fc7 60 case EAST:
goy5022 7:95ebadc83fc7 61 // go forward
goy5022 7:95ebadc83fc7 62 break;
goy5022 7:95ebadc83fc7 63 }
goy5022 7:95ebadc83fc7 64 orientation = EAST;
goy5022 7:95ebadc83fc7 65 }
goy5022 7:95ebadc83fc7 66 void moveWEST()
goy5022 7:95ebadc83fc7 67 {
goy5022 7:95ebadc83fc7 68 switch(orientation)
goy5022 7:95ebadc83fc7 69 {
goy5022 7:95ebadc83fc7 70 case NORTH:
goy5022 7:95ebadc83fc7 71 // turn left then forward...
goy5022 7:95ebadc83fc7 72 break;
goy5022 7:95ebadc83fc7 73 case WEST:
goy5022 7:95ebadc83fc7 74 // go forward
goy5022 7:95ebadc83fc7 75 break;
goy5022 7:95ebadc83fc7 76 case SOUTH:
goy5022 7:95ebadc83fc7 77 // turn left then forward
goy5022 7:95ebadc83fc7 78 break;
goy5022 7:95ebadc83fc7 79 case EAST:
goy5022 7:95ebadc83fc7 80 // turn around then forward
goy5022 7:95ebadc83fc7 81 break;
goy5022 7:95ebadc83fc7 82 }
goy5022 7:95ebadc83fc7 83 orientation = WEST;
goy5022 7:95ebadc83fc7 84 }
goy5022 7:95ebadc83fc7 85
goy5022 7:95ebadc83fc7 86 //////////////////////////////////////////////////////////////////////
goy5022 7:95ebadc83fc7 87
goy5022 7:95ebadc83fc7 88 void Move()
goy5022 7:95ebadc83fc7 89 {
goy5022 7:95ebadc83fc7 90
goy5022 7:95ebadc83fc7 91 switch(flood_findPath(Xpos, Ypos))
goy5022 7:95ebadc83fc7 92 {
goy5022 7:95ebadc83fc7 93 case M_NORTH:
goy5022 7:95ebadc83fc7 94 moveNORTH();
goy5022 7:95ebadc83fc7 95 break;
goy5022 7:95ebadc83fc7 96
goy5022 7:95ebadc83fc7 97 case M_SOUTH:
goy5022 7:95ebadc83fc7 98 moveSOUTH();
goy5022 7:95ebadc83fc7 99 break;
goy5022 7:95ebadc83fc7 100
goy5022 7:95ebadc83fc7 101 case M_WEST:
goy5022 7:95ebadc83fc7 102 moveWEST();
goy5022 7:95ebadc83fc7 103 break;
goy5022 7:95ebadc83fc7 104
goy5022 7:95ebadc83fc7 105 case M_EAST:
goy5022 7:95ebadc83fc7 106 moveEAST();
goy5022 7:95ebadc83fc7 107 break;
goy5022 7:95ebadc83fc7 108
goy5022 7:95ebadc83fc7 109 }
goy5022 7:95ebadc83fc7 110 }
goy5022 7:95ebadc83fc7 111
goy5022 7:95ebadc83fc7 112
goy5022 7:95ebadc83fc7 113 #endif