Accelerometer hinzugefügt (ungetestet)
This commit is contained in:
25
accelerometer.c
Normal file
25
accelerometer.c
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#include "accelerometer.h"
|
||||||
|
#include <libgy521.h>
|
||||||
|
#include <math.h> //for fabs
|
||||||
|
|
||||||
|
void setupAccelerometer(void) {
|
||||||
|
setupgy521();
|
||||||
|
}
|
||||||
|
|
||||||
|
float getaccelerometerdata(void) {
|
||||||
|
float xyz[] = {getAccelerometerData('x', 1), getAccelerometerData('y', 1), getAccelerometerData('z', 1)};
|
||||||
|
float temp;
|
||||||
|
int i, z;
|
||||||
|
|
||||||
|
for (i = 0, i < 3; i++) {
|
||||||
|
for (z = 0; z < 3 - i; z++) {
|
||||||
|
if (xyz[z] < xyz[z + 1]) {
|
||||||
|
temp = xyz[z];
|
||||||
|
xyz[z] = xyz[z + 1];
|
||||||
|
xyz[z + 1] = temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return fabs(xyz[0]); //Absolutwert fuer float
|
||||||
|
}
|
2
accelerometer.h
Normal file
2
accelerometer.h
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
void setupAccelerometer(void);
|
||||||
|
float getaccelerometerdata(void);
|
2
makefile
2
makefile
@@ -4,7 +4,7 @@ CFLAGS = -Wall -g -D_REENTRANT -DVERSION=\"$(VERSION)\"
|
|||||||
|
|
||||||
LDFLAGS = -lwiringPi -lpthread
|
LDFLAGS = -lwiringPi -lpthread
|
||||||
|
|
||||||
OBJ = main.o player.o
|
OBJ = main.o player.o accelerometer.o
|
||||||
|
|
||||||
pi2ezoplayer: $(OBJ)
|
pi2ezoplayer: $(OBJ)
|
||||||
$(CC) $(CFLAGS) -o pi2ezoplayer $(OBJ) $(LDFLAGS)
|
$(CC) $(CFLAGS) -o pi2ezoplayer $(OBJ) $(LDFLAGS)
|
||||||
|
Reference in New Issue
Block a user