From d5edba1fc21df0d2a2e4c2a00a4bfe796e5586b7 Mon Sep 17 00:00:00 2001 From: Armel FAUVEAU Date: Mon, 27 Apr 2026 06:10:44 +0200 Subject: [PATCH] Add UI_PrintStringYOffset to shift big-font --- App/ui/helper.c | 40 ++++++++++++++++++++++++++++++++++++++++ App/ui/helper.h | 1 + App/ui/main.c | 8 +++++--- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/App/ui/helper.c b/App/ui/helper.c index a0edd501..a21ca34f 100644 --- a/App/ui/helper.c +++ b/App/ui/helper.c @@ -98,6 +98,46 @@ void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Lin } } +// Same as UI_PrintString but shifts the glyph down by YOffset pixels (0..7). +// When YOffset > 0, a third page (Line+2) is also written. Bits are OR-ed +// so existing framebuffer content outside the glyph footprint is preserved. +void UI_PrintStringYOffset(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t Width, uint8_t YOffset) +{ + size_t i; + size_t Length = strlen(pString); + + if (End > Start) + Start += (((End - Start) - (Length * Width)) + 1) / 2; + + YOffset &= 7; + + for (i = 0; i < Length; i++) + { + const unsigned int ofs = (unsigned int)Start + (i * Width); + if (pString[i] > ' ' && pString[i] < 127) + { + const unsigned int index = pString[i] - ' ' - 1; + + if (YOffset == 0) + { + memcpy(gFrameBuffer[Line + 0] + ofs, &gFontBig[index][0], 7); + memcpy(gFrameBuffer[Line + 1] + ofs, &gFontBig[index][7], 7); + } + else + { + for (unsigned int x = 0; x < 7; x++) + { + const uint8_t top = gFontBig[index][x]; + const uint8_t bot = gFontBig[index][7 + x]; + gFrameBuffer[Line + 0][ofs + x] |= (uint8_t)(top << YOffset); + gFrameBuffer[Line + 1][ofs + x] |= (uint8_t)(top >> (8 - YOffset)) | (uint8_t)(bot << YOffset); + gFrameBuffer[Line + 2][ofs + x] |= (uint8_t)(bot >> (8 - YOffset)); + } + } + } + } +} + void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t char_width, const uint8_t *font) { const size_t Length = strlen(pString); diff --git a/App/ui/helper.h b/App/ui/helper.h index 0002f2cb..ccd5da05 100644 --- a/App/ui/helper.h +++ b/App/ui/helper.h @@ -23,6 +23,7 @@ void UI_GenerateChannelString(char *pString, const uint16_t Channel); void UI_GenerateChannelStringEx(char *pString, const bool bShowPrefix, const uint16_t ChannelNumber); void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t Width); +void UI_PrintStringYOffset(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t Width, uint8_t YOffset); void UI_PrintStringSmallNormal(const char *pString, uint8_t Start, uint8_t End, uint8_t Line); void UI_PrintStringSmallNormalInverse(const char *pString, uint8_t Start, uint8_t End, uint8_t Line); void UI_PrintStringSmallBold(const char *pString, uint8_t Start, uint8_t End, uint8_t Line); diff --git a/App/ui/main.c b/App/ui/main.c index 576fa0fa..baa6b9cb 100644 --- a/App/ui/main.c +++ b/App/ui/main.c @@ -1597,7 +1597,8 @@ void UI_DisplayMain(void) case MDF_CHANNEL: // show the channel number sprintf(String, "CH-%04u", gEeprom.ScreenChannel[vfo_num] + 1); - UI_PrintString(String, 36, 0, line, 8); + //UI_PrintString(String, 36, 0, line, 8); + UI_PrintStringYOffset(String, 36, 0, line, 8, 3); break; case MDF_NAME: // show the channel name @@ -1611,14 +1612,15 @@ void UI_DisplayMain(void) if (gEeprom.CHANNEL_DISPLAY_MODE == MDF_NAME) { String[10] = 0; - UI_PrintString(String, 33, 0, line, 8); + UI_PrintStringYOffset(String, 33, 0, line, 8, 3); } else { #ifdef ENABLE_FEAT_F4HWN if (isMainOnly()) { String[10] = 0; - UI_PrintString(String, 33, 0, line, 8); + //UI_PrintString(String, 33, 0, line, 8); + UI_PrintStringYOffset(String, 33, 0, line, 8, 3); } else {