-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathteventraw.h
More file actions
55 lines (48 loc) · 1.56 KB
/
teventraw.h
File metadata and controls
55 lines (48 loc) · 1.56 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
54
55
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <iostream>
#include <string.h>
#include <errno.h>
#include <chrono.h>
#include <thread>
#include <future>
#include <linux/if_link.h>
// structure for event data on each pixel
struct EventData{
signed short sign = 0; // sign of change, +1 for positive, -1 for negative and 0 for no change
static std::chrono::time_point<std::chrono::system_clock> time; // timestamp the change was logged
// blank constructor
EventData(){
this->time = std::chrono::system_clock::now(); // set timestamp
}
// constructor passing
EventData(unsigned short sig){
this->time = std::chrono::system_clock::now(); // set timestamp
this->sign = sig; // set sign change
}
};
class ThermalEventRaw{
private:
int fd; // file descriptor
uint16_t out[632]; // output data
uint16_t last_out[632]; // last frame
std::future<void> f; // future for reading thread
bool stopFlag = false; // flag for stopping read thread
public:
EventData events[632]; // output array of EventData
signed short signs[632]; // output array of just
std::map<int,EventData> events; // map containing the change data
ThermalEventRaw(); // blank constructor
~ThermalEventRaw(); // deconstructor
int openDev(); // open device
void closeDev(); // close device
int update(); // read from device and update output
void updateLoop(); // function passed to thread
void start(); // reset stop flag and start thread
void stop(); // set stop flag
};