10 |
|
#include <posix.hpp> |
11 |
|
#include <truck.hpp> |
12 |
|
|
13 |
+ |
#include <queue> |
14 |
+ |
|
15 |
|
class Display |
16 |
|
{ |
17 |
|
int ucom; |
31 |
|
SetLCDCursorPosition = 0x0b, |
32 |
|
SetLCDCursorStyle = 0x0c, |
33 |
|
SetLCDContrast = 0x0d, |
34 |
< |
SetLCDKeypadAndBacklight = 0x0e, |
34 |
> |
SetLCDAndKeypadBacklight = 0x0e, |
35 |
|
SetUpFanReporting = 0x10, |
36 |
|
SetFanPower = 0x11, |
37 |
|
ReadDOWDeviceInformation = 0x12, |
62 |
|
uint8_t data[22]; |
63 |
|
uint16_t crc; |
64 |
|
|
65 |
< |
Packet() {} |
66 |
< |
Packet(Command command, const std::string &data = std::string()); |
65 |
> |
inline Packet() {} |
66 |
> |
Packet(Command command, uint8_t length, const uint8_t *data); |
67 |
> |
|
68 |
> |
inline std::string GetData() { return std::string(reinterpret_cast<char *>(data), length); } |
69 |
|
}; |
70 |
+ |
std::queue<Packet> keyActivity; |
71 |
+ |
|
72 |
+ |
Packet Communicate(Packet::Command command, uint8_t length = 0, const uint8_t *data = NULL); |
73 |
+ |
inline Packet Communicate(Packet::Command command, const std::string &data) { return Communicate(command, data.size(), reinterpret_cast<const uint8_t *>(data.data())); } |
74 |
|
|
75 |
|
public: |
76 |
+ |
enum CursorStyle |
77 |
+ |
{ |
78 |
+ |
NoCursor, |
79 |
+ |
BlinkingBlockCursor, |
80 |
+ |
UnderscoreCursor, |
81 |
+ |
BlinkingBlockPlusUnderscore, |
82 |
+ |
InvertingBlinkingBlock |
83 |
+ |
}; |
84 |
+ |
enum Key |
85 |
+ |
{ |
86 |
+ |
Up = 0x01, |
87 |
+ |
Enter = 0x02, |
88 |
+ |
Cancel = 0x04, |
89 |
+ |
Left = 0x08, |
90 |
+ |
Right = 0x10, |
91 |
+ |
Down = 0x20, |
92 |
+ |
}; |
93 |
+ |
|
94 |
|
Display(const std::string &device); |
95 |
|
~Display() { Posix::Close(ucom); } |
96 |
|
|
97 |
|
bool Ping(const std::string &data = std::string()); |
98 |
+ |
std::string Version(); |
99 |
+ |
inline void Store() { Communicate(Packet::StoreCurrentStateAsBootState); } |
100 |
+ |
inline void Clear() { Communicate(Packet::ClearLCDScreen); } |
101 |
+ |
void SetCursorPosition(uint8_t column, uint8_t row); |
102 |
+ |
void SetCursorStyle(CursorStyle style); |
103 |
+ |
inline void SetContrast(uint8_t contrast) { Communicate(Packet::SetLCDContrast, 1, &contrast); } |
104 |
+ |
inline void SetBacklight(uint8_t backlight) { Communicate(Packet::SetLCDAndKeypadBacklight, 1, &backlight); } |
105 |
+ |
inline void KeyReporting(uint8_t press, uint8_t release); |
106 |
|
}; |
107 |
|
|
108 |
|
#endif//_Display_hpp_ |