From 78a45d9bbddbb6ec680e4f3af1033a62633521b9 Mon Sep 17 00:00:00 2001 From: Juan Antonio Date: Mon, 25 Dec 2023 01:24:47 +0100 Subject: [PATCH] Create function to zero gFrameBuffer Size: 60464 -> 60420 --- app/spectrum.c | 2 +- ui/fmradio.c | 2 +- ui/helper.c | 7 ++++++- ui/helper.h | 2 ++ ui/lock.c | 2 +- ui/main.c | 2 +- ui/menu.c | 2 +- ui/scanner.c | 2 +- ui/welcome.c | 7 +++---- 9 files changed, 17 insertions(+), 11 deletions(-) diff --git a/app/spectrum.c b/app/spectrum.c index 2ab22c1..1ad6710 100644 --- a/app/spectrum.c +++ b/app/spectrum.c @@ -1075,7 +1075,7 @@ static void RenderStill() { } static void Render() { - memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); + UI_DisplayClear(); switch (currentState) { case SPECTRUM: diff --git a/ui/fmradio.c b/ui/fmradio.c index a74ad73..a6b5bc8 100644 --- a/ui/fmradio.c +++ b/ui/fmradio.c @@ -32,7 +32,7 @@ void UI_DisplayFM(void) { char String[16] = {0}; char *pPrintStr = String; - memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); + UI_DisplayClear(); UI_PrintString("FM", 0, 127, 0, 12); diff --git a/ui/helper.c b/ui/helper.c index 9005577..da24f53 100644 --- a/ui/helper.c +++ b/ui/helper.c @@ -252,4 +252,9 @@ void UI_DisplayPopup(const char *string) // DrawRectangle(9,9, 118,38, true); UI_PrintString(string, 9, 118, 2, 8); UI_PrintStringSmall("Press EXIT", 9, 118, 6); -} \ No newline at end of file +} + +void UI_DisplayClear() +{ + memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); +} diff --git a/ui/helper.h b/ui/helper.h index d915b4c..bda8bf9 100644 --- a/ui/helper.h +++ b/ui/helper.h @@ -36,4 +36,6 @@ void UI_DrawPixelBuffer(uint8_t (*buffer)[128], uint8_t x, uint8_t y, bool black 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); +void UI_DisplayClear(); + #endif diff --git a/ui/lock.c b/ui/lock.c index a16e5d5..44423bf 100644 --- a/ui/lock.c +++ b/ui/lock.c @@ -35,7 +35,7 @@ static void Render(void) char String[7]; memset(gStatusLine, 0, sizeof(gStatusLine)); - memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); + UI_DisplayClear(); UI_PrintString("LOCK", 0, 127, 1, 10); for (i = 0; i < 6; i++) diff --git a/ui/main.c b/ui/main.c index 48050a9..6799f2f 100644 --- a/ui/main.c +++ b/ui/main.c @@ -309,7 +309,7 @@ void UI_DisplayMain(void) center_line = CENTER_LINE_NONE; // clear the screen - memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); + UI_DisplayClear(); if(gLowBattery && !gLowBatteryConfirmed) { UI_DisplayPopup("LOW BATTERY"); diff --git a/ui/menu.c b/ui/menu.c index 90d0b95..38178e8 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -404,7 +404,7 @@ void UI_DisplayMenu(void) #endif // clear the screen buffer - memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); + UI_DisplayClear(); #if 0 // original menu layout diff --git a/ui/scanner.c b/ui/scanner.c index 302d2bd..6fa7c74 100644 --- a/ui/scanner.c +++ b/ui/scanner.c @@ -31,7 +31,7 @@ void UI_DisplayScanner(void) bool bCentered; uint8_t Start; - memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); + UI_DisplayClear(); if (gScanSingleFrequency || (gScanCssState != SCAN_CSS_STATE_OFF && gScanCssState != SCAN_CSS_STATE_FAILED)) { sprintf(String, "FREQ:%u.%05u", gScanFrequency / 100000, gScanFrequency % 100000); diff --git a/ui/welcome.c b/ui/welcome.c index 0752310..7fd43e1 100644 --- a/ui/welcome.c +++ b/ui/welcome.c @@ -30,7 +30,7 @@ void UI_DisplayReleaseKeys(void) { memset(gStatusLine, 0, sizeof(gStatusLine)); - memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); + UI_DisplayClear(); UI_PrintString("RELEASE", 0, 127, 1, 10); UI_PrintString("ALL KEYS", 0, 127, 3, 10); @@ -43,9 +43,9 @@ void UI_DisplayWelcome(void) { char WelcomeString0[16]; char WelcomeString1[16]; - + memset(gStatusLine, 0, sizeof(gStatusLine)); - memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); + UI_DisplayClear(); if (gEeprom.POWER_ON_DISPLAY_MODE == POWER_ON_DISPLAY_MODE_NONE) { @@ -83,4 +83,3 @@ void UI_DisplayWelcome(void) ST7565_BlitFullScreen(); } } -