|
MythTV
0.26-pre
|
00001 #ifndef LCDDEVICE_H_ 00002 #define LCDDEVICE_H_ 00003 00004 #include <iostream> 00005 00006 #include <QObject> 00007 #include <QStringList> 00008 #include <QTimer> 00009 #include <QDateTime> 00010 #include <QMutex> 00011 #include <QList> 00012 00013 #include "mythbaseexp.h" 00014 #include "mythsocket_cb.h" 00015 00016 enum CHECKED_STATE {CHECKED = 0, UNCHECKED, NOTCHECKABLE }; 00017 00018 class MBASE_PUBLIC LCDMenuItem 00019 { 00020 public: 00021 LCDMenuItem(bool item_selected, CHECKED_STATE item_checked, 00022 QString item_name, unsigned int item_indent = 0, 00023 bool item_scroll = false) 00024 { 00025 selected = item_selected; 00026 checked = item_checked; 00027 name = item_name; 00028 scroll = item_scroll; 00029 indent = item_indent; 00030 scrollPosition = indent; 00031 } 00032 00033 CHECKED_STATE isChecked() const { return checked; } 00034 bool isSelected() const { return selected; } 00035 QString ItemName() const { return name; } 00036 bool Scroll() const { return scroll; } 00037 unsigned int getIndent() const { return indent; } 00038 unsigned int getScrollPos() const { return scrollPosition; } 00039 00040 void setChecked(CHECKED_STATE value) { checked = value; } 00041 void setSelected(bool value) { selected = value; } 00042 void setItemName(QString value) { name = value; } 00043 void setScroll(bool value) { scroll = value; } 00044 void setIndent(unsigned int value) { indent = value; } 00045 void setScrollPos(unsigned int value) { scrollPosition = value; } 00046 void incrementScrollPos() { ++scrollPosition; } 00047 00048 private: 00049 bool selected; 00050 CHECKED_STATE checked; 00051 QString name; 00052 bool scroll; 00053 unsigned int indent; 00054 unsigned int scrollPosition; 00055 }; 00056 00057 enum TEXT_ALIGNMENT {ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTERED }; 00058 00059 class MBASE_PUBLIC LCDTextItem 00060 { 00061 public: 00062 LCDTextItem(unsigned int row, TEXT_ALIGNMENT align, QString text, 00063 QString screen = "Generic", bool scroll = false, 00064 QString widget = "textWidget") 00065 { 00066 itemRow = row; 00067 itemAlignment = align; 00068 itemText = text; 00069 itemScreen = screen; 00070 itemWidget = widget; 00071 itemScrollable = scroll; 00072 } 00073 00074 unsigned int getRow() const { return itemRow; } 00075 TEXT_ALIGNMENT getAlignment() const { return itemAlignment; } 00076 QString getText() const { return itemText; } 00077 QString getScreen() const { return itemScreen; } 00078 QString getWidget() const { return itemWidget; } 00079 int getScroll() const { return itemScrollable; } 00080 00081 void setRow(unsigned int value) { itemRow = value; } 00082 void setAlignment(TEXT_ALIGNMENT value) { itemAlignment = value; } 00083 void setText(QString value) { itemText = value; } 00084 void setScreen(QString value) { itemScreen = value; } 00085 void setWidget(QString value) { itemWidget = value; } 00086 void setScrollable(bool value) { itemScrollable = value; } 00087 00088 private: 00089 unsigned int itemRow; 00090 TEXT_ALIGNMENT itemAlignment; 00091 QString itemText; 00092 QString itemScreen; 00093 QString itemWidget; 00094 bool itemScrollable; 00095 }; 00096 00097 //only one active at a time 00098 enum LCDSpeakerSet { 00099 SPEAKER_MASK = 0x00000030, 00100 SPEAKER_LR = 1 << 4, 00101 SPEAKER_51 = 2 << 4, 00102 SPEAKER_71 = 3 << 4, 00103 }; 00104 00105 //only one active at a time 00106 enum LCDAudioFormatSet { 00107 AUDIO_MASK = 0x0000E000 | 0x00070000, 00108 00109 AUDIO_MP3 = 1 << 13, 00110 AUDIO_OGG = 2 << 13, 00111 AUDIO_WMA2 = 3 << 13, 00112 AUDIO_WAV = 4 << 13, 00113 00114 AUDIO_MPEG2 = 1 << 16, 00115 AUDIO_AC3 = 2 << 16, 00116 AUDIO_DTS = 3 << 16, 00117 AUDIO_WMA = 4 << 16, 00118 }; 00119 00120 //only one active at a time 00121 enum LCDVideoFormatSet { 00122 VIDEO_MASK = 0x00380000, 00123 VIDEO_MPG = 1 << 19, 00124 VIDEO_DIVX = 2 << 19, 00125 VIDEO_XVID = 3 << 19, 00126 VIDEO_WMV = 4 << 19, 00127 }; 00128 00129 //only one active at a time 00130 enum LCDTunerSet { 00131 TUNER_MASK = 0x00000080 | 0x00000800 | 0x00001000, 00132 TUNER_SRC = 0x00000080, 00133 TUNER_SRC1 = 0x00000800, 00134 TUNER_SRC2 = 0x00001000, 00135 }; 00136 00137 //only one active at a time 00138 enum LCDVideoSourceSet { 00139 VSRC_MASK = 0x00000100 | 0x00000200, 00140 VSRC_FIT = 0x00000100, 00141 VSRC_TV = 0x00000200, 00142 }; 00143 00144 //can be enabled/disabled separately 00145 enum LCDVariousFlags { 00146 VARIOUS_VOL = 0x00400000, 00147 VARIOUS_TIME = 0x00800000, 00148 VARIOUS_ALARM = 0x01000000, 00149 VARIOUS_RECORD = 0x02000000, 00150 VARIOUS_REPEAT = 0x04000000, 00151 VARIOUS_SHUFFLE = 0x08000000, 00152 VARIOUS_DISC_IN = 0x20000000, 00153 VARIOUS_HDTV = 0x00000400, 00154 VARIOUS_SPDIF = 0x1 << 9, 00155 SPDIF_MASK = 0x00000040, 00156 }; 00157 00158 00159 //only one active at a time 00160 enum LCDFunctionSet { 00161 //0=none, 1=music, 2=movie, 3=photo, 4=CD/DVD, 5=TV, 6=Web, 7=News/Weather * 2 00162 FUNC_MASK = 0xE, 00163 FUNC_MUSIC = 1 << 1, 00164 FUNC_MOVIE = 2 << 1, 00165 FUNC_PHOTO = 3 << 1, 00166 FUNC_DVD = 4 << 1, 00167 FUNC_TV = 5 << 1, 00168 FUNC_WEB = 6 << 1, 00169 FUNC_NEWS = 7 << 1, 00170 }; 00171 00172 class MBASE_PUBLIC LCD : public QObject, public MythSocketCBs 00173 { 00174 Q_OBJECT 00175 00176 protected: 00177 LCD(); 00178 00179 static bool m_server_unavailable; 00180 static LCD *m_lcd; 00181 static bool m_enabled; 00182 00183 public: 00184 ~LCD(); 00185 00186 enum { 00187 MUSIC_REPEAT_NONE = 0, 00188 MUSIC_REPEAT_TRACK = 1, 00189 MUSIC_REPEAT_ALL = 2, 00190 }; 00191 00192 enum { 00193 MUSIC_SHUFFLE_NONE = 0, 00194 MUSIC_SHUFFLE_RAND = 1, 00195 MUSIC_SHUFFLE_SMART = 2, 00196 MUSIC_SHUFFLE_ALBUM = 3, 00197 MUSIC_SHUFFLE_ARTIST = 4 00198 }; 00199 00200 static LCD *Get(void); 00201 static void SetupLCD (void); 00202 00203 // Used to actually connect to an LCD device 00204 bool connectToHost(const QString &hostname, unsigned int port); 00205 00206 // When nothing else is going on, show the time 00207 void switchToTime(); 00208 00209 // Extended functionality for eg SoundGraph iMON LCD devices 00210 void setSpeakerLEDs(enum LCDSpeakerSet speaker, bool on); 00211 void setAudioFormatLEDs(enum LCDAudioFormatSet acodec, bool on); 00212 void setVideoFormatLEDs(enum LCDVideoFormatSet vcodec, bool on); 00213 void setVideoSrcLEDs(enum LCDVideoSourceSet vsrc, bool on); 00214 void setFunctionLEDs(enum LCDFunctionSet video, bool on); 00215 void setTunerLEDs(enum LCDTunerSet tuner, bool on); 00216 void setVariousLEDs(enum LCDVariousFlags various, bool on); 00217 00218 // When playing music, switch to this and give artist and track name 00219 // 00220 // Note: the use of switchToMusic is discouraged, because it 00221 // has become obvious that most LCD devices cannot handle communications 00222 // fast enough to make them useful. 00223 void switchToMusic(const QString &artist, const QString &album, 00224 const QString &track); 00225 00226 // For Live TV, supply the channel number, program title and subtitle 00227 // 00228 // Note that the "channel" screen can be used for any kind of progress meter 00229 // just put whatever you want in the strings, and update the progress as 00230 // appropriate; 00231 void switchToChannel(QString channum = "", QString title = "", 00232 QString subtitle = ""); 00233 00234 // While watching Live/Recording/Pause Buffer, occasionaly describe how 00235 // much of the program has been seen (between 0.0 and 1.0) 00236 // (e.g. [current time - start time] / [end time - start time] ) 00237 void setChannelProgress(const QString &time, float percentViewed); 00238 00239 // Show the Menu 00240 // QPtrList is a pointer to a bunch of menu items 00241 // See mythmusic/databasebox.cpp for an example 00242 void switchToMenu(QList<LCDMenuItem> &menuItems, QString app_name = "", 00243 bool popMenu = true); 00244 00245 // Show the Generic Progress 00246 // QPtrList contains pointers to LCDTextItem objects which allow you to 00247 // define the screen, row, and alignment of the text 00248 void switchToGeneric(QList<LCDTextItem> &textItems); 00249 00253 void setGenericProgress(float generic_progress); 00254 00259 void setGenericBusy(); 00260 00261 // Do a music progress bar with the generic level between 0 and 1.0 00262 void setMusicProgress(QString time, float generic_progress); 00263 00267 void setMusicRepeat(int repeat); 00268 00272 void setMusicShuffle(int shuffle); 00273 00274 // Show the Volume Level top_text scrolls 00275 void switchToVolume(QString app_name); 00276 00277 // Do a progress bar with the volume level between 0 and 1.0 00278 void setVolumeLevel(float volume_level); 00279 00280 // If some other process should be getting all the LCDd screen time (e.g. 00281 // mythMusic) we can use this to try and prevent and screens from showing 00282 // up without having to actual destroy the LCD object 00283 void switchToNothing(); 00284 00285 // If you want to be pleasant, call shutdown() before deleting your LCD 00286 // device 00287 void shutdown(); 00288 00289 void setupLEDs(int(*LedMaskFunc)(void)); 00290 00291 void stopAll(void); 00292 00293 uint getLCDHeight(void) { return lcd_height; } 00294 uint getLCDWidth(void) { return lcd_width; } 00295 00296 void resetServer(void); // tell the mythlcdserver to reload its settings 00297 00298 private slots: 00299 void restartConnection(); // Try to re-establish the connection to 00300 // LCDServer every 10 seconds 00301 void outputLEDs(); 00302 00303 private: 00304 bool startLCDServer(void); 00305 void sendToServer(const QString &someText); 00306 void init(); 00307 void handleKeyPress(QString key); 00308 QString quotedString(const QString &s); 00309 void describeServer(); 00310 00311 // mythsocket CB's 00312 void connected(MythSocket *sock) { (void)sock; } 00313 void connectionClosed(MythSocket *sock); 00314 void readyRead(MythSocket *sock); 00315 void connectionFailed(MythSocket *sock); 00316 00317 MythSocket *socket; 00318 QMutex socketLock; 00319 QString hostname; 00320 uint port; 00321 bool bConnected; 00322 00323 QTimer *retryTimer; 00324 QTimer *LEDTimer; 00325 00326 QString send_buffer; 00327 QString last_command; 00328 00329 int lcd_width; 00330 int lcd_height; 00331 00332 bool lcd_ready; 00333 00334 bool lcd_showtime; 00335 bool lcd_showmenu; 00336 bool lcd_showgeneric; 00337 bool lcd_showmusic; 00338 bool lcd_showchannel; 00339 bool lcd_showvolume; 00340 bool lcd_showrecstatus; 00341 bool lcd_backlighton; 00342 bool lcd_heartbeaton; 00343 int lcd_popuptime; 00344 QString lcd_showmusic_items; 00345 QString lcd_keystring; 00346 00347 int lcd_ledmask; 00348 00349 int (*GetLEDMask)(void); 00350 }; 00351 00352 #endif
1.7.6.1