/
simple.cpp
56 lines (40 loc) · 1.48 KB
/
simple.cpp
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
51
52
53
54
55
56
#include "bindings.h"
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/utsname.h>
#include <unistd.h>
int main() {
struct utsname uts;
uname(&uts);
printf("Navigator C test, system details:\n");
printf("System is %s on %s hardware\n", uts.sysname, uts.machine);
printf("OS Release is %s\n", uts.release);
printf("OS Version is %s\n", uts.version);
const char *ci_env = std::getenv("CI");
if (ci_env && std::string(ci_env) == "true") {
printf("Running from CI\n");
printf("Not possible to test navigator sensors yet.\n");
return 0;
}
printf("Initiating navigator module.\n");
init();
printf("Setting led on!\n");
set_led(UserLed::Led1, true);
printf("Temperature: %f\n", read_temp());
printf("Pressure: %f\n", read_pressure());
printf("Leak sensor: %s\n", read_leak() ? "true" : "false");
ADCData adc = read_adc_all();
printf("Reading ADC Channels: 1 = %f, 2 = %f, 3 = %f, 4 = %f\n",
adc.channel[0], adc.channel[1], adc.channel[2], adc.channel[3]);
printf("Data ADC Channels: 1 = %f\n", read_adc(AdcChannel::Ch1));
AxisData mag = read_mag();
printf("Magnetic field: X = %f, Y = %f, Z = %f\n", mag.x, mag.y, mag.z);
AxisData accel = read_accel();
printf("Acceleration: X = %f, Y = %f, Z = %f\n", accel.x, accel.y, accel.z);
AxisData gyro = read_gyro();
printf("Gyroscope: X = %f, Y = %f, Z = %f\n", gyro.x, gyro.y, gyro.z);
printf("Setting led off!\n");
set_led(UserLed::Led1, false);
return 0;
}