MythTV master
lcddevice.h
Go to the documentation of this file.
1#ifndef LCDDEVICE_H_
2#define LCDDEVICE_H_
3
4#include <utility>
5
6// Qt headers
7#include <QList>
8#include <QRecursiveMutex>
9#include <QObject>
10#include <QStringList>
11
12class QTimer;
13
14// MythTV headers
15#include "mythbaseexp.h"
16
17enum CHECKED_STATE : std::uint8_t {CHECKED = 0, UNCHECKED, NOTCHECKABLE };
18
19class QTcpSocket;
20
22{
23 public:
24 LCDMenuItem(bool item_selected, CHECKED_STATE item_checked,
25 QString item_name, unsigned int item_indent = 0,
26 bool item_scroll = false) :
27 m_selected(item_selected), m_checked(item_checked),
28 m_name(std::move(item_name)), m_scroll(item_scroll),
29 m_indent(item_indent), m_scrollPosition(item_indent)
30 {
31 }
32
33 CHECKED_STATE isChecked() const { return m_checked; }
34 bool isSelected() const { return m_selected; }
35 QString ItemName() const { return m_name; }
36 bool Scroll() const { return m_scroll; }
37 unsigned int getIndent() const { return m_indent; }
38 unsigned int getScrollPos() const { return m_scrollPosition; }
39
40 void setChecked(CHECKED_STATE value) { m_checked = value; }
41 void setSelected(bool value) { m_selected = value; }
42 void setItemName(const QString& value) { m_name = value; }
43 void setScroll(bool value) { m_scroll = value; }
44 void setIndent(unsigned int value) { m_indent = value; }
45 void setScrollPos(unsigned int value) { m_scrollPosition = value; }
46 void incrementScrollPos() { ++m_scrollPosition; }
47
48 private:
51 QString m_name;
52 bool m_scroll {false};
53 unsigned int m_indent {0};
54 unsigned int m_scrollPosition {0};
55};
56
58
60{
61 public:
62 LCDTextItem(unsigned int row, TEXT_ALIGNMENT align, QString text,
63 QString screen = "Generic", bool scroll = false,
64 QString widget = "textWidget") :
65 m_itemRow(row), m_itemAlignment(align),
66 m_itemText(std::move(text)), m_itemScreen(std::move(screen)),
67 m_itemWidget(std::move(widget)), m_itemScrollable(scroll)
68 {
69 }
70
71 unsigned int getRow() const { return m_itemRow; }
72 TEXT_ALIGNMENT getAlignment() const { return m_itemAlignment; }
73 QString getText() const { return m_itemText; }
74 QString getScreen() const { return m_itemScreen; }
75 QString getWidget() const { return m_itemWidget; }
76 bool getScroll() const { return m_itemScrollable; }
77
78 void setRow(unsigned int value) { m_itemRow = value; }
79 void setAlignment(TEXT_ALIGNMENT value) { m_itemAlignment = value; }
80 void setText(const QString &value) { m_itemText = value; }
81 void setScreen(const QString &value) { m_itemScreen = value; }
82 void setWidget(const QString &value) { m_itemWidget = value; }
83 void setScrollable(bool value) { m_itemScrollable = value; }
84
85 private:
86 unsigned int m_itemRow;
88 QString m_itemText;
89 QString m_itemScreen {"Generic"};
90 QString m_itemWidget {"textWidget"};
91 bool m_itemScrollable {false};
92};
93
94//only one active at a time
95enum LCDSpeakerSet : std::uint8_t {
96 SPEAKER_MASK = 0x00000030,
97 SPEAKER_LR = 1 << 4,
98 SPEAKER_51 = 2 << 4,
99 SPEAKER_71 = 3 << 4,
100};
101
102//only one active at a time
104 AUDIO_MASK = 0x0000E000 | 0x00070000,
105
106 AUDIO_MP3 = 1 << 13,
107 AUDIO_OGG = 2 << 13,
108 AUDIO_WMA2 = 3 << 13,
109 AUDIO_WAV = 4 << 13,
110
111 AUDIO_MPEG2 = 1 << 16,
112 AUDIO_AC3 = 2 << 16,
113 AUDIO_DTS = 3 << 16,
114 AUDIO_WMA = 4 << 16,
115};
116
117//only one active at a time
119 VIDEO_MASK = 0x00380000,
120 VIDEO_MPG = 1 << 19,
121 VIDEO_DIVX = 2 << 19,
122 VIDEO_XVID = 3 << 19,
123 VIDEO_WMV = 4 << 19,
124};
125
126//only one active at a time
128 TUNER_MASK = 0x00000080 | 0x00000800 | 0x00001000,
129 TUNER_SRC = 0x00000080,
130 TUNER_SRC1 = 0x00000800,
131 TUNER_SRC2 = 0x00001000,
132};
133
134//only one active at a time
136 VSRC_MASK = 0x00000100 | 0x00000200,
137 VSRC_FIT = 0x00000100,
138 VSRC_TV = 0x00000200,
139};
140
141//can be enabled/disabled separately
143 VARIOUS_VOL = 0x00400000,
144 VARIOUS_TIME = 0x00800000,
145 VARIOUS_ALARM = 0x01000000,
146 VARIOUS_RECORD = 0x02000000,
147 VARIOUS_REPEAT = 0x04000000,
148 VARIOUS_SHUFFLE = 0x08000000,
149 VARIOUS_DISC_IN = 0x20000000,
150 VARIOUS_HDTV = 0x00000400,
151 VARIOUS_SPDIF = 0x1 << 9,
152 SPDIF_MASK = 0x00000040,
153};
154
155
156//only one active at a time
157enum LCDFunctionSet : std::uint8_t {
158 //0=none, 1=music, 2=movie, 3=photo, 4=CD/DVD, 5=TV, 6=Web, 7=News/Weather * 2
160 FUNC_MUSIC = 1 << 1,
161 FUNC_MOVIE = 2 << 1,
162 FUNC_PHOTO = 3 << 1,
163 FUNC_DVD = 4 << 1,
164 FUNC_TV = 5 << 1,
165 FUNC_WEB = 6 << 1,
166 FUNC_NEWS = 7 << 1,
167};
168
169class MBASE_PUBLIC LCD : public QObject
170{
171 Q_OBJECT
172 friend class TestLcdDevice;
173
174 protected:
175 LCD();
176
178 static LCD *m_lcd;
179 static bool m_enabled;
180
181 public:
182 ~LCD() override;
183
184 enum : std::uint8_t {
185 MUSIC_REPEAT_NONE = 0,
186 MUSIC_REPEAT_TRACK = 1,
187 MUSIC_REPEAT_ALL = 2,
188 };
189
190 enum : std::uint8_t {
191 MUSIC_SHUFFLE_NONE = 0,
192 MUSIC_SHUFFLE_RAND = 1,
193 MUSIC_SHUFFLE_SMART = 2,
194 MUSIC_SHUFFLE_ALBUM = 3,
195 MUSIC_SHUFFLE_ARTIST = 4
196 };
197
198 static LCD *Get(void);
199 static void SetupLCD (void);
200
201 // Used to actually connect to an LCD device
202 bool connectToHost(const QString &hostname, unsigned int port);
203
204 // When nothing else is going on, show the time
205 void switchToTime();
206
207 // Extended functionality for eg SoundGraph iMON LCD devices
208 void setSpeakerLEDs(enum LCDSpeakerSet speaker, bool on);
209 void setAudioFormatLEDs(enum LCDAudioFormatSet acodec, bool on);
210 void setVideoFormatLEDs(enum LCDVideoFormatSet vcodec, bool on);
211 void setVideoSrcLEDs(enum LCDVideoSourceSet vsrc, bool on);
212 void setFunctionLEDs(enum LCDFunctionSet func, bool on);
213 void setTunerLEDs(enum LCDTunerSet tuner, bool on);
214 void setVariousLEDs(enum LCDVariousFlags various, bool on);
215
216 // When playing music, switch to this and give artist and track name
217 //
218 // Note: the use of switchToMusic is discouraged, because it
219 // has become obvious that most LCD devices cannot handle communications
220 // fast enough to make them useful.
221 void switchToMusic(const QString &artist, const QString &album,
222 const QString &track);
223
224 // For Live TV, supply the channel number, program title and subtitle
225 //
226 // Note that the "channel" screen can be used for any kind of progress meter
227 // just put whatever you want in the strings, and update the progress as
228 // appropriate;
229 void switchToChannel(const QString &channum = "", const QString &title = "",
230 const QString &subtitle = "");
231
232 // While watching Live/Recording/Pause Buffer, occasionaly describe how
233 // much of the program has been seen (between 0.0 and 1.0)
234 // (e.g. [current time - start time] / [end time - start time] )
235 void setChannelProgress(const QString &time, float value);
236
237 // Show the Menu
238 // QPtrList is a pointer to a bunch of menu items
239 // See mythmusic/databasebox.cpp for an example
240 void switchToMenu(QList<LCDMenuItem> &menuItems,
241 const QString &app_name = "",
242 bool popMenu = true);
243
244 // Show the Generic Progress
245 // QPtrList contains pointers to LCDTextItem objects which allow you to
246 // define the screen, row, and alignment of the text
247 void switchToGeneric(QList<LCDTextItem> &textItems);
248
252 void setGenericProgress(float value);
253
258 void setGenericBusy();
259
260 // Do a music progress bar with the generic level between 0 and 1.0
261 void setMusicProgress(const QString &time, float value);
262
266 void setMusicRepeat(int repeat);
267
271 void setMusicShuffle(int shuffle);
272
273 // Show the Volume Level top_text scrolls
274 void switchToVolume(const QString &app_name);
275
276 // Do a progress bar with the volume level between 0 and 1.0
277 void setVolumeLevel(float value);
278
279 // If some other process should be getting all the LCDd screen time (e.g.
280 // mythMusic) we can use this to try and prevent and screens from showing
281 // up without having to actual destroy the LCD object
282 void switchToNothing();
283
284 // If you want to be pleasant, call shutdown() before deleting your LCD
285 // device
286 void shutdown();
287
288 void setupLEDs(int(*LedMaskFunc)(void));
289
290 void stopAll(void);
291
292 int getLCDHeight(void) const { return m_lcdHeight; }
293 int getLCDWidth(void) const { return m_lcdWidth; }
294
295 void resetServer(void); // tell the mythlcdserver to reload its settings
296
297 private slots:
298 void restartConnection(); // Try to re-establish the connection to
299 // LCDServer every 10 seconds
300 void outputLEDs();
301 void sendToServerSlot(const QString &someText);
302
303signals:
304 void sendToServer(const QString &someText);
305
306 private:
307 static bool startLCDServer(void);
308 void init();
309 void handleKeyPress(const QString &keyPressed);
310 static QString quotedString(const QString &string);
312
313 private slots:
314 void ReadyRead(void);
315 void Disconnected(void);
316
317 private:
318 QTcpSocket *m_socket {nullptr};
319 QRecursiveMutex m_socketLock;
320 QString m_hostname {"localhost"};
321 uint m_port {6545};
322 bool m_connected {false};
323
324 QTimer *m_retryTimer {nullptr};
325 QTimer *m_ledTimer {nullptr};
326
329
330 int m_lcdWidth {0};
331 int m_lcdHeight {0};
332
333 bool m_lcdReady {false};
334
335 bool m_lcdShowTime {false};
336 bool m_lcdShowMenu {false};
337 bool m_lcdShowGeneric {false};
338 bool m_lcdShowMusic {false};
339 bool m_lcdShowChannel {false};
340 bool m_lcdShowVolume {false};
341 bool m_lcdShowRecStatus {false};
342 bool m_lcdBacklightOn {false};
343 bool m_lcdHeartbeatOn {false};
344 int m_lcdPopupTime {0};
347
348 int m_lcdLedMask {0};
349
350 int (*m_getLEDMask)(void) {nullptr};
351};
352
353#endif
void setSelected(bool value)
Definition: lcddevice.h:41
void setChecked(CHECKED_STATE value)
Definition: lcddevice.h:40
void setIndent(unsigned int value)
Definition: lcddevice.h:44
CHECKED_STATE m_checked
Definition: lcddevice.h:50
LCDMenuItem(bool item_selected, CHECKED_STATE item_checked, QString item_name, unsigned int item_indent=0, bool item_scroll=false)
Definition: lcddevice.h:24
void setScroll(bool value)
Definition: lcddevice.h:43
QString m_name
Definition: lcddevice.h:51
bool m_selected
Definition: lcddevice.h:49
unsigned int getIndent() const
Definition: lcddevice.h:37
void setItemName(const QString &value)
Definition: lcddevice.h:42
CHECKED_STATE isChecked() const
Definition: lcddevice.h:33
void incrementScrollPos()
Definition: lcddevice.h:46
unsigned int getScrollPos() const
Definition: lcddevice.h:38
bool isSelected() const
Definition: lcddevice.h:34
void setScrollPos(unsigned int value)
Definition: lcddevice.h:45
bool Scroll() const
Definition: lcddevice.h:36
QString ItemName() const
Definition: lcddevice.h:35
LCDTextItem(unsigned int row, TEXT_ALIGNMENT align, QString text, QString screen="Generic", bool scroll=false, QString widget="textWidget")
Definition: lcddevice.h:62
QString getWidget() const
Definition: lcddevice.h:75
QString getScreen() const
Definition: lcddevice.h:74
TEXT_ALIGNMENT getAlignment() const
Definition: lcddevice.h:72
void setText(const QString &value)
Definition: lcddevice.h:80
QString m_itemText
Definition: lcddevice.h:88
unsigned int getRow() const
Definition: lcddevice.h:71
QString getText() const
Definition: lcddevice.h:73
bool getScroll() const
Definition: lcddevice.h:76
TEXT_ALIGNMENT m_itemAlignment
Definition: lcddevice.h:87
void setScreen(const QString &value)
Definition: lcddevice.h:81
void setWidget(const QString &value)
Definition: lcddevice.h:82
void setScrollable(bool value)
Definition: lcddevice.h:83
void setRow(unsigned int value)
Definition: lcddevice.h:78
unsigned int m_itemRow
Definition: lcddevice.h:86
void setAlignment(TEXT_ALIGNMENT value)
Definition: lcddevice.h:79
Definition: lcddevice.h:170
QString m_sendBuffer
Definition: lcddevice.h:327
void sendToServer(const QString &someText)
QString m_lcdShowMusicItems
Definition: lcddevice.h:345
static bool m_serverUnavailable
Definition: lcddevice.h:177
QRecursiveMutex m_socketLock
Definition: lcddevice.h:319
QString m_lastCommand
Definition: lcddevice.h:328
static LCD * m_lcd
Definition: lcddevice.h:178
int getLCDWidth(void) const
Definition: lcddevice.h:293
static bool m_enabled
Definition: lcddevice.h:179
void describeServer()
QString m_lcdKeyString
Definition: lcddevice.h:346
int getLCDHeight(void) const
Definition: lcddevice.h:292
unsigned int uint
Definition: freesurround.h:24
unsigned short uint16_t
Definition: iso6937tables.h:3
LCDSpeakerSet
Definition: lcddevice.h:95
@ SPEAKER_LR
Definition: lcddevice.h:97
@ SPEAKER_MASK
Definition: lcddevice.h:96
@ SPEAKER_71
Definition: lcddevice.h:99
@ SPEAKER_51
Definition: lcddevice.h:98
LCDVideoSourceSet
Definition: lcddevice.h:135
@ VSRC_FIT
Definition: lcddevice.h:137
@ VSRC_MASK
Definition: lcddevice.h:136
@ VSRC_TV
Definition: lcddevice.h:138
LCDTunerSet
Definition: lcddevice.h:127
@ TUNER_SRC1
Definition: lcddevice.h:130
@ TUNER_SRC
Definition: lcddevice.h:129
@ TUNER_MASK
Definition: lcddevice.h:128
@ TUNER_SRC2
Definition: lcddevice.h:131
LCDFunctionSet
Definition: lcddevice.h:157
@ FUNC_PHOTO
Definition: lcddevice.h:162
@ FUNC_MASK
Definition: lcddevice.h:159
@ FUNC_WEB
Definition: lcddevice.h:165
@ FUNC_TV
Definition: lcddevice.h:164
@ FUNC_MOVIE
Definition: lcddevice.h:161
@ FUNC_MUSIC
Definition: lcddevice.h:160
@ FUNC_NEWS
Definition: lcddevice.h:166
@ FUNC_DVD
Definition: lcddevice.h:163
TEXT_ALIGNMENT
Definition: lcddevice.h:57
@ ALIGN_CENTERED
Definition: lcddevice.h:57
@ ALIGN_LEFT
Definition: lcddevice.h:57
@ ALIGN_RIGHT
Definition: lcddevice.h:57
LCDAudioFormatSet
Definition: lcddevice.h:103
@ AUDIO_MASK
Definition: lcddevice.h:104
@ AUDIO_OGG
Definition: lcddevice.h:107
@ AUDIO_MPEG2
Definition: lcddevice.h:111
@ AUDIO_AC3
Definition: lcddevice.h:112
@ AUDIO_WAV
Definition: lcddevice.h:109
@ AUDIO_MP3
Definition: lcddevice.h:106
@ AUDIO_DTS
Definition: lcddevice.h:113
@ AUDIO_WMA
Definition: lcddevice.h:114
@ AUDIO_WMA2
Definition: lcddevice.h:108
LCDVideoFormatSet
Definition: lcddevice.h:118
@ VIDEO_XVID
Definition: lcddevice.h:122
@ VIDEO_WMV
Definition: lcddevice.h:123
@ VIDEO_MPG
Definition: lcddevice.h:120
@ VIDEO_DIVX
Definition: lcddevice.h:121
@ VIDEO_MASK
Definition: lcddevice.h:119
CHECKED_STATE
Definition: lcddevice.h:17
@ NOTCHECKABLE
Definition: lcddevice.h:17
@ CHECKED
Definition: lcddevice.h:17
@ UNCHECKED
Definition: lcddevice.h:17
LCDVariousFlags
Definition: lcddevice.h:142
@ VARIOUS_REPEAT
Definition: lcddevice.h:147
@ SPDIF_MASK
Definition: lcddevice.h:152
@ VARIOUS_SPDIF
Definition: lcddevice.h:151
@ VARIOUS_ALARM
Definition: lcddevice.h:145
@ VARIOUS_VOL
Definition: lcddevice.h:143
@ VARIOUS_HDTV
Definition: lcddevice.h:150
@ VARIOUS_RECORD
Definition: lcddevice.h:146
@ VARIOUS_SHUFFLE
Definition: lcddevice.h:148
@ VARIOUS_DISC_IN
Definition: lcddevice.h:149
@ VARIOUS_TIME
Definition: lcddevice.h:144
#define MBASE_PUBLIC
Definition: mythbaseexp.h:15
static int shutdown()
string hostname
Definition: caa.py:17
STL namespace.