int i=0; int j=0; int degree_prev,degree_now;
char* MOVES_MADE [1000][2];
void ROVER (int degree,char TypeOfMove[10]) {
i++;
int steps=degree;
int goal=0;
HMC6352.Wake();
degree_prev=HMC6352.GetHeading();
if (Type0fMove == "RIGHT" ) {
MOVES_MADE[i][0] = (char*)degree;
MOVES_MADE[i][1] = TypeOfMove;
while (goal < degree) {
MOVE.RIGHT(1);
degree_now=HMC6352.GetHeading();
if (degree_now - degree_prev >=0) goal = degree_now - degree_prev;
else if (degree_now - degree_prev < 0) goal = 360 - degree_prev + degree_now; //right
}
}
else if ( TypeOfMove == "LEFT" ) {
MOVES_MADE[i][0] = (char*)degree;
MOVES_MADE[i][1] = TypeOfMove;
while (goal < degree) {
MOVE.LEFT(1);
degree_now=HMC6352.GetHeading();
if (degree_prev-degree_now>=0) goal = degree_prev - degree_now;
else if (degree_prev-degree_now < 0) goal = degree_prev + 360 - abs(degree_now); //left
}
}
else if ( TypeOfMove == "FORWARD" ) {
MOVES_MADE[i][0] = (char*)steps;
MOVES_MADE[i][1] = TypeOfMove;
MOVE.FORWARD(steps);
}
HMC6352.Sleep();
}
Ok so basically i wanted to make a function which moves my rover, im using my own library so the "MOVE.LEFT(90)" is just me saying the rover to move left (in delays); Since i want to make it do precise moves im using the HMC6352 magnetometer.
The issue at hand , i want to save every move the rover makes and then from a different function make it go back to its original position. My only concer is the char* MOVES_MADE [1000][2]; array, i want to store in the first column the amount of degrees (int) and on the second column the type of move, how will i store an int to char* array ?