Accelerometer eingebunden #1, Messung läuft in einem Thread
This commit is contained in:
21
main.c
21
main.c
@@ -2,23 +2,44 @@
|
||||
#include <stdlib.h>
|
||||
#include "player.h"
|
||||
#include "song.h"
|
||||
#include <wiringPi.h>
|
||||
#include "accelerometer.h"
|
||||
|
||||
|
||||
void shutdown(void) {
|
||||
//Diese Methode wird von beim beenden aufgerufen.
|
||||
printf("Auf Wiedersehen!\n");
|
||||
}
|
||||
|
||||
PI_THREAD (accelerometerupdater) {
|
||||
while (updateAccelerometerValue() == 0) {
|
||||
delay(500);
|
||||
}
|
||||
return 0; //Muss returned werden, da void *
|
||||
}
|
||||
|
||||
|
||||
int main(void) {
|
||||
int t1;
|
||||
atexit(shutdown);
|
||||
if (setupSoftTone() != 0) {
|
||||
printf("SoftTone konnte nicht initialisiert werden.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
t1 = piThreadCreate(accelerometerupdater);
|
||||
if (t1 != 0) {
|
||||
printf("Accelerometer Thread nicht gestartet.\n");
|
||||
}
|
||||
|
||||
//Intro
|
||||
play(intro, noteDurations, introlength);
|
||||
|
||||
|
||||
//Main theme
|
||||
play(melody, melodyNoteDurations, songlength);
|
||||
|
||||
//Accelerometer Thread beenden
|
||||
killAccelerometerMeasure();
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user