[Colorlcd] Support model notes with spaces and prevent radio crash due to filename (#645)

* support both versions of model notes file name. Fix for #641

* Adding support for names with spaces

* Fix compilation
This commit is contained in:
eshifri
2021-09-02 10:45:58 +10:00
committed by GitHub
parent 9a2461c7e9
commit 88b8ac86fb
5 changed files with 58 additions and 10 deletions
+5 -5
View File
@@ -1182,13 +1182,13 @@ extern ReusableBuffer reusableBuffer;
uint8_t zlen(const char *str, uint8_t size);
bool zexist(const char *str, uint8_t size);
unsigned int effectiveLen(const char * str, unsigned int size);
char * strcat_zchar(char *dest, const char *name, uint8_t size, const char *defaultName=nullptr, uint8_t defaultNameSize=0, uint8_t defaultIdx=0);
#define strcatFlightmodeName(dest, idx) strcat_zchar(dest, g_model.flightModeData[idx].name, LEN_FLIGHT_MODE_NAME, STR_FM, PSIZE(TR_FM), idx+1)
char * strcat_zchar(char *dest, const char *name, uint8_t size, const char spaceSym = 0, const char *defaultName=nullptr, uint8_t defaultNameSize=0, uint8_t defaultIdx=0);
#define strcatFlightmodeName(dest, idx) strcat_zchar(dest, g_model.flightModeData[idx].name, LEN_FLIGHT_MODE_NAME, 0, STR_FM, PSIZE(TR_FM), idx+1)
#if defined(EEPROM)
#define strcat_modelname(dest, idx) strcat_zchar(dest, modelHeaders[idx].name, LEN_MODEL_NAME, STR_MODEL, PSIZE(TR_MODEL), idx+1)
#define strcat_currentmodelname(dest) strcat_modelname(dest, g_eeGeneral.currModel)
#define strcat_modelname(dest, idx) strcat_zchar(dest, modelHeaders[idx].name, LEN_MODEL_NAME, 0, STR_MODEL, PSIZE(TR_MODEL), idx+1)
#define strcat_currentmodelname(dest, foo) strcat_modelname(dest, g_eeGeneral.currModel)
#else
#define strcat_currentmodelname(dest) strcat_zchar(dest, g_model.header.name, LEN_MODEL_NAME)
#define strcat_currentmodelname(dest, spaceSym) strcat_zchar(dest, g_model.header.name, LEN_MODEL_NAME, spaceSym)
#endif
#define ZLEN(s) zlen(s, sizeof(s))
#define ZEXIST(s) zexist(s, sizeof(s))