1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-21 06:53:01 +08:00
lvgl/lv_hal/lv_hal_disp.c

147 lines
3.4 KiB
C
Raw Normal View History

/**
* @file hal_disp.c
*
* @description HAL layer for display driver
*
*/
/*********************
* INCLUDES
*********************/
#include <stdint.h>
#include <stddef.h>
2019-02-10 11:06:47 +01:00
#include "lv_hal.h"
2017-11-23 20:42:14 +01:00
#include "../lv_misc/lv_mem.h"
2017-11-30 11:35:33 +01:00
#include "../lv_core/lv_obj.h"
#include "../lv_misc/lv_gc.h"
#if defined(LV_GC_INCLUDE)
# include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
/**********************
* STATIC VARIABLES
**********************/
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/**
* Initialize a display driver with default values.
* It is used to surly have known values in the fields ant not memory junk.
* After it you can set the fields.
* @param driver pointer to driver variable to initialize
*/
2018-06-19 09:49:58 +02:00
void lv_disp_drv_init(lv_disp_drv_t * driver)
{
2017-11-28 16:15:13 +01:00
driver->disp_fill = NULL;
driver->disp_map = NULL;
driver->disp_flush = NULL;
2019-02-10 11:06:47 +01:00
driver->hor_res = LV_HOR_RES_MAX;
driver->ver_res = LV_VER_RES_MAX;
#if USE_LV_GPU
2017-11-28 16:15:13 +01:00
driver->mem_blend = NULL;
driver->mem_fill = NULL;
#endif
#if LV_VDB_SIZE
driver->vdb_wr = NULL;
#endif
}
/**
2017-10-20 22:41:10 +02:00
* Register an initialized display driver.
* Automatically set the first display as active.
* @param driver pointer to an initialized 'lv_disp_drv_t' variable (can be local variable)
* @return pointer to the new display or NULL on error
*/
2018-06-19 09:49:58 +02:00
lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)
{
2019-02-10 11:06:47 +01:00
lv_disp_t * node = lv_ll_ins_head(&LV_GC_ROOT(_lv_disp_ll));
if(!node) {
lv_mem_assert(node);
return NULL;
}
2018-06-19 09:49:58 +02:00
memcpy(&node->driver, driver, sizeof(lv_disp_drv_t));
2019-02-10 11:06:47 +01:00
lv_ll_init(&node->scr_ll, sizeof(lv_obj_t));
node->act_scr = lv_obj_create(NULL, NULL); /*Create a default screen on the display*/
node->top_layer = lv_obj_create(NULL, NULL); /*Create top layer on the display*/
2019-02-12 12:21:34 +01:00
node->sys_layer = lv_obj_create(NULL, NULL); /*Create top layer on the display*/
lv_obj_set_style(node->top_layer, &lv_style_transp);
lv_obj_set_style(node->sys_layer, &lv_style_transp);
node->inv_p = 0;
return node;
}
2019-02-12 12:21:34 +01:00
lv_disp_t * lv_disp_get_next(lv_disp_t * disp)
{
2019-02-10 11:06:47 +01:00
if(disp == NULL) return lv_ll_get_head(&LV_GC_ROOT(_lv_disp_ll));
else return lv_ll_get_next(&LV_GC_ROOT(_lv_disp_ll), disp);
}
2019-02-10 11:06:47 +01:00
lv_disp_t * lv_disp_get_last(void)
{
2019-02-10 11:06:47 +01:00
return lv_ll_get_head(&LV_GC_ROOT(_lv_disp_ll));
}
2017-10-20 22:41:10 +02:00
2019-02-10 11:06:47 +01:00
/**
* Get the next display.
* @param disp pointer to the current display. NULL to initialize.
* @return the next display or NULL if no more. Give the first display when the parameter is NULL
*/
lv_disp_t * lv_disp_next(lv_disp_t * disp)
{
2019-02-10 11:06:47 +01:00
if(disp == NULL) return lv_ll_get_head(&LV_GC_ROOT(_lv_disp_ll));
else return lv_ll_get_next(&LV_GC_ROOT(_lv_disp_ll), disp);
}
lv_coord_t lv_disp_get_hor_res(lv_disp_t * disp)
{
2019-02-12 12:21:34 +01:00
if(disp == NULL) disp = lv_disp_get_last();
2019-02-10 11:06:47 +01:00
if(disp == NULL) return LV_HOR_RES_MAX;
else return disp->driver.hor_res;
}
lv_coord_t lv_disp_get_ver_res(lv_disp_t * disp)
{
2019-02-12 12:21:34 +01:00
if(disp == NULL) disp = lv_disp_get_last();
2019-02-10 11:06:47 +01:00
if(disp == NULL) return LV_VER_RES_MAX;
else return disp->driver.ver_res;
}
/**********************
* STATIC FUNCTIONS
**********************/