Appendix M: Pseudocode for Obtaining a Direction
The program continuously enters this routine checking to
see if a direction needs to be obtained.
-
Poll_Compass
-
IF (state equals waiting_for_direction)
-
IF (EOC is HIGH)
-
Clock in the first 8-bits of data from the compass
-
Save the LSB
-
Clock in the last 8-bits of data from the compass
-
Determine index into array based upon the data received
-
Determine if the steps are in the forward or reverse
direction
-
IF (direction is positive (i.e. 0 – 179 degrees))
-
Add the current Step_Count
-
to the newly indexed array element
-
ELSE
-
Subtract the current Step_Count
-
from newly indexed array element
-
ENDIF
-
Clear the Step_Count
-
Change state to indicate not waiting_for_direction
-
ENDIF
-
ENDIF
-
RETURN