Use simple scheme with direct model slot to model filename
This commit is contained in:
@@ -56,37 +56,6 @@ void eeLoadModel(uint8_t index)
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t eeFindEmptyModel(uint8_t id, bool down)
|
||||
{
|
||||
uint8_t i = id;
|
||||
for (;;) {
|
||||
i = (MAX_MODELS + (down ? i+1 : i-1)) % MAX_MODELS;
|
||||
if (!eeModelExists(i)) break;
|
||||
if (i == id) return 0xff; // no free space in directory left
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
void selectModel(uint8_t sub)
|
||||
{
|
||||
#if !defined(COLORLCD)
|
||||
showMessageBox(STR_LOADINGMODEL);
|
||||
#endif
|
||||
storageFlushCurrentModel();
|
||||
storageCheck(true); // force writing of current model data before this is changed
|
||||
g_eeGeneral.currModel = sub;
|
||||
storageDirty(EE_GENERAL);
|
||||
eeLoadModel(sub);
|
||||
}
|
||||
|
||||
ModelHeader modelHeaders[MAX_MODELS];
|
||||
void eeLoadModelHeaders()
|
||||
{
|
||||
for (uint32_t i=0; i<MAX_MODELS; i++) {
|
||||
eeLoadModelHeader(i, &modelHeaders[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void storageClearRadioSettings()
|
||||
{
|
||||
memclear(&g_eeGeneral, sizeof(RadioData));
|
||||
@@ -102,7 +71,7 @@ bool storageReadRadioSettings(bool allowFixes)
|
||||
storageEraseAll(true);
|
||||
}
|
||||
else {
|
||||
eeLoadModelHeaders();
|
||||
loadModelHeaders();
|
||||
}
|
||||
|
||||
for (uint8_t i=0; languagePacks[i]; i++) {
|
||||
@@ -191,32 +160,3 @@ void checkModelIdUnique(uint8_t index, uint8_t module)
|
||||
POPUP_WARNING(STR_MODELIDUSED, reusableBuffer.moduleSetup.msg);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t findNextUnusedModelId(uint8_t index, uint8_t module)
|
||||
{
|
||||
uint8_t usedModelIds[(MAX_RXNUM + 7) / 8];
|
||||
memset(usedModelIds, 0, sizeof(usedModelIds));
|
||||
|
||||
for (uint8_t modelIndex = 0; modelIndex < MAX_MODELS; modelIndex++) {
|
||||
if (modelIndex == index)
|
||||
continue;
|
||||
|
||||
uint8_t id = modelHeaders[modelIndex].modelId[module];
|
||||
if (id == 0)
|
||||
continue;
|
||||
|
||||
uint8_t mask = 1u << (id & 7u);
|
||||
usedModelIds[id >> 3u] |= mask;
|
||||
}
|
||||
|
||||
for (uint8_t id = 1; id <= getMaxRxNum(module); id++) {
|
||||
uint8_t mask = 1u << (id & 7u);
|
||||
if (!(usedModelIds[id >> 3u] & mask)) {
|
||||
// found free ID
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
// failed finding something...
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user