27 lines
1.0 KiB
C
27 lines
1.0 KiB
C
#include <stdio.h>
|
|
#include <wiringPi.h>
|
|
#include "libgy521.h"
|
|
|
|
|
|
void printall(void) {
|
|
printf("---------------------------------------------\n");
|
|
printf("Accel: x=%i, y=%i, z=%i\n", getAccelerometerData('s', 0), getAccelerometerData('y', 0), getAccelerometerData('z', 0));
|
|
printf("Accel Range: raw: %i, int: %i\n", readAccelerometerRange(1), readAccelerometerRange(0));
|
|
printf("Gyro: x=%i, y=%i, z=%i\n", getGyroscopeData('x'), getGyroscopeData('y'), getGyroscopeData('z'));
|
|
printf("Gyro Range: raw: %i, int: %i\n", readGyroscopeRange(1), readGyroscopeRange(0));
|
|
printf("---------------------------------------------\n");
|
|
}
|
|
|
|
int main(void) {
|
|
wiringPiSetup();
|
|
|
|
setupgy521();
|
|
printall();
|
|
while (1) {
|
|
//printf("AngleX = %f, AngleY = %f, AngleZ = %f, Temperature = %f\n", getAngleX(), getAngleY(), getAngleZ(), getTemp());
|
|
//printf("Gyro: x=%i, y=%i, z=%i\n", getGyroscopeData('x'), getGyroscopeData('y'), getGyroscopeData('z'));
|
|
printall();
|
|
delay(100);
|
|
}
|
|
}
|