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

feat(disp): add non-fullscreen display utilities (#2724)

This adds utility functions/macros for dealing with non-fullscreen
displays.

Related to lvgl/lv_drivers#166
This commit is contained in:
Johannes Marbach 2021-10-25 14:26:43 +02:00 committed by GitHub
parent 0c10453f17
commit b59cc9cfb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 71 additions and 4 deletions

View File

@ -43,6 +43,7 @@
- feat(disp): Enable rendering to display subsection
- feat(keyboard): add user-defined modes
- Add support for RT-Thread RTOS
- feat(disp): add utility functions/macros for dealing with non-fullscreen displays
## v8.0.2 (16.07.2021)
- fix(theme) improve button focus of keyboard

View File

@ -345,9 +345,9 @@ lv_coord_t lv_disp_get_physical_hor_res(lv_disp_t * disp)
switch(disp->driver->rotated) {
case LV_DISP_ROT_90:
case LV_DISP_ROT_270:
return disp->driver->physical_ver_res;
return disp->driver->physical_ver_res > 0 ? disp->driver->physical_ver_res : disp->driver->ver_res;
default:
return disp->driver->physical_hor_res;
return disp->driver->physical_hor_res > 0 ? disp->driver->physical_hor_res : disp->driver->hor_res;
}
}
}
@ -368,9 +368,61 @@ lv_coord_t lv_disp_get_physical_ver_res(lv_disp_t * disp)
switch(disp->driver->rotated) {
case LV_DISP_ROT_90:
case LV_DISP_ROT_270:
return disp->driver->physical_hor_res;
return disp->driver->physical_hor_res > 0 ? disp->driver->physical_hor_res : disp->driver->hor_res;
default:
return disp->driver->physical_ver_res;
return disp->driver->physical_ver_res > 0 ? disp->driver->physical_ver_res : disp->driver->ver_res;
}
}
}
/**
* Get the horizontal offset from the full / physical display
* @param disp pointer to a display (NULL to use the default display)
* @return the horizontal offset from the full / physical display
*/
lv_coord_t lv_disp_get_offset_x(lv_disp_t * disp)
{
if(disp == NULL) disp = lv_disp_get_default();
if(disp == NULL) {
return 0;
}
else {
switch(disp->driver->rotated) {
case LV_DISP_ROT_90:
return disp->driver->offset_y;
case LV_DISP_ROT_180:
return lv_disp_get_physical_hor_res(disp) - disp->driver->offset_x;
case LV_DISP_ROT_270:
return lv_disp_get_physical_hor_res(disp) - disp->driver->offset_y;
default:
return disp->driver->offset_x;
}
}
}
/**
* Get the vertical offset from the full / physical display
* @param disp pointer to a display (NULL to use the default display)
* @return the horizontal offset from the full / physical display
*/
lv_coord_t lv_disp_get_offset_y(lv_disp_t * disp)
{
if(disp == NULL) disp = lv_disp_get_default();
if(disp == NULL) {
return 0;
}
else {
switch(disp->driver->rotated) {
case LV_DISP_ROT_90:
return disp->driver->offset_x;
case LV_DISP_ROT_180:
return lv_disp_get_physical_ver_res(disp) - disp->driver->offset_y;
case LV_DISP_ROT_270:
return lv_disp_get_physical_ver_res(disp) - disp->driver->offset_x;
default:
return disp->driver->offset_y;
}
}
}

View File

@ -273,6 +273,20 @@ lv_coord_t lv_disp_get_physical_hor_res(lv_disp_t * disp);
*/
lv_coord_t lv_disp_get_physical_ver_res(lv_disp_t * disp);
/**
* Get the horizontal offset from the full / physical display
* @param disp pointer to a display (NULL to use the default display)
* @return the horizontal offset from the full / physical display
*/
lv_coord_t lv_disp_get_offset_x(lv_disp_t * disp);
/**
* Get the vertical offset from the full / physical display
* @param disp pointer to a display (NULL to use the default display)
* @return the horizontal offset from the full / physical display
*/
lv_coord_t lv_disp_get_offset_y(lv_disp_t * disp);
/**
* Get if anti-aliasing is enabled for a display or not
* @param disp pointer to a display (NULL to use the default display)