chore(radio): remove EEPROM macros and related code (#5461)
This commit is contained in:
@@ -25,7 +25,6 @@
|
||||
|
||||
using std::list;
|
||||
|
||||
#if defined(SDCARD_YAML)
|
||||
#include "edgetx.h"
|
||||
#include "storage/sdcard_yaml.h"
|
||||
#include "yaml/yaml_datastructs.h"
|
||||
@@ -33,8 +32,6 @@ using std::list;
|
||||
#include "yaml/yaml_modelslist.h"
|
||||
#include "yaml/yaml_parser.h"
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(USBJ_EX)
|
||||
#include "usb_joystick.h"
|
||||
#endif
|
||||
@@ -920,44 +917,6 @@ void ModelsList::clear()
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Load and parse the models.txt file
|
||||
*
|
||||
* @return true On Success
|
||||
* @return false On Failure
|
||||
*/
|
||||
|
||||
bool ModelsList::loadTxt()
|
||||
{
|
||||
char line[LEN_MODELS_IDX_LINE + 1];
|
||||
ModelCell *model = nullptr;
|
||||
|
||||
FRESULT result =
|
||||
f_open(&file, RADIO_MODELSLIST_PATH, FA_OPEN_EXISTING | FA_READ);
|
||||
if (result == FR_OK) {
|
||||
// TXT reader
|
||||
while (readNextLine(line, LEN_MODELS_IDX_LINE)) {
|
||||
int len = strlen(line); // TODO could be returned by readNextLine
|
||||
if (len > 2 && line[0] == '[' && line[len - 1] == ']') {
|
||||
line[len - 1] = '\0';
|
||||
} else if (len > 0) {
|
||||
model = new ModelCell(line);
|
||||
push_back(model);
|
||||
if (!strncmp(line, g_eeGeneral.currModelFilename, LEN_MODEL_FILENAME)) {
|
||||
currentModel = model;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
f_close(&file);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(SDCARD_YAML)
|
||||
|
||||
/**
|
||||
* @brief Opens a YAML file, reads the data and updates the ModelCell
|
||||
*
|
||||
@@ -1222,35 +1181,19 @@ bool ModelsList::loadYaml()
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Called to load the model data from file
|
||||
*
|
||||
* @param fmt Format::txt - Opens models.txt file, Format::yaml_txt - Opens
|
||||
* labels.yml
|
||||
* @return true on success
|
||||
* @return false on failure
|
||||
*/
|
||||
|
||||
bool ModelsList::load(Format fmt)
|
||||
bool ModelsList::load()
|
||||
{
|
||||
if (loaded) return true;
|
||||
|
||||
bool res = false;
|
||||
#if !defined(SDCARD_YAML)
|
||||
(void)fmt;
|
||||
res = loadTxt();
|
||||
#else
|
||||
FILINFO fno;
|
||||
if (fmt == Format::txt ||
|
||||
(fmt == Format::yaml_txt && f_stat(MODELSLIST_YAML_PATH, &fno) != FR_OK &&
|
||||
f_stat(FALLBACK_MODELSLIST_YAML_PATH, &fno) != FR_OK)) {
|
||||
res = loadTxt();
|
||||
} else {
|
||||
res = loadYaml();
|
||||
}
|
||||
#endif
|
||||
bool res = loadYaml();
|
||||
|
||||
if (!currentModel) {
|
||||
TRACE("ERROR no Current Model Found");
|
||||
@@ -1283,13 +1226,8 @@ bool ModelsList::load(Format fmt)
|
||||
|
||||
const char *ModelsList::save(LabelsVector newOrder)
|
||||
{
|
||||
#if !defined(SDCARD_YAML)
|
||||
FRESULT result =
|
||||
f_open(&file, RADIO_MODELSLIST_PATH, FA_CREATE_ALWAYS | FA_WRITE);
|
||||
#else
|
||||
FRESULT result =
|
||||
f_open(&file, LABELSLIST_YAML_PATH, FA_CREATE_ALWAYS | FA_WRITE);
|
||||
#endif
|
||||
if (result != FR_OK) return "Couldn't open labels.yml for writing";
|
||||
|
||||
// Save current selection
|
||||
@@ -1393,39 +1331,6 @@ void ModelsList::updateCurrentModelCell()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reads a line from a file. Used by loadTxt
|
||||
*
|
||||
* @param line Storage for the read line
|
||||
* @param maxlen maximum read length
|
||||
* @return true Success
|
||||
* @return false Failure
|
||||
*/
|
||||
|
||||
bool ModelsList::readNextLine(char *line, int maxlen)
|
||||
{
|
||||
while (maxlen > 0) {
|
||||
unsigned int br;
|
||||
FRESULT res = f_read(&file, line, 1, &br);
|
||||
if (res == FR_OK && br == 1) {
|
||||
// Return if line read
|
||||
if (*line == 0 || *line == '\n') {
|
||||
*line = 0;
|
||||
return true;
|
||||
}
|
||||
// Move to next char unless '\r' read
|
||||
if (*line != '\r') {
|
||||
line += 1;
|
||||
maxlen -= 1;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
*line = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Creates a new ModelCell
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user