mirror of
https://github.com/opentx/opentx.git
synced 2025-07-23 16:25:16 +03:00
X10 extra switches sticks (#6423)
[X10] 2 extra sticks switches + 2 extra pots
This commit is contained in:
parent
11cb2ea29b
commit
794fe32006
27 changed files with 390 additions and 166 deletions
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "opentx.h"
|
||||
#include "modelslist.h"
|
||||
#include "conversions/conversions.h"
|
||||
|
||||
void getModelPath(char * path, const char * filename)
|
||||
{
|
||||
|
@ -69,7 +70,7 @@ const char * writeModel()
|
|||
return writeFile(path, (uint8_t *)&g_model, sizeof(g_model));
|
||||
}
|
||||
|
||||
const char * openFile(const char * fullpath, FIL* file, uint16_t* size)
|
||||
const char * openFile(const char * fullpath, FIL * file, uint16_t * size, uint8_t * version)
|
||||
{
|
||||
FRESULT result = f_open(file, fullpath, FA_OPEN_EXISTING | FA_READ);
|
||||
if (result != FR_OK) {
|
||||
|
@ -90,14 +91,14 @@ const char * openFile(const char * fullpath, FIL* file, uint16_t* size)
|
|||
return SDCARD_ERROR(result);
|
||||
}
|
||||
|
||||
uint8_t version = (uint8_t)buf[4];
|
||||
if ((*(uint32_t*)&buf[0] != OTX_FOURCC && *(uint32_t*)&buf[0] != O9X_FOURCC) || version < FIRST_CONV_EEPROM_VER || version > EEPROM_VER || buf[5] != 'M') {
|
||||
*version = (uint8_t)buf[4];
|
||||
if ((*(uint32_t*)&buf[0] != OTX_FOURCC && *(uint32_t*)&buf[0] != O9X_FOURCC) || *version < FIRST_CONV_EEPROM_VER || *version > EEPROM_VER || buf[5] != 'M') {
|
||||
f_close(file);
|
||||
return STR_INCOMPATIBLE;
|
||||
}
|
||||
|
||||
*size = *(uint16_t*)&buf[6];
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char * loadFile(const char * fullpath, uint8_t * data, uint16_t maxsize)
|
||||
|
@ -105,11 +106,13 @@ const char * loadFile(const char * fullpath, uint8_t * data, uint16_t maxsize)
|
|||
FIL file;
|
||||
UINT read;
|
||||
uint16_t size;
|
||||
uint8_t version;
|
||||
|
||||
TRACE("loadFile(%s)", fullpath);
|
||||
|
||||
const char* err = openFile(fullpath, &file, &size);
|
||||
if (err) return err;
|
||||
const char * err = openFile(fullpath, &file, &size, &version);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
size = min<uint16_t>(maxsize, size);
|
||||
FRESULT result = f_read(&file, data, size, &read);
|
||||
|
@ -118,8 +121,12 @@ const char * loadFile(const char * fullpath, uint8_t * data, uint16_t maxsize)
|
|||
return SDCARD_ERROR(result);
|
||||
}
|
||||
|
||||
if (version < EEPROM_VER) {
|
||||
convertModelData(version);
|
||||
}
|
||||
|
||||
f_close(&file);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char * readModel(const char * filename, uint8_t * buffer, uint32_t size)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue