/**1* @file hal_disp.h2*3* @description Display Driver HAL interface header file4*5*/67#ifndef HAL_DISP_H8#define HAL_DISP_H910#ifdef __cplusplus11extern "C" {12#endif1314/*********************15* INCLUDES16*********************/17#include <stdint.h>18#include "lv_hal.h"19#include "../lv_misc/lv_color.h"20#include "../lv_misc/lv_area.h"2122/*********************23* DEFINES24*********************/2526/**********************27* TYPEDEFS28**********************/2930/**31* Display Driver structure to be registered by HAL32*/33typedef struct _disp_drv_t {34/*Write the internal buffer (VDB) to the display. 'lv_flush_ready()' has to be called when finished*/35void (*disp_flush)(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p);3637/*Fill an area with a color on the display*/38void (*disp_fill)(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color);3940/*Write pixel map (e.g. image) to the display*/41void (*disp_map)(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p);4243/*Optional interface functions to use GPU*/44#if USE_LV_GPU45/*Blend two memories using opacity (GPU only)*/46void (*mem_blend)(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa);4748/*Fill a memory with a color (GPU only)*/49void (*mem_fill)(lv_color_t * dest, uint32_t length, lv_color_t color);50#endif5152#if LV_VDB_SIZE53/*Optional: Set a pixel in a buffer according to the requirements of the display*/54void (*vdb_wr)(uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y, lv_color_t color, lv_opa_t opa);55#endif56} lv_disp_drv_t;5758typedef struct _disp_t {59lv_disp_drv_t driver;60struct _disp_t *next;61} lv_disp_t;6263/**********************64* GLOBAL PROTOTYPES65**********************/6667/**68* Initialize a display driver with default values.69* It is used to surly have known values in the fields ant not memory junk.70* After it you can set the fields.71* @param driver pointer to driver variable to initialize72*/73void lv_disp_drv_init(lv_disp_drv_t *driver);7475/**76* Register an initialized display driver.77* Automatically set the first display as active.78* @param driver pointer to an initialized 'lv_disp_drv_t' variable (can be local variable)79* @return pointer to the new display or NULL on error80*/81lv_disp_t * lv_disp_drv_register(lv_disp_drv_t *driver);8283/**84* Set the active display85* @param disp pointer to a display (return value of 'lv_disp_register')86*/87void lv_disp_set_active(lv_disp_t * disp);8889/**90* Get a pointer to the active display91* @return pointer to the active display92*/93lv_disp_t * lv_disp_get_active(void);9495/**96* Get the next display.97* @param disp pointer to the current display. NULL to initialize.98* @return the next display or NULL if no more. Give the first display when the parameter is NULL99*/100lv_disp_t * lv_disp_next(lv_disp_t * disp);101102/**103* Fill a rectangular area with a color on the active display104* @param x1 left coordinate of the rectangle105* @param x2 right coordinate of the rectangle106* @param y1 top coordinate of the rectangle107* @param y2 bottom coordinate of the rectangle108* @param color_p pointer to an array of colors109*/110void lv_disp_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t *color_p);111112/**113* Fill a rectangular area with a color on the active display114* @param x1 left coordinate of the rectangle115* @param x2 right coordinate of the rectangle116* @param y1 top coordinate of the rectangle117* @param y2 bottom coordinate of the rectangle118* @param color fill color119*/120void lv_disp_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color);121122/**123* Put a color map to a rectangular area on the active display124* @param x1 left coordinate of the rectangle125* @param x2 right coordinate of the rectangle126* @param y1 top coordinate of the rectangle127* @param y2 bottom coordinate of the rectangle128* @param color_map pointer to an array of colors129*/130void lv_disp_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_map);131132#if USE_LV_GPU133/**134* Blend pixels to a destination memory from a source memory135* In 'lv_disp_drv_t' 'mem_blend' is optional. (NULL if not available)136* @param dest a memory address. Blend 'src' here.137* @param src pointer to pixel map. Blend it to 'dest'.138* @param length number of pixels in 'src'139* @param opa opacity (0, LV_OPA_TRANSP: transparent ... 255, LV_OPA_COVER, fully cover)140*/141void lv_disp_mem_blend(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa);142143/**144* Fill a memory with a color (GPUs may support it)145* In 'lv_disp_drv_t' 'mem_fill' is optional. (NULL if not available)146* @param dest a memory address. Copy 'src' here.147* @param src pointer to pixel map. Copy it to 'dest'.148* @param length number of pixels in 'src'149* @param opa opacity (0, LV_OPA_TRANSP: transparent ... 255, LV_OPA_COVER, fully cover)150*/151void lv_disp_mem_fill(lv_color_t * dest, uint32_t length, lv_color_t color);152/**153* Shows if memory blending (by GPU) is supported or not154* @return false: 'mem_blend' is not supported in the driver; true: 'mem_blend' is supported in the driver155*/156bool lv_disp_is_mem_blend_supported(void);157158/**159* Shows if memory fill (by GPU) is supported or not160* @return false: 'mem_fill' is not supported in the drover; true: 'mem_fill' is supported in the driver161*/162bool lv_disp_is_mem_fill_supported(void);163#endif164/**********************165* MACROS166**********************/167168#ifdef __cplusplus169} /* extern "C" */170#endif171172#endif173174175