|
|
|
@ -6263,7 +6263,7 @@ bool quick_check_favorites_in_bank(uint8_t b, uint8_t instance_id) |
|
|
|
|
|
|
|
|
|
if (sd_card > 0) |
|
|
|
|
{ |
|
|
|
|
sprintf(tmp, "/%s/%d/hasfav", FAV_CONFIG_PATH, b); |
|
|
|
|
sprintf(tmp, "/%s/%d", FAV_CONFIG_PATH, b); |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print("check if there is a Favorite in Bank: "); |
|
|
|
|
Serial.print(tmp); |
|
|
|
@ -6298,12 +6298,14 @@ void save_favorite(uint8_t b, uint8_t v, uint8_t instance_id) |
|
|
|
|
b = constrain(b, 0, MAX_BANKS - 1); |
|
|
|
|
v = constrain(v, 0, MAX_VOICES - 1); |
|
|
|
|
char tmp[18]; |
|
|
|
|
char tmpfolder[18]; |
|
|
|
|
File myFav; |
|
|
|
|
uint8_t i = 0, countfavs = 0; |
|
|
|
|
|
|
|
|
|
if (sd_card > 0) |
|
|
|
|
{ |
|
|
|
|
sprintf(tmp, "/%s/%d/%d.fav", FAV_CONFIG_PATH, b, v); |
|
|
|
|
sprintf(tmpfolder, "/%s/%d", FAV_CONFIG_PATH, b); |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println("Save Favorite to SD card..."); |
|
|
|
|
Serial.println(tmp); |
|
|
|
@ -6311,21 +6313,14 @@ void save_favorite(uint8_t b, uint8_t v, uint8_t instance_id) |
|
|
|
|
|
|
|
|
|
if (!SD.exists(tmp)) |
|
|
|
|
{ //create Favorite Semaphore
|
|
|
|
|
SD.mkdir(tmp); |
|
|
|
|
if (!SD.exists(tmpfolder)) |
|
|
|
|
{ |
|
|
|
|
SD.mkdir(tmpfolder); |
|
|
|
|
} |
|
|
|
|
myFav = SD.open(tmp, FILE_WRITE); |
|
|
|
|
myFav.close(); |
|
|
|
|
Serial.println("Favorite saved..."); |
|
|
|
|
|
|
|
|
|
sprintf(tmp, "/%s/%d/hasfav", FAV_CONFIG_PATH, b); //for quick search, bank contains at least 1 favorite
|
|
|
|
|
if (!SD.exists(tmp)) |
|
|
|
|
{ |
|
|
|
|
myFav = SD.open(tmp, FILE_WRITE); |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println("write hasfav file to:"); |
|
|
|
|
Serial.print(tmp); |
|
|
|
|
#endif |
|
|
|
|
myFav.close(); |
|
|
|
|
} |
|
|
|
|
lcd.setCursor(13, 0); |
|
|
|
|
lcd.write(2); //fav symbol
|
|
|
|
|
#ifdef DEBUG |
|
|
|
@ -6338,17 +6333,18 @@ void save_favorite(uint8_t b, uint8_t v, uint8_t instance_id) |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println("Removed from Favorites..."); |
|
|
|
|
#endif |
|
|
|
|
for (i = 0; i < 32; i++) { //if no other favs exist in current bank, remove quick search semaphore
|
|
|
|
|
for (i = 0; i < 32; i++) { //if no other favs exist in current bank, remove folder
|
|
|
|
|
sprintf(tmp, "/%s/%d/%d.fav", FAV_CONFIG_PATH, b, i); |
|
|
|
|
if (SD.exists(tmp)) countfavs++; |
|
|
|
|
} |
|
|
|
|
if (countfavs == 0) { |
|
|
|
|
sprintf(tmp, "/%s/%d/hasfav", FAV_CONFIG_PATH, b); |
|
|
|
|
SD.remove(tmp); |
|
|
|
|
sprintf(tmp, "/%s/%d", FAV_CONFIG_PATH, b); |
|
|
|
|
SD.rmdir(tmp); |
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println("Fav count in bank:"); |
|
|
|
|
Serial.print(countfavs); |
|
|
|
|
Serial.println("Removed hasfav file since no voice in bank flagged as favorite any more"); |
|
|
|
|
Serial.println("Removed folder since no voice in bank flagged as favorite any more"); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
lcd.setCursor(13, 0); |
|
|
|
|