ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/truck/DashInterface/Display.hpp
(Generate patch)

Comparing DashInterface/Display.hpp (file contents):
Revision 28 by douglas, 2008-02-25T21:13:59-08:00 vs.
Revision 29 by douglas, 2008-02-27T16:09:18-08:00

# Line 69 | Line 69 | class Display
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())); }
72 >        inline Packet Communicate(Packet::Command command) { return Communicate_(command, 0, reinterpret_cast<const uint8_t *>(NULL)); }
73 >        template <typename Arg0>
74 >        Packet Communicate(Packet::Command command, Arg0 arg0);
75 >        template <typename Arg0, typename Arg1>
76 >        Packet Communicate(Packet::Command command, Arg0 arg0, Arg1 arg1);
77 >        template <typename Arg0, typename Arg1, typename Arg2>
78 >        Packet Communicate(Packet::Command command, Arg0 arg0, Arg1 arg1, Arg2 arg2);
79 >        Packet Communicate_(Packet::Command command, uint8_t length, const uint8_t *data);
80  
81   public:
82          enum CursorStyle
83          {
84 <                NoCursor,
85 <                BlinkingBlockCursor,
86 <                UnderscoreCursor,
87 <                BlinkingBlockPlusUnderscore,
88 <                InvertingBlinkingBlock
84 >                NoCursor                                        = 0,
85 >                BlinkingBlockCursor                     = 1,
86 >                UnderscoreCursor                        = 2,
87 >                BlinkingBlockPlusUnderscore     = 3,
88 >                InvertingBlinkingBlock          = 4,
89          };
90          enum Key
91          {
# Line 90 | Line 96 | public:
96                  Right   = 0x10,
97                  Down    = 0x20,
98          };
99 +        enum Color
100 +        {
101 +                Green   = 1,
102 +                Red             = 0,
103 +        };
104  
105          Display(const std::string &device);
106          ~Display() { Posix::Close(ucom); }
# Line 98 | Line 109 | public:
109          std::string Version();
110          inline void Store() { Communicate(Packet::StoreCurrentStateAsBootState); }
111          inline void Clear() { Communicate(Packet::ClearLCDScreen); }
112 <        void SetCursorPosition(uint8_t column, uint8_t row);
113 <        void SetCursorStyle(CursorStyle style);
114 <        inline void SetContrast(uint8_t contrast) { Communicate(Packet::SetLCDContrast, 1, &contrast); }
115 <        inline void SetBacklight(uint8_t backlight) { Communicate(Packet::SetLCDAndKeypadBacklight, 1, &backlight); }
116 <        inline void KeyReporting(uint8_t press, uint8_t release);
112 >        inline void SetCursorPosition(uint8_t column, uint8_t row) { Communicate(Packet::SetLCDCursorPosition, column, row); }
113 >        inline void SetCursorStyle(CursorStyle style) { Communicate(Packet::SetLCDCursorStyle, style); }
114 >        inline void SetContrast(uint8_t contrast) { Communicate(Packet::SetLCDContrast, contrast); }
115 >        inline void SetBacklight(uint8_t backlight) { Communicate(Packet::SetLCDAndKeypadBacklight, backlight); }
116 >        inline void KeyReporting(uint8_t press, uint8_t release) { Communicate(Packet::ConfigureKeyReporting, press, release); }
117 >        void Set(uint8_t column, uint8_t row, const std::string &data);
118 >        void Set(uint8_t led, Color color, uint8_t brightness) { Communicate(Packet::SetOrSetAndConfigureGPIOPin, 12 - (led << 1) - color, brightness); }
119   };
120  
121 + template <typename Arg0>
122 + inline Display::Packet Display::Communicate(Packet::Command command, Arg0 arg0)
123 + {
124 +        uint8_t data(arg0);
125 +
126 +        return Communicate_(command, 1, &data);
127 + }
128 +
129 + template <>
130 + inline Display::Packet Display::Communicate(Packet::Command command, const std::string &string)
131 + {
132 +        return Communicate_(command, string.size(), reinterpret_cast<const uint8_t *>(string.data()));
133 + }
134 +
135 + template <typename Arg0, typename Arg1>
136 + inline Display::Packet Display::Communicate(Packet::Command command, Arg0 arg0, Arg1 arg1)
137 + {
138 +        uint8_t data[] = { arg0, arg1 };
139 +
140 +        return Communicate_(command, 2, data);
141 + }
142 +
143 + template <typename Arg0, typename Arg1, typename Arg2>
144 + inline Display::Packet Display::Communicate(Packet::Command command, Arg0 arg0, Arg1 arg1, Arg2 arg2)
145 + {
146 +        uint8_t data[] = { arg0, arg1, arg2 };
147 +
148 +        return Communicate_(command, 2, data);
149 + }
150 +
151 + template <>
152 + inline Display::Packet Display::Communicate(Packet::Command command, uint8_t arg0, uint8_t arg1, const std::string &string)
153 + {
154 +        uint8_t data[] = { arg0, arg1 };
155 +
156 +        return Communicate_(command, 2 + string.size(), reinterpret_cast<const uint8_t *>((reinterpret_cast<const char *>(data) + string).data()));
157 + }
158 +
159   #endif//_Display_hpp_

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines