diff --git a/components/homeThing/homeThingMenuBase.cpp b/components/homeThing/homeThingMenuBase.cpp index ef184b03..d71aeae9 100644 --- a/components/homeThing/homeThingMenuBase.cpp +++ b/components/homeThing/homeThingMenuBase.cpp @@ -144,7 +144,7 @@ bool HomeThingMenuBase::selectMenu() { menuIndex = 0; if (menuTree.size() == 1) { reset_menu(); - return false; + return true; } return true; case homething_menu_now_playing::NavigationCoordination:: @@ -378,7 +378,26 @@ void HomeThingMenuBase::buttonPressSelect() { switch (menuTree.back()) { case appMenu: if (active_app_ && active_app_->should_draw_app()) { - active_app_->buttonPressSelect(menuIndex); + switch (active_app_->buttonPressSelect(menuIndex)) { + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationReturn: + return; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationNone: + break; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationUpdate: + update_display(); + return; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationPop: + upMenu(); + return; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationRoot: + topMenu(); + return; + } } break; case lightsDetailMenu: @@ -591,8 +610,26 @@ void HomeThingMenuBase::buttonPressUp() { switch (menuTree.back()) { case appMenu: if (active_app_ && active_app_->should_draw_app()) { - if (active_app_->buttonPressUp()) - update_display(); + switch (active_app_->buttonPressUp()) { + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationReturn: + return; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationNone: + break; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationUpdate: + update_display(); + return; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationPop: + upMenu(); + return; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationRoot: + topMenu(); + return; + } } break; case lightsDetailMenu: @@ -631,8 +668,26 @@ void HomeThingMenuBase::buttonPressDown() { switch (menuTree.back()) { case appMenu: if (active_app_ && active_app_->should_draw_app()) { - if (active_app_->buttonPressDown()) - update_display(); + switch (active_app_->buttonPressDown()) { + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationReturn: + return; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationNone: + break; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationUpdate: + update_display(); + return; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationPop: + upMenu(); + return; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationRoot: + topMenu(); + return; + } } break; default: @@ -646,8 +701,26 @@ void HomeThingMenuBase::buttonPressLeft() { switch (menuTree.back()) { case appMenu: if (active_app_ && active_app_->should_draw_app()) { - if (active_app_->buttonPressLeft()) - update_display(); + switch (active_app_->buttonPressLeft()) { + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationReturn: + return; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationNone: + break; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationUpdate: + update_display(); + return; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationPop: + upMenu(); + return; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationRoot: + topMenu(); + return; + } } break; default: @@ -663,8 +736,26 @@ void HomeThingMenuBase::buttonPressRight() { switch (menuTree.back()) { case appMenu: if (active_app_ && active_app_->should_draw_app()) { - if (active_app_->buttonPressRight()) - update_display(); + switch (active_app_->buttonPressRight()) { + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationReturn: + return; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationNone: + break; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationUpdate: + update_display(); + return; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationPop: + upMenu(); + return; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationRoot: + topMenu(); + return; + } } break; default: @@ -678,8 +769,26 @@ void HomeThingMenuBase::buttonReleaseScreenLeft() { switch (menuTree.back()) { case appMenu: if (active_app_ && active_app_->should_draw_app()) { - if (active_app_->buttonReleaseScreenLeft()) - update_display(); + switch (active_app_->buttonReleaseScreenLeft()) { + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationReturn: + return; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationNone: + break; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationUpdate: + update_display(); + return; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationPop: + upMenu(); + return; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationRoot: + topMenu(); + return; + } } break; default: @@ -710,8 +819,23 @@ void HomeThingMenuBase::buttonPressScreenLeft() { switch (menuTree.back()) { case appMenu: if (active_app_ && active_app_->should_draw_app()) { - if (active_app_->buttonPressScreenLeft()) - update_display(); + switch (active_app_->buttonPressScreenLeft()) { + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationNone: + break; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationUpdate: + update_display(); + return; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationPop: + upMenu(); + return; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationRoot: + topMenu(); + return; + } } break; default: @@ -722,14 +846,26 @@ void HomeThingMenuBase::buttonPressScreenLeft() { void HomeThingMenuBase::buttonPressScreenRight() { if (!button_press_and_continue()) return; - // #ifdef USE_MEDIA_PLAYER_GROUP - // circle_menu_->clear_active_menu(); - // #endif switch (menuTree.back()) { case appMenu: if (active_app_ && active_app_->should_draw_app()) { - if (active_app_->buttonPressScreenRight()) - update_display(); + switch (active_app_->buttonPressScreenRight()) { + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationNone: + break; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationUpdate: + update_display(); + return; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationPop: + upMenu(); + return; + case homething_menu_now_playing::NavigationCoordination:: + NavigationCoordinationRoot: + topMenu(); + return; + } } break; case rootMenu: diff --git a/components/homeThing/homeThingMenuNowPlayingControl.cpp b/components/homeThing/homeThingMenuNowPlayingControl.cpp index c32518b2..f6318f99 100644 --- a/components/homeThing/homeThingMenuNowPlayingControl.cpp +++ b/components/homeThing/homeThingMenuNowPlayingControl.cpp @@ -257,7 +257,7 @@ void HomeThingMenuNowPlayingControl::draw_app( void HomeThingMenuNowPlayingControl::idleTick(int idleTime, int display_timeout) { - ESP_LOGD(TAG, "idleTick: idle %d", idleTime); + ESP_LOGI(TAG, "idleTick: idle %d", idleTime); if (idleTime == 3) { circle_menu_->clear_active_menu(); } else if (idleTime == display_timeout) { @@ -424,11 +424,12 @@ void HomeThingMenuNowPlayingControl::rotaryScrollCounterClockwise(int rotary) { media_player_group_->active_player_); } -bool HomeThingMenuNowPlayingControl::buttonPressUp() { +NavigationCoordination HomeThingMenuNowPlayingControl::buttonPressUp() { switch (button_press_now_playing_option(CircleOptionMenuPosition::TOP)) { case NavigationCoordination::NavigationCoordinationUpdate: + return NavigationCoordination::NavigationCoordinationUpdate; case NavigationCoordination::NavigationCoordinationPop: - return true; + return NavigationCoordination::NavigationCoordinationPop; default: break; } @@ -437,18 +438,19 @@ bool HomeThingMenuNowPlayingControl::buttonPressUp() { case homeassistant_media_player::RemotePlayerType::TVRemotePlayerType: media_player_group_->sendActivePlayerRemoteCommand( homeassistant_media_player::MediaPlayerTVRemoteCommand::UP); - return false; + return NavigationCoordination::NavigationCoordinationReturn; case homeassistant_media_player::RemotePlayerType::SpeakerRemotePlayerType: break; } - return false; + return NavigationCoordination::NavigationCoordinationPop; } -bool HomeThingMenuNowPlayingControl::buttonPressDown() { +NavigationCoordination HomeThingMenuNowPlayingControl::buttonPressDown() { switch (button_press_now_playing_option(CircleOptionMenuPosition::BOTTOM)) { case NavigationCoordination::NavigationCoordinationUpdate: + return NavigationCoordination::NavigationCoordinationUpdate; case NavigationCoordination::NavigationCoordinationPop: - return true; + return NavigationCoordination::NavigationCoordinationPop; default: break; } @@ -457,19 +459,20 @@ bool HomeThingMenuNowPlayingControl::buttonPressDown() { case homeassistant_media_player::RemotePlayerType::TVRemotePlayerType: media_player_group_->sendActivePlayerRemoteCommand( homeassistant_media_player::MediaPlayerTVRemoteCommand::DOWN); - break; + return NavigationCoordination::NavigationCoordinationReturn; case homeassistant_media_player::RemotePlayerType::SpeakerRemotePlayerType: media_player_group_->active_player_->playPause(); break; } - return false; + return NavigationCoordination::NavigationCoordinationNone; } -bool HomeThingMenuNowPlayingControl::buttonPressLeft() { +NavigationCoordination HomeThingMenuNowPlayingControl::buttonPressLeft() { switch (button_press_now_playing_option(CircleOptionMenuPosition::LEFT)) { case NavigationCoordination::NavigationCoordinationUpdate: + return NavigationCoordination::NavigationCoordinationUpdate; case NavigationCoordination::NavigationCoordinationPop: - return true; + return NavigationCoordination::NavigationCoordinationPop; default: break; } @@ -478,19 +481,20 @@ bool HomeThingMenuNowPlayingControl::buttonPressLeft() { case homeassistant_media_player::RemotePlayerType::TVRemotePlayerType: media_player_group_->sendActivePlayerRemoteCommand( homeassistant_media_player::MediaPlayerTVRemoteCommand::LEFT); - break; + return NavigationCoordination::NavigationCoordinationReturn; case homeassistant_media_player::RemotePlayerType::SpeakerRemotePlayerType: circle_menu_->clear_active_menu(); break; } - return false; + return NavigationCoordination::NavigationCoordinationNone; } -bool HomeThingMenuNowPlayingControl::buttonPressRight() { +NavigationCoordination HomeThingMenuNowPlayingControl::buttonPressRight() { switch (button_press_now_playing_option(CircleOptionMenuPosition::RIGHT)) { case NavigationCoordination::NavigationCoordinationUpdate: + return NavigationCoordination::NavigationCoordinationUpdate; case NavigationCoordination::NavigationCoordinationPop: - return true; + return NavigationCoordination::NavigationCoordinationPop; default: break; } @@ -499,15 +503,24 @@ bool HomeThingMenuNowPlayingControl::buttonPressRight() { case homeassistant_media_player::RemotePlayerType::TVRemotePlayerType: media_player_group_->sendActivePlayerRemoteCommand( homeassistant_media_player::MediaPlayerTVRemoteCommand::RIGHT); - break; + return NavigationCoordination::NavigationCoordinationReturn; case homeassistant_media_player::RemotePlayerType::SpeakerRemotePlayerType: media_player_group_->active_player_->nextTrack(); break; } - return false; + return NavigationCoordination::NavigationCoordinationNone; } -bool HomeThingMenuNowPlayingControl::buttonPressSelect(int menuIndex) { +NavigationCoordination HomeThingMenuNowPlayingControl::buttonPressSelect( + int menuIndex) { + switch (button_press_now_playing_option(CircleOptionMenuPosition::CENTER)) { + case NavigationCoordination::NavigationCoordinationUpdate: + return NavigationCoordination::NavigationCoordinationUpdate; + case NavigationCoordination::NavigationCoordinationPop: + return NavigationCoordination::NavigationCoordinationPop; + default: + break; + } auto features = media_player_group_->active_player_->get_option_menu_features(true); auto active_feature = (*features)[menuIndex]; @@ -528,24 +541,25 @@ bool HomeThingMenuNowPlayingControl::buttonPressSelect(int menuIndex) { break; } select_media_player_feature(active_feature); - return true; + return NavigationCoordination::NavigationCoordinationUpdate; } -bool HomeThingMenuNowPlayingControl::buttonPressSelectHold() { - return false; +NavigationCoordination HomeThingMenuNowPlayingControl::buttonPressSelectHold() { + return NavigationCoordination::NavigationCoordinationNone; } -bool HomeThingMenuNowPlayingControl::buttonPressScreenLeft() { +NavigationCoordination HomeThingMenuNowPlayingControl::buttonPressScreenLeft() { if (circle_menu_->get_active_menu()) { circle_menu_->clear_active_menu(); } else { circle_menu_->set_active_menu(speakerOptionMenu, media_player_group_->active_player_); } - return true; + return NavigationCoordination::NavigationCoordinationUpdate; } -bool HomeThingMenuNowPlayingControl::buttonReleaseScreenLeft() { +NavigationCoordination +HomeThingMenuNowPlayingControl::buttonReleaseScreenLeft() { switch (media_player_group_->active_player_->get_player_type()) { case homeassistant_media_player::RemotePlayerType::TVRemotePlayerType: // update_display(); @@ -553,12 +567,13 @@ bool HomeThingMenuNowPlayingControl::buttonReleaseScreenLeft() { case homeassistant_media_player::RemotePlayerType::SpeakerRemotePlayerType: break; } - return false; + return NavigationCoordination::NavigationCoordinationNone; } -bool HomeThingMenuNowPlayingControl::buttonPressScreenRight() { +NavigationCoordination +HomeThingMenuNowPlayingControl::buttonPressScreenRight() { media_player_group_->selectNextMediaPlayer(); - return true; + return NavigationCoordination::NavigationCoordinationUpdate; } // header diff --git a/components/homeThing/homeThingMenuNowPlayingControl.h b/components/homeThing/homeThingMenuNowPlayingControl.h index 0fd4f157..a69fdca1 100644 --- a/components/homeThing/homeThingMenuNowPlayingControl.h +++ b/components/homeThing/homeThingMenuNowPlayingControl.h @@ -18,7 +18,8 @@ enum NavigationCoordination { NavigationCoordinationNone, NavigationCoordinationPop, NavigationCoordinationRoot, - NavigationCoordinationUpdate + NavigationCoordinationUpdate, + NavigationCoordinationReturn }; class HomeThingMenuNowPlayingControl @@ -55,15 +56,15 @@ class HomeThingMenuNowPlayingControl // buttons void rotaryScrollClockwise(int rotary); void rotaryScrollCounterClockwise(int rotary); - bool buttonPressUp(); - bool buttonPressDown(); - bool buttonPressLeft(); - bool buttonPressRight(); - bool buttonPressSelect(int menuIndex); - bool buttonPressSelectHold(); - bool buttonPressScreenLeft(); - bool buttonReleaseScreenLeft(); - bool buttonPressScreenRight(); + NavigationCoordination buttonPressUp(); + NavigationCoordination buttonPressDown(); + NavigationCoordination buttonPressLeft(); + NavigationCoordination buttonPressRight(); + NavigationCoordination buttonPressSelect(int menuIndex); + NavigationCoordination buttonPressSelectHold(); + NavigationCoordination buttonPressScreenLeft(); + NavigationCoordination buttonReleaseScreenLeft(); + NavigationCoordination buttonPressScreenRight(); // header std::string get_header_title();