mirror of
https://github.com/luc-github/ESP3D.git
synced 2025-10-31 11:56:48 -07:00
Refactoring internal clients (#987)
* Remove all output flags * Masse replace name function / class to sync with ESP3D-TFT * Create ESP3DMessageManager class to handle messages creation / deletion (import functions of ESp3DClient from ESp3D-TFT) * Move to new messaging API of ESP3D-TFT * Remove empty line from remote screen dispatching * Replace \n to space and \r to nothing in remote screen dispatching * Add missing default entry for sensor device * Fix buzzer for ESP32 missing ledc initialization with latest core * Move formatBytes to esp3d_string * Add welcome message to telnet connection\ * Add display to the new messaging API * Add sticky authentication on Serial / SerialBridge /Telnet/Data web socket and BT * Log simplification * Use enum class instead of typdef enum for ESP3DAuthenticationLevel to be sure correct enum is used * (v3) Home Assistant notification support (#971) * Add notification via post request * Extend t1 size to 255 bytes * Hide Home Assistant notifications from web UI (#974) * Sync with ESP3DLib on serial_socket * Add some sanity check to avoid unnecessary message copies * Update ESP0.cpp --------- Co-authored-by: David Buezas <dbuezas@users.noreply.github.com>
This commit is contained in:
@@ -264,7 +264,7 @@ menu "LVGL configuration"
|
||||
bool "Log if something unwanted happened but didn't cause a problem"
|
||||
config LV_LOG_LEVEL_ERROR
|
||||
bool "Only critical issues, when the system may fail"
|
||||
config LV_LOG_LEVEL_USER
|
||||
config LV_LOG_user
|
||||
bool "Only logs added by the user"
|
||||
config LV_LOG_LEVEL_NONE
|
||||
bool "Do not log anything"
|
||||
@@ -276,7 +276,7 @@ menu "LVGL configuration"
|
||||
default 1 if LV_LOG_LEVEL_INFO
|
||||
default 2 if LV_LOG_LEVEL_WARN
|
||||
default 3 if LV_LOG_LEVEL_ERROR
|
||||
default 4 if LV_LOG_LEVEL_USER
|
||||
default 4 if LV_LOG_user
|
||||
default 5 if LV_LOG_LEVEL_NONE
|
||||
|
||||
config LV_LOG_PRINTF
|
||||
|
||||
@@ -12,7 +12,7 @@ To enable logging, set `LV_USE_LOG 1` in `lv_conf.h` and set `LV_LOG_LEVEL` to
|
||||
- `LV_LOG_LEVEL_INFO` Log important events
|
||||
- `LV_LOG_LEVEL_WARN` Log if something unwanted happened but didn't cause a problem
|
||||
- `LV_LOG_LEVEL_ERROR` Only critical issues, where the system may fail
|
||||
- `LV_LOG_LEVEL_USER` Only user messages
|
||||
- `LV_LOG_user` Only user messages
|
||||
- `LV_LOG_LEVEL_NONE` Do not log anything
|
||||
|
||||
The events which have a higher level than the set log level will be logged too. E.g. if you `LV_LOG_LEVEL_WARN`, errors will be also logged.
|
||||
|
||||
@@ -208,7 +208,7 @@
|
||||
*LV_LOG_LEVEL_INFO Log important events
|
||||
*LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem
|
||||
*LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail
|
||||
*LV_LOG_LEVEL_USER Only logs added by the user
|
||||
*LV_LOG_user Only logs added by the user
|
||||
*LV_LOG_LEVEL_NONE Do not log anything*/
|
||||
#define LV_LOG_LEVEL LV_LOG_LEVEL_WARN
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@
|
||||
*LV_LOG_LEVEL_INFO Log important events
|
||||
*LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem
|
||||
*LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail
|
||||
*LV_LOG_LEVEL_USER Only logs added by the user
|
||||
*LV_LOG_user Only logs added by the user
|
||||
*LV_LOG_LEVEL_NONE Do not log anything*/
|
||||
#define LV_LOG_LEVEL LV_LOG_LEVEL_WARN
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ extern "C" {
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../hal/lv_hal.h"
|
||||
#include "../hal/lv_esp3d_hal.h"
|
||||
#include "lv_obj.h"
|
||||
#include "lv_theme.h"
|
||||
|
||||
@@ -26,16 +26,16 @@ extern "C" {
|
||||
**********************/
|
||||
|
||||
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_ON,
|
||||
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_ON,
|
||||
} lv_scr_load_anim_t;
|
||||
|
||||
/**********************
|
||||
@@ -44,103 +44,110 @@ typedef enum {
|
||||
|
||||
/**
|
||||
* 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)
|
||||
* @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);
|
||||
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 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);
|
||||
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);
|
||||
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 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);
|
||||
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 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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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 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);
|
||||
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)
|
||||
* @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);
|
||||
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);
|
||||
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);
|
||||
void lv_disp_clean_dcache(lv_disp_t* disp);
|
||||
|
||||
/**
|
||||
* Get a pointer to the screen refresher timer to
|
||||
@@ -148,7 +155,7 @@ void lv_disp_clean_dcache(lv_disp_t * disp);
|
||||
* @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);
|
||||
lv_timer_t* _lv_disp_get_refr_timer(lv_disp_t* disp);
|
||||
|
||||
/*------------------------------------------------
|
||||
* To improve backward compatibility
|
||||
@@ -159,33 +166,27 @@ lv_timer_t * _lv_disp_get_refr_timer(lv_disp_t * disp);
|
||||
* 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());
|
||||
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());
|
||||
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 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);
|
||||
}
|
||||
static inline void lv_scr_load(lv_obj_t* scr) { lv_disp_load_scr(scr); }
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@@ -211,30 +212,26 @@ static inline void lv_scr_load(lv_obj_t * scr)
|
||||
#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.
|
||||
* 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);
|
||||
}
|
||||
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.
|
||||
* 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);
|
||||
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
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -13,16 +13,17 @@ extern "C" {
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_conf_internal.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "../hal/lv_esp3d_hal.h"
|
||||
#include "../lv_conf_internal.h"
|
||||
#include "../misc/lv_area.h"
|
||||
#include "../misc/lv_assert.h"
|
||||
#include "../misc/lv_color.h"
|
||||
#include "../misc/lv_style.h"
|
||||
#include "../misc/lv_types.h"
|
||||
#include "../misc/lv_area.h"
|
||||
#include "../misc/lv_color.h"
|
||||
#include "../misc/lv_assert.h"
|
||||
#include "../hal/lv_hal.h"
|
||||
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -39,22 +40,23 @@ struct _lv_obj_t;
|
||||
* OR-ed values are possible
|
||||
*/
|
||||
enum {
|
||||
LV_STATE_DEFAULT = 0x0000,
|
||||
LV_STATE_CHECKED = 0x0001,
|
||||
LV_STATE_FOCUSED = 0x0002,
|
||||
LV_STATE_FOCUS_KEY = 0x0004,
|
||||
LV_STATE_EDITED = 0x0008,
|
||||
LV_STATE_HOVERED = 0x0010,
|
||||
LV_STATE_PRESSED = 0x0020,
|
||||
LV_STATE_SCROLLED = 0x0040,
|
||||
LV_STATE_DISABLED = 0x0080,
|
||||
LV_STATE_DEFAULT = 0x0000,
|
||||
LV_STATE_CHECKED = 0x0001,
|
||||
LV_STATE_FOCUSED = 0x0002,
|
||||
LV_STATE_FOCUS_KEY = 0x0004,
|
||||
LV_STATE_EDITED = 0x0008,
|
||||
LV_STATE_HOVERED = 0x0010,
|
||||
LV_STATE_PRESSED = 0x0020,
|
||||
LV_STATE_SCROLLED = 0x0040,
|
||||
LV_STATE_DISABLED = 0x0080,
|
||||
|
||||
LV_STATE_USER_1 = 0x1000,
|
||||
LV_STATE_USER_2 = 0x2000,
|
||||
LV_STATE_USER_3 = 0x4000,
|
||||
LV_STATE_USER_4 = 0x8000,
|
||||
LV_STATE_USER_1 = 0x1000,
|
||||
LV_STATE_USER_2 = 0x2000,
|
||||
LV_STATE_USER_3 = 0x4000,
|
||||
LV_STATE_USER_4 = 0x8000,
|
||||
|
||||
LV_STATE_ANY = 0xFFFF, /**< Special value can be used in some functions to target all states*/
|
||||
LV_STATE_ANY = 0xFFFF, /**< Special value can be used in some functions to
|
||||
target all states*/
|
||||
};
|
||||
|
||||
typedef uint16_t lv_state_t;
|
||||
@@ -66,18 +68,23 @@ typedef uint16_t lv_state_t;
|
||||
* Note every part is used by every widget
|
||||
*/
|
||||
enum {
|
||||
LV_PART_MAIN = 0x000000, /**< A background like rectangle*/
|
||||
LV_PART_SCROLLBAR = 0x010000, /**< The scrollbar(s)*/
|
||||
LV_PART_INDICATOR = 0x020000, /**< Indicator, e.g. for slider, bar, switch, or the tick box of the checkbox*/
|
||||
LV_PART_KNOB = 0x030000, /**< Like handle to grab to adjust the value*/
|
||||
LV_PART_SELECTED = 0x040000, /**< Indicate the currently selected option or section*/
|
||||
LV_PART_ITEMS = 0x050000, /**< Used if the widget has multiple similar elements (e.g. table cells)*/
|
||||
LV_PART_TICKS = 0x060000, /**< Ticks on scale e.g. for a chart or meter*/
|
||||
LV_PART_CURSOR = 0x070000, /**< Mark a specific place e.g. for text area's cursor or on a chart*/
|
||||
LV_PART_MAIN = 0x000000, /**< A background like rectangle*/
|
||||
LV_PART_SCROLLBAR = 0x010000, /**< The scrollbar(s)*/
|
||||
LV_PART_INDICATOR = 0x020000, /**< Indicator, e.g. for slider, bar, switch, or
|
||||
the tick box of the checkbox*/
|
||||
LV_PART_KNOB = 0x030000, /**< Like handle to grab to adjust the value*/
|
||||
LV_PART_SELECTED =
|
||||
0x040000, /**< Indicate the currently selected option or section*/
|
||||
LV_PART_ITEMS = 0x050000, /**< Used if the widget has multiple similar
|
||||
elements (e.g. table cells)*/
|
||||
LV_PART_TICKS = 0x060000, /**< Ticks on scale e.g. for a chart or meter*/
|
||||
LV_PART_CURSOR = 0x070000, /**< Mark a specific place e.g. for text area's
|
||||
cursor or on a chart*/
|
||||
|
||||
LV_PART_CUSTOM_FIRST = 0x080000, /**< Extension point for custom widgets*/
|
||||
LV_PART_CUSTOM_FIRST = 0x080000, /**< Extension point for custom widgets*/
|
||||
|
||||
LV_PART_ANY = 0x0F0000, /**< Special value can be used in some functions to target all parts*/
|
||||
LV_PART_ANY = 0x0F0000, /**< Special value can be used in some functions to
|
||||
target all parts*/
|
||||
};
|
||||
|
||||
typedef uint32_t lv_part_t;
|
||||
@@ -87,41 +94,62 @@ typedef uint32_t lv_part_t;
|
||||
* OR-ed values are possible
|
||||
*/
|
||||
enum {
|
||||
LV_OBJ_FLAG_HIDDEN = (1L << 0), /**< Make the object hidden. (Like it wasn't there at all)*/
|
||||
LV_OBJ_FLAG_CLICKABLE = (1L << 1), /**< Make the object clickable by the input devices*/
|
||||
LV_OBJ_FLAG_CLICK_FOCUSABLE = (1L << 2), /**< Add focused state to the object when clicked*/
|
||||
LV_OBJ_FLAG_CHECKABLE = (1L << 3), /**< Toggle checked state when the object is clicked*/
|
||||
LV_OBJ_FLAG_SCROLLABLE = (1L << 4), /**< Make the object scrollable*/
|
||||
LV_OBJ_FLAG_SCROLL_ELASTIC = (1L << 5), /**< Allow scrolling inside but with slower speed*/
|
||||
LV_OBJ_FLAG_SCROLL_MOMENTUM = (1L << 6), /**< Make the object scroll further when "thrown"*/
|
||||
LV_OBJ_FLAG_SCROLL_ONE = (1L << 7), /**< Allow scrolling only one snappable children*/
|
||||
LV_OBJ_FLAG_SCROLL_CHAIN_HOR = (1L << 8), /**< Allow propagating the horizontal scroll to a parent*/
|
||||
LV_OBJ_FLAG_SCROLL_CHAIN_VER = (1L << 9), /**< Allow propagating the vertical scroll to a parent*/
|
||||
LV_OBJ_FLAG_SCROLL_CHAIN = (LV_OBJ_FLAG_SCROLL_CHAIN_HOR | LV_OBJ_FLAG_SCROLL_CHAIN_VER),
|
||||
LV_OBJ_FLAG_SCROLL_ON_FOCUS = (1L << 10), /**< Automatically scroll object to make it visible when focused*/
|
||||
LV_OBJ_FLAG_SCROLL_WITH_ARROW = (1L << 11), /**< Allow scrolling the focused object with arrow keys*/
|
||||
LV_OBJ_FLAG_SNAPPABLE = (1L << 12), /**< If scroll snap is enabled on the parent it can snap to this object*/
|
||||
LV_OBJ_FLAG_PRESS_LOCK = (1L << 13), /**< Keep the object pressed even if the press slid from the object*/
|
||||
LV_OBJ_FLAG_EVENT_BUBBLE = (1L << 14), /**< Propagate the events to the parent too*/
|
||||
LV_OBJ_FLAG_GESTURE_BUBBLE = (1L << 15), /**< Propagate the gestures to the parent*/
|
||||
LV_OBJ_FLAG_ADV_HITTEST = (1L << 16), /**< Allow performing more accurate hit (click) test. E.g. consider rounded corners.*/
|
||||
LV_OBJ_FLAG_IGNORE_LAYOUT = (1L << 17), /**< Make the object position-able by the layouts*/
|
||||
LV_OBJ_FLAG_FLOATING = (1L << 18), /**< Do not scroll the object when the parent scrolls and ignore layout*/
|
||||
LV_OBJ_FLAG_OVERFLOW_VISIBLE = (1L << 19), /**< Do not clip the children's content to the parent's boundary*/
|
||||
LV_OBJ_FLAG_HIDDEN =
|
||||
(1L << 0), /**< Make the object hidden. (Like it wasn't there at all)*/
|
||||
LV_OBJ_FLAG_CLICKABLE =
|
||||
(1L << 1), /**< Make the object clickable by the input devices*/
|
||||
LV_OBJ_FLAG_CLICK_FOCUSABLE =
|
||||
(1L << 2), /**< Add focused state to the object when clicked*/
|
||||
LV_OBJ_FLAG_CHECKABLE =
|
||||
(1L << 3), /**< Toggle checked state when the object is clicked*/
|
||||
LV_OBJ_FLAG_SCROLLABLE = (1L << 4), /**< Make the object scrollable*/
|
||||
LV_OBJ_FLAG_SCROLL_ELASTIC =
|
||||
(1L << 5), /**< Allow scrolling inside but with slower speed*/
|
||||
LV_OBJ_FLAG_SCROLL_MOMENTUM =
|
||||
(1L << 6), /**< Make the object scroll further when "thrown"*/
|
||||
LV_OBJ_FLAG_SCROLL_ONE =
|
||||
(1L << 7), /**< Allow scrolling only one snappable children*/
|
||||
LV_OBJ_FLAG_SCROLL_CHAIN_HOR =
|
||||
(1L << 8), /**< Allow propagating the horizontal scroll to a parent*/
|
||||
LV_OBJ_FLAG_SCROLL_CHAIN_VER =
|
||||
(1L << 9), /**< Allow propagating the vertical scroll to a parent*/
|
||||
LV_OBJ_FLAG_SCROLL_CHAIN =
|
||||
(LV_OBJ_FLAG_SCROLL_CHAIN_HOR | LV_OBJ_FLAG_SCROLL_CHAIN_VER),
|
||||
LV_OBJ_FLAG_SCROLL_ON_FOCUS = (1L << 10), /**< Automatically scroll object to
|
||||
make it visible when focused*/
|
||||
LV_OBJ_FLAG_SCROLL_WITH_ARROW =
|
||||
(1L << 11), /**< Allow scrolling the focused object with arrow keys*/
|
||||
LV_OBJ_FLAG_SNAPPABLE = (1L << 12), /**< If scroll snap is enabled on the
|
||||
parent it can snap to this object*/
|
||||
LV_OBJ_FLAG_PRESS_LOCK = (1L << 13), /**< Keep the object pressed even if the
|
||||
press slid from the object*/
|
||||
LV_OBJ_FLAG_EVENT_BUBBLE =
|
||||
(1L << 14), /**< Propagate the events to the parent too*/
|
||||
LV_OBJ_FLAG_GESTURE_BUBBLE =
|
||||
(1L << 15), /**< Propagate the gestures to the parent*/
|
||||
LV_OBJ_FLAG_ADV_HITTEST =
|
||||
(1L << 16), /**< Allow performing more accurate hit (click) test. E.g.
|
||||
consider rounded corners.*/
|
||||
LV_OBJ_FLAG_IGNORE_LAYOUT =
|
||||
(1L << 17), /**< Make the object position-able by the layouts*/
|
||||
LV_OBJ_FLAG_FLOATING = (1L << 18), /**< Do not scroll the object when the
|
||||
parent scrolls and ignore layout*/
|
||||
LV_OBJ_FLAG_OVERFLOW_VISIBLE =
|
||||
(1L << 19), /**< Do not clip the children's content to the parent's
|
||||
boundary*/
|
||||
|
||||
LV_OBJ_FLAG_LAYOUT_1 = (1L << 23), /**< Custom flag, free to use by layouts*/
|
||||
LV_OBJ_FLAG_LAYOUT_2 = (1L << 24), /**< Custom flag, free to use by layouts*/
|
||||
LV_OBJ_FLAG_LAYOUT_1 = (1L << 23), /**< Custom flag, free to use by layouts*/
|
||||
LV_OBJ_FLAG_LAYOUT_2 = (1L << 24), /**< Custom flag, free to use by layouts*/
|
||||
|
||||
LV_OBJ_FLAG_WIDGET_1 = (1L << 25), /**< Custom flag, free to use by widget*/
|
||||
LV_OBJ_FLAG_WIDGET_2 = (1L << 26), /**< Custom flag, free to use by widget*/
|
||||
LV_OBJ_FLAG_USER_1 = (1L << 27), /**< Custom flag, free to use by user*/
|
||||
LV_OBJ_FLAG_USER_2 = (1L << 28), /**< Custom flag, free to use by user*/
|
||||
LV_OBJ_FLAG_USER_3 = (1L << 29), /**< Custom flag, free to use by user*/
|
||||
LV_OBJ_FLAG_USER_4 = (1L << 30), /**< Custom flag, free to use by user*/
|
||||
LV_OBJ_FLAG_WIDGET_1 = (1L << 25), /**< Custom flag, free to use by widget*/
|
||||
LV_OBJ_FLAG_WIDGET_2 = (1L << 26), /**< Custom flag, free to use by widget*/
|
||||
LV_OBJ_FLAG_USER_1 = (1L << 27), /**< Custom flag, free to use by user*/
|
||||
LV_OBJ_FLAG_USER_2 = (1L << 28), /**< Custom flag, free to use by user*/
|
||||
LV_OBJ_FLAG_USER_3 = (1L << 29), /**< Custom flag, free to use by user*/
|
||||
LV_OBJ_FLAG_USER_4 = (1L << 30), /**< Custom flag, free to use by user*/
|
||||
|
||||
};
|
||||
|
||||
|
||||
typedef uint32_t lv_obj_flag_t;
|
||||
|
||||
/**
|
||||
@@ -129,19 +157,20 @@ typedef uint32_t lv_obj_flag_t;
|
||||
* Used in `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END`
|
||||
*/
|
||||
typedef enum {
|
||||
LV_OBJ_DRAW_PART_RECTANGLE, /**< The main rectangle*/
|
||||
LV_OBJ_DRAW_PART_BORDER_POST,/**< The border if style_border_post = true*/
|
||||
LV_OBJ_DRAW_PART_SCROLLBAR, /**< The scrollbar*/
|
||||
LV_OBJ_DRAW_PART_RECTANGLE, /**< The main rectangle*/
|
||||
LV_OBJ_DRAW_PART_BORDER_POST, /**< The border if style_border_post = true*/
|
||||
LV_OBJ_DRAW_PART_SCROLLBAR, /**< The scrollbar*/
|
||||
} lv_obj_draw_part_type_t;
|
||||
|
||||
#include "lv_obj_tree.h"
|
||||
#include "lv_event.h"
|
||||
#include "lv_group.h"
|
||||
#include "lv_obj_class.h"
|
||||
#include "lv_obj_draw.h"
|
||||
#include "lv_obj_pos.h"
|
||||
#include "lv_obj_scroll.h"
|
||||
#include "lv_obj_style.h"
|
||||
#include "lv_obj_draw.h"
|
||||
#include "lv_obj_class.h"
|
||||
#include "lv_event.h"
|
||||
#include "lv_group.h"
|
||||
#include "lv_obj_tree.h"
|
||||
|
||||
|
||||
/**
|
||||
* Make the base object's class publicly available.
|
||||
@@ -153,43 +182,48 @@ extern const lv_obj_class_t lv_obj_class;
|
||||
* They are allocated automatically if any elements is set.
|
||||
*/
|
||||
typedef struct {
|
||||
struct _lv_obj_t ** children; /**< Store the pointer of the children in an array.*/
|
||||
uint32_t child_cnt; /**< Number of children*/
|
||||
lv_group_t * group_p;
|
||||
struct _lv_obj_t**
|
||||
children; /**< Store the pointer of the children in an array.*/
|
||||
uint32_t child_cnt; /**< Number of children*/
|
||||
lv_group_t* group_p;
|
||||
|
||||
struct _lv_event_dsc_t * event_dsc; /**< Dynamically allocated event callback and user data array*/
|
||||
lv_point_t scroll; /**< The current X/Y scroll offset*/
|
||||
struct _lv_event_dsc_t*
|
||||
event_dsc; /**< Dynamically allocated event callback and user data array*/
|
||||
lv_point_t scroll; /**< The current X/Y scroll offset*/
|
||||
|
||||
lv_coord_t ext_click_pad; /**< Extra click padding in all direction*/
|
||||
lv_coord_t ext_draw_size; /**< EXTend the size in every direction for drawing.*/
|
||||
lv_coord_t ext_click_pad; /**< Extra click padding in all direction*/
|
||||
lv_coord_t
|
||||
ext_draw_size; /**< EXTend the size in every direction for drawing.*/
|
||||
|
||||
lv_scrollbar_mode_t scrollbar_mode : 2; /**< How to display scrollbars*/
|
||||
lv_scroll_snap_t scroll_snap_x : 2; /**< Where to align the snappable children horizontally*/
|
||||
lv_scroll_snap_t scroll_snap_y : 2; /**< Where to align the snappable children vertically*/
|
||||
lv_dir_t scroll_dir : 4; /**< The allowed scroll direction(s)*/
|
||||
uint8_t event_dsc_cnt; /**< Number of event callbacks stored in `event_dsc` array*/
|
||||
lv_scrollbar_mode_t scrollbar_mode : 2; /**< How to display scrollbars*/
|
||||
lv_scroll_snap_t scroll_snap_x : 2; /**< Where to align the snappable children
|
||||
horizontally*/
|
||||
lv_scroll_snap_t
|
||||
scroll_snap_y : 2; /**< Where to align the snappable children vertically*/
|
||||
lv_dir_t scroll_dir : 4; /**< The allowed scroll direction(s)*/
|
||||
uint8_t event_dsc_cnt; /**< Number of event callbacks stored in `event_dsc`
|
||||
array*/
|
||||
} _lv_obj_spec_attr_t;
|
||||
|
||||
typedef struct _lv_obj_t {
|
||||
const lv_obj_class_t * class_p;
|
||||
struct _lv_obj_t * parent;
|
||||
_lv_obj_spec_attr_t * spec_attr;
|
||||
_lv_obj_style_t * styles;
|
||||
const lv_obj_class_t* class_p;
|
||||
struct _lv_obj_t* parent;
|
||||
_lv_obj_spec_attr_t* spec_attr;
|
||||
_lv_obj_style_t* styles;
|
||||
#if LV_USE_USER_DATA
|
||||
void * user_data;
|
||||
void* user_data;
|
||||
#endif
|
||||
lv_area_t coords;
|
||||
lv_obj_flag_t flags;
|
||||
lv_state_t state;
|
||||
uint16_t layout_inv : 1;
|
||||
uint16_t scr_layout_inv : 1;
|
||||
uint16_t skip_trans : 1;
|
||||
uint16_t style_cnt : 6;
|
||||
uint16_t h_layout : 1;
|
||||
uint16_t w_layout : 1;
|
||||
lv_area_t coords;
|
||||
lv_obj_flag_t flags;
|
||||
lv_state_t state;
|
||||
uint16_t layout_inv : 1;
|
||||
uint16_t scr_layout_inv : 1;
|
||||
uint16_t skip_trans : 1;
|
||||
uint16_t style_cnt : 6;
|
||||
uint16_t h_layout : 1;
|
||||
uint16_t w_layout : 1;
|
||||
} lv_obj_t;
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
@@ -204,7 +238,8 @@ void lv_init(void);
|
||||
|
||||
/**
|
||||
* Deinit the 'lv' library
|
||||
* Currently only implemented when not using custom allocators, or GC is enabled.
|
||||
* Currently only implemented when not using custom allocators, or GC is
|
||||
* enabled.
|
||||
*/
|
||||
void lv_deinit(void);
|
||||
|
||||
@@ -217,11 +252,11 @@ bool lv_is_initialized(void);
|
||||
|
||||
/**
|
||||
* Create a base object (a rectangle)
|
||||
* @param parent pointer to a parent object. If NULL then a screen will be created.
|
||||
* @param parent pointer to a parent object. If NULL then a screen will be
|
||||
* created.
|
||||
* @return pointer to the new object
|
||||
*/
|
||||
lv_obj_t * lv_obj_create(lv_obj_t * parent);
|
||||
|
||||
lv_obj_t* lv_obj_create(lv_obj_t* parent);
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
@@ -232,31 +267,32 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent);
|
||||
* @param obj pointer to an object
|
||||
* @param f R-ed values from `lv_obj_flag_t` to set.
|
||||
*/
|
||||
void lv_obj_add_flag(lv_obj_t * obj, lv_obj_flag_t f);
|
||||
void lv_obj_add_flag(lv_obj_t* obj, lv_obj_flag_t f);
|
||||
|
||||
/**
|
||||
* Clear one or more flags
|
||||
* @param obj pointer to an object
|
||||
* @param f OR-ed values from `lv_obj_flag_t` to set.
|
||||
*/
|
||||
void lv_obj_clear_flag(lv_obj_t * obj, lv_obj_flag_t f);
|
||||
|
||||
void lv_obj_clear_flag(lv_obj_t* obj, lv_obj_flag_t f);
|
||||
|
||||
/**
|
||||
* Add one or more states to the object. The other state bits will remain unchanged.
|
||||
* If specified in the styles, transition animation will be started from the previous state to the current.
|
||||
* Add one or more states to the object. The other state bits will remain
|
||||
* unchanged. If specified in the styles, transition animation will be started
|
||||
* from the previous state to the current.
|
||||
* @param obj pointer to an object
|
||||
* @param state the states to add. E.g `LV_STATE_PRESSED | LV_STATE_FOCUSED`
|
||||
*/
|
||||
void lv_obj_add_state(lv_obj_t * obj, lv_state_t state);
|
||||
void lv_obj_add_state(lv_obj_t* obj, lv_state_t state);
|
||||
|
||||
/**
|
||||
* Remove one or more states to the object. The other state bits will remain unchanged.
|
||||
* If specified in the styles, transition animation will be started from the previous state to the current.
|
||||
* Remove one or more states to the object. The other state bits will remain
|
||||
* unchanged. If specified in the styles, transition animation will be started
|
||||
* from the previous state to the current.
|
||||
* @param obj pointer to an object
|
||||
* @param state the states to add. E.g `LV_STATE_PRESSED | LV_STATE_FOCUSED`
|
||||
*/
|
||||
void lv_obj_clear_state(lv_obj_t * obj, lv_state_t state);
|
||||
void lv_obj_clear_state(lv_obj_t* obj, lv_state_t state);
|
||||
|
||||
/**
|
||||
* Set the user_data field of the object
|
||||
@@ -264,9 +300,8 @@ void lv_obj_clear_state(lv_obj_t * obj, lv_state_t state);
|
||||
* @param user_data pointer to the new user_data.
|
||||
*/
|
||||
#if LV_USE_USER_DATA
|
||||
static inline void lv_obj_set_user_data(lv_obj_t * obj, void * user_data)
|
||||
{
|
||||
obj->user_data = user_data;
|
||||
static inline void lv_obj_set_user_data(lv_obj_t* obj, void* user_data) {
|
||||
obj->user_data = user_data;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -280,22 +315,23 @@ static inline void lv_obj_set_user_data(lv_obj_t * obj, void * user_data)
|
||||
* @param f the flag(s) to check (OR-ed values can be used)
|
||||
* @return true: all flags are set; false: not all flags are set
|
||||
*/
|
||||
bool lv_obj_has_flag(const lv_obj_t * obj, lv_obj_flag_t f);
|
||||
bool lv_obj_has_flag(const lv_obj_t* obj, lv_obj_flag_t f);
|
||||
|
||||
/**
|
||||
* Check if a given flag or any of the flags are set on an object.
|
||||
* @param obj pointer to an object
|
||||
* @param f the flag(s) to check (OR-ed values can be used)
|
||||
* @return true: at lest one flag flag is set; false: none of the flags are set
|
||||
* @return true: at lest one flag flag is set; false: none of the flags are
|
||||
* set
|
||||
*/
|
||||
bool lv_obj_has_flag_any(const lv_obj_t * obj, lv_obj_flag_t f);
|
||||
bool lv_obj_has_flag_any(const lv_obj_t* obj, lv_obj_flag_t f);
|
||||
|
||||
/**
|
||||
* Get the state of an object
|
||||
* @param obj pointer to an object
|
||||
* @return the state (OR-ed values from `lv_state_t`)
|
||||
*/
|
||||
lv_state_t lv_obj_get_state(const lv_obj_t * obj);
|
||||
lv_state_t lv_obj_get_state(const lv_obj_t* obj);
|
||||
|
||||
/**
|
||||
* Check if the object is in a given state or not.
|
||||
@@ -303,14 +339,14 @@ lv_state_t lv_obj_get_state(const lv_obj_t * obj);
|
||||
* @param state a state or combination of states to check
|
||||
* @return true: `obj` is in `state`; false: `obj` is not in `state`
|
||||
*/
|
||||
bool lv_obj_has_state(const lv_obj_t * obj, lv_state_t state);
|
||||
bool lv_obj_has_state(const lv_obj_t* obj, lv_state_t state);
|
||||
|
||||
/**
|
||||
* Get the group of the object
|
||||
* @param obj pointer to an object
|
||||
* @return the pointer to group of the object
|
||||
*/
|
||||
void * lv_obj_get_group(const lv_obj_t * obj);
|
||||
void* lv_obj_get_group(const lv_obj_t* obj);
|
||||
|
||||
/**
|
||||
* Get the user_data field of the object
|
||||
@@ -318,9 +354,8 @@ void * lv_obj_get_group(const lv_obj_t * obj);
|
||||
* @return the pointer to the user_data of the object
|
||||
*/
|
||||
#if LV_USE_USER_DATA
|
||||
static inline void * lv_obj_get_user_data(lv_obj_t * obj)
|
||||
{
|
||||
return obj->user_data;
|
||||
static inline void* lv_obj_get_user_data(lv_obj_t* obj) {
|
||||
return obj->user_data;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -332,7 +367,7 @@ static inline void * lv_obj_get_user_data(lv_obj_t * obj)
|
||||
* Allocate special data for an object if not allocated yet.
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_allocate_spec_attr(lv_obj_t * obj);
|
||||
void lv_obj_allocate_spec_attr(lv_obj_t* obj);
|
||||
|
||||
/**
|
||||
* Check the type of obj.
|
||||
@@ -340,7 +375,7 @@ void lv_obj_allocate_spec_attr(lv_obj_t * obj);
|
||||
* @param class_p a class to check (e.g. `lv_slider_class`)
|
||||
* @return true: `class_p` is the `obj` class.
|
||||
*/
|
||||
bool lv_obj_check_type(const lv_obj_t * obj, const lv_obj_class_t * class_p);
|
||||
bool lv_obj_check_type(const lv_obj_t* obj, const lv_obj_class_t* class_p);
|
||||
|
||||
/**
|
||||
* Check if any object has a given class (type).
|
||||
@@ -349,34 +384,33 @@ bool lv_obj_check_type(const lv_obj_t * obj, const lv_obj_class_t * class_p);
|
||||
* @param class_p a class to check (e.g. `lv_slider_class`)
|
||||
* @return true: `obj` has the given class
|
||||
*/
|
||||
bool lv_obj_has_class(const lv_obj_t * obj, const lv_obj_class_t * class_p);
|
||||
bool lv_obj_has_class(const lv_obj_t* obj, const lv_obj_class_t* class_p);
|
||||
|
||||
/**
|
||||
* Get the class (type) of the object
|
||||
* @param obj pointer to an object
|
||||
* @return the class (type) of the object
|
||||
*/
|
||||
const lv_obj_class_t * lv_obj_get_class(const lv_obj_t * obj);
|
||||
const lv_obj_class_t* lv_obj_get_class(const lv_obj_t* obj);
|
||||
|
||||
/**
|
||||
* Check if any object is still "alive".
|
||||
* @param obj pointer to an object
|
||||
* @return true: valid
|
||||
*/
|
||||
bool lv_obj_is_valid(const lv_obj_t * obj);
|
||||
bool lv_obj_is_valid(const lv_obj_t* obj);
|
||||
|
||||
/**
|
||||
* Scale the given number of pixels (a distance or size) relative to a 160 DPI display
|
||||
* considering the DPI of the `obj`'s display.
|
||||
* It ensures that e.g. `lv_dpx(100)` will have the same physical size regardless to the
|
||||
* DPI of the display.
|
||||
* Scale the given number of pixels (a distance or size) relative to a 160 DPI
|
||||
* display considering the DPI of the `obj`'s display. It ensures that e.g.
|
||||
* `lv_dpx(100)` will have the same physical size regardless to the DPI of the
|
||||
* display.
|
||||
* @param obj an object whose display's dpi should be considered
|
||||
* @param n the number of pixels to scale
|
||||
* @return `n x current_dpi/160`
|
||||
*/
|
||||
static inline lv_coord_t lv_obj_dpx(const lv_obj_t * obj, lv_coord_t n)
|
||||
{
|
||||
return _LV_DPX_CALC(lv_disp_get_dpi(lv_obj_get_disp(obj)), n);
|
||||
static inline lv_coord_t lv_obj_dpx(const lv_obj_t* obj, lv_coord_t n) {
|
||||
return _LV_DPX_CALC(lv_disp_get_dpi(lv_obj_get_disp(obj)), n);
|
||||
}
|
||||
|
||||
/**********************
|
||||
@@ -384,23 +418,26 @@ static inline lv_coord_t lv_obj_dpx(const lv_obj_t * obj, lv_coord_t n)
|
||||
**********************/
|
||||
|
||||
#if LV_USE_ASSERT_OBJ
|
||||
# define LV_ASSERT_OBJ(obj_p, obj_class) \
|
||||
do { \
|
||||
LV_ASSERT_MSG(obj_p != NULL, "The object is NULL"); \
|
||||
LV_ASSERT_MSG(lv_obj_has_class(obj_p, obj_class) == true, "Incompatible object type."); \
|
||||
LV_ASSERT_MSG(lv_obj_is_valid(obj_p) == true, "The object is invalid, deleted or corrupted?"); \
|
||||
} while(0)
|
||||
# else
|
||||
# define LV_ASSERT_OBJ(obj_p, obj_class) do{}while(0)
|
||||
#define LV_ASSERT_OBJ(obj_p, obj_class) \
|
||||
do { \
|
||||
LV_ASSERT_MSG(obj_p != NULL, "The object is NULL"); \
|
||||
LV_ASSERT_MSG(lv_obj_has_class(obj_p, obj_class) == true, \
|
||||
"Incompatible object type."); \
|
||||
LV_ASSERT_MSG(lv_obj_is_valid(obj_p) == true, \
|
||||
"The object is invalid, deleted or corrupted?"); \
|
||||
} while (0)
|
||||
#else
|
||||
#define LV_ASSERT_OBJ(obj_p, obj_class) \
|
||||
do { \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#if LV_USE_LOG && LV_LOG_TRACE_OBJ_CREATE
|
||||
# define LV_TRACE_OBJ_CREATE(...) LV_LOG_TRACE(__VA_ARGS__)
|
||||
#define LV_TRACE_OBJ_CREATE(...) LV_LOG_TRACE(__VA_ARGS__)
|
||||
#else
|
||||
# define LV_TRACE_OBJ_CREATE(...)
|
||||
#define LV_TRACE_OBJ_CREATE(...)
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @file lv_hal.h
|
||||
* @file lv_esp3d_hal.h
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -21,13 +21,14 @@ extern "C" {
|
||||
* DEFINES
|
||||
*********************/
|
||||
/**
|
||||
* Same as Android's DIP. (Different name is chosen to avoid mistype between LV_DPI and LV_DIP)
|
||||
* 1 dip is 1 px on a 160 DPI screen
|
||||
* 1 dip is 2 px on a 320 DPI screen
|
||||
* Same as Android's DIP. (Different name is chosen to avoid mistype between
|
||||
* LV_DPI and LV_DIP) 1 dip is 1 px on a 160 DPI screen 1 dip is 2 px on a 320
|
||||
* DPI screen
|
||||
* https://stackoverflow.com/questions/2025282/what-is-the-difference-between-px-dip-dp-and-sp
|
||||
*/
|
||||
#define _LV_DPX_CALC(dpi, n) ((n) == 0 ? 0 :LV_MAX((( (dpi) * (n) + 80) / 160), 1)) /*+80 for rounding*/
|
||||
#define LV_DPX(n) _LV_DPX_CALC(lv_disp_get_dpi(NULL), n)
|
||||
#define _LV_DPX_CALC(dpi, n) \
|
||||
((n) == 0 ? 0 : LV_MAX((((dpi) * (n) + 80) / 160), 1)) /*+80 for rounding*/
|
||||
#define LV_DPX(n) _LV_DPX_CALC(lv_disp_get_dpi(NULL), n)
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,14 +15,16 @@ extern "C" {
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "lv_hal.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../draw/lv_draw.h"
|
||||
#include "../misc/lv_color.h"
|
||||
#include "../misc/lv_area.h"
|
||||
#include "../misc/lv_color.h"
|
||||
#include "../misc/lv_ll.h"
|
||||
#include "../misc/lv_timer.h"
|
||||
#include "lv_esp3d_hal.h"
|
||||
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -48,25 +50,28 @@ struct _lv_theme_t;
|
||||
* Structure for holding display buffer information.
|
||||
*/
|
||||
typedef struct _lv_disp_draw_buf_t {
|
||||
void * buf1; /**< First display buffer.*/
|
||||
void * buf2; /**< Second display buffer.*/
|
||||
void* buf1; /**< First display buffer.*/
|
||||
void* buf2; /**< Second display buffer.*/
|
||||
|
||||
/*Internal, used by the library*/
|
||||
void * buf_act;
|
||||
uint32_t size; /*In pixel count*/
|
||||
/*1: flushing is in progress. (It can't be a bit field because when it's cleared from IRQ Read-Modify-Write issue might occur)*/
|
||||
volatile int flushing;
|
||||
/*1: It was the last chunk to flush. (It can't be a bit field because when it's cleared from IRQ Read-Modify-Write issue might occur)*/
|
||||
volatile int flushing_last;
|
||||
volatile uint32_t last_area : 1; /*1: the last area is being rendered*/
|
||||
volatile uint32_t last_part : 1; /*1: the last part of the current area is being rendered*/
|
||||
/*Internal, used by the library*/
|
||||
void* buf_act;
|
||||
uint32_t size; /*In pixel count*/
|
||||
/*1: flushing is in progress. (It can't be a bit field because when it's
|
||||
* cleared from IRQ Read-Modify-Write issue might occur)*/
|
||||
volatile int flushing;
|
||||
/*1: It was the last chunk to flush. (It can't be a bit field because when
|
||||
* it's cleared from IRQ Read-Modify-Write issue might occur)*/
|
||||
volatile int flushing_last;
|
||||
volatile uint32_t last_area : 1; /*1: the last area is being rendered*/
|
||||
volatile uint32_t
|
||||
last_part : 1; /*1: the last part of the current area is being rendered*/
|
||||
} lv_disp_draw_buf_t;
|
||||
|
||||
typedef enum {
|
||||
LV_DISP_ROT_NONE = 0,
|
||||
LV_DISP_ROT_90,
|
||||
LV_DISP_ROT_180,
|
||||
LV_DISP_ROT_270
|
||||
LV_DISP_ROT_NONE = 0,
|
||||
LV_DISP_ROT_90,
|
||||
LV_DISP_ROT_180,
|
||||
LV_DISP_ROT_270
|
||||
} lv_disp_rot_t;
|
||||
|
||||
/**
|
||||
@@ -75,75 +80,86 @@ typedef enum {
|
||||
* `static lv_disp_drv_t my_drv` or allocated dynamically.
|
||||
*/
|
||||
typedef struct _lv_disp_drv_t {
|
||||
lv_coord_t hor_res; /**< Horizontal resolution.*/
|
||||
lv_coord_t ver_res; /**< Vertical resolution.*/
|
||||
|
||||
lv_coord_t hor_res; /**< Horizontal resolution.*/
|
||||
lv_coord_t ver_res; /**< Vertical resolution.*/
|
||||
lv_coord_t physical_hor_res; /**< Horizontal resolution of the full / physical
|
||||
display. Set to -1 for fullscreen mode.*/
|
||||
lv_coord_t physical_ver_res; /**< Vertical resolution of the full / physical
|
||||
display. Set to -1 for fullscreen mode.*/
|
||||
lv_coord_t offset_x; /**< Horizontal offset from the full / physical display.
|
||||
Set to 0 for fullscreen mode.*/
|
||||
lv_coord_t offset_y; /**< Vertical offset from the full / physical display.
|
||||
Set to 0 for fullscreen mode.*/
|
||||
|
||||
lv_coord_t
|
||||
physical_hor_res; /**< Horizontal resolution of the full / physical display. Set to -1 for fullscreen mode.*/
|
||||
lv_coord_t
|
||||
physical_ver_res; /**< Vertical resolution of the full / physical display. Set to -1 for fullscreen mode.*/
|
||||
lv_coord_t
|
||||
offset_x; /**< Horizontal offset from the full / physical display. Set to 0 for fullscreen mode.*/
|
||||
lv_coord_t offset_y; /**< Vertical offset from the full / physical display. Set to 0 for fullscreen mode.*/
|
||||
/** Pointer to a buffer initialized with `lv_disp_draw_buf_init()`.
|
||||
* LVGL will use this buffer(s) to draw the screens contents*/
|
||||
lv_disp_draw_buf_t* draw_buf;
|
||||
|
||||
/** Pointer to a buffer initialized with `lv_disp_draw_buf_init()`.
|
||||
* LVGL will use this buffer(s) to draw the screens contents*/
|
||||
lv_disp_draw_buf_t * draw_buf;
|
||||
uint32_t direct_mode : 1; /**< 1: Use screen-sized buffers and draw to
|
||||
absolute coordinates*/
|
||||
uint32_t full_refresh : 1; /**< 1: Always make the whole screen redrawn*/
|
||||
uint32_t sw_rotate : 1; /**< 1: use software rotation (slower)*/
|
||||
uint32_t antialiasing : 1; /**< 1: anti-aliasing is enabled on this display.*/
|
||||
uint32_t rotated : 2; /**< 1: turn the display by 90 degree. @warning Does not
|
||||
update coordinates for you!*/
|
||||
uint32_t screen_transp : 1; /**Handle if the screen doesn't have a solid (opa
|
||||
* == LV_OPA_COVER) background. Use only if
|
||||
* required because it's slower.*/
|
||||
|
||||
uint32_t direct_mode : 1; /**< 1: Use screen-sized buffers and draw to absolute coordinates*/
|
||||
uint32_t full_refresh : 1; /**< 1: Always make the whole screen redrawn*/
|
||||
uint32_t sw_rotate : 1; /**< 1: use software rotation (slower)*/
|
||||
uint32_t antialiasing : 1; /**< 1: anti-aliasing is enabled on this display.*/
|
||||
uint32_t rotated : 2; /**< 1: turn the display by 90 degree. @warning Does not update coordinates for you!*/
|
||||
uint32_t screen_transp : 1; /**Handle if the screen doesn't have a solid (opa == LV_OPA_COVER) background.
|
||||
* Use only if required because it's slower.*/
|
||||
uint32_t dpi : 10; /** DPI (dot per inch) of the display. Default value is
|
||||
`LV_DPI_DEF`.*/
|
||||
|
||||
uint32_t dpi : 10; /** DPI (dot per inch) of the display. Default value is `LV_DPI_DEF`.*/
|
||||
/** MANDATORY: Write the internal buffer (draw_buf) to the display.
|
||||
* 'lv_disp_flush_ready()' has to be called when finished*/
|
||||
void (*flush_cb)(struct _lv_disp_drv_t* disp_drv, const lv_area_t* area,
|
||||
lv_color_t* color_p);
|
||||
|
||||
/** MANDATORY: Write the internal buffer (draw_buf) to the display. 'lv_disp_flush_ready()' has to be
|
||||
* called when finished*/
|
||||
void (*flush_cb)(struct _lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p);
|
||||
/** OPTIONAL: Extend the invalidated areas to match with the display drivers
|
||||
* requirements E.g. round `y` to, 8, 16 ..) on a monochrome display*/
|
||||
void (*rounder_cb)(struct _lv_disp_drv_t* disp_drv, lv_area_t* area);
|
||||
|
||||
/** OPTIONAL: Extend the invalidated areas to match with the display drivers requirements
|
||||
* E.g. round `y` to, 8, 16 ..) on a monochrome display*/
|
||||
void (*rounder_cb)(struct _lv_disp_drv_t * disp_drv, lv_area_t * area);
|
||||
/** OPTIONAL: Set a pixel in a buffer according to the special requirements of
|
||||
* the display Can be used for color format not supported in LittelvGL. E.g. 2
|
||||
* bit -> 4 gray scales
|
||||
* @note Much slower then drawing with supported color formats.*/
|
||||
void (*set_px_cb)(struct _lv_disp_drv_t* disp_drv, uint8_t* buf,
|
||||
lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
|
||||
lv_color_t color, lv_opa_t opa);
|
||||
|
||||
/** OPTIONAL: Set a pixel in a buffer according to the special requirements of the display
|
||||
* Can be used for color format not supported in LittelvGL. E.g. 2 bit -> 4 gray scales
|
||||
* @note Much slower then drawing with supported color formats.*/
|
||||
void (*set_px_cb)(struct _lv_disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
|
||||
lv_color_t color, lv_opa_t opa);
|
||||
void (*clear_cb)(struct _lv_disp_drv_t* disp_drv, uint8_t* buf,
|
||||
uint32_t size);
|
||||
|
||||
void (*clear_cb)(struct _lv_disp_drv_t * disp_drv, uint8_t * buf, uint32_t size);
|
||||
/** OPTIONAL: Called after every refresh cycle to tell the rendering and
|
||||
* flushing time + the number of flushed pixels*/
|
||||
void (*monitor_cb)(struct _lv_disp_drv_t* disp_drv, uint32_t time,
|
||||
uint32_t px);
|
||||
|
||||
/** OPTIONAL: Called periodically while lvgl waits for operation to be
|
||||
* completed. For example flushing or GPU User can execute very simple tasks
|
||||
* here or yield the task*/
|
||||
void (*wait_cb)(struct _lv_disp_drv_t* disp_drv);
|
||||
|
||||
/** OPTIONAL: Called after every refresh cycle to tell the rendering and flushing time + the
|
||||
* number of flushed pixels*/
|
||||
void (*monitor_cb)(struct _lv_disp_drv_t * disp_drv, uint32_t time, uint32_t px);
|
||||
/** OPTIONAL: Called when lvgl needs any CPU cache that affects rendering to
|
||||
* be cleaned*/
|
||||
void (*clean_dcache_cb)(struct _lv_disp_drv_t* disp_drv);
|
||||
|
||||
/** OPTIONAL: Called periodically while lvgl waits for operation to be completed.
|
||||
* For example flushing or GPU
|
||||
* User can execute very simple tasks here or yield the task*/
|
||||
void (*wait_cb)(struct _lv_disp_drv_t * disp_drv);
|
||||
/** OPTIONAL: called when driver parameters are updated */
|
||||
void (*drv_update_cb)(struct _lv_disp_drv_t* disp_drv);
|
||||
|
||||
/** OPTIONAL: Called when lvgl needs any CPU cache that affects rendering to be cleaned*/
|
||||
void (*clean_dcache_cb)(struct _lv_disp_drv_t * disp_drv);
|
||||
/** On CHROMA_KEYED images this color will be transparent.
|
||||
* `LV_COLOR_CHROMA_KEY` by default. (lv_conf.h)*/
|
||||
lv_color_t color_chroma_key;
|
||||
|
||||
/** OPTIONAL: called when driver parameters are updated */
|
||||
void (*drv_update_cb)(struct _lv_disp_drv_t * disp_drv);
|
||||
|
||||
/** On CHROMA_KEYED images this color will be transparent.
|
||||
* `LV_COLOR_CHROMA_KEY` by default. (lv_conf.h)*/
|
||||
lv_color_t color_chroma_key;
|
||||
|
||||
lv_draw_ctx_t * draw_ctx;
|
||||
void (*draw_ctx_init)(struct _lv_disp_drv_t * disp_drv, lv_draw_ctx_t * draw_ctx);
|
||||
void (*draw_ctx_deinit)(struct _lv_disp_drv_t * disp_drv, lv_draw_ctx_t * draw_ctx);
|
||||
size_t draw_ctx_size;
|
||||
lv_draw_ctx_t* draw_ctx;
|
||||
void (*draw_ctx_init)(struct _lv_disp_drv_t* disp_drv,
|
||||
lv_draw_ctx_t* draw_ctx);
|
||||
void (*draw_ctx_deinit)(struct _lv_disp_drv_t* disp_drv,
|
||||
lv_draw_ctx_t* draw_ctx);
|
||||
size_t draw_ctx_size;
|
||||
|
||||
#if LV_USE_USER_DATA
|
||||
void * user_data; /**< Custom display driver user data*/
|
||||
void* user_data; /**< Custom display driver user data*/
|
||||
#endif
|
||||
|
||||
} lv_disp_drv_t;
|
||||
@@ -153,37 +169,40 @@ typedef struct _lv_disp_drv_t {
|
||||
* @note `lv_disp_drv_t` should be the first member of the structure.
|
||||
*/
|
||||
typedef struct _lv_disp_t {
|
||||
/**< Driver to the display*/
|
||||
struct _lv_disp_drv_t * driver;
|
||||
/**< Driver to the display*/
|
||||
struct _lv_disp_drv_t* driver;
|
||||
|
||||
/**< A timer which periodically checks the dirty areas and refreshes them*/
|
||||
lv_timer_t * refr_timer;
|
||||
/**< A timer which periodically checks the dirty areas and refreshes them*/
|
||||
lv_timer_t* refr_timer;
|
||||
|
||||
/**< The theme assigned to the screen*/
|
||||
struct _lv_theme_t * theme;
|
||||
/**< The theme assigned to the screen*/
|
||||
struct _lv_theme_t* theme;
|
||||
|
||||
/** Screens of the display*/
|
||||
struct _lv_obj_t ** screens; /**< Array of screen objects.*/
|
||||
struct _lv_obj_t * act_scr; /**< Currently active screen on this display*/
|
||||
struct _lv_obj_t * prev_scr; /**< Previous screen. Used during screen animations*/
|
||||
struct _lv_obj_t * scr_to_load; /**< The screen prepared to load in lv_scr_load_anim*/
|
||||
struct _lv_obj_t * top_layer; /**< @see lv_disp_get_layer_top*/
|
||||
struct _lv_obj_t * sys_layer; /**< @see lv_disp_get_layer_sys*/
|
||||
uint32_t screen_cnt;
|
||||
uint8_t del_prev :
|
||||
1; /**< 1: Automatically delete the previous screen when the screen load animation is ready*/
|
||||
/** Screens of the display*/
|
||||
struct _lv_obj_t** screens; /**< Array of screen objects.*/
|
||||
struct _lv_obj_t* act_scr; /**< Currently active screen on this display*/
|
||||
struct _lv_obj_t*
|
||||
prev_scr; /**< Previous screen. Used during screen animations*/
|
||||
struct _lv_obj_t*
|
||||
scr_to_load; /**< The screen prepared to load in lv_scr_load_anim*/
|
||||
struct _lv_obj_t* top_layer; /**< @see lv_disp_get_layer_top*/
|
||||
struct _lv_obj_t* sys_layer; /**< @see lv_disp_get_layer_sys*/
|
||||
uint32_t screen_cnt;
|
||||
uint8_t del_prev : 1; /**< 1: Automatically delete the previous screen when
|
||||
the screen load animation is ready*/
|
||||
|
||||
lv_opa_t bg_opa; /**<Opacity of the background color or wallpaper*/
|
||||
lv_color_t bg_color; /**< Default display color when screens are transparent*/
|
||||
const void * bg_img; /**< An image source to display as wallpaper*/
|
||||
lv_opa_t bg_opa; /**<Opacity of the background color or wallpaper*/
|
||||
lv_color_t bg_color; /**< Default display color when screens are transparent*/
|
||||
const void* bg_img; /**< An image source to display as wallpaper*/
|
||||
|
||||
/** Invalidated (marked to redraw) areas*/
|
||||
lv_area_t inv_areas[LV_INV_BUF_SIZE];
|
||||
uint8_t inv_area_joined[LV_INV_BUF_SIZE];
|
||||
uint16_t inv_p;
|
||||
/** Invalidated (marked to redraw) areas*/
|
||||
lv_area_t inv_areas[LV_INV_BUF_SIZE];
|
||||
uint8_t inv_area_joined[LV_INV_BUF_SIZE];
|
||||
uint16_t inv_p;
|
||||
|
||||
/*Miscellaneous data*/
|
||||
uint32_t last_activity_time; /**< Last time when there was activity on this display*/
|
||||
/*Miscellaneous data*/
|
||||
uint32_t last_activity_time; /**< Last time when there was activity on this
|
||||
display*/
|
||||
} lv_disp_t;
|
||||
|
||||
/**********************
|
||||
@@ -196,162 +215,167 @@ uint8_t del_prev :
|
||||
* After it you can safely set only the fields you need.
|
||||
* @param driver pointer to driver variable to initialize
|
||||
*/
|
||||
void lv_disp_drv_init(lv_disp_drv_t * driver);
|
||||
void lv_disp_drv_init(lv_disp_drv_t* driver);
|
||||
|
||||
/**
|
||||
* Initialize a display buffer
|
||||
* @param draw_buf pointer `lv_disp_draw_buf_t` variable to initialize
|
||||
* @param buf1 A buffer to be used by LVGL to draw the image.
|
||||
* Always has to specified and can't be NULL.
|
||||
* Can be an array allocated by the user. E.g. `static lv_color_t disp_buf1[1024 * 10]`
|
||||
* Or a memory address e.g. in external SRAM
|
||||
* @param buf2 Optionally specify a second buffer to make image rendering and image flushing
|
||||
* (sending to the display) parallel.
|
||||
* In the `disp_drv->flush` you should use DMA or similar hardware to send
|
||||
* the image to the display in the background.
|
||||
* It lets LVGL to render next frame into the other buffer while previous is being
|
||||
* sent. Set to `NULL` if unused.
|
||||
* Can be an array allocated by the user. E.g. `static lv_color_t
|
||||
* disp_buf1[1024 * 10]` Or a memory address e.g. in external SRAM
|
||||
* @param buf2 Optionally specify a second buffer to make image rendering and
|
||||
* image flushing (sending to the display) parallel. In the `disp_drv->flush`
|
||||
* you should use DMA or similar hardware to send the image to the display in
|
||||
* the background. It lets LVGL to render next frame into the other buffer while
|
||||
* previous is being sent. Set to `NULL` if unused.
|
||||
* @param size_in_px_cnt size of the `buf1` and `buf2` in pixel count.
|
||||
*/
|
||||
void lv_disp_draw_buf_init(lv_disp_draw_buf_t * draw_buf, void * buf1, void * buf2, uint32_t size_in_px_cnt);
|
||||
void lv_disp_draw_buf_init(lv_disp_draw_buf_t* draw_buf, void* buf1, void* buf2,
|
||||
uint32_t size_in_px_cnt);
|
||||
|
||||
/**
|
||||
* Register an initialized display driver.
|
||||
* Automatically set the first display as active.
|
||||
* @param driver pointer to an initialized 'lv_disp_drv_t' variable. Only its pointer is saved!
|
||||
* @param driver pointer to an initialized 'lv_disp_drv_t' variable. Only its
|
||||
* pointer is saved!
|
||||
* @return pointer to the new display or NULL on error
|
||||
*/
|
||||
lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver);
|
||||
lv_disp_t* lv_disp_drv_register(lv_disp_drv_t* driver);
|
||||
|
||||
/**
|
||||
* Update the driver in run time.
|
||||
* @param disp pointer to a display. (return value of `lv_disp_drv_register`)
|
||||
* @param new_drv pointer to the new driver
|
||||
*/
|
||||
void lv_disp_drv_update(lv_disp_t * disp, lv_disp_drv_t * new_drv);
|
||||
void lv_disp_drv_update(lv_disp_t* disp, lv_disp_drv_t* new_drv);
|
||||
|
||||
/**
|
||||
* Remove a display
|
||||
* @param disp pointer to display
|
||||
*/
|
||||
void lv_disp_remove(lv_disp_t * disp);
|
||||
void lv_disp_remove(lv_disp_t* disp);
|
||||
|
||||
/**
|
||||
* Set a default display. The new screens will be created on it by default.
|
||||
* @param disp pointer to a display
|
||||
*/
|
||||
void lv_disp_set_default(lv_disp_t * disp);
|
||||
void lv_disp_set_default(lv_disp_t* disp);
|
||||
|
||||
/**
|
||||
* Get the default display
|
||||
* @return pointer to the default display
|
||||
*/
|
||||
lv_disp_t * lv_disp_get_default(void);
|
||||
lv_disp_t* lv_disp_get_default(void);
|
||||
|
||||
/**
|
||||
* Get the horizontal resolution of a display
|
||||
* @param disp pointer to a display (NULL to use the default display)
|
||||
* @return the horizontal resolution of the display
|
||||
*/
|
||||
lv_coord_t lv_disp_get_hor_res(lv_disp_t * disp);
|
||||
lv_coord_t lv_disp_get_hor_res(lv_disp_t* disp);
|
||||
|
||||
/**
|
||||
* Get the vertical resolution of a display
|
||||
* @param disp pointer to a display (NULL to use the default display)
|
||||
* @return the vertical resolution of the display
|
||||
*/
|
||||
lv_coord_t lv_disp_get_ver_res(lv_disp_t * disp);
|
||||
lv_coord_t lv_disp_get_ver_res(lv_disp_t* disp);
|
||||
|
||||
/**
|
||||
* Get the full / physical horizontal resolution of a display
|
||||
* @param disp pointer to a display (NULL to use the default display)
|
||||
* @return the full / physical horizontal resolution of the display
|
||||
*/
|
||||
lv_coord_t lv_disp_get_physical_hor_res(lv_disp_t * disp);
|
||||
lv_coord_t lv_disp_get_physical_hor_res(lv_disp_t* disp);
|
||||
|
||||
/**
|
||||
* Get the full / physical vertical resolution of a display
|
||||
* @param disp pointer to a display (NULL to use the default display)
|
||||
* @return the full / physical vertical resolution of the display
|
||||
*/
|
||||
lv_coord_t lv_disp_get_physical_ver_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);
|
||||
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);
|
||||
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)
|
||||
* @return true: anti-aliasing is enabled; false: disabled
|
||||
*/
|
||||
bool lv_disp_get_antialiasing(lv_disp_t * disp);
|
||||
bool lv_disp_get_antialiasing(lv_disp_t* disp);
|
||||
|
||||
/**
|
||||
* Get the DPI of the display
|
||||
* @param disp pointer to a display (NULL to use the default display)
|
||||
* @return dpi of the display
|
||||
*/
|
||||
lv_coord_t lv_disp_get_dpi(const lv_disp_t * disp);
|
||||
|
||||
lv_coord_t lv_disp_get_dpi(const lv_disp_t* disp);
|
||||
|
||||
/**
|
||||
* Set the rotation of this display.
|
||||
* @param disp pointer to a display (NULL to use the default display)
|
||||
* @param rotation rotation angle
|
||||
*/
|
||||
void lv_disp_set_rotation(lv_disp_t * disp, lv_disp_rot_t rotation);
|
||||
void lv_disp_set_rotation(lv_disp_t* disp, lv_disp_rot_t rotation);
|
||||
|
||||
/**
|
||||
* Get the current rotation of this display.
|
||||
* @param disp pointer to a display (NULL to use the default display)
|
||||
* @return rotation angle
|
||||
*/
|
||||
lv_disp_rot_t lv_disp_get_rotation(lv_disp_t * disp);
|
||||
lv_disp_rot_t lv_disp_get_rotation(lv_disp_t* disp);
|
||||
|
||||
//! @cond Doxygen_Suppress
|
||||
|
||||
/**
|
||||
* Call in the display driver's `flush_cb` function when the flushing is finished
|
||||
* @param disp_drv pointer to display driver in `flush_cb` where this function is called
|
||||
* Call in the display driver's `flush_cb` function when the flushing is
|
||||
* finished
|
||||
* @param disp_drv pointer to display driver in `flush_cb` where this function
|
||||
* is called
|
||||
*/
|
||||
LV_ATTRIBUTE_FLUSH_READY void lv_disp_flush_ready(lv_disp_drv_t * disp_drv);
|
||||
LV_ATTRIBUTE_FLUSH_READY void lv_disp_flush_ready(lv_disp_drv_t* disp_drv);
|
||||
|
||||
/**
|
||||
* Tell if it's the last area of the refreshing process.
|
||||
* Can be called from `flush_cb` to execute some special display refreshing if needed when all areas area flushed.
|
||||
* Can be called from `flush_cb` to execute some special display refreshing if
|
||||
* needed when all areas area flushed.
|
||||
* @param disp_drv pointer to display driver
|
||||
* @return true: it's the last area to flush; false: there are other areas too which will be refreshed soon
|
||||
* @return true: it's the last area to flush; false: there are other areas too
|
||||
* which will be refreshed soon
|
||||
*/
|
||||
LV_ATTRIBUTE_FLUSH_READY bool lv_disp_flush_is_last(lv_disp_drv_t * disp_drv);
|
||||
LV_ATTRIBUTE_FLUSH_READY bool lv_disp_flush_is_last(lv_disp_drv_t* disp_drv);
|
||||
|
||||
//! @endcond
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @return the next display or NULL if no more. Give the first display when the
|
||||
* parameter is NULL
|
||||
*/
|
||||
lv_disp_t * lv_disp_get_next(lv_disp_t * disp);
|
||||
lv_disp_t* lv_disp_get_next(lv_disp_t* disp);
|
||||
|
||||
/**
|
||||
* Get the internal buffer of a display
|
||||
* @param disp pointer to a display
|
||||
* @return pointer to the internal buffers
|
||||
*/
|
||||
lv_disp_draw_buf_t * lv_disp_get_draw_buf(lv_disp_t * disp);
|
||||
lv_disp_draw_buf_t* lv_disp_get_draw_buf(lv_disp_t* disp);
|
||||
|
||||
void lv_disp_drv_use_generic_set_px_cb(lv_disp_drv_t * disp_drv, lv_img_cf_t cf);
|
||||
void lv_disp_drv_use_generic_set_px_cb(lv_disp_drv_t* disp_drv, lv_img_cf_t cf);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* GENERATED FILE, DO NOT EDIT IT!
|
||||
* @file lv_conf_internal.h
|
||||
* Make sure all the defines of lv_conf.h have a default value
|
||||
**/
|
||||
**/
|
||||
|
||||
#ifndef LV_CONF_INTERNAL_H
|
||||
#define LV_CONF_INTERNAL_H
|
||||
@@ -473,7 +473,7 @@
|
||||
*LV_LOG_LEVEL_INFO Log important events
|
||||
*LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem
|
||||
*LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail
|
||||
*LV_LOG_LEVEL_USER Only logs added by the user
|
||||
*LV_LOG_user Only logs added by the user
|
||||
*LV_LOG_LEVEL_NONE Do not log anything*/
|
||||
#ifndef LV_LOG_LEVEL
|
||||
#ifdef CONFIG_LV_LOG_LEVEL
|
||||
|
||||
@@ -13,30 +13,34 @@ extern "C" {
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_conf_internal.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../lv_conf_internal.h"
|
||||
#include "lv_types.h"
|
||||
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/*Possible log level. For compatibility declare it independently from `LV_USE_LOG`*/
|
||||
/*Possible log level. For compatibility declare it independently from
|
||||
* `LV_USE_LOG`*/
|
||||
|
||||
#define LV_LOG_LEVEL_TRACE 0 /**< A lot of logs to give detailed information*/
|
||||
#define LV_LOG_LEVEL_INFO 1 /**< Log important events*/
|
||||
#define LV_LOG_LEVEL_WARN 2 /**< Log if something unwanted happened but didn't caused problem*/
|
||||
#define LV_LOG_LEVEL_ERROR 3 /**< Only critical issue, when the system may fail*/
|
||||
#define LV_LOG_LEVEL_USER 4 /**< Custom logs from the user*/
|
||||
#define LV_LOG_LEVEL_NONE 5 /**< Do not log anything*/
|
||||
#define _LV_LOG_LEVEL_NUM 6 /**< Number of log levels*/
|
||||
#define LV_LOG_LEVEL_INFO 1 /**< Log important events*/
|
||||
#define LV_LOG_LEVEL_WARN \
|
||||
2 /**< Log if something unwanted happened but didn't caused problem*/
|
||||
#define LV_LOG_LEVEL_ERROR \
|
||||
3 /**< Only critical issue, when the system may fail*/
|
||||
#define LV_LOG_user 4 /**< Custom logs from the user*/
|
||||
#define LV_LOG_LEVEL_NONE 5 /**< Do not log anything*/
|
||||
#define _LV_LOG_LEVEL_NUM 6 /**< Number of log levels*/
|
||||
|
||||
LV_EXPORT_CONST_INT(LV_LOG_LEVEL_TRACE);
|
||||
LV_EXPORT_CONST_INT(LV_LOG_LEVEL_INFO);
|
||||
LV_EXPORT_CONST_INT(LV_LOG_LEVEL_WARN);
|
||||
LV_EXPORT_CONST_INT(LV_LOG_LEVEL_ERROR);
|
||||
LV_EXPORT_CONST_INT(LV_LOG_LEVEL_USER);
|
||||
LV_EXPORT_CONST_INT(LV_LOG_user);
|
||||
LV_EXPORT_CONST_INT(LV_LOG_LEVEL_NONE);
|
||||
|
||||
typedef int8_t lv_log_level_t;
|
||||
@@ -49,7 +53,7 @@ typedef int8_t lv_log_level_t;
|
||||
/**
|
||||
* Log print function. Receives a string buffer to print".
|
||||
*/
|
||||
typedef void (*lv_log_print_g_cb_t)(const char * buf);
|
||||
typedef void (*lv_log_print_g_cb_t)(const char* buf);
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
@@ -64,11 +68,12 @@ typedef void (*lv_log_print_g_cb_t)(const char * buf);
|
||||
void lv_log_register_print_cb(lv_log_print_g_cb_t print_cb);
|
||||
|
||||
/**
|
||||
* Print a log message via `printf` if enabled with `LV_LOG_PRINTF` in `lv_conf.h`
|
||||
* and/or a print callback if registered with `lv_log_register_print_cb`
|
||||
* Print a log message via `printf` if enabled with `LV_LOG_PRINTF` in
|
||||
* `lv_conf.h` and/or a print callback if registered with
|
||||
* `lv_log_register_print_cb`
|
||||
* @param buf a string message to print
|
||||
*/
|
||||
void lv_log(const char * buf);
|
||||
void lv_log(const char* buf);
|
||||
|
||||
/**
|
||||
* Add a log
|
||||
@@ -79,61 +84,87 @@ void lv_log(const char * buf);
|
||||
* @param format printf-like format string
|
||||
* @param ... parameters for `format`
|
||||
*/
|
||||
void _lv_log_add(lv_log_level_t level, const char * file, int line,
|
||||
const char * func, const char * format, ...) LV_FORMAT_ATTRIBUTE(5, 6);
|
||||
void _lv_log_add(lv_log_level_t level, const char* file, int line,
|
||||
const char* func, const char* format, ...)
|
||||
LV_FORMAT_ATTRIBUTE(5, 6);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
#ifndef LV_LOG_TRACE
|
||||
# if LV_LOG_LEVEL <= LV_LOG_LEVEL_TRACE
|
||||
# define LV_LOG_TRACE(...) _lv_log_add(LV_LOG_LEVEL_TRACE, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||
# else
|
||||
# define LV_LOG_TRACE(...) do {}while(0)
|
||||
# endif
|
||||
#if LV_LOG_LEVEL <= LV_LOG_LEVEL_TRACE
|
||||
#define LV_LOG_TRACE(...) \
|
||||
_lv_log_add(LV_LOG_LEVEL_TRACE, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||
#else
|
||||
#define LV_LOG_TRACE(...) \
|
||||
do { \
|
||||
} while (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef LV_LOG_INFO
|
||||
# if LV_LOG_LEVEL <= LV_LOG_LEVEL_INFO
|
||||
# define LV_LOG_INFO(...) _lv_log_add(LV_LOG_LEVEL_INFO, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||
# else
|
||||
# define LV_LOG_INFO(...) do {}while(0)
|
||||
# endif
|
||||
#if LV_LOG_LEVEL <= LV_LOG_LEVEL_INFO
|
||||
#define LV_LOG_INFO(...) \
|
||||
_lv_log_add(LV_LOG_LEVEL_INFO, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||
#else
|
||||
#define LV_LOG_INFO(...) \
|
||||
do { \
|
||||
} while (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef LV_LOG_WARN
|
||||
# if LV_LOG_LEVEL <= LV_LOG_LEVEL_WARN
|
||||
# define LV_LOG_WARN(...) _lv_log_add(LV_LOG_LEVEL_WARN, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||
# else
|
||||
# define LV_LOG_WARN(...) do {}while(0)
|
||||
# endif
|
||||
#if LV_LOG_LEVEL <= LV_LOG_LEVEL_WARN
|
||||
#define LV_LOG_WARN(...) \
|
||||
_lv_log_add(LV_LOG_LEVEL_WARN, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||
#else
|
||||
#define LV_LOG_WARN(...) \
|
||||
do { \
|
||||
} while (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef LV_LOG_ERROR
|
||||
# if LV_LOG_LEVEL <= LV_LOG_LEVEL_ERROR
|
||||
# define LV_LOG_ERROR(...) _lv_log_add(LV_LOG_LEVEL_ERROR, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||
# else
|
||||
# define LV_LOG_ERROR(...) do {}while(0)
|
||||
# endif
|
||||
#if LV_LOG_LEVEL <= LV_LOG_LEVEL_ERROR
|
||||
#define LV_LOG_ERROR(...) \
|
||||
_lv_log_add(LV_LOG_LEVEL_ERROR, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||
#else
|
||||
#define LV_LOG_ERROR(...) \
|
||||
do { \
|
||||
} while (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef LV_LOG_USER
|
||||
# if LV_LOG_LEVEL <= LV_LOG_LEVEL_USER
|
||||
# define LV_LOG_USER(...) _lv_log_add(LV_LOG_LEVEL_USER, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||
# else
|
||||
# define LV_LOG_USER(...) do {}while(0)
|
||||
# endif
|
||||
#if LV_LOG_LEVEL <= LV_LOG_user
|
||||
#define LV_LOG_USER(...) \
|
||||
_lv_log_add(LV_LOG_user, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||
#else
|
||||
#define LV_LOG_USER(...) \
|
||||
do { \
|
||||
} while (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#else /*LV_USE_LOG*/
|
||||
|
||||
/*Do nothing if `LV_USE_LOG 0`*/
|
||||
#define _lv_log_add(level, file, line, ...)
|
||||
#define LV_LOG_TRACE(...) do {}while(0)
|
||||
#define LV_LOG_INFO(...) do {}while(0)
|
||||
#define LV_LOG_WARN(...) do {}while(0)
|
||||
#define LV_LOG_ERROR(...) do {}while(0)
|
||||
#define LV_LOG_USER(...) do {}while(0)
|
||||
#define LV_LOG_TRACE(...) \
|
||||
do { \
|
||||
} while (0)
|
||||
#define LV_LOG_INFO(...) \
|
||||
do { \
|
||||
} while (0)
|
||||
#define LV_LOG_WARN(...) \
|
||||
do { \
|
||||
} while (0)
|
||||
#define LV_LOG_ERROR(...) \
|
||||
do { \
|
||||
} while (0)
|
||||
#define LV_LOG_USER(...) \
|
||||
do { \
|
||||
} while (0)
|
||||
#endif /*LV_USE_LOG*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user