diff --git a/companion/src/firmwares/eepromimportexport.h b/companion/src/firmwares/eepromimportexport.h index 69944cba7..30cd2a045 100644 --- a/companion/src/firmwares/eepromimportexport.h +++ b/companion/src/firmwares/eepromimportexport.h @@ -387,7 +387,7 @@ class CharField: public DataField { }; static const char specialCharsTab[] = "_-.,"; -static inline int8_t char2idx(char c) +static inline int8_t char2zchar(char c) { if (c==' ') return 0; if (c>='A' && c<='Z') return 1+c-'A'; @@ -401,7 +401,7 @@ static inline int8_t char2idx(char c) } #define ZCHAR_MAX 40 -static inline char idx2char(int8_t idx) +static inline char zchar2char(int8_t idx) { if (idx == 0) return ' '; if (idx < 0) { @@ -429,7 +429,7 @@ class ZCharField: public DataField { int b = 0; int len = strlen(field); for (int i=0; i=len ? 0 : char2idx(field[i]); + int idx = i>=len ? 0 : char2zchar(field[i]); for (int j=0; j<8; j++, b++) { if (idx & (1< 0) { for (int i = 0; i < len; i++) { - *cur++ = idx2char(g_eeGeneral.bluetoothName[i]); + *cur++ = zchar2char(g_eeGeneral.bluetoothName[i]); } } else { diff --git a/radio/src/gui/128x64/lcd.cpp b/radio/src/gui/128x64/lcd.cpp index a9be302f3..d800521df 100644 --- a/radio/src/gui/128x64/lcd.cpp +++ b/radio/src/gui/128x64/lcd.cpp @@ -292,7 +292,7 @@ uint8_t getTextWidth(const char * s, uint8_t len, LcdFlags flags) { uint8_t width = 0; for (int i=0; len==0 || i 0) { int8_t c = name[editNameCursorPos]; if (!(flags & ZCHAR)) { - c = char2idx(c); + c = char2zchar(c); } int8_t v = c; @@ -132,7 +132,7 @@ void editName(coord_t x, coord_t y, char * name, uint8_t size, event_t event, ui if (c != v) { if (!(flags & ZCHAR)) { if (v != '\0' || name[editNameCursorPos+1] != '\0') - v = idx2char(v); + v = zchar2char(v); } name[editNameCursorPos] = v; storageDirty(menuVerticalPositions[0] == 0 ? EE_MODEL : EE_GENERAL); @@ -140,7 +140,7 @@ void editName(coord_t x, coord_t y, char * name, uint8_t size, event_t event, ui lcdDrawSizedText(x, y, name, size, flags); coord_t left = (editNameCursorPos == 0 ? 0 : getTextWidth(name, editNameCursorPos, flags)); - char s[] = { (flags & ZCHAR) ? idx2char(name[editNameCursorPos]) : name[editNameCursorPos], '\0' }; + char s[] = { (flags & ZCHAR) ? zchar2char(name[editNameCursorPos]) : name[editNameCursorPos], '\0' }; lcdDrawSolidFilledRect(x+left-1, y, getTextWidth(s, 1)+1, INVERT_LINE_HEIGHT, TEXT_INVERTED_BGCOLOR); lcdDrawText(x+left, y, s, TEXT_INVERTED_COLOR); } diff --git a/radio/src/gui/common/stdlcd/widgets.cpp b/radio/src/gui/common/stdlcd/widgets.cpp index c1b60ec32..fde626ecd 100644 --- a/radio/src/gui/common/stdlcd/widgets.cpp +++ b/radio/src/gui/common/stdlcd/widgets.cpp @@ -160,7 +160,7 @@ void editName(coord_t x, coord_t y, char * name, uint8_t size, event_t event, ui } if (attr == ZCHAR) { - lcdDrawChar(x+editNameCursorPos*FW, y, idx2char(v), ERASEBG|INVERS|FIXEDWIDTH); + lcdDrawChar(x+editNameCursorPos*FW, y, zchar2char(v), ERASEBG|INVERS|FIXEDWIDTH); } else { lcdDrawChar(x+editNameCursorPos*FW, y, v, ERASEBG|INVERS|FIXEDWIDTH); diff --git a/radio/src/logs.cpp b/radio/src/logs.cpp index 63c6ddb46..8a90c71c1 100644 --- a/radio/src/logs.cpp +++ b/radio/src/logs.cpp @@ -71,7 +71,7 @@ const char * logsOpen() len = i+1; if (len) { if (filename[i]) - filename[i] = idx2char(filename[i]); + filename[i] = zchar2char(filename[i]); else filename[i] = '_'; } diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 9ee271d63..4b416ac11 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -341,7 +341,7 @@ void defaultInputs() } #else for (int c=0; c<3; c++) { - g_model.inputNames[i][c] = char2idx(STR_VSRCRAW[2+4*stick_index+c]); + g_model.inputNames[i][c] = char2zchar(STR_VSRCRAW[2 + 4 * stick_index + c]); } #if LEN_INPUT_NAME > 3 g_model.inputNames[i][3] = '\0'; diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 47336de39..bc7a7e90e 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -431,8 +431,8 @@ extern struct t_inactivity inactivity; #endif char hex2zchar(uint8_t hex); -char idx2char(int8_t idx); -int8_t char2idx(char c); +char zchar2char(int8_t idx); +int8_t char2zchar(char c); void str2zchar(char *dest, const char *src, int size); int zchar2str(char *dest, const char *src, int size); diff --git a/radio/src/storage/eeprom_rlc.cpp b/radio/src/storage/eeprom_rlc.cpp index 07c5df730..d3b94d723 100644 --- a/radio/src/storage/eeprom_rlc.cpp +++ b/radio/src/storage/eeprom_rlc.cpp @@ -467,7 +467,7 @@ const char * eeBackupModel(uint8_t i_fileSrc) len = i+1; if (len) { if (buf[i]) - buf[i] = idx2char(buf[i]); + buf[i] = zchar2char(buf[i]); else buf[i] = '_'; } diff --git a/radio/src/strhelpers.cpp b/radio/src/strhelpers.cpp index 99a61996a..313775460 100644 --- a/radio/src/strhelpers.cpp +++ b/radio/src/strhelpers.cpp @@ -28,7 +28,7 @@ char hex2zchar(uint8_t hex) return (hex >= 10 ? hex-9 : 27+hex); } -char idx2char(int8_t idx) +char zchar2char(int8_t idx) { if (idx == 0) return ' '; if (idx < 0) { @@ -44,7 +44,7 @@ char idx2char(int8_t idx) return ' '; } -int8_t char2idx(char c) +int8_t char2zchar(char c) { if (c == '_') return 37; #if LEN_SPECIAL_CHARS > 0 @@ -63,14 +63,14 @@ void str2zchar(char * dest, const char * src, int size) { memset(dest, 0, size); for (int c=0; c