/**************************************************************************//** * @brief Initializes the graphics stack. * @note This function will /hang/ if errors occur (usually * caused by faulty displays. *****************************************************************************/ void GRAPHICS_Init(void) { EMSTATUS status; /* Initialize the display module. */ status = DISPLAY_Init(); if (DISPLAY_EMSTATUS_OK != status) while (1) ; /* Initialize the DMD module for the DISPLAY device driver. */ status = DMD_init(0); if (DMD_OK != status) while (1) ; status = GLIB_contextInit(&glibContext); if (GLIB_OK != status) while (1) ; glibContext.backgroundColor = White; glibContext.foregroundColor = Black; /* Use Narrow font */ GLIB_setFont(&glibContext, (GLIB_Font_t *)&GLIB_FontNarrow6x8); }
/**************************************************************************//** * @brief Updates the digital clock. * *****************************************************************************/ void digitalClockUpdate(struct tm *time, bool redraw) { char clockString[16]; if (redraw) { GLIB_setFont(&gc, (GLIB_Font_t *)&GLIB_FontNumber16x20); gc.backgroundColor = White; gc.foregroundColor = Black; GLIB_clear(&gc); } sprintf(clockString, "%02d:%02d:%02d", time->tm_hour, time->tm_min, time->tm_sec); GLIB_drawString(&gc, clockString, strlen(clockString), 1, 52, true); /* Update display */ DMD_updateDisplay(); }