/* UA1ZBE Custom Firmware - Boot Splash Screen
 * Displays:
 *   Line 1 (top, large):  UA1ZBE
 *   Line 2 (center):       POCSAG pager
 *   Line 3 (bottom):       YYYY-MM-DD (build date)
 * Then fades to VFO mode after 2 seconds.
 */

#include <string.h>
#include "driver/st7565.h"
#include "driver/system.h"
#include "ui/helper.h"
#include "font.h"

#ifndef BUILD_DATE
#define BUILD_DATE "unknown"
#endif

void BOOT_SplashShow(void)
{
    /* Clear screen */
    ST7565_FillScreen(0x00);
    memset(gStatusLine, 0, sizeof(gStatusLine));
    for (int line = 0; line < FRAME_LINES; line++)
        memset(gFrameBuffer[line], 0, LCD_WIDTH);

    /* Line 1: UA1ZBE — large font, centered, top */
    UI_PrintString("UA1ZBE", 0, LCD_WIDTH, 0, 12);

    /* Line 2: "POCSAG pager" — small font, centered */
    /* Small font is 6 pixels tall, at y-offset line 3 (~24px) */
    const char *line2 = "POCSAG pager";
    int len2 = 0;
    while (line2[len2]) len2++;
    int x2 = (LCD_WIDTH - len2 * 6) / 2;
    if (x2 < 0) x2 = 0;
    UI_PrintStringSmallNormal(line2, x2, LCD_WIDTH, 24);

    /* Line 3: BUILD_DATE — small font, centered, bottom */
    const char *date_str = BUILD_DATE;
    int len3 = 0;
    while (date_str[len3]) len3++;
    int x3 = (LCD_WIDTH - len3 * 6) / 2;
    if (x3 < 0) x3 = 0;
    UI_PrintStringSmallNormal(date_str, x3, LCD_WIDTH, 48);

    /* Blit to screen */
    ST7565_BlitStatusLine();
    ST7565_BlitFullScreen();

    /* Hold for 2 seconds */
    SYSTEM_DelayMs(2000);
}
