1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

add disp. rotate config for disp_drv

This commit is contained in:
Gabor Kiss-Vamosi 2019-03-30 06:23:41 +01:00
parent 9515e800d4
commit 09f362a1ed
3 changed files with 23 additions and 6 deletions

View File

@ -92,8 +92,8 @@ void lv_inv_area(lv_disp_t * disp, const lv_area_t * area_p)
lv_area_t scr_area; lv_area_t scr_area;
scr_area.x1 = 0; scr_area.x1 = 0;
scr_area.y1 = 0; scr_area.y1 = 0;
scr_area.x2 = disp->driver.hor_res - 1; scr_area.x2 = lv_disp_get_hor_res(disp) - 1;
scr_area.y2 = disp->driver.ver_res - 1; scr_area.y2 = lv_disp_get_ver_res(disp) - 1;
lv_area_t com_area; lv_area_t com_area;
bool suc; bool suc;

View File

@ -60,6 +60,7 @@ void lv_disp_drv_init(lv_disp_drv_t * driver)
driver->hor_res = LV_HOR_RES_MAX; driver->hor_res = LV_HOR_RES_MAX;
driver->ver_res = LV_VER_RES_MAX; driver->ver_res = LV_VER_RES_MAX;
driver->buffer = NULL; driver->buffer = NULL;
driver->rotated = 1;
#if LV_ANTIALIAS #if LV_ANTIALIAS
driver->antialiasing = true; driver->antialiasing = true;
@ -171,6 +172,21 @@ void lv_disp_remove(lv_disp_t * disp)
if(was_default) lv_disp_set_default(lv_ll_get_head(&LV_GC_ROOT(_lv_disp_ll))); if(was_default) lv_disp_set_default(lv_ll_get_head(&LV_GC_ROOT(_lv_disp_ll)));
} }
/**
* Update the driver in run time.
* @param disp Pointer toa display. (return value of `lv_disp_drv_register`)
* @param new_drv pointer to the new driver
*/
void lv_disp_update_drv(lv_disp_t * disp, lv_disp_drv_t * new_drv)
{
memcpy(&disp->driver, new_drv, sizeof(lv_disp_drv_t));
lv_obj_t * scr;
LV_LL_READ(disp->scr_ll, scr) {
lv_obj_set_size(scr, lv_disp_get_hor_res(disp), lv_disp_get_ver_res(disp));
}
}
/** /**
* Set a default screen. The new screens will be created on it by default. * Set a default screen. The new screens will be created on it by default.
* @param disp pointer to a display * @param disp pointer to a display
@ -198,8 +214,8 @@ lv_coord_t lv_disp_get_hor_res(lv_disp_t * disp)
{ {
if(disp == NULL) disp = lv_disp_get_default(); if(disp == NULL) disp = lv_disp_get_default();
if(disp == NULL) return LV_HOR_RES_MAX; if(disp == NULL) return disp->driver.rotated == 0 ? LV_HOR_RES_MAX : LV_VER_RES_MAX;
else return disp->driver.hor_res; else return disp->driver.rotated == 0 ? disp->driver.hor_res : disp->driver.ver_res;
} }
/** /**
@ -211,8 +227,8 @@ lv_coord_t lv_disp_get_ver_res(lv_disp_t * disp)
{ {
if(disp == NULL) disp = lv_disp_get_default(); if(disp == NULL) disp = lv_disp_get_default();
if(disp == NULL) return LV_VER_RES_MAX; if(disp == NULL) return disp->driver.rotated == 0 ? LV_VER_RES_MAX : LV_HOR_RES_MAX;
else return disp->driver.ver_res; else return disp->driver.rotated == 0 ? disp->driver.ver_res : disp->driver.hor_res;
} }
/** /**

View File

@ -71,6 +71,7 @@ typedef struct _disp_drv_t {
#if LV_ANTIALIAS #if LV_ANTIALIAS
uint32_t antialiasing :1; uint32_t antialiasing :1;
#endif #endif
uint32_t rotated :1; /*1: turn the display by 90 degree.*/
/* MANDATORY: Write the internal buffer (VDB) to the display. 'lv_flush_ready()' has to be called when finished */ /* MANDATORY: Write the internal buffer (VDB) to the display. 'lv_flush_ready()' has to be called when finished */
void (*flush_cb)(struct _disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p); void (*flush_cb)(struct _disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p);