-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgpio_button_manager.hpp
More file actions
48 lines (37 loc) · 1.08 KB
/
gpio_button_manager.hpp
File metadata and controls
48 lines (37 loc) · 1.08 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
#ifndef _GPIO_BUTTON_MANAGER_HPP
#define _GPIO_BUTTON_MANAGER_HPP
#include <pthread.h>
#include <sys/timerfd.h>
#include <mutex>
#include <map>
#include <vector>
#include <poll.h>
#include "pipe.hpp"
class GpioButton;
class GpioButtonManager {
public:
static bool add(GpioButton *);
static void remove(GpioButton *);
static void onButtonTimerChanged();
protected:
static GpioButtonManager* _instance;
static std::mutex _mut;
static std::map<int, GpioButton*> _btns;
static const char EXIT = 1;
static const char BUTTON_CHANGED = 2;
static const char BUTTON_LIST_CHANGED = 3;
GpioButtonManager();
~GpioButtonManager();
static void* _startRun(void* manager);
void _run();
int _initFdList(pollfd*);
void _resetLocalList();
void _initTimerFd();
void _clearTimer(int timerFd);
Pipe _pipe;
int _timerFd;
itimerspec _interval;
pthread_t _thread;
std::vector<GpioButton*> _localBtns;
};
#endif // _GPIO_BUTTON_MANAGER_HPP