Functions to retrieve heading information from the ADI gyroscope. More...
Functions | |
void | gyro_init (uint8_t port, float lsb_us_per_deg, uint32_t time_ms) |
int | gyro_update (void) |
float | gyro_get_rotation (void) |
float | gyro_get_degrees (void) |
void | gyro_set_degrees (float deg) |
The gyro is plugged into 4 of the analog ports on the Happyboard. It should not be used with analog_read(); instead use the provided gyro functions. Please see gyrotest for an example of correct gyro usage. You will need to wait pause half a second before calling gyro_init (which should be called in usetup).
float gyro_get_degrees | ( | void | ) |
returns the current heading, modified to be a float between -179 and 180
float gyro_get_rotation | ( | void | ) |
Returns the current heading of an initialized gyroscope. This will not wrap; in other words, if you turn counterclockwise twice, you will get a reading of 720 degrees.
void gyro_init | ( | uint8_t | port, |
float | lsb_us_per_deg, | ||
uint32_t | time_ms | ||
) |
Initialize and calibrate the gyro located at `port'.
port | Analog port number of the gyroscope. This refers to the leftmost port of the 4 analog ports used. |
lsb_us_per_deg | Constant for converting readings into degrees. Typical value for gyro module Rev. B is 1400000. |
time_ms | Time (in milliseconds) for calibrating gyro. |
void gyro_set_degrees | ( | float | deg | ) |
Sets the gyro to a specified degree. This is useful when used in conjuction with PID controlled loops that turn specified number of degrees--you can reset the gyro reading between distinct turning phases of nagivation.
deg | The degree value that you wish to set the gyro to read. |
int gyro_update | ( | void | ) |
Internal routine for updating gyroscope. Don't call this unless you know what you're doing.