-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtry.cpp
More file actions
51 lines (42 loc) · 979 Bytes
/
try.cpp
File metadata and controls
51 lines (42 loc) · 979 Bytes
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
#include <iostream>
#include "mgm.hpp"
#include <chrono>
#include <thread>
#include <signal.h>
#include <fstream>
using std::ofstream;
using std::cout;
using std::endl;
using std::cin;
using std::chrono::milliseconds;
using std::this_thread::sleep_for;
void do_shit(int s);
void printWTF();
int main(void) {
struct sigaction sigIntHandler;
sigIntHandler.sa_handler = do_shit;
sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);
ofstream file = ofstream("log.csv");
Magnetometer mgm = Magnetometer();
if (!mgm.ok) return 1;
mgm.calibrateMagnetometer();
float mx,
my,
mz;
printf("reading\n");
while (true) {
sleep_for(milliseconds(50));
mgm.GetMagnetValues(mx, my, mz);
file << mx << "," << my << "," << mz << "\n";
}
return 0;
}
void do_shit(int s) {
printWTF();
exit(1);
}
void printWTF() {
printf("hi\n");
}