15 |
|
class Display |
16 |
|
{ |
17 |
|
int ucom; |
18 |
+ |
Pthreads::ThreadMutex ucomLock; |
19 |
+ |
Pthreads::ThreadCondition ucomCondition; |
20 |
+ |
volatile bool running; |
21 |
|
struct Packet |
22 |
|
{ |
23 |
|
enum Command |
54 |
|
SetOrSetAndConfigureGPIOPin = 0x22, |
55 |
|
ReadGPIOPinLevelsAndConfigurationState = 0x23, |
56 |
|
Response = 0x40, |
57 |
+ |
Report = 0x80, |
58 |
|
KeyActivity = 0x80, |
59 |
|
FanSpeedReport = 0x81, |
60 |
|
TemperatureSensorReport = 0x82, |
71 |
|
|
72 |
|
inline std::string GetData() const { return std::string(reinterpret_cast<const char *>(data), length); } |
73 |
|
}; |
74 |
+ |
std::queue<Packet> responses; |
75 |
+ |
Pthreads::ThreadMutex responsesLock; |
76 |
+ |
Pthreads::ThreadCondition responsesCondition; |
77 |
|
std::queue<Packet> keyActivity; |
78 |
+ |
Pthreads::ThreadMutex keyActivityLock; |
79 |
|
Pthreads::Thread thread; |
80 |
|
|
81 |
|
inline Packet Communicate(Packet::Command command) { return Communicate_(command, 0, reinterpret_cast<const uint8_t *>(NULL)); } |
85 |
|
Packet Communicate(Packet::Command command, Arg0 arg0, Arg1 arg1); |
86 |
|
template <typename Arg0, typename Arg1, typename Arg2> |
87 |
|
Packet Communicate(Packet::Command command, Arg0 arg0, Arg1 arg1, Arg2 arg2); |
88 |
+ |
void Communicate_(); |
89 |
|
Packet Communicate_(Packet::Command command, uint8_t length, const uint8_t *data); |
90 |
|
|
91 |
|
public: |
111 |
|
Green = 1, |
112 |
|
Red = 0, |
113 |
|
}; |
114 |
+ |
enum KeyActivity |
115 |
+ |
{ |
116 |
+ |
None = 0, |
117 |
+ |
UpPress = 1, |
118 |
+ |
DownPress = 2, |
119 |
+ |
LeftPress = 3, |
120 |
+ |
RightPress = 4, |
121 |
+ |
EnterPress = 5, |
122 |
+ |
ExitPress = 6, |
123 |
+ |
UpRelease = 7, |
124 |
+ |
DownRelease = 8, |
125 |
+ |
LeftRelease = 9, |
126 |
+ |
RightRelease = 10, |
127 |
+ |
EnterRelease = 11, |
128 |
+ |
ExitRelease = 12, |
129 |
+ |
}; |
130 |
|
|
131 |
|
Display(const std::string &device); |
132 |
< |
~Display() { Posix::Close(ucom); } |
132 |
> |
~Display(); |
133 |
|
|
134 |
|
bool Ping(const std::string &data = std::string()); |
135 |
|
std::string Version(); |
142 |
|
inline void KeyReporting(uint8_t press, uint8_t release) { Communicate(Packet::ConfigureKeyReporting, press, release); } |
143 |
|
void Set(uint8_t column, uint8_t row, const std::string &data); |
144 |
|
void Set(uint8_t led, Color color, uint8_t brightness) { Communicate(Packet::SetOrSetAndConfigureGPIOPin, 12 - (led << 1) - color, brightness); } |
145 |
+ |
KeyActivity GetKeyActivity(); |
146 |
|
|
147 |
|
friend std::ostream &operator<<(std::ostream &output, const Packet &packet); |
148 |
|
friend void operator<<(int fd, const Display::Packet &packet); |