mirror of
https://github.com/EdgeTX/edgetx.git
synced 2025-07-23 16:25:12 +03:00
Rename char2idx to char2zchar
This commit is contained in:
parent
61af68caf8
commit
e4fa31be28
10 changed files with 21 additions and 21 deletions
|
@ -387,7 +387,7 @@ class CharField: public DataField {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char specialCharsTab[] = "_-.,";
|
static const char specialCharsTab[] = "_-.,";
|
||||||
static inline int8_t char2idx(char c)
|
static inline int8_t char2zchar(char c)
|
||||||
{
|
{
|
||||||
if (c==' ') return 0;
|
if (c==' ') return 0;
|
||||||
if (c>='A' && c<='Z') return 1+c-'A';
|
if (c>='A' && c<='Z') return 1+c-'A';
|
||||||
|
@ -401,7 +401,7 @@ static inline int8_t char2idx(char c)
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ZCHAR_MAX 40
|
#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) return ' ';
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
|
@ -429,7 +429,7 @@ class ZCharField: public DataField {
|
||||||
int b = 0;
|
int b = 0;
|
||||||
int len = strlen(field);
|
int len = strlen(field);
|
||||||
for (int i=0; i<N; i++) {
|
for (int i=0; i<N; i++) {
|
||||||
int idx = i>=len ? 0 : char2idx(field[i]);
|
int idx = i>=len ? 0 : char2zchar(field[i]);
|
||||||
for (int j=0; j<8; j++, b++) {
|
for (int j=0; j<8; j++, b++) {
|
||||||
if (idx & (1<<j))
|
if (idx & (1<<j))
|
||||||
output.setBit(b);
|
output.setBit(b);
|
||||||
|
@ -446,7 +446,7 @@ class ZCharField: public DataField {
|
||||||
if (input[b++])
|
if (input[b++])
|
||||||
idx |= (1<<j);
|
idx |= (1<<j);
|
||||||
}
|
}
|
||||||
field[i] = idx2char(idx);
|
field[i] = zchar2char(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
field[N] = '\0';
|
field[N] = '\0';
|
||||||
|
|
|
@ -401,7 +401,7 @@ void bluetoothWakeup()
|
||||||
uint8_t len = ZLEN(g_eeGeneral.bluetoothName);
|
uint8_t len = ZLEN(g_eeGeneral.bluetoothName);
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
*cur++ = idx2char(g_eeGeneral.bluetoothName[i]);
|
*cur++ = zchar2char(g_eeGeneral.bluetoothName[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -292,7 +292,7 @@ uint8_t getTextWidth(const char * s, uint8_t len, LcdFlags flags)
|
||||||
{
|
{
|
||||||
uint8_t width = 0;
|
uint8_t width = 0;
|
||||||
for (int i=0; len==0 || i<len; ++i) {
|
for (int i=0; len==0 || i<len; ++i) {
|
||||||
unsigned char c = (flags & ZCHAR) ? idx2char(*s) : *s;
|
unsigned char c = (flags & ZCHAR) ? zchar2char(*s) : *s;
|
||||||
if (!c) {
|
if (!c) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -327,7 +327,7 @@ void lcdDrawSizedText(coord_t x, coord_t y, const char * s, uint8_t len, LcdFlag
|
||||||
break;
|
break;
|
||||||
#if !defined(BOOT)
|
#if !defined(BOOT)
|
||||||
case ZCHAR:
|
case ZCHAR:
|
||||||
c = idx2char(*s);
|
c = zchar2char(*s);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -82,7 +82,7 @@ void editName(coord_t x, coord_t y, char * name, uint8_t size, event_t event, ui
|
||||||
if (s_editMode > 0) {
|
if (s_editMode > 0) {
|
||||||
int8_t c = name[editNameCursorPos];
|
int8_t c = name[editNameCursorPos];
|
||||||
if (!(flags & ZCHAR)) {
|
if (!(flags & ZCHAR)) {
|
||||||
c = char2idx(c);
|
c = char2zchar(c);
|
||||||
}
|
}
|
||||||
int8_t v = 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 (c != v) {
|
||||||
if (!(flags & ZCHAR)) {
|
if (!(flags & ZCHAR)) {
|
||||||
if (v != '\0' || name[editNameCursorPos+1] != '\0')
|
if (v != '\0' || name[editNameCursorPos+1] != '\0')
|
||||||
v = idx2char(v);
|
v = zchar2char(v);
|
||||||
}
|
}
|
||||||
name[editNameCursorPos] = v;
|
name[editNameCursorPos] = v;
|
||||||
storageDirty(menuVerticalPositions[0] == 0 ? EE_MODEL : EE_GENERAL);
|
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);
|
lcdDrawSizedText(x, y, name, size, flags);
|
||||||
coord_t left = (editNameCursorPos == 0 ? 0 : getTextWidth(name, editNameCursorPos, 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);
|
lcdDrawSolidFilledRect(x+left-1, y, getTextWidth(s, 1)+1, INVERT_LINE_HEIGHT, TEXT_INVERTED_BGCOLOR);
|
||||||
lcdDrawText(x+left, y, s, TEXT_INVERTED_COLOR);
|
lcdDrawText(x+left, y, s, TEXT_INVERTED_COLOR);
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,7 +160,7 @@ void editName(coord_t x, coord_t y, char * name, uint8_t size, event_t event, ui
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attr == ZCHAR) {
|
if (attr == ZCHAR) {
|
||||||
lcdDrawChar(x+editNameCursorPos*FW, y, idx2char(v), ERASEBG|INVERS|FIXEDWIDTH);
|
lcdDrawChar(x+editNameCursorPos*FW, y, zchar2char(v), ERASEBG|INVERS|FIXEDWIDTH);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lcdDrawChar(x+editNameCursorPos*FW, y, v, ERASEBG|INVERS|FIXEDWIDTH);
|
lcdDrawChar(x+editNameCursorPos*FW, y, v, ERASEBG|INVERS|FIXEDWIDTH);
|
||||||
|
|
|
@ -71,7 +71,7 @@ const char * logsOpen()
|
||||||
len = i+1;
|
len = i+1;
|
||||||
if (len) {
|
if (len) {
|
||||||
if (filename[i])
|
if (filename[i])
|
||||||
filename[i] = idx2char(filename[i]);
|
filename[i] = zchar2char(filename[i]);
|
||||||
else
|
else
|
||||||
filename[i] = '_';
|
filename[i] = '_';
|
||||||
}
|
}
|
||||||
|
|
|
@ -341,7 +341,7 @@ void defaultInputs()
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
for (int c=0; c<3; c++) {
|
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
|
#if LEN_INPUT_NAME > 3
|
||||||
g_model.inputNames[i][3] = '\0';
|
g_model.inputNames[i][3] = '\0';
|
||||||
|
|
|
@ -431,8 +431,8 @@ extern struct t_inactivity inactivity;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char hex2zchar(uint8_t hex);
|
char hex2zchar(uint8_t hex);
|
||||||
char idx2char(int8_t idx);
|
char zchar2char(int8_t idx);
|
||||||
int8_t char2idx(char c);
|
int8_t char2zchar(char c);
|
||||||
void str2zchar(char *dest, const char *src, int size);
|
void str2zchar(char *dest, const char *src, int size);
|
||||||
int zchar2str(char *dest, const char *src, int size);
|
int zchar2str(char *dest, const char *src, int size);
|
||||||
|
|
||||||
|
|
|
@ -467,7 +467,7 @@ const char * eeBackupModel(uint8_t i_fileSrc)
|
||||||
len = i+1;
|
len = i+1;
|
||||||
if (len) {
|
if (len) {
|
||||||
if (buf[i])
|
if (buf[i])
|
||||||
buf[i] = idx2char(buf[i]);
|
buf[i] = zchar2char(buf[i]);
|
||||||
else
|
else
|
||||||
buf[i] = '_';
|
buf[i] = '_';
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ char hex2zchar(uint8_t hex)
|
||||||
return (hex >= 10 ? hex-9 : 27+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) return ' ';
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
|
@ -44,7 +44,7 @@ char idx2char(int8_t idx)
|
||||||
return ' ';
|
return ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t char2idx(char c)
|
int8_t char2zchar(char c)
|
||||||
{
|
{
|
||||||
if (c == '_') return 37;
|
if (c == '_') return 37;
|
||||||
#if LEN_SPECIAL_CHARS > 0
|
#if LEN_SPECIAL_CHARS > 0
|
||||||
|
@ -63,14 +63,14 @@ void str2zchar(char * dest, const char * src, int size)
|
||||||
{
|
{
|
||||||
memset(dest, 0, size);
|
memset(dest, 0, size);
|
||||||
for (int c=0; c<size && src[c]; c++) {
|
for (int c=0; c<size && src[c]; c++) {
|
||||||
dest[c] = char2idx(src[c]);
|
dest[c] = char2zchar(src[c]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int zchar2str(char * dest, const char * src, int size)
|
int zchar2str(char * dest, const char * src, int size)
|
||||||
{
|
{
|
||||||
for (int c=0; c<size; c++) {
|
for (int c=0; c<size; c++) {
|
||||||
dest[c] = idx2char(src[c]);
|
dest[c] = zchar2char(src[c]);
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
dest[size--] = '\0';
|
dest[size--] = '\0';
|
||||||
|
@ -122,7 +122,7 @@ char * strcat_zchar(char * dest, const char * name, uint8_t size, const char * d
|
||||||
len = i+1;
|
len = i+1;
|
||||||
if (len) {
|
if (len) {
|
||||||
if (dest[i])
|
if (dest[i])
|
||||||
dest[i] = idx2char(dest[i]);
|
dest[i] = zchar2char(dest[i]);
|
||||||
else
|
else
|
||||||
dest[i] = '_';
|
dest[i] = '_';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue