forked from matthew-t-watson/Picopter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Timer.h
50 lines (40 loc) · 950 Bytes
/
Timer.h
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
/*
* File: Timer.h
* Author: matt
*
* Created on 05 November 2012, 10:19
*/
#ifndef TIMER_H
#define TIMER_H
#include <signal.h>
#include <iostream>
#include "MPU6050.h"
#include "AHRS.h"
#include "Logger.h"
#include "PICInterface.h"
#include "Control.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 */