Fall back to /RADIO/models.yml in case /MODELS/models.yml is not present

and do not load models.txt unless we are explicitly converting.
This commit is contained in:
Raphael Coeffic
2021-11-22 12:52:53 +01:00
committed by Raphael Coeffic
parent 5290820ada
commit 959f6c18e7
3 changed files with 8 additions and 2 deletions
+1
View File
@@ -62,6 +62,7 @@ const char RADIO_MODELSLIST_PATH[] = RADIO_PATH PATH_SEPARATOR "models.txt";
const char RADIO_SETTINGS_PATH[] = RADIO_PATH PATH_SEPARATOR RADIO_FILENAME; const char RADIO_SETTINGS_PATH[] = RADIO_PATH PATH_SEPARATOR RADIO_FILENAME;
#if defined(SDCARD_YAML) #if defined(SDCARD_YAML)
const char MODELSLIST_YAML_PATH[] = MODELS_PATH PATH_SEPARATOR "models.yml"; const char MODELSLIST_YAML_PATH[] = MODELS_PATH PATH_SEPARATOR "models.yml";
const char FALLBACK_MODELSLIST_YAML_PATH[] = RADIO_PATH PATH_SEPARATOR "models.yml";
const char RADIO_SETTINGS_YAML_PATH[] = RADIO_PATH PATH_SEPARATOR "radio.yml"; const char RADIO_SETTINGS_YAML_PATH[] = RADIO_PATH PATH_SEPARATOR "radio.yml";
#endif #endif
#define SPLASH_FILE "splash.png" #define SPLASH_FILE "splash.png"
+6 -1
View File
@@ -352,6 +352,10 @@ bool ModelsList::loadYaml()
{ {
char line[LEN_MODELS_IDX_LINE+1]; char line[LEN_MODELS_IDX_LINE+1];
FRESULT result = f_open(&file, MODELSLIST_YAML_PATH, FA_OPEN_EXISTING | FA_READ); FRESULT result = f_open(&file, MODELSLIST_YAML_PATH, FA_OPEN_EXISTING | FA_READ);
if (result != FR_OK) {
result = f_open(&file, FALLBACK_MODELSLIST_YAML_PATH, FA_OPEN_EXISTING | FA_READ);
}
if (result == FR_OK) { if (result == FR_OK) {
// YAML reader // YAML reader
TRACE("YAML modelslist reader"); TRACE("YAML modelslist reader");
@@ -395,7 +399,8 @@ bool ModelsList::load(Format fmt)
FILINFO fno; FILINFO fno;
if (fmt == Format::txt || if (fmt == Format::txt ||
(fmt == Format::yaml_txt && (fmt == Format::yaml_txt &&
f_stat(MODELSLIST_YAML_PATH, &fno) != FR_OK)) { f_stat(MODELSLIST_YAML_PATH, &fno) != FR_OK &&
f_stat(FALLBACK_MODELSLIST_YAML_PATH, &fno) != FR_OK)) {
res = loadTxt(); res = loadTxt();
} else { } else {
res = loadYaml(); res = loadYaml();
+1 -1
View File
@@ -108,7 +108,7 @@ public:
#if defined(SDCARD_YAML) #if defined(SDCARD_YAML)
yaml, yaml,
yaml_txt, yaml_txt,
load_default = yaml_txt, load_default = yaml,
#else #else
load_default = txt, load_default = txt,
#endif #endif