2019-02-07 19:17:10 +01:00
|
|
|
/**
|
|
|
|
* @file lv_disp.c
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*********************
|
|
|
|
* INCLUDES
|
|
|
|
*********************/
|
|
|
|
#include "lv_disp.h"
|
2019-04-04 07:07:17 +02:00
|
|
|
#include "../lv_misc/lv_math.h"
|
2019-02-07 19:17:10 +01:00
|
|
|
|
|
|
|
/*********************
|
|
|
|
* DEFINES
|
|
|
|
*********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* TYPEDEFS
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* STATIC PROTOTYPES
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* STATIC VARIABLES
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* MACROS
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* GLOBAL FUNCTIONS
|
|
|
|
**********************/
|
|
|
|
|
2019-02-12 15:38:13 +01:00
|
|
|
/**
|
2019-02-20 23:58:13 +01:00
|
|
|
* Return with a pointer to the active screen
|
|
|
|
* @param disp pointer to display which active screen should be get. (NULL to use the default screen)
|
|
|
|
* @return pointer to the active screen object (loaded by 'lv_scr_load()')
|
2019-02-12 15:38:13 +01:00
|
|
|
*/
|
2019-02-20 23:58:13 +01:00
|
|
|
lv_obj_t * lv_disp_get_scr_act(lv_disp_t * disp)
|
2019-02-12 15:38:13 +01:00
|
|
|
{
|
2019-02-20 23:58:13 +01:00
|
|
|
if(!disp) disp = lv_disp_get_default();
|
|
|
|
if(!disp) {
|
|
|
|
LV_LOG_WARN("lv_scr_act: no display registered to get its top layer");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return disp->act_scr;
|
2019-02-12 15:38:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-02-20 23:58:13 +01:00
|
|
|
* Make a screen active
|
|
|
|
* @param scr pointer to a screen
|
2019-02-12 15:38:13 +01:00
|
|
|
*/
|
2019-02-20 23:58:13 +01:00
|
|
|
void lv_disp_set_scr_act(lv_obj_t * scr)
|
2019-02-12 15:38:13 +01:00
|
|
|
{
|
2019-02-20 23:58:13 +01:00
|
|
|
lv_disp_t * d = lv_obj_get_disp(scr);
|
|
|
|
|
|
|
|
d->act_scr = scr;
|
2019-02-12 15:38:13 +01:00
|
|
|
|
2019-02-20 23:58:13 +01:00
|
|
|
lv_obj_invalidate(scr);
|
2019-02-12 15:38:13 +01:00
|
|
|
}
|
|
|
|
|
2019-02-20 23:58:13 +01:00
|
|
|
/**
|
|
|
|
* Return with the top layer. (Same on every screen and it is above the normal screen layer)
|
|
|
|
* @param disp pointer to display which top layer should be get. (NULL to use the default screen)
|
|
|
|
* @return pointer to the top layer object (transparent screen sized lv_obj)
|
|
|
|
*/
|
|
|
|
lv_obj_t * lv_disp_get_layer_top(lv_disp_t * disp)
|
|
|
|
{
|
|
|
|
if(!disp) disp = lv_disp_get_default();
|
|
|
|
if(!disp) {
|
|
|
|
LV_LOG_WARN("lv_layer_top: no display registered to get its top layer");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return disp->top_layer;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return with the sys. layer. (Same on every screen and it is above the normal screen and the top layer)
|
|
|
|
* @param disp pointer to display which sys. layer should be get. (NULL to use the default screen)
|
|
|
|
* @return pointer to the sys layer object (transparent screen sized lv_obj)
|
|
|
|
*/
|
|
|
|
lv_obj_t * lv_disp_get_layer_sys(lv_disp_t * disp)
|
2019-02-12 16:20:59 +01:00
|
|
|
{
|
2019-02-20 23:58:13 +01:00
|
|
|
if(!disp) disp = lv_disp_get_default();
|
|
|
|
if(!disp) {
|
|
|
|
LV_LOG_WARN("lv_layer_sys: no display registered to get its top layer");
|
|
|
|
return NULL;
|
|
|
|
}
|
2019-02-12 16:20:59 +01:00
|
|
|
|
2019-02-20 23:58:13 +01:00
|
|
|
return disp->sys_layer;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Assign a screen to a display.
|
|
|
|
* @param disp pointer to a display where to assign the screen
|
|
|
|
* @param scr pointer to a screen object to assign
|
|
|
|
*/
|
|
|
|
void lv_disp_assign_screen(lv_disp_t * disp, lv_obj_t * scr)
|
|
|
|
{
|
|
|
|
if(lv_obj_get_parent(scr) != NULL) {
|
|
|
|
LV_LOG_WARN("lv_disp_assign_screen: try to assign a non-screen object");
|
2019-02-12 16:20:59 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-02-20 23:58:13 +01:00
|
|
|
lv_disp_t * old_disp = lv_obj_get_disp(scr);
|
|
|
|
|
|
|
|
if(old_disp == disp) return;
|
|
|
|
|
2019-02-12 16:20:59 +01:00
|
|
|
lv_ll_chg_list(&old_disp->scr_ll, &disp->scr_ll, scr);
|
|
|
|
}
|
|
|
|
|
2019-03-30 06:03:23 +01:00
|
|
|
/**
|
2019-04-02 12:15:35 +02:00
|
|
|
* Get a pointer to the screen refresher task to
|
|
|
|
* modify its parameters with `lv_task_...` functions.
|
2019-03-30 06:03:23 +01:00
|
|
|
* @param disp pointer to a display
|
|
|
|
* @return pointer to the display refresher task. (NULL on error)
|
|
|
|
*/
|
|
|
|
lv_task_t * lv_disp_get_refr_task(lv_disp_t * disp)
|
|
|
|
{
|
|
|
|
if(!disp) disp = lv_disp_get_default();
|
|
|
|
if(!disp) {
|
2019-04-02 12:15:35 +02:00
|
|
|
LV_LOG_WARN("lv_disp_get_refr_task: no display registered");
|
2019-03-30 06:03:23 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return disp->refr_task;
|
|
|
|
}
|
|
|
|
|
2019-04-04 07:07:17 +02:00
|
|
|
/**
|
|
|
|
* Get elapsed time since last user activity on a display (e.g. click)
|
|
|
|
* @param disp pointer to an display (NULL to get the overall smallest inactivity)
|
|
|
|
* @return elapsed ticks (milliseconds) since the last activity
|
|
|
|
*/
|
|
|
|
uint32_t lv_disp_get_inactive_time(const lv_disp_t * disp)
|
|
|
|
{
|
|
|
|
if(!disp) disp = lv_disp_get_default();
|
|
|
|
if(!disp) {
|
|
|
|
LV_LOG_WARN("lv_disp_get_inactive_time: no display registered");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(disp) return lv_tick_elaps(disp->last_activity_time);
|
|
|
|
|
|
|
|
lv_disp_t * d;
|
|
|
|
uint32_t t = UINT32_MAX;
|
|
|
|
d = lv_disp_get_next(NULL);
|
|
|
|
while(d) {
|
|
|
|
t = LV_MATH_MIN(t, lv_tick_elaps(d->last_activity_time));
|
|
|
|
d = lv_disp_get_next(d);
|
|
|
|
}
|
|
|
|
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Manually trigger an activity on a display
|
|
|
|
* @param disp pointer to an display (NULL to use the default display)
|
|
|
|
*/
|
|
|
|
void lv_disp_trig_activity(const lv_disp_t * disp)
|
|
|
|
{
|
|
|
|
if(!disp) disp = lv_disp_get_default();
|
|
|
|
if(!disp) {
|
|
|
|
LV_LOG_WARN("lv_disp_trig_activity: no display registered");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
disp->last_activity_time = lv_tick_get();
|
|
|
|
}
|
|
|
|
|
2019-02-07 19:17:10 +01:00
|
|
|
/**********************
|
|
|
|
* STATIC FUNCTIONS
|
|
|
|
**********************/
|