forked from matthew-t-watson/Picopter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimer.h
More file actions
54 lines (44 loc) · 1.02 KB
/
Timer.h
File metadata and controls
54 lines (44 loc) · 1.02 KB
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
/*
* File: Timer.h
* Author: matt
*
* Created on 05 November 2012, 10:19
*/
#ifndef TIMER_H
#define TIMER_H
#include <signal.h>
#include <sys/time.h>
#include <iostream>
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fstream>
#include "MPU6050.h"
#include "AHRS.h"
#include "Logger.h"
class TimerClass
{
public:
TimerClass();
TimerClass(const TimerClass& orig);
virtual ~TimerClass();
void start();
void stop();
float dt;
timer_t timerId; /* id for the posix timer */
struct sigaction signalAction; /* signal action handler struct */
bool started;
private:
static void sig_handler_(int signum);
struct itimerspec timeToSet_; /* time to be set */
struct timespec timeValue_; /* timer expiration value */
struct timespec timeInterval_; /* timer period */
timespec oldtime_;
timespec time_;
timespec iterationtime_;
void calcdt_();
void compensate_();
};
extern TimerClass Timer;
#endif /* TIMER_H */