-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathled.hpp
More file actions
52 lines (43 loc) · 1.14 KB
/
led.hpp
File metadata and controls
52 lines (43 loc) · 1.14 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
#ifndef _LED_HPP
#define _LED_HPP
#include <pthread.h>
#include <mutex>
#include "pipe.hpp"
#include "gpio_out.hpp"
//TODO: perf optim with poll, or better: pwn
//TODO: good error management
class Led {
public:
static const char ON = 1;
static const char OFF = 2;
static const char BLINK_SLOWLY = 3;
static const char BLINK_QUICKLY = 4;
static const char BLINK_NUMBER = 5;
Led(int ledPin);
~Led();
void on();
void off();
void blinkSlowly();
void blinkQuickly();
void blinkNumber(unsigned int);
protected:
static const char QUIT = 6;
static const long SLOW_TIME = 300000;
static const long QUICK_TIME = 50000;
static const long NUMBER_TIME = 250000;
Pipe _pipe;
pthread_t _thread;
std::mutex _mut;
bool _isOn;
char _status;
GpioOut _pin;
unsigned int _blinkNumber;
unsigned int _blinkCount;
static void* _startBlinking(void*);
void _light(bool);
void _stopBlinking();
bool _blinking();
void _blink();
long _getBlinkDelay();
};
#endif // _LED_HPP