diff --git a/font.c b/font.c index 0dbb66a6..9269d3e9 100644 --- a/font.c +++ b/font.c @@ -19,39 +19,7 @@ #include "font.h" //stolen from https://github.com/dhepper/font8x8 -const uint8_t gFontSmall[128][8] = { - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, - {0, 0, 0, 0, 0, 0, 0, 0,}, +const uint8_t gFontSmall[128 - 32][8] = { {0, 0, 0, 0, 0, 0, 0, 0,}, {0, 0, 6, 95, 95, 6, 0, 0,}, {0, 3, 3, 0, 3, 3, 0, 0,}, diff --git a/font.h b/font.h index 81a1fd79..5c7fd4f1 100644 --- a/font.h +++ b/font.h @@ -19,7 +19,7 @@ #include -extern const uint8_t gFontSmall[128][8]; +extern const uint8_t gFontSmall[128 - 32][8]; extern const uint8_t gFontBigDigits[11][26]; #endif diff --git a/ui/aircopy.c b/ui/aircopy.c index be33ea0d..9e04aead 100644 --- a/ui/aircopy.c +++ b/ui/aircopy.c @@ -37,7 +37,7 @@ void UI_DisplayAircopy(void) } else { strcpy(String, "AIR COPY(CMP)"); } - UI_PrintString(String, 2, 127, 0, 8, true); + UI_PrintStringSmall(String, 2, 127, 0, 8, true); if (gInputBoxIndex == 0) { NUMBER_ToDigits(gRxVfo->ConfigRX.Frequency, String); @@ -54,7 +54,7 @@ void UI_DisplayAircopy(void) } else if (gAirCopyIsSendMode == 1) { sprintf(String, "SND:%d", gAirCopyBlockNumber); } - UI_PrintString(String, 2, 127, 4, 8, true); + UI_PrintStringSmall(String, 2, 127, 4, 8, true); ST7565_BlitFullScreen(); } diff --git a/ui/fmradio.c b/ui/fmradio.c index 851a0102..28c3f09a 100644 --- a/ui/fmradio.c +++ b/ui/fmradio.c @@ -35,7 +35,7 @@ void UI_DisplayFM(void) memset(String, 0, sizeof(String)); strcpy(String, "FM"); - UI_PrintString(String, 0, 127, 0, 12, true); + UI_PrintStringSmall(String, 0, 127, 0, 12, true); memset(String, 0, sizeof(String)); if (gAskToSave) { @@ -66,7 +66,7 @@ void UI_DisplayFM(void) } } - UI_PrintString(String, 0, 127, 2, 10, true); + UI_PrintStringSmall(String, 0, 127, 2, 10, true); memset(String, 0, sizeof(String)); if (gAskToSave || (gEeprom.FM_IsMrMode && gInputBoxIndex)) { @@ -84,7 +84,7 @@ void UI_DisplayFM(void) sprintf(String, "CH-%02d", gEeprom.FM_SelectedChannel + 1); } - UI_PrintString(String, 0, 127, 4, 10, true); + UI_PrintStringSmall(String, 0, 127, 4, 10, true); ST7565_BlitFullScreen(); } diff --git a/ui/helper.c b/ui/helper.c index 614fe8bc..19eafe0a 100644 --- a/ui/helper.c +++ b/ui/helper.c @@ -82,7 +82,7 @@ void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_ } for (i = 0; i < Length; i++) { if (pString[i] >= ' ' && pString[i] < 0x7F) { - uint8_t Index = pString[i]; + uint8_t Index = pString[i] - ' '; if(Line < 7) memcpy(gFrameBuffer[Line + 0] + (i * Width) + Start, &gFontSmall[Index][0], 8); else @@ -91,21 +91,6 @@ void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_ } } -void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t Width, bool bCentered) -{ - uint32_t i, Length; - - Length = strlen(pString); - if (bCentered) { - Start += (((End - Start) - (Length * Width)) + 1) / 2; - } - for (i = 0; i < Length; i++) { - if (pString[i] >= ' ' && pString[i] < 0x7F) { - memcpy(gFrameBuffer[Line + 0] + (i * Width) + Start, gFontSmall[(uint8_t)pString[i]], 8); - } - } -} - void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero, bool bFlag) { uint8_t *pFb0, *pFb1; @@ -146,7 +131,7 @@ void UI_DisplaySmallDigits(uint8_t Size, const char *pString, uint8_t X, uint8_t uint8_t i; for (i = 0; i < Size; i++) { - memcpy(gFrameBuffer[Y] + (i * 7) + X, gFontSmall[pString[i] + '0'], 7); + memcpy(gFrameBuffer[Y] + (i * 7) + X, gFontSmall[pString[i] + '0' - ' '], 7); } } diff --git a/ui/helper.h b/ui/helper.h index 9c330249..b5a1b045 100644 --- a/ui/helper.h +++ b/ui/helper.h @@ -23,7 +23,6 @@ void UI_GenerateChannelString(char *pString, uint8_t Channel); void UI_GenerateChannelStringEx(char *pString, bool bShowPrefix, uint8_t ChannelNumber); void UI_PrintStringSmall(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); void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero, bool bFlag); void UI_DisplaySmallDigits(uint8_t Size, const char *pString, uint8_t X, uint8_t Y); diff --git a/ui/lock.c b/ui/lock.c index 1b679102..47cd49be 100644 --- a/ui/lock.c +++ b/ui/lock.c @@ -36,7 +36,7 @@ static void Render(void) memset(gStatusLine, 0, sizeof(gStatusLine)); memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); strcpy(String, "LOCK"); - UI_PrintString(String, 0, 127, 1, 10, true); + UI_PrintStringSmall(String, 0, 127, 1, 10, true); for (i = 0; i < 6; i++) { if (gInputBox[i] == 10) { String[i] = '-'; @@ -45,7 +45,7 @@ static void Render(void) } } String[6] = 0; - UI_PrintString(String, 0, 127, 3, 12, true); + UI_PrintStringSmall(String, 0, 127, 3, 12, true); ST7565_BlitStatusLine(); ST7565_BlitFullScreen(); } diff --git a/ui/main.c b/ui/main.c index 800cd8f5..79622ed0 100644 --- a/ui/main.c +++ b/ui/main.c @@ -26,6 +26,7 @@ #include "ui/helper.h" #include "ui/inputbox.h" #include "ui/main.h" +#include "font.h" void UI_DisplayMain(void) { @@ -34,8 +35,8 @@ void UI_DisplayMain(void) memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); if (gEeprom.KEY_LOCK && gKeypadLocked) { - UI_PrintString("Long Press #", 0, 127, 1, 8, true); - UI_PrintString("To Unlock", 0, 127, 3, 8, true); + UI_PrintStringSmall("Long Press #", 0, 127, 1, 8, true); + UI_PrintStringSmall("To Unlock", 0, 127, 3, 8, true); ST7565_BlitFullScreen(); return; } @@ -91,7 +92,7 @@ void UI_DisplayMain(void) } else { sprintf(String, ">%s", gDTMF_InputBox); } - UI_PrintString(String, 2, 127, i * 3, 8, false); + UI_PrintStringSmall(String, 2, 127, i * 3, 8, false); memset(String, 0, sizeof(String)); memset(Contact, 0, sizeof(Contact)); @@ -113,7 +114,7 @@ void UI_DisplayMain(void) sprintf(String, ">%s", gDTMF_String); } } - UI_PrintString(String, 2, 127, 2 + (i * 3), 8, false); + UI_PrintStringSmall(String, 2, 127, 2 + (i * 3), 8, false); continue; } else if (bIsSameVfo) { memcpy(pLine0 + 2, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); @@ -225,7 +226,7 @@ void UI_DisplayMain(void) Width = 8; break; } - UI_PrintString(String, 31, 111, i * 4, Width, true); + UI_PrintStringSmall(String, 31, 111, i * 4, Width, true); } else { if (gInputBoxIndex && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[i]) && gEeprom.TX_CHANNEL == i) { UI_DisplayFrequency(gInputBox, 31, i * 4, true, false); @@ -261,14 +262,14 @@ void UI_DisplayMain(void) break; case MDF_CHANNEL: sprintf(String, "CH-%03d", gEeprom.ScreenChannel[i] + 1); - UI_PrintString(String, 31, 112, i * 4, 8, true); + UI_PrintStringSmall(String, 31, 112, i * 4, 8, true); break; case MDF_NAME: if(gEeprom.VfoInfo[i].Name[0] == 0 || gEeprom.VfoInfo[i].Name[0] == 0xFF) { sprintf(String, "CH-%03d", gEeprom.ScreenChannel[i] + 1); - UI_PrintString(String, 31, 112, i * 4, 8, true); + UI_PrintStringSmall(String, 31, 112, i * 4, 8, true); } else { - UI_PrintString(gEeprom.VfoInfo[i].Name, 31, 112, i * 4, 8, true); + UI_PrintStringSmall(gEeprom.VfoInfo[i].Name, 31, 112, i * 4, 8, true); } break; } @@ -379,10 +380,10 @@ void UI_DisplayMain(void) if (gEeprom.VfoInfo[i].ConfigRX.Frequency != gEeprom.VfoInfo[i].ConfigTX.Frequency) { if (gEeprom.VfoInfo[i].FREQUENCY_DEVIATION_SETTING == FREQUENCY_DEVIATION_ADD) { - memcpy(pLine1 + 128 + 54, BITMAP_Add, sizeof(BITMAP_Add)); + UI_PrintStringSmall("+", 80, 127, 2, 7, false); } if (gEeprom.VfoInfo[i].FREQUENCY_DEVIATION_SETTING == FREQUENCY_DEVIATION_SUB) { - memcpy(pLine1 + 128 + 54, BITMAP_Sub, sizeof(BITMAP_Sub)); + UI_PrintStringSmall("-", 80, 127, 2, 7, false); } } diff --git a/ui/menu.c b/ui/menu.c index 15275b28..5a65211f 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -476,16 +476,16 @@ void UI_DisplayMenu(void) } if (gSubMenuSelection == 0xFF || !gEeprom.SCAN_LIST_ENABLED[i]) { - UI_PrintString(String, 50, 127, 2, 8, 1); + UI_PrintStringSmall(String, 50, 127, 2, 8, 1); } else { - UI_PrintString(String, 50, 127, 0, 8, 1); + UI_PrintStringSmall(String, 50, 127, 0, 8, 1); if (IS_MR_CHANNEL(gEeprom.SCANLIST_PRIORITY_CH1[i])) { sprintf(String, "PRI1:%d", gEeprom.SCANLIST_PRIORITY_CH1[i] + 1); - UI_PrintString(String, 50, 127, 2, 8, 1); + UI_PrintStringSmall(String, 50, 127, 2, 8, 1); } if (IS_MR_CHANNEL(gEeprom.SCANLIST_PRIORITY_CH2[i])) { sprintf(String, "PRI2:%d", gEeprom.SCANLIST_PRIORITY_CH2[i] + 1); - UI_PrintString(String, 50, 127, 4, 8, 1); + UI_PrintStringSmall(String, 50, 127, 4, 8, 1); } } } diff --git a/ui/scanner.c b/ui/scanner.c index e93ca5fb..664c258e 100644 --- a/ui/scanner.c +++ b/ui/scanner.c @@ -38,7 +38,7 @@ void UI_DisplayScanner(void) } else { sprintf(String, "FREQ:**.*****"); } - UI_PrintString(String, 2, 127, 1, 8, 0); + UI_PrintStringSmall(String, 2, 127, 1, 8, 0); memset(String, 0, sizeof(String)); if (gScanCssState < SCAN_CSS_STATE_FOUND || !gScanUseCssResult) { @@ -48,7 +48,7 @@ void UI_DisplayScanner(void) } else { sprintf(String, "DCS:D%03oN", DCS_Options[gScanCssResultCode]); } - UI_PrintString(String, 2, 127, 3, 8, 0); + UI_PrintStringSmall(String, 2, 127, 3, 8, 0); memset(String, 0, sizeof(String)); if (gScannerEditState == 2) { @@ -73,7 +73,7 @@ void UI_DisplayScanner(void) bCentered = 0; } - UI_PrintString(String, Start, 127, 5, 8, bCentered); + UI_PrintStringSmall(String, Start, 127, 5, 8, bCentered); ST7565_BlitFullScreen(); } diff --git a/ui/welcome.c b/ui/welcome.c index d495cdbb..b85a5204 100644 --- a/ui/welcome.c +++ b/ui/welcome.c @@ -44,9 +44,9 @@ void UI_DisplayWelcome(void) EEPROM_ReadBuffer(0x0EB0, WelcomeString0, 16); EEPROM_ReadBuffer(0x0EC0, WelcomeString1, 16); } - UI_PrintString(WelcomeString0, 0, 127, 1, 10, true); - UI_PrintString(WelcomeString1, 0, 127, 3, 10, true); - UI_PrintString(Version, 0, 127, 5, 10, true); + UI_PrintStringSmall(WelcomeString0, 0, 127, 1, 10, true); + UI_PrintStringSmall(WelcomeString1, 0, 127, 3, 10, true); + UI_PrintStringSmall(Version, 0, 127, 5, 10, true); ST7565_BlitStatusLine(); ST7565_BlitFullScreen(); }