This commit is contained in:
25
ui/helper.c
25
ui/helper.c
@@ -110,6 +110,31 @@ void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_
|
||||
UI_PrintStringBuffer(pString, gFrameBuffer[Line] + Start, char_width, font, inv);
|
||||
}
|
||||
|
||||
void itoa(unsigned long num, char *str) {
|
||||
char buf[20]; // Enough to store any 32-bit or 64-bit unsigned number
|
||||
int i = 0;
|
||||
|
||||
// Handle 0 explicitly
|
||||
if (num == 0) {
|
||||
str[i++] = '0';
|
||||
str[i] = '\0';
|
||||
return;
|
||||
}
|
||||
|
||||
// Convert number to string in reverse order
|
||||
while (num > 0) {
|
||||
buf[i++] = (num % 10) + '0'; // Get last digit and convert to ASCII
|
||||
num /= 10;
|
||||
}
|
||||
|
||||
// Reverse the string
|
||||
int j = 0;
|
||||
while (i > 0) {
|
||||
str[j++] = buf[--i];
|
||||
}
|
||||
str[j] = '\0'; // Null-terminate the string
|
||||
}
|
||||
|
||||
|
||||
void UI_PrintStringSmallNormal(const char *pString, uint8_t Start, uint8_t End, uint8_t Line) {
|
||||
UI_PrintStringSmall(pString, Start, End, Line, ARRAY_SIZE(gFontSmall[0]), (const uint8_t *) gFontSmall, false);
|
||||
|
Reference in New Issue
Block a user