Override liblary .c file

Hello, 

I'm working on a project with a multi-color EPD display, using my custom display driver and LVGL. My display supports 3 colors (white, black, red), so the best option would be to use 4-bit pixels. Unfortunately, LVGL's minimum color depth for multi-color support is 8-bit, which is acceptable for my needs. However, Zephyr requires at least 16-bit color depth dsiplay.

enum display_pixel_format {
PIXEL_FORMAT_RGB_888 = BIT(0), /**< 24-bit RGB */
PIXEL_FORMAT_MONO01 = BIT(1), /**< Monochrome (0=Black 1=White) */
PIXEL_FORMAT_MONO10 = BIT(2), /**< Monochrome (1=Black 0=White) */
PIXEL_FORMAT_ARGB_8888 = BIT(3), /**< 32-bit ARGB */
PIXEL_FORMAT_RGB_565 = BIT(4), /**< 16-bit RGB */
PIXEL_FORMAT_BGR_565 = BIT(5), /**< 16-bit BGR */
};

To avoid wasting RAM unnecessarily, I've made some modifications to the lvgl_display.c file to implement my own display callbacks, for example:

disp_drv->flush_cb = lvgl_flush_cb_8bit_epd_opencoded;
disp_drv->rounder_cb = lvgl_rounder_cb_8bit_epd_opencoded;
disp_drv->set_px_cb = lvgl_set_px_cb_8bit_epd_opencoded;

Currently, I’m modifying the source file directly in the SDK directory, and my question is: can I override this file during the build? I want to have my version of this file in project and linked it to final build. I checked CMake capabilities, but it doesn’t seem to offer an option to exclude a source file from the build. Is there a way to achieve this?

Related