mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-24 08:45:36 +03:00
Extract function toUpperCase for osd elements
This commit is contained in:
parent
b28b07eb95
commit
191294aad0
1 changed files with 14 additions and 45 deletions
|
@ -783,20 +783,21 @@ static void osdBackgroundCameraFrame(osdElementParms_t *element)
|
|||
element->drawElement = false; // element already drawn
|
||||
}
|
||||
|
||||
static void toUpperCase(char* dest, const char* src, unsigned int maxSrcLength)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < maxSrcLength && src[i]; i++) {
|
||||
dest[i] = toupper((unsigned char)src[i]);
|
||||
}
|
||||
dest[i] = '\0';
|
||||
}
|
||||
|
||||
static void osdBackgroundCraftName(osdElementParms_t *element)
|
||||
{
|
||||
if (strlen(pilotConfig()->name) == 0) {
|
||||
strcpy(element->buff, "CRAFT_NAME");
|
||||
} else {
|
||||
unsigned i;
|
||||
for (i = 0; i < MAX_NAME_LENGTH; i++) {
|
||||
if (pilotConfig()->name[i]) {
|
||||
element->buff[i] = toupper((unsigned char)pilotConfig()->name[i]);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
element->buff[i] = '\0';
|
||||
toUpperCase(element->buff, pilotConfig()->name, MAX_NAME_LENGTH);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -875,15 +876,7 @@ static void osdBackgroundDisplayName(osdElementParms_t *element)
|
|||
if (strlen(pilotConfig()->displayName) == 0) {
|
||||
strcpy(element->buff, "DISPLAY_NAME");
|
||||
} else {
|
||||
unsigned i;
|
||||
for (i = 0; i < MAX_NAME_LENGTH; i++) {
|
||||
if (pilotConfig()->displayName[i]) {
|
||||
element->buff[i] = toupper((unsigned char)pilotConfig()->displayName[i]);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
element->buff[i] = '\0';
|
||||
toUpperCase(element->buff, pilotConfig()->displayName, MAX_NAME_LENGTH);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -901,15 +894,7 @@ static void osdElementRateProfileName(osdElementParms_t *element)
|
|||
if (strlen(currentControlRateProfile->profileName) == 0) {
|
||||
tfp_sprintf(element->buff, "RATE_%u", getCurrentControlRateProfileIndex() + 1);
|
||||
} else {
|
||||
unsigned i;
|
||||
for (i = 0; i < MAX_PROFILE_NAME_LENGTH; i++) {
|
||||
if (currentControlRateProfile->profileName[i]) {
|
||||
element->buff[i] = toupper((unsigned char)currentControlRateProfile->profileName[i]);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
element->buff[i] = '\0';
|
||||
toUpperCase(element->buff, currentControlRateProfile->profileName, MAX_PROFILE_NAME_LENGTH);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -918,15 +903,7 @@ static void osdElementPidProfileName(osdElementParms_t *element)
|
|||
if (strlen(currentPidProfile->profileName) == 0) {
|
||||
tfp_sprintf(element->buff, "PID_%u", getCurrentPidProfileIndex() + 1);
|
||||
} else {
|
||||
unsigned i;
|
||||
for (i = 0; i < MAX_PROFILE_NAME_LENGTH; i++) {
|
||||
if (currentPidProfile->profileName[i]) {
|
||||
element->buff[i] = toupper((unsigned char)currentPidProfile->profileName[i]);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
element->buff[i] = '\0';
|
||||
toUpperCase(element->buff, currentPidProfile->profileName, MAX_PROFILE_NAME_LENGTH);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -939,15 +916,7 @@ static void osdElementOsdProfileName(osdElementParms_t *element)
|
|||
if (strlen(osdConfig()->profile[profileIndex - 1]) == 0) {
|
||||
tfp_sprintf(element->buff, "OSD_%u", profileIndex);
|
||||
} else {
|
||||
unsigned i;
|
||||
for (i = 0; i < OSD_PROFILE_NAME_LENGTH; i++) {
|
||||
if (osdConfig()->profile[profileIndex - 1][i]) {
|
||||
element->buff[i] = toupper((unsigned char)osdConfig()->profile[profileIndex - 1][i]);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
element->buff[i] = '\0';
|
||||
toUpperCase(element->buff, osdConfig()->profile[profileIndex - 1], OSD_PROFILE_NAME_LENGTH);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue