Dateien hochladen nach „“

pull/44/head
positionhigh 3 years ago
parent 2c9c54c517
commit 63cb4413a6
  1. 42
      MicroDexed.ino
  2. 28
      UI.hpp

@ -2190,7 +2190,7 @@ void check_and_create_directories(void)
} }
} }
// create directories for confgiuration files // create directories for configuration files
sprintf(tmp, "/%s", VOICE_CONFIG_PATH); sprintf(tmp, "/%s", VOICE_CONFIG_PATH);
if (!SD.exists(tmp)) if (!SD.exists(tmp))
{ {
@ -2228,18 +2228,44 @@ void check_and_create_directories(void)
SD.mkdir(tmp); SD.mkdir(tmp);
} }
/* //check if updated Fav-System is ready or if setup has to run once.
sprintf(tmp, "/%s/fav-v2", FAV_CONFIG_PATH);
if (!SD.exists(tmp)) {
// Clear now obsolte marker files from Favs.
// Only needs to run once.
for (uint8_t i = 0; i < MAX_BANKS; i++)
{
sprintf(tmp, "/%s/%d/hasfav", FAV_CONFIG_PATH, i);
#ifdef DEBUG
Serial.print(F("Delete Marker File"));
Serial.println(tmp);
#endif
if (SD.exists(tmp))
SD.remove(tmp);
}
// Remove empty Folders. rmdir will only remove strictly emtpy folders, which is the desired result.
// Only needs to run once.
for (uint8_t i = 0; i < MAX_BANKS; i++) for (uint8_t i = 0; i < MAX_BANKS; i++)
{ {
sprintf(tmp, "/%s/%d", FAV_CONFIG_PATH, i); sprintf(tmp, "/%s/%d", FAV_CONFIG_PATH, i);
#ifdef DEBUG #ifdef DEBUG
Serial.print(F("Creating directory ")); Serial.print(F("Delete empty folder"));
Serial.println(tmp); Serial.println(tmp);
#endif #endif
if (!SD.exists(tmp)) if (SD.exists(tmp))
SD.mkdir(tmp); SD.rmdir(tmp);
} }
*/
sprintf(tmp, "/%s/fav-v2", FAV_CONFIG_PATH);
if (!SD.exists(tmp))
SD.mkdir(tmp); // Set Marker so that the Cleanup loops only run once.
} else
Serial.println(F("Favs-V2 ready. "));
} }
#ifdef DEBUG #ifdef DEBUG
else else

@ -6263,7 +6263,7 @@ bool quick_check_favorites_in_bank(uint8_t b, uint8_t instance_id)
if (sd_card > 0) if (sd_card > 0)
{ {
sprintf(tmp, "/%s/%d/hasfav", FAV_CONFIG_PATH, b); sprintf(tmp, "/%s/%d", FAV_CONFIG_PATH, b);
#ifdef DEBUG #ifdef DEBUG
Serial.print("check if there is a Favorite in Bank: "); Serial.print("check if there is a Favorite in Bank: ");
Serial.print(tmp); 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); b = constrain(b, 0, MAX_BANKS - 1);
v = constrain(v, 0, MAX_VOICES - 1); v = constrain(v, 0, MAX_VOICES - 1);
char tmp[18]; char tmp[18];
char tmpfolder[18];
File myFav; File myFav;
uint8_t i = 0, countfavs = 0; uint8_t i = 0, countfavs = 0;
if (sd_card > 0) if (sd_card > 0)
{ {
sprintf(tmp, "/%s/%d/%d.fav", FAV_CONFIG_PATH, b, v); sprintf(tmp, "/%s/%d/%d.fav", FAV_CONFIG_PATH, b, v);
sprintf(tmpfolder, "/%s/%d", FAV_CONFIG_PATH, b);
#ifdef DEBUG #ifdef DEBUG
Serial.println("Save Favorite to SD card..."); Serial.println("Save Favorite to SD card...");
Serial.println(tmp); Serial.println(tmp);
@ -6311,21 +6313,14 @@ void save_favorite(uint8_t b, uint8_t v, uint8_t instance_id)
if (!SD.exists(tmp)) if (!SD.exists(tmp))
{ //create Favorite Semaphore { //create Favorite Semaphore
SD.mkdir(tmp); if (!SD.exists(tmpfolder))
{
SD.mkdir(tmpfolder);
}
myFav = SD.open(tmp, FILE_WRITE); myFav = SD.open(tmp, FILE_WRITE);
myFav.close(); myFav.close();
Serial.println("Favorite saved..."); 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.setCursor(13, 0);
lcd.write(2); //fav symbol lcd.write(2); //fav symbol
#ifdef DEBUG #ifdef DEBUG
@ -6338,17 +6333,18 @@ void save_favorite(uint8_t b, uint8_t v, uint8_t instance_id)
#ifdef DEBUG #ifdef DEBUG
Serial.println("Removed from Favorites..."); Serial.println("Removed from Favorites...");
#endif #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); sprintf(tmp, "/%s/%d/%d.fav", FAV_CONFIG_PATH, b, i);
if (SD.exists(tmp)) countfavs++; if (SD.exists(tmp)) countfavs++;
} }
if (countfavs == 0) { if (countfavs == 0) {
sprintf(tmp, "/%s/%d/hasfav", FAV_CONFIG_PATH, b); sprintf(tmp, "/%s/%d", FAV_CONFIG_PATH, b);
SD.remove(tmp); SD.rmdir(tmp);
#ifdef DEBUG #ifdef DEBUG
Serial.println("Fav count in bank:"); Serial.println("Fav count in bank:");
Serial.print(countfavs); 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 #endif
} }
lcd.setCursor(13, 0); lcd.setCursor(13, 0);

Loading…
Cancel
Save