ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/truck/DashInterface/Display.hpp
Revision: 28
Committed: 2008-02-25T21:13:59-08:00 (17 years, 3 months ago) by douglas
File size: 3070 byte(s)
Log Message:
Progress...

File Contents

# Content
1 // Display (Crystalfontz CFA-635 USB LCD)
2 //
3 // Douglas Thrift
4 //
5 // $Id$
6
7 #ifndef _Display_hpp_
8 #define _Display_hpp_
9
10 #include <posix.hpp>
11 #include <truck.hpp>
12
13 #include <queue>
14
15 class Display
16 {
17 int ucom;
18 struct Packet
19 {
20 enum Command
21 {
22 PingCommand = 0x00,
23 GetHardwareAndFirmwareVersion = 0x01,
24 WriteUserFlashArea = 0x02,
25 ReadUserFlashArea = 0x03,
26 StoreCurrentStateAsBootState = 0x04,
27 RebootResetHostOrPowerOffHost = 0x05,
28 ClearLCDScreen = 0x06,
29 SetLCDSpecialCharacterData = 0x09,
30 Read8ByesOfLCDMemory = 0x0a,
31 SetLCDCursorPosition = 0x0b,
32 SetLCDCursorStyle = 0x0c,
33 SetLCDContrast = 0x0d,
34 SetLCDAndKeypadBacklight = 0x0e,
35 SetUpFanReporting = 0x10,
36 SetFanPower = 0x11,
37 ReadDOWDeviceInformation = 0x12,
38 SetUpTemperatureReporting = 0x13,
39 ArbitraryDOWTransaction = 0x14,
40 SendCommandDirectlyToTheLCDController = 0x16,
41 ConfigureKeyReporting = 0x17,
42 ReadKeypad = 0x18,
43 SetFanPowerFailSafe = 0x19,
44 SetFanTachometerGlitchFilter = 0x1a,
45 QueryFanPowerAndFailSafeMask = 0x1b,
46 SetATXPowerSwitchFunctionality = 0x1c,
47 EnableDisableAndResetTheWatchdog = 0x1d,
48 ReadReportingAndStatus = 0x1e,
49 SendDataToLCD = 0x1f,
50 SetBaudRate = 0x21,
51 SetOrSetAndConfigureGPIOPin = 0x22,
52 ReadGPIOPinLevelsAndConfigurationState = 0x23,
53 Response = 0x40,
54 KeyActivity = 0x80,
55 FanSpeedReport = 0x81,
56 TemperatureSensorReport = 0x82,
57 Error = 0xc0,
58 };
59
60 uint8_t command;
61 uint8_t length;
62 uint8_t data[22];
63 uint16_t crc;
64
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_

Properties

Name Value
svn:keywords Id