diff --git a/UI.hpp b/UI.hpp index 4132a86..23e63c8 100644 --- a/UI.hpp +++ b/UI.hpp @@ -6079,29 +6079,50 @@ void locate_previous_non_favorite() void locate_previous_favorite() { - //find previous fav in current bank - lcd.setCursor(3, 0); - lcd.print("= 1 && configuration.performance.bank[selected_instance_id] >= 0) { + + lcd.setCursor(3, 0); + lcd.print("= 1 && favsearcher < 18); + + // if found, we are done. else quick check in previous banks + + if ( check_favorite(configuration.performance.bank[selected_instance_id], configuration.performance.voice[selected_instance_id], + selected_instance_id) == false && configuration.performance.voice[selected_instance_id] >= 0 && + configuration.performance.bank[selected_instance_id] >= 0 && favsearcher < 170) { - configuration.performance.voice[selected_instance_id] = 32; //+1 - //configuration.performance.bank[selected_instance_id]--; - if (configuration.performance.bank[selected_instance_id] < 1 ) - configuration.performance.bank[selected_instance_id] = MAX_BANKS - 1; + configuration.performance.voice[selected_instance_id] = 32; do { //seek for previous bank configuration.performance.bank[selected_instance_id]--; - if (configuration.performance.bank[selected_instance_id] < 1 ) - configuration.performance.bank[selected_instance_id] = MAX_BANKS - 1; favsearcher++; - } while (quick_check_favorites_in_bank(configuration.performance.bank[selected_instance_id], selected_instance_id) == false && favsearcher < 132); + } while (quick_check_favorites_in_bank(configuration.performance.bank[selected_instance_id], selected_instance_id) == false && + favsearcher < 132 && configuration.performance.bank[selected_instance_id] >= 0); + + do { //last try to search if a bank with fav was found + + configuration.performance.voice[selected_instance_id]--; + favsearcher++; + } while ( check_favorite(configuration.performance.bank[selected_instance_id], configuration.performance.voice[selected_instance_id], + selected_instance_id) == false && configuration.performance.voice[selected_instance_id] >= 1 && favsearcher < 170); } - configuration.performance.voice[selected_instance_id]--; - favsearcher++; - } while ( check_favorite(configuration.performance.bank[selected_instance_id], configuration.performance.voice[selected_instance_id], - selected_instance_id) == false && favsearcher < 170); + } favsearcher = 0; }