-
Notifications
You must be signed in to change notification settings - Fork 1
/
IOcontrol.h
50 lines (40 loc) · 1005 Bytes
/
IOcontrol.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
50
/**
* @file IOcontrol.cpp
* @Author BeeeOn team
* @date
* @brief
*/
#ifndef IOCONTROL_H
#define IOCONTROL_H
#include <thread>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <fcntl.h>
#include <linux/input.h>
#include <unistd.h>
#include "utils.h"
#define BITS_PER_LONG (sizeof(long) * 8)
#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
#define OFF(x) ((x)%BITS_PER_LONG)
#define BIT(x) (1UL<<OFF(x))
#define LONG(x) ((x)/BITS_PER_LONG)
#define test_bit(bit, array) ((array[LONG(bit)] >> OFF(bit)) & 1)
#ifndef EV_SYN
#define EV_SYN 0
#endif
extern bool quit_global_flag;
int waitForEvent(void (*)(int));
#ifndef PC_PLATFORM
/**
* Class for LED control
*/
class LEDControl {
public:
static void initLED(std::string led);
static void blinkLED(std::string led, unsigned int blinks_count=5);
static void setLED(std::string led, bool val, long int timeout=0);
static void setLEDAfterTimeout(std::string led, bool val, long int timeout);
};
#endif
#endif /* IOCONTROL_H */