initial commit
This commit is contained in:
commit
cff2a21efc
550 files changed
+154887
No files matched your search
+237
@@ -0,0 +1,237 @@
|
||||
/**
|
||||
* @file lv_cache.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_CACHE_H
|
||||
#define LV_CACHE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_cache_entry.h"
|
||||
#include "lv_cache_private.h"
|
||||
#include "../lv_types.h"
|
||||
|
||||
#include "lv_cache_lru_rb.h"
|
||||
|
||||
#include "lv_image_cache.h"
|
||||
#include "lv_image_header_cache.h"
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a cache object with the given parameters.
|
||||
* @param cache_class The class of the cache. Currently only support one two builtin classes:
|
||||
* - lv_cache_class_lru_rb_count for LRU-based cache with count-based eviction policy.
|
||||
* - lv_cache_class_lru_rb_size for LRU-based cache with size-based eviction policy.
|
||||
* @param node_size The node size is the size of the data stored in the cache..
|
||||
* @param max_size The max size is the maximum amount of memory or count that the cache can hold.
|
||||
* - lv_cache_class_lru_rb_count: max_size is the maximum count of nodes in the cache.
|
||||
* - lv_cache_class_lru_rb_size: max_size is the maximum size of the cache in bytes.
|
||||
* @param ops A set of operations that can be performed on the cache. See lv_cache_ops_t for details.
|
||||
* @return Returns a pointer to the created cache object on success, `NULL` on error.
|
||||
*/
|
||||
lv_cache_t * lv_cache_create(const lv_cache_class_t * cache_class,
|
||||
size_t node_size, size_t max_size,
|
||||
lv_cache_ops_t ops);
|
||||
|
||||
/**
|
||||
* Destroy a cache object.
|
||||
* @param cache The cache object pointer to destroy.
|
||||
* @param user_data A user data pointer that will be passed to the free callback.
|
||||
*/
|
||||
void lv_cache_destroy(lv_cache_t * cache, void * user_data);
|
||||
|
||||
/**
|
||||
* Acquire a cache entry with the given key. If entry not in cache, it will return `NULL` (not found).
|
||||
* If the entry is found, it's priority will be changed by the cache's policy. And the `lv_cache_entry_t::ref_cnt` will be incremented.
|
||||
* @param cache The cache object pointer to acquire the entry.
|
||||
* @param key The key of the entry to acquire.
|
||||
* @param user_data A user data pointer that will be passed to the create callback.
|
||||
* @return Returns a pointer to the acquired cache entry on success with `lv_cache_entry_t::ref_cnt` incremented, `NULL` on error.
|
||||
*/
|
||||
lv_cache_entry_t * lv_cache_acquire(lv_cache_t * cache, const void * key, void * user_data);
|
||||
|
||||
/**
|
||||
* Acquire a cache entry with the given key. If the entry is not in the cache, it will create a new entry with the given key.
|
||||
* If the entry is found, it's priority will be changed by the cache's policy. And the `lv_cache_entry_t::ref_cnt` will be incremented.
|
||||
* If you want to use this API to simplify the code, you should provide a `lv_cache_ops_t::create_cb` that creates a new entry with the given key.
|
||||
* This API is a combination of lv_cache_acquire() and lv_cache_add(). The effect is the same as calling lv_cache_acquire() and lv_cache_add() separately.
|
||||
* And the internal impact on cache is also consistent with these two APIs.
|
||||
* @param cache The cache object pointer to acquire the entry.
|
||||
* @param key The key of the entry to acquire or create.
|
||||
* @param user_data A user data pointer that will be passed to the create callback.
|
||||
* @return Returns a pointer to the acquired or created cache entry on success with `lv_cache_entry_t::ref_cnt` incremented, `NULL` on error.
|
||||
*/
|
||||
lv_cache_entry_t * lv_cache_acquire_or_create(lv_cache_t * cache, const void * key, void * user_data);
|
||||
|
||||
/**
|
||||
* Add a new cache entry with the given key and data. If the cache is full, the cache's policy will be used to evict an entry.
|
||||
* @param cache The cache object pointer to add the entry.
|
||||
* @param key The key of the entry to add.
|
||||
* @param user_data A user data pointer that will be passed to the create callback.
|
||||
* @return Returns a pointer to the added cache entry on success with `lv_cache_entry_t::ref_cnt` incremented, `NULL` on error.
|
||||
*/
|
||||
lv_cache_entry_t * lv_cache_add(lv_cache_t * cache, const void * key, void * user_data);
|
||||
|
||||
/**
|
||||
* Release a cache entry. The `lv_cache_entry_t::ref_cnt` will be decremented. If the `lv_cache_entry_t::ref_cnt` is zero, it will issue an error.
|
||||
* If the entry passed to this function is the last reference to the data and the entry is marked as invalid, the cache's policy will be used to evict the entry.
|
||||
* @param cache The cache object pointer to release the entry.
|
||||
* @param entry The cache entry pointer to release.
|
||||
* @param user_data A user data pointer that will be passed to the free callback.
|
||||
*/
|
||||
void lv_cache_release(lv_cache_t * cache, lv_cache_entry_t * entry, void * user_data);
|
||||
|
||||
/**
|
||||
* Reserve a certain amount of memory/count in the cache. This function is useful when you want to reserve a certain amount of memory/count in advance,
|
||||
* for example, when you know that you will need it later.
|
||||
* When the current cache size is max than the reserved size, the function will evict entries until the reserved size is reached.
|
||||
* @param cache The cache object pointer to reserve.
|
||||
* @param reserved_size The amount of memory/count to reserve.
|
||||
* @param user_data A user data pointer that will be passed to the free callback.
|
||||
*/
|
||||
void lv_cache_reserve(lv_cache_t * cache, uint32_t reserved_size, void * user_data);
|
||||
|
||||
/**
|
||||
* Drop a cache entry with the given key. If the entry is not in the cache, nothing will happen to it.
|
||||
* If the entry is found, it will be removed from the cache and its data will be freed when the last reference to it is released.
|
||||
* @note The data will not be freed immediately but when the last reference to it is released. But this entry will not be found by lv_cache_acquire().
|
||||
* If you want cache a same key again, you should use lv_cache_add() or lv_cache_acquire_or_create().
|
||||
* @param cache The cache object pointer to drop the entry.
|
||||
* @param key The key of the entry to drop.
|
||||
* @param user_data A user data pointer that will be passed to the free callback.
|
||||
*/
|
||||
void lv_cache_drop(lv_cache_t * cache, const void * key, void * user_data);
|
||||
|
||||
/**
|
||||
* Drop all cache entries. All entries will be removed from the cache and their data will be freed when the last reference to them is released.
|
||||
* @note If some entries are still referenced by other objects, it will issue an error. And this case shouldn't happen in normal cases..
|
||||
* @param cache The cache object pointer to drop all entries.
|
||||
* @param user_data A user data pointer that will be passed to the free callback.
|
||||
*/
|
||||
void lv_cache_drop_all(lv_cache_t * cache, void * user_data);
|
||||
|
||||
/**
|
||||
* Evict one entry from the cache. The eviction policy will be used to select the entry to evict.
|
||||
* @param cache The cache object pointer to evict an entry.
|
||||
* @param user_data A user data pointer that will be passed to the free callback.
|
||||
* @return Returns true if an entry is evicted, false if no entry is evicted.
|
||||
*/
|
||||
bool lv_cache_evict_one(lv_cache_t * cache, void * user_data);
|
||||
|
||||
/**
|
||||
* Set the maximum size of the cache.
|
||||
* If the current cache size is greater than the new maximum size, the cache's policy will be used to evict entries until the new maximum size is reached.
|
||||
* If set to 0, the cache will be disabled.
|
||||
* @note But this behavior will happen only new entries are added to the cache.
|
||||
* @param cache The cache object pointer to set the maximum size.
|
||||
* @param max_size The new maximum size of the cache.
|
||||
* @param user_data A user data pointer that will be passed to the free callback.
|
||||
*/
|
||||
void lv_cache_set_max_size(lv_cache_t * cache, size_t max_size, void * user_data);
|
||||
|
||||
/**
|
||||
* Get the maximum size of the cache.
|
||||
* @param cache The cache object pointer to get the maximum size.
|
||||
* @param user_data A user data pointer that will be passed to the free callback.
|
||||
* @return Returns the maximum size of the cache.
|
||||
*/
|
||||
size_t lv_cache_get_max_size(lv_cache_t * cache, void * user_data);
|
||||
|
||||
/**
|
||||
* Get the current size of the cache.
|
||||
* @param cache The cache object pointer to get the current size.
|
||||
* @param user_data A user data pointer that will be passed to the free callback.
|
||||
* @return Returns the current size of the cache.
|
||||
*/
|
||||
size_t lv_cache_get_size(lv_cache_t * cache, void * user_data);
|
||||
|
||||
/**
|
||||
* Get the free size of the cache.
|
||||
* @param cache The cache object pointer to get the free size.
|
||||
* @param user_data A user data pointer that will be passed to the free callback.
|
||||
* @return Returns the free size of the cache.
|
||||
*/
|
||||
size_t lv_cache_get_free_size(lv_cache_t * cache, void * user_data);
|
||||
|
||||
/**
|
||||
* Return true if the cache is enabled.
|
||||
* Disabled cache means that when the max_size of the cache is 0. In this case, all cache operations will be no-op.
|
||||
* @param cache The cache object pointer to check if it's disabled.
|
||||
* @return Returns true if the cache is enabled, false otherwise.
|
||||
*/
|
||||
bool lv_cache_is_enabled(lv_cache_t * cache);
|
||||
|
||||
/**
|
||||
* Set the compare callback of the cache.
|
||||
* @param cache The cache object pointer to set the compare callback.
|
||||
* @param compare_cb The compare callback to set.
|
||||
* @param user_data A user data pointer.
|
||||
*/
|
||||
void lv_cache_set_compare_cb(lv_cache_t * cache, lv_cache_compare_cb_t compare_cb, void * user_data);
|
||||
|
||||
/**
|
||||
* Set the create callback of the cache.
|
||||
* @param cache The cache object pointer to set the create callback.
|
||||
* @param alloc_cb The create callback to set.
|
||||
* @param user_data A user data pointer.
|
||||
*/
|
||||
void lv_cache_set_create_cb(lv_cache_t * cache, lv_cache_create_cb_t alloc_cb, void * user_data);
|
||||
|
||||
/**
|
||||
* Set the free callback of the cache.
|
||||
* @param cache The cache object pointer to set the free callback.
|
||||
* @param free_cb The free callback to set.
|
||||
* @param user_data A user data pointer.
|
||||
*/
|
||||
void lv_cache_set_free_cb(lv_cache_t * cache, lv_cache_free_cb_t free_cb, void * user_data);
|
||||
|
||||
/**
|
||||
* Give a name for a cache object. Only the pointer of the string is saved.
|
||||
* @param cache The cache object pointer to set the name.
|
||||
* @param name The name of the cache.
|
||||
*/
|
||||
void lv_cache_set_name(lv_cache_t * cache, const char * name);
|
||||
|
||||
/**
|
||||
* Get the name of a cache object.
|
||||
* @param cache The cache object pointer to get the name.
|
||||
* @return Returns the name of the cache.
|
||||
*/
|
||||
const char * lv_cache_get_name(lv_cache_t * cache);
|
||||
|
||||
/**
|
||||
* Create an iterator for the cache object. The iterator is used to iterate over all cache entries.
|
||||
* @param cache The cache object pointer to create the iterator.
|
||||
* @return Returns a pointer to the created iterator on success, `NULL` on error.
|
||||
*/
|
||||
lv_iter_t * lv_cache_iter_create(lv_cache_t * cache);
|
||||
|
||||
/*************************
|
||||
* GLOBAL VARIABLES
|
||||
*************************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /* LV_CACHE_H */
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
/**
|
||||
* @file lv_cache_entry.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_CACHE_ENTRY_H
|
||||
#define LV_CACHE_ENTRY_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../../osal/lv_os.h"
|
||||
#include "../lv_types.h"
|
||||
#include "lv_cache_private.h"
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Get the size of a cache entry.
|
||||
* @param node_size The size of the node in the cache.
|
||||
* @return The size of the cache entry.
|
||||
*/
|
||||
uint32_t lv_cache_entry_get_size(const uint32_t node_size);
|
||||
|
||||
/**
|
||||
* Get the reference count of a cache entry.
|
||||
* @param entry The cache entry to get the reference count of.
|
||||
* @return The reference count of the cache entry.
|
||||
*/
|
||||
int32_t lv_cache_entry_get_ref(lv_cache_entry_t * entry);
|
||||
|
||||
/**
|
||||
* Get the node size of a cache entry. Which is the same size with lv_cache_entry_get_size()'s node_size parameter.
|
||||
* @param entry The cache entry to get the node size of.
|
||||
* @return The node size of the cache entry.
|
||||
*/
|
||||
uint32_t lv_cache_entry_get_node_size(lv_cache_entry_t * entry);
|
||||
|
||||
/**
|
||||
* Check if a cache entry is invalid.
|
||||
* @param entry The cache entry to check.
|
||||
* @return True: the cache entry is invalid. False: the cache entry is valid.
|
||||
*/
|
||||
bool lv_cache_entry_is_invalid(lv_cache_entry_t * entry);
|
||||
|
||||
/**
|
||||
* Get the data of a cache entry.
|
||||
* @param entry The cache entry to get the data of.
|
||||
* @return The pointer to the data of the cache entry.
|
||||
*/
|
||||
void * lv_cache_entry_get_data(lv_cache_entry_t * entry);
|
||||
|
||||
/**
|
||||
* Get the cache instance of a cache entry.
|
||||
* @param entry The cache entry to get the cache instance of.
|
||||
* @return The pointer to the cache instance of the cache entry.
|
||||
*/
|
||||
const lv_cache_t * lv_cache_entry_get_cache(const lv_cache_entry_t * entry);
|
||||
|
||||
/**
|
||||
* Get the cache entry of a data. The data should be allocated by the cache instance.
|
||||
* @param data The data to get the cache entry of.
|
||||
* @param node_size The size of the node in the cache.
|
||||
* @return The pointer to the cache entry of the data.
|
||||
*/
|
||||
lv_cache_entry_t * lv_cache_entry_get_entry(void * data, const uint32_t node_size);
|
||||
|
||||
/**
|
||||
* Allocate a cache entry.
|
||||
* @param node_size The size of the node in the cache.
|
||||
* @param cache The cache instance to allocate the cache entry from.
|
||||
* @return The pointer to the allocated cache entry.
|
||||
*/
|
||||
lv_cache_entry_t * lv_cache_entry_alloc(const uint32_t node_size, const lv_cache_t * cache);
|
||||
|
||||
/**
|
||||
* Initialize a cache entry.
|
||||
* @param entry The cache entry to initialize.
|
||||
* @param cache The cache instance to allocate the cache entry from.
|
||||
* @param node_size The size of the node in the cache.
|
||||
*/
|
||||
void lv_cache_entry_init(lv_cache_entry_t * entry, const lv_cache_t * cache, const uint32_t node_size);
|
||||
|
||||
/**
|
||||
* Deallocate a cache entry. And the data of the cache entry will be freed.
|
||||
* @param entry The cache entry to deallocate.
|
||||
*/
|
||||
void lv_cache_entry_delete(lv_cache_entry_t * entry);
|
||||
/*************************
|
||||
* GLOBAL VARIABLES
|
||||
*************************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_CACHE_ENTRY_H*/
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @file lv_cache_entry_private.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_CACHE_ENTRY_PRIVATE_H
|
||||
#define LV_CACHE_ENTRY_PRIVATE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_types.h"
|
||||
#include "../../osal/lv_os.h"
|
||||
#include "../lv_profiler.h"
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
void lv_cache_entry_reset_ref(lv_cache_entry_t * entry);
|
||||
void lv_cache_entry_inc_ref(lv_cache_entry_t * entry);
|
||||
void lv_cache_entry_dec_ref(lv_cache_entry_t * entry);
|
||||
void lv_cache_entry_set_node_size(lv_cache_entry_t * entry, uint32_t node_size);
|
||||
void lv_cache_entry_set_invalid(lv_cache_entry_t * entry, bool is_invalid);
|
||||
void lv_cache_entry_set_cache(lv_cache_entry_t * entry, const lv_cache_t * cache);
|
||||
void * lv_cache_entry_acquire_data(lv_cache_entry_t * entry);
|
||||
void lv_cache_entry_release_data(lv_cache_entry_t * entry, void * user_data);
|
||||
/*************************
|
||||
* GLOBAL VARIABLES
|
||||
*************************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /* LV_CACHE_ENTRY_PRIVATE_H */
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* @file lv_cache_lru_rb.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_CACHE_LRU_RB_H
|
||||
#define LV_CACHE_LRU_RB_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_cache_entry.h"
|
||||
#include "lv_cache_private.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/*************************
|
||||
* GLOBAL VARIABLES
|
||||
*************************/
|
||||
LV_ATTRIBUTE_EXTERN_DATA extern const lv_cache_class_t lv_cache_class_lru_rb_count;
|
||||
LV_ATTRIBUTE_EXTERN_DATA extern const lv_cache_class_t lv_cache_class_lru_rb_size;
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_CACHE_LRU_RB_H*/
|
||||
+201
@@ -0,0 +1,201 @@
|
||||
/**
|
||||
* @file lv_cache_private.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_CACHE_PRIVATE_H
|
||||
#define LV_CACHE_PRIVATE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_types.h"
|
||||
#include "../../osal/lv_os.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* The result of the cache reserve condition callback
|
||||
*/
|
||||
typedef enum {
|
||||
LV_CACHE_RESERVE_COND_OK, /**< The condition is met and no entries need to be evicted */
|
||||
LV_CACHE_RESERVE_COND_TOO_LARGE, /**< The condition is not met and the reserve size is too large */
|
||||
LV_CACHE_RESERVE_COND_NEED_VICTIM, /**< The condition is not met and a victim is needed to be evicted */
|
||||
LV_CACHE_RESERVE_COND_ERROR /**< An error occurred while checking the condition */
|
||||
} lv_cache_reserve_cond_res_t;
|
||||
|
||||
struct _lv_cache_ops_t;
|
||||
struct _lv_cache_t;
|
||||
struct _lv_cache_class_t;
|
||||
struct _lv_cache_entry_t;
|
||||
|
||||
typedef struct _lv_cache_ops_t lv_cache_ops_t;
|
||||
typedef struct _lv_cache_t lv_cache_t;
|
||||
typedef struct _lv_cache_class_t lv_cache_class_t;
|
||||
typedef struct _lv_cache_entry_t lv_cache_entry_t;
|
||||
|
||||
typedef int8_t lv_cache_compare_res_t;
|
||||
typedef bool (*lv_cache_create_cb_t)(void * node, void * user_data);
|
||||
typedef void (*lv_cache_free_cb_t)(void * node, void * user_data);
|
||||
typedef lv_cache_compare_res_t (*lv_cache_compare_cb_t)(const void * a, const void * b);
|
||||
|
||||
/**
|
||||
* The cache instance allocation function, used by the cache class to allocate memory for cache instances.
|
||||
* @return It should return a pointer to the allocated instance.
|
||||
*/
|
||||
typedef void * (*lv_cache_alloc_cb_t)(void);
|
||||
|
||||
/**
|
||||
* The cache instance initialization function, used by the cache class to initialize the cache instance.
|
||||
* @return It should return true if the initialization is successful, false otherwise.
|
||||
*/
|
||||
typedef bool (*lv_cache_init_cb_t)(lv_cache_t * cache);
|
||||
|
||||
/**
|
||||
* The cache instance destruction function, used by the cache class to destroy the cache instance.
|
||||
*/
|
||||
typedef void (*lv_cache_destroy_cb_t)(lv_cache_t * cache, void * user_data);
|
||||
|
||||
/**
|
||||
* The cache get function, used by the cache class to get a cache entry by its key.
|
||||
* @return `NULL` if the key is not found.
|
||||
*/
|
||||
typedef lv_cache_entry_t * (*lv_cache_get_cb_t)(lv_cache_t * cache, const void * key, void * user_data);
|
||||
|
||||
/**
|
||||
* The cache add function, used by the cache class to add a cache entry with a given key.
|
||||
* This function only cares about how to add the entry, it doesn't check if the entry already exists and doesn't care about is it a victim or not.
|
||||
* @return the added cache entry, or NULL if the entry is not added.
|
||||
*/
|
||||
typedef lv_cache_entry_t * (*lv_cache_add_cb_t)(lv_cache_t * cache, const void * key, void * user_data);
|
||||
|
||||
/**
|
||||
* The cache remove function, used by the cache class to remove a cache entry from the cache but doesn't free the memory..
|
||||
* This function only cares about how to remove the entry, it doesn't care about is it a victim or not.
|
||||
*/
|
||||
typedef void (*lv_cache_remove_cb_t)(lv_cache_t * cache, lv_cache_entry_t * entry, void * user_data);
|
||||
|
||||
/**
|
||||
* The cache drop function, used by the cache class to remove a cache entry from the cache and free the memory.
|
||||
*/
|
||||
typedef void (*lv_cache_drop_cb_t)(lv_cache_t * cache, const void * key, void * user_data);
|
||||
|
||||
/**
|
||||
* The cache drop all function, used by the cache class to remove all cache entries from the cache and free the memory.
|
||||
*/
|
||||
typedef void (*lv_cache_drop_all_cb_t)(lv_cache_t * cache, void * user_data);
|
||||
|
||||
/**
|
||||
* The cache get victim function, used by the cache class to get a victim entry to be evicted.
|
||||
*/
|
||||
typedef lv_cache_entry_t * (*lv_cache_get_victim_cb)(lv_cache_t * cache, void * user_data);
|
||||
|
||||
/**
|
||||
* The cache reserve condition function, used by the cache class to check if a new entry can be added to the cache without exceeding its maximum size.
|
||||
* See lv_cache_reserve_cond_res_t for the possible results.
|
||||
*/
|
||||
typedef lv_cache_reserve_cond_res_t (*lv_cache_reserve_cond_cb)(lv_cache_t * cache, const void * key, size_t size,
|
||||
void * user_data);
|
||||
|
||||
/**
|
||||
* The cache iterator creation function, used by the cache class to create an iterator for the cache.
|
||||
* @return A pointer to the created iterator, or NULL if the iterator cannot be created.
|
||||
*/
|
||||
typedef lv_iter_t * (*lv_cache_iter_create_cb)(lv_cache_t * cache);
|
||||
|
||||
/**
|
||||
* The cache operations struct
|
||||
*/
|
||||
struct _lv_cache_ops_t {
|
||||
lv_cache_compare_cb_t compare_cb; /**< Compare function for keys */
|
||||
lv_cache_create_cb_t create_cb; /**< Create function for nodes */
|
||||
lv_cache_free_cb_t free_cb; /**< Free function for nodes */
|
||||
};
|
||||
|
||||
/**
|
||||
* The cache entry struct
|
||||
*/
|
||||
struct _lv_cache_t {
|
||||
const lv_cache_class_t * clz; /**< Cache class. There are two built-in classes:
|
||||
* - lv_cache_class_lru_rb_count for LRU-based cache with count-based eviction policy.
|
||||
* - lv_cache_class_lru_rb_size for LRU-based cache with size-based eviction policy. */
|
||||
|
||||
uint32_t node_size; /**< Size of a node */
|
||||
|
||||
uint32_t max_size; /**< Maximum size of the cache */
|
||||
uint32_t size; /**< Current size of the cache */
|
||||
|
||||
lv_cache_ops_t ops; /**< Cache operations struct _lv_cache_ops_t */
|
||||
|
||||
lv_mutex_t lock; /**< Cache lock used to protect the cache in multithreading environments */
|
||||
|
||||
const char * name; /**< Name of the cache */
|
||||
};
|
||||
|
||||
/**
|
||||
* Cache class struct for building custom cache classes
|
||||
*
|
||||
* Examples:
|
||||
* - lv_cache_class_lru_rb_count for LRU-based cache with count-based eviction policy.
|
||||
* - lv_cache_class_lru_rb_size for LRU-based cache with size-based eviction policy.
|
||||
*/
|
||||
struct _lv_cache_class_t {
|
||||
lv_cache_alloc_cb_t alloc_cb; /**< The allocation function for cache entries */
|
||||
lv_cache_init_cb_t init_cb; /**< The initialization function for cache entries */
|
||||
lv_cache_destroy_cb_t destroy_cb; /**< The destruction function for cache entries */
|
||||
|
||||
lv_cache_get_cb_t get_cb; /**< The get function for cache entries */
|
||||
lv_cache_add_cb_t add_cb; /**< The add function for cache entries */
|
||||
lv_cache_remove_cb_t remove_cb; /**< The remove function for cache entries */
|
||||
lv_cache_drop_cb_t drop_cb; /**< The drop function for cache entries */
|
||||
lv_cache_drop_all_cb_t drop_all_cb; /**< The drop all function for cache entries */
|
||||
lv_cache_get_victim_cb get_victim_cb; /**< The get victim function for cache entries */
|
||||
lv_cache_reserve_cond_cb reserve_cond_cb; /**< The reserve condition function for cache entries */
|
||||
|
||||
lv_cache_iter_create_cb iter_create_cb; /**< The iterator creation function for cache entries */
|
||||
};
|
||||
|
||||
/*-----------------
|
||||
* Cache entry slot
|
||||
*----------------*/
|
||||
|
||||
struct _lv_cache_slot_size_t;
|
||||
|
||||
typedef struct _lv_cache_slot_size_t lv_cache_slot_size_t;
|
||||
|
||||
/**
|
||||
* Cache entry slot struct
|
||||
*
|
||||
* To add new fields to the cache entry, add them to a new struct and add it to the first
|
||||
* field of the cache data struct. And this one is a size slot for the cache entry.
|
||||
*/
|
||||
struct _lv_cache_slot_size_t {
|
||||
size_t size;
|
||||
};
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/*************************
|
||||
* GLOBAL VARIABLES
|
||||
*************************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_CACHE_PRIVATE_H*/
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* @file lv_image_cache.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_IMAGE_CACHE_H
|
||||
#define LV_IMAGE_CACHE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "../../lv_conf_internal.h"
|
||||
#include "../lv_types.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize image cache.
|
||||
* @param size size of the cache in bytes.
|
||||
* @return LV_RESULT_OK: initialization succeeded, LV_RESULT_INVALID: failed.
|
||||
*/
|
||||
lv_result_t lv_image_cache_init(uint32_t size);
|
||||
|
||||
/**
|
||||
* Resize image cache.
|
||||
* If set to 0, the cache will be disabled.
|
||||
* @param new_size new size of the cache in bytes.
|
||||
* @param evict_now true: evict the images should be removed by the eviction policy, false: wait for the next cache cleanup.
|
||||
*/
|
||||
void lv_image_cache_resize(uint32_t new_size, bool evict_now);
|
||||
|
||||
/**
|
||||
* Invalidate image cache. Use NULL to invalidate all images.
|
||||
* @param src pointer to an image source.
|
||||
*/
|
||||
void lv_image_cache_drop(const void * src);
|
||||
|
||||
/**
|
||||
* Return true if the image cache is enabled.
|
||||
* @return true: enabled, false: disabled.
|
||||
*/
|
||||
bool lv_image_cache_is_enabled(void);
|
||||
|
||||
/**
|
||||
* Create an iterator to iterate over the image cache.
|
||||
* @return an iterator to iterate over the image cache.
|
||||
*/
|
||||
lv_iter_t * lv_image_cache_iter_create(void);
|
||||
|
||||
/**
|
||||
* Dump the content of the image cache in a human-readable format with cache order.
|
||||
*/
|
||||
void lv_image_cache_dump(void);
|
||||
|
||||
/*************************
|
||||
* GLOBAL VARIABLES
|
||||
*************************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_IMAGE_CACHE_H*/
|
||||
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* @file lv_image_header_cache.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_IMAGE_HEADER_CACHE_H
|
||||
#define LV_IMAGE_HEADER_CACHE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "../../lv_conf_internal.h"
|
||||
#include "../lv_types.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize image header cache.
|
||||
* @param count initial size of the cache in count of image headers.
|
||||
* @return LV_RESULT_OK: initialization succeeded, LV_RESULT_INVALID: failed.
|
||||
*/
|
||||
lv_result_t lv_image_header_cache_init(uint32_t count);
|
||||
|
||||
/**
|
||||
* Resize image header cache.
|
||||
* If set to 0, the cache is disabled.
|
||||
* @param count new max count of cached image headers.
|
||||
* @param evict_now true: evict the image headers should be removed by the eviction policy, false: wait for the next cache cleanup.
|
||||
*/
|
||||
void lv_image_header_cache_resize(uint32_t count, bool evict_now);
|
||||
|
||||
/**
|
||||
* Invalidate image header cache. Use NULL to invalidate all image headers.
|
||||
* It's also automatically called when an image is invalidated.
|
||||
* @param src pointer to an image source.
|
||||
*/
|
||||
void lv_image_header_cache_drop(const void * src);
|
||||
|
||||
/**
|
||||
* Return true if the image header cache is enabled.
|
||||
* @return true: enabled, false: disabled.
|
||||
*/
|
||||
bool lv_image_header_cache_is_enabled(void);
|
||||
|
||||
/**
|
||||
* Create an iterator to iterate over the image header cache.
|
||||
* @return an iterator to iterate over the image header cache.
|
||||
*/
|
||||
lv_iter_t * lv_image_header_cache_iter_create(void);
|
||||
|
||||
/**
|
||||
* Dump the content of the image header cache in a human-readable format with cache order.
|
||||
*/
|
||||
void lv_image_header_cache_dump(void);
|
||||
|
||||
/*************************
|
||||
* GLOBAL VARIABLES
|
||||
*************************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_IMAGE_HEADER_CACHE_H*/
|
||||
@@ -0,0 +1,525 @@
|
||||
/**
|
||||
* @file lv_anim.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_ANIM_H
|
||||
#define LV_ANIM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_conf_internal.h"
|
||||
#include "lv_types.h"
|
||||
#include "lv_math.h"
|
||||
#include "lv_timer.h"
|
||||
#include "lv_ll.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
#define LV_ANIM_REPEAT_INFINITE 0xFFFFFFFF
|
||||
#define LV_ANIM_PLAYTIME_INFINITE 0xFFFFFFFF
|
||||
|
||||
/*
|
||||
* Macros used to set cubic-bezier anim parameter.
|
||||
* Parameters come from https://easings.net/
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* lv_anim_t a;
|
||||
* lv_anim_init(&a);
|
||||
* ...
|
||||
* lv_anim_set_path_cb(&a, lv_anim_path_custom_bezier3);
|
||||
* LV_ANIM_SET_EASE_IN_SINE(&a); //Set cubic-bezier anim parameter to easeInSine
|
||||
* ...
|
||||
* lv_anim_start(&a);
|
||||
*/
|
||||
|
||||
#define _PARA(a, x1, y1, x2, y2) ((a)->parameter.bezier3 = \
|
||||
(lv_anim_bezier3_para_t) { \
|
||||
LV_BEZIER_VAL_FLOAT(x1), LV_BEZIER_VAL_FLOAT(y1), \
|
||||
LV_BEZIER_VAL_FLOAT(x2), LV_BEZIER_VAL_FLOAT(y2) } \
|
||||
)
|
||||
|
||||
#define LV_ANIM_SET_EASE_IN_SINE(a) _PARA(a, 0.12, 0, 0.39, 0)
|
||||
#define LV_ANIM_SET_EASE_OUT_SINE(a) _PARA(a, 0.61, 1, 0.88, 1)
|
||||
#define LV_ANIM_SET_EASE_IN_OUT_SINE(a) _PARA(a, 0.37, 0, 0.63, 1)
|
||||
#define LV_ANIM_SET_EASE_IN_QUAD(a) _PARA(a, 0.11, 0, 0.5, 0)
|
||||
#define LV_ANIM_SET_EASE_OUT_QUAD(a) _PARA(a, 0.5, 1, 0.89, 1)
|
||||
#define LV_ANIM_SET_EASE_IN_OUT_QUAD(a) _PARA(a, 0.45, 0, 0.55, 1)
|
||||
#define LV_ANIM_SET_EASE_IN_CUBIC(a) _PARA(a, 0.32, 0, 0.67, 0)
|
||||
#define LV_ANIM_SET_EASE_OUT_CUBIC(a) _PARA(a, 0.33, 1, 0.68, 1)
|
||||
#define LV_ANIM_SET_EASE_IN_OUT_CUBIC(a) _PARA(a, 0.65, 0, 0.35, 1)
|
||||
#define LV_ANIM_SET_EASE_IN_QUART(a) _PARA(a, 0.5, 0, 0.75, 0)
|
||||
#define LV_ANIM_SET_EASE_OUT_QUART(a) _PARA(a, 0.25, 1, 0.5, 1)
|
||||
#define LV_ANIM_SET_EASE_IN_OUT_QUART(a) _PARA(a, 0.76, 0, 0.24, 1)
|
||||
#define LV_ANIM_SET_EASE_IN_QUINT(a) _PARA(a, 0.64, 0, 0.78, 0)
|
||||
#define LV_ANIM_SET_EASE_OUT_QUINT(a) _PARA(a, 0.22, 1, 0.36, 1)
|
||||
#define LV_ANIM_SET_EASE_IN_OUT_QUINT(a) _PARA(a, 0.83, 0, 0.17, 1)
|
||||
#define LV_ANIM_SET_EASE_IN_EXPO(a) _PARA(a, 0.7, 0, 0.84, 0)
|
||||
#define LV_ANIM_SET_EASE_OUT_EXPO(a) _PARA(a, 0.16, 1, 0.3, 1)
|
||||
#define LV_ANIM_SET_EASE_IN_OUT_EXPO(a) _PARA(a, 0.87, 0, 0.13, 1)
|
||||
#define LV_ANIM_SET_EASE_IN_CIRC(a) _PARA(a, 0.55, 0, 1, 0.45)
|
||||
#define LV_ANIM_SET_EASE_OUT_CIRC(a) _PARA(a, 0, 0.55, 0.45, 1)
|
||||
#define LV_ANIM_SET_EASE_IN_OUT_CIRC(a) _PARA(a, 0.85, 0, 0.15, 1)
|
||||
#define LV_ANIM_SET_EASE_IN_BACK(a) _PARA(a, 0.36, 0, 0.66, -0.56)
|
||||
#define LV_ANIM_SET_EASE_OUT_BACK(a) _PARA(a, 0.34, 1.56, 0.64, 1)
|
||||
#define LV_ANIM_SET_EASE_IN_OUT_BACK(a) _PARA(a, 0.68, -0.6, 0.32, 1.6)
|
||||
|
||||
LV_EXPORT_CONST_INT(LV_ANIM_REPEAT_INFINITE);
|
||||
LV_EXPORT_CONST_INT(LV_ANIM_PLAYTIME_INFINITE);
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/** Can be used to indicate if animations are enabled or disabled in a case*/
|
||||
typedef enum {
|
||||
LV_ANIM_OFF,
|
||||
LV_ANIM_ON,
|
||||
} lv_anim_enable_t;
|
||||
|
||||
/** Get the current value during an animation*/
|
||||
typedef int32_t (*lv_anim_path_cb_t)(const lv_anim_t *);
|
||||
|
||||
/** Generic prototype of "animator" functions.
|
||||
* First parameter is the variable to animate.
|
||||
* Second parameter is the value to set.
|
||||
* Compatible with `lv_xxx_set_yyy(obj, value)` functions
|
||||
* The `x` in `_xcb_t` means it's not a fully generic prototype because
|
||||
* it doesn't receive `lv_anim_t *` as its first argument*/
|
||||
typedef void (*lv_anim_exec_xcb_t)(void *, int32_t);
|
||||
|
||||
/** Same as `lv_anim_exec_xcb_t` but receives `lv_anim_t *` as the first parameter.
|
||||
* It's more consistent but less convenient. Might be used by binding generator functions.*/
|
||||
typedef void (*lv_anim_custom_exec_cb_t)(lv_anim_t *, int32_t);
|
||||
|
||||
/** Callback to call when the animation is ready*/
|
||||
typedef void (*lv_anim_completed_cb_t)(lv_anim_t *);
|
||||
|
||||
/** Callback to call when the animation really stars (considering `delay`)*/
|
||||
typedef void (*lv_anim_start_cb_t)(lv_anim_t *);
|
||||
|
||||
/** Callback used when the animation values are relative to get the current value*/
|
||||
typedef int32_t (*lv_anim_get_value_cb_t)(lv_anim_t *);
|
||||
|
||||
/** Callback used when the animation is deleted*/
|
||||
typedef void (*lv_anim_deleted_cb_t)(lv_anim_t *);
|
||||
|
||||
/** Parameter used when path is custom_bezier */
|
||||
typedef struct {
|
||||
int16_t x1;
|
||||
int16_t y1;
|
||||
int16_t x2;
|
||||
int16_t y2;
|
||||
} lv_anim_bezier3_para_t;
|
||||
|
||||
/** Describes an animation*/
|
||||
struct _lv_anim_t {
|
||||
void * var; /**< Variable to animate*/
|
||||
lv_anim_exec_xcb_t exec_cb; /**< Function to execute to animate*/
|
||||
lv_anim_custom_exec_cb_t custom_exec_cb; /**< Function to execute to animate,
|
||||
* same purpose as exec_cb but different parameters*/
|
||||
lv_anim_start_cb_t start_cb; /**< Call it when the animation is starts (considering `delay`)*/
|
||||
lv_anim_completed_cb_t completed_cb; /**< Call it when the animation is fully completed*/
|
||||
lv_anim_deleted_cb_t deleted_cb; /**< Call it when the animation is deleted*/
|
||||
lv_anim_get_value_cb_t get_value_cb; /**< Get the current value in relative mode*/
|
||||
void * user_data; /**< Custom user data*/
|
||||
lv_anim_path_cb_t path_cb; /**< Describe the path (curve) of animations*/
|
||||
int32_t start_value; /**< Start value*/
|
||||
int32_t current_value; /**< Current value*/
|
||||
int32_t end_value; /**< End value*/
|
||||
int32_t duration; /**< Animation time in ms*/
|
||||
int32_t act_time; /**< Current time in animation. Set to negative to make delay.*/
|
||||
uint32_t playback_delay; /**< Wait before play back*/
|
||||
uint32_t playback_duration; /**< Duration of playback animation*/
|
||||
uint32_t repeat_delay; /**< Wait before repeat*/
|
||||
uint32_t repeat_cnt; /**< Repeat count for the animation*/
|
||||
union _lv_anim_path_para_t {
|
||||
lv_anim_bezier3_para_t bezier3; /**< Parameter used when path is custom_bezier*/
|
||||
} parameter;
|
||||
|
||||
/* Animation system use these - user shouldn't set */
|
||||
uint32_t last_timer_run;
|
||||
uint8_t playback_now : 1; /**< Play back is in progress*/
|
||||
uint8_t run_round : 1; /**< Indicates the animation has run in this round*/
|
||||
uint8_t start_cb_called : 1; /**< Indicates that the `start_cb` was already called*/
|
||||
uint8_t early_apply : 1; /**< 1: Apply start value immediately even is there is `delay`*/
|
||||
};
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize an animation variable.
|
||||
* E.g.:
|
||||
* lv_anim_t a;
|
||||
* lv_anim_init(&a);
|
||||
* lv_anim_set_...(&a);
|
||||
* lv_anim_start(&a);
|
||||
* @param a pointer to an `lv_anim_t` variable to initialize
|
||||
*/
|
||||
void lv_anim_init(lv_anim_t * a);
|
||||
|
||||
/**
|
||||
* Set a variable to animate
|
||||
* @param a pointer to an initialized `lv_anim_t` variable
|
||||
* @param var pointer to a variable to animate
|
||||
*/
|
||||
void lv_anim_set_var(lv_anim_t * a, void * var);
|
||||
|
||||
/**
|
||||
* Set a function to animate `var`
|
||||
* @param a pointer to an initialized `lv_anim_t` variable
|
||||
* @param exec_cb a function to execute during animation
|
||||
* LVGL's built-in functions can be used.
|
||||
* E.g. lv_obj_set_x
|
||||
*/
|
||||
void lv_anim_set_exec_cb(lv_anim_t * a, lv_anim_exec_xcb_t exec_cb);
|
||||
|
||||
/**
|
||||
* Set the duration of an animation
|
||||
* @param a pointer to an initialized `lv_anim_t` variable
|
||||
* @param duration duration of the animation in milliseconds
|
||||
*/
|
||||
void lv_anim_set_duration(lv_anim_t * a, uint32_t duration);
|
||||
|
||||
/**
|
||||
* Legacy `lv_anim_set_time` API will be removed soon, use `lv_anim_set_duration` instead.
|
||||
*/
|
||||
void lv_anim_set_time(lv_anim_t * a, uint32_t duration);
|
||||
|
||||
/**
|
||||
* Set a delay before starting the animation
|
||||
* @param a pointer to an initialized `lv_anim_t` variable
|
||||
* @param delay delay before the animation in milliseconds
|
||||
*/
|
||||
void lv_anim_set_delay(lv_anim_t * a, uint32_t delay);
|
||||
|
||||
/**
|
||||
* Set the start and end values of an animation
|
||||
* @param a pointer to an initialized `lv_anim_t` variable
|
||||
* @param start the start value
|
||||
* @param end the end value
|
||||
*/
|
||||
void lv_anim_set_values(lv_anim_t * a, int32_t start, int32_t end);
|
||||
|
||||
/**
|
||||
* Similar to `lv_anim_set_exec_cb` but `lv_anim_custom_exec_cb_t` receives
|
||||
* `lv_anim_t * ` as its first parameter instead of `void *`.
|
||||
* This function might be used when LVGL is bound to other languages because
|
||||
* it's more consistent to have `lv_anim_t *` as first parameter.
|
||||
* @param a pointer to an initialized `lv_anim_t` variable
|
||||
* @param exec_cb a function to execute.
|
||||
*/
|
||||
void lv_anim_set_custom_exec_cb(lv_anim_t * a, lv_anim_custom_exec_cb_t exec_cb);
|
||||
|
||||
/**
|
||||
* Set the path (curve) of the animation.
|
||||
* @param a pointer to an initialized `lv_anim_t` variable
|
||||
* @param path_cb a function to set the current value of the animation.
|
||||
*/
|
||||
void lv_anim_set_path_cb(lv_anim_t * a, lv_anim_path_cb_t path_cb);
|
||||
|
||||
/**
|
||||
* Set a function call when the animation really starts (considering `delay`)
|
||||
* @param a pointer to an initialized `lv_anim_t` variable
|
||||
* @param start_cb a function call when the animation starts
|
||||
*/
|
||||
void lv_anim_set_start_cb(lv_anim_t * a, lv_anim_start_cb_t start_cb);
|
||||
|
||||
/**
|
||||
* Set a function to use the current value of the variable and make start and end value
|
||||
* relative to the returned current value.
|
||||
* @param a pointer to an initialized `lv_anim_t` variable
|
||||
* @param get_value_cb a function call when the animation starts
|
||||
*/
|
||||
void lv_anim_set_get_value_cb(lv_anim_t * a, lv_anim_get_value_cb_t get_value_cb);
|
||||
|
||||
/**
|
||||
* Set a function call when the animation is completed
|
||||
* @param a pointer to an initialized `lv_anim_t` variable
|
||||
* @param completed_cb a function call when the animation is fully completed
|
||||
*/
|
||||
void lv_anim_set_completed_cb(lv_anim_t * a, lv_anim_completed_cb_t completed_cb);
|
||||
|
||||
/**
|
||||
* Set a function call when the animation is deleted.
|
||||
* @param a pointer to an initialized `lv_anim_t` variable
|
||||
* @param deleted_cb a function call when the animation is deleted
|
||||
*/
|
||||
void lv_anim_set_deleted_cb(lv_anim_t * a, lv_anim_deleted_cb_t deleted_cb);
|
||||
|
||||
/**
|
||||
* Make the animation to play back to when the forward direction is ready
|
||||
* @param a pointer to an initialized `lv_anim_t` variable
|
||||
* @param duration duration of playback animation in milliseconds. 0: disable playback
|
||||
*/
|
||||
void lv_anim_set_playback_duration(lv_anim_t * a, uint32_t duration);
|
||||
|
||||
/**
|
||||
* Legacy `lv_anim_set_playback_time` API will be removed soon, use `lv_anim_set_playback_duration` instead.
|
||||
*/
|
||||
void lv_anim_set_playback_time(lv_anim_t * a, uint32_t duration);
|
||||
|
||||
/**
|
||||
* Make the animation to play back to when the forward direction is ready
|
||||
* @param a pointer to an initialized `lv_anim_t` variable
|
||||
* @param delay delay in milliseconds before starting the playback animation.
|
||||
*/
|
||||
void lv_anim_set_playback_delay(lv_anim_t * a, uint32_t delay);
|
||||
|
||||
/**
|
||||
* Make the animation repeat itself.
|
||||
* @param a pointer to an initialized `lv_anim_t` variable
|
||||
* @param cnt repeat count or `LV_ANIM_REPEAT_INFINITE` for infinite repetition. 0: to disable repetition.
|
||||
*/
|
||||
void lv_anim_set_repeat_count(lv_anim_t * a, uint32_t cnt);
|
||||
|
||||
/**
|
||||
* Set a delay before repeating the animation.
|
||||
* @param a pointer to an initialized `lv_anim_t` variable
|
||||
* @param delay delay in milliseconds before repeating the animation.
|
||||
*/
|
||||
void lv_anim_set_repeat_delay(lv_anim_t * a, uint32_t delay);
|
||||
|
||||
/**
|
||||
* Set a whether the animation's should be applied immediately or only when the delay expired.
|
||||
* @param a pointer to an initialized `lv_anim_t` variable
|
||||
* @param en true: apply the start value immediately in `lv_anim_start`;
|
||||
* false: apply the start value only when `delay` ms is elapsed and the animations really starts
|
||||
*/
|
||||
void lv_anim_set_early_apply(lv_anim_t * a, bool en);
|
||||
|
||||
/**
|
||||
* Set the custom user data field of the animation.
|
||||
* @param a pointer to an initialized `lv_anim_t` variable
|
||||
* @param user_data pointer to the new user_data.
|
||||
*/
|
||||
void lv_anim_set_user_data(lv_anim_t * a, void * user_data);
|
||||
|
||||
/**
|
||||
* Set parameter for cubic bezier path
|
||||
* @param a pointer to an initialized `lv_anim_t` variable
|
||||
* @param x1 first control point X
|
||||
* @param y1 first control point Y
|
||||
* @param x2 second control point X
|
||||
* @param y2 second control point Y
|
||||
*/
|
||||
void lv_anim_set_bezier3_param(lv_anim_t * a, int16_t x1, int16_t y1, int16_t x2, int16_t y2);
|
||||
|
||||
/**
|
||||
* Create an animation
|
||||
* @param a an initialized 'anim_t' variable. Not required after call.
|
||||
* @return pointer to the created animation (different from the `a` parameter)
|
||||
*/
|
||||
lv_anim_t * lv_anim_start(const lv_anim_t * a);
|
||||
|
||||
/**
|
||||
* Get a delay before starting the animation
|
||||
* @param a pointer to an initialized `lv_anim_t` variable
|
||||
* @return delay before the animation in milliseconds
|
||||
*/
|
||||
uint32_t lv_anim_get_delay(const lv_anim_t * a);
|
||||
|
||||
/**
|
||||
* Get the time used to play the animation.
|
||||
* @param a pointer to an animation.
|
||||
* @return the play time in milliseconds.
|
||||
*/
|
||||
uint32_t lv_anim_get_playtime(const lv_anim_t * a);
|
||||
|
||||
/**
|
||||
* Get the duration of an animation
|
||||
* @param a pointer to an initialized `lv_anim_t` variable
|
||||
* @return the duration of the animation in milliseconds
|
||||
*/
|
||||
uint32_t lv_anim_get_time(const lv_anim_t * a);
|
||||
|
||||
/**
|
||||
* Get the repeat count of the animation.
|
||||
* @param a pointer to an initialized `lv_anim_t` variable
|
||||
* @return the repeat count or `LV_ANIM_REPEAT_INFINITE` for infinite repetition. 0: disabled repetition.
|
||||
*/
|
||||
uint32_t lv_anim_get_repeat_count(const lv_anim_t * a);
|
||||
|
||||
/**
|
||||
* Get the user_data field of the animation
|
||||
* @param a pointer to an initialized `lv_anim_t` variable
|
||||
* @return the pointer to the custom user_data of the animation
|
||||
*/
|
||||
void * lv_anim_get_user_data(const lv_anim_t * a);
|
||||
|
||||
/**
|
||||
* Delete animation(s) of a variable with a given animator function
|
||||
* @param var pointer to variable
|
||||
* @param exec_cb a function pointer which is animating 'var',
|
||||
* or NULL to ignore it and delete all the animations of 'var
|
||||
* @return true: at least 1 animation is deleted, false: no animation is deleted
|
||||
*/
|
||||
bool lv_anim_delete(void * var, lv_anim_exec_xcb_t exec_cb);
|
||||
|
||||
/**
|
||||
* Delete all the animations
|
||||
*/
|
||||
void lv_anim_delete_all(void);
|
||||
|
||||
/**
|
||||
* Get the animation of a variable and its `exec_cb`.
|
||||
* @param var pointer to variable
|
||||
* @param exec_cb a function pointer which is animating 'var', or NULL to return first matching 'var'
|
||||
* @return pointer to the animation.
|
||||
*/
|
||||
lv_anim_t * lv_anim_get(void * var, lv_anim_exec_xcb_t exec_cb);
|
||||
|
||||
/**
|
||||
* Get global animation refresher timer.
|
||||
* @return pointer to the animation refresher timer.
|
||||
*/
|
||||
lv_timer_t * lv_anim_get_timer(void);
|
||||
|
||||
/**
|
||||
* Delete an animation by getting the animated variable from `a`.
|
||||
* Only animations with `exec_cb` will be deleted.
|
||||
* This function exists because it's logical that all anim. functions receives an
|
||||
* `lv_anim_t` as their first parameter. It's not practical in C but might make
|
||||
* the API more consequent and makes easier to generate bindings.
|
||||
* @param a pointer to an animation.
|
||||
* @param exec_cb a function pointer which is animating 'var',
|
||||
* or NULL to ignore it and delete all the animations of 'var
|
||||
* @return true: at least 1 animation is deleted, false: no animation is deleted
|
||||
*/
|
||||
bool lv_anim_custom_delete(lv_anim_t * a, lv_anim_custom_exec_cb_t exec_cb);
|
||||
|
||||
/**
|
||||
* Get the animation of a variable and its `exec_cb`.
|
||||
* This function exists because it's logical that all anim. functions receives an
|
||||
* `lv_anim_t` as their first parameter. It's not practical in C but might make
|
||||
* the API more consequent and makes easier to generate bindings.
|
||||
* @param a pointer to an animation.
|
||||
* @param exec_cb a function pointer which is animating 'var', or NULL to return first matching 'var'
|
||||
* @return pointer to the animation.
|
||||
*/
|
||||
lv_anim_t * lv_anim_custom_get(lv_anim_t * a, lv_anim_custom_exec_cb_t exec_cb);
|
||||
|
||||
/**
|
||||
* Get the number of currently running animations
|
||||
* @return the number of running animations
|
||||
*/
|
||||
uint16_t lv_anim_count_running(void);
|
||||
|
||||
/**
|
||||
* Store the speed as a special value which can be used as time in animations.
|
||||
* It will be converted to time internally based on the start and end values
|
||||
* @param speed the speed of the animation in with unit / sec resolution in 0..10k range
|
||||
* @return a special value which can be used as an animation time
|
||||
*/
|
||||
uint32_t lv_anim_speed(uint32_t speed);
|
||||
|
||||
/**
|
||||
* Store the speed as a special value which can be used as time in animations.
|
||||
* It will be converted to time internally based on the start and end values
|
||||
* @param speed the speed of the animation in as unit / sec resolution in 0..10k range
|
||||
* @param min_time the minimum time in 0..10k range
|
||||
* @param max_time the maximum time in 0..10k range
|
||||
* @return a special value in where all three values are stored and can be used as an animation time
|
||||
* @note internally speed is stored as 10 unit/sec
|
||||
* @note internally min/max_time are stored with 10 ms unit
|
||||
*
|
||||
*/
|
||||
uint32_t lv_anim_speed_clamped(uint32_t speed, uint32_t min_time, uint32_t max_time);
|
||||
|
||||
/**
|
||||
* Calculate the time of an animation based on its speed, start and end values.
|
||||
* @param speed the speed of the animation
|
||||
* @param start the start value
|
||||
* @param end the end value
|
||||
* @return the time of the animation in milliseconds
|
||||
*/
|
||||
uint32_t lv_anim_speed_to_time(uint32_t speed, int32_t start, int32_t end);
|
||||
|
||||
/**
|
||||
* Manually refresh the state of the animations.
|
||||
* Useful to make the animations running in a blocking process where
|
||||
* `lv_timer_handler` can't run for a while.
|
||||
* Shouldn't be used directly because it is called in `lv_refr_now()`.
|
||||
*/
|
||||
void lv_anim_refr_now(void);
|
||||
|
||||
/**
|
||||
* Calculate the current value of an animation applying linear characteristic
|
||||
* @param a pointer to an animation
|
||||
* @return the current value to set
|
||||
*/
|
||||
int32_t lv_anim_path_linear(const lv_anim_t * a);
|
||||
|
||||
/**
|
||||
* Calculate the current value of an animation slowing down the start phase
|
||||
* @param a pointer to an animation
|
||||
* @return the current value to set
|
||||
*/
|
||||
int32_t lv_anim_path_ease_in(const lv_anim_t * a);
|
||||
|
||||
/**
|
||||
* Calculate the current value of an animation slowing down the end phase
|
||||
* @param a pointer to an animation
|
||||
* @return the current value to set
|
||||
*/
|
||||
int32_t lv_anim_path_ease_out(const lv_anim_t * a);
|
||||
|
||||
/**
|
||||
* Calculate the current value of an animation applying an "S" characteristic (cosine)
|
||||
* @param a pointer to an animation
|
||||
* @return the current value to set
|
||||
*/
|
||||
int32_t lv_anim_path_ease_in_out(const lv_anim_t * a);
|
||||
|
||||
/**
|
||||
* Calculate the current value of an animation with overshoot at the end
|
||||
* @param a pointer to an animation
|
||||
* @return the current value to set
|
||||
*/
|
||||
int32_t lv_anim_path_overshoot(const lv_anim_t * a);
|
||||
|
||||
/**
|
||||
* Calculate the current value of an animation with 3 bounces
|
||||
* @param a pointer to an animation
|
||||
* @return the current value to set
|
||||
*/
|
||||
int32_t lv_anim_path_bounce(const lv_anim_t * a);
|
||||
|
||||
/**
|
||||
* Calculate the current value of an animation applying step characteristic.
|
||||
* (Set end value on the end of the animation)
|
||||
* @param a pointer to an animation
|
||||
* @return the current value to set
|
||||
*/
|
||||
int32_t lv_anim_path_step(const lv_anim_t * a);
|
||||
|
||||
/**
|
||||
* A custom cubic bezier animation path, need to specify cubic-parameters in a->parameter.bezier3
|
||||
* @param a pointer to an animation
|
||||
* @return the current value to set
|
||||
*/
|
||||
int32_t lv_anim_path_custom_bezier3(const lv_anim_t * a);
|
||||
|
||||
/**********************
|
||||
* GLOBAL VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_ANIM_H*/
|
||||
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* @file lv_anim_private.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_ANIM_PRIVATE_H
|
||||
#define LV_ANIM_PRIVATE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lv_anim.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef struct {
|
||||
bool anim_list_changed;
|
||||
bool anim_run_round;
|
||||
lv_timer_t * timer;
|
||||
lv_ll_t anim_ll;
|
||||
} lv_anim_state_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Init the animation module
|
||||
*/
|
||||
void lv_anim_core_init(void);
|
||||
|
||||
/**
|
||||
* Deinit the animation module
|
||||
*/
|
||||
void lv_anim_core_deinit(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_ANIM_PRIVATE_H*/
|
||||
@@ -0,0 +1,136 @@
|
||||
/**
|
||||
* @file lv_anim_timeline.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_ANIM_TIMELINE_H
|
||||
#define LV_ANIM_TIMELINE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_anim.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
#define LV_ANIM_TIMELINE_PROGRESS_MAX 0xFFFF
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef struct _lv_anim_timeline_t lv_anim_timeline_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create an animation timeline.
|
||||
* @return pointer to the animation timeline.
|
||||
*/
|
||||
lv_anim_timeline_t * lv_anim_timeline_create(void);
|
||||
|
||||
/**
|
||||
* Delete animation timeline.
|
||||
* @param at pointer to the animation timeline.
|
||||
*/
|
||||
void lv_anim_timeline_delete(lv_anim_timeline_t * at);
|
||||
|
||||
/**
|
||||
* Add animation to the animation timeline.
|
||||
* @param at pointer to the animation timeline.
|
||||
* @param start_time the time the animation started on the timeline, note that start_time will override the value of delay.
|
||||
* @param a pointer to an animation.
|
||||
*/
|
||||
void lv_anim_timeline_add(lv_anim_timeline_t * at, uint32_t start_time, const lv_anim_t * a);
|
||||
|
||||
/**
|
||||
* Start the animation timeline.
|
||||
* @param at pointer to the animation timeline.
|
||||
* @return total time spent in animation timeline.
|
||||
*/
|
||||
uint32_t lv_anim_timeline_start(lv_anim_timeline_t * at);
|
||||
|
||||
/**
|
||||
* Pause the animation timeline.
|
||||
* @param at pointer to the animation timeline.
|
||||
*/
|
||||
void lv_anim_timeline_pause(lv_anim_timeline_t * at);
|
||||
|
||||
/**
|
||||
* Set the playback direction of the animation timeline.
|
||||
* @param at pointer to the animation timeline.
|
||||
* @param reverse whether to play in reverse.
|
||||
*/
|
||||
void lv_anim_timeline_set_reverse(lv_anim_timeline_t * at, bool reverse);
|
||||
|
||||
/**
|
||||
* Make the animation timeline repeat itself.
|
||||
* @param at pointer to the animation timeline.
|
||||
* @param cnt repeat count or `LV_ANIM_REPEAT_INFINITE` for infinite repetition. 0: to disable repetition.
|
||||
*/
|
||||
void lv_anim_timeline_set_repeat_count(lv_anim_timeline_t * at, uint32_t cnt);
|
||||
|
||||
/**
|
||||
* Set a delay before repeating the animation timeline.
|
||||
* @param at pointer to the animation timeline.
|
||||
* @param delay delay in milliseconds before repeating the animation timeline.
|
||||
*/
|
||||
void lv_anim_timeline_set_repeat_delay(lv_anim_timeline_t * at, uint32_t delay);
|
||||
|
||||
/**
|
||||
* Set the progress of the animation timeline.
|
||||
* @param at pointer to the animation timeline.
|
||||
* @param progress set value 0~65535 to map 0~100% animation progress.
|
||||
*/
|
||||
void lv_anim_timeline_set_progress(lv_anim_timeline_t * at, uint16_t progress);
|
||||
|
||||
/**
|
||||
* Get the time used to play the animation timeline.
|
||||
* @param at pointer to the animation timeline.
|
||||
* @return total time spent in animation timeline.
|
||||
*/
|
||||
uint32_t lv_anim_timeline_get_playtime(lv_anim_timeline_t * at);
|
||||
|
||||
/**
|
||||
* Get whether the animation timeline is played in reverse.
|
||||
* @param at pointer to the animation timeline.
|
||||
* @return return true if it is reverse playback.
|
||||
*/
|
||||
bool lv_anim_timeline_get_reverse(lv_anim_timeline_t * at);
|
||||
|
||||
/**
|
||||
* Get the progress of the animation timeline.
|
||||
* @param at pointer to the animation timeline.
|
||||
* @return return value 0~65535 to map 0~100% animation progress.
|
||||
*/
|
||||
uint16_t lv_anim_timeline_get_progress(lv_anim_timeline_t * at);
|
||||
|
||||
/**
|
||||
* Get repeat count of the animation timeline.
|
||||
* @param at pointer to the animation timeline.
|
||||
*/
|
||||
uint32_t lv_anim_timeline_get_repeat_count(lv_anim_timeline_t * at);
|
||||
|
||||
/**
|
||||
* Get repeat delay of the animation timeline.
|
||||
* @param at pointer to the animation timeline.
|
||||
*/
|
||||
uint32_t lv_anim_timeline_get_repeat_delay(lv_anim_timeline_t * at);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_ANIM_TIMELINE_H*/
|
||||
@@ -0,0 +1,254 @@
|
||||
/**
|
||||
* @file lv_area.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_AREA_H
|
||||
#define LV_AREA_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_conf_internal.h"
|
||||
#include "lv_types.h"
|
||||
#include "lv_math.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Represents a point on the screen.
|
||||
*/
|
||||
typedef struct {
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
} lv_point_t;
|
||||
|
||||
typedef struct {
|
||||
lv_value_precise_t x;
|
||||
lv_value_precise_t y;
|
||||
} lv_point_precise_t;
|
||||
|
||||
/** Represents an area of the screen.*/
|
||||
typedef struct {
|
||||
int32_t x1;
|
||||
int32_t y1;
|
||||
int32_t x2;
|
||||
int32_t y2;
|
||||
} lv_area_t;
|
||||
|
||||
/** Alignments*/
|
||||
|
||||
typedef enum {
|
||||
LV_ALIGN_DEFAULT = 0,
|
||||
LV_ALIGN_TOP_LEFT,
|
||||
LV_ALIGN_TOP_MID,
|
||||
LV_ALIGN_TOP_RIGHT,
|
||||
LV_ALIGN_BOTTOM_LEFT,
|
||||
LV_ALIGN_BOTTOM_MID,
|
||||
LV_ALIGN_BOTTOM_RIGHT,
|
||||
LV_ALIGN_LEFT_MID,
|
||||
LV_ALIGN_RIGHT_MID,
|
||||
LV_ALIGN_CENTER,
|
||||
|
||||
LV_ALIGN_OUT_TOP_LEFT,
|
||||
LV_ALIGN_OUT_TOP_MID,
|
||||
LV_ALIGN_OUT_TOP_RIGHT,
|
||||
LV_ALIGN_OUT_BOTTOM_LEFT,
|
||||
LV_ALIGN_OUT_BOTTOM_MID,
|
||||
LV_ALIGN_OUT_BOTTOM_RIGHT,
|
||||
LV_ALIGN_OUT_LEFT_TOP,
|
||||
LV_ALIGN_OUT_LEFT_MID,
|
||||
LV_ALIGN_OUT_LEFT_BOTTOM,
|
||||
LV_ALIGN_OUT_RIGHT_TOP,
|
||||
LV_ALIGN_OUT_RIGHT_MID,
|
||||
LV_ALIGN_OUT_RIGHT_BOTTOM,
|
||||
} lv_align_t;
|
||||
|
||||
typedef enum {
|
||||
LV_DIR_NONE = 0x00,
|
||||
LV_DIR_LEFT = (1 << 0),
|
||||
LV_DIR_RIGHT = (1 << 1),
|
||||
LV_DIR_TOP = (1 << 2),
|
||||
LV_DIR_BOTTOM = (1 << 3),
|
||||
LV_DIR_HOR = LV_DIR_LEFT | LV_DIR_RIGHT,
|
||||
LV_DIR_VER = LV_DIR_TOP | LV_DIR_BOTTOM,
|
||||
LV_DIR_ALL = LV_DIR_HOR | LV_DIR_VER,
|
||||
} lv_dir_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize an area
|
||||
* @param area_p pointer to an area
|
||||
* @param x1 left coordinate of the area
|
||||
* @param y1 top coordinate of the area
|
||||
* @param x2 right coordinate of the area
|
||||
* @param y2 bottom coordinate of the area
|
||||
*/
|
||||
void lv_area_set(lv_area_t * area_p, int32_t x1, int32_t y1, int32_t x2, int32_t y2);
|
||||
|
||||
/**
|
||||
* Copy an area
|
||||
* @param dest pointer to the destination area
|
||||
* @param src pointer to the source area
|
||||
*/
|
||||
inline static void lv_area_copy(lv_area_t * dest, const lv_area_t * src)
|
||||
{
|
||||
dest->x1 = src->x1;
|
||||
dest->y1 = src->y1;
|
||||
dest->x2 = src->x2;
|
||||
dest->y2 = src->y2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the width of an area
|
||||
* @param area_p pointer to an area
|
||||
* @return the width of the area (if x1 == x2 -> width = 1)
|
||||
*/
|
||||
int32_t lv_area_get_width(const lv_area_t * area_p);
|
||||
|
||||
/**
|
||||
* Get the height of an area
|
||||
* @param area_p pointer to an area
|
||||
* @return the height of the area (if y1 == y2 -> height = 1)
|
||||
*/
|
||||
int32_t lv_area_get_height(const lv_area_t * area_p);
|
||||
|
||||
/**
|
||||
* Set the width of an area
|
||||
* @param area_p pointer to an area
|
||||
* @param w the new width of the area (w == 1 makes x1 == x2)
|
||||
*/
|
||||
void lv_area_set_width(lv_area_t * area_p, int32_t w);
|
||||
|
||||
/**
|
||||
* Set the height of an area
|
||||
* @param area_p pointer to an area
|
||||
* @param h the new height of the area (h == 1 makes y1 == y2)
|
||||
*/
|
||||
void lv_area_set_height(lv_area_t * area_p, int32_t h);
|
||||
|
||||
/**
|
||||
* Return with area of an area (x * y)
|
||||
* @param area_p pointer to an area
|
||||
* @return size of area
|
||||
*/
|
||||
uint32_t lv_area_get_size(const lv_area_t * area_p);
|
||||
|
||||
void lv_area_increase(lv_area_t * area, int32_t w_extra, int32_t h_extra);
|
||||
|
||||
void lv_area_move(lv_area_t * area, int32_t x_ofs, int32_t y_ofs);
|
||||
|
||||
/**
|
||||
* Align an area to another
|
||||
* @param base an area where the other will be aligned
|
||||
* @param to_align the area to align
|
||||
* @param align `LV_ALIGN_...`
|
||||
* @param ofs_x X offset
|
||||
* @param ofs_y Y offset
|
||||
*/
|
||||
void lv_area_align(const lv_area_t * base, lv_area_t * to_align, lv_align_t align, int32_t ofs_x, int32_t ofs_y);
|
||||
|
||||
/**
|
||||
* Transform a point
|
||||
* @param point pointer to a point
|
||||
* @param angle angle with 0.1 resolutions (123 means 12.3°)
|
||||
* @param scale_x horizontal zoom, 256 means 100%
|
||||
* @param scale_y vertical zoom, 256 means 100%
|
||||
* @param pivot pointer to the pivot point of the transformation
|
||||
* @param zoom_first true: zoom first and rotate after that; else: opposite order
|
||||
*/
|
||||
void lv_point_transform(lv_point_t * point, int32_t angle, int32_t scale_x, int32_t scale_y, const lv_point_t * pivot,
|
||||
bool zoom_first);
|
||||
|
||||
/**
|
||||
* Transform an array of points
|
||||
* @param points pointer to an array of points
|
||||
* @param count number of points in the array
|
||||
* @param angle angle with 0.1 resolutions (123 means 12.3°)
|
||||
* @param scale_x horizontal zoom, 256 means 100%
|
||||
* @param scale_y vertical zoom, 256 means 100%
|
||||
* @param pivot pointer to the pivot point of the transformation
|
||||
* @param zoom_first true: zoom first and rotate after that; else: opposite order
|
||||
*/
|
||||
void lv_point_array_transform(lv_point_t * points, size_t count, int32_t angle, int32_t scale_x, int32_t scale_y,
|
||||
const lv_point_t * pivot,
|
||||
bool zoom_first);
|
||||
|
||||
lv_point_t lv_point_from_precise(const lv_point_precise_t * p);
|
||||
|
||||
lv_point_precise_t lv_point_to_precise(const lv_point_t * p);
|
||||
|
||||
void lv_point_set(lv_point_t * p, int32_t x, int32_t y);
|
||||
|
||||
void lv_point_precise_set(lv_point_precise_t * p, lv_value_precise_t x, lv_value_precise_t y);
|
||||
|
||||
void lv_point_swap(lv_point_t * p1, lv_point_t * p2);
|
||||
|
||||
void lv_point_precise_swap(lv_point_precise_t * p1, lv_point_precise_t * p2);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#define LV_COORD_TYPE_SHIFT (29U)
|
||||
|
||||
#define LV_COORD_TYPE_MASK (3 << LV_COORD_TYPE_SHIFT)
|
||||
#define LV_COORD_TYPE(x) ((x) & LV_COORD_TYPE_MASK) /*Extract type specifiers*/
|
||||
#define LV_COORD_PLAIN(x) ((x) & ~LV_COORD_TYPE_MASK) /*Remove type specifiers*/
|
||||
|
||||
#define LV_COORD_TYPE_PX (0 << LV_COORD_TYPE_SHIFT)
|
||||
#define LV_COORD_TYPE_SPEC (1 << LV_COORD_TYPE_SHIFT)
|
||||
#define LV_COORD_TYPE_PX_NEG (3 << LV_COORD_TYPE_SHIFT)
|
||||
|
||||
#define LV_COORD_IS_PX(x) (LV_COORD_TYPE(x) == LV_COORD_TYPE_PX || LV_COORD_TYPE(x) == LV_COORD_TYPE_PX_NEG)
|
||||
#define LV_COORD_IS_SPEC(x) (LV_COORD_TYPE(x) == LV_COORD_TYPE_SPEC)
|
||||
|
||||
#define LV_COORD_SET_SPEC(x) ((x) | LV_COORD_TYPE_SPEC)
|
||||
|
||||
/** Max coordinate value */
|
||||
#define LV_COORD_MAX ((1 << LV_COORD_TYPE_SHIFT) - 1)
|
||||
#define LV_COORD_MIN (-LV_COORD_MAX)
|
||||
|
||||
/*Special coordinates*/
|
||||
#define LV_SIZE_CONTENT LV_COORD_SET_SPEC(LV_COORD_MAX)
|
||||
#define LV_PCT_STORED_MAX (LV_COORD_MAX - 1)
|
||||
#if LV_PCT_STORED_MAX % 2 != 0
|
||||
#error LV_PCT_STORED_MAX should be an even number
|
||||
#endif
|
||||
#define LV_PCT_POS_MAX (LV_PCT_STORED_MAX / 2)
|
||||
#define LV_PCT(x) (LV_COORD_SET_SPEC(((x) < 0 ? (LV_PCT_POS_MAX - LV_MAX((x), -LV_PCT_POS_MAX)) : LV_MIN((x), LV_PCT_POS_MAX))))
|
||||
#define LV_COORD_IS_PCT(x) ((LV_COORD_IS_SPEC(x) && LV_COORD_PLAIN(x) <= LV_PCT_STORED_MAX))
|
||||
#define LV_COORD_GET_PCT(x) (LV_COORD_PLAIN(x) > LV_PCT_POS_MAX ? LV_PCT_POS_MAX - LV_COORD_PLAIN(x) : LV_COORD_PLAIN(x))
|
||||
|
||||
LV_EXPORT_CONST_INT(LV_COORD_MAX);
|
||||
LV_EXPORT_CONST_INT(LV_COORD_MIN);
|
||||
LV_EXPORT_CONST_INT(LV_SIZE_CONTENT);
|
||||
|
||||
/**
|
||||
* Convert a percentage value to `int32_t`.
|
||||
* Percentage values are stored in special range
|
||||
* @param x the percentage (0..1000)
|
||||
* @return a coordinate that stores the percentage
|
||||
*/
|
||||
int32_t lv_pct(int32_t x);
|
||||
|
||||
int32_t lv_pct_to_px(int32_t v, int32_t base);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,115 @@
|
||||
/**
|
||||
* @file lv_area_private.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_AREA_PRIVATE_H
|
||||
#define LV_AREA_PRIVATE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lv_area.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Set the position of an area (width and height will be kept)
|
||||
* @param area_p pointer to an area
|
||||
* @param x the new x coordinate of the area
|
||||
* @param y the new y coordinate of the area
|
||||
*/
|
||||
void lv_area_set_pos(lv_area_t * area_p, int32_t x, int32_t y);
|
||||
|
||||
/**
|
||||
* Get the common parts of two areas
|
||||
* @param res_p pointer to an area, the result will be stored her
|
||||
* @param a1_p pointer to the first area
|
||||
* @param a2_p pointer to the second area
|
||||
* @return false: the two area has NO common parts, res_p is invalid
|
||||
*/
|
||||
bool lv_area_intersect(lv_area_t * res_p, const lv_area_t * a1_p, const lv_area_t * a2_p);
|
||||
|
||||
/**
|
||||
* Get resulting sub areas after removing the common parts of two areas from the first area
|
||||
* @param res_p pointer to an array of areas with a count of 4, the resulting areas will be stored here
|
||||
* @param a1_p pointer to the first area
|
||||
* @param a2_p pointer to the second area
|
||||
* @return number of results (max 4) or -1 if no intersect
|
||||
*/
|
||||
int8_t lv_area_diff(lv_area_t res_p[], const lv_area_t * a1_p, const lv_area_t * a2_p);
|
||||
|
||||
/**
|
||||
* Join two areas into a third which involves the other two
|
||||
* @param a_res_p pointer to an area, the result will be stored here
|
||||
* @param a1_p pointer to the first area
|
||||
* @param a2_p pointer to the second area
|
||||
*/
|
||||
void lv_area_join(lv_area_t * a_res_p, const lv_area_t * a1_p, const lv_area_t * a2_p);
|
||||
|
||||
/**
|
||||
* Check if a point is on an area
|
||||
* @param a_p pointer to an area
|
||||
* @param p_p pointer to a point
|
||||
* @param radius radius of area (e.g. for rounded rectangle)
|
||||
* @return false:the point is out of the area
|
||||
*/
|
||||
bool lv_area_is_point_on(const lv_area_t * a_p, const lv_point_t * p_p, int32_t radius);
|
||||
|
||||
/**
|
||||
* Check if two area has common parts
|
||||
* @param a1_p pointer to an area.
|
||||
* @param a2_p pointer to another area
|
||||
* @return false: a1_p and a2_p has no common parts
|
||||
*/
|
||||
bool lv_area_is_on(const lv_area_t * a1_p, const lv_area_t * a2_p);
|
||||
|
||||
/**
|
||||
* Check if an area is fully on another
|
||||
* @param ain_p pointer to an area which could be in 'aholder_p'
|
||||
* @param aholder_p pointer to an area which could involve 'ain_p'
|
||||
* @param radius radius of `aholder_p` (e.g. for rounded rectangle)
|
||||
* @return true: `ain_p` is fully inside `aholder_p`
|
||||
*/
|
||||
bool lv_area_is_in(const lv_area_t * ain_p, const lv_area_t * aholder_p, int32_t radius);
|
||||
|
||||
/**
|
||||
* Check if an area is fully out of another
|
||||
* @param aout_p pointer to an area which could be in 'aholder_p'
|
||||
* @param aholder_p pointer to an area which could involve 'ain_p'
|
||||
* @param radius radius of `aholder_p` (e.g. for rounded rectangle)
|
||||
* @return true: `aout_p` is fully outside `aholder_p`
|
||||
*/
|
||||
bool lv_area_is_out(const lv_area_t * aout_p, const lv_area_t * aholder_p, int32_t radius);
|
||||
|
||||
/**
|
||||
* Check if 2 area is the same
|
||||
* @param a pointer to an area
|
||||
* @param b pointer to another area
|
||||
*/
|
||||
bool lv_area_is_equal(const lv_area_t * a, const lv_area_t * b);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_AREA_PRIVATE_H*/
|
||||
@@ -0,0 +1,205 @@
|
||||
/**
|
||||
* @file lv_array.h
|
||||
* Array. The elements are dynamically allocated by the 'lv_mem' module.
|
||||
*/
|
||||
|
||||
#ifndef LV_ARRAY_H
|
||||
#define LV_ARRAY_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_types.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
#ifndef LV_ARRAY_DEFAULT_CAPACITY
|
||||
#define LV_ARRAY_DEFAULT_CAPACITY 4
|
||||
#endif
|
||||
|
||||
#ifndef LV_ARRAY_DEFAULT_SHRINK_RATIO
|
||||
#define LV_ARRAY_DEFAULT_SHRINK_RATIO 2
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/** Description of a array*/
|
||||
struct _lv_array_t {
|
||||
uint8_t * data;
|
||||
uint32_t size;
|
||||
uint32_t capacity;
|
||||
uint32_t element_size;
|
||||
|
||||
bool inner_alloc; /* true: data is allocated by the array; false: data is allocated by the user */
|
||||
};
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Init an array.
|
||||
* @param array pointer to an `lv_array_t` variable to initialize
|
||||
* @param capacity the initial capacity of the array
|
||||
* @param element_size the size of an element in bytes
|
||||
*/
|
||||
void lv_array_init(lv_array_t * array, uint32_t capacity, uint32_t element_size);
|
||||
|
||||
/**
|
||||
* Init an array from a buffer.
|
||||
* @note The buffer must be large enough to store `capacity` elements. The array will not release the buffer and reallocate it.
|
||||
* The user must ensure that the buffer is valid during the lifetime of the array. And release the buffer when the array is no longer needed.
|
||||
* @param array pointer to an `lv_array_t` variable to initialize
|
||||
* @param buf pointer to a buffer to use as the array's data
|
||||
* @param capacity the initial capacity of the array
|
||||
* @param element_size the size of an element in bytes
|
||||
*/
|
||||
void lv_array_init_from_buf(lv_array_t * array, void * buf, uint32_t capacity, uint32_t element_size);
|
||||
|
||||
/**
|
||||
* Resize the array to the given capacity.
|
||||
* @note if the new capacity is smaller than the current size, the array will be truncated.
|
||||
* @param array pointer to an `lv_array_t` variable
|
||||
* @param new_capacity the new capacity of the array
|
||||
*/
|
||||
bool lv_array_resize(lv_array_t * array, uint32_t new_capacity);
|
||||
|
||||
/**
|
||||
* Deinit the array, and free the allocated memory
|
||||
* @param array pointer to an `lv_array_t` variable to deinitialize
|
||||
*/
|
||||
void lv_array_deinit(lv_array_t * array);
|
||||
|
||||
/**
|
||||
* Return how many elements are stored in the array.
|
||||
* @param array pointer to an `lv_array_t` variable
|
||||
* @return the number of elements stored in the array
|
||||
*/
|
||||
uint32_t lv_array_size(const lv_array_t * array);
|
||||
|
||||
/**
|
||||
* Return the capacity of the array, i.e. how many elements can be stored.
|
||||
* @param array pointer to an `lv_array_t` variable
|
||||
* @return the capacity of the array
|
||||
*/
|
||||
uint32_t lv_array_capacity(const lv_array_t * array);
|
||||
|
||||
/**
|
||||
* Return if the array is empty
|
||||
* @param array pointer to an `lv_array_t` variable
|
||||
* @return true: array is empty; false: array is not empty
|
||||
*/
|
||||
bool lv_array_is_empty(const lv_array_t * array);
|
||||
|
||||
/**
|
||||
* Return if the array is full
|
||||
* @param array pointer to an `lv_array_t` variable
|
||||
* @return true: array is full; false: array is not full
|
||||
*/
|
||||
bool lv_array_is_full(const lv_array_t * array);
|
||||
|
||||
/**
|
||||
* Copy an array to another.
|
||||
* @note this will create a new array with the same capacity and size as the source array.
|
||||
* @param target pointer to an `lv_array_t` variable to copy to
|
||||
* @param source pointer to an `lv_array_t` variable to copy from
|
||||
*/
|
||||
void lv_array_copy(lv_array_t * target, const lv_array_t * source);
|
||||
|
||||
/**
|
||||
* Remove all elements in array.
|
||||
* @param array pointer to an `lv_array_t` variable
|
||||
*/
|
||||
void lv_array_clear(lv_array_t * array);
|
||||
|
||||
/**
|
||||
* Shrink the memory capacity of array if necessary.
|
||||
* @param array pointer to an `lv_array_t` variable
|
||||
*/
|
||||
void lv_array_shrink(lv_array_t * array);
|
||||
|
||||
/**
|
||||
* Remove the element at the specified position in the array.
|
||||
* @param array pointer to an `lv_array_t` variable
|
||||
* @param index the index of the element to remove
|
||||
* @return LV_RESULT_OK: success, otherwise: error
|
||||
*/
|
||||
lv_result_t lv_array_remove(lv_array_t * array, uint32_t index);
|
||||
|
||||
/**
|
||||
* Remove from the array either a single element or a range of elements ([start, end)).
|
||||
* @note This effectively reduces the container size by the number of elements removed.
|
||||
* @note When start equals to end, the function has no effect.
|
||||
* @param array pointer to an `lv_array_t` variable
|
||||
* @param start the index of the first element to be removed
|
||||
* @param end the index of the first element that is not to be removed
|
||||
* @return LV_RESULT_OK: success, otherwise: error
|
||||
*/
|
||||
lv_result_t lv_array_erase(lv_array_t * array, uint32_t start, uint32_t end);
|
||||
|
||||
/**
|
||||
* Concatenate two arrays. Adds new elements to the end of the array.
|
||||
* @note The destination array is automatically expanded as necessary.
|
||||
* @param array pointer to an `lv_array_t` variable
|
||||
* @param other pointer to the array to concatenate
|
||||
* @return LV_RESULT_OK: success, otherwise: error
|
||||
*/
|
||||
lv_result_t lv_array_concat(lv_array_t * array, const lv_array_t * other);
|
||||
|
||||
/**
|
||||
* Push back element. Adds a new element to the end of the array.
|
||||
* If the array capacity is not enough for the new element, the array will be resized automatically.
|
||||
* @note If the element is NULL, it will be added as an empty element.
|
||||
* @param array pointer to an `lv_array_t` variable
|
||||
* @param element pointer to the element to add. NULL to push an empty element.
|
||||
* @return LV_RESULT_OK: success, otherwise: error
|
||||
*/
|
||||
lv_result_t lv_array_push_back(lv_array_t * array, const void * element);
|
||||
|
||||
/**
|
||||
* Assigns one content to the array, replacing its current content.
|
||||
* @param array pointer to an `lv_array_t` variable
|
||||
* @param index the index of the element to replace
|
||||
* @param value pointer to the elements to add
|
||||
* @return true: success; false: error
|
||||
*/
|
||||
lv_result_t lv_array_assign(lv_array_t * array, uint32_t index, const void * value);
|
||||
|
||||
/**
|
||||
* Returns a pointer to the element at position n in the array.
|
||||
* @param array pointer to an `lv_array_t` variable
|
||||
* @param index the index of the element to return
|
||||
* @return a pointer to the requested element, NULL if `index` is out of range
|
||||
*/
|
||||
void * lv_array_at(const lv_array_t * array, uint32_t index);
|
||||
|
||||
/**
|
||||
* Returns a pointer to the first element in the array.
|
||||
* @param array pointer to an `lv_array_t` variable
|
||||
* @return a pointer to the first element in the array
|
||||
*/
|
||||
void * lv_array_front(const lv_array_t * array);
|
||||
|
||||
/**
|
||||
* Returns a pointer to the last element in the array.
|
||||
* @param array pointer to an `lv_array_t` variable
|
||||
*/
|
||||
void * lv_array_back(const lv_array_t * array);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* @file lv_assert.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_ASSERT_H
|
||||
#define LV_ASSERT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_conf_internal.h"
|
||||
#include "lv_log.h"
|
||||
#include "../stdlib/lv_mem.h"
|
||||
#include LV_ASSERT_HANDLER_INCLUDE
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#define LV_ASSERT(expr) \
|
||||
do { \
|
||||
if(!(expr)) { \
|
||||
LV_LOG_ERROR("Asserted at expression: %s", #expr); \
|
||||
LV_ASSERT_HANDLER \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define LV_ASSERT_MSG(expr, msg) \
|
||||
do { \
|
||||
if(!(expr)) { \
|
||||
LV_LOG_ERROR("Asserted at expression: %s (%s)", #expr, msg); \
|
||||
LV_ASSERT_HANDLER \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define LV_ASSERT_FORMAT_MSG(expr, format, ...) \
|
||||
do { \
|
||||
if(!(expr)) { \
|
||||
LV_LOG_ERROR("Asserted at expression: %s " format , #expr, __VA_ARGS__); \
|
||||
LV_ASSERT_HANDLER \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/*-----------------
|
||||
* ASSERTS
|
||||
*-----------------*/
|
||||
|
||||
#if LV_USE_ASSERT_NULL
|
||||
# define LV_ASSERT_NULL(p) LV_ASSERT_MSG(p != NULL, "NULL pointer");
|
||||
#else
|
||||
# define LV_ASSERT_NULL(p)
|
||||
#endif
|
||||
|
||||
#if LV_USE_ASSERT_MALLOC
|
||||
# define LV_ASSERT_MALLOC(p) LV_ASSERT_MSG(p != NULL, "Out of memory");
|
||||
#else
|
||||
# define LV_ASSERT_MALLOC(p)
|
||||
#endif
|
||||
|
||||
#if LV_USE_ASSERT_MEM_INTEGRITY
|
||||
# define LV_ASSERT_MEM_INTEGRITY() LV_ASSERT_MSG(lv_mem_test() == LV_RESULT_OK, "Memory integrity error");
|
||||
#else
|
||||
# define LV_ASSERT_MEM_INTEGRITY()
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_ASSERT_H*/
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* @file lv_async.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_ASYNC_H
|
||||
#define LV_ASYNC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lv_types.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Type for async callback.
|
||||
*/
|
||||
typedef void (*lv_async_cb_t)(void *);
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Call an asynchronous function the next time lv_timer_handler() is run. This function is likely to return
|
||||
* **before** the call actually happens!
|
||||
* @param async_xcb a callback which is the task itself.
|
||||
* (the 'x' in the argument name indicates that it's not a fully generic function because it not follows
|
||||
* the `func_name(object, callback, ...)` convention)
|
||||
* @param user_data custom parameter
|
||||
*/
|
||||
lv_result_t lv_async_call(lv_async_cb_t async_xcb, void * user_data);
|
||||
|
||||
/**
|
||||
* Cancel an asynchronous function call
|
||||
* @param async_xcb a callback which is the task itself.
|
||||
* @param user_data custom parameter
|
||||
*/
|
||||
lv_result_t lv_async_call_cancel(lv_async_cb_t async_xcb, void * user_data);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_ASYNC_H*/
|
||||
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* @file lv_bidi.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_BIDI_H
|
||||
#define LV_BIDI_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_conf_internal.h"
|
||||
#include "lv_types.h"
|
||||
#include "lv_text.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
/** Special non printable strong characters.
|
||||
* They can be inserted to texts to affect the run's direction */
|
||||
#define LV_BIDI_LRO "\xE2\x80\xAD" /*U+202D*/
|
||||
#define LV_BIDI_RLO "\xE2\x80\xAE" /*U+202E*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef enum {
|
||||
LV_BASE_DIR_LTR = 0x00,
|
||||
LV_BASE_DIR_RTL = 0x01,
|
||||
LV_BASE_DIR_AUTO = 0x02,
|
||||
|
||||
LV_BASE_DIR_NEUTRAL = 0x20,
|
||||
LV_BASE_DIR_WEAK = 0x21,
|
||||
} lv_base_dir_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
#if LV_USE_BIDI
|
||||
|
||||
/**
|
||||
* Get the real text alignment from the a text alignment, base direction and a text.
|
||||
* @param align LV_TEXT_ALIGN_..., write back the calculated align here (LV_TEXT_ALIGN_LEFT/RIGHT/CENTER)
|
||||
* @param base_dir LV_BASE_DIR_..., write the calculated base dir here (LV_BASE_DIR_LTR/RTL)
|
||||
* @param txt a text, used with LV_BASE_DIR_AUTO to determine the base direction
|
||||
*/
|
||||
void lv_bidi_calculate_align(lv_text_align_t * align, lv_base_dir_t * base_dir, const char * txt);
|
||||
|
||||
/**
|
||||
* Set custom neutrals string
|
||||
* @param neutrals default " \t\n\r.,:;'\"`!?%/\\-=()[]{}<>@#&$|"
|
||||
*/
|
||||
void lv_bidi_set_custom_neutrals_static(const char * neutrals);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#else /*LV_USE_BIDI*/
|
||||
/**
|
||||
* For compatibility if LV_USE_BIDI = 0
|
||||
* Get the real text alignment from the a text alignment, base direction and a text.
|
||||
* @param align For LV_TEXT_ALIGN_AUTO give LV_TEXT_ALIGN_LEFT else leave unchanged, write back the calculated align here
|
||||
* @param base_dir Unused
|
||||
* @param txt Unused
|
||||
*/
|
||||
static inline void lv_bidi_calculate_align(lv_text_align_t * align, lv_base_dir_t * base_dir, const char * txt)
|
||||
{
|
||||
LV_UNUSED(txt);
|
||||
LV_UNUSED(base_dir);
|
||||
if(*align == LV_TEXT_ALIGN_AUTO) * align = LV_TEXT_ALIGN_LEFT;
|
||||
}
|
||||
#endif /*LV_USE_BIDI*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_BIDI_H*/
|
||||
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* @file lv_bidi_private.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_BIDI_PRIVATE_H
|
||||
#define LV_BIDI_PRIVATE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lv_bidi.h"
|
||||
#if LV_USE_BIDI
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Convert a text to get the characters in the correct visual order according to
|
||||
* Unicode Bidirectional Algorithm
|
||||
* @param str_in the text to process
|
||||
* @param str_out store the result here. Has the be `strlen(str_in)` length
|
||||
* @param base_dir `LV_BASE_DIR_LTR` or `LV_BASE_DIR_RTL`
|
||||
*/
|
||||
void lv_bidi_process(const char * str_in, char * str_out, lv_base_dir_t base_dir);
|
||||
|
||||
/**
|
||||
* Auto-detect the direction of a text based on the first strong character
|
||||
* @param txt the text to process
|
||||
* @return `LV_BASE_DIR_LTR` or `LV_BASE_DIR_RTL`
|
||||
*/
|
||||
lv_base_dir_t lv_bidi_detect_base_dir(const char * txt);
|
||||
|
||||
/**
|
||||
* Get the logical position of a character in a line
|
||||
* @param str_in the input string. Can be only one line.
|
||||
* @param bidi_txt internally the text is bidi processed which buffer can be get here.
|
||||
* If not required anymore has to freed with `lv_free()`
|
||||
* Can be `NULL` is unused
|
||||
* @param len length of the line in character count
|
||||
* @param base_dir base direction of the text: `LV_BASE_DIR_LTR` or `LV_BASE_DIR_RTL`
|
||||
* @param visual_pos the visual character position which logical position should be get
|
||||
* @param is_rtl tell the char at `visual_pos` is RTL or LTR context
|
||||
* @return the logical character position
|
||||
*/
|
||||
uint16_t lv_bidi_get_logical_pos(const char * str_in, char ** bidi_txt, uint32_t len, lv_base_dir_t base_dir,
|
||||
uint32_t visual_pos, bool * is_rtl);
|
||||
|
||||
/**
|
||||
* Get the visual position of a character in a line
|
||||
* @param str_in the input string. Can be only one line.
|
||||
* @param bidi_txt internally the text is bidi processed which buffer can be get here.
|
||||
* If not required anymore has to freed with `lv_free()`
|
||||
* Can be `NULL` is unused
|
||||
* @param len length of the line in character count
|
||||
* @param base_dir base direction of the text: `LV_BASE_DIR_LTR` or `LV_BASE_DIR_RTL`
|
||||
* @param logical_pos the logical character position which visual position should be get
|
||||
* @param is_rtl tell the char at `logical_pos` is RTL or LTR context
|
||||
* @return the visual character position
|
||||
*/
|
||||
uint16_t lv_bidi_get_visual_pos(const char * str_in, char ** bidi_txt, uint16_t len, lv_base_dir_t base_dir,
|
||||
uint32_t logical_pos, bool * is_rtl);
|
||||
|
||||
/**
|
||||
* Bidi process a paragraph of text
|
||||
* @param str_in the string to process
|
||||
* @param str_out store the result here
|
||||
* @param len length of the text
|
||||
* @param base_dir base dir of the text
|
||||
* @param pos_conv_out an `uint16_t` array to store the related logical position of the character.
|
||||
* Can be `NULL` is unused
|
||||
* @param pos_conv_len length of `pos_conv_out` in element count
|
||||
*/
|
||||
void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len, lv_base_dir_t base_dir,
|
||||
uint16_t * pos_conv_out, uint16_t pos_conv_len);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_BIDI*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_BIDI_PRIVATE_H*/
|
||||
@@ -0,0 +1,191 @@
|
||||
/**
|
||||
* @file lv_circle_buf.h
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LV_CIRCLE_BUF_H
|
||||
#define LV_CIRCLE_BUF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lv_types.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef bool (*lv_circle_buf_fill_cb_t)(void * buf, uint32_t buff_len, int32_t index, void * user_data);
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a circle buffer
|
||||
* @param capacity the maximum number of elements in the buffer
|
||||
* @param element_size the size of an element in bytes
|
||||
* @return pointer to the created buffer
|
||||
*/
|
||||
lv_circle_buf_t * lv_circle_buf_create(uint32_t capacity, uint32_t element_size);
|
||||
|
||||
/**
|
||||
* Create a circle buffer from an existing buffer
|
||||
* @param buf pointer to a buffer
|
||||
* @param capacity the maximum number of elements in the buffer
|
||||
* @param element_size the size of an element in bytes
|
||||
* @return pointer to the created buffer
|
||||
*/
|
||||
lv_circle_buf_t * lv_circle_buf_create_from_buf(void * buf, uint32_t capacity, uint32_t element_size);
|
||||
|
||||
/**
|
||||
* Create a circle buffer from an existing array
|
||||
* @param array pointer to an array
|
||||
* @return pointer to the created buffer
|
||||
*/
|
||||
lv_circle_buf_t * lv_circle_buf_create_from_array(const lv_array_t * array);
|
||||
|
||||
/**
|
||||
* Resize the buffer
|
||||
* @param circle_buf pointer to a buffer
|
||||
* @param capacity the new capacity of the buffer
|
||||
* @return LV_RESULT_OK: the buffer is resized; LV_RESULT_INVALID: the buffer is not resized
|
||||
*/
|
||||
lv_result_t lv_circle_buf_resize(lv_circle_buf_t * circle_buf, uint32_t capacity);
|
||||
|
||||
/**
|
||||
* Destroy a circle buffer
|
||||
* @param circle_buf pointer to buffer
|
||||
*/
|
||||
void lv_circle_buf_destroy(lv_circle_buf_t * circle_buf);
|
||||
|
||||
/**
|
||||
* Get the size of the buffer
|
||||
* @param circle_buf pointer to buffer
|
||||
* @return the number of elements in the buffer
|
||||
*/
|
||||
uint32_t lv_circle_buf_size(const lv_circle_buf_t * circle_buf);
|
||||
|
||||
/**
|
||||
* Get the capacity of the buffer
|
||||
* @param circle_buf pointer to buffer
|
||||
* @return the maximum number of elements in the buffer
|
||||
*/
|
||||
uint32_t lv_circle_buf_capacity(const lv_circle_buf_t * circle_buf);
|
||||
|
||||
/**
|
||||
* Get the remaining space in the buffer
|
||||
* @param circle_buf pointer to buffer
|
||||
* @return the number of elements that can be written to the buffer
|
||||
*/
|
||||
uint32_t lv_circle_buf_remain(const lv_circle_buf_t * circle_buf);
|
||||
|
||||
/**
|
||||
* Check if the buffer is empty
|
||||
* @param circle_buf pointer to buffer
|
||||
* @return true: the buffer is empty; false: the buffer is not empty
|
||||
*/
|
||||
bool lv_circle_buf_is_empty(const lv_circle_buf_t * circle_buf);
|
||||
|
||||
/**
|
||||
* Check if the buffer is full
|
||||
* @param circle_buf pointer to buffer
|
||||
* @return true: the buffer is full; false: the buffer is not full
|
||||
*/
|
||||
bool lv_circle_buf_is_full(const lv_circle_buf_t * circle_buf);
|
||||
|
||||
/**
|
||||
* Reset the buffer
|
||||
* @param circle_buf pointer to buffer
|
||||
* @return LV_RESULT_OK: the buffer is reset; LV_RESULT_INVALID: the buffer is not reset
|
||||
*/
|
||||
void lv_circle_buf_reset(lv_circle_buf_t * circle_buf);
|
||||
|
||||
/**
|
||||
* Get the head of the buffer
|
||||
* @param circle_buf pointer to buffer
|
||||
* @return pointer to the head of the buffer
|
||||
*/
|
||||
void * lv_circle_buf_head(const lv_circle_buf_t * circle_buf);
|
||||
|
||||
/**
|
||||
* Get the tail of the buffer
|
||||
* @param circle_buf pointer to buffer
|
||||
* @return pointer to the tail of the buffer
|
||||
*/
|
||||
void * lv_circle_buf_tail(const lv_circle_buf_t * circle_buf);
|
||||
|
||||
/**
|
||||
* Read a value
|
||||
* @param circle_buf pointer to buffer
|
||||
* @param data pointer to a variable to store the read value
|
||||
* @return LV_RESULT_OK: the value is read; LV_RESULT_INVALID: the value is not read
|
||||
*/
|
||||
lv_result_t lv_circle_buf_read(lv_circle_buf_t * circle_buf, void * data);
|
||||
|
||||
/**
|
||||
* Write a value
|
||||
* @param circle_buf pointer to buffer
|
||||
* @param data pointer to the value to write
|
||||
* @return LV_RESULT_OK: the value is written; LV_RESULT_INVALID: the value is not written
|
||||
*/
|
||||
lv_result_t lv_circle_buf_write(lv_circle_buf_t * circle_buf, const void * data);
|
||||
|
||||
/**
|
||||
* Fill the buffer with values
|
||||
* @param circle_buf pointer to buffer
|
||||
* @param count the number of values to fill
|
||||
* @param fill_cb the callback function to fill the buffer
|
||||
* @param user_data
|
||||
* @return the number of values filled
|
||||
*/
|
||||
uint32_t lv_circle_buf_fill(lv_circle_buf_t * circle_buf, uint32_t count, lv_circle_buf_fill_cb_t fill_cb,
|
||||
void * user_data);
|
||||
|
||||
/**
|
||||
* Skip a value
|
||||
* @param circle_buf pointer to buffer
|
||||
* @return LV_RESULT_OK: the value is skipped; LV_RESULT_INVALID: the value is not skipped
|
||||
*/
|
||||
lv_result_t lv_circle_buf_skip(lv_circle_buf_t * circle_buf);
|
||||
|
||||
/**
|
||||
* Peek a value
|
||||
* @param circle_buf pointer to buffer
|
||||
* @param data pointer to a variable to store the peeked value
|
||||
* @return LV_RESULT_OK: the value is peeked; LV_RESULT_INVALID: the value is not peeked
|
||||
*/
|
||||
lv_result_t lv_circle_buf_peek(const lv_circle_buf_t * circle_buf, void * data);
|
||||
|
||||
/**
|
||||
* Peek a value at an index
|
||||
* @param circle_buf pointer to buffer
|
||||
* @param index the index of the value to peek, if the index is greater than the size of the buffer, it will return looply.
|
||||
* @param data pointer to a variable to store the peeked value
|
||||
* @return LV_RESULT_OK: the value is peeked; LV_RESULT_INVALID: the value is not peeked
|
||||
*/
|
||||
lv_result_t lv_circle_buf_peek_at(const lv_circle_buf_t * circle_buf, uint32_t index, void * data);
|
||||
|
||||
/*************************
|
||||
* GLOBAL VARIABLES
|
||||
*************************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_CIRCLE_BUF_H*/
|
||||
@@ -0,0 +1,429 @@
|
||||
/**
|
||||
* @file lv_color.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_COLOR_H
|
||||
#define LV_COLOR_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_conf_internal.h"
|
||||
#include "lv_assert.h"
|
||||
#include "lv_math.h"
|
||||
#include "lv_types.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
LV_EXPORT_CONST_INT(LV_COLOR_DEPTH);
|
||||
|
||||
#if LV_COLOR_DEPTH == 8
|
||||
#define LV_COLOR_NATIVE_WITH_ALPHA_SIZE 2
|
||||
#elif LV_COLOR_DEPTH == 16
|
||||
#define LV_COLOR_NATIVE_WITH_ALPHA_SIZE 3
|
||||
#elif LV_COLOR_DEPTH == 24
|
||||
#define LV_COLOR_NATIVE_WITH_ALPHA_SIZE 4
|
||||
#elif LV_COLOR_DEPTH == 32
|
||||
#define LV_COLOR_NATIVE_WITH_ALPHA_SIZE 4
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Opacity percentages.
|
||||
*/
|
||||
|
||||
enum {
|
||||
LV_OPA_TRANSP = 0,
|
||||
LV_OPA_0 = 0,
|
||||
LV_OPA_10 = 25,
|
||||
LV_OPA_20 = 51,
|
||||
LV_OPA_30 = 76,
|
||||
LV_OPA_40 = 102,
|
||||
LV_OPA_50 = 127,
|
||||
LV_OPA_60 = 153,
|
||||
LV_OPA_70 = 178,
|
||||
LV_OPA_80 = 204,
|
||||
LV_OPA_90 = 229,
|
||||
LV_OPA_100 = 255,
|
||||
LV_OPA_COVER = 255,
|
||||
};
|
||||
|
||||
#define LV_OPA_MIN 2 /**< Opacities below this will be transparent */
|
||||
#define LV_OPA_MAX 253 /**< Opacities above this will fully cover */
|
||||
|
||||
/**
|
||||
* Get the pixel size of a color format in bits, bpp
|
||||
* @param cf a color format (`LV_COLOR_FORMAT_...`)
|
||||
* @return the pixel size in bits
|
||||
* @sa lv_color_format_get_bpp
|
||||
*/
|
||||
#define LV_COLOR_FORMAT_GET_BPP(cf) ( \
|
||||
(cf) == LV_COLOR_FORMAT_I1 ? 1 : \
|
||||
(cf) == LV_COLOR_FORMAT_A1 ? 1 : \
|
||||
(cf) == LV_COLOR_FORMAT_I2 ? 2 : \
|
||||
(cf) == LV_COLOR_FORMAT_A2 ? 2 : \
|
||||
(cf) == LV_COLOR_FORMAT_I4 ? 4 : \
|
||||
(cf) == LV_COLOR_FORMAT_A4 ? 4 : \
|
||||
(cf) == LV_COLOR_FORMAT_L8 ? 8 : \
|
||||
(cf) == LV_COLOR_FORMAT_A8 ? 8 : \
|
||||
(cf) == LV_COLOR_FORMAT_I8 ? 8 : \
|
||||
(cf) == LV_COLOR_FORMAT_AL88 ? 16 : \
|
||||
(cf) == LV_COLOR_FORMAT_RGB565 ? 16 : \
|
||||
(cf) == LV_COLOR_FORMAT_RGB565A8 ? 16 : \
|
||||
(cf) == LV_COLOR_FORMAT_YUY2 ? 16 : \
|
||||
(cf) == LV_COLOR_FORMAT_ARGB8565 ? 24 : \
|
||||
(cf) == LV_COLOR_FORMAT_RGB888 ? 24 : \
|
||||
(cf) == LV_COLOR_FORMAT_ARGB8888 ? 32 : \
|
||||
(cf) == LV_COLOR_FORMAT_XRGB8888 ? 32 : \
|
||||
0 \
|
||||
)
|
||||
|
||||
/**
|
||||
* Get the pixel size of a color format in bytes
|
||||
* @param cf a color format (`LV_COLOR_FORMAT_...`)
|
||||
* @return the pixel size in bytes
|
||||
* @sa lv_color_format_get_size
|
||||
*/
|
||||
#define LV_COLOR_FORMAT_GET_SIZE(cf) ((LV_COLOR_FORMAT_GET_BPP(cf) + 7) >> 3)
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef struct {
|
||||
uint8_t blue;
|
||||
uint8_t green;
|
||||
uint8_t red;
|
||||
} lv_color_t;
|
||||
|
||||
typedef struct {
|
||||
uint16_t blue : 5;
|
||||
uint16_t green : 6;
|
||||
uint16_t red : 5;
|
||||
} lv_color16_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t blue;
|
||||
uint8_t green;
|
||||
uint8_t red;
|
||||
uint8_t alpha;
|
||||
} lv_color32_t;
|
||||
|
||||
typedef struct {
|
||||
uint16_t h;
|
||||
uint8_t s;
|
||||
uint8_t v;
|
||||
} lv_color_hsv_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t lumi;
|
||||
uint8_t alpha;
|
||||
} lv_color16a_t;
|
||||
|
||||
typedef enum {
|
||||
LV_COLOR_FORMAT_UNKNOWN = 0,
|
||||
|
||||
LV_COLOR_FORMAT_RAW = 0x01,
|
||||
LV_COLOR_FORMAT_RAW_ALPHA = 0x02,
|
||||
|
||||
/*<=1 byte (+alpha) formats*/
|
||||
LV_COLOR_FORMAT_L8 = 0x06,
|
||||
LV_COLOR_FORMAT_I1 = 0x07,
|
||||
LV_COLOR_FORMAT_I2 = 0x08,
|
||||
LV_COLOR_FORMAT_I4 = 0x09,
|
||||
LV_COLOR_FORMAT_I8 = 0x0A,
|
||||
LV_COLOR_FORMAT_A8 = 0x0E,
|
||||
|
||||
/*2 byte (+alpha) formats*/
|
||||
LV_COLOR_FORMAT_RGB565 = 0x12,
|
||||
LV_COLOR_FORMAT_ARGB8565 = 0x13, /**< Not supported by sw renderer yet. */
|
||||
LV_COLOR_FORMAT_RGB565A8 = 0x14, /**< Color array followed by Alpha array*/
|
||||
LV_COLOR_FORMAT_AL88 = 0x15, /**< L8 with alpha >*/
|
||||
|
||||
/*3 byte (+alpha) formats*/
|
||||
LV_COLOR_FORMAT_RGB888 = 0x0F,
|
||||
LV_COLOR_FORMAT_ARGB8888 = 0x10,
|
||||
LV_COLOR_FORMAT_XRGB8888 = 0x11,
|
||||
|
||||
/*Formats not supported by software renderer but kept here so GPU can use it*/
|
||||
LV_COLOR_FORMAT_A1 = 0x0B,
|
||||
LV_COLOR_FORMAT_A2 = 0x0C,
|
||||
LV_COLOR_FORMAT_A4 = 0x0D,
|
||||
|
||||
/* reference to https://wiki.videolan.org/YUV/ */
|
||||
/*YUV planar formats*/
|
||||
LV_COLOR_FORMAT_YUV_START = 0x20,
|
||||
LV_COLOR_FORMAT_I420 = LV_COLOR_FORMAT_YUV_START, /*YUV420 planar(3 plane)*/
|
||||
LV_COLOR_FORMAT_I422 = 0x21, /*YUV422 planar(3 plane)*/
|
||||
LV_COLOR_FORMAT_I444 = 0x22, /*YUV444 planar(3 plane)*/
|
||||
LV_COLOR_FORMAT_I400 = 0x23, /*YUV400 no chroma channel*/
|
||||
LV_COLOR_FORMAT_NV21 = 0x24, /*YUV420 planar(2 plane), UV plane in 'V, U, V, U'*/
|
||||
LV_COLOR_FORMAT_NV12 = 0x25, /*YUV420 planar(2 plane), UV plane in 'U, V, U, V'*/
|
||||
|
||||
/*YUV packed formats*/
|
||||
LV_COLOR_FORMAT_YUY2 = 0x26, /*YUV422 packed like 'Y U Y V'*/
|
||||
LV_COLOR_FORMAT_UYVY = 0x27, /*YUV422 packed like 'U Y V Y'*/
|
||||
|
||||
LV_COLOR_FORMAT_YUV_END = LV_COLOR_FORMAT_UYVY,
|
||||
|
||||
/*Color formats in which LVGL can render*/
|
||||
#if LV_COLOR_DEPTH == 1
|
||||
LV_COLOR_FORMAT_NATIVE = LV_COLOR_FORMAT_I1,
|
||||
LV_COLOR_FORMAT_NATIVE_WITH_ALPHA = LV_COLOR_FORMAT_I1,
|
||||
#elif LV_COLOR_DEPTH == 8
|
||||
LV_COLOR_FORMAT_NATIVE = LV_COLOR_FORMAT_L8,
|
||||
LV_COLOR_FORMAT_NATIVE_WITH_ALPHA = LV_COLOR_FORMAT_AL88,
|
||||
#elif LV_COLOR_DEPTH == 16
|
||||
LV_COLOR_FORMAT_NATIVE = LV_COLOR_FORMAT_RGB565,
|
||||
LV_COLOR_FORMAT_NATIVE_WITH_ALPHA = LV_COLOR_FORMAT_RGB565A8,
|
||||
#elif LV_COLOR_DEPTH == 24
|
||||
LV_COLOR_FORMAT_NATIVE = LV_COLOR_FORMAT_RGB888,
|
||||
LV_COLOR_FORMAT_NATIVE_WITH_ALPHA = LV_COLOR_FORMAT_ARGB8888,
|
||||
#elif LV_COLOR_DEPTH == 32
|
||||
LV_COLOR_FORMAT_NATIVE = LV_COLOR_FORMAT_XRGB8888,
|
||||
LV_COLOR_FORMAT_NATIVE_WITH_ALPHA = LV_COLOR_FORMAT_ARGB8888,
|
||||
#else
|
||||
#error "LV_COLOR_DEPTH should be 1, 8, 16, 24 or 32"
|
||||
#endif
|
||||
|
||||
} lv_color_format_t;
|
||||
|
||||
#define LV_COLOR_FORMAT_IS_ALPHA_ONLY(cf) ((cf) >= LV_COLOR_FORMAT_A1 && (cf) <= LV_COLOR_FORMAT_A8)
|
||||
#define LV_COLOR_FORMAT_IS_INDEXED(cf) ((cf) >= LV_COLOR_FORMAT_I1 && (cf) <= LV_COLOR_FORMAT_I8)
|
||||
#define LV_COLOR_FORMAT_IS_YUV(cf) ((cf) >= LV_COLOR_FORMAT_YUV_START && (cf) <= LV_COLOR_FORMAT_YUV_END)
|
||||
#define LV_COLOR_INDEXED_PALETTE_SIZE(cf) ((cf) == LV_COLOR_FORMAT_I1 ? 2 :\
|
||||
(cf) == LV_COLOR_FORMAT_I2 ? 4 :\
|
||||
(cf) == LV_COLOR_FORMAT_I4 ? 16 :\
|
||||
(cf) == LV_COLOR_FORMAT_I8 ? 256 : 0)
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#define LV_COLOR_MAKE(r8, g8, b8) {b8, g8, r8}
|
||||
|
||||
#define LV_OPA_MIX2(a1, a2) (((int32_t)(a1) * (a2)) >> 8)
|
||||
#define LV_OPA_MIX3(a1, a2, a3) (((int32_t)(a1) * (a2) * (a3)) >> 16)
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Get the pixel size of a color format in bits, bpp
|
||||
* @param cf a color format (`LV_COLOR_FORMAT_...`)
|
||||
* @return the pixel size in bits
|
||||
* @sa LV_COLOR_FORMAT_GET_BPP
|
||||
*/
|
||||
uint8_t lv_color_format_get_bpp(lv_color_format_t cf);
|
||||
|
||||
/**
|
||||
* Get the pixel size of a color format in bytes
|
||||
* @param cf a color format (`LV_COLOR_FORMAT_...`)
|
||||
* @return the pixel size in bytes
|
||||
* @sa LV_COLOR_FORMAT_GET_SIZE
|
||||
*/
|
||||
uint8_t lv_color_format_get_size(lv_color_format_t cf);
|
||||
|
||||
/**
|
||||
* Check if a color format has alpha channel or not
|
||||
* @param src_cf a color format (`LV_COLOR_FORMAT_...`)
|
||||
* @return true: has alpha channel; false: doesn't have alpha channel
|
||||
*/
|
||||
bool lv_color_format_has_alpha(lv_color_format_t src_cf);
|
||||
|
||||
/**
|
||||
* Create an ARGB8888 color from RGB888 + alpha
|
||||
* @param color an RGB888 color
|
||||
* @param opa the alpha value
|
||||
* @return the ARGB8888 color
|
||||
*/
|
||||
lv_color32_t lv_color_to_32(lv_color_t color, lv_opa_t opa);
|
||||
|
||||
/**
|
||||
* Convert an RGB888 color to an integer
|
||||
* @param c an RGB888 color
|
||||
* @return `c` as an integer
|
||||
*/
|
||||
uint32_t lv_color_to_int(lv_color_t c);
|
||||
|
||||
/**
|
||||
* Check if two RGB888 color are equal
|
||||
* @param c1 the first color
|
||||
* @param c2 the second color
|
||||
* @return true: equal
|
||||
*/
|
||||
bool lv_color_eq(lv_color_t c1, lv_color_t c2);
|
||||
|
||||
/**
|
||||
* Check if two ARGB8888 color are equal
|
||||
* @param c1 the first color
|
||||
* @param c2 the second color
|
||||
* @return true: equal
|
||||
*/
|
||||
bool lv_color32_eq(lv_color32_t c1, lv_color32_t c2);
|
||||
|
||||
/**
|
||||
* Create a color from 0x000000..0xffffff input
|
||||
* @param c the hex input
|
||||
* @return the color
|
||||
*/
|
||||
lv_color_t lv_color_hex(uint32_t c);
|
||||
|
||||
/**
|
||||
* Create an RGB888 color
|
||||
* @param r the red channel (0..255)
|
||||
* @param g the green channel (0..255)
|
||||
* @param b the blue channel (0..255)
|
||||
* @return the color
|
||||
*/
|
||||
lv_color_t lv_color_make(uint8_t r, uint8_t g, uint8_t b);
|
||||
|
||||
/**
|
||||
* Create an ARGB8888 color
|
||||
* @param r the red channel (0..255)
|
||||
* @param g the green channel (0..255)
|
||||
* @param b the blue channel (0..255)
|
||||
* @param a the alpha channel (0..255)
|
||||
* @return the color
|
||||
*/
|
||||
lv_color32_t lv_color32_make(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
|
||||
|
||||
/**
|
||||
* Create a color from 0x000..0xfff input
|
||||
* @param c the hex input (e.g. 0x123 will be 0x112233)
|
||||
* @return the color
|
||||
*/
|
||||
lv_color_t lv_color_hex3(uint32_t c);
|
||||
|
||||
/**
|
||||
* Convert am RGB888 color to RGB565 stored in `uint16_t`
|
||||
* @param color and RGB888 color
|
||||
* @return `color` as RGB565 on `uin16_t`
|
||||
*/
|
||||
uint16_t lv_color_to_u16(lv_color_t color);
|
||||
|
||||
/**
|
||||
* Convert am RGB888 color to XRGB8888 stored in `uint32_t`
|
||||
* @param color and RGB888 color
|
||||
* @return `color` as XRGB8888 on `uin32_t` (the alpha channel is always set to 0xFF)
|
||||
*/
|
||||
uint32_t lv_color_to_u32(lv_color_t color);
|
||||
|
||||
/**
|
||||
* Mix two RGB565 colors
|
||||
* @param c1 the first color (typically the foreground color)
|
||||
* @param c2 the second color (typically the background color)
|
||||
* @param mix 0..255, or LV_OPA_0/10/20...
|
||||
* @return mix == 0: c2
|
||||
* mix == 255: c1
|
||||
* mix == 128: 0.5 x c1 + 0.5 x c2
|
||||
*/
|
||||
uint16_t LV_ATTRIBUTE_FAST_MEM lv_color_16_16_mix(uint16_t c1, uint16_t c2, uint8_t mix);
|
||||
|
||||
/**
|
||||
* Mix white to a color
|
||||
* @param c the base color
|
||||
* @param lvl the intensity of white (0: no change, 255: fully white)
|
||||
* @return the mixed color
|
||||
*/
|
||||
lv_color_t lv_color_lighten(lv_color_t c, lv_opa_t lvl);
|
||||
|
||||
/**
|
||||
* Mix black to a color
|
||||
* @param c the base color
|
||||
* @param lvl the intensity of black (0: no change, 255: fully black)
|
||||
* @return the mixed color
|
||||
*/
|
||||
lv_color_t lv_color_darken(lv_color_t c, lv_opa_t lvl);
|
||||
|
||||
/**
|
||||
* Convert a HSV color to RGB
|
||||
* @param h hue [0..359]
|
||||
* @param s saturation [0..100]
|
||||
* @param v value [0..100]
|
||||
* @return the given RGB color in RGB (with LV_COLOR_DEPTH depth)
|
||||
*/
|
||||
lv_color_t lv_color_hsv_to_rgb(uint16_t h, uint8_t s, uint8_t v);
|
||||
|
||||
/**
|
||||
* Convert a 32-bit RGB color to HSV
|
||||
* @param r8 8-bit red
|
||||
* @param g8 8-bit green
|
||||
* @param b8 8-bit blue
|
||||
* @return the given RGB color in HSV
|
||||
*/
|
||||
lv_color_hsv_t lv_color_rgb_to_hsv(uint8_t r8, uint8_t g8, uint8_t b8);
|
||||
|
||||
/**
|
||||
* Convert a color to HSV
|
||||
* @param color color
|
||||
* @return the given color in HSV
|
||||
*/
|
||||
lv_color_hsv_t lv_color_to_hsv(lv_color_t color);
|
||||
|
||||
/*Source: https://vuetifyjs.com/en/styles/colors/#material-colors*/
|
||||
|
||||
/**
|
||||
* A helper for white color
|
||||
* @return a white color
|
||||
*/
|
||||
lv_color_t lv_color_white(void);
|
||||
|
||||
/**
|
||||
* A helper for black color
|
||||
* @return a black color
|
||||
*/
|
||||
lv_color_t lv_color_black(void);
|
||||
|
||||
void lv_color_premultiply(lv_color32_t * c);
|
||||
|
||||
void lv_color16_premultiply(lv_color16_t * c, lv_opa_t a);
|
||||
|
||||
/**
|
||||
* Get the luminance of a color: luminance = 0.3 R + 0.59 G + 0.11 B
|
||||
* @param c a color
|
||||
* @return the brightness [0..255]
|
||||
*/
|
||||
uint8_t lv_color_luminance(lv_color_t c);
|
||||
|
||||
/**
|
||||
* Get the luminance of a color16: luminance = 0.3 R + 0.59 G + 0.11 B
|
||||
* @param c a color
|
||||
* @return the brightness [0..255]
|
||||
*/
|
||||
uint8_t lv_color16_luminance(const lv_color16_t c);
|
||||
|
||||
/**
|
||||
* Get the luminance of a color24: luminance = 0.3 R + 0.59 G + 0.11 B
|
||||
* @param c a color
|
||||
* @return the brightness [0..255]
|
||||
*/
|
||||
uint8_t lv_color24_luminance(const uint8_t * c);
|
||||
|
||||
/**
|
||||
* Get the luminance of a color32: luminance = 0.3 R + 0.59 G + 0.11 B
|
||||
* @param c a color
|
||||
* @return the brightness [0..255]
|
||||
*/
|
||||
uint8_t lv_color32_luminance(lv_color32_t c);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#include "lv_palette.h"
|
||||
#include "lv_color_op.h"
|
||||
|
||||
LV_ATTRIBUTE_EXTERN_DATA extern const lv_color_filter_dsc_t lv_color_filter_shade;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_COLOR_H*/
|
||||
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* @file lv_color_op.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_COLOR_OP_H
|
||||
#define LV_COLOR_OP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_assert.h"
|
||||
#include "lv_math.h"
|
||||
#include "lv_color.h"
|
||||
#include "lv_types.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
struct _lv_color_filter_dsc_t;
|
||||
|
||||
typedef lv_color_t (*lv_color_filter_cb_t)(const struct _lv_color_filter_dsc_t *, lv_color_t, lv_opa_t);
|
||||
|
||||
struct _lv_color_filter_dsc_t {
|
||||
lv_color_filter_cb_t filter_cb;
|
||||
void * user_data;
|
||||
};
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Mix two colors with a given ratio.
|
||||
* @param c1 the first color to mix (usually the foreground)
|
||||
* @param c2 the second color to mix (usually the background)
|
||||
* @param mix The ratio of the colors. 0: full `c2`, 255: full `c1`, 127: half `c1` and half`c2`
|
||||
* @return the mixed color
|
||||
*/
|
||||
lv_color_t LV_ATTRIBUTE_FAST_MEM lv_color_mix(lv_color_t c1, lv_color_t c2, uint8_t mix);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fg
|
||||
* @param bg
|
||||
* @return
|
||||
* @note Use bg.alpha in the return value
|
||||
* @note Use fg.alpha as mix ratio
|
||||
*/
|
||||
lv_color32_t lv_color_mix32(lv_color32_t fg, lv_color32_t bg);
|
||||
|
||||
/**
|
||||
* Get the brightness of a color
|
||||
* @param c a color
|
||||
* @return brightness in range [0..255]
|
||||
*/
|
||||
uint8_t lv_color_brightness(lv_color_t c);
|
||||
|
||||
void lv_color_filter_dsc_init(lv_color_filter_dsc_t * dsc, lv_color_filter_cb_t cb);
|
||||
|
||||
/**********************
|
||||
* PREDEFINED COLORS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_COLOR_H*/
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @file lv_color_op_private.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_COLOR_OP_PRIVATE_H
|
||||
#define LV_COLOR_OP_PRIVATE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lv_color_op.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_COLOR_OP_PRIVATE_H*/
|
||||
@@ -0,0 +1,224 @@
|
||||
/**
|
||||
* @file lv_event.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_EVENT_H
|
||||
#define LV_EVENT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_types.h"
|
||||
#include "../lv_conf_internal.h"
|
||||
|
||||
#include "lv_array.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef void (*lv_event_cb_t)(lv_event_t * e);
|
||||
|
||||
/**
|
||||
* Type of event being sent to the object.
|
||||
*/
|
||||
typedef enum {
|
||||
LV_EVENT_ALL = 0,
|
||||
|
||||
/** Input device events*/
|
||||
LV_EVENT_PRESSED, /**< The object has been pressed*/
|
||||
LV_EVENT_PRESSING, /**< The object is being pressed (called continuously while pressing)*/
|
||||
LV_EVENT_PRESS_LOST, /**< The object is still being pressed but slid cursor/finger off of the object */
|
||||
LV_EVENT_SHORT_CLICKED, /**< The object was pressed for a short period of time, then released it. Not called if scrolled.*/
|
||||
LV_EVENT_SINGLE_CLICKED, /**< Called for the first short click within a small distance and short time*/
|
||||
LV_EVENT_DOUBLE_CLICKED, /**< Called for the second short click within small distance and short time*/
|
||||
LV_EVENT_TRIPLE_CLICKED, /**< Called for the third short click within small distance and short time*/
|
||||
LV_EVENT_LONG_PRESSED, /**< Object has been pressed for at least `long_press_time`. Not called if scrolled.*/
|
||||
LV_EVENT_LONG_PRESSED_REPEAT, /**< Called after `long_press_time` in every `long_press_repeat_time` ms. Not called if scrolled.*/
|
||||
LV_EVENT_CLICKED, /**< Called on release if not scrolled (regardless to long press)*/
|
||||
LV_EVENT_RELEASED, /**< Called in every cases when the object has been released*/
|
||||
LV_EVENT_SCROLL_BEGIN, /**< Scrolling begins. The event parameter is a pointer to the animation of the scroll. Can be modified*/
|
||||
LV_EVENT_SCROLL_THROW_BEGIN,
|
||||
LV_EVENT_SCROLL_END, /**< Scrolling ends*/
|
||||
LV_EVENT_SCROLL, /**< Scrolling*/
|
||||
LV_EVENT_GESTURE, /**< A gesture is detected. Get the gesture with `lv_indev_get_gesture_dir(lv_indev_active());` */
|
||||
LV_EVENT_KEY, /**< A key is sent to the object. Get the key with `lv_indev_get_key(lv_indev_active());`*/
|
||||
LV_EVENT_ROTARY, /**< An encoder or wheel was rotated. Get the rotation count with `lv_event_get_rotary_diff(e);`*/
|
||||
LV_EVENT_FOCUSED, /**< The object is focused*/
|
||||
LV_EVENT_DEFOCUSED, /**< The object is defocused*/
|
||||
LV_EVENT_LEAVE, /**< The object is defocused but still selected*/
|
||||
LV_EVENT_HIT_TEST, /**< Perform advanced hit-testing*/
|
||||
LV_EVENT_INDEV_RESET, /**< Indev has been reset*/
|
||||
LV_EVENT_HOVER_OVER, /**< Indev hover over object*/
|
||||
LV_EVENT_HOVER_LEAVE, /**< Indev hover leave object*/
|
||||
|
||||
/** Drawing events*/
|
||||
LV_EVENT_COVER_CHECK, /**< Check if the object fully covers an area. The event parameter is `lv_cover_check_info_t *`.*/
|
||||
LV_EVENT_REFR_EXT_DRAW_SIZE, /**< Get the required extra draw area around the object (e.g. for shadow). The event parameter is `int32_t *` to store the size.*/
|
||||
LV_EVENT_DRAW_MAIN_BEGIN, /**< Starting the main drawing phase*/
|
||||
LV_EVENT_DRAW_MAIN, /**< Perform the main drawing*/
|
||||
LV_EVENT_DRAW_MAIN_END, /**< Finishing the main drawing phase*/
|
||||
LV_EVENT_DRAW_POST_BEGIN, /**< Starting the post draw phase (when all children are drawn)*/
|
||||
LV_EVENT_DRAW_POST, /**< Perform the post draw phase (when all children are drawn)*/
|
||||
LV_EVENT_DRAW_POST_END, /**< Finishing the post draw phase (when all children are drawn)*/
|
||||
LV_EVENT_DRAW_TASK_ADDED, /**< Adding a draw task */
|
||||
|
||||
/** Special events*/
|
||||
LV_EVENT_VALUE_CHANGED, /**< The object's value has changed (i.e. slider moved)*/
|
||||
LV_EVENT_INSERT, /**< A text is inserted to the object. The event data is `char *` being inserted.*/
|
||||
LV_EVENT_REFRESH, /**< Notify the object to refresh something on it (for the user)*/
|
||||
LV_EVENT_READY, /**< A process has finished*/
|
||||
LV_EVENT_CANCEL, /**< A process has been cancelled */
|
||||
|
||||
/** Other events*/
|
||||
LV_EVENT_CREATE, /**< Object is being created*/
|
||||
LV_EVENT_DELETE, /**< Object is being deleted*/
|
||||
LV_EVENT_CHILD_CHANGED, /**< Child was removed, added, or its size, position were changed */
|
||||
LV_EVENT_CHILD_CREATED, /**< Child was created, always bubbles up to all parents*/
|
||||
LV_EVENT_CHILD_DELETED, /**< Child was deleted, always bubbles up to all parents*/
|
||||
LV_EVENT_SCREEN_UNLOAD_START, /**< A screen unload started, fired immediately when scr_load is called*/
|
||||
LV_EVENT_SCREEN_LOAD_START, /**< A screen load started, fired when the screen change delay is expired*/
|
||||
LV_EVENT_SCREEN_LOADED, /**< A screen was loaded*/
|
||||
LV_EVENT_SCREEN_UNLOADED, /**< A screen was unloaded*/
|
||||
LV_EVENT_SIZE_CHANGED, /**< Object coordinates/size have changed*/
|
||||
LV_EVENT_STYLE_CHANGED, /**< Object's style has changed*/
|
||||
LV_EVENT_LAYOUT_CHANGED, /**< The children position has changed due to a layout recalculation*/
|
||||
LV_EVENT_GET_SELF_SIZE, /**< Get the internal size of a widget*/
|
||||
|
||||
/** Events of optional LVGL components*/
|
||||
LV_EVENT_INVALIDATE_AREA,
|
||||
LV_EVENT_RESOLUTION_CHANGED,
|
||||
LV_EVENT_COLOR_FORMAT_CHANGED,
|
||||
LV_EVENT_REFR_REQUEST,
|
||||
LV_EVENT_REFR_START,
|
||||
LV_EVENT_REFR_READY,
|
||||
LV_EVENT_RENDER_START,
|
||||
LV_EVENT_RENDER_READY,
|
||||
LV_EVENT_FLUSH_START,
|
||||
LV_EVENT_FLUSH_FINISH,
|
||||
LV_EVENT_FLUSH_WAIT_START,
|
||||
LV_EVENT_FLUSH_WAIT_FINISH,
|
||||
|
||||
LV_EVENT_VSYNC,
|
||||
|
||||
LV_EVENT_LAST, /** Number of default events*/
|
||||
|
||||
LV_EVENT_PREPROCESS = 0x8000, /** This is a flag that can be set with an event so it's processed
|
||||
before the class default event processing */
|
||||
LV_EVENT_MARKED_DELETING = 0x10000,
|
||||
} lv_event_code_t;
|
||||
|
||||
typedef struct {
|
||||
lv_array_t array;
|
||||
uint8_t is_traversing: 1; /**< True: the list is being nested traversed */
|
||||
uint8_t has_marked_deleting: 1; /**< True: the list has marked deleting objects
|
||||
when some of events are marked as deleting */
|
||||
} lv_event_list_t;
|
||||
|
||||
/**
|
||||
* @brief Event callback.
|
||||
* Events are used to notify the user of some action being taken on the object.
|
||||
* For details, see ::lv_event_t.
|
||||
*/
|
||||
|
||||
lv_result_t lv_event_send(lv_event_list_t * list, lv_event_t * e, bool preprocess);
|
||||
|
||||
lv_event_dsc_t * lv_event_add(lv_event_list_t * list, lv_event_cb_t cb, lv_event_code_t filter, void * user_data);
|
||||
bool lv_event_remove_dsc(lv_event_list_t * list, lv_event_dsc_t * dsc);
|
||||
|
||||
uint32_t lv_event_get_count(lv_event_list_t * list);
|
||||
|
||||
lv_event_dsc_t * lv_event_get_dsc(lv_event_list_t * list, uint32_t index);
|
||||
|
||||
lv_event_cb_t lv_event_dsc_get_cb(lv_event_dsc_t * dsc);
|
||||
|
||||
void * lv_event_dsc_get_user_data(lv_event_dsc_t * dsc);
|
||||
|
||||
bool lv_event_remove(lv_event_list_t * list, uint32_t index);
|
||||
|
||||
void lv_event_remove_all(lv_event_list_t * list);
|
||||
|
||||
/**
|
||||
* Get the object originally targeted by the event. It's the same even if the event is bubbled.
|
||||
* @param e pointer to the event descriptor
|
||||
* @return the target of the event_code
|
||||
*/
|
||||
void * lv_event_get_target(lv_event_t * e);
|
||||
|
||||
/**
|
||||
* Get the current target of the event. It's the object which event handler being called.
|
||||
* If the event is not bubbled it's the same as "normal" target.
|
||||
* @param e pointer to the event descriptor
|
||||
* @return pointer to the current target of the event_code
|
||||
*/
|
||||
void * lv_event_get_current_target(lv_event_t * e);
|
||||
|
||||
/**
|
||||
* Get the event code of an event
|
||||
* @param e pointer to the event descriptor
|
||||
* @return the event code. (E.g. `LV_EVENT_CLICKED`, `LV_EVENT_FOCUSED`, etc)
|
||||
*/
|
||||
lv_event_code_t lv_event_get_code(lv_event_t * e);
|
||||
|
||||
/**
|
||||
* Get the parameter passed when the event was sent
|
||||
* @param e pointer to the event descriptor
|
||||
* @return pointer to the parameter
|
||||
*/
|
||||
void * lv_event_get_param(lv_event_t * e);
|
||||
|
||||
/**
|
||||
* Get the user_data passed when the event was registered on the object
|
||||
* @param e pointer to the event descriptor
|
||||
* @return pointer to the user_data
|
||||
*/
|
||||
void * lv_event_get_user_data(lv_event_t * e);
|
||||
|
||||
/**
|
||||
* Stop the event from bubbling.
|
||||
* This is only valid when called in the middle of an event processing chain.
|
||||
* @param e pointer to the event descriptor
|
||||
*/
|
||||
void lv_event_stop_bubbling(lv_event_t * e);
|
||||
|
||||
/**
|
||||
* Stop processing this event.
|
||||
* This is only valid when called in the middle of an event processing chain.
|
||||
* @param e pointer to the event descriptor
|
||||
*/
|
||||
void lv_event_stop_processing(lv_event_t * e);
|
||||
|
||||
/**
|
||||
* Register a new, custom event ID.
|
||||
* It can be used the same way as e.g. `LV_EVENT_CLICKED` to send custom events
|
||||
* @return the new event id
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* uint32_t LV_EVENT_MINE = 0;
|
||||
* ...
|
||||
* e = lv_event_register_id();
|
||||
* ...
|
||||
* lv_obj_send_event(obj, LV_EVENT_MINE, &some_data);
|
||||
* @endcode
|
||||
*/
|
||||
uint32_t lv_event_register_id(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_EVENT_H*/
|
||||
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
* @file lv_event_private.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_EVENT_PRIVATE_H
|
||||
#define LV_EVENT_PRIVATE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lv_event.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
struct _lv_event_dsc_t {
|
||||
lv_event_cb_t cb;
|
||||
void * user_data;
|
||||
uint32_t filter;
|
||||
};
|
||||
|
||||
struct _lv_event_t {
|
||||
void * current_target;
|
||||
void * original_target;
|
||||
lv_event_code_t code;
|
||||
void * user_data;
|
||||
void * param;
|
||||
lv_event_t * prev;
|
||||
uint8_t deleted : 1;
|
||||
uint8_t stop_processing : 1;
|
||||
uint8_t stop_bubbling : 1;
|
||||
};
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
void lv_event_push(lv_event_t * e);
|
||||
|
||||
void lv_event_pop(lv_event_t * e);
|
||||
|
||||
/**
|
||||
* Nested events can be called and one of them might belong to an object that is being deleted.
|
||||
* Mark this object's `event_temp_data` deleted to know that its `lv_obj_send_event` should return `LV_RESULT_INVALID`
|
||||
* @param target pointer to an event target which was deleted
|
||||
*/
|
||||
void lv_event_mark_deleted(void * target);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_EVENT_PRIVATE_H*/
|
||||
@@ -0,0 +1,258 @@
|
||||
/**
|
||||
* @file lv_fs.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_FS_H
|
||||
#define LV_FS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_conf_internal.h"
|
||||
#include "lv_types.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_FS_MAX_FN_LENGTH 64
|
||||
#define LV_FS_MAX_PATH_LENGTH 256
|
||||
|
||||
#define LV_FS_CACHE_FROM_BUFFER UINT32_MAX
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Errors in the file system module.
|
||||
*/
|
||||
typedef enum {
|
||||
LV_FS_RES_OK = 0,
|
||||
LV_FS_RES_HW_ERR, /*Low level hardware error*/
|
||||
LV_FS_RES_FS_ERR, /*Error in the file system structure*/
|
||||
LV_FS_RES_NOT_EX, /*Driver, file or directory is not exists*/
|
||||
LV_FS_RES_FULL, /*Disk full*/
|
||||
LV_FS_RES_LOCKED, /*The file is already opened*/
|
||||
LV_FS_RES_DENIED, /*Access denied. Check 'fs_open' modes and write protect*/
|
||||
LV_FS_RES_BUSY, /*The file system now can't handle it, try later*/
|
||||
LV_FS_RES_TOUT, /*Process time outed*/
|
||||
LV_FS_RES_NOT_IMP, /*Requested function is not implemented*/
|
||||
LV_FS_RES_OUT_OF_MEM, /*Not enough memory for an internal operation*/
|
||||
LV_FS_RES_INV_PARAM, /*Invalid parameter among arguments*/
|
||||
LV_FS_RES_UNKNOWN, /*Other unknown error*/
|
||||
} lv_fs_res_t;
|
||||
|
||||
/**
|
||||
* File open mode.
|
||||
*/
|
||||
typedef enum {
|
||||
LV_FS_MODE_WR = 0x01,
|
||||
LV_FS_MODE_RD = 0x02,
|
||||
} lv_fs_mode_t;
|
||||
|
||||
/**
|
||||
* Seek modes.
|
||||
*/
|
||||
typedef enum {
|
||||
LV_FS_SEEK_SET = 0x00, /**< Set the position from absolutely (from the start of file)*/
|
||||
LV_FS_SEEK_CUR = 0x01, /**< Set the position from the current position*/
|
||||
LV_FS_SEEK_END = 0x02, /**< Set the position from the end of the file*/
|
||||
} lv_fs_whence_t;
|
||||
|
||||
struct _lv_fs_drv_t;
|
||||
typedef struct _lv_fs_drv_t lv_fs_drv_t;
|
||||
struct _lv_fs_drv_t {
|
||||
char letter;
|
||||
uint32_t cache_size;
|
||||
bool (*ready_cb)(lv_fs_drv_t * drv);
|
||||
|
||||
void * (*open_cb)(lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode);
|
||||
lv_fs_res_t (*close_cb)(lv_fs_drv_t * drv, void * file_p);
|
||||
lv_fs_res_t (*read_cb)(lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br);
|
||||
lv_fs_res_t (*write_cb)(lv_fs_drv_t * drv, void * file_p, const void * buf, uint32_t btw, uint32_t * bw);
|
||||
lv_fs_res_t (*seek_cb)(lv_fs_drv_t * drv, void * file_p, uint32_t pos, lv_fs_whence_t whence);
|
||||
lv_fs_res_t (*tell_cb)(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p);
|
||||
|
||||
void * (*dir_open_cb)(lv_fs_drv_t * drv, const char * path);
|
||||
lv_fs_res_t (*dir_read_cb)(lv_fs_drv_t * drv, void * rddir_p, char * fn, uint32_t fn_len);
|
||||
lv_fs_res_t (*dir_close_cb)(lv_fs_drv_t * drv, void * rddir_p);
|
||||
|
||||
void * user_data; /**< Custom file user data*/
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
void * file_d;
|
||||
lv_fs_drv_t * drv;
|
||||
lv_fs_file_cache_t * cache;
|
||||
} lv_fs_file_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
void * dir_d;
|
||||
lv_fs_drv_t * drv;
|
||||
} lv_fs_dir_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize a file system driver with default values.
|
||||
* It is used to ensure all fields have known values and not memory junk.
|
||||
* After it you can set the fields.
|
||||
* @param drv pointer to driver variable to initialize
|
||||
*/
|
||||
void lv_fs_drv_init(lv_fs_drv_t * drv);
|
||||
|
||||
/**
|
||||
* Add a new drive
|
||||
* @param drv pointer to an lv_fs_drv_t structure which is inited with the
|
||||
* corresponding function pointers. Only pointer is saved, so the
|
||||
* driver should be static or dynamically allocated.
|
||||
*/
|
||||
void lv_fs_drv_register(lv_fs_drv_t * drv);
|
||||
|
||||
/**
|
||||
* Give a pointer to a driver from its letter
|
||||
* @param letter the driver letter
|
||||
* @return pointer to a driver or NULL if not found
|
||||
*/
|
||||
lv_fs_drv_t * lv_fs_get_drv(char letter);
|
||||
|
||||
/**
|
||||
* Test if a drive is ready or not. If the `ready` function was not initialized `true` will be
|
||||
* returned.
|
||||
* @param letter letter of the drive
|
||||
* @return true: drive is ready; false: drive is not ready
|
||||
*/
|
||||
bool lv_fs_is_ready(char letter);
|
||||
|
||||
/**
|
||||
* Open a file
|
||||
* @param file_p pointer to a lv_fs_file_t variable
|
||||
* @param path path to the file beginning with the driver letter (e.g. S:/folder/file.txt)
|
||||
* @param mode read: FS_MODE_RD, write: FS_MODE_WR, both: FS_MODE_RD | FS_MODE_WR
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
lv_fs_res_t lv_fs_open(lv_fs_file_t * file_p, const char * path, lv_fs_mode_t mode);
|
||||
|
||||
/**
|
||||
* Make a path object for the memory-mapped file compatible with the file system interface
|
||||
* @param path path to a lv_fs_path_ex object
|
||||
* @param letter the letter of the driver. E.g. `LV_FS_MEMFS_LETTER`
|
||||
* @param buf address of the memory buffer
|
||||
* @param size size of the memory buffer in bytes
|
||||
*/
|
||||
void lv_fs_make_path_from_buffer(lv_fs_path_ex_t * path, char letter, const void * buf, uint32_t size);
|
||||
|
||||
/**
|
||||
* Close an already opened file
|
||||
* @param file_p pointer to a lv_fs_file_t variable
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
lv_fs_res_t lv_fs_close(lv_fs_file_t * file_p);
|
||||
|
||||
/**
|
||||
* Read from a file
|
||||
* @param file_p pointer to a lv_fs_file_t variable
|
||||
* @param buf pointer to a buffer where the read bytes are stored
|
||||
* @param btr Bytes To Read
|
||||
* @param br the number of real read bytes (Bytes Read). NULL if unused.
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
lv_fs_res_t lv_fs_read(lv_fs_file_t * file_p, void * buf, uint32_t btr, uint32_t * br);
|
||||
|
||||
/**
|
||||
* Write into a file
|
||||
* @param file_p pointer to a lv_fs_file_t variable
|
||||
* @param buf pointer to a buffer with the bytes to write
|
||||
* @param btw Bytes To Write
|
||||
* @param bw the number of real written bytes (Bytes Written). NULL if unused.
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
lv_fs_res_t lv_fs_write(lv_fs_file_t * file_p, const void * buf, uint32_t btw, uint32_t * bw);
|
||||
|
||||
/**
|
||||
* Set the position of the 'cursor' (read write pointer) in a file
|
||||
* @param file_p pointer to a lv_fs_file_t variable
|
||||
* @param pos the new position expressed in bytes index (0: start of file)
|
||||
* @param whence tells from where to set position. See lv_fs_whence_t
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
lv_fs_res_t lv_fs_seek(lv_fs_file_t * file_p, uint32_t pos, lv_fs_whence_t whence);
|
||||
|
||||
/**
|
||||
* Give the position of the read write pointer
|
||||
* @param file_p pointer to a lv_fs_file_t variable
|
||||
* @param pos pointer to store the position of the read write pointer
|
||||
* @return LV_FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
lv_fs_res_t lv_fs_tell(lv_fs_file_t * file_p, uint32_t * pos);
|
||||
|
||||
/**
|
||||
* Initialize a 'fs_dir_t' variable for directory reading
|
||||
* @param rddir_p pointer to a 'lv_fs_dir_t' variable
|
||||
* @param path path to a directory
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
lv_fs_res_t lv_fs_dir_open(lv_fs_dir_t * rddir_p, const char * path);
|
||||
|
||||
/**
|
||||
* Read the next filename form a directory.
|
||||
* The name of the directories will begin with '/'
|
||||
* @param rddir_p pointer to an initialized 'fs_dir_t' variable
|
||||
* @param fn pointer to a buffer to store the filename
|
||||
* @param fn_len length of the buffer to store the filename
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
lv_fs_res_t lv_fs_dir_read(lv_fs_dir_t * rddir_p, char * fn, uint32_t fn_len);
|
||||
|
||||
/**
|
||||
* Close the directory reading
|
||||
* @param rddir_p pointer to an initialized 'fs_dir_t' variable
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
lv_fs_res_t lv_fs_dir_close(lv_fs_dir_t * rddir_p);
|
||||
|
||||
/**
|
||||
* Fill a buffer with the letters of existing drivers
|
||||
* @param buf buffer to store the letters ('\0' added after the last letter)
|
||||
* @return the buffer
|
||||
*/
|
||||
char * lv_fs_get_letters(char * buf);
|
||||
|
||||
/**
|
||||
* Return with the extension of the filename
|
||||
* @param fn string with a filename
|
||||
* @return pointer to the beginning extension or empty string if no extension
|
||||
*/
|
||||
const char * lv_fs_get_ext(const char * fn);
|
||||
|
||||
/**
|
||||
* Step up one level
|
||||
* @param path pointer to a file name
|
||||
* @return the truncated file name
|
||||
*/
|
||||
char * lv_fs_up(char * path);
|
||||
|
||||
/**
|
||||
* Get the last element of a path (e.g. U:/folder/file -> file)
|
||||
* @param path pointer to a file name
|
||||
* @return pointer to the beginning of the last element in the path
|
||||
*/
|
||||
const char * lv_fs_get_last(const char * path);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_FS_H*/
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* @file lv_fs_private.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_FS_PRIVATE_H
|
||||
#define LV_FS_PRIVATE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lv_fs.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
struct _lv_fs_file_cache_t {
|
||||
uint32_t start;
|
||||
uint32_t end;
|
||||
uint32_t file_position;
|
||||
void * buffer;
|
||||
};
|
||||
|
||||
/** Extended path object to specify buffer for memory-mapped files */
|
||||
struct _lv_fs_path_ex_t {
|
||||
char path[4]; /**< This is needed to make it compatible with a normal path */
|
||||
const void * buffer;
|
||||
uint32_t size;
|
||||
};
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the File system interface
|
||||
*/
|
||||
void lv_fs_init(void);
|
||||
|
||||
/**
|
||||
* Deinitialize the File system interface
|
||||
*/
|
||||
void lv_fs_deinit(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_FS_PRIVATE_H*/
|
||||
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* @file lv_iter.h
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LV_ITER_H
|
||||
#define LV_ITER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lv_types.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef lv_result_t (*lv_iter_next_cb)(void * instance, void * context, void * elem);
|
||||
typedef void (*lv_iter_inspect_cb)(void * elem);
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create an iterator based on an instance, and then the next element of the iterator can be obtained through lv_iter_next,
|
||||
* In order to obtain the next operation in a unified and abstract way.
|
||||
* @param instance The instance to be iterated
|
||||
* @param elem_size The size of the element to be iterated in bytes
|
||||
* @param context_size The size of the context to be passed to the next_cb in bytes
|
||||
* @param next_cb The callback function to get the next element
|
||||
* @return The iterator object
|
||||
*/
|
||||
lv_iter_t * lv_iter_create(void * instance, uint32_t elem_size, uint32_t context_size, lv_iter_next_cb next_cb);
|
||||
|
||||
/**
|
||||
* Get the context of the iterator. You can use it to store some temporary variables associated with current iterator..
|
||||
* @param iter `lv_iter_t` object create before
|
||||
* @return the iter context
|
||||
*/
|
||||
void * lv_iter_get_context(const lv_iter_t * iter);
|
||||
|
||||
/**
|
||||
* Destroy the iterator object, and release the context. Other resources allocated by the user are not released.
|
||||
* The user needs to release it by itself.
|
||||
* @param iter `lv_iter_t` object create before
|
||||
*/
|
||||
void lv_iter_destroy(lv_iter_t * iter);
|
||||
|
||||
/**
|
||||
* Get the next element of the iterator.
|
||||
* @param iter `lv_iter_t` object create before
|
||||
* @param elem The pointer to store the next element
|
||||
* @return LV_RESULT_OK: Get the next element successfully
|
||||
* LV_RESULT_INVALID: The next element is invalid
|
||||
*/
|
||||
lv_result_t lv_iter_next(lv_iter_t * iter, void * elem);
|
||||
|
||||
/**
|
||||
* Make the iterator peekable, which means that the user can peek the next element without advancing the iterator.
|
||||
* @param iter `lv_iter_t` object create before
|
||||
* @param capacity The capacity of the peek buffer
|
||||
*/
|
||||
void lv_iter_make_peekable(lv_iter_t * iter, uint32_t capacity);
|
||||
|
||||
/**
|
||||
* Peek the next element of the iterator without advancing the iterator.
|
||||
* @param iter `lv_iter_t` object create before
|
||||
* @param elem The pointer to store the next element
|
||||
* @return LV_RESULT_OK: Peek the next element successfully
|
||||
* LV_RESULT_INVALID: The next element is invalid
|
||||
*/
|
||||
lv_result_t lv_iter_peek(lv_iter_t * iter, void * elem);
|
||||
|
||||
/**
|
||||
* Only advance the iterator without getting the next element.
|
||||
* @param iter `lv_iter_t` object create before
|
||||
* @return LV_RESULT_OK: Peek the next element successfully
|
||||
* LV_RESULT_INVALID: The next element is invalid
|
||||
*/
|
||||
lv_result_t lv_iter_peek_advance(lv_iter_t * iter);
|
||||
|
||||
/**
|
||||
* Reset the peek cursor to the `next` cursor.
|
||||
* @param iter `lv_iter_t` object create before
|
||||
* @return LV_RESULT_OK: Reset the peek buffer successfully
|
||||
* LV_RESULT_INVALID: The peek buffer is invalid
|
||||
*/
|
||||
lv_result_t lv_iter_peek_reset(lv_iter_t * iter);
|
||||
|
||||
/**
|
||||
* Inspect the element of the iterator. The callback function will be called for each element of the iterator.
|
||||
* @param iter `lv_iter_t` object create before
|
||||
* @param inspect_cb The callback function to inspect the element
|
||||
*/
|
||||
void lv_iter_inspect(lv_iter_t * iter, lv_iter_inspect_cb inspect_cb);
|
||||
|
||||
/*************************
|
||||
* GLOBAL VARIABLES
|
||||
*************************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_ITER_H*/
|
||||
@@ -0,0 +1,169 @@
|
||||
/**
|
||||
* @file lv_ll.h
|
||||
* Handle linked lists. The nodes are dynamically allocated by the 'lv_mem' module.
|
||||
*/
|
||||
|
||||
#ifndef LV_LL_H
|
||||
#define LV_LL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_conf_internal.h"
|
||||
#include "lv_types.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/** Dummy type to make handling easier*/
|
||||
typedef uint8_t lv_ll_node_t;
|
||||
|
||||
/** Description of a linked list*/
|
||||
typedef struct {
|
||||
uint32_t n_size;
|
||||
lv_ll_node_t * head;
|
||||
lv_ll_node_t * tail;
|
||||
} lv_ll_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize linked list
|
||||
* @param ll_p pointer to lv_ll_t variable
|
||||
* @param node_size the size of 1 node in bytes
|
||||
*/
|
||||
void lv_ll_init(lv_ll_t * ll_p, uint32_t node_size);
|
||||
|
||||
/**
|
||||
* Add a new head to a linked list
|
||||
* @param ll_p pointer to linked list
|
||||
* @return pointer to the new head
|
||||
*/
|
||||
void * lv_ll_ins_head(lv_ll_t * ll_p);
|
||||
|
||||
/**
|
||||
* Insert a new node in front of the n_act node
|
||||
* @param ll_p pointer to linked list
|
||||
* @param n_act pointer a node
|
||||
* @return pointer to the new node
|
||||
*/
|
||||
void * lv_ll_ins_prev(lv_ll_t * ll_p, void * n_act);
|
||||
|
||||
/**
|
||||
* Add a new tail to a linked list
|
||||
* @param ll_p pointer to linked list
|
||||
* @return pointer to the new tail
|
||||
*/
|
||||
void * lv_ll_ins_tail(lv_ll_t * ll_p);
|
||||
|
||||
/**
|
||||
* Remove the node 'node_p' from 'll_p' linked list.
|
||||
* It does not free the memory of node.
|
||||
* @param ll_p pointer to the linked list of 'node_p'
|
||||
* @param node_p pointer to node in 'll_p' linked list
|
||||
*/
|
||||
void lv_ll_remove(lv_ll_t * ll_p, void * node_p);
|
||||
|
||||
void lv_ll_clear_custom(lv_ll_t * ll_p, void(*cleanup)(void *));
|
||||
|
||||
/**
|
||||
* Remove and free all elements from a linked list. The list remain valid but become empty.
|
||||
* @param ll_p pointer to linked list
|
||||
*/
|
||||
void lv_ll_clear(lv_ll_t * ll_p);
|
||||
|
||||
/**
|
||||
* Move a node to a new linked list
|
||||
* @param ll_ori_p pointer to the original (old) linked list
|
||||
* @param ll_new_p pointer to the new linked list
|
||||
* @param node pointer to a node
|
||||
* @param head true: be the head in the new list
|
||||
* false be the tail in the new list
|
||||
*/
|
||||
void lv_ll_chg_list(lv_ll_t * ll_ori_p, lv_ll_t * ll_new_p, void * node, bool head);
|
||||
|
||||
/**
|
||||
* Return with head node of the linked list
|
||||
* @param ll_p pointer to linked list
|
||||
* @return pointer to the head of 'll_p'
|
||||
*/
|
||||
void * lv_ll_get_head(const lv_ll_t * ll_p);
|
||||
|
||||
/**
|
||||
* Return with tail node of the linked list
|
||||
* @param ll_p pointer to linked list
|
||||
* @return pointer to the tail of 'll_p'
|
||||
*/
|
||||
void * lv_ll_get_tail(const lv_ll_t * ll_p);
|
||||
|
||||
/**
|
||||
* Return with the pointer of the next node after 'n_act'
|
||||
* @param ll_p pointer to linked list
|
||||
* @param n_act pointer a node
|
||||
* @return pointer to the next node
|
||||
*/
|
||||
void * lv_ll_get_next(const lv_ll_t * ll_p, const void * n_act);
|
||||
|
||||
/**
|
||||
* Return with the pointer of the previous node after 'n_act'
|
||||
* @param ll_p pointer to linked list
|
||||
* @param n_act pointer a node
|
||||
* @return pointer to the previous node
|
||||
*/
|
||||
void * lv_ll_get_prev(const lv_ll_t * ll_p, const void * n_act);
|
||||
|
||||
/**
|
||||
* Return the length of the linked list.
|
||||
* @param ll_p pointer to linked list
|
||||
* @return length of the linked list
|
||||
*/
|
||||
uint32_t lv_ll_get_len(const lv_ll_t * ll_p);
|
||||
|
||||
/*
|
||||
* TODO
|
||||
* @param ll_p
|
||||
* @param n1_p
|
||||
* @param n2_p
|
||||
void lv_ll_swap(lv_ll_t * ll_p, void * n1_p, void * n2_p);
|
||||
*/
|
||||
|
||||
/**
|
||||
* Move a node before another node in the same linked list
|
||||
*
|
||||
* @param ll_p pointer to a linked list
|
||||
* @param n_act pointer to node to move
|
||||
* @param n_after pointer to a node which should be after `n_act`
|
||||
*/
|
||||
void lv_ll_move_before(lv_ll_t * ll_p, void * n_act, void * n_after);
|
||||
|
||||
/**
|
||||
* Check if a linked list is empty
|
||||
* @param ll_p pointer to a linked list
|
||||
* @return true: the linked list is empty; false: not empty
|
||||
*/
|
||||
bool lv_ll_is_empty(lv_ll_t * ll_p);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#define LV_LL_READ(list, i) for(i = lv_ll_get_head(list); i != NULL; i = lv_ll_get_next(list, i))
|
||||
|
||||
#define LV_LL_READ_BACK(list, i) for(i = lv_ll_get_tail(list); i != NULL; i = lv_ll_get_prev(list, i))
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,162 @@
|
||||
/**
|
||||
* @file lv_log.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_LOG_H
|
||||
#define LV_LOG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_conf_internal.h"
|
||||
|
||||
#include "lv_types.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/*Possible log level. For compatibility declare it independently from `LV_USE_LOG`*/
|
||||
|
||||
#define LV_LOG_LEVEL_TRACE 0 /**< Log 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 /**< Log only critical issues, when system may fail. */
|
||||
#define LV_LOG_LEVEL_USER 4 /**< Log only custom log messages added by 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_LEVEL_NONE);
|
||||
|
||||
typedef int8_t lv_log_level_t;
|
||||
|
||||
#if LV_USE_LOG
|
||||
|
||||
#if LV_LOG_USE_FILE_LINE
|
||||
#define LV_LOG_FILE __FILE__
|
||||
#define LV_LOG_LINE __LINE__
|
||||
#else
|
||||
#define LV_LOG_FILE NULL
|
||||
#define LV_LOG_LINE 0
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Log print function. Receives a string buffer to print".
|
||||
*/
|
||||
typedef void (*lv_log_print_g_cb_t)(lv_log_level_t level, const char * buf);
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Register custom print/write function to call when a log is added.
|
||||
* It can format its "File path", "Line number" and "Description" as required
|
||||
* and send the formatted log message to a console or serial port.
|
||||
* @param print_cb a function pointer to print a log
|
||||
*/
|
||||
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`
|
||||
* @param format printf-like format string
|
||||
* @param ... parameters for `format`
|
||||
*/
|
||||
void lv_log(const char * format, ...) LV_FORMAT_ATTRIBUTE(1, 2);
|
||||
|
||||
/**
|
||||
* Add a log
|
||||
* @param level the level of log. (From `lv_log_level_t` enum)
|
||||
* @param file name of the file when the log added
|
||||
* @param line line number in the source code where the log added
|
||||
* @param func name of the function when the log added
|
||||
* @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);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
#ifndef LV_LOG_TRACE
|
||||
# if LV_LOG_LEVEL <= LV_LOG_LEVEL_TRACE
|
||||
# define LV_LOG_TRACE(...) lv_log_add(LV_LOG_LEVEL_TRACE, LV_LOG_FILE, LV_LOG_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, LV_LOG_FILE, LV_LOG_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, LV_LOG_FILE, LV_LOG_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, LV_LOG_FILE, LV_LOG_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, LV_LOG_FILE, LV_LOG_LINE, __func__, __VA_ARGS__)
|
||||
# else
|
||||
# define LV_LOG_USER(...) do {}while(0)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef LV_LOG
|
||||
# if LV_LOG_LEVEL < LV_LOG_LEVEL_NONE
|
||||
# define LV_LOG(...) lv_log(__VA_ARGS__)
|
||||
# else
|
||||
# define LV_LOG(...) 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(...) do {}while(0)
|
||||
|
||||
#endif /*LV_USE_LOG*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_LOG_H*/
|
||||
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* @file lv_lru.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_LRU_H
|
||||
#define LV_LRU_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "../lv_conf_internal.h"
|
||||
|
||||
#include "lv_types.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef enum {
|
||||
LV_LRU_OK = 0,
|
||||
LV_LRU_MISSING_CACHE,
|
||||
LV_LRU_MISSING_KEY,
|
||||
LV_LRU_MISSING_VALUE,
|
||||
LV_LRU_LOCK_ERROR,
|
||||
LV_LRU_VALUE_TOO_LARGE
|
||||
} lv_lru_res_t;
|
||||
|
||||
typedef void (*lv_lru_free_cb_t)(void * v);
|
||||
|
||||
typedef struct _lv_lru_item_t lv_lru_item_t;
|
||||
|
||||
typedef struct _lv_lru_t {
|
||||
lv_lru_item_t ** items;
|
||||
uint64_t access_count;
|
||||
size_t free_memory;
|
||||
size_t total_memory;
|
||||
size_t average_item_length;
|
||||
size_t hash_table_size;
|
||||
uint32_t seed;
|
||||
lv_lru_free_cb_t value_free;
|
||||
lv_lru_free_cb_t key_free;
|
||||
lv_lru_item_t * free_items;
|
||||
} lv_lru_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
lv_lru_t * lv_lru_create(size_t cache_size, size_t average_length, lv_lru_free_cb_t value_free,
|
||||
lv_lru_free_cb_t key_free);
|
||||
|
||||
void lv_lru_delete(lv_lru_t * cache);
|
||||
|
||||
lv_lru_res_t lv_lru_set(lv_lru_t * cache, const void * key, size_t key_length, void * value, size_t value_length);
|
||||
|
||||
lv_lru_res_t lv_lru_get(lv_lru_t * cache, const void * key, size_t key_size, void ** value);
|
||||
|
||||
lv_lru_res_t lv_lru_remove(lv_lru_t * cache, const void * key, size_t key_size);
|
||||
|
||||
/**
|
||||
* remove the least recently used item
|
||||
*
|
||||
* @todo we can optimise this by finding the n lru items, where n = required_space / average_length
|
||||
*/
|
||||
void lv_lru_remove_lru_item(lv_lru_t * cache);
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_LRU_H*/
|
||||
@@ -0,0 +1,181 @@
|
||||
/**
|
||||
* @file lv_math.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_MATH_H
|
||||
#define LV_MATH_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_conf_internal.h"
|
||||
#include "lv_types.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_TRIGO_SIN_MAX 32768
|
||||
#define LV_TRIGO_SHIFT 15 /**< >> LV_TRIGO_SHIFT to normalize*/
|
||||
|
||||
#define LV_BEZIER_VAL_SHIFT 10 /**< log2(LV_BEZIER_VAL_MAX): used to normalize up scaled values*/
|
||||
#define LV_BEZIER_VAL_MAX (1L << LV_BEZIER_VAL_SHIFT) /**< Max time in Bezier functions (not [0..1] to use integers)*/
|
||||
#define LV_BEZIER_VAL_FLOAT(f) ((int32_t)((f) * LV_BEZIER_VAL_MAX)) /**< Convert const float number cubic-bezier values to fix-point value*/
|
||||
|
||||
/** Align up value x to align, align must be a power of two */
|
||||
#define LV_ALIGN_UP(x, align) (((x) + ((align) - 1)) & ~((align) - 1))
|
||||
|
||||
/** Round up value x to round, round can be any integer number */
|
||||
#define LV_ROUND_UP(x, round) ((((x) + ((round) - 1)) / (round)) * (round))
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef struct {
|
||||
uint16_t i;
|
||||
uint16_t f;
|
||||
} lv_sqrt_res_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
//! @cond Doxygen_Suppress
|
||||
/**
|
||||
* Return with sinus of an angle
|
||||
* @param angle
|
||||
* @return sinus of 'angle'. sin(-90) = -32767, sin(90) = 32767
|
||||
*/
|
||||
int32_t /* LV_ATTRIBUTE_FAST_MEM */ lv_trigo_sin(int16_t angle);
|
||||
|
||||
int32_t LV_ATTRIBUTE_FAST_MEM lv_trigo_cos(int16_t angle);
|
||||
|
||||
//! @endcond
|
||||
|
||||
/**
|
||||
* Calculate the y value of cubic-bezier(x1, y1, x2, y2) function as specified x.
|
||||
* @param x time in range of [0..LV_BEZIER_VAL_MAX]
|
||||
* @param x1 x of control point 1 in range of [0..LV_BEZIER_VAL_MAX]
|
||||
* @param y1 y of control point 1 in range of [0..LV_BEZIER_VAL_MAX]
|
||||
* @param x2 x of control point 2 in range of [0..LV_BEZIER_VAL_MAX]
|
||||
* @param y2 y of control point 2 in range of [0..LV_BEZIER_VAL_MAX]
|
||||
* @return the value calculated
|
||||
*/
|
||||
int32_t lv_cubic_bezier(int32_t x, int32_t x1, int32_t y1, int32_t x2, int32_t y2);
|
||||
|
||||
/**
|
||||
* Calculate a value of a Cubic Bezier function.
|
||||
* @param t time in range of [0..LV_BEZIER_VAL_MAX]
|
||||
* @param u0 must be 0
|
||||
* @param u1 control value 1 values in range of [0..LV_BEZIER_VAL_MAX]
|
||||
* @param u2 control value 2 in range of [0..LV_BEZIER_VAL_MAX]
|
||||
* @param u3 must be LV_BEZIER_VAL_MAX
|
||||
* @return the value calculated from the given parameters in range of [0..LV_BEZIER_VAL_MAX]
|
||||
*/
|
||||
int32_t lv_bezier3(int32_t t, int32_t u0, uint32_t u1, int32_t u2, int32_t u3);
|
||||
|
||||
|
||||
/**
|
||||
* Calculate the atan2 of a vector.
|
||||
* @param x
|
||||
* @param y
|
||||
* @return the angle in degree calculated from the given parameters in range of [0..360]
|
||||
*/
|
||||
uint16_t lv_atan2(int x, int y);
|
||||
|
||||
//! @cond Doxygen_Suppress
|
||||
|
||||
/**
|
||||
* Get the square root of a number
|
||||
* @param x integer which square root should be calculated
|
||||
* @param q store the result here. q->i: integer part, q->f: fractional part in 1/256 unit
|
||||
* @param mask optional to skip some iterations if the magnitude of the root is known.
|
||||
* Set to 0x8000 by default.
|
||||
* If root < 16: mask = 0x80
|
||||
* If root < 256: mask = 0x800
|
||||
* Else: mask = 0x8000
|
||||
*/
|
||||
void /* LV_ATTRIBUTE_FAST_MEM */ lv_sqrt(uint32_t x, lv_sqrt_res_t * q, uint32_t mask);
|
||||
|
||||
//! @endcond
|
||||
|
||||
/**
|
||||
* Alternative (fast, approximate) implementation for getting the square root of an integer.
|
||||
* @param x integer which square root should be calculated
|
||||
*/
|
||||
int32_t /* LV_ATTRIBUTE_FAST_MEM */ lv_sqrt32(uint32_t x);
|
||||
|
||||
/**
|
||||
* Calculate the square of an integer (input range is 0..32767).
|
||||
* @param x input
|
||||
* @return square
|
||||
*/
|
||||
static inline int32_t lv_sqr(int32_t x)
|
||||
{
|
||||
return x * x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the integer exponents.
|
||||
* @param base
|
||||
* @param exp
|
||||
* @return base raised to the power exponent
|
||||
*/
|
||||
int64_t lv_pow(int64_t base, int8_t exp);
|
||||
|
||||
/**
|
||||
* Get the mapped of a number given an input and output range
|
||||
* @param x integer which mapped value should be calculated
|
||||
* @param min_in min input range
|
||||
* @param max_in max input range
|
||||
* @param min_out max output range
|
||||
* @param max_out max output range
|
||||
* @return the mapped number
|
||||
*/
|
||||
int32_t lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min_out, int32_t max_out);
|
||||
|
||||
/**
|
||||
* Set the seed of the pseudo random number generator
|
||||
* @param seed a number to initialize the random generator
|
||||
*/
|
||||
void lv_rand_set_seed(uint32_t seed);
|
||||
|
||||
/**
|
||||
* Get a pseudo random number in the given range
|
||||
* @param min the minimum value
|
||||
* @param max the maximum value
|
||||
* @return return the random number. min <= return_value <= max
|
||||
*/
|
||||
uint32_t lv_rand(uint32_t min, uint32_t max);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
#define LV_MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#define LV_MIN3(a, b, c) (LV_MIN(LV_MIN(a,b), c))
|
||||
#define LV_MIN4(a, b, c, d) (LV_MIN(LV_MIN(a,b), LV_MIN(c,d)))
|
||||
|
||||
#define LV_MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define LV_MAX3(a, b, c) (LV_MAX(LV_MAX(a,b), c))
|
||||
#define LV_MAX4(a, b, c, d) (LV_MAX(LV_MAX(a,b), LV_MAX(c,d)))
|
||||
|
||||
#define LV_CLAMP(min, val, max) (LV_MAX(min, (LV_MIN(val, max))))
|
||||
|
||||
#define LV_ABS(x) ((x) > 0 ? (x) : (-(x)))
|
||||
#define LV_UDIV255(x) (((x) * 0x8081U) >> 0x17)
|
||||
|
||||
#define LV_IS_SIGNED(t) (((t)(-1)) < ((t)0))
|
||||
#define LV_UMAX_OF(t) (((0x1ULL << ((sizeof(t) * 8ULL) - 1ULL)) - 1ULL) | (0xFULL << ((sizeof(t) * 8ULL) - 4ULL)))
|
||||
#define LV_SMAX_OF(t) (((0x1ULL << ((sizeof(t) * 8ULL) - 1ULL)) - 1ULL) | (0x7ULL << ((sizeof(t) * 8ULL) - 4ULL)))
|
||||
#define LV_MAX_OF(t) ((unsigned long)(LV_IS_SIGNED(t) ? LV_SMAX_OF(t) : LV_UMAX_OF(t)))
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,129 @@
|
||||
/**
|
||||
* @file lv_matrix.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_MATRIX_H
|
||||
#define LV_MATRIX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "../lv_conf_internal.h"
|
||||
|
||||
#if LV_USE_MATRIX
|
||||
|
||||
#include "lv_types.h"
|
||||
#include "lv_area.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
#if !LV_USE_FLOAT
|
||||
#error "LV_USE_FLOAT is required for lv_matrix"
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
struct _lv_matrix_t {
|
||||
float m[3][3];
|
||||
};
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Set matrix to identity matrix
|
||||
* @param matrix pointer to a matrix
|
||||
*/
|
||||
void lv_matrix_identity(lv_matrix_t * matrix);
|
||||
|
||||
/**
|
||||
* Translate the matrix to new position
|
||||
* @param matrix pointer to a matrix
|
||||
* @param tx the amount of translate in x direction
|
||||
* @param tx the amount of translate in y direction
|
||||
*/
|
||||
void lv_matrix_translate(lv_matrix_t * matrix, float tx, float ty);
|
||||
|
||||
/**
|
||||
* Change the scale factor of the matrix
|
||||
* @param matrix pointer to a matrix
|
||||
* @param scale_x the scale factor for the X direction
|
||||
* @param scale_y the scale factor for the Y direction
|
||||
*/
|
||||
void lv_matrix_scale(lv_matrix_t * matrix, float scale_x, float scale_y);
|
||||
|
||||
/**
|
||||
* Rotate the matrix with origin
|
||||
* @param matrix pointer to a matrix
|
||||
* @param degree angle to rotate
|
||||
*/
|
||||
void lv_matrix_rotate(lv_matrix_t * matrix, float degree);
|
||||
|
||||
/**
|
||||
* Change the skew factor of the matrix
|
||||
* @param matrix pointer to a matrix
|
||||
* @param skew_x the skew factor for x direction
|
||||
* @param skew_y the skew factor for y direction
|
||||
*/
|
||||
void lv_matrix_skew(lv_matrix_t * matrix, float skew_x, float skew_y);
|
||||
|
||||
/**
|
||||
* Multiply two matrix and store the result to the first one
|
||||
* @param matrix pointer to a matrix
|
||||
* @param matrix2 pointer to another matrix
|
||||
*/
|
||||
void lv_matrix_multiply(lv_matrix_t * matrix, const lv_matrix_t * mul);
|
||||
|
||||
/**
|
||||
* Invert the matrix
|
||||
* @param matrix pointer to a matrix
|
||||
* @param m pointer to another matrix (optional)
|
||||
* @return true: the matrix is invertible, false: the matrix is singular and cannot be inverted
|
||||
*/
|
||||
bool lv_matrix_inverse(lv_matrix_t * matrix, const lv_matrix_t * m);
|
||||
|
||||
/**
|
||||
* Transform a point by a matrix
|
||||
* @param matrix pointer to a matrix
|
||||
* @param point pointer to a point
|
||||
* @return the transformed point
|
||||
*/
|
||||
lv_point_precise_t lv_matrix_transform_precise_point(const lv_matrix_t * matrix, const lv_point_precise_t * point);
|
||||
|
||||
/**
|
||||
* Transform an area by a matrix
|
||||
* @param matrix pointer to a matrix
|
||||
* @param area pointer to an area
|
||||
* @return the transformed area
|
||||
*/
|
||||
lv_area_t lv_matrix_transform_area(const lv_matrix_t * matrix, const lv_area_t * area);
|
||||
|
||||
/**
|
||||
* Check if the matrix is identity or translation matrix
|
||||
* @param matrix pointer to a matrix
|
||||
* @return true: the matrix is identity or translation matrix, false: the matrix is not identity or translation matrix
|
||||
*/
|
||||
bool lv_matrix_is_identity_or_translation(const lv_matrix_t * matrix);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_MATRIX*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_MATRIX_H*/
|
||||
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* @file lv_palette.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_PALETTE_H
|
||||
#define LV_PALETTE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_color.h"
|
||||
#include "lv_types.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef enum {
|
||||
LV_PALETTE_RED,
|
||||
LV_PALETTE_PINK,
|
||||
LV_PALETTE_PURPLE,
|
||||
LV_PALETTE_DEEP_PURPLE,
|
||||
LV_PALETTE_INDIGO,
|
||||
LV_PALETTE_BLUE,
|
||||
LV_PALETTE_LIGHT_BLUE,
|
||||
LV_PALETTE_CYAN,
|
||||
LV_PALETTE_TEAL,
|
||||
LV_PALETTE_GREEN,
|
||||
LV_PALETTE_LIGHT_GREEN,
|
||||
LV_PALETTE_LIME,
|
||||
LV_PALETTE_YELLOW,
|
||||
LV_PALETTE_AMBER,
|
||||
LV_PALETTE_ORANGE,
|
||||
LV_PALETTE_DEEP_ORANGE,
|
||||
LV_PALETTE_BROWN,
|
||||
LV_PALETTE_BLUE_GREY,
|
||||
LV_PALETTE_GREY,
|
||||
LV_PALETTE_LAST,
|
||||
LV_PALETTE_NONE = 0xff,
|
||||
} lv_palette_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/*Source: https://vuetifyjs.com/en/styles/colors/#material-colors*/
|
||||
|
||||
lv_color_t lv_palette_main(lv_palette_t p);
|
||||
lv_color_t lv_palette_lighten(lv_palette_t p, uint8_t lvl);
|
||||
lv_color_t lv_palette_darken(lv_palette_t p, uint8_t lvl);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_PALETTE_H*/
|
||||
@@ -0,0 +1,172 @@
|
||||
/**
|
||||
* @file lv_profiler.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_PROFILER_H
|
||||
#define LV_PROFILER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "../lv_conf_internal.h"
|
||||
|
||||
#if LV_USE_PROFILER
|
||||
|
||||
#include LV_PROFILER_INCLUDE
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#else
|
||||
|
||||
#define LV_PROFILER_BEGIN
|
||||
#define LV_PROFILER_END
|
||||
#define LV_PROFILER_BEGIN_TAG(tag) LV_UNUSED(tag)
|
||||
#define LV_PROFILER_END_TAG(tag) LV_UNUSED(tag)
|
||||
|
||||
#endif /*LV_USE_PROFILER*/
|
||||
|
||||
#if LV_USE_PROFILER && LV_PROFILER_LAYOUT
|
||||
#define LV_PROFILER_LAYOUT_BEGIN LV_PROFILER_BEGIN
|
||||
#define LV_PROFILER_LAYOUT_END LV_PROFILER_END
|
||||
#define LV_PROFILER_LAYOUT_BEGIN_TAG(tag) LV_PROFILER_BEGIN_TAG(tag)
|
||||
#define LV_PROFILER_LAYOUT_END_TAG(tag) LV_PROFILER_END_TAG(tag)
|
||||
#else
|
||||
#define LV_PROFILER_LAYOUT_BEGIN
|
||||
#define LV_PROFILER_LAYOUT_END
|
||||
#define LV_PROFILER_LAYOUT_BEGIN_TAG(tag)
|
||||
#define LV_PROFILER_LAYOUT_END_TAG(tag)
|
||||
#endif
|
||||
|
||||
#if LV_USE_PROFILER && LV_PROFILER_STYLE
|
||||
#define LV_PROFILER_STYLE_BEGIN LV_PROFILER_BEGIN
|
||||
#define LV_PROFILER_STYLE_END LV_PROFILER_END
|
||||
#define LV_PROFILER_STYLE_BEGIN_TAG(tag) LV_PROFILER_BEGIN_TAG(tag)
|
||||
#define LV_PROFILER_STYLE_END_TAG(tag) LV_PROFILER_END_TAG(tag)
|
||||
#else
|
||||
#define LV_PROFILER_STYLE_BEGIN
|
||||
#define LV_PROFILER_STYLE_END
|
||||
#define LV_PROFILER_STYLE_BEGIN_TAG(tag)
|
||||
#define LV_PROFILER_STYLE_END_TAG(tag)
|
||||
#endif
|
||||
|
||||
#if LV_USE_PROFILER && LV_PROFILER_DRAW
|
||||
#define LV_PROFILER_DRAW_BEGIN LV_PROFILER_BEGIN
|
||||
#define LV_PROFILER_DRAW_END LV_PROFILER_END
|
||||
#define LV_PROFILER_DRAW_BEGIN_TAG(tag) LV_PROFILER_BEGIN_TAG(tag)
|
||||
#define LV_PROFILER_DRAW_END_TAG(tag) LV_PROFILER_END_TAG(tag)
|
||||
#else
|
||||
#define LV_PROFILER_DRAW_BEGIN
|
||||
#define LV_PROFILER_DRAW_END
|
||||
#define LV_PROFILER_DRAW_BEGIN_TAG(tag)
|
||||
#define LV_PROFILER_DRAW_END_TAG(tag)
|
||||
#endif
|
||||
|
||||
#if LV_USE_PROFILER && LV_PROFILER_DECODER
|
||||
#define LV_PROFILER_DECODER_BEGIN LV_PROFILER_BEGIN
|
||||
#define LV_PROFILER_DECODER_END LV_PROFILER_END
|
||||
#define LV_PROFILER_DECODER_BEGIN_TAG(tag) LV_PROFILER_BEGIN_TAG(tag)
|
||||
#define LV_PROFILER_DECODER_END_TAG(tag) LV_PROFILER_END_TAG(tag)
|
||||
#else
|
||||
#define LV_PROFILER_DECODER_BEGIN
|
||||
#define LV_PROFILER_DECODER_END
|
||||
#define LV_PROFILER_DECODER_BEGIN_TAG(tag)
|
||||
#define LV_PROFILER_DECODER_END_TAG(tag)
|
||||
#endif
|
||||
|
||||
#if LV_USE_PROFILER && LV_PROFILER_REFR
|
||||
#define LV_PROFILER_REFR_BEGIN LV_PROFILER_BEGIN
|
||||
#define LV_PROFILER_REFR_END LV_PROFILER_END
|
||||
#define LV_PROFILER_REFR_BEGIN_TAG(tag) LV_PROFILER_BEGIN_TAG(tag)
|
||||
#define LV_PROFILER_REFR_END_TAG(tag) LV_PROFILER_END_TAG(tag)
|
||||
#else
|
||||
#define LV_PROFILER_REFR_BEGIN
|
||||
#define LV_PROFILER_REFR_END
|
||||
#define LV_PROFILER_REFR_BEGIN_TAG(tag)
|
||||
#define LV_PROFILER_REFR_END_TAG(tag)
|
||||
#endif
|
||||
|
||||
#if LV_USE_PROFILER && LV_PROFILER_INDEV
|
||||
#define LV_PROFILER_INDEV_BEGIN LV_PROFILER_BEGIN
|
||||
#define LV_PROFILER_INDEV_END LV_PROFILER_END
|
||||
#define LV_PROFILER_INDEV_BEGIN_TAG(tag) LV_PROFILER_BEGIN_TAG(tag)
|
||||
#define LV_PROFILER_INDEV_END_TAG(tag) LV_PROFILER_END_TAG(tag)
|
||||
#else
|
||||
#define LV_PROFILER_INDEV_BEGIN
|
||||
#define LV_PROFILER_INDEV_END
|
||||
#define LV_PROFILER_INDEV_BEGIN_TAG(tag)
|
||||
#define LV_PROFILER_INDEV_END_TAG(tag)
|
||||
#endif
|
||||
|
||||
#if LV_USE_PROFILER && LV_PROFILER_FONT
|
||||
#define LV_PROFILER_FONT_BEGIN LV_PROFILER_BEGIN
|
||||
#define LV_PROFILER_FONT_END LV_PROFILER_END
|
||||
#define LV_PROFILER_FONT_BEGIN_TAG(tag) LV_PROFILER_BEGIN_TAG(tag)
|
||||
#define LV_PROFILER_FONT_END_TAG(tag) LV_PROFILER_END_TAG(tag)
|
||||
#else
|
||||
#define LV_PROFILER_FONT_BEGIN
|
||||
#define LV_PROFILER_FONT_END
|
||||
#define LV_PROFILER_FONT_BEGIN_TAG(tag)
|
||||
#define LV_PROFILER_FONT_END_TAG(tag)
|
||||
#endif
|
||||
|
||||
#if LV_USE_PROFILER && LV_PROFILER_CACHE
|
||||
#define LV_PROFILER_CACHE_BEGIN LV_PROFILER_BEGIN
|
||||
#define LV_PROFILER_CACHE_END LV_PROFILER_END
|
||||
#define LV_PROFILER_CACHE_BEGIN_TAG(tag) LV_PROFILER_BEGIN_TAG(tag)
|
||||
#define LV_PROFILER_CACHE_END_TAG(tag) LV_PROFILER_END_TAG(tag)
|
||||
#else
|
||||
#define LV_PROFILER_CACHE_BEGIN
|
||||
#define LV_PROFILER_CACHE_END
|
||||
#define LV_PROFILER_CACHE_BEGIN_TAG(tag)
|
||||
#define LV_PROFILER_CACHE_END_TAG(tag)
|
||||
#endif
|
||||
|
||||
#if LV_USE_PROFILER && LV_PROFILER_FS
|
||||
#define LV_PROFILER_FS_BEGIN LV_PROFILER_BEGIN
|
||||
#define LV_PROFILER_FS_END LV_PROFILER_END
|
||||
#define LV_PROFILER_FS_BEGIN_TAG(tag) LV_PROFILER_BEGIN_TAG(tag)
|
||||
#define LV_PROFILER_FS_END_TAG(tag) LV_PROFILER_END_TAG(tag)
|
||||
#else
|
||||
#define LV_PROFILER_FS_BEGIN
|
||||
#define LV_PROFILER_FS_END
|
||||
#define LV_PROFILER_FS_BEGIN_TAG(tag)
|
||||
#define LV_PROFILER_FS_END_TAG(tag)
|
||||
#endif
|
||||
|
||||
#if LV_USE_PROFILER && LV_PROFILER_TIMER
|
||||
#define LV_PROFILER_TIMER_BEGIN LV_PROFILER_BEGIN
|
||||
#define LV_PROFILER_TIMER_END LV_PROFILER_END
|
||||
#define LV_PROFILER_TIMER_BEGIN_TAG(tag) LV_PROFILER_BEGIN_TAG(tag)
|
||||
#define LV_PROFILER_TIMER_END_TAG(tag) LV_PROFILER_END_TAG(tag)
|
||||
#else
|
||||
#define LV_PROFILER_TIMER_BEGIN
|
||||
#define LV_PROFILER_TIMER_END
|
||||
#define LV_PROFILER_TIMER_BEGIN_TAG(tag)
|
||||
#define LV_PROFILER_TIMER_END_TAG(tag)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_PROFILER_H*/
|
||||
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* @file lv_profiler_builtin.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_PROFILER_BUILTIN_H
|
||||
#define LV_PROFILER_BUILTIN_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "../lv_conf_internal.h"
|
||||
|
||||
#if LV_USE_PROFILER && LV_USE_PROFILER_BUILTIN
|
||||
|
||||
#include "lv_types.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
#define LV_PROFILER_BUILTIN_BEGIN_TAG(tag) lv_profiler_builtin_write((tag), 'B')
|
||||
#define LV_PROFILER_BUILTIN_END_TAG(tag) lv_profiler_builtin_write((tag), 'E')
|
||||
#define LV_PROFILER_BUILTIN_BEGIN LV_PROFILER_BUILTIN_BEGIN_TAG(__func__)
|
||||
#define LV_PROFILER_BUILTIN_END LV_PROFILER_BUILTIN_END_TAG(__func__)
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* @brief Initialize the configuration of the built-in profiler
|
||||
* @param config Pointer to the configuration structure of the built-in profiler
|
||||
*/
|
||||
void lv_profiler_builtin_config_init(lv_profiler_builtin_config_t * config);
|
||||
|
||||
/**
|
||||
* @brief Initialize the built-in profiler with the given configuration
|
||||
* @param config Pointer to the configuration structure of the built-in profiler
|
||||
*/
|
||||
void lv_profiler_builtin_init(const lv_profiler_builtin_config_t * config);
|
||||
|
||||
/**
|
||||
* @brief Uninitialize the built-in profiler
|
||||
*/
|
||||
void lv_profiler_builtin_uninit(void);
|
||||
|
||||
/**
|
||||
* @brief Enable or disable the built-in profiler
|
||||
* @param enable true to enable the built-in profiler, false to disable
|
||||
*/
|
||||
void lv_profiler_builtin_set_enable(bool enable);
|
||||
|
||||
/**
|
||||
* @brief Flush the profiling data to the console
|
||||
*/
|
||||
void lv_profiler_builtin_flush(void);
|
||||
|
||||
/**
|
||||
* @brief Write the profiling data for a function with the given tag
|
||||
* @param func Name of the function being profiled
|
||||
* @param tag Tag to associate with the profiling data for the function
|
||||
*/
|
||||
void lv_profiler_builtin_write(const char * func, char tag);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_PROFILER_BUILTIN*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_PROFILER_BUILTIN_H*/
|
||||
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* @file lv_profiler_builtin_private.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_PROFILER_BUILTIN_PRIVATE_H
|
||||
#define LV_PROFILER_BUILTIN_PRIVATE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lv_profiler_builtin.h"
|
||||
|
||||
#if LV_USE_PROFILER && LV_USE_PROFILER_BUILTIN
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* @brief LVGL profiler built-in configuration structure
|
||||
*/
|
||||
struct _lv_profiler_builtin_config_t {
|
||||
size_t buf_size; /**< The size of the buffer used for profiling data */
|
||||
uint32_t tick_per_sec; /**< The number of ticks per second */
|
||||
uint32_t (*tick_get_cb)(void); /**< Callback function to get the current tick count */
|
||||
void (*flush_cb)(const char * buf); /**< Callback function to flush the profiling data */
|
||||
int (*tid_get_cb)(void); /**< Callback function to get the current thread ID */
|
||||
int (*cpu_get_cb)(void); /**< Callback function to get the current CPU */
|
||||
};
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /* LV_USE_PROFILER && LV_USE_PROFILER_BUILTIN */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_PROFILER_BUILTIN_PRIVATE_H*/
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* @file lv_rb.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_RB_H
|
||||
#define LV_RB_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_types.h"
|
||||
#include "lv_assert.h"
|
||||
#include "lv_types.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef enum {
|
||||
LV_RB_COLOR_RED,
|
||||
LV_RB_COLOR_BLACK
|
||||
} lv_rb_color_t;
|
||||
|
||||
typedef int8_t lv_rb_compare_res_t;
|
||||
|
||||
typedef lv_rb_compare_res_t (*lv_rb_compare_t)(const void * a, const void * b);
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
bool lv_rb_init(lv_rb_t * tree, lv_rb_compare_t compare, size_t node_size);
|
||||
lv_rb_node_t * lv_rb_insert(lv_rb_t * tree, void * key);
|
||||
lv_rb_node_t * lv_rb_find(lv_rb_t * tree, const void * key);
|
||||
void * lv_rb_remove_node(lv_rb_t * tree, lv_rb_node_t * node);
|
||||
void * lv_rb_remove(lv_rb_t * tree, const void * key);
|
||||
bool lv_rb_drop_node(lv_rb_t * tree, lv_rb_node_t * node);
|
||||
bool lv_rb_drop(lv_rb_t * tree, const void * key);
|
||||
lv_rb_node_t * lv_rb_minimum(lv_rb_t * node);
|
||||
lv_rb_node_t * lv_rb_maximum(lv_rb_t * node);
|
||||
lv_rb_node_t * lv_rb_minimum_from(lv_rb_node_t * node);
|
||||
lv_rb_node_t * lv_rb_maximum_from(lv_rb_node_t * node);
|
||||
void lv_rb_destroy(lv_rb_t * tree);
|
||||
|
||||
/*************************
|
||||
* GLOBAL VARIABLES
|
||||
*************************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_RB_H*/
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* @file lv_rb_private.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_RB_PRIVATE_H
|
||||
#define LV_RB_PRIVATE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lv_rb.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
struct _lv_rb_node_t {
|
||||
struct _lv_rb_node_t * parent;
|
||||
struct _lv_rb_node_t * left;
|
||||
struct _lv_rb_node_t * right;
|
||||
lv_rb_color_t color;
|
||||
void * data;
|
||||
};
|
||||
|
||||
struct _lv_rb_t {
|
||||
lv_rb_node_t * root;
|
||||
lv_rb_compare_t compare;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_RB_PRIVATE_H*/
|
||||
@@ -0,0 +1,640 @@
|
||||
/**
|
||||
* @file lv_style.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_STYLE_H
|
||||
#define LV_STYLE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../font/lv_font.h"
|
||||
#include "lv_color.h"
|
||||
#include "lv_area.h"
|
||||
#include "lv_anim.h"
|
||||
#include "lv_text.h"
|
||||
#include "lv_types.h"
|
||||
#include "lv_assert.h"
|
||||
#include "lv_bidi.h"
|
||||
#include "../layouts/lv_layout.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
#define LV_STYLE_SENTINEL_VALUE 0xAABBCCDD
|
||||
|
||||
/*
|
||||
* Flags for style behavior
|
||||
*/
|
||||
#define LV_STYLE_PROP_FLAG_NONE (0) /**< No special behavior */
|
||||
#define LV_STYLE_PROP_FLAG_INHERITABLE (1 << 0) /**< Inherited */
|
||||
#define LV_STYLE_PROP_FLAG_EXT_DRAW_UPDATE (1 << 1) /**< Requires ext. draw size update when changed */
|
||||
#define LV_STYLE_PROP_FLAG_LAYOUT_UPDATE (1 << 2) /**< Requires layout update when changed */
|
||||
#define LV_STYLE_PROP_FLAG_PARENT_LAYOUT_UPDATE (1 << 3) /**< Requires layout update on parent when changed */
|
||||
#define LV_STYLE_PROP_FLAG_LAYER_UPDATE (1 << 4) /**< Affects layer handling */
|
||||
#define LV_STYLE_PROP_FLAG_TRANSFORM (1 << 5) /**< Affects the object's transformation */
|
||||
#define LV_STYLE_PROP_FLAG_ALL (0x3F) /**< Indicating all flags */
|
||||
|
||||
/*
|
||||
* Other constants
|
||||
*/
|
||||
#define LV_SCALE_NONE 256 /**< Value for not zooming the image */
|
||||
LV_EXPORT_CONST_INT(LV_SCALE_NONE);
|
||||
|
||||
// *INDENT-OFF*
|
||||
#if LV_USE_ASSERT_STYLE
|
||||
#define LV_STYLE_CONST_INIT(var_name, prop_array) \
|
||||
const lv_style_t var_name = { \
|
||||
.sentinel = LV_STYLE_SENTINEL_VALUE, \
|
||||
.values_and_props = (void*)prop_array, \
|
||||
.has_group = 0xFFFFFFFF, \
|
||||
.prop_cnt = 255 \
|
||||
}
|
||||
#else
|
||||
#define LV_STYLE_CONST_INIT(var_name, prop_array) \
|
||||
const lv_style_t var_name = { \
|
||||
.values_and_props = prop_array, \
|
||||
.has_group = 0xFFFFFFFF, \
|
||||
.prop_cnt = 255, \
|
||||
}
|
||||
#endif
|
||||
// *INDENT-ON*
|
||||
|
||||
#define LV_STYLE_CONST_PROPS_END { .prop = LV_STYLE_PROP_INV, .value = { .num = 0 } }
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Possible options for blending opaque drawings
|
||||
*/
|
||||
typedef enum {
|
||||
LV_BLEND_MODE_NORMAL, /**< Simply mix according to the opacity value*/
|
||||
LV_BLEND_MODE_ADDITIVE, /**< Add the respective color channels*/
|
||||
LV_BLEND_MODE_SUBTRACTIVE,/**< Subtract the foreground from the background*/
|
||||
LV_BLEND_MODE_MULTIPLY, /**< Multiply the foreground and background*/
|
||||
} lv_blend_mode_t;
|
||||
|
||||
/**
|
||||
* Some options to apply decorations on texts.
|
||||
* 'OR'ed values can be used.
|
||||
*/
|
||||
typedef enum {
|
||||
LV_TEXT_DECOR_NONE = 0x00,
|
||||
LV_TEXT_DECOR_UNDERLINE = 0x01,
|
||||
LV_TEXT_DECOR_STRIKETHROUGH = 0x02,
|
||||
} lv_text_decor_t;
|
||||
|
||||
/**
|
||||
* Selects on which sides border should be drawn
|
||||
* 'OR'ed values can be used.
|
||||
*/
|
||||
typedef enum {
|
||||
LV_BORDER_SIDE_NONE = 0x00,
|
||||
LV_BORDER_SIDE_BOTTOM = 0x01,
|
||||
LV_BORDER_SIDE_TOP = 0x02,
|
||||
LV_BORDER_SIDE_LEFT = 0x04,
|
||||
LV_BORDER_SIDE_RIGHT = 0x08,
|
||||
LV_BORDER_SIDE_FULL = 0x0F,
|
||||
LV_BORDER_SIDE_INTERNAL = 0x10, /**< FOR matrix-like objects (e.g. Button matrix)*/
|
||||
} lv_border_side_t;
|
||||
|
||||
/**
|
||||
* The direction of the gradient.
|
||||
*/
|
||||
typedef enum {
|
||||
LV_GRAD_DIR_NONE, /**< No gradient (the `grad_color` property is ignored)*/
|
||||
LV_GRAD_DIR_VER, /**< Simple vertical (top to bottom) gradient*/
|
||||
LV_GRAD_DIR_HOR, /**< Simple horizontal (left to right) gradient*/
|
||||
LV_GRAD_DIR_LINEAR, /**< Linear gradient defined by start and end points. Can be at any angle.*/
|
||||
LV_GRAD_DIR_RADIAL, /**< Radial gradient defined by start and end circles*/
|
||||
LV_GRAD_DIR_CONICAL, /**< Conical gradient defined by center point, start and end angles*/
|
||||
} lv_grad_dir_t;
|
||||
|
||||
/**
|
||||
* Gradient behavior outside the defined range.
|
||||
*/
|
||||
typedef enum {
|
||||
LV_GRAD_EXTEND_PAD, /**< Repeat the same color*/
|
||||
LV_GRAD_EXTEND_REPEAT, /**< Repeat the pattern*/
|
||||
LV_GRAD_EXTEND_REFLECT, /**< Repeat the pattern mirrored*/
|
||||
} lv_grad_extend_t;
|
||||
|
||||
/** A gradient stop definition.
|
||||
* This matches a color and a position in a virtual 0-255 scale.
|
||||
*/
|
||||
typedef struct {
|
||||
lv_color_t color; /**< The stop color */
|
||||
lv_opa_t opa; /**< The opacity of the color*/
|
||||
uint8_t frac; /**< The stop position in 1/255 unit */
|
||||
} lv_gradient_stop_t;
|
||||
|
||||
/** A descriptor of a gradient. */
|
||||
typedef struct {
|
||||
lv_gradient_stop_t stops[LV_GRADIENT_MAX_STOPS]; /**< A gradient stop array */
|
||||
uint8_t stops_count; /**< The number of used stops in the array */
|
||||
lv_grad_dir_t dir : 3; /**< The gradient direction.
|
||||
* Any of LV_GRAD_DIR_NONE, LV_GRAD_DIR_VER, LV_GRAD_DIR_HOR,
|
||||
* LV_GRAD_TYPE_LINEAR, LV_GRAD_TYPE_RADIAL, LV_GRAD_TYPE_CONICAL */
|
||||
lv_grad_extend_t extend : 2; /**< Behaviour outside the defined range.
|
||||
* LV_GRAD_EXTEND_NONE, LV_GRAD_EXTEND_PAD, LV_GRAD_EXTEND_REPEAT, LV_GRAD_EXTEND_REFLECT */
|
||||
#if LV_USE_DRAW_SW_COMPLEX_GRADIENTS
|
||||
union {
|
||||
/*Linear gradient parameters*/
|
||||
struct {
|
||||
lv_point_t start; /**< Linear gradient vector start point */
|
||||
lv_point_t end; /**< Linear gradient vector end point */
|
||||
} linear;
|
||||
/*Radial gradient parameters*/
|
||||
struct {
|
||||
lv_point_t focal; /**< Center of the focal (starting) circle in local coordinates */
|
||||
/* (can be the same as the ending circle to create concentric circles) */
|
||||
lv_point_t focal_extent; /**< Point on the circle (can be the same as the center) */
|
||||
lv_point_t end; /**< Center of the ending circle in local coordinates */
|
||||
lv_point_t end_extent; /**< Point on the circle determining the radius of the gradient */
|
||||
} radial;
|
||||
/*Conical gradient parameters*/
|
||||
struct {
|
||||
lv_point_t center; /**< Conical gradient center point */
|
||||
int16_t start_angle; /**< Start angle 0..3600 */
|
||||
int16_t end_angle; /**< End angle 0..3600 */
|
||||
} conical;
|
||||
} params;
|
||||
void * state;
|
||||
#endif
|
||||
} lv_grad_dsc_t;
|
||||
|
||||
/**
|
||||
* A common type to handle all the property types in the same way.
|
||||
*/
|
||||
typedef union {
|
||||
int32_t num; /**< Number integer number (opacity, enums, booleans or "normal" numbers)*/
|
||||
const void * ptr; /**< Constant pointers (font, cone text, etc)*/
|
||||
lv_color_t color; /**< Colors*/
|
||||
} lv_style_value_t;
|
||||
|
||||
/**
|
||||
* Enumeration of all built in style properties
|
||||
*
|
||||
* Props are split into groups of 16. When adding a new prop to a group, ensure it does not overflow into the next one.
|
||||
*/
|
||||
enum {
|
||||
LV_STYLE_PROP_INV = 0,
|
||||
|
||||
/*Group 0*/
|
||||
LV_STYLE_WIDTH = 1,
|
||||
LV_STYLE_HEIGHT = 2,
|
||||
LV_STYLE_LENGTH = 3,
|
||||
|
||||
LV_STYLE_MIN_WIDTH = 4,
|
||||
LV_STYLE_MAX_WIDTH = 5,
|
||||
LV_STYLE_MIN_HEIGHT = 6,
|
||||
LV_STYLE_MAX_HEIGHT = 7,
|
||||
|
||||
LV_STYLE_X = 8,
|
||||
LV_STYLE_Y = 9,
|
||||
LV_STYLE_ALIGN = 10,
|
||||
|
||||
LV_STYLE_RADIUS = 12,
|
||||
|
||||
/*Group 1*/
|
||||
LV_STYLE_PAD_TOP = 16,
|
||||
LV_STYLE_PAD_BOTTOM = 17,
|
||||
LV_STYLE_PAD_LEFT = 18,
|
||||
LV_STYLE_PAD_RIGHT = 19,
|
||||
|
||||
LV_STYLE_PAD_ROW = 20,
|
||||
LV_STYLE_PAD_COLUMN = 21,
|
||||
LV_STYLE_LAYOUT = 22,
|
||||
|
||||
LV_STYLE_MARGIN_TOP = 24,
|
||||
LV_STYLE_MARGIN_BOTTOM = 25,
|
||||
LV_STYLE_MARGIN_LEFT = 26,
|
||||
LV_STYLE_MARGIN_RIGHT = 27,
|
||||
|
||||
/*Group 2*/
|
||||
LV_STYLE_BG_COLOR = 28,
|
||||
LV_STYLE_BG_OPA = 29,
|
||||
|
||||
LV_STYLE_BG_GRAD_DIR = 32,
|
||||
LV_STYLE_BG_MAIN_STOP = 33,
|
||||
LV_STYLE_BG_GRAD_STOP = 34,
|
||||
LV_STYLE_BG_GRAD_COLOR = 35,
|
||||
|
||||
LV_STYLE_BG_MAIN_OPA = 36,
|
||||
LV_STYLE_BG_GRAD_OPA = 37,
|
||||
LV_STYLE_BG_GRAD = 38,
|
||||
LV_STYLE_BASE_DIR = 39,
|
||||
|
||||
LV_STYLE_BG_IMAGE_SRC = 40,
|
||||
LV_STYLE_BG_IMAGE_OPA = 41,
|
||||
LV_STYLE_BG_IMAGE_RECOLOR = 42,
|
||||
LV_STYLE_BG_IMAGE_RECOLOR_OPA = 43,
|
||||
|
||||
LV_STYLE_BG_IMAGE_TILED = 44,
|
||||
LV_STYLE_CLIP_CORNER = 45,
|
||||
|
||||
/*Group 3*/
|
||||
LV_STYLE_BORDER_WIDTH = 48,
|
||||
LV_STYLE_BORDER_COLOR = 49,
|
||||
LV_STYLE_BORDER_OPA = 50,
|
||||
|
||||
LV_STYLE_BORDER_SIDE = 52,
|
||||
LV_STYLE_BORDER_POST = 53,
|
||||
|
||||
LV_STYLE_OUTLINE_WIDTH = 56,
|
||||
LV_STYLE_OUTLINE_COLOR = 57,
|
||||
LV_STYLE_OUTLINE_OPA = 58,
|
||||
LV_STYLE_OUTLINE_PAD = 59,
|
||||
|
||||
/*Group 4*/
|
||||
LV_STYLE_SHADOW_WIDTH = 60,
|
||||
LV_STYLE_SHADOW_COLOR = 61,
|
||||
LV_STYLE_SHADOW_OPA = 62,
|
||||
|
||||
LV_STYLE_SHADOW_OFFSET_X = 64,
|
||||
LV_STYLE_SHADOW_OFFSET_Y = 65,
|
||||
LV_STYLE_SHADOW_SPREAD = 66,
|
||||
|
||||
LV_STYLE_IMAGE_OPA = 68,
|
||||
LV_STYLE_IMAGE_RECOLOR = 69,
|
||||
LV_STYLE_IMAGE_RECOLOR_OPA = 70,
|
||||
|
||||
LV_STYLE_LINE_WIDTH = 72,
|
||||
LV_STYLE_LINE_DASH_WIDTH = 73,
|
||||
LV_STYLE_LINE_DASH_GAP = 74,
|
||||
LV_STYLE_LINE_ROUNDED = 75,
|
||||
LV_STYLE_LINE_COLOR = 76,
|
||||
LV_STYLE_LINE_OPA = 77,
|
||||
|
||||
/*Group 5*/
|
||||
LV_STYLE_ARC_WIDTH = 80,
|
||||
LV_STYLE_ARC_ROUNDED = 81,
|
||||
LV_STYLE_ARC_COLOR = 82,
|
||||
LV_STYLE_ARC_OPA = 83,
|
||||
LV_STYLE_ARC_IMAGE_SRC = 84,
|
||||
|
||||
LV_STYLE_TEXT_COLOR = 88,
|
||||
LV_STYLE_TEXT_OPA = 89,
|
||||
LV_STYLE_TEXT_FONT = 90,
|
||||
|
||||
LV_STYLE_TEXT_LETTER_SPACE = 91,
|
||||
LV_STYLE_TEXT_LINE_SPACE = 92,
|
||||
LV_STYLE_TEXT_DECOR = 93,
|
||||
LV_STYLE_TEXT_ALIGN = 94,
|
||||
|
||||
LV_STYLE_OPA = 95,
|
||||
LV_STYLE_OPA_LAYERED = 96,
|
||||
LV_STYLE_COLOR_FILTER_DSC = 97,
|
||||
LV_STYLE_COLOR_FILTER_OPA = 98,
|
||||
LV_STYLE_ANIM = 99,
|
||||
LV_STYLE_ANIM_DURATION = 100,
|
||||
LV_STYLE_TRANSITION = 102,
|
||||
LV_STYLE_BLEND_MODE = 103,
|
||||
LV_STYLE_TRANSFORM_WIDTH = 104,
|
||||
LV_STYLE_TRANSFORM_HEIGHT = 105,
|
||||
LV_STYLE_TRANSLATE_X = 106,
|
||||
LV_STYLE_TRANSLATE_Y = 107,
|
||||
LV_STYLE_TRANSFORM_SCALE_X = 108,
|
||||
LV_STYLE_TRANSFORM_SCALE_Y = 109,
|
||||
LV_STYLE_TRANSFORM_ROTATION = 110,
|
||||
LV_STYLE_TRANSFORM_PIVOT_X = 111,
|
||||
LV_STYLE_TRANSFORM_PIVOT_Y = 112,
|
||||
LV_STYLE_TRANSFORM_SKEW_X = 113,
|
||||
LV_STYLE_TRANSFORM_SKEW_Y = 114,
|
||||
LV_STYLE_BITMAP_MASK_SRC = 115,
|
||||
LV_STYLE_ROTARY_SENSITIVITY = 116,
|
||||
|
||||
LV_STYLE_FLEX_FLOW = 125,
|
||||
LV_STYLE_FLEX_MAIN_PLACE = 126,
|
||||
LV_STYLE_FLEX_CROSS_PLACE = 127,
|
||||
LV_STYLE_FLEX_TRACK_PLACE = 128,
|
||||
LV_STYLE_FLEX_GROW = 129,
|
||||
|
||||
LV_STYLE_GRID_COLUMN_ALIGN = 130,
|
||||
LV_STYLE_GRID_ROW_ALIGN = 131,
|
||||
LV_STYLE_GRID_ROW_DSC_ARRAY = 132,
|
||||
LV_STYLE_GRID_COLUMN_DSC_ARRAY = 133,
|
||||
LV_STYLE_GRID_CELL_COLUMN_POS = 134,
|
||||
LV_STYLE_GRID_CELL_COLUMN_SPAN = 135,
|
||||
LV_STYLE_GRID_CELL_X_ALIGN = 136,
|
||||
LV_STYLE_GRID_CELL_ROW_POS = 137,
|
||||
LV_STYLE_GRID_CELL_ROW_SPAN = 138,
|
||||
LV_STYLE_GRID_CELL_Y_ALIGN = 139,
|
||||
|
||||
LV_STYLE_LAST_BUILT_IN_PROP = 140,
|
||||
|
||||
LV_STYLE_NUM_BUILT_IN_PROPS = LV_STYLE_LAST_BUILT_IN_PROP + 1,
|
||||
|
||||
LV_STYLE_PROP_ANY = 0xFF,
|
||||
LV_STYLE_PROP_CONST = 0xFF /* magic value for const styles */
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
LV_STYLE_RES_NOT_FOUND,
|
||||
LV_STYLE_RES_FOUND,
|
||||
} lv_style_res_t;
|
||||
|
||||
/**
|
||||
* Descriptor for style transitions
|
||||
*/
|
||||
typedef struct {
|
||||
const lv_style_prop_t * props; /**< An array with the properties to animate.*/
|
||||
void * user_data; /**< A custom user data that will be passed to the animation's user_data */
|
||||
lv_anim_path_cb_t path_xcb; /**< A path for the animation.*/
|
||||
uint32_t time; /**< Duration of the transition in [ms]*/
|
||||
uint32_t delay; /**< Delay before the transition in [ms]*/
|
||||
} lv_style_transition_dsc_t;
|
||||
|
||||
/**
|
||||
* Descriptor of a constant style property.
|
||||
*/
|
||||
typedef struct {
|
||||
lv_style_prop_t prop;
|
||||
lv_style_value_t value;
|
||||
} lv_style_const_prop_t;
|
||||
|
||||
/**
|
||||
* Descriptor of a style (a collection of properties and values).
|
||||
*/
|
||||
typedef struct {
|
||||
|
||||
#if LV_USE_ASSERT_STYLE
|
||||
uint32_t sentinel;
|
||||
#endif
|
||||
|
||||
void * values_and_props;
|
||||
|
||||
uint32_t has_group;
|
||||
uint8_t prop_cnt; /**< 255 means it's a constant style*/
|
||||
} lv_style_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize a style
|
||||
* @param style pointer to a style to initialize
|
||||
* @note Do not call `lv_style_init` on styles that already have some properties
|
||||
* because this function won't free the used memory, just sets a default state for the style.
|
||||
* In other words be sure to initialize styles only once!
|
||||
*/
|
||||
void lv_style_init(lv_style_t * style);
|
||||
|
||||
/**
|
||||
* Clear all properties from a style and free all allocated memories.
|
||||
* @param style pointer to a style
|
||||
*/
|
||||
void lv_style_reset(lv_style_t * style);
|
||||
|
||||
/**
|
||||
* Check if a style is constant
|
||||
* @param style pointer to a style
|
||||
* @return true: the style is constant
|
||||
*/
|
||||
static inline bool lv_style_is_const(const lv_style_t * style)
|
||||
{
|
||||
if(style->prop_cnt == 255) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new style property for custom usage
|
||||
* @return a new property ID, or LV_STYLE_PROP_INV if there are no more available.
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* lv_style_prop_t MY_PROP;
|
||||
* static inline void lv_style_set_my_prop(lv_style_t * style, lv_color_t value) {
|
||||
* lv_style_value_t v = {.color = value}; lv_style_set_prop(style, MY_PROP, v); }
|
||||
*
|
||||
* ...
|
||||
* MY_PROP = lv_style_register_prop();
|
||||
* ...
|
||||
* lv_style_set_my_prop(&style1, lv_palette_main(LV_PALETTE_RED));
|
||||
* @endcode
|
||||
*/
|
||||
lv_style_prop_t lv_style_register_prop(uint8_t flag);
|
||||
|
||||
/**
|
||||
* Get the number of custom properties that have been registered thus far.
|
||||
*/
|
||||
lv_style_prop_t lv_style_get_num_custom_props(void);
|
||||
|
||||
/**
|
||||
* Remove a property from a style
|
||||
* @param style pointer to a style
|
||||
* @param prop a style property ORed with a state.
|
||||
* @return true: the property was found and removed; false: the property wasn't found
|
||||
*/
|
||||
bool lv_style_remove_prop(lv_style_t * style, lv_style_prop_t prop);
|
||||
|
||||
/**
|
||||
* Set the value of property in a style.
|
||||
* This function shouldn't be used directly by the user.
|
||||
* Instead use `lv_style_set_<prop_name>()`. E.g. `lv_style_set_bg_color()`
|
||||
* @param style pointer to style
|
||||
* @param prop the ID of a property (e.g. `LV_STYLE_BG_COLOR`)
|
||||
* @param value `lv_style_value_t` variable in which a field is set according to the type of `prop`
|
||||
*/
|
||||
void lv_style_set_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t value);
|
||||
|
||||
/**
|
||||
* Get the value of a property
|
||||
* @param style pointer to a style
|
||||
* @param prop the ID of a property
|
||||
* @param value pointer to a `lv_style_value_t` variable to store the value
|
||||
* @return LV_RESULT_INVALID: the property wasn't found in the style (`value` is unchanged)
|
||||
* LV_RESULT_OK: the property was fond, and `value` is set accordingly
|
||||
* @note For performance reasons there are no sanity check on `style`
|
||||
*/
|
||||
lv_style_res_t lv_style_get_prop(const lv_style_t * style, lv_style_prop_t prop, lv_style_value_t * value);
|
||||
|
||||
/**
|
||||
* Initialize a transition descriptor.
|
||||
* @param tr pointer to a transition descriptor to initialize
|
||||
* @param props an array with the properties to transition. The last element must be zero.
|
||||
* @param path_cb an animation path (ease) callback. If `NULL` liner path will be used.
|
||||
* @param time duration of the transition in [ms]
|
||||
* @param delay delay before the transition in [ms]
|
||||
* @param user_data any custom data that will be saved in the transition animation and will be available when `path_cb` is called
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* const static lv_style_prop_t trans_props[] = { LV_STYLE_BG_OPA, LV_STYLE_BG_COLOR, 0 };
|
||||
* static lv_style_transition_dsc_t trans1;
|
||||
* lv_style_transition_dsc_init(&trans1, trans_props, NULL, 300, 0, NULL);
|
||||
* @endcode
|
||||
*/
|
||||
void lv_style_transition_dsc_init(lv_style_transition_dsc_t * tr, const lv_style_prop_t props[],
|
||||
lv_anim_path_cb_t path_cb, uint32_t time, uint32_t delay, void * user_data);
|
||||
|
||||
/**
|
||||
* Get the default value of a property
|
||||
* @param prop the ID of a property
|
||||
* @return the default value
|
||||
*/
|
||||
lv_style_value_t lv_style_prop_get_default(lv_style_prop_t prop);
|
||||
|
||||
/**
|
||||
* Get the value of a property
|
||||
* @param style pointer to a style
|
||||
* @param prop the ID of a property
|
||||
* @param value pointer to a `lv_style_value_t` variable to store the value
|
||||
* @return LV_RESULT_INVALID: the property wasn't found in the style (`value` is unchanged)
|
||||
* LV_RESULT_OK: the property was fond, and `value` is set accordingly
|
||||
* @note For performance reasons there are no sanity check on `style`
|
||||
* @note This function is the same as ::lv_style_get_prop but inlined. Use it only on performance critical places
|
||||
*/
|
||||
static inline lv_style_res_t lv_style_get_prop_inlined(const lv_style_t * style, lv_style_prop_t prop,
|
||||
lv_style_value_t * value)
|
||||
{
|
||||
if(lv_style_is_const(style)) {
|
||||
lv_style_const_prop_t * props = (lv_style_const_prop_t *)style->values_and_props;
|
||||
uint32_t i;
|
||||
for(i = 0; props[i].prop != LV_STYLE_PROP_INV; i++) {
|
||||
if(props[i].prop == prop) {
|
||||
*value = props[i].value;
|
||||
return LV_STYLE_RES_FOUND;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
lv_style_prop_t * props = (lv_style_prop_t *)style->values_and_props + style->prop_cnt * sizeof(lv_style_value_t);
|
||||
uint32_t i;
|
||||
for(i = 0; i < style->prop_cnt; i++) {
|
||||
if(props[i] == prop) {
|
||||
lv_style_value_t * values = (lv_style_value_t *)style->values_and_props;
|
||||
*value = values[i];
|
||||
return LV_STYLE_RES_FOUND;
|
||||
}
|
||||
}
|
||||
}
|
||||
return LV_STYLE_RES_NOT_FOUND;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a style is empty (has no properties)
|
||||
* @param style pointer to a style
|
||||
* @return true if the style is empty
|
||||
*/
|
||||
bool lv_style_is_empty(const lv_style_t * style);
|
||||
|
||||
/**
|
||||
* Tell the group of a property. If the a property from a group is set in a style the (1 << group) bit of style->has_group is set.
|
||||
* It allows early skipping the style if the property is not exists in the style at all.
|
||||
* @param prop a style property
|
||||
* @return the group [0..30] 30 means all the custom properties with index > 120
|
||||
*/
|
||||
static inline uint32_t lv_style_get_prop_group(lv_style_prop_t prop)
|
||||
{
|
||||
uint32_t group = prop >> 2;
|
||||
if(group > 30) group = 31; /*The MSB marks all the custom properties*/
|
||||
return group;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the flags of a built-in or custom property.
|
||||
*
|
||||
* @param prop a style property
|
||||
* @return the flags of the property
|
||||
*/
|
||||
uint8_t lv_style_prop_lookup_flags(lv_style_prop_t prop);
|
||||
|
||||
#include "lv_style_gen.h"
|
||||
|
||||
static inline void lv_style_set_size(lv_style_t * style, int32_t width, int32_t height)
|
||||
{
|
||||
lv_style_set_width(style, width);
|
||||
lv_style_set_height(style, height);
|
||||
}
|
||||
|
||||
static inline void lv_style_set_pad_all(lv_style_t * style, int32_t value)
|
||||
{
|
||||
lv_style_set_pad_left(style, value);
|
||||
lv_style_set_pad_right(style, value);
|
||||
lv_style_set_pad_top(style, value);
|
||||
lv_style_set_pad_bottom(style, value);
|
||||
}
|
||||
|
||||
static inline void lv_style_set_pad_hor(lv_style_t * style, int32_t value)
|
||||
{
|
||||
lv_style_set_pad_left(style, value);
|
||||
lv_style_set_pad_right(style, value);
|
||||
}
|
||||
|
||||
static inline void lv_style_set_pad_ver(lv_style_t * style, int32_t value)
|
||||
{
|
||||
lv_style_set_pad_top(style, value);
|
||||
lv_style_set_pad_bottom(style, value);
|
||||
}
|
||||
|
||||
static inline void lv_style_set_pad_gap(lv_style_t * style, int32_t value)
|
||||
{
|
||||
lv_style_set_pad_row(style, value);
|
||||
lv_style_set_pad_column(style, value);
|
||||
}
|
||||
|
||||
static inline void lv_style_set_margin_all(lv_style_t * style, int32_t value)
|
||||
{
|
||||
lv_style_set_margin_left(style, value);
|
||||
lv_style_set_margin_right(style, value);
|
||||
lv_style_set_margin_top(style, value);
|
||||
lv_style_set_margin_bottom(style, value);
|
||||
}
|
||||
|
||||
static inline void lv_style_set_transform_scale(lv_style_t * style, int32_t value)
|
||||
{
|
||||
lv_style_set_transform_scale_x(style, value);
|
||||
lv_style_set_transform_scale_y(style, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if the style property has a specified behavioral flag.
|
||||
*
|
||||
* Do not pass multiple flags to this function as backwards-compatibility is not guaranteed
|
||||
* for that.
|
||||
*
|
||||
* @param prop Property ID
|
||||
* @param flag Flag
|
||||
* @return true if the flag is set for this property
|
||||
*/
|
||||
static inline bool lv_style_prop_has_flag(lv_style_prop_t prop, uint8_t flag)
|
||||
{
|
||||
return lv_style_prop_lookup_flags(prop) & flag;
|
||||
}
|
||||
|
||||
/*************************
|
||||
* GLOBAL VARIABLES
|
||||
*************************/
|
||||
|
||||
LV_ATTRIBUTE_EXTERN_DATA extern const lv_style_prop_t lv_style_const_prop_id_inv;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#if LV_USE_ASSERT_STYLE
|
||||
# define LV_ASSERT_STYLE(style_p) \
|
||||
do { \
|
||||
LV_ASSERT_MSG(style_p != NULL, "The style is NULL"); \
|
||||
LV_ASSERT_MSG(style_p->sentinel == LV_STYLE_SENTINEL_VALUE, "Style is not initialized or corrupted"); \
|
||||
} while(0)
|
||||
#else
|
||||
# define LV_ASSERT_STYLE(p) do{}while(0)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_STYLE_H*/
|
||||
@@ -0,0 +1,694 @@
|
||||
|
||||
/*
|
||||
**********************************************************************
|
||||
* DO NOT EDIT
|
||||
* This file is automatically generated by "style_api_gen.py"
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LV_STYLE_GEN_H
|
||||
#define LV_STYLE_GEN_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void lv_style_set_width(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_min_width(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_max_width(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_height(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_min_height(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_max_height(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_length(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_x(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_y(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_align(lv_style_t * style, lv_align_t value);
|
||||
void lv_style_set_transform_width(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_transform_height(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_translate_x(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_translate_y(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_transform_scale_x(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_transform_scale_y(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_transform_rotation(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_transform_pivot_x(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_transform_pivot_y(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_transform_skew_x(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_transform_skew_y(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_pad_top(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_pad_bottom(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_pad_left(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_pad_right(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_pad_row(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_pad_column(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_margin_top(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_margin_bottom(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_margin_left(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_margin_right(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_bg_color(lv_style_t * style, lv_color_t value);
|
||||
void lv_style_set_bg_opa(lv_style_t * style, lv_opa_t value);
|
||||
void lv_style_set_bg_grad_color(lv_style_t * style, lv_color_t value);
|
||||
void lv_style_set_bg_grad_dir(lv_style_t * style, lv_grad_dir_t value);
|
||||
void lv_style_set_bg_main_stop(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_bg_grad_stop(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_bg_main_opa(lv_style_t * style, lv_opa_t value);
|
||||
void lv_style_set_bg_grad_opa(lv_style_t * style, lv_opa_t value);
|
||||
void lv_style_set_bg_grad(lv_style_t * style, const lv_grad_dsc_t * value);
|
||||
void lv_style_set_bg_image_src(lv_style_t * style, const void * value);
|
||||
void lv_style_set_bg_image_opa(lv_style_t * style, lv_opa_t value);
|
||||
void lv_style_set_bg_image_recolor(lv_style_t * style, lv_color_t value);
|
||||
void lv_style_set_bg_image_recolor_opa(lv_style_t * style, lv_opa_t value);
|
||||
void lv_style_set_bg_image_tiled(lv_style_t * style, bool value);
|
||||
void lv_style_set_border_color(lv_style_t * style, lv_color_t value);
|
||||
void lv_style_set_border_opa(lv_style_t * style, lv_opa_t value);
|
||||
void lv_style_set_border_width(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_border_side(lv_style_t * style, lv_border_side_t value);
|
||||
void lv_style_set_border_post(lv_style_t * style, bool value);
|
||||
void lv_style_set_outline_width(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_outline_color(lv_style_t * style, lv_color_t value);
|
||||
void lv_style_set_outline_opa(lv_style_t * style, lv_opa_t value);
|
||||
void lv_style_set_outline_pad(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_shadow_width(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_shadow_offset_x(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_shadow_offset_y(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_shadow_spread(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_shadow_color(lv_style_t * style, lv_color_t value);
|
||||
void lv_style_set_shadow_opa(lv_style_t * style, lv_opa_t value);
|
||||
void lv_style_set_image_opa(lv_style_t * style, lv_opa_t value);
|
||||
void lv_style_set_image_recolor(lv_style_t * style, lv_color_t value);
|
||||
void lv_style_set_image_recolor_opa(lv_style_t * style, lv_opa_t value);
|
||||
void lv_style_set_line_width(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_line_dash_width(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_line_dash_gap(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_line_rounded(lv_style_t * style, bool value);
|
||||
void lv_style_set_line_color(lv_style_t * style, lv_color_t value);
|
||||
void lv_style_set_line_opa(lv_style_t * style, lv_opa_t value);
|
||||
void lv_style_set_arc_width(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_arc_rounded(lv_style_t * style, bool value);
|
||||
void lv_style_set_arc_color(lv_style_t * style, lv_color_t value);
|
||||
void lv_style_set_arc_opa(lv_style_t * style, lv_opa_t value);
|
||||
void lv_style_set_arc_image_src(lv_style_t * style, const void * value);
|
||||
void lv_style_set_text_color(lv_style_t * style, lv_color_t value);
|
||||
void lv_style_set_text_opa(lv_style_t * style, lv_opa_t value);
|
||||
void lv_style_set_text_font(lv_style_t * style, const lv_font_t * value);
|
||||
void lv_style_set_text_letter_space(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_text_line_space(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_text_decor(lv_style_t * style, lv_text_decor_t value);
|
||||
void lv_style_set_text_align(lv_style_t * style, lv_text_align_t value);
|
||||
void lv_style_set_radius(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_clip_corner(lv_style_t * style, bool value);
|
||||
void lv_style_set_opa(lv_style_t * style, lv_opa_t value);
|
||||
void lv_style_set_opa_layered(lv_style_t * style, lv_opa_t value);
|
||||
void lv_style_set_color_filter_dsc(lv_style_t * style, const lv_color_filter_dsc_t * value);
|
||||
void lv_style_set_color_filter_opa(lv_style_t * style, lv_opa_t value);
|
||||
void lv_style_set_anim(lv_style_t * style, const lv_anim_t * value);
|
||||
void lv_style_set_anim_duration(lv_style_t * style, uint32_t value);
|
||||
void lv_style_set_transition(lv_style_t * style, const lv_style_transition_dsc_t * value);
|
||||
void lv_style_set_blend_mode(lv_style_t * style, lv_blend_mode_t value);
|
||||
void lv_style_set_layout(lv_style_t * style, uint16_t value);
|
||||
void lv_style_set_base_dir(lv_style_t * style, lv_base_dir_t value);
|
||||
void lv_style_set_bitmap_mask_src(lv_style_t * style, const void * value);
|
||||
void lv_style_set_rotary_sensitivity(lv_style_t * style, uint32_t value);
|
||||
#if LV_USE_FLEX
|
||||
void lv_style_set_flex_flow(lv_style_t * style, lv_flex_flow_t value);
|
||||
void lv_style_set_flex_main_place(lv_style_t * style, lv_flex_align_t value);
|
||||
void lv_style_set_flex_cross_place(lv_style_t * style, lv_flex_align_t value);
|
||||
void lv_style_set_flex_track_place(lv_style_t * style, lv_flex_align_t value);
|
||||
void lv_style_set_flex_grow(lv_style_t * style, uint8_t value);
|
||||
#endif /*LV_USE_FLEX*/
|
||||
|
||||
#if LV_USE_GRID
|
||||
void lv_style_set_grid_column_dsc_array(lv_style_t * style, const int32_t * value);
|
||||
void lv_style_set_grid_column_align(lv_style_t * style, lv_grid_align_t value);
|
||||
void lv_style_set_grid_row_dsc_array(lv_style_t * style, const int32_t * value);
|
||||
void lv_style_set_grid_row_align(lv_style_t * style, lv_grid_align_t value);
|
||||
void lv_style_set_grid_cell_column_pos(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_grid_cell_x_align(lv_style_t * style, lv_grid_align_t value);
|
||||
void lv_style_set_grid_cell_column_span(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_grid_cell_row_pos(lv_style_t * style, int32_t value);
|
||||
void lv_style_set_grid_cell_y_align(lv_style_t * style, lv_grid_align_t value);
|
||||
void lv_style_set_grid_cell_row_span(lv_style_t * style, int32_t value);
|
||||
#endif /*LV_USE_GRID*/
|
||||
|
||||
|
||||
#define LV_STYLE_CONST_WIDTH(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_WIDTH, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_MIN_WIDTH(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_MIN_WIDTH, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_MAX_WIDTH(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_MAX_WIDTH, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_HEIGHT(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_HEIGHT, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_MIN_HEIGHT(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_MIN_HEIGHT, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_MAX_HEIGHT(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_MAX_HEIGHT, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_LENGTH(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_LENGTH, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_X(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_X, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_Y(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_Y, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_ALIGN(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_ALIGN, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_TRANSFORM_WIDTH(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_TRANSFORM_WIDTH, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_TRANSFORM_HEIGHT(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_TRANSFORM_HEIGHT, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_TRANSLATE_X(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_TRANSLATE_X, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_TRANSLATE_Y(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_TRANSLATE_Y, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_TRANSFORM_SCALE_X(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_TRANSFORM_SCALE_X, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_TRANSFORM_SCALE_Y(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_TRANSFORM_SCALE_Y, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_TRANSFORM_ROTATION(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_TRANSFORM_ROTATION, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_TRANSFORM_PIVOT_X(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_TRANSFORM_PIVOT_X, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_TRANSFORM_PIVOT_Y(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_TRANSFORM_PIVOT_Y, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_TRANSFORM_SKEW_X(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_TRANSFORM_SKEW_X, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_TRANSFORM_SKEW_Y(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_TRANSFORM_SKEW_Y, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_PAD_TOP(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_PAD_TOP, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_PAD_BOTTOM(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_PAD_BOTTOM, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_PAD_LEFT(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_PAD_LEFT, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_PAD_RIGHT(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_PAD_RIGHT, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_PAD_ROW(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_PAD_ROW, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_PAD_COLUMN(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_PAD_COLUMN, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_MARGIN_TOP(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_MARGIN_TOP, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_MARGIN_BOTTOM(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_MARGIN_BOTTOM, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_MARGIN_LEFT(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_MARGIN_LEFT, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_MARGIN_RIGHT(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_MARGIN_RIGHT, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_BG_COLOR(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_BG_COLOR, .value = { .color = val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_BG_OPA(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_BG_OPA, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_BG_GRAD_COLOR(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_BG_GRAD_COLOR, .value = { .color = val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_BG_GRAD_DIR(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_BG_GRAD_DIR, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_BG_MAIN_STOP(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_BG_MAIN_STOP, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_BG_GRAD_STOP(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_BG_GRAD_STOP, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_BG_MAIN_OPA(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_BG_MAIN_OPA, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_BG_GRAD_OPA(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_BG_GRAD_OPA, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_BG_GRAD(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_BG_GRAD, .value = { .ptr = val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_BG_IMAGE_SRC(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_BG_IMAGE_SRC, .value = { .ptr = val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_BG_IMAGE_OPA(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_BG_IMAGE_OPA, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_BG_IMAGE_RECOLOR(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_BG_IMAGE_RECOLOR, .value = { .color = val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_BG_IMAGE_RECOLOR_OPA(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_BG_IMAGE_RECOLOR_OPA, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_BG_IMAGE_TILED(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_BG_IMAGE_TILED, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_BORDER_COLOR(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_BORDER_COLOR, .value = { .color = val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_BORDER_OPA(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_BORDER_OPA, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_BORDER_WIDTH(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_BORDER_WIDTH, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_BORDER_SIDE(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_BORDER_SIDE, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_BORDER_POST(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_BORDER_POST, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_OUTLINE_WIDTH(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_OUTLINE_WIDTH, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_OUTLINE_COLOR(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_OUTLINE_COLOR, .value = { .color = val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_OUTLINE_OPA(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_OUTLINE_OPA, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_OUTLINE_PAD(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_OUTLINE_PAD, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_SHADOW_WIDTH(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_SHADOW_WIDTH, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_SHADOW_OFFSET_X(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_SHADOW_OFFSET_X, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_SHADOW_OFFSET_Y(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_SHADOW_OFFSET_Y, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_SHADOW_SPREAD(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_SHADOW_SPREAD, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_SHADOW_COLOR(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_SHADOW_COLOR, .value = { .color = val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_SHADOW_OPA(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_SHADOW_OPA, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_IMAGE_OPA(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_IMAGE_OPA, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_IMAGE_RECOLOR(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_IMAGE_RECOLOR, .value = { .color = val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_IMAGE_RECOLOR_OPA(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_IMAGE_RECOLOR_OPA, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_LINE_WIDTH(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_LINE_WIDTH, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_LINE_DASH_WIDTH(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_LINE_DASH_WIDTH, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_LINE_DASH_GAP(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_LINE_DASH_GAP, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_LINE_ROUNDED(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_LINE_ROUNDED, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_LINE_COLOR(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_LINE_COLOR, .value = { .color = val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_LINE_OPA(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_LINE_OPA, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_ARC_WIDTH(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_ARC_WIDTH, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_ARC_ROUNDED(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_ARC_ROUNDED, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_ARC_COLOR(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_ARC_COLOR, .value = { .color = val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_ARC_OPA(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_ARC_OPA, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_ARC_IMAGE_SRC(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_ARC_IMAGE_SRC, .value = { .ptr = val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_TEXT_COLOR(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_TEXT_COLOR, .value = { .color = val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_TEXT_OPA(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_TEXT_OPA, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_TEXT_FONT(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_TEXT_FONT, .value = { .ptr = val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_TEXT_LETTER_SPACE(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_TEXT_LETTER_SPACE, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_TEXT_LINE_SPACE(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_TEXT_LINE_SPACE, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_TEXT_DECOR(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_TEXT_DECOR, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_TEXT_ALIGN(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_TEXT_ALIGN, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_RADIUS(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_RADIUS, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_CLIP_CORNER(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_CLIP_CORNER, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_OPA(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_OPA, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_OPA_LAYERED(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_OPA_LAYERED, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_COLOR_FILTER_DSC(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_COLOR_FILTER_DSC, .value = { .ptr = val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_COLOR_FILTER_OPA(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_COLOR_FILTER_OPA, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_ANIM(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_ANIM, .value = { .ptr = val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_ANIM_DURATION(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_ANIM_DURATION, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_TRANSITION(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_TRANSITION, .value = { .ptr = val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_BLEND_MODE(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_BLEND_MODE, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_LAYOUT(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_LAYOUT, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_BASE_DIR(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_BASE_DIR, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_BITMAP_MASK_SRC(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_BITMAP_MASK_SRC, .value = { .ptr = val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_ROTARY_SENSITIVITY(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_ROTARY_SENSITIVITY, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
#if LV_USE_FLEX
|
||||
|
||||
#define LV_STYLE_CONST_FLEX_FLOW(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_FLEX_FLOW, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_FLEX_MAIN_PLACE(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_FLEX_MAIN_PLACE, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_FLEX_CROSS_PLACE(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_FLEX_CROSS_PLACE, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_FLEX_TRACK_PLACE(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_FLEX_TRACK_PLACE, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_FLEX_GROW(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_FLEX_GROW, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
#endif /*LV_USE_FLEX*/
|
||||
|
||||
#if LV_USE_GRID
|
||||
|
||||
#define LV_STYLE_CONST_GRID_COLUMN_DSC_ARRAY(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_GRID_COLUMN_DSC_ARRAY, .value = { .ptr = val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_GRID_COLUMN_ALIGN(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_GRID_COLUMN_ALIGN, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_GRID_ROW_DSC_ARRAY(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_GRID_ROW_DSC_ARRAY, .value = { .ptr = val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_GRID_ROW_ALIGN(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_GRID_ROW_ALIGN, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_GRID_CELL_COLUMN_POS(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_GRID_CELL_COLUMN_POS, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_GRID_CELL_X_ALIGN(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_GRID_CELL_X_ALIGN, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_GRID_CELL_COLUMN_SPAN(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_GRID_CELL_COLUMN_SPAN, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_GRID_CELL_ROW_POS(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_GRID_CELL_ROW_POS, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_GRID_CELL_Y_ALIGN(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_GRID_CELL_Y_ALIGN, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
|
||||
#define LV_STYLE_CONST_GRID_CELL_ROW_SPAN(val) \
|
||||
{ \
|
||||
.prop = LV_STYLE_GRID_CELL_ROW_SPAN, .value = { .num = (int32_t)val } \
|
||||
}
|
||||
#endif /*LV_USE_GRID*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* LV_STYLE_GEN_H */
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @file lv_style_private.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_STYLE_PRIVATE_H
|
||||
#define LV_STYLE_PRIVATE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lv_style.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_STYLE_PRIVATE_H*/
|
||||
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @file lv_templ.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_TEMPL_H
|
||||
#define LV_TEMPL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_TEMPL_H*/
|
||||
@@ -0,0 +1,125 @@
|
||||
/**
|
||||
* @file lv_text.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_TEXT_H
|
||||
#define LV_TEXT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_conf_internal.h"
|
||||
|
||||
#include "lv_types.h"
|
||||
#include "lv_area.h"
|
||||
#include "../font/lv_font.h"
|
||||
#include "../stdlib/lv_sprintf.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#ifndef LV_TXT_COLOR_CMD
|
||||
#define LV_TXT_COLOR_CMD "#"
|
||||
#endif
|
||||
|
||||
#define LV_TXT_ENC_UTF8 1
|
||||
#define LV_TXT_ENC_ASCII 2
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Options for text rendering.
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
LV_TEXT_FLAG_NONE = 0x00,
|
||||
LV_TEXT_FLAG_EXPAND = 0x01, /**< Ignore max-width to avoid automatic word wrapping*/
|
||||
LV_TEXT_FLAG_FIT = 0x02, /**< Max-width is already equal to the longest line. (Used to skip some calculation)*/
|
||||
LV_TEXT_FLAG_BREAK_ALL = 0x04, /**< To prevent overflow, insert breaks between any two characters.
|
||||
Otherwise breaks are inserted at word boundaries, as configured via LV_TXT_BREAK_CHARS
|
||||
or according to LV_TXT_LINE_BREAK_LONG_LEN, LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN,
|
||||
and LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN.*/
|
||||
LV_TEXT_FLAG_RECOLOR = 0x08, /**< Enable parsing of recolor command*/
|
||||
} lv_text_flag_t;
|
||||
|
||||
/** Label align policy*/
|
||||
typedef enum {
|
||||
LV_TEXT_ALIGN_AUTO, /**< Align text auto*/
|
||||
LV_TEXT_ALIGN_LEFT, /**< Align text to left*/
|
||||
LV_TEXT_ALIGN_CENTER, /**< Align text to center*/
|
||||
LV_TEXT_ALIGN_RIGHT, /**< Align text to right*/
|
||||
} lv_text_align_t;
|
||||
|
||||
/** State machine for text renderer. */
|
||||
typedef enum {
|
||||
LV_TEXT_CMD_STATE_WAIT, /**< Waiting for command*/
|
||||
LV_TEXT_CMD_STATE_PAR, /**< Processing the parameter*/
|
||||
LV_TEXT_CMD_STATE_IN, /**< Processing the command*/
|
||||
} lv_text_cmd_state_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Get size of a text
|
||||
* @param size_res pointer to a 'point_t' variable to store the result
|
||||
* @param text pointer to a text
|
||||
* @param font pointer to font of the text
|
||||
* @param letter_space letter space of the text
|
||||
* @param line_space line space of the text
|
||||
* @param max_width max width of the text (break the lines to fit this size). Set COORD_MAX to avoid
|
||||
* @param flag settings for the text from ::lv_text_flag_t
|
||||
|
||||
* line breaks
|
||||
*/
|
||||
void lv_text_get_size(lv_point_t * size_res, const char * text, const lv_font_t * font, int32_t letter_space,
|
||||
int32_t line_space, int32_t max_width, lv_text_flag_t flag);
|
||||
|
||||
/**
|
||||
* Give the length of a text with a given font
|
||||
* @param txt a '\0' terminate string
|
||||
* @param length length of 'txt' in byte count and not characters (Á is 1 character but 2 bytes in
|
||||
* UTF-8)
|
||||
* @param font pointer to a font
|
||||
* @param letter_space letter space
|
||||
* @return length of a char_num long text
|
||||
*/
|
||||
int32_t lv_text_get_width(const char * txt, uint32_t length, const lv_font_t * font, int32_t letter_space);
|
||||
|
||||
/**
|
||||
* Give the length of a text with a given font with text flags
|
||||
* @param txt a '\0' terminate string
|
||||
* @param length length of 'txt' in byte count and not characters (Á is 1 character but 2 bytes in
|
||||
* UTF-8)
|
||||
* @param font pointer to a font
|
||||
* @param letter_space letter space
|
||||
* @param flags settings for the text from ::lv_text_flag_t
|
||||
* @return length of a char_num long text
|
||||
*/
|
||||
int32_t lv_text_get_width_with_flags(const char * txt, uint32_t length, const lv_font_t * font, int32_t letter_space,
|
||||
lv_text_flag_t flags);
|
||||
|
||||
/**
|
||||
* Check if c is command state
|
||||
* @param state
|
||||
* @param c
|
||||
* @return True if c is state
|
||||
*/
|
||||
bool lv_text_is_cmd(lv_text_cmd_state_t * state, uint32_t c);
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_TEXT_H*/
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* @file lv_text_ap.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_TEXT_AP_H
|
||||
#define LV_TEXT_AP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_text.h"
|
||||
#include "lv_types.h"
|
||||
#include "../draw/lv_draw.h"
|
||||
|
||||
#if LV_USE_ARABIC_PERSIAN_CHARS == 1
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
#define LV_UNDEF_ARABIC_PERSIAN_CHARS (UINT32_MAX)
|
||||
#define LV_AP_ALPHABET_BASE_CODE 0x0622
|
||||
#define LV_AP_END_CHARS_LIST {0,0,0,0,0,{0,0}}
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
uint32_t lv_text_ap_calc_bytes_count(const char * txt);
|
||||
void lv_text_ap_proc(const char * txt, char * txt_out);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif // LV_USE_ARABIC_PERSIAN_CHARS
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_TEXT_AP_H*/
|
||||
@@ -0,0 +1,273 @@
|
||||
/**
|
||||
* @file lv_text_private.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_TEXT_PRIVATE_H
|
||||
#define LV_TEXT_PRIVATE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lv_text.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Get the next line of text. Check line length and break chars too.
|
||||
* @param txt a '\0' terminated string
|
||||
* @param font pointer to a font
|
||||
* @param letter_space letter space
|
||||
* @param max_width max width of the text (break the lines to fit this size). Set COORD_MAX to avoid
|
||||
* line breaks
|
||||
* @param used_width When used_width != NULL, save the width of this line if
|
||||
* flag == LV_TEXT_FLAG_NONE, otherwise save -1.
|
||||
* @param flag settings for the text from 'txt_flag_type' enum
|
||||
* @return the index of the first char of the new line (in byte index not letter index. With UTF-8
|
||||
* they are different)
|
||||
*/
|
||||
uint32_t lv_text_get_next_line(const char * txt, const lv_font_t * font, int32_t letter_space,
|
||||
int32_t max_width, int32_t * used_width, lv_text_flag_t flag);
|
||||
|
||||
/**
|
||||
* Insert a string into another
|
||||
* @param txt_buf the original text (must be big enough for the result text and NULL terminated)
|
||||
* @param pos position to insert (0: before the original text, 1: after the first char etc.)
|
||||
* @param ins_txt text to insert, must be '\0' terminated
|
||||
*/
|
||||
void lv_text_ins(char * txt_buf, uint32_t pos, const char * ins_txt);
|
||||
|
||||
/**
|
||||
* Delete a part of a string
|
||||
* @param txt string to modify, must be '\0' terminated and should point to a heap or stack frame, not read-only memory.
|
||||
* @param pos position where to start the deleting (0: before the first char, 1: after the first
|
||||
* char etc.)
|
||||
* @param len number of characters to delete
|
||||
*/
|
||||
void lv_text_cut(char * txt, uint32_t pos, uint32_t len);
|
||||
|
||||
/**
|
||||
* return a new formatted text. Memory will be allocated to store the text.
|
||||
* @param fmt `printf`-like format
|
||||
* @param ap items to print
|
||||
|
||||
* @return pointer to the allocated text string.
|
||||
*/
|
||||
char * lv_text_set_text_vfmt(const char * fmt, va_list ap) LV_FORMAT_ATTRIBUTE(1, 0);
|
||||
|
||||
/**
|
||||
* Decode two encoded character from a string.
|
||||
* @param txt pointer to '\0' terminated string
|
||||
* @param letter the first decoded Unicode character or 0 on invalid data code
|
||||
* @param letter_next the second decoded Unicode character or 0 on invalid data code
|
||||
* @param ofs start index in 'txt' where to start.
|
||||
* After the call it will point to the next encoded char in 'txt'.
|
||||
* NULL to use txt[0] as index
|
||||
*/
|
||||
void lv_text_encoded_letter_next_2(const char * txt, uint32_t * letter, uint32_t * letter_next, uint32_t * ofs);
|
||||
|
||||
/**
|
||||
* Test if char is break char or not (a text can broken here or not)
|
||||
* @param letter a letter
|
||||
* @return false: 'letter' is not break char
|
||||
*/
|
||||
static inline bool lv_text_is_break_char(uint32_t letter)
|
||||
{
|
||||
uint8_t i;
|
||||
bool ret = false;
|
||||
|
||||
/*Compare the letter to TXT_BREAK_CHARS*/
|
||||
for(i = 0; LV_TXT_BREAK_CHARS[i] != '\0'; i++) {
|
||||
if(letter == (uint32_t)LV_TXT_BREAK_CHARS[i]) {
|
||||
ret = true; /*If match then it is break char*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if char is break char or not (a text can broken here or not)
|
||||
* @param letter a letter
|
||||
* @return false: 'letter' is not break char
|
||||
*/
|
||||
static inline bool lv_text_is_a_word(uint32_t letter)
|
||||
{
|
||||
/*Cheap check on invalid letter*/
|
||||
if(letter == 0) return false;
|
||||
|
||||
/*CJK Unified Ideographs*/
|
||||
if(letter >= 0x4E00 && letter <= 0x9FFF) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*Fullwidth ASCII variants*/
|
||||
if(letter >= 0xFF01 && letter <= 0xFF5E) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*CJK symbols and punctuation*/
|
||||
if(letter >= 0x3000 && letter <= 0x303F) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*CJK Radicals Supplement*/
|
||||
if(letter >= 0x2E80 && letter <= 0x2EFF) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*CJK Strokes*/
|
||||
if(letter >= 0x31C0 && letter <= 0x31EF) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*Hiragana and Katakana*/
|
||||
if(letter >= 0x3040 && letter <= 0x30FF) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*Chinese Vertical Forms*/
|
||||
if(letter >= 0xFE10 && letter <= 0xFE1F) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*CJK Compatibility Forms*/
|
||||
if(letter >= 0xFE30 && letter <= 0xFE4F) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if character can be treated as marker, and don't need to be rendered.
|
||||
* Note, this is not a full list. Add your findings to the list.
|
||||
*
|
||||
* @param letter a letter
|
||||
* @return true if so
|
||||
*/
|
||||
static inline bool lv_text_is_marker(uint32_t letter)
|
||||
{
|
||||
if(letter < 0x20) return true;
|
||||
|
||||
/*U+061C ARABIC LETTER MARK, see https://www.compart.com/en/unicode/block/U+0600*/
|
||||
if(letter == 0x061C) return true;
|
||||
|
||||
/*U+115F HANGUL CHOSEONG FILLER, See https://www.compart.com/en/unicode/block/U+1100*/
|
||||
if(letter == 0x115F) return true;
|
||||
/*U+1160 HANGUL JUNGSEONG FILLER*/
|
||||
if(letter == 0x1160) return true;
|
||||
|
||||
/*See https://www.compart.com/en/unicode/block/U+1800*/
|
||||
if(letter >= 0x180B && letter <= 0x180E) return true;
|
||||
|
||||
/*See https://www.compart.com/en/unicode/block/U+2000*/
|
||||
if(letter >= 0x200B && letter <= 0x200F) return true;
|
||||
if(letter >= 0x2028 && letter <= 0x202F) return true;
|
||||
if(letter >= 0x205F && letter <= 0x206F) return true;
|
||||
|
||||
/*U+FEFF ZERO WIDTH NO-BREAK SPACE, see https://www.compart.com/en/unicode/block/U+FE70*/
|
||||
if(letter == 0xFEFF) return true;
|
||||
|
||||
if(letter == 0xF8FF) return true; /*LV_SYMBOL_DUMMY*/
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* GLOBAL FUNCTION POINTERS FOR CHARACTER ENCODING INTERFACE
|
||||
***************************************************************/
|
||||
|
||||
/**
|
||||
* Give the size of an encoded character
|
||||
* @param txt pointer to a character in a string
|
||||
* @return length of the encoded character (1,2,3 ...). O in invalid
|
||||
*/
|
||||
extern uint8_t (*const lv_text_encoded_size)(const char * txt);
|
||||
|
||||
/**
|
||||
* Convert a Unicode letter to encoded
|
||||
* @param letter_uni a Unicode letter
|
||||
* @return Encoded character in Little Endian to be compatible with C chars (e.g. 'Á', 'Ü')
|
||||
*/
|
||||
extern uint32_t (*const lv_text_unicode_to_encoded)(uint32_t letter_uni);
|
||||
|
||||
/**
|
||||
* Convert a wide character, e.g. 'Á' little endian to be compatible with the encoded format.
|
||||
* @param c a wide character
|
||||
* @return `c` in the encoded format
|
||||
*/
|
||||
extern uint32_t (*const lv_text_encoded_conv_wc)(uint32_t c);
|
||||
|
||||
/**
|
||||
* Decode the next encoded character from a string.
|
||||
* @param txt pointer to '\0' terminated string
|
||||
* @param i_start start index in 'txt' where to start.
|
||||
* After the call it will point to the next encoded char in 'txt'.
|
||||
* NULL to use txt[0] as index
|
||||
* @return the decoded Unicode character or 0 on invalid data code
|
||||
*/
|
||||
extern uint32_t (*const lv_text_encoded_next)(const char * txt, uint32_t * i_start);
|
||||
|
||||
/**
|
||||
* Get the previous encoded character form a string.
|
||||
*
|
||||
* @param txt pointer to '\0' terminated string
|
||||
* @param i_start index in 'txt' where to start. After the call it will point to the previous
|
||||
* encoded char in 'txt'.
|
||||
*
|
||||
* @return the decoded Unicode character or 0 on invalid data
|
||||
*/
|
||||
extern uint32_t (*const lv_text_encoded_prev)(const char * txt, uint32_t * i_start);
|
||||
|
||||
/**
|
||||
* Convert a letter index (in the encoded text) to byte index.
|
||||
* E.g. in UTF-8 "AÁRT" index of 'R' is 2 but start at byte 3 because 'Á' is 2 bytes long
|
||||
* @param txt a '\0' terminated UTF-8 string
|
||||
* @param utf8_id character index
|
||||
* @return byte index of the 'enc_id'th letter
|
||||
*/
|
||||
extern uint32_t (*const lv_text_encoded_get_byte_id)(const char * txt, uint32_t utf8_id);
|
||||
|
||||
/**
|
||||
* Convert a byte index (in an encoded text) to character index.
|
||||
* E.g. in UTF-8 "AÁRT" index of 'R' is 2 but start at byte 3 because 'Á' is 2 bytes long
|
||||
* @param txt a '\0' terminated UTF-8 string
|
||||
* @param byte_id byte index
|
||||
* @return character index of the letter at 'byte_id'th position
|
||||
*/
|
||||
extern uint32_t (*const lv_text_encoded_get_char_id)(const char * txt, uint32_t byte_id);
|
||||
|
||||
/**
|
||||
* Get the number of characters (and NOT bytes) in a string.
|
||||
* E.g. in UTF-8 "ÁBC" is 3 characters (but 4 bytes)
|
||||
* @param txt a '\0' terminated char string
|
||||
* @return number of characters
|
||||
*/
|
||||
extern uint32_t (*const lv_text_get_encoded_length)(const char * txt);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_TEXT_PRIVATE_H*/
|
||||
@@ -0,0 +1,210 @@
|
||||
/**
|
||||
* @file lv_timer.h
|
||||
*/
|
||||
|
||||
#ifndef LV_TIMER_H
|
||||
#define LV_TIMER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_conf_internal.h"
|
||||
#include "../tick/lv_tick.h"
|
||||
#include "lv_types.h"
|
||||
#include "lv_ll.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#ifndef LV_ATTRIBUTE_TIMER_HANDLER
|
||||
#define LV_ATTRIBUTE_TIMER_HANDLER
|
||||
#endif
|
||||
|
||||
#define LV_NO_TIMER_READY 0xFFFFFFFF
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Timers execute this type of functions.
|
||||
*/
|
||||
typedef void (*lv_timer_cb_t)(lv_timer_t *);
|
||||
|
||||
/**
|
||||
* Timer handler resume this type of function.
|
||||
*/
|
||||
typedef void (*lv_timer_handler_resume_cb_t)(void * data);
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
//! @cond Doxygen_Suppress
|
||||
|
||||
/**
|
||||
* Call it periodically to handle lv_timers.
|
||||
* @return time till it needs to be run next (in ms)
|
||||
*/
|
||||
LV_ATTRIBUTE_TIMER_HANDLER uint32_t lv_timer_handler(void);
|
||||
|
||||
//! @endcond
|
||||
|
||||
/**
|
||||
* Call it in the super-loop of main() or threads. It will run lv_timer_handler()
|
||||
* with a given period in ms. You can use it with sleep or delay in OS environment.
|
||||
* This function is used to simplify the porting.
|
||||
* @param period the period for running lv_timer_handler()
|
||||
* @return the time after which it must be called again
|
||||
*/
|
||||
LV_ATTRIBUTE_TIMER_HANDLER uint32_t lv_timer_handler_run_in_period(uint32_t period);
|
||||
|
||||
/**
|
||||
* Call it in the super-loop of main() or threads. It will automatically call lv_timer_handler() at the right time.
|
||||
* This function is used to simplify the porting.
|
||||
*/
|
||||
LV_ATTRIBUTE_TIMER_HANDLER void lv_timer_periodic_handler(void);
|
||||
|
||||
/**
|
||||
* Set the resume callback to the timer handler
|
||||
* @param cb the function to call when timer handler is resumed
|
||||
* @param data pointer to a resume data
|
||||
*/
|
||||
void lv_timer_handler_set_resume_cb(lv_timer_handler_resume_cb_t cb, void * data);
|
||||
|
||||
/**
|
||||
* Create an "empty" timer. It needs to be initialized with at least
|
||||
* `lv_timer_set_cb` and `lv_timer_set_period`
|
||||
* @return pointer to the created timer
|
||||
*/
|
||||
lv_timer_t * lv_timer_create_basic(void);
|
||||
|
||||
/**
|
||||
* Create a new lv_timer
|
||||
* @param timer_xcb a callback to call periodically.
|
||||
* (the 'x' in the argument name indicates that it's not a fully generic function because it not follows
|
||||
* the `func_name(object, callback, ...)` convention)
|
||||
* @param period call period in ms unit
|
||||
* @param user_data custom parameter
|
||||
* @return pointer to the new timer
|
||||
*/
|
||||
lv_timer_t * lv_timer_create(lv_timer_cb_t timer_xcb, uint32_t period, void * user_data);
|
||||
|
||||
/**
|
||||
* Delete a lv_timer
|
||||
* @param timer pointer to an lv_timer
|
||||
*/
|
||||
void lv_timer_delete(lv_timer_t * timer);
|
||||
|
||||
/**
|
||||
* Pause a timer.
|
||||
* @param timer pointer to an lv_timer
|
||||
*/
|
||||
void lv_timer_pause(lv_timer_t * timer);
|
||||
|
||||
/**
|
||||
* Resume a timer.
|
||||
* @param timer pointer to an lv_timer
|
||||
*/
|
||||
void lv_timer_resume(lv_timer_t * timer);
|
||||
|
||||
/**
|
||||
* Set the callback to the timer (the function to call periodically)
|
||||
* @param timer pointer to a timer
|
||||
* @param timer_cb the function to call periodically
|
||||
*/
|
||||
void lv_timer_set_cb(lv_timer_t * timer, lv_timer_cb_t timer_cb);
|
||||
|
||||
/**
|
||||
* Set new period for a lv_timer
|
||||
* @param timer pointer to a lv_timer
|
||||
* @param period the new period
|
||||
*/
|
||||
void lv_timer_set_period(lv_timer_t * timer, uint32_t period);
|
||||
|
||||
/**
|
||||
* Make a lv_timer ready. It will not wait its period.
|
||||
* @param timer pointer to a lv_timer.
|
||||
*/
|
||||
void lv_timer_ready(lv_timer_t * timer);
|
||||
|
||||
/**
|
||||
* Set the number of times a timer will repeat.
|
||||
* @param timer pointer to a lv_timer.
|
||||
* @param repeat_count -1 : infinity; 0 : stop ; n>0: residual times
|
||||
*/
|
||||
void lv_timer_set_repeat_count(lv_timer_t * timer, int32_t repeat_count);
|
||||
|
||||
/**
|
||||
* Set whether a lv_timer will be deleted automatically when it is called `repeat_count` times.
|
||||
* @param timer pointer to a lv_timer.
|
||||
* @param auto_delete true: auto delete; false: timer will be paused when it is called `repeat_count` times.
|
||||
*/
|
||||
void lv_timer_set_auto_delete(lv_timer_t * timer, bool auto_delete);
|
||||
|
||||
/**
|
||||
* Set custom parameter to the lv_timer.
|
||||
* @param timer pointer to a lv_timer.
|
||||
* @param user_data custom parameter
|
||||
*/
|
||||
void lv_timer_set_user_data(lv_timer_t * timer, void * user_data);
|
||||
|
||||
/**
|
||||
* Reset a lv_timer.
|
||||
* It will be called the previously set period milliseconds later.
|
||||
* @param timer pointer to a lv_timer.
|
||||
*/
|
||||
void lv_timer_reset(lv_timer_t * timer);
|
||||
|
||||
/**
|
||||
* Enable or disable the whole lv_timer handling
|
||||
* @param en true: lv_timer handling is running, false: lv_timer handling is suspended
|
||||
*/
|
||||
void lv_timer_enable(bool en);
|
||||
|
||||
/**
|
||||
* Get idle percentage
|
||||
* @return the lv_timer idle in percentage
|
||||
*/
|
||||
uint32_t lv_timer_get_idle(void);
|
||||
|
||||
/**
|
||||
* Get the time remaining until the next timer will run
|
||||
* @return the time remaining in ms
|
||||
*/
|
||||
uint32_t lv_timer_get_time_until_next(void);
|
||||
|
||||
/**
|
||||
* Iterate through the timers
|
||||
* @param timer NULL to start iteration or the previous return value to get the next timer
|
||||
* @return the next timer or NULL if there is no more timer
|
||||
*/
|
||||
lv_timer_t * lv_timer_get_next(lv_timer_t * timer);
|
||||
|
||||
/**
|
||||
* Get the user_data passed when the timer was created
|
||||
* @param timer pointer to the lv_timer
|
||||
* @return pointer to the user_data
|
||||
*/
|
||||
void * lv_timer_get_user_data(lv_timer_t * timer);
|
||||
|
||||
/**
|
||||
* Get the pause state of a timer
|
||||
* @param timer pointer to a lv_timer
|
||||
* @return true: timer is paused; false: timer is running
|
||||
*/
|
||||
bool lv_timer_get_paused(lv_timer_t * timer);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* @file lv_timer_private.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_TIMER_PRIVATE_H
|
||||
#define LV_TIMER_PRIVATE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lv_timer.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Descriptor of a lv_timer
|
||||
*/
|
||||
struct _lv_timer_t {
|
||||
uint32_t period; /**< How often the timer should run */
|
||||
uint32_t last_run; /**< Last time the timer ran */
|
||||
lv_timer_cb_t timer_cb; /**< Timer function */
|
||||
void * user_data; /**< Custom user data */
|
||||
int32_t repeat_count; /**< 1: One time; -1 : infinity; n>0: residual times */
|
||||
uint32_t paused : 1;
|
||||
uint32_t auto_delete : 1;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
lv_ll_t timer_ll; /**< Linked list to store the lv_timers */
|
||||
|
||||
bool lv_timer_run;
|
||||
uint8_t idle_last;
|
||||
bool timer_deleted;
|
||||
bool timer_created;
|
||||
uint32_t timer_time_until_next;
|
||||
|
||||
bool already_running;
|
||||
uint32_t periodic_last_tick;
|
||||
uint32_t busy_time;
|
||||
uint32_t idle_period_start;
|
||||
uint32_t run_cnt;
|
||||
|
||||
lv_timer_handler_resume_cb_t resume_cb;
|
||||
void * resume_data;
|
||||
} lv_timer_state_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Init the lv_timer module
|
||||
*/
|
||||
void lv_timer_core_init(void);
|
||||
|
||||
/**
|
||||
* Deinit the lv_timer module
|
||||
*/
|
||||
void lv_timer_core_deinit(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_TIMER_PRIVATE_H*/
|
||||
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* @file lv_tree.h
|
||||
* Tree. The tree nodes are dynamically allocated by the 'lv_mem' module.
|
||||
*/
|
||||
|
||||
#ifndef LV_TREE_H
|
||||
#define LV_TREE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_types.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
#define LV_TREE_NODE(n) ((lv_tree_node_t*)(n))
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
struct _lv_tree_node_t;
|
||||
|
||||
/**
|
||||
* Describe the common methods of every object.
|
||||
* Similar to a C++ class.
|
||||
*/
|
||||
typedef struct _lv_tree_class_t {
|
||||
const struct _lv_tree_class_t * base_class;
|
||||
uint32_t instance_size;
|
||||
void (*constructor_cb)(const struct _lv_tree_class_t * class_p, struct _lv_tree_node_t * node);
|
||||
void (*destructor_cb)(const struct _lv_tree_class_t * class_p, struct _lv_tree_node_t * node);
|
||||
} lv_tree_class_t;
|
||||
|
||||
/** Description of a tree node*/
|
||||
typedef struct _lv_tree_node_t {
|
||||
struct _lv_tree_node_t * parent;
|
||||
struct _lv_tree_node_t ** children;
|
||||
uint32_t child_cnt;
|
||||
uint32_t child_cap;
|
||||
const struct _lv_tree_class_t * class_p;
|
||||
} lv_tree_node_t;
|
||||
|
||||
enum {
|
||||
LV_TREE_WALK_PRE_ORDER = 0,
|
||||
LV_TREE_WALK_POST_ORDER,
|
||||
};
|
||||
typedef uint8_t lv_tree_walk_mode_t;
|
||||
|
||||
typedef bool (*lv_tree_traverse_cb_t)(const lv_tree_node_t * node, void * user_data);
|
||||
typedef bool (*lv_tree_before_cb_t)(const lv_tree_node_t * node, void * user_data);
|
||||
typedef void (*lv_tree_after_cb_t)(const lv_tree_node_t * node, void * user_data);
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
extern const lv_tree_class_t lv_tree_node_class;
|
||||
|
||||
/**
|
||||
* @brief Create a tree node
|
||||
* @param class_p pointer to a class of the node
|
||||
* @param parent pointer to the parent node (or NULL if it's the root node)
|
||||
* @return pointer to the new node
|
||||
*/
|
||||
lv_tree_node_t * lv_tree_node_create(const lv_tree_class_t * class_p, lv_tree_node_t * parent);
|
||||
|
||||
/**
|
||||
* @brief Delete a tree node and all its children recursively
|
||||
* @param node pointer to the node to delete
|
||||
*/
|
||||
void lv_tree_node_delete(lv_tree_node_t * node);
|
||||
|
||||
/**
|
||||
* @brief Walk the tree recursively and call a callback function on each node
|
||||
* @param node pointer to the root node of the tree
|
||||
* @param mode LV_TREE_WALK_PRE_ORDER or LV_TREE_WALK_POST_ORDER
|
||||
* @param cb callback function to call on each node
|
||||
* @param bcb callback function to call before visiting a node
|
||||
* @param acb callback function to call after visiting a node
|
||||
* @param user_data user data to pass to the callback functions
|
||||
* @return true: traversal is finished; false: traversal breaked
|
||||
*/
|
||||
bool lv_tree_walk(const lv_tree_node_t * node,
|
||||
lv_tree_walk_mode_t mode,
|
||||
lv_tree_traverse_cb_t cb,
|
||||
lv_tree_before_cb_t bcb,
|
||||
lv_tree_after_cb_t acb,
|
||||
void * user_data);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,381 @@
|
||||
/**
|
||||
* @file lv_types.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_TYPES_H
|
||||
#define LV_TYPES_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_conf_internal.h"
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
#include LV_STDINT_INCLUDE
|
||||
#include LV_STDDEF_INCLUDE
|
||||
#include LV_STDBOOL_INCLUDE
|
||||
#include LV_INTTYPES_INCLUDE
|
||||
#include LV_LIMITS_INCLUDE
|
||||
#include LV_STDARG_INCLUDE
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/*If __UINTPTR_MAX__ or UINTPTR_MAX are available, use them to determine arch size*/
|
||||
#if defined(__UINTPTR_MAX__) && __UINTPTR_MAX__ > 0xFFFFFFFF
|
||||
#define LV_ARCH_64
|
||||
|
||||
#elif defined(UINTPTR_MAX) && UINTPTR_MAX > 0xFFFFFFFF
|
||||
#define LV_ARCH_64
|
||||
|
||||
/*Otherwise use compiler-dependent means to determine arch size*/
|
||||
#elif defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__) || defined (__aarch64__)
|
||||
#define LV_ARCH_64
|
||||
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/* Exclude C enum and struct definitions when included by assembly code */
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/**
|
||||
* LVGL error codes.
|
||||
*/
|
||||
typedef enum {
|
||||
LV_RESULT_INVALID = 0, /*Typically indicates that the object is deleted (become invalid) in the action
|
||||
function or an operation was failed*/
|
||||
LV_RESULT_OK, /*The object is valid (no deleted) after the action*/
|
||||
} lv_result_t;
|
||||
|
||||
#if defined(__cplusplus) || __STDC_VERSION__ >= 199901L
|
||||
/*If c99 or newer, use the definition of uintptr_t directly from <stdint.h>*/
|
||||
typedef uintptr_t lv_uintptr_t;
|
||||
typedef intptr_t lv_intptr_t;
|
||||
|
||||
#else
|
||||
|
||||
/*Otherwise, use the arch size determination*/
|
||||
#ifdef LV_ARCH_64
|
||||
typedef uint64_t lv_uintptr_t;
|
||||
typedef int64_t lv_intptr_t;
|
||||
#else
|
||||
typedef uint32_t lv_uintptr_t;
|
||||
typedef int32_t lv_intptr_t;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if LV_USE_FLOAT
|
||||
typedef float lv_value_precise_t;
|
||||
#else
|
||||
typedef int32_t lv_value_precise_t;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Typedefs from various lvgl modules.
|
||||
* They are defined here to avoid circular dependencies.
|
||||
*/
|
||||
|
||||
typedef struct _lv_obj_t lv_obj_t;
|
||||
|
||||
typedef uint16_t lv_state_t;
|
||||
typedef uint32_t lv_part_t;
|
||||
|
||||
typedef uint8_t lv_opa_t;
|
||||
|
||||
typedef uint8_t lv_style_prop_t;
|
||||
|
||||
typedef struct _lv_obj_class_t lv_obj_class_t;
|
||||
|
||||
typedef struct _lv_group_t lv_group_t;
|
||||
|
||||
typedef struct _lv_display_t lv_display_t;
|
||||
|
||||
typedef struct _lv_layer_t lv_layer_t;
|
||||
typedef struct _lv_draw_unit_t lv_draw_unit_t;
|
||||
typedef struct _lv_draw_task_t lv_draw_task_t;
|
||||
|
||||
typedef struct _lv_indev_t lv_indev_t;
|
||||
|
||||
typedef struct _lv_event_t lv_event_t;
|
||||
|
||||
typedef struct _lv_timer_t lv_timer_t;
|
||||
|
||||
typedef struct _lv_theme_t lv_theme_t;
|
||||
|
||||
typedef struct _lv_anim_t lv_anim_t;
|
||||
|
||||
typedef struct _lv_font_t lv_font_t;
|
||||
|
||||
typedef struct _lv_image_decoder_t lv_image_decoder_t;
|
||||
|
||||
typedef struct _lv_image_decoder_dsc_t lv_image_decoder_dsc_t;
|
||||
|
||||
typedef struct _lv_fragment_t lv_fragment_t;
|
||||
typedef struct _lv_fragment_class_t lv_fragment_class_t;
|
||||
typedef struct _lv_fragment_managed_states_t lv_fragment_managed_states_t;
|
||||
|
||||
typedef struct _lv_profiler_builtin_config_t lv_profiler_builtin_config_t;
|
||||
|
||||
typedef struct _lv_rb_node_t lv_rb_node_t;
|
||||
|
||||
typedef struct _lv_rb_t lv_rb_t;
|
||||
|
||||
typedef struct _lv_color_filter_dsc_t lv_color_filter_dsc_t;
|
||||
|
||||
typedef struct _lv_event_dsc_t lv_event_dsc_t;
|
||||
|
||||
typedef struct _lv_fs_file_cache_t lv_fs_file_cache_t;
|
||||
|
||||
typedef struct _lv_fs_path_ex_t lv_fs_path_ex_t;
|
||||
|
||||
typedef struct _lv_image_decoder_args_t lv_image_decoder_args_t;
|
||||
|
||||
typedef struct _lv_image_cache_data_t lv_image_cache_data_t;
|
||||
|
||||
typedef struct _lv_image_header_cache_data_t lv_image_header_cache_data_t;
|
||||
|
||||
typedef struct _lv_draw_mask_t lv_draw_mask_t;
|
||||
|
||||
typedef struct _lv_grad_t lv_grad_t;
|
||||
|
||||
typedef struct _lv_draw_label_hint_t lv_draw_label_hint_t;
|
||||
|
||||
typedef struct _lv_draw_glyph_dsc_t lv_draw_glyph_dsc_t;
|
||||
|
||||
typedef struct _lv_draw_image_sup_t lv_draw_image_sup_t;
|
||||
|
||||
typedef struct _lv_draw_mask_rect_dsc_t lv_draw_mask_rect_dsc_t;
|
||||
|
||||
typedef struct _lv_obj_style_t lv_obj_style_t;
|
||||
|
||||
typedef struct _lv_obj_style_transition_dsc_t lv_obj_style_transition_dsc_t;
|
||||
|
||||
typedef struct _lv_hit_test_info_t lv_hit_test_info_t;
|
||||
|
||||
typedef struct _lv_cover_check_info_t lv_cover_check_info_t;
|
||||
|
||||
typedef struct _lv_obj_spec_attr_t lv_obj_spec_attr_t;
|
||||
|
||||
typedef struct _lv_image_t lv_image_t;
|
||||
|
||||
typedef struct _lv_animimg_t lv_animimg_t;
|
||||
|
||||
typedef struct _lv_arc_t lv_arc_t;
|
||||
|
||||
typedef struct _lv_label_t lv_label_t;
|
||||
|
||||
typedef struct _lv_bar_anim_t lv_bar_anim_t;
|
||||
|
||||
typedef struct _lv_bar_t lv_bar_t;
|
||||
|
||||
typedef struct _lv_button_t lv_button_t;
|
||||
|
||||
typedef struct _lv_buttonmatrix_t lv_buttonmatrix_t;
|
||||
|
||||
typedef struct _lv_calendar_t lv_calendar_t;
|
||||
|
||||
typedef struct _lv_canvas_t lv_canvas_t;
|
||||
|
||||
typedef struct _lv_chart_series_t lv_chart_series_t;
|
||||
|
||||
typedef struct _lv_chart_cursor_t lv_chart_cursor_t;
|
||||
|
||||
typedef struct _lv_chart_t lv_chart_t;
|
||||
|
||||
typedef struct _lv_checkbox_t lv_checkbox_t;
|
||||
|
||||
typedef struct _lv_dropdown_t lv_dropdown_t;
|
||||
|
||||
typedef struct _lv_dropdown_list_t lv_dropdown_list_t;
|
||||
|
||||
typedef struct _lv_imagebutton_src_info_t lv_imagebutton_src_info_t;
|
||||
|
||||
typedef struct _lv_imagebutton_t lv_imagebutton_t;
|
||||
|
||||
typedef struct _lv_keyboard_t lv_keyboard_t;
|
||||
|
||||
typedef struct _lv_led_t lv_led_t;
|
||||
|
||||
typedef struct _lv_line_t lv_line_t;
|
||||
|
||||
typedef struct _lv_menu_load_page_event_data_t lv_menu_load_page_event_data_t;
|
||||
|
||||
typedef struct _lv_menu_history_t lv_menu_history_t;
|
||||
|
||||
typedef struct _lv_menu_t lv_menu_t;
|
||||
|
||||
typedef struct _lv_menu_page_t lv_menu_page_t;
|
||||
|
||||
typedef struct _lv_msgbox_t lv_msgbox_t;
|
||||
|
||||
typedef struct _lv_roller_t lv_roller_t;
|
||||
|
||||
typedef struct _lv_scale_section_t lv_scale_section_t;
|
||||
|
||||
typedef struct _lv_scale_t lv_scale_t;
|
||||
|
||||
typedef struct _lv_slider_t lv_slider_t;
|
||||
|
||||
typedef struct _lv_span_t lv_span_t;
|
||||
|
||||
typedef struct _lv_spangroup_t lv_spangroup_t;
|
||||
|
||||
typedef struct _lv_textarea_t lv_textarea_t;
|
||||
|
||||
typedef struct _lv_spinbox_t lv_spinbox_t;
|
||||
|
||||
typedef struct _lv_switch_t lv_switch_t;
|
||||
|
||||
typedef struct _lv_table_cell_t lv_table_cell_t;
|
||||
|
||||
typedef struct _lv_table_t lv_table_t;
|
||||
|
||||
typedef struct _lv_tabview_t lv_tabview_t;
|
||||
|
||||
typedef struct _lv_tileview_t lv_tileview_t;
|
||||
|
||||
typedef struct _lv_tileview_tile_t lv_tileview_tile_t;
|
||||
|
||||
typedef struct _lv_win_t lv_win_t;
|
||||
|
||||
typedef struct _lv_observer_t lv_observer_t;
|
||||
|
||||
typedef struct _lv_monkey_config_t lv_monkey_config_t;
|
||||
|
||||
typedef struct _lv_ime_pinyin_t lv_ime_pinyin_t;
|
||||
|
||||
typedef struct _lv_file_explorer_t lv_file_explorer_t;
|
||||
|
||||
typedef struct _lv_barcode_t lv_barcode_t;
|
||||
|
||||
typedef struct _lv_gif_t lv_gif_t;
|
||||
|
||||
typedef struct _lv_qrcode_t lv_qrcode_t;
|
||||
|
||||
typedef struct _lv_freetype_outline_vector_t lv_freetype_outline_vector_t;
|
||||
|
||||
typedef struct _lv_freetype_outline_event_param_t lv_freetype_outline_event_param_t;
|
||||
|
||||
typedef struct _lv_fpoint_t lv_fpoint_t;
|
||||
|
||||
typedef struct _lv_matrix_t lv_matrix_t;
|
||||
|
||||
typedef struct _lv_vector_path_t lv_vector_path_t;
|
||||
|
||||
typedef struct _lv_vector_gradient_t lv_vector_gradient_t;
|
||||
|
||||
typedef struct _lv_vector_fill_dsc_t lv_vector_fill_dsc_t;
|
||||
|
||||
typedef struct _lv_vector_stroke_dsc_t lv_vector_stroke_dsc_t;
|
||||
|
||||
typedef struct _lv_vector_draw_dsc_t lv_vector_draw_dsc_t;
|
||||
|
||||
typedef struct _lv_draw_vector_task_dsc_t lv_draw_vector_task_dsc_t;
|
||||
|
||||
typedef struct _lv_vector_dsc_t lv_vector_dsc_t;
|
||||
|
||||
typedef struct _lv_xkb_t lv_xkb_t;
|
||||
|
||||
typedef struct _lv_libinput_event_t lv_libinput_event_t;
|
||||
|
||||
typedef struct _lv_libinput_t lv_libinput_t;
|
||||
|
||||
typedef struct _lv_draw_sw_unit_t lv_draw_sw_unit_t;
|
||||
|
||||
typedef struct _lv_draw_sw_mask_common_dsc_t lv_draw_sw_mask_common_dsc_t;
|
||||
|
||||
typedef struct _lv_draw_sw_mask_line_param_t lv_draw_sw_mask_line_param_t;
|
||||
|
||||
typedef struct _lv_draw_sw_mask_angle_param_t lv_draw_sw_mask_angle_param_t;
|
||||
|
||||
typedef struct _lv_draw_sw_mask_radius_param_t lv_draw_sw_mask_radius_param_t;
|
||||
|
||||
typedef struct _lv_draw_sw_mask_fade_param_t lv_draw_sw_mask_fade_param_t;
|
||||
|
||||
typedef struct _lv_draw_sw_mask_map_param_t lv_draw_sw_mask_map_param_t;
|
||||
|
||||
typedef struct _lv_draw_sw_blend_dsc_t lv_draw_sw_blend_dsc_t;
|
||||
|
||||
typedef struct _lv_draw_sw_blend_fill_dsc_t lv_draw_sw_blend_fill_dsc_t;
|
||||
|
||||
typedef struct _lv_draw_sw_blend_image_dsc_t lv_draw_sw_blend_image_dsc_t;
|
||||
|
||||
typedef struct _lv_draw_buf_handlers_t lv_draw_buf_handlers_t;
|
||||
|
||||
typedef struct _lv_rlottie_t lv_rlottie_t;
|
||||
|
||||
typedef struct _lv_ffmpeg_player_t lv_ffmpeg_player_t;
|
||||
|
||||
typedef struct _lv_glfw_window_t lv_glfw_window_t;
|
||||
typedef struct _lv_glfw_texture_t lv_glfw_texture_t;
|
||||
|
||||
typedef uint32_t lv_prop_id_t;
|
||||
|
||||
typedef struct _lv_array_t lv_array_t;
|
||||
|
||||
typedef struct _lv_iter_t lv_iter_t;
|
||||
|
||||
typedef struct _lv_circle_buf_t lv_circle_buf_t;
|
||||
|
||||
typedef struct _lv_draw_buf_t lv_draw_buf_t;
|
||||
|
||||
#if LV_USE_OBJ_PROPERTY
|
||||
typedef struct _lv_property_name_t lv_property_name_t;
|
||||
#endif
|
||||
|
||||
#if LV_USE_SYSMON
|
||||
|
||||
typedef struct _lv_sysmon_backend_data_t lv_sysmon_backend_data_t;
|
||||
|
||||
#if LV_USE_PERF_MONITOR
|
||||
typedef struct _lv_sysmon_perf_info_t lv_sysmon_perf_info_t;
|
||||
#endif /*LV_USE_PERF_MONITOR*/
|
||||
|
||||
#endif /*LV_USE_SYSMON*/
|
||||
|
||||
#endif /*__ASSEMBLY__*/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#define LV_UNUSED(x) ((void)x)
|
||||
|
||||
#define _LV_CONCAT(x, y) x ## y
|
||||
#define LV_CONCAT(x, y) _LV_CONCAT(x, y)
|
||||
#undef _LV_CONCAT
|
||||
|
||||
#define _LV_CONCAT3(x, y, z) x ## y ## z
|
||||
#define LV_CONCAT3(x, y, z) _LV_CONCAT3(x, y, z)
|
||||
#undef _LV_CONCAT3
|
||||
|
||||
#if defined(PYCPARSER) || defined(__CC_ARM)
|
||||
#define LV_FORMAT_ATTRIBUTE(fmtstr, vararg)
|
||||
#elif defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 4) || __GNUC__ > 4)
|
||||
#define LV_FORMAT_ATTRIBUTE(fmtstr, vararg) __attribute__((format(gnu_printf, fmtstr, vararg)))
|
||||
#elif (defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) || defined(__IAR_SYSTEMS_ICC__))
|
||||
#define LV_FORMAT_ATTRIBUTE(fmtstr, vararg) __attribute__((format(printf, fmtstr, vararg)))
|
||||
#else
|
||||
#define LV_FORMAT_ATTRIBUTE(fmtstr, vararg)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_TYPES_H*/
|
||||
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* @file lv_utils.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_UTILS_H
|
||||
#define LV_UTILS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lv_types.h"
|
||||
#include "../draw/lv_draw_buf.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/** Searches base[0] to base[n - 1] for an item that matches *key.
|
||||
*
|
||||
* @note The function cmp must return negative if it's first
|
||||
* argument (the search key) is less that it's second (a table entry),
|
||||
* zero if equal, and positive if greater.
|
||||
*
|
||||
* @note Items in the array must be in ascending order.
|
||||
*
|
||||
* @param key Pointer to item being searched for
|
||||
* @param base Pointer to first element to search
|
||||
* @param n Number of elements
|
||||
* @param size Size of each element
|
||||
* @param cmp Pointer to comparison function (see unicode_list_compare()
|
||||
* as a comparison function example)
|
||||
*
|
||||
* @return a pointer to a matching item, or NULL if none exists.
|
||||
*/
|
||||
void * lv_utils_bsearch(const void * key, const void * base, size_t n, size_t size,
|
||||
int (*cmp)(const void * pRef, const void * pElement));
|
||||
|
||||
/**
|
||||
* Save a draw buf to a file
|
||||
* @param draw_buf pointer to a draw buffer
|
||||
* @param path path to the file to save
|
||||
* @return LV_RESULT_OK: success; LV_RESULT_INVALID: error
|
||||
*/
|
||||
lv_result_t lv_draw_buf_save_to_file(const lv_draw_buf_t * draw_buf, const char * path);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user