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
|
||||
*
|
||||
|
||||
@@ -34,10 +34,6 @@
|
||||
|
||||
#include "sdcard.h"
|
||||
|
||||
#if !defined(SDCARD_YAML)
|
||||
#include "sdcard_raw.h"
|
||||
#endif
|
||||
|
||||
#include "dataconstants.h"
|
||||
#include "rtc.h"
|
||||
|
||||
@@ -221,21 +217,10 @@ class ModelsList : public ModelsVector
|
||||
void init();
|
||||
|
||||
public:
|
||||
enum class Format {
|
||||
txt,
|
||||
#if defined(SDCARD_YAML)
|
||||
yaml,
|
||||
yaml_txt,
|
||||
load_default = yaml,
|
||||
#else
|
||||
load_default = txt,
|
||||
#endif
|
||||
};
|
||||
|
||||
ModelsList();
|
||||
~ModelsList();
|
||||
|
||||
bool load(Format fmt = Format::load_default);
|
||||
bool load();
|
||||
const char *save(LabelsVector newOrder=LabelsVector());
|
||||
void clear();
|
||||
|
||||
@@ -249,8 +234,6 @@ class ModelsList : public ModelsVector
|
||||
return std::vector<ModelCell *>::size();
|
||||
}
|
||||
|
||||
bool readNextLine(char *line, int maxlen);
|
||||
|
||||
ModelCell *addModel(const char *name, bool save = true, ModelCell *copyCell = nullptr);
|
||||
bool removeModel(ModelCell *model);
|
||||
bool moveModelTo(unsigned curindex, unsigned toindex);
|
||||
@@ -269,11 +252,8 @@ class ModelsList : public ModelsVector
|
||||
protected:
|
||||
FIL file;
|
||||
|
||||
bool loadTxt();
|
||||
#if defined(SDCARD_YAML)
|
||||
bool loadYaml();
|
||||
bool loadYamlDirScanner();
|
||||
#endif
|
||||
};
|
||||
|
||||
ModelLabelsVector getUniqueLabels();
|
||||
|
||||
@@ -25,29 +25,10 @@
|
||||
#include "translations.h"
|
||||
|
||||
#define MODEL_FILENAME_PREFIX "model"
|
||||
#if defined(SDCARD_RAW)
|
||||
#define MODEL_FILENAME_SUFFIX ".bin"
|
||||
#elif defined(SDCARD_YAML)
|
||||
#define MODEL_FILENAME_SUFFIX ".yml"
|
||||
#endif
|
||||
#define DEFAULT_MODEL_FILENAME MODEL_FILENAME_PREFIX "1" MODEL_FILENAME_SUFFIX
|
||||
#define MODEL_FILENAME_PATTERN MODEL_FILENAME_PREFIX MODEL_FILENAME_SUFFIX
|
||||
|
||||
#if !defined(STORAGE_MODELSLIST)
|
||||
extern ModelHeader modelHeaders[MAX_MODELS];
|
||||
#endif
|
||||
|
||||
// opens radio.bin or model file
|
||||
const char* openFileBin(const char* fullpath, FIL* file, uint16_t* size,
|
||||
uint8_t* version);
|
||||
|
||||
const char* writeFileBin(const char* fullpath, const uint8_t* data,
|
||||
uint16_t size, uint8_t version = EEPROM_VER);
|
||||
|
||||
// open, read, and close the file
|
||||
const char *loadFileBin(const char *fullpath, uint8_t *data,
|
||||
uint16_t maxsize, uint8_t *version);
|
||||
|
||||
// writes a complete YAML file
|
||||
struct YamlNode;
|
||||
const char* writeFileYaml(const char* path, const YamlNode* root_node, uint8_t* data, uint16_t checksum);
|
||||
@@ -62,6 +43,8 @@ const char * writeModel();
|
||||
|
||||
#if !defined(STORAGE_MODELSLIST)
|
||||
|
||||
extern ModelHeader modelHeaders[MAX_MODELS];
|
||||
|
||||
// index storage vs modelslist
|
||||
void selectModel(uint8_t idx);
|
||||
const char* loadModel(uint8_t idx, bool alarms=true);
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "FatFs/ff.h"
|
||||
|
||||
#if defined(SDCARD_RAW)
|
||||
|
||||
#define writeModel writeModelBin
|
||||
#define loadRadioSettings loadRadioSettingsBin
|
||||
#define writeGeneralSettings writeGeneralSettingsBin
|
||||
|
||||
const char* readModel(const char* filename, uint8_t* buffer, uint32_t size);
|
||||
|
||||
#endif
|
||||
|
||||
const char* loadRadioSettingsBin();
|
||||
const char * writeGeneralSettingsBin();
|
||||
|
||||
const char* openFileBin(const char* fullpath, FIL* file, uint16_t* size,
|
||||
uint8_t* version);
|
||||
|
||||
const char* readModelBin(const char* filename, uint8_t* buffer, uint32_t size,
|
||||
uint8_t* version);
|
||||
|
||||
const char* writeModelBin();
|
||||
@@ -25,7 +25,6 @@
|
||||
#include "edgetx_helpers.h"
|
||||
#include "storage.h"
|
||||
#include "sdcard_common.h"
|
||||
#include "sdcard_raw.h"
|
||||
#include "sdcard_yaml.h"
|
||||
#include "modelslist.h"
|
||||
|
||||
@@ -34,12 +33,6 @@
|
||||
#include "yaml/yaml_datastructs.h"
|
||||
#include "yaml/yaml_bits.h"
|
||||
|
||||
|
||||
#if defined(EEPROM_RLC)
|
||||
#include "storage/eeprom_common.h"
|
||||
#include "storage/eeprom_rlc.h"
|
||||
#endif
|
||||
|
||||
const char * readYamlFile(const char* fullpath, const YamlParserCalls* calls, void* parser_ctx, ChecksumResult* checksum_result)
|
||||
{
|
||||
FIL file;
|
||||
|
||||
@@ -58,7 +58,6 @@ void storageFlushCurrentModel();
|
||||
void postRadioSettingsLoad();
|
||||
void preModelLoad();
|
||||
void postModelLoad(bool alarms);
|
||||
void checkExternalAntenna();
|
||||
|
||||
#if !defined(STORAGE_MODELSLIST)
|
||||
extern ModelHeader modelHeaders[MAX_MODELS];
|
||||
@@ -69,13 +68,7 @@ void loadModelHeaders();
|
||||
uint8_t findNextUnusedModelId(uint8_t index, uint8_t module);
|
||||
#endif
|
||||
|
||||
#if defined(EEPROM)
|
||||
#include "eeprom_common.h"
|
||||
#endif
|
||||
|
||||
#if defined(SDCARD_RAW) || defined(SDCARD_YAML)
|
||||
#include "sdcard_common.h"
|
||||
#endif
|
||||
|
||||
#if defined(RTC_BACKUP_RAM)
|
||||
#include "rtc_backup.h"
|
||||
|
||||
@@ -63,9 +63,7 @@ void preModelLoad()
|
||||
{
|
||||
watchdogSuspend(500/*5s*/);
|
||||
|
||||
#if defined(SDCARD)
|
||||
logsClose();
|
||||
#endif
|
||||
|
||||
bool needDelay = false;
|
||||
if (mixerTaskStarted()) {
|
||||
@@ -285,9 +283,7 @@ if(g_model.rssiSource) {
|
||||
pulsesStart();
|
||||
}
|
||||
|
||||
#if defined(SDCARD)
|
||||
referenceModelAudioFiles();
|
||||
#endif
|
||||
|
||||
#if defined(COLORLCD)
|
||||
LayoutFactory::loadCustomScreens();
|
||||
|
||||
Reference in New Issue
Block a user