getGyroscopeData, readGyroscopeRange, setGyroscopeRange, extended example

This commit is contained in:
2016-09-09 21:41:50 +02:00
parent 06753bc2b1
commit db41cd547b
3 changed files with 174 additions and 49 deletions

View File

@@ -2,13 +2,25 @@
#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("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);
}
}