Radio init / masstorage start / massstorage end / shutdown sequences … (#3674)

* Radio init / masstorage start / massstorage end / shutdown sequences reordering:

- More traces
- Fixes #3642
- Reuses idea of #3662

Still not finished and completely untested

* More traces

* Compilation fix

* Reuses the idea of #3652

* Alarms were checked 2 times on massstorage end
This commit is contained in:
Bertrand Songis
2016-08-01 18:39:34 +02:00
committed by GitHub
parent 6c34752907
commit 6d2c5a4db6
16 changed files with 109 additions and 63 deletions
+3 -3
View File
@@ -44,14 +44,14 @@ void eeLoadModel(uint8_t index)
}
#endif
bool newModel = false;
bool alarms = true;
if (size < EEPROM_MIN_MODEL_SIZE) { // if not loaded a fair amount
modelDefault(index) ;
storageCheck(true);
newModel = true;
alarms = false;
}
postModelLoad(newModel);
postModelLoad(alarms);
}
}
+1 -1
View File
@@ -234,7 +234,7 @@ const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name);
// For conversions
#if defined(CPUARM)
void loadGeneralSettings();
void loadModel(int index);
void loadModel(int index, bool alarms=true);
#endif
bool eepromOpen();
+13 -10
View File
@@ -29,6 +29,8 @@ void getModelPath(char * path, const char * filename)
const char * writeFile(const char * filename, const uint8_t * data, uint16_t size)
{
TRACE("writeFile(%s)", filename);
FIL file;
char buf[8];
UINT written;
@@ -68,6 +70,8 @@ const char * writeModel()
const char * loadFile(const char * filename, uint8_t * data, uint16_t maxsize)
{
TRACE("loadFile(%s)", filename);
FIL file;
char buf[8];
UINT read;
@@ -112,7 +116,7 @@ const char * readModel(const char * filename, uint8_t * buffer, uint32_t size)
return loadFile(path, buffer, size);
}
const char * loadModel(const char * filename)
const char * loadModel(const char * filename, bool alarms)
{
preModelLoad();
@@ -120,15 +124,14 @@ const char * loadModel(const char * filename)
if (error) {
TRACE("loadModel error=%s", error);
}
bool newModel = false;
if (error) {
modelDefault(0) ;
storageCheck(true);
newModel = true;
alarms = false;
}
postModelLoad(newModel);
postModelLoad(alarms);
return error;
}
@@ -171,8 +174,8 @@ void storageCheck(bool immediately)
void storageReadAll()
{
sdInit();
TRACE("storageReadAll");
if (loadGeneralSettings() != NULL) {
storageEraseAll(true);
}
@@ -186,7 +189,7 @@ void storageReadAll()
}
#endif
loadModel(g_eeGeneral.currModelFilename);
loadModel(g_eeGeneral.currModelFilename, false);
}
void storageCreateModelsList()
@@ -223,14 +226,14 @@ const char * createModel()
storageDirty(EE_MODEL);
storageCheck(true);
}
postModelLoad(true);
postModelLoad(false);
return g_eeGeneral.currModelFilename;
}
void storageEraseAll(bool warn)
{
TRACE("storageEraseAll()");
TRACE("storageEraseAll");
#if defined(COLORLCD)
// the theme has not been loaded before
+1 -1
View File
@@ -27,7 +27,7 @@
#define DEFAULT_MODEL_FILENAME "model01.bin"
const char * readModel(const char * filename, uint8_t * buffer, uint32_t size);
const char * loadModel(const char * filename);
const char * loadModel(const char * filename, bool alarms=true);
const char * createModel();
PACK(struct RamBackup {
+1 -1
View File
@@ -52,7 +52,7 @@ void storageDirty(uint8_t msk);
void storageCheck(bool immediately);
void preModelLoad();
void postModelLoad(bool newModel);
void postModelLoad(bool alarms);
#if defined(EEPROM_RLC)
#include "eeprom_common.h"
+2 -2
View File
@@ -56,14 +56,14 @@ void preModelLoad()
pauseMixerCalculations();
}
void postModelLoad(bool newModel)
void postModelLoad(bool alarms)
{
AUDIO_FLUSH();
flightReset(false);
if (pulsesStarted()) {
#if defined(GUI)
if (!newModel) {
if (alarms) {
checkAll();
}
#endif