MythTV master
lcdprocclient.h
Go to the documentation of this file.
1#ifndef LCDPROCCLIENT_H_
2#define LCDPROCCLIENT_H_
3
4#include <QStringList>
5#include <QObject>
6#include <QList>
7#include <QTcpSocket>
8
10
11using namespace std::chrono_literals;
12
13class LCDServer;
14class LCDTextItem;
15class LCDMenuItem;
16class QEvent;
17class QTimer;
18
19
20class LCDProcClient : public QObject
21{
22 Q_OBJECT
23
24 public:
25
26 explicit LCDProcClient(LCDServer *lparent);
27
28 void customEvent(QEvent *e) override; // QObject
29
30 ~LCDProcClient() override;
31
32 bool SetupLCD(void);
33 void reset(void);
34
35 void setStartupMessage(QString msg, std::chrono::seconds messagetime);
36
37 // Used to actually connect to an LCD device
38 bool connectToHost(const QString &hostname, unsigned int port);
39
40 void switchToTime();
41 void switchToMusic(const QString &artist, const QString &album, const QString &track);
42 void setMusicProgress(QString time, float value);
43 void setMusicRepeat(int repeat);
44 void setMusicShuffle(int shuffle);
45 void switchToChannel(const QString& channum = "", const QString& title = "",
46 const QString& subtitle = "");
47 void setChannelProgress(const QString &time, float value);
48 void switchToMenu(QList<LCDMenuItem> *menuItems, const QString& app_name = "",
49 bool popMenu = true);
50 void switchToGeneric(QList<LCDTextItem> *textItems);
51 void setGenericProgress(bool busy, float value);
52
53 void switchToVolume(const QString& app_name);
54 void setVolumeLevel(float value);
55
56 void switchToNothing();
57
58 void shutdown();
59 void removeWidgets();
60 void updateLEDs(int mask);
61 void stopAll(void);
62
63 int getLCDWidth(void) const { return m_lcdWidth; }
64 int getLCDHeight(void) const { return m_lcdHeight; }
65
66 private slots:
67 void veryBadThings(QAbstractSocket::SocketError error); // Communication Errors
68 void serverSendingData(); // Data coming back from LCDd
69
70 void checkConnections(); // check connections to LCDd and mythbackend
71 // every 10 seconds
72
73 void dobigclock(void); // Large display
74 void dostdclock(); // Small display
75 void outputTime(); // Fire from a timer
76 void outputMusic(); // Short timer (equalizer)
77 void outputChannel(); // Longer timer (progress bar)
78 void outputGeneric(); // Longer timer (progress bar)
79 void outputVolume();
80 void outputRecStatus();
81 void scrollMenuText(); // Scroll the menu items if need be
82 void beginScrollingMenuText(); // But only after a bit of time has gone by
83 void unPopMenu(); // Remove the Pop Menu display
84 void scrollList(); // display a list line by line
85 void updateRecordingList(void);
86 void removeStartupMessage(void);
87 void beginScrollingWidgets(void);
88 void scrollWidgets(void);
89
90 private:
91 void outputCenteredText(const QString& theScreen, QString theText,
92 const QString& widget = "topWidget", int row = 1);
93
94 void outputLeftText(const QString& theScreen, QString theText,
95 const QString& widget = "topWidget", int row = 1);
96 void outputRightText(const QString& theScreen, QString theText,
97 const QString& widget = "topWidget", int row = 1);
98
99 void outputScrollerText(const QString& theScreen, const QString& theText,
100 const QString& widget = "scroller", int top = 1, int bottom = 1);
101
102 QStringList formatScrollerText(const QString &text) const;
103 void outputText(QList<LCDTextItem> *textItems);
104
105 void sendToServer(const QString &someText);
106
107 enum PRIORITY : std::uint8_t {TOP, URGENT, HIGH, MEDIUM, LOW, OFF};
108 void setPriority(const QString &screen, PRIORITY priority);
109
110 void setHeartbeat (const QString &screen, bool onoff);
111 QString expandString(const QString &aString) const;
112
113 void init();
114 void loadSettings(); //reload the settings from the db
115
116 void assignScrollingList(QStringList theList, QString theScreen,
117 QString theWidget = "topWidget", int theRow = 1);
118
119 // Scroll 1 or more widgets on a screen
120 void assignScrollingWidgets(const QString& theText, const QString& theScreen,
121 const QString& theWidget = "topWidget", int theRow = 1);
122 void formatScrollingWidgets(void);
123
124 void startTime();
125 void startMusic(QString artist, const QString& album, const QString& track);
126 void startChannel(const QString& channum, const QString& title, const QString& subtitle);
127 void startGeneric(QList<LCDTextItem> * textItems);
128 void startMenu(QList<LCDMenuItem> *menuItems, QString app_name,
129 bool popMenu);
130 void startVolume(const QString& app_name);
131 void showStartupMessage(void);
132
133 void setWidth(unsigned int x);
134 void setHeight(unsigned int x);
135 void setCellWidth(unsigned int x);
136 void setCellHeight(unsigned int x);
137 void setVersion(const QString &sversion, const QString &pversion);
138 void describeServer();
139
141
142 QTcpSocket *m_socket {nullptr};
143 QTimer *m_timeTimer {nullptr};
144 QTimer *m_scrollWTimer {nullptr};
145 QTimer *m_preScrollWTimer {nullptr};
146 QTimer *m_menuScrollTimer {nullptr};
147 QTimer *m_menuPreScrollTimer {nullptr};
148 QTimer *m_popMenuTimer {nullptr};
149 QTimer *m_checkConnectionsTimer {nullptr};
150 QTimer *m_recStatusTimer {nullptr};
151 QTimer *m_scrollListTimer {nullptr};
152 QTimer *m_showMessageTimer {nullptr};
153 QTimer *m_updateRecInfoTimer {nullptr};
154
155 QString m_prioTop;
157 QString m_prioHigh;
159 QString m_prioLow;
160 QString m_prioOff;
161
162 uint8_t m_lcdWidth {5};
163 uint8_t m_lcdHeight {1};
164 uint8_t m_cellWidth {1};
165 uint8_t m_cellHeight {1};
166
169 uint8_t m_pVersion {0};
170
171 float m_progress {0.0};
175 bool m_busyProgress {false};
178 int m_busyPos {0};
185 float m_genericProgress {0.0};
186 float m_volumeLevel {0.0};
187
188 float m_musicProgress {0.0};
189 QString m_musicTime;
192
193 QList<LCDTextItem> *m_lcdTextItems {nullptr};
194 //QString m_scrollingText;
196 unsigned int m_scrollPosition {0};
199
200 QStringList m_scrollListItems;
204 unsigned int m_scrollListItem {0};
205
206 unsigned int m_menuScrollPosition {0};
207 QList<LCDMenuItem> *m_lcdMenuItems {nullptr};
208
209 bool m_connected {false};
210 bool m_timeFlash {false};
211
214 QString m_hostname;
215 unsigned int m_port {13666};
216
217 bool m_lcdReady {false};
218
219 bool m_lcdShowTime {true};
220 bool m_lcdShowMenu {true};
221 bool m_lcdShowGeneric {true};
222 bool m_lcdShowMusic {true};
223 bool m_lcdShowChannel {true};
224 bool m_lcdShowVolume {true};
226 bool m_lcdBacklightOn {true};
227 bool m_lcdHeartbeatOn {true};
228 bool m_lcdBigClock {true};
229 std::chrono::milliseconds m_lcdPopupTime {0ms};
234 std::chrono::seconds m_startupShowTime {0s};
235
236 bool m_isRecording {false};
237 bool m_isTimeVisible {false};
239
240 std::vector<TunerStatus> m_tunerList;
241};
242
243#endif
void startMenu(QList< LCDMenuItem > *menuItems, QString app_name, bool popMenu)
void switchToChannel(const QString &channum="", const QString &title="", const QString &subtitle="")
bool m_lcdShowRecstatus
void outputText(QList< LCDTextItem > *textItems)
std::chrono::seconds m_startupShowTime
void setWidth(unsigned int x)
void assignScrollingList(QStringList theList, QString theScreen, QString theWidget="topWidget", int theRow=1)
void startMusic(QString artist, const QString &album, const QString &track)
void startChannel(const QString &channum, const QString &title, const QString &subtitle)
uint8_t m_cellWidth
void reset(void)
void setMusicShuffle(int shuffle)
QString m_activeScreen
void showStartupMessage(void)
void setHeight(unsigned int x)
QString m_scrollScreen
void setCellHeight(unsigned int x)
QString m_serverVersion
QString m_startupMessage
void checkConnections()
void setGenericProgress(bool busy, float value)
QTimer * m_scrollListTimer
void startVolume(const QString &app_name)
QTimer * m_showMessageTimer
uint8_t m_pVersion
QList< LCDMenuItem > * m_lcdMenuItems
void switchToVolume(const QString &app_name)
QTimer * m_recStatusTimer
void stopAll(void)
int getLCDHeight(void) const
Definition: lcdprocclient.h:64
QString m_lcdKeyString
int m_busyDirection
Direction of the busy indicator on the, -1 or 1, used if m_busyProgress is true.
void formatScrollingWidgets(void)
QTimer * m_scrollWTimer
QString m_prioTop
QTimer * m_preScrollWTimer
bool m_busyProgress
true if the generic progress indicator is a busy (ie.
uint8_t m_cellHeight
QString m_channelTime
QString m_prioMedium
void setMusicRepeat(int repeat)
void dobigclock(void)
bool connectToHost(const QString &hostname, unsigned int port)
QTcpSocket * m_socket
QTimer * m_timeTimer
std::vector< TunerStatus > m_tunerList
QStringList formatScrollerText(const QString &text) const
void beginScrollingMenuText()
QTimer * m_updateRecInfoTimer
void veryBadThings(QAbstractSocket::SocketError error)
float m_genericProgress
int m_busyPos
Current position of the busy indicator, used if m_busyProgress is true.
QString m_lcdShowMusicItems
void switchToMenu(QList< LCDMenuItem > *menuItems, const QString &app_name="", bool popMenu=true)
void startGeneric(QList< LCDTextItem > *textItems)
QTimer * m_popMenuTimer
QString m_protocolVersion
void serverSendingData()
QTimer * m_menuPreScrollTimer
void outputRightText(const QString &theScreen, QString theText, const QString &widget="topWidget", int row=1)
void switchToGeneric(QList< LCDTextItem > *textItems)
LCDServer * m_parentLCDServer
void setCellWidth(unsigned int x)
void outputCenteredText(const QString &theScreen, QString theText, const QString &widget="topWidget", int row=1)
QString m_scrollListWidget
QTimer * m_checkConnectionsTimer
void switchToMusic(const QString &artist, const QString &album, const QString &track)
QString m_scrollListScreen
~LCDProcClient() override
QString m_musicTime
void sendToServer(const QString &someText)
QString m_lastCommand
void setVolumeLevel(float value)
unsigned int m_menuScrollPosition
QString m_prioUrgent
void beginScrollingWidgets(void)
void outputLeftText(const QString &theScreen, QString theText, const QString &widget="topWidget", int row=1)
unsigned int m_port
QString m_hostname
void setMusicProgress(QString time, float value)
QString m_timeFormat
float m_musicProgress
int getLCDWidth(void) const
Definition: lcdprocclient.h:63
std::chrono::milliseconds m_lcdPopupTime
void setVersion(const QString &sversion, const QString &pversion)
void setChannelProgress(const QString &time, float value)
QString expandString(const QString &aString) const
void setHeartbeat(const QString &screen, bool onoff)
unsigned int m_scrollPosition
uint8_t m_lcdWidth
bool SetupLCD(void)
uint8_t m_lcdHeight
QString m_dateFormat
QTimer * m_menuScrollTimer
void customEvent(QEvent *e) override
QString m_prioLow
LCDProcClient(LCDServer *lparent)
void assignScrollingWidgets(const QString &theText, const QString &theScreen, const QString &theWidget="topWidget", int theRow=1)
void setPriority(const QString &screen, PRIORITY priority)
QString m_prioHigh
QList< LCDTextItem > * m_lcdTextItems
void updateRecordingList(void)
float m_busyIndicatorSize
How many "blocks" the busy indicator must be, used if m_busyProgress is true.
unsigned int m_scrollListItem
void scrollWidgets(void)
QStringList m_scrollListItems
void setStartupMessage(QString msg, std::chrono::seconds messagetime)
void removeStartupMessage(void)
void outputScrollerText(const QString &theScreen, const QString &theText, const QString &widget="scroller", int top=1, int bottom=1)
QString m_prioOff
QString m_sendBuffer
void updateLEDs(int mask)
def error(message)
Definition: smolt.py:409
string hostname
Definition: caa.py:17