initial commit
This commit is contained in:
commit
cff2a21efc
550 files changed
+154887
No files matched your search
@@ -0,0 +1,168 @@
|
||||
/**
|
||||
* @file lv_file_explorer.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_FILE_EXPLORER_H
|
||||
#define LV_FILE_EXPLORER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../../lv_conf_internal.h"
|
||||
#include "../../core/lv_obj.h"
|
||||
|
||||
#if LV_USE_FILE_EXPLORER != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef enum {
|
||||
LV_EXPLORER_SORT_NONE,
|
||||
LV_EXPLORER_SORT_KIND,
|
||||
} lv_file_explorer_sort_t;
|
||||
|
||||
#if LV_FILE_EXPLORER_QUICK_ACCESS
|
||||
typedef enum {
|
||||
LV_EXPLORER_HOME_DIR,
|
||||
LV_EXPLORER_MUSIC_DIR,
|
||||
LV_EXPLORER_PICTURES_DIR,
|
||||
LV_EXPLORER_VIDEO_DIR,
|
||||
LV_EXPLORER_DOCS_DIR,
|
||||
LV_EXPLORER_FS_DIR,
|
||||
} lv_file_explorer_dir_t;
|
||||
#endif
|
||||
|
||||
extern const lv_obj_class_t lv_file_explorer_class;
|
||||
|
||||
/***********************
|
||||
* GLOBAL VARIABLES
|
||||
***********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
lv_obj_t * lv_file_explorer_create(lv_obj_t * parent);
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
#if LV_FILE_EXPLORER_QUICK_ACCESS
|
||||
/**
|
||||
* Set file_explorer
|
||||
* @param obj pointer to a label object
|
||||
* @param dir the dir from 'lv_file_explorer_dir_t' enum.
|
||||
* @param path path
|
||||
|
||||
*/
|
||||
void lv_file_explorer_set_quick_access_path(lv_obj_t * obj, lv_file_explorer_dir_t dir, const char * path);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Set file_explorer sort
|
||||
* @param obj pointer to a file explorer object
|
||||
* @param sort the sort from 'lv_file_explorer_sort_t' enum.
|
||||
*/
|
||||
void lv_file_explorer_set_sort(lv_obj_t * obj, lv_file_explorer_sort_t sort);
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get file explorer Selected file
|
||||
* @param obj pointer to a file explorer object
|
||||
* @return pointer to the file explorer selected file name
|
||||
*/
|
||||
const char * lv_file_explorer_get_selected_file_name(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get file explorer cur path
|
||||
* @param obj pointer to a file explorer object
|
||||
* @return pointer to the file explorer cur path
|
||||
*/
|
||||
const char * lv_file_explorer_get_current_path(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get file explorer head area obj
|
||||
* @param obj pointer to a file explorer object
|
||||
* @return pointer to the file explorer head area obj(lv_obj)
|
||||
*/
|
||||
lv_obj_t * lv_file_explorer_get_header(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get file explorer head area obj
|
||||
* @param obj pointer to a file explorer object
|
||||
* @return pointer to the file explorer quick access area obj(lv_obj)
|
||||
*/
|
||||
lv_obj_t * lv_file_explorer_get_quick_access_area(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get file explorer path obj(label)
|
||||
* @param obj pointer to a file explorer object
|
||||
* @return pointer to the file explorer path obj(lv_label)
|
||||
*/
|
||||
lv_obj_t * lv_file_explorer_get_path_label(lv_obj_t * obj);
|
||||
|
||||
#if LV_FILE_EXPLORER_QUICK_ACCESS
|
||||
/**
|
||||
* Get file explorer places list obj(lv_list)
|
||||
* @param obj pointer to a file explorer object
|
||||
* @return pointer to the file explorer places list obj(lv_list)
|
||||
*/
|
||||
lv_obj_t * lv_file_explorer_get_places_list(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get file explorer device list obj(lv_list)
|
||||
* @param obj pointer to a file explorer object
|
||||
* @return pointer to the file explorer device list obj(lv_list)
|
||||
*/
|
||||
lv_obj_t * lv_file_explorer_get_device_list(lv_obj_t * obj);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Get file explorer file list obj(lv_table)
|
||||
* @param obj pointer to a file explorer object
|
||||
* @return pointer to the file explorer file table obj(lv_table)
|
||||
*/
|
||||
lv_obj_t * lv_file_explorer_get_file_table(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Set file_explorer sort
|
||||
* @param obj pointer to a file explorer object
|
||||
* @return the current mode from 'lv_file_explorer_sort_t'
|
||||
*/
|
||||
lv_file_explorer_sort_t lv_file_explorer_get_sort(const lv_obj_t * obj);
|
||||
|
||||
/*=====================
|
||||
* Other functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Open a specified path
|
||||
* @param obj pointer to a file explorer object
|
||||
* @param dir pointer to the path
|
||||
*/
|
||||
void lv_file_explorer_open_dir(lv_obj_t * obj, const char * dir);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_FILE_EXPLORER*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_FILE_EXPLORER_H*/
|
||||
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* @file lv_file_explorer_private.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_FILE_EXPLORER_PRIVATE_H
|
||||
#define LV_FILE_EXPLORER_PRIVATE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "../../core/lv_obj_private.h"
|
||||
#include "lv_file_explorer.h"
|
||||
|
||||
#if LV_USE_FILE_EXPLORER != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Data of canvas*/
|
||||
struct _lv_file_explorer_t {
|
||||
lv_obj_t obj;
|
||||
lv_obj_t * cont;
|
||||
lv_obj_t * head_area;
|
||||
lv_obj_t * browser_area;
|
||||
lv_obj_t * file_table;
|
||||
lv_obj_t * path_label;
|
||||
#if LV_FILE_EXPLORER_QUICK_ACCESS
|
||||
lv_obj_t * quick_access_area;
|
||||
lv_obj_t * list_device;
|
||||
lv_obj_t * list_places;
|
||||
char * home_dir;
|
||||
char * music_dir;
|
||||
char * pictures_dir;
|
||||
char * video_dir;
|
||||
char * docs_dir;
|
||||
char * fs_dir;
|
||||
#endif
|
||||
const char * sel_fn;
|
||||
char current_path[LV_FILE_EXPLORER_PATH_MAX_LEN];
|
||||
lv_file_explorer_sort_t sort;
|
||||
};
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /* LV_USE_FILE_EXPLORER != 0 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_FILE_EXPLORER_PRIVATE_H*/
|
||||
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* @file lv_font_manager.h
|
||||
*
|
||||
*/
|
||||
#ifndef LV_FONT_MANAGER_H
|
||||
#define LV_FONT_MANAGER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "../../misc/lv_types.h"
|
||||
|
||||
#if LV_USE_FONT_MANAGER
|
||||
|
||||
#if !LV_USE_FREETYPE
|
||||
#error "LV_USE_FONT_MANAGER requires LV_USE_FREETYPE"
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef struct _lv_font_manager_t lv_font_manager_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create main font manager.
|
||||
* @param recycle_cache_size number of fonts that were recently deleted from the cache.
|
||||
* @return pointer to main font manager.
|
||||
*/
|
||||
lv_font_manager_t * lv_font_manager_create(uint32_t recycle_cache_size);
|
||||
|
||||
/**
|
||||
* Delete main font manager.
|
||||
* @param manager pointer to main font manager.
|
||||
* @return return true if the deletion was successful.
|
||||
*/
|
||||
bool lv_font_manager_delete(lv_font_manager_t * manager);
|
||||
|
||||
/**
|
||||
* Add the font file path.
|
||||
* @param manager pointer to main font manager.
|
||||
* @param name font name.
|
||||
* @param path font file path.
|
||||
*/
|
||||
void lv_font_manager_add_path(lv_font_manager_t * manager, const char * name, const char * path);
|
||||
|
||||
/**
|
||||
* Add the font file path with static memory.
|
||||
* @param manager pointer to main font manager.
|
||||
* @param name font name.
|
||||
* @param path font file path.
|
||||
*/
|
||||
void lv_font_manager_add_path_static(lv_font_manager_t * manager, const char * name, const char * path);
|
||||
|
||||
/**
|
||||
* Remove the font file path.
|
||||
* @param manager pointer to main font manager.
|
||||
* @param name font name.
|
||||
* @return return true if the remove was successful.
|
||||
*/
|
||||
bool lv_font_manager_remove_path(lv_font_manager_t * manager, const char * name);
|
||||
|
||||
/**
|
||||
* Create font.
|
||||
* @param manager pointer to main font manager.
|
||||
* @param font_family font family name.
|
||||
* @param render_mode font render mode, see lv_freetype_font_render_mode_t.
|
||||
* @param size font size.
|
||||
* @param style font style, see lv_freetype_font_style_t.
|
||||
* @return point to the created font
|
||||
*/
|
||||
lv_font_t * lv_font_manager_create_font(lv_font_manager_t * manager, const char * font_family, uint16_t render_mode,
|
||||
uint32_t size, uint16_t style);
|
||||
|
||||
/**
|
||||
* Delete font.
|
||||
* @param manager pointer to main font manager.
|
||||
* @param font point to the font.
|
||||
* @return return true if the deletion was successful.
|
||||
*/
|
||||
void lv_font_manager_delete_font(lv_font_manager_t * manager, lv_font_t * font);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /* LV_USE_FONT_MANAGER */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* FONT_MANAGER_MANAGER_H */
|
||||
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* @file lv_font_manager_recycle.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_FONT_MANAGER_RECYCLE_H
|
||||
#define LV_FONT_MANAGER_RECYCLE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lv_font_manager_utils.h"
|
||||
|
||||
#if LV_USE_FONT_MANAGER
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef struct _lv_font_manager_recycle_t lv_font_manager_recycle_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create font recycle manager.
|
||||
* @param max_size recycle size.
|
||||
* @return pointer to font recycle manager.
|
||||
*/
|
||||
lv_font_manager_recycle_t * lv_font_manager_recycle_create(uint32_t max_size);
|
||||
|
||||
/**
|
||||
* Delete font recycle manager.
|
||||
* @param manager pointer to font recycle manager.
|
||||
*/
|
||||
void lv_font_manager_recycle_delete(lv_font_manager_recycle_t * manager);
|
||||
|
||||
/**
|
||||
* Get a reusable font.
|
||||
* @param manager pointer to font recycle manager.
|
||||
* @param ft_info font info.
|
||||
* @return returns true on success.
|
||||
*/
|
||||
lv_font_t * lv_font_manager_recycle_get_reuse(lv_font_manager_recycle_t * manager, const lv_freetype_info_t * ft_info);
|
||||
|
||||
/**
|
||||
* Set fonts to be reused.
|
||||
* @param manager pointer to font recycle manager.
|
||||
* @param ft_info font info.
|
||||
*/
|
||||
void lv_font_manager_recycle_set_reuse(lv_font_manager_recycle_t * manager, lv_font_t * font,
|
||||
const lv_freetype_info_t * ft_info);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /* LV_USE_FONT_MANAGER */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /* LV_FONT_MANAGER_RECYCLE_H */
|
||||
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* @file lv_font_manager_utils.h
|
||||
*
|
||||
*/
|
||||
#ifndef LV_FONT_MANAGER_UTILS_H
|
||||
#define LV_FONT_MANAGER_UTILS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "../../misc/lv_types.h"
|
||||
|
||||
#if LV_USE_FONT_MANAGER
|
||||
|
||||
#include "../../libs/freetype/lv_freetype.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef struct {
|
||||
const char * name;
|
||||
lv_freetype_font_render_mode_t render_mode;
|
||||
lv_freetype_font_style_t style;
|
||||
uint32_t size;
|
||||
} lv_freetype_info_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Compare font information.
|
||||
* @param ft_info_1 font information 1.
|
||||
* @param ft_info_2 font information 2.
|
||||
* @return return true if the fonts are equal.
|
||||
*/
|
||||
bool lv_freetype_info_is_equal(const lv_freetype_info_t * ft_info_1, const lv_freetype_info_t * ft_info_2);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_FONT_MANAGER*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /* LV_FONT_MANAGER_UTILS_H */
|
||||
Whitespace-only changes.
@@ -0,0 +1,297 @@
|
||||
/**
|
||||
* Public header for Fragment
|
||||
* @file lv_fragment.h
|
||||
*/
|
||||
|
||||
#ifndef LV_FRAGMENT_H
|
||||
#define LV_FRAGMENT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../../core/lv_obj.h"
|
||||
|
||||
#if LV_USE_FRAGMENT
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef struct _lv_fragment_manager_t lv_fragment_manager_t;
|
||||
|
||||
struct _lv_fragment_t {
|
||||
/**
|
||||
* Class of this fragment
|
||||
*/
|
||||
const lv_fragment_class_t * cls;
|
||||
/**
|
||||
* Managed fragment states. If not null, then this fragment is managed.
|
||||
*
|
||||
* @warning Don't modify values inside this struct!
|
||||
*/
|
||||
lv_fragment_managed_states_t * managed;
|
||||
/**
|
||||
* Child fragment manager
|
||||
*/
|
||||
lv_fragment_manager_t * child_manager;
|
||||
/**
|
||||
* lv_obj returned by create_obj_cb
|
||||
*/
|
||||
lv_obj_t * obj;
|
||||
|
||||
};
|
||||
|
||||
struct _lv_fragment_class_t {
|
||||
/**
|
||||
* Constructor function for fragment class
|
||||
* @param self Fragment instance
|
||||
* @param args Arguments assigned by fragment manager
|
||||
*/
|
||||
void (*constructor_cb)(lv_fragment_t * self, void * args);
|
||||
|
||||
/**
|
||||
* Destructor function for fragment class
|
||||
* @param self Fragment instance, will be freed after this call
|
||||
*/
|
||||
void (*destructor_cb)(lv_fragment_t * self);
|
||||
|
||||
/**
|
||||
* Fragment attached to manager
|
||||
* @param self Fragment instance
|
||||
*/
|
||||
void (*attached_cb)(lv_fragment_t * self);
|
||||
|
||||
/**
|
||||
* Fragment detached from manager
|
||||
* @param self Fragment instance
|
||||
*/
|
||||
void (*detached_cb)(lv_fragment_t * self);
|
||||
|
||||
/**
|
||||
* Create objects
|
||||
* @param self Fragment instance
|
||||
* @param container Container of the objects should be created upon
|
||||
* @return Created object, NULL if multiple objects has been created
|
||||
*/
|
||||
lv_obj_t * (*create_obj_cb)(lv_fragment_t * self, lv_obj_t * container);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param self Fragment instance
|
||||
* @param obj lv_obj returned by create_obj_cb
|
||||
*/
|
||||
void (*obj_created_cb)(lv_fragment_t * self, lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Called before objects in the fragment will be deleted.
|
||||
*
|
||||
* @param self Fragment instance
|
||||
* @param obj object with this fragment
|
||||
*/
|
||||
void (*obj_will_delete_cb)(lv_fragment_t * self, lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Called when the object created by fragment received `LV_EVENT_DELETE` event
|
||||
* @param self Fragment instance
|
||||
* @param obj object with this fragment
|
||||
*/
|
||||
void (*obj_deleted_cb)(lv_fragment_t * self, lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Handle event
|
||||
* @param self Fragment instance
|
||||
* @param which User-defined ID of event
|
||||
* @param data1 User-defined data
|
||||
* @param data2 User-defined data
|
||||
*/
|
||||
bool (*event_cb)(lv_fragment_t * self, int code, void * userdata);
|
||||
|
||||
/**
|
||||
* *REQUIRED*: Allocation size of fragment
|
||||
*/
|
||||
size_t instance_size;
|
||||
};
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create fragment manager instance
|
||||
* @param parent Parent fragment if this manager is placed inside another fragment, can be null.
|
||||
* @return Fragment manager instance
|
||||
*/
|
||||
lv_fragment_manager_t * lv_fragment_manager_create(lv_fragment_t * parent);
|
||||
|
||||
/**
|
||||
* Destroy fragment manager instance
|
||||
* @param manager Fragment manager instance
|
||||
*/
|
||||
void lv_fragment_manager_delete(lv_fragment_manager_t * manager);
|
||||
|
||||
/**
|
||||
* Create object of all fragments managed by this manager.
|
||||
* @param manager Fragment manager instance
|
||||
*/
|
||||
void lv_fragment_manager_create_obj(lv_fragment_manager_t * manager);
|
||||
|
||||
/**
|
||||
* Delete object created by all fragments managed by this manager. Instance of fragments will not be deleted.
|
||||
* @param manager Fragment manager instance
|
||||
*/
|
||||
void lv_fragment_manager_delete_obj(lv_fragment_manager_t * manager);
|
||||
|
||||
/**
|
||||
* Attach fragment to manager, and add to container.
|
||||
* @param manager Fragment manager instance
|
||||
* @param fragment Fragment instance
|
||||
* @param container Pointer to container object for manager to add objects to
|
||||
*/
|
||||
void lv_fragment_manager_add(lv_fragment_manager_t * manager, lv_fragment_t * fragment, lv_obj_t * const * container);
|
||||
|
||||
/**
|
||||
* Detach and destroy fragment. If fragment is in navigation stack, remove from it.
|
||||
* @param manager Fragment manager instance
|
||||
* @param fragment Fragment instance
|
||||
*/
|
||||
void lv_fragment_manager_remove(lv_fragment_manager_t * manager, lv_fragment_t * fragment);
|
||||
|
||||
/**
|
||||
* Attach fragment to manager and add to navigation stack.
|
||||
* @param manager Fragment manager instance
|
||||
* @param fragment Fragment instance
|
||||
* @param container Pointer to container object for manager to add objects to
|
||||
*/
|
||||
void lv_fragment_manager_push(lv_fragment_manager_t * manager, lv_fragment_t * fragment, lv_obj_t * const * container);
|
||||
|
||||
/**
|
||||
* Remove the top-most fragment for stack
|
||||
* @param manager Fragment manager instance
|
||||
* @return true if there is fragment to pop
|
||||
*/
|
||||
bool lv_fragment_manager_pop(lv_fragment_manager_t * manager);
|
||||
|
||||
/**
|
||||
* Replace fragment. Old item in the stack will be removed.
|
||||
* @param manager Fragment manager instance
|
||||
* @param fragment Fragment instance
|
||||
* @param container Pointer to container object for manager to add objects to
|
||||
*/
|
||||
void lv_fragment_manager_replace(lv_fragment_manager_t * manager, lv_fragment_t * fragment,
|
||||
lv_obj_t * const * container);
|
||||
|
||||
/**
|
||||
* Send event to top-most fragment
|
||||
* @param manager Fragment manager instance
|
||||
* @param code User-defined ID of event
|
||||
* @param userdata User-defined data
|
||||
* @return true if fragment returned true
|
||||
*/
|
||||
bool lv_fragment_manager_send_event(lv_fragment_manager_t * manager, int code, void * userdata);
|
||||
|
||||
/**
|
||||
* Get stack size of this fragment manager
|
||||
* @param manager Fragment manager instance
|
||||
* @return Stack size of this fragment manager
|
||||
*/
|
||||
size_t lv_fragment_manager_get_stack_size(lv_fragment_manager_t * manager);
|
||||
|
||||
/**
|
||||
* Get top most fragment instance
|
||||
* @param manager Fragment manager instance
|
||||
* @return Top most fragment instance
|
||||
*/
|
||||
lv_fragment_t * lv_fragment_manager_get_top(lv_fragment_manager_t * manager);
|
||||
|
||||
/**
|
||||
* Find first fragment instance in the container
|
||||
* @param manager Fragment manager instance
|
||||
* @param container Container which target fragment added to
|
||||
* @return First fragment instance in the container
|
||||
*/
|
||||
lv_fragment_t * lv_fragment_manager_find_by_container(lv_fragment_manager_t * manager, const lv_obj_t * container);
|
||||
|
||||
/**
|
||||
* Get parent fragment
|
||||
* @param manager Fragment manager instance
|
||||
* @return Parent fragment instance
|
||||
*/
|
||||
lv_fragment_t * lv_fragment_manager_get_parent_fragment(lv_fragment_manager_t * manager);
|
||||
|
||||
/**
|
||||
* Create a fragment instance.
|
||||
*
|
||||
* @param cls Fragment class. This fragment must return non null object.
|
||||
* @param args Arguments assigned by fragment manager
|
||||
* @return Fragment instance
|
||||
*/
|
||||
lv_fragment_t * lv_fragment_create(const lv_fragment_class_t * cls, void * args);
|
||||
|
||||
/**
|
||||
* Destroy a fragment.
|
||||
* @param fragment Fragment instance.
|
||||
*/
|
||||
void lv_fragment_delete(lv_fragment_t * fragment);
|
||||
|
||||
/**
|
||||
* Get associated manager of this fragment
|
||||
* @param fragment Fragment instance
|
||||
* @return Fragment manager instance
|
||||
*/
|
||||
lv_fragment_manager_t * lv_fragment_get_manager(lv_fragment_t * fragment);
|
||||
|
||||
/**
|
||||
* Get container object of this fragment
|
||||
* @param fragment Fragment instance
|
||||
* @return Reference to container object
|
||||
*/
|
||||
lv_obj_t * const * lv_fragment_get_container(lv_fragment_t * fragment);
|
||||
|
||||
/**
|
||||
* Get parent fragment of this fragment
|
||||
* @param fragment Fragment instance
|
||||
* @return Parent fragment
|
||||
*/
|
||||
lv_fragment_t * lv_fragment_get_parent(lv_fragment_t * fragment);
|
||||
|
||||
/**
|
||||
* Create object by fragment.
|
||||
*
|
||||
* @param fragment Fragment instance.
|
||||
* @param container Container of the objects should be created upon.
|
||||
* @return Created object
|
||||
*/
|
||||
lv_obj_t * lv_fragment_create_obj(lv_fragment_t * fragment, lv_obj_t * container);
|
||||
|
||||
/**
|
||||
* Delete created object of a fragment
|
||||
*
|
||||
* @param fragment Fragment instance.
|
||||
*/
|
||||
void lv_fragment_delete_obj(lv_fragment_t * fragment);
|
||||
|
||||
/**
|
||||
* Destroy obj in fragment, and recreate them.
|
||||
* @param fragment Fragment instance
|
||||
*/
|
||||
void lv_fragment_recreate_obj(lv_fragment_t * fragment);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_FRAGMENT*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_FRAGMENT_H*/
|
||||
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* @file lv_fragment_private.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_FRAGMENT_PRIVATE_H
|
||||
#define LV_FRAGMENT_PRIVATE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lv_fragment.h"
|
||||
|
||||
#if LV_USE_FRAGMENT
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Fragment states
|
||||
*/
|
||||
struct _lv_fragment_managed_states_t {
|
||||
/**
|
||||
* Class of the fragment
|
||||
*/
|
||||
const lv_fragment_class_t * cls;
|
||||
/**
|
||||
* Manager the fragment attached to
|
||||
*/
|
||||
lv_fragment_manager_t * manager;
|
||||
/**
|
||||
* Container object the fragment adding view to
|
||||
*/
|
||||
lv_obj_t * const * container;
|
||||
/**
|
||||
* Fragment instance
|
||||
*/
|
||||
lv_fragment_t * instance;
|
||||
/**
|
||||
* true between `create_obj_cb` and `obj_deleted_cb`
|
||||
*/
|
||||
bool obj_created;
|
||||
/**
|
||||
* true before `lv_fragment_delete_obj` is called. Don't touch any object if this is true
|
||||
*/
|
||||
bool destroying_obj;
|
||||
/**
|
||||
* true if this fragment is in navigation stack that can be popped
|
||||
*/
|
||||
bool in_stack;
|
||||
};
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /* LV_USE_FRAGMENT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_FRAGMENT_PRIVATE_H*/
|
||||
@@ -0,0 +1,95 @@
|
||||
/**
|
||||
* @file lv_gridnav.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_GRIDNAV_H
|
||||
#define LV_GRIDNAV_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../../core/lv_obj.h"
|
||||
|
||||
#if LV_USE_GRIDNAV
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef enum {
|
||||
LV_GRIDNAV_CTRL_NONE = 0x0,
|
||||
|
||||
/**
|
||||
* If there is no next/previous object in a direction,
|
||||
* the focus goes to the object in the next/previous row (on left/right keys)
|
||||
* or first/last row (on up/down keys)
|
||||
*/
|
||||
LV_GRIDNAV_CTRL_ROLLOVER = 0x1,
|
||||
|
||||
/**
|
||||
* If an arrow is pressed and the focused object can be scrolled in that direction
|
||||
* then it will be scrolled instead of going to the next/previous object.
|
||||
* If there is no more room for scrolling the next/previous object will be focused normally */
|
||||
LV_GRIDNAV_CTRL_SCROLL_FIRST = 0x2,
|
||||
|
||||
/**
|
||||
* Only use left/right keys for grid navigation. Up/down key events will be sent to the
|
||||
* focused object.
|
||||
*/
|
||||
LV_GRIDNAV_CTRL_HORIZONTAL_MOVE_ONLY = 0x4,
|
||||
|
||||
/**
|
||||
* Only use up/down keys for grid navigation. Left/right key events will be sent to the
|
||||
* focused object.
|
||||
*/
|
||||
LV_GRIDNAV_CTRL_VERTICAL_MOVE_ONLY = 0x8
|
||||
|
||||
} lv_gridnav_ctrl_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Add grid navigation feature to an object. It expects the children to be arranged
|
||||
* into a grid-like layout. Although it's not required to have pixel perfect alignment.
|
||||
* This feature makes possible to use keys to navigate among the children and focus them.
|
||||
* The keys other than arrows and press/release related events
|
||||
* are forwarded to the focused child.
|
||||
* @param obj pointer to an object on which navigation should be applied.
|
||||
* @param ctrl control flags from `lv_gridnav_ctrl_t`.
|
||||
*/
|
||||
void lv_gridnav_add(lv_obj_t * obj, lv_gridnav_ctrl_t ctrl);
|
||||
|
||||
/**
|
||||
* Remove the grid navigation support from an object
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_gridnav_remove(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Manually focus an object on gridnav container
|
||||
* @param cont pointer to a gridnav container
|
||||
* @param to_focus pointer to an object to focus
|
||||
* @param anim_en LV_ANIM_ON/OFF
|
||||
*/
|
||||
void lv_gridnav_set_focused(lv_obj_t * cont, lv_obj_t * to_focus, lv_anim_enable_t anim_en);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
#endif /*LV_USE_GRIDNAV*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /* LV_GRIDNAV_H */
|
||||
@@ -0,0 +1,121 @@
|
||||
/**
|
||||
* @file lv_ime_pinyin.h
|
||||
*
|
||||
*/
|
||||
#ifndef LV_IME_PINYIN_H
|
||||
#define LV_IME_PINYIN_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../../lv_conf_internal.h"
|
||||
#include "../../core/lv_obj.h"
|
||||
|
||||
#if LV_USE_IME_PINYIN != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_IME_PINYIN_K9_MAX_INPUT 7
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef enum {
|
||||
LV_IME_PINYIN_MODE_K26,
|
||||
LV_IME_PINYIN_MODE_K9,
|
||||
LV_IME_PINYIN_MODE_K9_NUMBER,
|
||||
} lv_ime_pinyin_mode_t;
|
||||
|
||||
/*Data of pinyin_dict*/
|
||||
typedef struct {
|
||||
const char * const py;
|
||||
const char * const py_mb;
|
||||
} lv_pinyin_dict_t;
|
||||
|
||||
/*Data of 9-key input(k9) mode*/
|
||||
typedef struct {
|
||||
char py_str[7];
|
||||
} ime_pinyin_k9_py_str_t;
|
||||
|
||||
/***********************
|
||||
* GLOBAL VARIABLES
|
||||
***********************/
|
||||
|
||||
extern const lv_obj_class_t lv_ime_pinyin_class;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
lv_obj_t * lv_ime_pinyin_create(lv_obj_t * parent);
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set the keyboard of Pinyin input method.
|
||||
* @param obj pointer to a Pinyin input method object
|
||||
* @param kb pointer to a Pinyin input method keyboard
|
||||
*/
|
||||
void lv_ime_pinyin_set_keyboard(lv_obj_t * obj, lv_obj_t * kb);
|
||||
|
||||
/**
|
||||
* Set the dictionary of Pinyin input method.
|
||||
* @param obj pointer to a Pinyin input method object
|
||||
* @param dict pointer to a Pinyin input method dictionary
|
||||
*/
|
||||
void lv_ime_pinyin_set_dict(lv_obj_t * obj, lv_pinyin_dict_t * dict);
|
||||
|
||||
/**
|
||||
* Set mode, 26-key input(k26) or 9-key input(k9).
|
||||
* @param obj pointer to a Pinyin input method object
|
||||
* @param mode the mode from 'lv_ime_pinyin_mode_t'
|
||||
*/
|
||||
void lv_ime_pinyin_set_mode(lv_obj_t * obj, lv_ime_pinyin_mode_t mode);
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set the dictionary of Pinyin input method.
|
||||
* @param obj pointer to a Pinyin IME object
|
||||
* @return pointer to the Pinyin IME keyboard
|
||||
*/
|
||||
lv_obj_t * lv_ime_pinyin_get_kb(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Set the dictionary of Pinyin input method.
|
||||
* @param obj pointer to a Pinyin input method object
|
||||
* @return pointer to the Pinyin input method candidate panel
|
||||
*/
|
||||
lv_obj_t * lv_ime_pinyin_get_cand_panel(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Set the dictionary of Pinyin input method.
|
||||
* @param obj pointer to a Pinyin input method object
|
||||
* @return pointer to the Pinyin input method dictionary
|
||||
*/
|
||||
const lv_pinyin_dict_t * lv_ime_pinyin_get_dict(lv_obj_t * obj);
|
||||
|
||||
/*=====================
|
||||
* Other functions
|
||||
*====================*/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_IME_PINYIN*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_USE_IME_PINYIN*/
|
||||
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* @file lv_ime_pinyin_private.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_IME_PINYIN_PRIVATE_H
|
||||
#define LV_IME_PINYIN_PRIVATE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "../../core/lv_obj_private.h"
|
||||
#include "lv_ime_pinyin.h"
|
||||
|
||||
#if LV_USE_IME_PINYIN != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Data of lv_ime_pinyin*/
|
||||
struct _lv_ime_pinyin_t {
|
||||
lv_obj_t obj;
|
||||
lv_obj_t * kb;
|
||||
lv_obj_t * cand_panel;
|
||||
const lv_pinyin_dict_t * dict;
|
||||
lv_ll_t k9_legal_py_ll;
|
||||
char * cand_str; /* Candidate string */
|
||||
char input_char[16]; /* Input box character */
|
||||
#if LV_IME_PINYIN_USE_K9_MODE
|
||||
char k9_input_str[LV_IME_PINYIN_K9_MAX_INPUT + 1]; /* 9-key input(k9) mode input string */
|
||||
uint16_t k9_py_ll_pos; /* Current pinyin map pages(k9) */
|
||||
uint16_t k9_legal_py_count; /* Count of legal Pinyin numbers(k9) */
|
||||
uint16_t k9_input_str_len; /* 9-key input(k9) mode input string max len */
|
||||
#endif
|
||||
uint16_t ta_count; /* The number of characters entered in the text box this time */
|
||||
uint16_t cand_num; /* Number of candidates */
|
||||
uint16_t py_page; /* Current pinyin map pages(k26) */
|
||||
uint16_t py_num[26]; /* Number and length of Pinyin */
|
||||
uint16_t py_pos[26]; /* Pinyin position */
|
||||
lv_ime_pinyin_mode_t mode; /* Set mode, 1: 26-key input(k26), 0: 9-key input(k9). Default: 1. */
|
||||
};
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /* LV_USE_IME_PINYIN != 0 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_IME_PINYIN_PRIVATE_H*/
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* @file lv_imgfont.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_IMGFONT_H
|
||||
#define LV_IMGFONT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../../lv_conf_internal.h"
|
||||
#include "../../font/lv_font.h"
|
||||
|
||||
#if LV_USE_IMGFONT
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/* gets the image path name of this character */
|
||||
typedef const void * (*lv_imgfont_get_path_cb_t)(const lv_font_t * font,
|
||||
uint32_t unicode, uint32_t unicode_next,
|
||||
int32_t * offset_y, void * user_data);
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Creates a image font with info parameter specified.
|
||||
* @param height font size
|
||||
* @param path_cb a function to get the image path name of character.
|
||||
* @param user_data pointer to user data
|
||||
* @return pointer to the new imgfont or NULL if create error.
|
||||
*/
|
||||
lv_font_t * lv_imgfont_create(uint16_t height, lv_imgfont_get_path_cb_t path_cb, void * user_data);
|
||||
|
||||
/**
|
||||
* Destroy a image font that has been created.
|
||||
* @param font pointer to image font handle.
|
||||
*/
|
||||
void lv_imgfont_destroy(lv_font_t * font);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_IMGFONT*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /* LV_IMGFONT_H */
|
||||
@@ -0,0 +1,117 @@
|
||||
/**
|
||||
* @file lv_monkey.h
|
||||
*
|
||||
*/
|
||||
#ifndef LV_MONKEY_H
|
||||
#define LV_MONKEY_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../../lv_conf_internal.h"
|
||||
#include "../../indev/lv_indev.h"
|
||||
|
||||
#if LV_USE_MONKEY != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef struct _lv_monkey_t lv_monkey_t;
|
||||
|
||||
struct _lv_monkey_config_t {
|
||||
/**< Input device type*/
|
||||
lv_indev_type_t type;
|
||||
|
||||
/**< Monkey execution period*/
|
||||
struct {
|
||||
//! @cond Doxygen_Suppress
|
||||
uint32_t min;
|
||||
uint32_t max;
|
||||
//! @endcond
|
||||
} period_range;
|
||||
|
||||
/**< The range of input value*/
|
||||
struct {
|
||||
int32_t min;
|
||||
int32_t max;
|
||||
} input_range;
|
||||
};
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize a monkey config with default values
|
||||
* @param config pointer to 'lv_monkey_config_t' variable to initialize
|
||||
*/
|
||||
void lv_monkey_config_init(lv_monkey_config_t * config);
|
||||
|
||||
/**
|
||||
* Create monkey for test
|
||||
* @param config pointer to 'lv_monkey_config_t' variable
|
||||
* @return pointer to the created monkey
|
||||
*/
|
||||
lv_monkey_t * lv_monkey_create(const lv_monkey_config_t * config);
|
||||
|
||||
/**
|
||||
* Get monkey input device
|
||||
* @param monkey pointer to a monkey
|
||||
* @return pointer to the input device
|
||||
*/
|
||||
lv_indev_t * lv_monkey_get_indev(lv_monkey_t * monkey);
|
||||
|
||||
/**
|
||||
* Enable monkey
|
||||
* @param monkey pointer to a monkey
|
||||
* @param en set to true to enable
|
||||
*/
|
||||
void lv_monkey_set_enable(lv_monkey_t * monkey, bool en);
|
||||
|
||||
/**
|
||||
* Get whether monkey is enabled
|
||||
* @param monkey pointer to a monkey
|
||||
* @return return true if monkey enabled
|
||||
*/
|
||||
bool lv_monkey_get_enable(lv_monkey_t * monkey);
|
||||
|
||||
/**
|
||||
* Set the user_data field of the monkey
|
||||
* @param monkey pointer to a monkey
|
||||
* @param user_data pointer to the new user_data.
|
||||
*/
|
||||
void lv_monkey_set_user_data(lv_monkey_t * monkey, void * user_data);
|
||||
|
||||
/**
|
||||
* Get the user_data field of the monkey
|
||||
* @param monkey pointer to a monkey
|
||||
* @return the pointer to the user_data of the monkey
|
||||
*/
|
||||
void * lv_monkey_get_user_data(lv_monkey_t * monkey);
|
||||
|
||||
/**
|
||||
* Delete monkey
|
||||
* @param monkey pointer to monkey
|
||||
*/
|
||||
void lv_monkey_delete(lv_monkey_t * monkey);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_MONKEY*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_MONKEY_H*/
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* @file lv_monkey_private.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_MONKEY_PRIVATE_H
|
||||
#define LV_MONKEY_PRIVATE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lv_monkey.h"
|
||||
|
||||
#if LV_USE_MONKEY != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /* LV_USE_MONKEY != 0 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_MONKEY_PRIVATE_H*/
|
||||
@@ -0,0 +1,406 @@
|
||||
/**
|
||||
* @file lv_observer.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_OBSERVER_H
|
||||
#define LV_OBSERVER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "../../core/lv_obj.h"
|
||||
#if LV_USE_OBSERVER
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Values for lv_submect_t's `type` field.
|
||||
*/
|
||||
typedef enum {
|
||||
LV_SUBJECT_TYPE_INVALID = 0, /**< indicates subject not initialized yet*/
|
||||
LV_SUBJECT_TYPE_NONE = 1, /**< a null value like None or NILt*/
|
||||
LV_SUBJECT_TYPE_INT = 2, /**< an int32_t*/
|
||||
LV_SUBJECT_TYPE_POINTER = 3, /**< a void pointer*/
|
||||
LV_SUBJECT_TYPE_COLOR = 4, /**< an lv_color_t*/
|
||||
LV_SUBJECT_TYPE_GROUP = 5, /**< an array of subjects*/
|
||||
LV_SUBJECT_TYPE_STRING = 6, /**< a char pointer*/
|
||||
} lv_subject_type_t;
|
||||
|
||||
/**
|
||||
* A common type to handle all the various observable types in the same way
|
||||
*/
|
||||
typedef union {
|
||||
int32_t num; /**< Integer number (opacity, enums, booleans or "normal" numbers)*/
|
||||
const void * pointer; /**< Constant pointer (string buffer, format string, font, cone text, etc)*/
|
||||
lv_color_t color; /**< Color */
|
||||
} lv_subject_value_t;
|
||||
|
||||
/**
|
||||
* The subject (an observable value)
|
||||
*/
|
||||
typedef struct {
|
||||
lv_ll_t subs_ll; /**< Subscribers*/
|
||||
uint32_t type : 4;
|
||||
uint32_t size : 28; /**< Might be used to store a size related to `type`*/
|
||||
lv_subject_value_t value; /**< Actual value*/
|
||||
lv_subject_value_t prev_value; /**< Previous value*/
|
||||
uint32_t notify_restart_query : 1; /**< If an observer deleted start notifying from the beginning. */
|
||||
void * user_data; /**< Additional parameter, can be used freely by the user*/
|
||||
} lv_subject_t;
|
||||
|
||||
/**
|
||||
* Callback called when the observed value changes
|
||||
* @param observer pointer to the observer of the callback
|
||||
* @param subject pointer to the subject of the observer
|
||||
*/
|
||||
typedef void (*lv_observer_cb_t)(lv_observer_t * observer, lv_subject_t * subject);
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize an integer type subject
|
||||
* @param subject pointer to the subject
|
||||
* @param value initial value
|
||||
*/
|
||||
void lv_subject_init_int(lv_subject_t * subject, int32_t value);
|
||||
|
||||
/**
|
||||
* Set the value of an integer subject. It will notify all the observers as well.
|
||||
* @param subject pointer to the subject
|
||||
* @param value the new value
|
||||
*/
|
||||
void lv_subject_set_int(lv_subject_t * subject, int32_t value);
|
||||
|
||||
/**
|
||||
* Get the current value of an integer subject
|
||||
* @param subject pointer to the subject
|
||||
* @return the current value
|
||||
*/
|
||||
int32_t lv_subject_get_int(lv_subject_t * subject);
|
||||
|
||||
/**
|
||||
* Get the previous value of an integer subject
|
||||
* @param subject pointer to the subject
|
||||
* @return the current value
|
||||
*/
|
||||
int32_t lv_subject_get_previous_int(lv_subject_t * subject);
|
||||
|
||||
/**
|
||||
* Initialize a string type subject
|
||||
* @param subject pointer to the subject
|
||||
* @param buf pointer to a buffer to store the string
|
||||
* @param prev_buf pointer to a buffer to store the previous string, can be NULL if not used
|
||||
* @param size size of the buffer
|
||||
* @param value initial value as a string, e.g. "hello"
|
||||
* @note the string subject stores the whole string, not only a pointer
|
||||
*/
|
||||
void lv_subject_init_string(lv_subject_t * subject, char * buf, char * prev_buf, size_t size, const char * value);
|
||||
|
||||
/**
|
||||
* Copy a string to a subject. It will notify all the observers as well.
|
||||
* @param subject pointer to the subject
|
||||
* @param buf the new string
|
||||
*/
|
||||
void lv_subject_copy_string(lv_subject_t * subject, const char * buf);
|
||||
|
||||
/**
|
||||
* Get the current value of an string subject
|
||||
* @param subject pointer to the subject
|
||||
* @return pointer to the buffer containing the current value
|
||||
*/
|
||||
const char * lv_subject_get_string(lv_subject_t * subject);
|
||||
|
||||
/**
|
||||
* Get the previous value of an string subject
|
||||
* @param subject pointer to the subject
|
||||
* @return pointer to the buffer containing the current value
|
||||
* @note NULL will be returned if NULL was passed in `lv_subject_init_string()`
|
||||
* as `prev_buf`
|
||||
*/
|
||||
const char * lv_subject_get_previous_string(lv_subject_t * subject);
|
||||
|
||||
/**
|
||||
* Initialize an pointer type subject
|
||||
* @param subject pointer to the subject
|
||||
* @param value initial value
|
||||
*/
|
||||
void lv_subject_init_pointer(lv_subject_t * subject, void * value);
|
||||
|
||||
/**
|
||||
* Set the value of a pointer subject. It will notify all the observers as well.
|
||||
* @param subject pointer to the subject
|
||||
* @param ptr new value
|
||||
*/
|
||||
void lv_subject_set_pointer(lv_subject_t * subject, void * ptr);
|
||||
|
||||
/**
|
||||
* Get the current value of a pointer subject
|
||||
* @param subject pointer to the subject
|
||||
* @return current value
|
||||
*/
|
||||
const void * lv_subject_get_pointer(lv_subject_t * subject);
|
||||
|
||||
/**
|
||||
* Get the previous value of a pointer subject
|
||||
* @param subject pointer to the subject
|
||||
* @return current value
|
||||
*/
|
||||
const void * lv_subject_get_previous_pointer(lv_subject_t * subject);
|
||||
|
||||
/**
|
||||
* Initialize an color type subject
|
||||
* @param subject pointer to the subject
|
||||
* @param color initial value
|
||||
*/
|
||||
void lv_subject_init_color(lv_subject_t * subject, lv_color_t color);
|
||||
|
||||
/**
|
||||
* Set the value of a color subject. It will notify all the observers as well.
|
||||
* @param subject pointer to the subject
|
||||
* @param color new value
|
||||
*/
|
||||
void lv_subject_set_color(lv_subject_t * subject, lv_color_t color);
|
||||
|
||||
/**
|
||||
* Get the current value of a color subject
|
||||
* @param subject pointer to the subject
|
||||
* @return current value
|
||||
*/
|
||||
lv_color_t lv_subject_get_color(lv_subject_t * subject);
|
||||
|
||||
/**
|
||||
* Get the previous value of a color subject
|
||||
* @param subject pointer to the subject
|
||||
* @return current value
|
||||
*/
|
||||
lv_color_t lv_subject_get_previous_color(lv_subject_t * subject);
|
||||
|
||||
/**
|
||||
* Initialize a subject group
|
||||
* @param subject pointer to the subject
|
||||
* @param list list of other subject addresses, any of these changes `subject` will be notified
|
||||
* @param list_len number of elements in `list`
|
||||
*/
|
||||
void lv_subject_init_group(lv_subject_t * subject, lv_subject_t * list[], uint32_t list_len);
|
||||
|
||||
/**
|
||||
* Remove all the observers from a subject and free all allocated memories in it
|
||||
* @param subject pointer to the subject
|
||||
* @note objects added with `lv_subject_add_observer_obj` should be already deleted or
|
||||
* removed manually.
|
||||
*/
|
||||
void lv_subject_deinit(lv_subject_t * subject);
|
||||
|
||||
/**
|
||||
* Get an element from the subject group's list
|
||||
* @param subject pointer to the subject
|
||||
* @param index index of the element to get
|
||||
* @return pointer a subject from the list, or NULL if the index is out of bounds
|
||||
*/
|
||||
lv_subject_t * lv_subject_get_group_element(lv_subject_t * subject, int32_t index);
|
||||
|
||||
/**
|
||||
* Add an observer to a subject. When the subject changes `observer_cb` will be called.
|
||||
* @param subject pointer to the subject
|
||||
* @param observer_cb callback to call
|
||||
* @param user_data optional user data
|
||||
* @return pointer to the created observer
|
||||
*/
|
||||
lv_observer_t * lv_subject_add_observer(lv_subject_t * subject, lv_observer_cb_t observer_cb, void * user_data);
|
||||
|
||||
/**
|
||||
* Add an observer to a subject for an object.
|
||||
* When the object is deleted, it will be removed from the subject automatically.
|
||||
* @param subject pointer to the subject
|
||||
* @param observer_cb callback to call
|
||||
* @param obj pointer to an object
|
||||
* @param user_data optional user data
|
||||
* @return pointer to the created observer
|
||||
*/
|
||||
lv_observer_t * lv_subject_add_observer_obj(lv_subject_t * subject, lv_observer_cb_t observer_cb, lv_obj_t * obj,
|
||||
void * user_data);
|
||||
|
||||
/**
|
||||
* Add an observer to a subject and also save a target.
|
||||
* @param subject pointer to the subject
|
||||
* @param observer_cb callback to call
|
||||
* @param target pointer to any data
|
||||
* @param user_data optional user data
|
||||
* @return pointer to the created observer
|
||||
*/
|
||||
lv_observer_t * lv_subject_add_observer_with_target(lv_subject_t * subject, lv_observer_cb_t observer_cb,
|
||||
void * target, void * user_data);
|
||||
|
||||
/**
|
||||
* Remove an observer from its subject
|
||||
* @param observer pointer to an observer
|
||||
*/
|
||||
void lv_observer_remove(lv_observer_t * observer);
|
||||
|
||||
/**
|
||||
* Remove the observers of an object from a subject or all subjects
|
||||
* @param obj the object whose observers should be removed
|
||||
* @param subject the subject to remove the object from, or `NULL` to remove from all subjects
|
||||
* @note This function can be used e.g. when an object's subject(s) needs to be replaced by other subject(s)
|
||||
*/
|
||||
void lv_obj_remove_from_subject(lv_obj_t * obj, lv_subject_t * subject);
|
||||
|
||||
/**
|
||||
* Get the target of an observer
|
||||
* @param observer pointer to an observer
|
||||
* @return pointer to the saved target
|
||||
*/
|
||||
void * lv_observer_get_target(lv_observer_t * observer);
|
||||
|
||||
/**
|
||||
* Get the target object of the observer.
|
||||
* It's the same as `lv_observer_get_target` and added only
|
||||
* for semantic reasons
|
||||
* @param observer pointer to an observer
|
||||
* @return pointer to the saved object target
|
||||
*/
|
||||
lv_obj_t * lv_observer_get_target_obj(lv_observer_t * observer);
|
||||
|
||||
/**
|
||||
* Get the user data of the observer.
|
||||
* @param observer pointer to an observer
|
||||
* @return void pointer to the saved user data
|
||||
*/
|
||||
void * lv_observer_get_user_data(const lv_observer_t * observer);
|
||||
|
||||
/**
|
||||
* Notify all observers of subject
|
||||
* @param subject pointer to a subject
|
||||
*/
|
||||
void lv_subject_notify(lv_subject_t * subject);
|
||||
|
||||
/**
|
||||
* Set an object flag if an integer subject's value is equal to a reference value, clear the flag otherwise
|
||||
* @param obj pointer to an object
|
||||
* @param subject pointer to a subject
|
||||
* @param flag flag to set or clear (e.g. `LV_OBJ_FLAG_HIDDEN`)
|
||||
* @param ref_value reference value to compare the subject's value with
|
||||
* @return pointer to the created observer
|
||||
*/
|
||||
lv_observer_t * lv_obj_bind_flag_if_eq(lv_obj_t * obj, lv_subject_t * subject, lv_obj_flag_t flag, int32_t ref_value);
|
||||
|
||||
/**
|
||||
* Set an object flag if an integer subject's value is not equal to a reference value, clear the flag otherwise
|
||||
* @param obj pointer to an object
|
||||
* @param subject pointer to a subject
|
||||
* @param flag flag to set or clear (e.g. `LV_OBJ_FLAG_HIDDEN`)
|
||||
* @param ref_value reference value to compare the subject's value with
|
||||
* @return pointer to the created observer
|
||||
*/
|
||||
lv_observer_t * lv_obj_bind_flag_if_not_eq(lv_obj_t * obj, lv_subject_t * subject, lv_obj_flag_t flag,
|
||||
int32_t ref_value);
|
||||
|
||||
/**
|
||||
* Set an object state if an integer subject's value is equal to a reference value, clear the flag otherwise
|
||||
* @param obj pointer to an object
|
||||
* @param subject pointer to a subject
|
||||
* @param state state to set or clear (e.g. `LV_STATE_CHECKED`)
|
||||
* @param ref_value reference value to compare the subject's value with
|
||||
* @return pointer to the created observer
|
||||
*/
|
||||
lv_observer_t * lv_obj_bind_state_if_eq(lv_obj_t * obj, lv_subject_t * subject, lv_state_t state, int32_t ref_value);
|
||||
|
||||
/**
|
||||
* Set an object state if an integer subject's value is not equal to a reference value, clear the flag otherwise
|
||||
* @param obj pointer to an object
|
||||
* @param subject pointer to a subject
|
||||
* @param state state to set or clear (e.g. `LV_STATE_CHECKED`)
|
||||
* @param ref_value reference value to compare the subject's value with
|
||||
* @return pointer to the created observer
|
||||
*/
|
||||
lv_observer_t * lv_obj_bind_state_if_not_eq(lv_obj_t * obj, lv_subject_t * subject, lv_state_t state,
|
||||
int32_t ref_value);
|
||||
|
||||
/**
|
||||
* Set an integer subject to 1 when an object is checked and set it 0 when unchecked.
|
||||
* @param obj pointer to an object
|
||||
* @param subject pointer to a subject
|
||||
* @return pointer to the created observer
|
||||
* @note Ensure the object's `LV_OBJ_FLAG_CHECKABLE` flag is set
|
||||
*/
|
||||
lv_observer_t * lv_obj_bind_checked(lv_obj_t * obj, lv_subject_t * subject);
|
||||
|
||||
#if LV_USE_LABEL
|
||||
/**
|
||||
* Bind an integer, string, or pointer subject to a label.
|
||||
* @param obj pointer to a label
|
||||
* @param subject pointer to a subject
|
||||
* @param fmt optional format string with 1 format specifier (e.g. "%d °C")
|
||||
* or NULL to bind the value directly.
|
||||
* @return pointer to the created observer
|
||||
* @note fmt == NULL can be used only with string and pointer subjects.
|
||||
* @note if the subject is a pointer must point to a `\0` terminated string.
|
||||
*/
|
||||
lv_observer_t * lv_label_bind_text(lv_obj_t * obj, lv_subject_t * subject, const char * fmt);
|
||||
#endif
|
||||
|
||||
#if LV_USE_ARC
|
||||
/**
|
||||
* Bind an integer subject to an arc's value
|
||||
* @param obj pointer to an arc
|
||||
* @param subject pointer to a subject
|
||||
* @return pointer to the created observer
|
||||
*/
|
||||
lv_observer_t * lv_arc_bind_value(lv_obj_t * obj, lv_subject_t * subject);
|
||||
#endif
|
||||
|
||||
#if LV_USE_SLIDER
|
||||
/**
|
||||
* Bind an integer subject to a slider's value
|
||||
* @param obj pointer to a slider
|
||||
* @param subject pointer to a subject
|
||||
* @return pointer to the created observer
|
||||
*/
|
||||
lv_observer_t * lv_slider_bind_value(lv_obj_t * obj, lv_subject_t * subject);
|
||||
#endif
|
||||
|
||||
#if LV_USE_ROLLER
|
||||
/**
|
||||
* Bind an integer subject to a roller's value
|
||||
* @param obj pointer to a roller
|
||||
* @param subject pointer to a subject
|
||||
* @return pointer to the created observer
|
||||
*/
|
||||
lv_observer_t * lv_roller_bind_value(lv_obj_t * obj, lv_subject_t * subject);
|
||||
#endif
|
||||
|
||||
#if LV_USE_DROPDOWN
|
||||
/**
|
||||
* Bind an integer subject to a dropdown's value
|
||||
* @param obj pointer to a drop down
|
||||
* @param subject pointer to a subject
|
||||
* @return pointer to the created observer
|
||||
*/
|
||||
lv_observer_t * lv_dropdown_bind_value(lv_obj_t * obj, lv_subject_t * subject);
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_OBSERVER*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_OBSERVER_H*/
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* @file lv_observer_private.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_OBSERVER_PRIVATE_H
|
||||
#define LV_OBSERVER_PRIVATE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lv_observer.h"
|
||||
|
||||
#if LV_USE_OBSERVER
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* The observer object: a descriptor returned when subscribing LVGL widgets to subjects
|
||||
*/
|
||||
struct _lv_observer_t {
|
||||
lv_subject_t * subject; /**< The observed value */
|
||||
lv_observer_cb_t cb; /**< Callback that should be called when the value changes*/
|
||||
void * target; /**< A target for the observer, e.g. a widget or style*/
|
||||
void * user_data; /**< Additional parameter supplied when subscribing*/
|
||||
uint32_t auto_free_user_data : 1; /**< Automatically free user data when the observer is removed */
|
||||
uint32_t notified : 1; /**< Mark if this observer was already notified*/
|
||||
uint32_t for_obj : 1; /**< `target` is an `lv_obj_t *`*/
|
||||
};
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /* LV_USE_OBSERVER */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_OBSERVER_PRIVATE_H*/
|
||||
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* @file lv_snapshot.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_SNAPSHOT_H
|
||||
#define LV_SNAPSHOT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../../core/lv_obj.h"
|
||||
|
||||
#if LV_USE_SNAPSHOT
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Take snapshot for object with its children, create the draw buffer as needed.
|
||||
* @param obj the object to generate snapshot.
|
||||
* @param cf color format for generated image.
|
||||
* @return a pointer to an draw buffer containing snapshot image, or NULL if failed.
|
||||
*/
|
||||
lv_draw_buf_t * lv_snapshot_take(lv_obj_t * obj, lv_color_format_t cf);
|
||||
|
||||
/**
|
||||
* Create a draw buffer to store the snapshot image for object.
|
||||
* @param obj the object to generate snapshot.
|
||||
* @param cf color format for generated image.
|
||||
* @return a pointer to an draw buffer ready for taking snapshot, or NULL if failed.
|
||||
*/
|
||||
lv_draw_buf_t * lv_snapshot_create_draw_buf(lv_obj_t * obj, lv_color_format_t cf);
|
||||
|
||||
/**
|
||||
* Reshape the draw buffer to prepare for taking snapshot for obj.
|
||||
* This is usually used to check if the existing draw buffer is enough for
|
||||
* obj snapshot. If return LV_RESULT_INVALID, you should create a new one.
|
||||
* @param draw_buf the draw buffer to reshape.
|
||||
* @param obj the object to generate snapshot.
|
||||
*/
|
||||
lv_result_t lv_snapshot_reshape_draw_buf(lv_obj_t * obj, lv_draw_buf_t * draw_buf);
|
||||
|
||||
/**
|
||||
* Take snapshot for object with its children, save image info to provided buffer.
|
||||
* @param obj the object to generate snapshot.
|
||||
* @param cf color format for new snapshot image.
|
||||
* It could differ with cf of `draw_buf` as long as the new cf will fit in.
|
||||
* @param draw_buf the draw buffer to store the image result. It's reshaped automatically.
|
||||
* @return LV_RESULT_OK on success, LV_RESULT_INVALID on error.
|
||||
*/
|
||||
lv_result_t lv_snapshot_take_to_draw_buf(lv_obj_t * obj, lv_color_format_t cf, lv_draw_buf_t * draw_buf);
|
||||
|
||||
/**
|
||||
* @deprecated Use `lv_draw_buf_destroy` instead.
|
||||
*
|
||||
* Free the snapshot image returned by @ref lv_snapshot_take
|
||||
* @param dsc the image descriptor generated by lv_snapshot_take.
|
||||
*/
|
||||
void lv_snapshot_free(lv_image_dsc_t * dsc);
|
||||
|
||||
/**
|
||||
* Take snapshot for object with its children, save image info to provided buffer.
|
||||
* @param obj the object to generate snapshot.
|
||||
* @param cf color format for generated image.
|
||||
* @param dsc image descriptor to store the image result.
|
||||
* @param buf the buffer to store image data. It must meet align requirement.
|
||||
* @param buf_size provided buffer size in bytes.
|
||||
* @return LV_RESULT_OK on success, LV_RESULT_INVALID on error.
|
||||
* @deprecated Use lv_snapshot_take_to_draw_buf instead.
|
||||
*/
|
||||
lv_result_t lv_snapshot_take_to_buf(lv_obj_t * obj, lv_color_format_t cf, lv_image_dsc_t * dsc,
|
||||
void * buf,
|
||||
uint32_t buf_size);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
#endif /*LV_USE_SNAPSHOT*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
* @file lv_sysmon.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_SYSMON_H
|
||||
#define LV_SYSMON_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "../../misc/lv_timer.h"
|
||||
#include "../../others/observer/lv_observer.h"
|
||||
|
||||
#if LV_USE_SYSMON
|
||||
|
||||
#if LV_USE_LABEL == 0
|
||||
#error "lv_sysmon: lv_label is required. Enable it in lv_conf.h (LV_USE_LABEL 1) "
|
||||
#endif
|
||||
|
||||
#if LV_USE_OBSERVER == 0
|
||||
#error "lv_observer: lv_observer is required. Enable it in lv_conf.h (LV_USE_OBSERVER 1) "
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a new system monitor label
|
||||
* @param disp create the sys. mon. on this display's system layer
|
||||
* @return the create label
|
||||
*/
|
||||
lv_obj_t * lv_sysmon_create(lv_display_t * disp);
|
||||
|
||||
#if LV_USE_PERF_MONITOR
|
||||
|
||||
/**
|
||||
* Show system performance monitor: CPU usage and FPS count
|
||||
* @param disp target display, NULL: use the default displays
|
||||
*/
|
||||
void lv_sysmon_show_performance(lv_display_t * disp);
|
||||
|
||||
/**
|
||||
* Hide system performance monitor
|
||||
* @param disp target display, NULL: use the default
|
||||
*/
|
||||
void lv_sysmon_hide_performance(lv_display_t * disp);
|
||||
|
||||
#endif /*LV_USE_PERF_MONITOR*/
|
||||
|
||||
#if LV_USE_MEM_MONITOR
|
||||
|
||||
/**
|
||||
* Show system memory monitor: used memory and the memory fragmentation
|
||||
* @param disp target display, NULL: use the default displays
|
||||
*/
|
||||
void lv_sysmon_show_memory(lv_display_t * disp);
|
||||
|
||||
/**
|
||||
* Hide system memory monitor
|
||||
* @param disp target display, NULL: use the default displays
|
||||
*/
|
||||
void lv_sysmon_hide_memory(lv_display_t * disp);
|
||||
|
||||
#endif /*LV_USE_MEM_MONITOR*/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_SYSMON*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_SYSMON_H*/
|
||||
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
* @file lv_sysmon_private.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_SYSMON_PRIVATE_H
|
||||
#define LV_SYSMON_PRIVATE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lv_sysmon.h"
|
||||
|
||||
#if LV_USE_SYSMON
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
struct _lv_sysmon_backend_data_t {
|
||||
lv_subject_t subject;
|
||||
lv_timer_t * timer;
|
||||
};
|
||||
|
||||
#if LV_USE_PERF_MONITOR
|
||||
struct _lv_sysmon_perf_info_t {
|
||||
struct {
|
||||
bool inited;
|
||||
uint32_t refr_start;
|
||||
uint32_t refr_interval_sum;
|
||||
uint32_t refr_elaps_sum;
|
||||
uint32_t refr_cnt;
|
||||
uint32_t render_start;
|
||||
uint32_t render_elaps_sum; /*Contains the flush time too*/
|
||||
uint32_t render_cnt;
|
||||
uint32_t flush_in_render_start;
|
||||
uint32_t flush_in_render_elaps_sum;
|
||||
uint32_t flush_not_in_render_start;
|
||||
uint32_t flush_not_in_render_elaps_sum;
|
||||
uint32_t last_report_timestamp;
|
||||
uint32_t render_in_progress : 1;
|
||||
} measured;
|
||||
|
||||
struct {
|
||||
uint32_t fps;
|
||||
uint32_t cpu;
|
||||
uint32_t refr_avg_time;
|
||||
uint32_t render_avg_time; /**< Pure rendering time without flush time*/
|
||||
uint32_t flush_avg_time; /**< Pure flushing time without rendering time*/
|
||||
uint32_t cpu_avg_total;
|
||||
uint32_t fps_avg_total;
|
||||
uint32_t run_cnt;
|
||||
} calculated;
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize built-in system monitor, such as performance and memory monitor.
|
||||
*/
|
||||
void lv_sysmon_builtin_init(void);
|
||||
|
||||
/**
|
||||
* DeInitialize built-in system monitor, such as performance and memory monitor.
|
||||
*/
|
||||
void lv_sysmon_builtin_deinit(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /* LV_USE_SYSMON */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_SYSMON_PRIVATE_H*/
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user