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 33 by douglas, 2008-02-29T19:05:18-08:00 vs.
Revision 38 by douglas, 2008-03-05T13:36:38-08:00

# Line 18 | Line 18 | class Display
18          Pthreads::ThreadMutex ucomLock;
19          Pthreads::ThreadCondition ucomCondition;
20          volatile bool running;
21 +
22          struct Packet
23          {
24                  enum Command
# Line 69 | Line 70 | class Display
70                  inline Packet() {}
71                  Packet(Command command, uint8_t length, const uint8_t *data);
72  
73 <                inline std::string GetData() const { return std::string(reinterpret_cast<const char *>(data), length); }
73 >                inline std::string GetData() const
74 >                {
75 >                        return std::string(reinterpret_cast<const char *>(data), length);
76 >                }
77          };
78 +
79          std::queue<Packet> responses;
80          Pthreads::ThreadMutex responsesLock;
81          Pthreads::ThreadCondition responsesCondition;
82          std::queue<Packet> keyActivity;
83          Pthreads::ThreadMutex keyActivityLock;
84 <        Pthreads::Thread thread;
84 >        Pthreads::ThreadCondition keyActivityCondition;
85 >
86 >        inline Packet Communicate(Packet::Command command)
87 >        {
88 >                return Communicate_(command, 0, reinterpret_cast<const uint8_t *>(NULL));
89 >        }
90  
81        inline Packet Communicate(Packet::Command command) { return Communicate_(command, 0, reinterpret_cast<const uint8_t *>(NULL)); }
91          template <typename Arg0>
92          Packet Communicate(Packet::Command command, Arg0 arg0);
93          template <typename Arg0, typename Arg1>
# Line 87 | Line 96 | class Display
96          Packet Communicate(Packet::Command command, Arg0 arg0, Arg1 arg1, Arg2 arg2);
97          void Communicate_();
98          Packet Communicate_(Packet::Command command, uint8_t length, const uint8_t *data);
99 +        void Activity();
100 +
101 + public:
102 +        enum KeyActivity
103 +        {
104 +                None                    = 0,
105 +                UpPress                 = 1,
106 +                DownPress               = 2,
107 +                LeftPress               = 3,
108 +                RightPress              = 4,
109 +                EnterPress              = 5,
110 +                ExitPress               = 6,
111 +                UpRelease               = 7,
112 +                DownRelease             = 8,
113 +                LeftRelease             = 9,
114 +                RightRelease    = 10,
115 +                EnterRelease    = 11,
116 +                ExitRelease             = 12,
117 +        };
118 +
119 +        typedef void (*Callback)(KeyActivity);
120 +
121 + private:
122 +        Callback callback;
123 +        Pthreads::Thread communicate, activity;
124  
125   public:
126          enum CursorStyle
# Line 97 | Line 131 | public:
131                  BlinkingBlockPlusUnderscore     = 3,
132                  InvertingBlinkingBlock          = 4,
133          };
134 +
135          enum Key
136          {
137                  Up              = 0x01,
# Line 106 | Line 141 | public:
141                  Right   = 0x10,
142                  Down    = 0x20,
143          };
144 +
145          enum Color
146          {
147                  Green   = 1,
148                  Red             = 0,
149          };
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        };
150  
151 <        Display(const std::string &device);
151 >        Display(const std::string &device, Callback callback = NULL);
152          ~Display();
153  
154          bool Ping(const std::string &data = std::string());
155          std::string Version();
156 <        inline void Store() { Communicate(Packet::StoreCurrentStateAsBootState); }
157 <        inline void Clear() { Communicate(Packet::ClearLCDScreen); }
158 <        inline void SetCursorPosition(uint8_t column, uint8_t row) { Communicate(Packet::SetLCDCursorPosition, column, row); }
159 <        inline void SetCursorStyle(CursorStyle style) { Communicate(Packet::SetLCDCursorStyle, style); }
160 <        inline void SetContrast(uint8_t contrast) { Communicate(Packet::SetLCDContrast, contrast); }
161 <        inline void SetBacklight(uint8_t backlight) { Communicate(Packet::SetLCDAndKeypadBacklight, backlight); }
162 <        inline void KeyReporting(uint8_t press, uint8_t release) { Communicate(Packet::ConfigureKeyReporting, press, release); }
156 >
157 >        inline void Store()
158 >        {
159 >                Communicate(Packet::StoreCurrentStateAsBootState);
160 >        }
161 >
162 >        inline void Clear()
163 >        {
164 >                Communicate(Packet::ClearLCDScreen);
165 >        }
166 >
167 >        inline void SetCursorPosition(uint8_t column, uint8_t row)
168 >        {
169 >                Communicate(Packet::SetLCDCursorPosition, column, row);
170 >        }
171 >
172 >        inline void SetCursorStyle(CursorStyle style)
173 >        {
174 >                Communicate(Packet::SetLCDCursorStyle, style);
175 >        }
176 >
177 >        inline void SetContrast(uint8_t contrast)
178 >        {
179 >                Communicate(Packet::SetLCDContrast, contrast);
180 >        }
181 >
182 >        inline void SetBacklight(uint8_t backlight)
183 >        {
184 >                Communicate(Packet::SetLCDAndKeypadBacklight, backlight);
185 >        }
186 >
187 >        inline void KeyReporting(uint8_t press, uint8_t release)
188 >        {
189 >                Communicate(Packet::ConfigureKeyReporting, press, release);
190 >        }
191 >
192          void Set(uint8_t column, uint8_t row, const std::string &data);
193 <        void Set(uint8_t led, Color color, uint8_t brightness) { Communicate(Packet::SetOrSetAndConfigureGPIOPin, 12 - (led << 1) - color, brightness); }
194 <        KeyActivity GetKeyActivity();
193 >
194 >        inline void Set(uint8_t led, Color color, uint8_t brightness)
195 >        {
196 >                Communicate(Packet::SetOrSetAndConfigureGPIOPin, 12 - (led << 1) - color, brightness);
197 >        }
198  
199          friend std::ostream &operator<<(std::ostream &output, const Packet &packet);
200          friend void operator<<(int fd, const Display::Packet &packet);
201          friend void operator>>(int fd, Display::Packet &packet);
202          friend void Communicate(Display *display);
203 +        friend void Activity(Display *display);
204   };
205  
206   template <typename Arg0>

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines