-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_gyroscope_data.c
50 lines (42 loc) · 1.2 KB
/
test_gyroscope_data.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <unistd.h>
#include <mraa/aio.h>
#include <stdio.h>
#include "floatfann.h"
int main()
{
int i;
int temp0, temp1, temp2, location;
uint16_t value0, value1, value2;
float max;
fann_type *calc_out;
fann_type input[3];
struct fann *ann;
mraa_aio_context lightsensor0, lightsensor1, lightsensor2;
ann = fann_create_from_file("TEST.net");
lightsensor0 = mraa_aio_init(0);
lightsensor1 = mraa_aio_init(1);
lightsensor2 = mraa_aio_init(2);
while (1) {
temp0 = 0;
temp1 = 0;
temp2 = 0;
max = -100;
for (i = 0; i < 50; i++) {
temp0 += mraa_aio_read(lightsensor0);
temp1 += mraa_aio_read(lightsensor1);
temp2 += mraa_aio_read(lightsensor2);
usleep(10000);
}
value0 = temp0 / 50;
value1 = temp1 / 50;
value2 = temp2 / 50;
input[0] = (float) value0 / 1000;
input[1] = (float) value1 / 1000;
input[2] = (float) value2 / 1000;
calc_out = fann_run(ann, input);
for (i = 0; i < 5; i++) {
if (calc_out[i] > max) {
max = calc_out[i];
location = i;
}
}