0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-05-19 00:11:18 +03:00

Clean ups

This commit is contained in:
OneOfEleven 2023-09-09 12:40:19 +01:00
parent 2f2bdcb4b8
commit 6670b47340
4 changed files with 32 additions and 42 deletions

BIN
firmware

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -23,9 +23,10 @@
void UI_GenerateChannelString(char *pString, uint8_t Channel) void UI_GenerateChannelString(char *pString, uint8_t Channel)
{ {
uint8_t i; unsigned int i;
if (gInputBoxIndex == 0) { if (gInputBoxIndex == 0)
{
sprintf(pString, "CH-%02d", Channel + 1); sprintf(pString, "CH-%02d", Channel + 1);
return; return;
} }
@ -33,41 +34,27 @@ void UI_GenerateChannelString(char *pString, uint8_t Channel)
pString[0] = 'C'; pString[0] = 'C';
pString[1] = 'H'; pString[1] = 'H';
pString[2] = '-'; pString[2] = '-';
for (i = 0; i < 2; i++)
for (i = 0; i < 2; i++) { pString[i + 3] = (gInputBox[i] == 10) ? '-' : gInputBox[i] + '0';
if (gInputBox[i] == 10) {
pString[i + 3] = '-';
} else {
pString[i + 3] = gInputBox[i] + '0';
}
}
} }
void UI_GenerateChannelStringEx(char *pString, bool bShowPrefix, uint8_t ChannelNumber) void UI_GenerateChannelStringEx(char *pString, bool bShowPrefix, uint8_t ChannelNumber)
{ {
if (gInputBoxIndex) { if (gInputBoxIndex)
uint8_t i; {
unsigned int i;
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++)
if (gInputBox[i] == 10) { pString[i] = (gInputBox[i] == 10) ? '-' : gInputBox[i] + '0';
pString[i] = '-';
} else {
pString[i] = gInputBox[i] + '0';
}
}
return; return;
} }
if (bShowPrefix) { if (bShowPrefix)
sprintf(pString, "CH-%03d", ChannelNumber + 1); sprintf(pString, "CH-%03d", ChannelNumber + 1);
} else { else
if (ChannelNumber == 0xFF) { if (ChannelNumber == 0xFF)
strcpy(pString, "NULL"); strcpy(pString, "NULL");
} else { else
sprintf(pString, "%03d", ChannelNumber + 1); sprintf(pString, "%03d", ChannelNumber + 1);
}
}
} }
void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t Width, bool bCentered) void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t Width, bool bCentered)
@ -82,31 +69,34 @@ void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Lin
{ {
if (pString[i] >= ' ' && pString[i] < 127) if (pString[i] >= ' ' && pString[i] < 127)
{ {
const uint8_t Index = pString[i] - ' '; const unsigned int Index = pString[i] - ' ';
memcpy(gFrameBuffer[Line + 0] + (i * Width) + Start, &gFontBig[Index][0], 8); const unsigned int ofs = (unsigned int)Start + (i * Width);
memcpy(gFrameBuffer[Line + 1] + (i * Width) + Start, &gFontBig[Index][8], 8); memcpy(gFrameBuffer[Line + 0] + ofs, &gFontBig[Index][0], 8);
memcpy(gFrameBuffer[Line + 1] + ofs, &gFontBig[Index][8], 8);
} }
} }
} }
void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero, bool bFlag) void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero, bool bFlag)
{ {
uint8_t *pFb0, *pFb1; unsigned int i;
bool bCanDisplay; uint8_t *pFb0 = gFrameBuffer[Y] + X;;
uint8_t i; uint8_t *pFb1 = pFb0 + 128;
bool bCanDisplay = false;
pFb0 = gFrameBuffer[Y] + X; for (i = 0; i < 3; i++)
pFb1 = pFb0 + 128; {
bCanDisplay = false;
for (i = 0; i < 3; i++) {
const uint8_t Digit = pDigits[i]; const uint8_t Digit = pDigits[i];
if (bDisplayLeadingZero || bCanDisplay || Digit) { if (bDisplayLeadingZero || bCanDisplay || Digit)
{
bCanDisplay = true; bCanDisplay = true;
memcpy(pFb0 + (i * 13), gFontBigDigits[Digit] + 0, 13); memcpy(pFb0 + (i * 13), gFontBigDigits[Digit] + 0, 13);
memcpy(pFb1 + (i * 13), gFontBigDigits[Digit] + 13, 13); memcpy(pFb1 + (i * 13), gFontBigDigits[Digit] + 13, 13);
} else if (bFlag) { }
else
if (bFlag)
{
pFb1 -= 6; pFb1 -= 6;
pFb0 -= 6; pFb0 -= 6;
} }