Added example, added makefile

This commit is contained in:
2016-09-04 20:58:29 +02:00
parent 9b87fcc68c
commit 84d9a3d3a7
3 changed files with 42 additions and 6 deletions

View File

@@ -1,7 +1,9 @@
#include <wiringPi.h>
//#include <wiringPi.h>
#include <wiringPiI2C.h>
#include <math.h>
#include <libgy521.h>
#include <stdio.h>
#include <stdlib.h>
#include "libgy521.h"
//Constants
@@ -19,12 +21,12 @@
int id;
int setupgy521(void) {
if (id = wiringPiI2CSetup(MPU6050_I2C_ADDRESS) != -1) {
if ((id = wiringPiI2CSetup(MPU6050_I2C_ADDRESS)) != -1) {
wiringPiI2CReadReg8(id, MPU6050_PWR_MGMT_1);
wiringPiI2CWriteReg16(id, MPU6050_PWR_MGMT_1, 0);
return EXIT_SUCCESS;
} else {
return EXIT_FAILURE
return EXIT_FAILURE;
}
}
@@ -70,5 +72,5 @@ float getAngleZ(void) {
int x = getAccelX();
int y = getAccelY();
int z = getAccelZ();
return atan((sqrt(po(y, 2) + pow(x, 2))) / z) * 180.0 / M_PI;
return atan((sqrt(pow(y, 2) + pow(x, 2))) / z) * 180.0 / M_PI;
}