251 lines
6.9 KiB
C
251 lines
6.9 KiB
C
|
/**
|
||
|
* @file lv_disp.h
|
||
|
*
|
||
|
*/
|
||
|
|
||
|
#ifndef LV_DISP_H
|
||
|
#define LV_DISP_H
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
extern "C" {
|
||
|
#endif
|
||
|
|
||
|
/*********************
|
||
|
* INCLUDES
|
||
|
*********************/
|
||
|
#include "../hal/lv_hal.h"
|
||
|
#include "lv_obj.h"
|
||
|
#include "lv_theme.h"
|
||
|
|
||
|
/*********************
|
||
|
* DEFINES
|
||
|
*********************/
|
||
|
|
||
|
/**********************
|
||
|
* TYPEDEFS
|
||
|
**********************/
|
||
|
|
||
|
typedef enum {
|
||
|
LV_SCR_LOAD_ANIM_NONE,
|
||
|
LV_SCR_LOAD_ANIM_OVER_LEFT,
|
||
|
LV_SCR_LOAD_ANIM_OVER_RIGHT,
|
||
|
LV_SCR_LOAD_ANIM_OVER_TOP,
|
||
|
LV_SCR_LOAD_ANIM_OVER_BOTTOM,
|
||
|
LV_SCR_LOAD_ANIM_MOVE_LEFT,
|
||
|
LV_SCR_LOAD_ANIM_MOVE_RIGHT,
|
||
|
LV_SCR_LOAD_ANIM_MOVE_TOP,
|
||
|
LV_SCR_LOAD_ANIM_MOVE_BOTTOM,
|
||
|
LV_SCR_LOAD_ANIM_FADE_IN,
|
||
|
LV_SCR_LOAD_ANIM_FADE_ON = LV_SCR_LOAD_ANIM_FADE_IN, /*For backward compatibility*/
|
||
|
LV_SCR_LOAD_ANIM_FADE_OUT,
|
||
|
LV_SCR_LOAD_ANIM_OUT_LEFT,
|
||
|
LV_SCR_LOAD_ANIM_OUT_RIGHT,
|
||
|
LV_SCR_LOAD_ANIM_OUT_TOP,
|
||
|
LV_SCR_LOAD_ANIM_OUT_BOTTOM,
|
||
|
} lv_scr_load_anim_t;
|
||
|
|
||
|
/**********************
|
||
|
* GLOBAL PROTOTYPES
|
||
|
**********************/
|
||
|
|
||
|
/**
|
||
|
* 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()')
|
||
|
*/
|
||
|
lv_obj_t * lv_disp_get_scr_act(lv_disp_t * disp);
|
||
|
|
||
|
/**
|
||
|
* Return with a pointer to the previous screen. Only used during screen transitions.
|
||
|
* @param disp pointer to display which previous screen should be get. (NULL to use the default
|
||
|
* screen)
|
||
|
* @return pointer to the previous screen object or NULL if not used now
|
||
|
*/
|
||
|
lv_obj_t * lv_disp_get_scr_prev(lv_disp_t * disp);
|
||
|
|
||
|
/**
|
||
|
* Make a screen active
|
||
|
* @param scr pointer to a screen
|
||
|
*/
|
||
|
void lv_disp_load_scr(lv_obj_t * scr);
|
||
|
|
||
|
/**
|
||
|
* 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);
|
||
|
|
||
|
/**
|
||
|
* 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 retrieved. (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);
|
||
|
|
||
|
/**
|
||
|
* Set the theme of a display
|
||
|
* @param disp pointer to a display
|
||
|
*/
|
||
|
void lv_disp_set_theme(lv_disp_t * disp, lv_theme_t * th);
|
||
|
|
||
|
/**
|
||
|
* Get the theme of a display
|
||
|
* @param disp pointer to a display
|
||
|
* @return the display's theme (can be NULL)
|
||
|
*/
|
||
|
lv_theme_t * lv_disp_get_theme(lv_disp_t * disp);
|
||
|
|
||
|
/**
|
||
|
* Set the background color of a display
|
||
|
* @param disp pointer to a display
|
||
|
* @param color color of the background
|
||
|
*/
|
||
|
void lv_disp_set_bg_color(lv_disp_t * disp, lv_color_t color);
|
||
|
|
||
|
/**
|
||
|
* Set the background image of a display
|
||
|
* @param disp pointer to a display
|
||
|
* @param img_src path to file or pointer to an `lv_img_dsc_t` variable
|
||
|
*/
|
||
|
void lv_disp_set_bg_image(lv_disp_t * disp, const void * img_src);
|
||
|
|
||
|
/**
|
||
|
* Set opacity of the background
|
||
|
* @param disp pointer to a display
|
||
|
* @param opa opacity (0..255)
|
||
|
*/
|
||
|
void lv_disp_set_bg_opa(lv_disp_t * disp, lv_opa_t opa);
|
||
|
|
||
|
/**
|
||
|
* Switch screen with animation
|
||
|
* @param scr pointer to the new screen to load
|
||
|
* @param anim_type type of the animation from `lv_scr_load_anim_t`. E.g. `LV_SCR_LOAD_ANIM_MOVE_LEFT`
|
||
|
* @param time time of the animation
|
||
|
* @param delay delay before the transition
|
||
|
* @param auto_del true: automatically delete the old screen
|
||
|
*/
|
||
|
void lv_scr_load_anim(lv_obj_t * scr, lv_scr_load_anim_t anim_type, uint32_t time, uint32_t delay, bool auto_del);
|
||
|
|
||
|
/**
|
||
|
* Get elapsed time since last user activity on a display (e.g. click)
|
||
|
* @param disp pointer to a 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);
|
||
|
|
||
|
/**
|
||
|
* Manually trigger an activity on a display
|
||
|
* @param disp pointer to a display (NULL to use the default display)
|
||
|
*/
|
||
|
void lv_disp_trig_activity(lv_disp_t * disp);
|
||
|
|
||
|
/**
|
||
|
* Clean any CPU cache that is related to the display.
|
||
|
* @param disp pointer to a display (NULL to use the default display)
|
||
|
*/
|
||
|
void lv_disp_clean_dcache(lv_disp_t * disp);
|
||
|
|
||
|
/**
|
||
|
* Get a pointer to the screen refresher timer to
|
||
|
* modify its parameters with `lv_timer_...` functions.
|
||
|
* @param disp pointer to a display
|
||
|
* @return pointer to the display refresher timer. (NULL on error)
|
||
|
*/
|
||
|
lv_timer_t * _lv_disp_get_refr_timer(lv_disp_t * disp);
|
||
|
|
||
|
/*------------------------------------------------
|
||
|
* To improve backward compatibility
|
||
|
* Recommended only if you have one display
|
||
|
*------------------------------------------------*/
|
||
|
|
||
|
/**
|
||
|
* Get the active screen of the default display
|
||
|
* @return pointer to the active screen
|
||
|
*/
|
||
|
static inline lv_obj_t * lv_scr_act(void)
|
||
|
{
|
||
|
return lv_disp_get_scr_act(lv_disp_get_default());
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Get the top layer of the default display
|
||
|
* @return pointer to the top layer
|
||
|
*/
|
||
|
static inline lv_obj_t * lv_layer_top(void)
|
||
|
{
|
||
|
return lv_disp_get_layer_top(lv_disp_get_default());
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Get the active screen of the default display
|
||
|
* @return pointer to the sys layer
|
||
|
*/
|
||
|
static inline lv_obj_t * lv_layer_sys(void)
|
||
|
{
|
||
|
return lv_disp_get_layer_sys(lv_disp_get_default());
|
||
|
}
|
||
|
|
||
|
static inline void lv_scr_load(lv_obj_t * scr)
|
||
|
{
|
||
|
lv_disp_load_scr(scr);
|
||
|
}
|
||
|
|
||
|
/**********************
|
||
|
* MACROS
|
||
|
**********************/
|
||
|
|
||
|
/*------------------------------------------------
|
||
|
* To improve backward compatibility
|
||
|
* Recommended only if you have one display
|
||
|
*------------------------------------------------*/
|
||
|
|
||
|
#ifndef LV_HOR_RES
|
||
|
/**
|
||
|
* The horizontal resolution of the currently active display.
|
||
|
*/
|
||
|
#define LV_HOR_RES lv_disp_get_hor_res(lv_disp_get_default())
|
||
|
#endif
|
||
|
|
||
|
#ifndef LV_VER_RES
|
||
|
/**
|
||
|
* The vertical resolution of the currently active display.
|
||
|
*/
|
||
|
#define LV_VER_RES lv_disp_get_ver_res(lv_disp_get_default())
|
||
|
#endif
|
||
|
|
||
|
/**
|
||
|
* Scale the given number of pixels (a distance or size) relative to a 160 DPI display
|
||
|
* considering the DPI of the default display.
|
||
|
* It ensures that e.g. `lv_dpx(100)` will have the same physical size regardless to the
|
||
|
* DPI of the display.
|
||
|
* @param n the number of pixels to scale
|
||
|
* @return `n x current_dpi/160`
|
||
|
*/
|
||
|
static inline lv_coord_t lv_dpx(lv_coord_t n)
|
||
|
{
|
||
|
return LV_DPX(n);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Scale the given number of pixels (a distance or size) relative to a 160 DPI display
|
||
|
* considering the DPI of the given display.
|
||
|
* It ensures that e.g. `lv_dpx(100)` will have the same physical size regardless to the
|
||
|
* DPI of the display.
|
||
|
* @param obj a display whose dpi should be considered
|
||
|
* @param n the number of pixels to scale
|
||
|
* @return `n x current_dpi/160`
|
||
|
*/
|
||
|
static inline lv_coord_t lv_disp_dpx(const lv_disp_t * disp, lv_coord_t n)
|
||
|
{
|
||
|
return _LV_DPX_CALC(lv_disp_get_dpi(disp), n);
|
||
|
}
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
} /*extern "C"*/
|
||
|
#endif
|
||
|
|
||
|
#endif /*LV_DISP_H*/
|