mirror of
https://github.com/armel/uv-k1-k5v3-firmware-custom.git
synced 2026-10-02 11:08:20 +00:00
Improve one and two-letter scan list names (issue #206)
This commit is contained in:
1 parent
d83c6451c8
commit
7b7186e293
5 files changed
+15
-7
No files matched your search
@@ -321,6 +321,16 @@ static void sort(int16_t *a, int16_t *b)
|
||||
x += 4;
|
||||
}
|
||||
}
|
||||
|
||||
bool IsEmptyName(const char *name, uint8_t len) {
|
||||
if (name[0] == '\0' || name[0] == '\xff')
|
||||
return true;
|
||||
for (uint8_t i = 0; i < len; i++) {
|
||||
if (name[i] != ' ' && name[i] != '\xff' && name[i] != '\0')
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
void UI_DrawLineBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black)
|
||||
|
||||
@@ -38,6 +38,7 @@ void UI_DrawPixelBuffer(uint8_t (*buffer)[128], uint8_t x, uint8_t y, bool black
|
||||
void PutPixel(uint8_t x, uint8_t y, bool fill);
|
||||
void PutPixelStatus(uint8_t x, uint8_t y, bool fill);
|
||||
void GUI_DisplaySmallest(const char *pString, uint8_t x, uint8_t y, bool statusbar, bool fill);
|
||||
bool IsEmptyName(const char *name, uint8_t len);
|
||||
#endif
|
||||
void UI_DrawLineBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black);
|
||||
void UI_DrawRectangleBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black);
|
||||
|
||||
+1
-1
@@ -976,7 +976,7 @@ void UI_DisplayMain(void)
|
||||
const char *name = gListName[countList - 1];
|
||||
|
||||
// If name is empty/invalid, display number
|
||||
if (name[0] == '\0' || name[0] == '\xff') {
|
||||
if (IsEmptyName(name, sizeof(gListName[0]))) {
|
||||
sprintf(String, "%02d", countList);
|
||||
xStart = 117; // 2-digit number aligned right
|
||||
xDisplay = 119;
|
||||
|
||||
+2
-2
@@ -976,7 +976,7 @@ void UI_DisplayMenu(void)
|
||||
const char *name = gListName[gSubMenuSelection - 1];
|
||||
|
||||
// If first character is empty/invalid, display "N/A"
|
||||
if (name[0] == '\0' || name[0] == '\xff')
|
||||
if (IsEmptyName(name, sizeof(gListName[0])))
|
||||
sprintf(String, "%02u", gSubMenuSelection);
|
||||
else
|
||||
sprintf(String, "%02u (%.3s)", gSubMenuSelection, name);
|
||||
@@ -989,7 +989,7 @@ void UI_DisplayMenu(void)
|
||||
else {
|
||||
const char *name = gListName[gSubMenuSelection - 1];
|
||||
// If first character is empty/invalid, display "N/A"
|
||||
if (name[0] == '\0' || name[0] == '\xff')
|
||||
if (IsEmptyName(name, sizeof(gListName[0])))
|
||||
sprintf(String, "%02u", gSubMenuSelection);
|
||||
else
|
||||
sprintf(String, "%02u (%.3s)", gSubMenuSelection, name);
|
||||
|
||||
+1
-4
@@ -114,10 +114,7 @@ void UI_DisplayStatus()
|
||||
const char *name = gListName[gEeprom.SCAN_LIST_DEFAULT - 1];
|
||||
|
||||
// Check if name is valid
|
||||
bool nameValid = (name[0] != '\0' && name[0] != '\xff');
|
||||
|
||||
// Format the string
|
||||
if (nameValid) {
|
||||
if (!IsEmptyName(name, sizeof(gListName[0]))) {
|
||||
sprintf(str, "%.3s%s", name, gEeprom.SCAN_LIST_ENABLED ? "+" : "");
|
||||
end = gEeprom.SCAN_LIST_ENABLED ? 18 : 14;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user