/** * @file display_driver.h * @brief Display driver interface for LCD and LVGL initialization * * This module provides a clean abstraction for display hardware initialization * and LVGL integration. The driver handles SPI bus setup, panel configuration, * IO expander control, and LVGL buffer management. */ #ifndef DISPLAY_DRIVER_H #define DISPLAY_DRIVER_H #include "lvgl.h" #include #include #ifdef __cplusplus extern "C" { #endif // ---------------------------------------------------------------------------- // Display Driver Interface // ---------------------------------------------------------------------------- /** * @brief Initialize the display subsystem * * Initializes I2C bus, IO expander, SPI bus, LCD panel driver, and LVGL. * Creates display buffers and starts the LVGL port task. * Must be called before any other display operations. * * @return true on success, false on failure */ bool displayDriverInit(void); /** * @brief Acquire LVGL mutex for thread-safe operations * * Call this before any LVGL API calls from outside the LVGL task. * Must be paired with displayDriverUnlock(). * * @param timeoutMs Timeout in milliseconds, -1 for infinite wait * @return true if mutex acquired, false on timeout */ bool displayDriverLock(int timeoutMs); /** * @brief Release LVGL mutex after thread-safe operations * * Call this after completing LVGL API calls. * Must be preceded by a successful displayDriverLock() call. */ void displayDriverUnlock(void); /** * @brief Get the current active LVGL screen * * Convenience wrapper for lv_scr_act() to reduce LVGL coupling. * * @return Pointer to the active screen object */ lv_obj_t *displayDriverGetActiveScreen(void); #ifdef __cplusplus } #endif #endif // DISPLAY_DRIVER_H