Ticket #341: lcd-busy-520.patch
| File lcd-busy-520.patch, 21.6 KB (added by , 20 years ago) |
|---|
-
mythtv/libs/libmyth/lcddevice.cpp
Patch to add a busy spinner to LCD and fix ticket#520. 1) Added a flush when writing to the mythlcdserver. I might have been confused by the lag causes by the menus, but I'm fairly sure I observed lack of updates that the flush fixed. Anyway, it can't hurt. 2) Fix for ticket#520. Add two new calls to LCD, setMusicShuffle and setMusicRepeat, used by MythMusic to set what the shuffle and repeat mode is. 3) Changed the layout of the music screen : height == 2 : Artist[-Album-]-Title hh:mm / HH:MM height == 3 : Artist[-Album-]-Title hh:mm / HH:MM [shuffle] [repeat] height > 3 : Artist[-Album-]-Title hh:mm / HH:MM ====progress==- [shuffle] [repeat] 4) Added support for a busy spinner. Calling LCD::setGenericBusy will animate a busy spinner. Note, the busy spinner does *not* selfanimate (it could), but I've chosen to only animate when setGenericBusy is called. 5) when checking recording status, and failing to talk to the backend, only fallback to time screen if we're showing the recording status. Otherwise, if the backend is unreachable (ie. a machine used for mythmusic only) will constantly fallback to time screen. 6) Moved all the LCD::switchToMusic calls in playbackbox to a single function (setTrackOnLCD).192 192 #endif 193 193 // Just stream the text out the socket 194 194 195 os << someText << "\n" ;195 os << someText << "\n" << flush; 196 196 } 197 197 else 198 198 { … … 387 387 else if (value > 1.0) 388 388 value = 1.0; 389 389 390 sendToServer("SET_GENERIC_PROGRESS " + QString().setNum(value)); 390 sendToServer("SET_GENERIC_PROGRESS " + QString().setNum (false) + 391 " " + QString().setNum(value)); 391 392 } 392 393 394 void LCD::setGenericBusy () 395 { 396 if (!lcd_ready || !lcd_showgeneric) 397 return; 398 399 sendToServer("SET_GENERIC_PROGRESS 1 0.0"); 400 } 401 393 402 void LCD::setMusicProgress(QString time, float value) 394 403 { 395 404 if (!lcd_ready || !lcd_showmusic) … … 404 413 QString().setNum(value)); 405 414 } 406 415 416 void LCD::setMusicShuffle(int shuffle) 417 { 418 if (!lcd_ready || !lcd_showmusic) 419 return; 420 421 sendToServer("SET_MUSIC_PLAYER_PROP SHUFFLE "+ QString().setNum(shuffle)); 422 } 423 424 void LCD::setMusicRepeat(int repeat) 425 { 426 if (!lcd_ready || !lcd_showmusic) 427 return; 428 429 sendToServer("SET_MUSIC_PLAYER_PROP REPEAT "+ QString().setNum(repeat)); 430 } 431 407 432 void LCD::setVolumeLevel(float value) 408 433 { 409 434 if (!lcd_ready || !lcd_showvolume) -
mythtv/libs/libmyth/lcddevice.h
104 104 public: 105 105 ~LCD(); 106 106 107 enum { 108 MUSIC_REPEAT_NONE = 0, 109 MUSIC_REPEAT_TRACK = 1, 110 MUSIC_REPEAT_ALL = 2 111 }; 112 113 enum { 114 MUSIC_SHUFFLE_NONE = 0, 115 MUSIC_SHUFFLE_RAND = 1, 116 MUSIC_SHUFFLE_SMART = 2 117 }; 118 107 119 static class LCD * Get(void); 108 120 static void SetupLCD (void); 109 121 … … 147 159 // define the screen, row, and alignment of the text 148 160 void switchToGeneric(QPtrList<LCDTextItem> *textItems); 149 161 150 // Do a progress bar with the generic level between 0 and 1.0 162 /** Update the generic progress bar. 163 \param generic_progress a value between 0 and 1.0 164 */ 151 165 void setGenericProgress(float generic_progress); 152 166 167 /** Update the generic screen to display a busy spinner. 168 169 \note The LCD busy spinner only 'moves' when this is called 170 instead of the lcdserver just handling it itself. 171 */ 172 void setGenericBusy(); 173 153 174 // Do a music progress bar with the generic level between 0 and 1.0 154 175 void setMusicProgress(QString time, float generic_progress); 155 176 177 /** \brief Set music player's repeat properties 178 \param repeat the state of repeat 179 */ 180 void setMusicRepeat (int repeat); 181 182 /** \brief Set music player's shuffle properties 183 \param repeat the state of repeat 184 */ 185 void setMusicShuffle (int shuffle); 186 156 187 // Show the Volume Level top_text scrolls 157 188 void switchToVolume(QString app_name); 158 189 -
mythtv/programs/mythlcdserver/lcdserver.h
55 55 void switchToMenu(const QStringList &tokens, QSocket *socket); 56 56 void setChannelProgress(const QStringList &tokens, QSocket *socket); 57 57 void setMusicProgress(const QStringList &tokens, QSocket *socket); 58 void setMusicProp(const QStringList &tokens, QSocket *socket); 58 59 void setGenericProgress(const QStringList &tokens, QSocket *socket); 59 60 void setVolumeLevel(const QStringList &tokens, QSocket *socket); 60 61 void updateLEDs(const QStringList &tokens, QSocket *socket); -
mythtv/programs/mythlcdserver/lcdprocclient.cpp
470 470 setPriority("Music", LOW); 471 471 sendToServer("widget_add Music topWidget string"); 472 472 sendToServer("widget_add Music timeWidget string"); 473 sendToServer("widget_add Music infoWidget string"); 473 474 sendToServer("widget_add Music progressBar hbar"); 474 475 475 476 // The Channel Screen … … 959 960 void LCDProcClient::startMusic(QString artist, QString album, QString track) 960 961 { 961 962 QString aString; 963 music_progress = 0.0; 962 964 if (lcd_showmusic) 963 965 setPriority("Music", HIGH); 964 966 aString = artist; … … 1016 1018 QString aString; 1017 1019 1018 1020 if (lcd_showgeneric) 1019 setPriority("Generic", HIGH);1021 setPriority("Generic", TOP); 1020 1022 1021 1023 // Clear out the LCD. Do this before checking if its empty incase the user 1022 1024 // wants to just clear the lcd … … 1029 1031 return; 1030 1032 1031 1033 activeScreen = "Generic"; 1034 1035 busy_progress = false; 1036 busy_pos = 1; 1037 busy_direction = 1; 1038 busy_indicator_size = 2.0; 1032 1039 generic_progress = 0.0; 1033 1040 1034 1041 // Return if there are no more items … … 1505 1512 outputChannel(); 1506 1513 } 1507 1514 1508 void LCDProcClient::setGenericProgress( float value)1515 void LCDProcClient::setGenericProgress(bool b, float value) 1509 1516 { 1510 1517 if (!lcd_ready) 1511 1518 return; … … 1517 1524 else if (generic_progress > 1.0) 1518 1525 generic_progress = 1.0; 1519 1526 1527 // Note, this will let us switch to/from busy indicator by alternating between 1528 // being passed true or false for b. 1529 busy_progress = b; 1530 if (busy_progress) { 1531 // If we're at either end of the line, switch direction 1532 if (busy_pos + busy_direction > (signed int)lcdWidth - busy_indicator_size || 1533 busy_pos + busy_direction < 1) { 1534 busy_direction = -busy_direction; 1535 } 1536 busy_pos += busy_direction; 1537 generic_progress = busy_indicator_size / (float)lcdWidth; 1538 } else { 1539 busy_pos = 1; 1540 } 1541 1520 1542 outputGeneric(); 1521 1543 } 1522 1544 … … 1536 1558 outputMusic(); 1537 1559 } 1538 1560 1561 void LCDProcClient::setMusicRepeat (int repeat) 1562 { 1563 if (!lcd_ready) 1564 return; 1565 1566 music_repeat = repeat; 1567 1568 outputMusic (); 1569 } 1570 1571 void LCDProcClient::setMusicShuffle (int shuffle) 1572 { 1573 if (!lcd_ready) 1574 return; 1575 1576 music_shuffle = shuffle; 1577 1578 outputMusic (); 1579 } 1580 1539 1581 void LCDProcClient::setVolumeLevel(float value) 1540 1582 { 1541 1583 if (!lcd_ready) … … 1767 1809 1768 1810 void LCDProcClient::outputMusic() 1769 1811 { 1770 QString aString;1812 outputCenteredText("Music", music_time, "timeWidget", 2); 1771 1813 1772 1814 if (lcdHeight > 2) { 1773 outputCenteredText("Music", music_time, "timeWidget", 2); 1815 QString props; 1816 QString shuffle = " "; 1817 QString repeat = " "; 1818 1819 if (music_shuffle == 1) { 1820 shuffle = "Shfl ?"; 1821 } else if (music_shuffle == 2) { 1822 shuffle = "Shfl i"; 1823 } 1824 1825 if (music_repeat == 1) { 1826 repeat = "Rpt 1"; 1827 } else if (music_repeat == 2) { 1828 repeat = "Rpt *"; 1829 } 1830 1831 props.sprintf ("%s %s", shuffle.ascii (), repeat.ascii ()); 1832 1833 outputCenteredText("Music", props, "infoWidget", lcdHeight); 1774 1834 } 1775 1835 1776 aString = "widget_set Music progressBar 1 ";1777 aString += QString::number(lcdHeight);1778 aString += "";1779 aString += QString::number((int)rint(music_progress * lcdWidth *1836 if (lcdHeight > 3) { 1837 QString aString; 1838 aString = "widget_set Music progressBar 1 3 "; 1839 aString += QString::number((int)rint(music_progress * lcdWidth * 1780 1840 cellWidth)); 1781 sendToServer(aString); 1841 sendToServer(aString); 1842 } 1782 1843 } 1783 1844 1784 1845 void LCDProcClient::outputChannel() … … 1794 1855 void LCDProcClient::outputGeneric() 1795 1856 { 1796 1857 QString aString; 1797 aString = "widget_set Generic progressBar 1 "; 1858 aString = "widget_set Generic progressBar "; 1859 aString += QString::number (busy_pos); 1860 aString += " "; 1798 1861 aString += QString::number(lcdHeight); 1799 1862 aString += " "; 1800 1863 aString += QString::number((int)rint(generic_progress * lcdWidth * … … 1935 1998 sendToServer("screen_del Menu menuWidget5"); 1936 1999 1937 2000 sendToServer("widget_del Music progressBar"); 2001 sendToServer("widget_del Music infoWidget"); 1938 2002 sendToServer("widget_del Music timeWidget"); 1939 2003 sendToServer("widget_del Music topWidget"); 1940 2004 sendToServer("screen_del Music"); … … 2003 2067 "- is the master server running?\n\t\t\t" 2004 2068 "Will retry in 30 seconds"); 2005 2069 QTimer::singleShot(30 * 1000, this, SLOT(updateRecordingList())); 2006 switchToTime(); 2070 2071 // If we can't get the recording status and we're showing 2072 // it, switch back to time. Maybe it would be even better 2073 // to show that the backend is unreachable ? 2074 if (activeScreen == "RecStatus") 2075 switchToTime(); 2007 2076 return; 2008 2077 } 2009 2078 } -
mythtv/programs/mythlcdserver/lcdserver.cpp
39 39 time is a string 40 40 progress is a float between 0.0 and 1.0 41 41 42 SET_GENERIC_PROGRESS <progress> 42 SET_MUSIC_PLAYER_PROP <field> <val> 43 field is a string, currently SHUFFLE or REPEAT 44 val depends on field, currently integer 45 46 SET_GENERIC_PROGRESS <busy> <progress> 47 busy is 0 for busy spinner, 0 for normal progess bar 43 48 progress is a float between 0.0 and 1.0 44 49 45 50 UPDATE_LEDS … … 213 218 { 214 219 setMusicProgress(tokens, socket); 215 220 } 221 else if (tokens[0] == "SET_MUSIC_PLAYER_PROP") 222 { 223 setMusicProp(tokens, socket); 224 } 216 225 else if (tokens[0] == "SET_CHANNEL_PROGRESS") 217 226 { 218 227 setChannelProgress(tokens, socket); … … 577 586 578 587 QString flat = tokens.join(" "); 579 588 580 if (tokens.count() != 2)589 if (tokens.count() != 3) 581 590 { 582 591 VERBOSE(VB_IMPORTANT, "LCDServer: bad SET_GENERIC_PROGRESS command: " 583 592 << flat); … … 586 595 } 587 596 588 597 bool bOK; 589 float progress = tokens[1].toFloat(&bOK);598 bool busy = tokens[1].toInt (&bOK); 590 599 if (!bOK) 591 600 { 601 VERBOSE(VB_IMPORTANT, "LCDServer: bad bool value in " 602 "SET_GENERIC_PROGRESS command: %1 %2" << tokens[1] << tokens[2]); 603 sendMessage(socket, "HUH?"); 604 return; 605 } 606 float progress = tokens[2].toFloat(&bOK); 607 if (!bOK) 608 { 592 609 VERBOSE(VB_IMPORTANT, "LCDServer: bad float value in " 593 610 "SET_GENERIC_PROGRESS command: %1" << tokens[1]); 594 611 sendMessage(socket, "HUH?"); … … 596 613 } 597 614 598 615 if (m_lcd) 599 m_lcd->setGenericProgress( progress);616 m_lcd->setGenericProgress(busy, progress); 600 617 601 618 sendMessage(socket, "OK"); 602 619 } … … 632 649 sendMessage(socket, "OK"); 633 650 } 634 651 652 void LCDServer::setMusicProp(const QStringList &tokens, QSocket *socket) 653 { 654 if (debug_level > 0) 655 VERBOSE(VB_GENERAL, "LCDServer: SET_MUSIC_PROP"); 656 657 QString flat = tokens.join(" "); 658 659 if (tokens.count() < 3) 660 { 661 VERBOSE(VB_IMPORTANT, "LCDServer: bad SET_MUSIC_PROP command: " 662 << flat); 663 sendMessage(socket, "HUH?"); 664 return; 665 } 666 667 if (tokens[1] == "SHUFFLE") { 668 if (tokens.count () != 3) { 669 VERBOSE(VB_IMPORTANT, "LCDServer: missing argument for " 670 "SET_MUSIC_PROP SHUFFLE command: " << flat); 671 sendMessage(socket, "HUH?"); 672 return; 673 } 674 bool bOk; 675 int state = tokens[2].toInt (&bOk); 676 if (!bOk) { 677 VERBOSE(VB_IMPORTANT, "LCDServer: bad argument for " 678 "SET_MUSIC_PROP SHUFFLE command: " << tokens[2]); 679 sendMessage(socket, "HUH?"); 680 return; 681 } 682 if (m_lcd) 683 m_lcd->setMusicShuffle (state); 684 } else if (tokens[1] == "REPEAT") { 685 if (tokens.count () != 3) { 686 VERBOSE(VB_IMPORTANT, "LCDServer: missing argument for " 687 "SET_MUSIC_PROP REPEAT command: " << flat); 688 sendMessage(socket, "HUH?"); 689 return; 690 } 691 bool bOk; 692 int state = tokens[2].toInt (&bOk); 693 if (!bOk) { 694 VERBOSE(VB_IMPORTANT, "LCDServer: bad argument for " 695 "SET_MUSIC_PROP REPEAT command: " << tokens[2]); 696 sendMessage(socket, "HUH?"); 697 return; 698 } 699 if (m_lcd) 700 m_lcd->setMusicRepeat (state); 701 } else { 702 VERBOSE(VB_IMPORTANT, "LCDServer: bad argument for " 703 "SET_MUSIC_PROP command: " << tokens[1]); 704 sendMessage(socket, "HUH?"); 705 return; 706 } 707 708 sendMessage(socket, "OK"); 709 } 710 635 711 void LCDServer::setVolumeLevel(const QStringList &tokens, QSocket *socket) 636 712 { 637 713 if (debug_level > 0) -
mythtv/programs/mythlcdserver/lcdprocclient.h
39 39 40 40 void switchToMusic(const QString &artist, const QString &album, const QString &track); 41 41 void setMusicProgress(QString time, float generic_progress); 42 void setMusicRepeat (int repeat); 43 void setMusicShuffle (int shuffle); 42 44 void setLevels(int numbLevels, float *values); 43 45 44 46 void switchToChannel(QString channum = "", QString title = "", … … 49 51 bool popMenu = true); 50 52 51 53 void switchToGeneric(QPtrList<LCDTextItem> *textItems); 52 void setGenericProgress( float generic_progress);54 void setGenericProgress(bool busy, float generic_progress); 53 55 54 56 void switchToVolume(QString app_name); 55 57 void setVolumeLevel(float volume_level); … … 162 164 163 165 float EQlevels[10]; 164 166 float progress; 167 /** TRUE if the generic progress indicator is a busy (ie. doesn't have a known total steps */ 168 bool busy_progress; 169 /** Current position of the busy indicator, used if @p busy_progress is true. */ 170 int busy_pos; 171 /** How many "blocks" the busy indicator must be, used if @p busy_progress is true. */ 172 float busy_indicator_size; 173 /** Dicrection of the busy indicator on the, -1 or 1, used if @p busy_progress is true. */ 174 int busy_direction; 165 175 float generic_progress; 166 176 float volume_level; 167 177 168 178 float music_progress; 169 179 QString music_time; 180 int music_repeat; 181 int music_shuffle; 170 182 171 183 QString scrollingText; 172 184 QString scrollScreen, scrollWidget; -
mythplugins/mythmusic/mythmusic/playbackbox.cpp
772 772 773 773 if (curMeta) 774 774 { 775 if (class LCD * lcd = LCD::Get()) 776 { 777 // Set track info on the LCD 778 QPtrList<LCDTextItem> textItems; 779 textItems.setAutoDelete(true); 780 lcd->switchToMusic(curMeta->Artist (), 781 curMeta->Album (), 782 curMeta->Title ()); 783 } 775 setTrackOnLCD (curMeta); 784 776 } 785 777 } 786 778 else … … 850 842 851 843 if (curMeta) 852 844 { 853 if (class LCD * lcd = LCD::Get()) 854 { 855 //Show the artist stuff on the LCD 856 lcd->switchToMusic(curMeta->Artist (), 857 curMeta->Album (), 858 curMeta->Title ()); 859 lcd_volume_visible = false; 860 } 845 setTrackOnLCD (curMeta); 861 846 } 862 847 } 863 848 } … … 1036 1021 } 1037 1022 } 1038 1023 1024 void PlaybackBoxMusic::setTrackOnLCD (Metadata *mdata) { 1025 if (class LCD * lcd = LCD::Get()) 1026 { 1027 // Set the Artist and Tract on the LCD 1028 lcd->switchToMusic(mdata->Artist (), 1029 mdata->Album (), 1030 mdata->Title ()); 1031 } 1032 } 1039 1033 1040 1034 void PlaybackBoxMusic::pause(void) 1041 1035 { … … 1247 1241 shuffle_button->setText(tr("Shuffle: Smart")); 1248 1242 } 1249 1243 music_tree_list->scrambleParents(true); 1244 1245 if (class LCD * lcd = LCD::Get ()) 1246 lcd->setMusicShuffle (LCD::MUSIC_SHUFFLE_SMART); 1250 1247 break; 1251 1248 case SHUFFLE_RANDOM: 1252 1249 if(shuffle_button) … … 1257 1254 shuffle_button->setText(tr("Shuffle: Rand")); 1258 1255 } 1259 1256 music_tree_list->scrambleParents(true); 1257 1258 if (class LCD * lcd = LCD::Get ()) 1259 lcd->setMusicShuffle (LCD::MUSIC_SHUFFLE_RAND); 1260 1260 break; 1261 1261 default: 1262 1262 if(shuffle_button) … … 1267 1267 shuffle_button->setText(tr("Shuffle: None")); 1268 1268 } 1269 1269 music_tree_list->scrambleParents(false); 1270 1271 if (class LCD * lcd = LCD::Get ()) 1272 lcd->setMusicShuffle (LCD::MUSIC_SHUFFLE_NONE); 1270 1273 break; 1271 1274 } 1272 1275 music_tree_list->setTreeOrdering(shufflemode + 1); … … 1275 1278 else 1276 1279 music_tree_list->setVisualOrdering(1); 1277 1280 music_tree_list->refresh(); 1281 1282 if (isplaying) { 1283 setTrackOnLCD (curMeta); 1284 } 1278 1285 } 1279 1286 1280 1287 void PlaybackBoxMusic::toggleShuffle(void) … … 1325 1332 repeat_button->setText(tr("2 Repeat: All")); 1326 1333 else 1327 1334 repeat_button->setText(tr("Repeat: All")); 1335 1336 if (class LCD * lcd = LCD::Get ()) 1337 lcd->setMusicRepeat (LCD::MUSIC_REPEAT_ALL); 1328 1338 break; 1329 1339 case REPEAT_TRACK: 1330 1340 if (keyboard_accelerators) 1331 1341 repeat_button->setText(tr("2 Repeat: Track")); 1332 1342 else 1333 1343 repeat_button->setText(tr("Repeat: Track")); 1344 1345 if (class LCD * lcd = LCD::Get ()) 1346 lcd->setMusicRepeat (LCD::MUSIC_REPEAT_TRACK); 1334 1347 break; 1335 1348 default: 1336 1349 if (keyboard_accelerators) 1337 1350 repeat_button->setText(tr("2 Repeat: None")); 1338 1351 else 1339 1352 repeat_button->setText(tr("Repeat: None")); 1353 1354 if (class LCD * lcd = LCD::Get ()) 1355 lcd->setMusicRepeat (LCD::MUSIC_REPEAT_NONE); 1340 1356 break; 1341 1357 } 1342 1358 } … … 1437 1453 { 1438 1454 case OutputEvent::Playing: 1439 1455 { 1440 if (class LCD * lcd = LCD::Get()) { 1441 // Set track info on the LCD 1442 QPtrList<LCDTextItem> textItems; 1443 textItems.setAutoDelete(true); 1444 lcd->switchToMusic(curMeta->Artist (), 1445 curMeta->Album (), 1446 curMeta->Title ()); 1447 } 1456 setTrackOnLCD (curMeta); 1448 1457 statusString = tr("Playing stream."); 1449 1458 break; 1450 1459 } … … 1613 1622 if (album_text) 1614 1623 album_text->SetText(curMeta->Album()); 1615 1624 1616 if (class LCD * lcd = LCD::Get()) 1617 { 1618 // Set the Artist and Tract on the LCD 1619 lcd->switchToMusic(curMeta->Artist (), 1620 curMeta->Album (), 1621 curMeta->Title ()); 1622 } 1625 setTrackOnLCD (curMeta); 1623 1626 1624 1627 maxTime = curMeta->Length() / 1000; 1625 1628 -
mythplugins/mythmusic/mythmusic/playbackbox.h
100 100 void updatePlaylistFromSmartPlaylist(QString category, QString name); 101 101 void CycleVisualizer(void); 102 102 void updatePlaylistFromCD(void); 103 void setTrackOnLCD (Metadata *mdata); 103 104 104 105 void postUpdate(); 105 106
