diff options
Diffstat (limited to 'src/libs/lvgl/src/lv_misc')
36 files changed, 0 insertions, 8452 deletions
diff --git a/src/libs/lvgl/src/lv_misc/lv_anim.c b/src/libs/lvgl/src/lv_misc/lv_anim.c deleted file mode 100644 index 77bd87b9..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_anim.c +++ /dev/null @@ -1,474 +0,0 @@ -/** - * @file anim.c - * - */ - -/********************* - * INCLUDES - *********************/ -#include "lv_anim.h" - -#if LV_USE_ANIMATION -#include <stddef.h> -#include <string.h> -#include "../lv_core/lv_debug.h" -#include "../lv_hal/lv_hal_tick.h" -#include "lv_task.h" -#include "lv_math.h" -#include "lv_gc.h" - -#if defined(LV_GC_INCLUDE) -#include LV_GC_INCLUDE -#endif /* LV_ENABLE_GC */ - -/********************* - * DEFINES - *********************/ -#define LV_ANIM_RESOLUTION 1024 -#define LV_ANIM_RES_SHIFT 10 - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ -static void anim_task(lv_task_t * param); -static bool anim_ready_handler(lv_anim_t * a); - -/********************** - * STATIC VARIABLES - **********************/ -static uint32_t last_task_run; -static bool anim_list_changed; - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -/** - * Init. the animation module - */ -void lv_anim_core_init(void) -{ - lv_ll_init(&LV_GC_ROOT(_lv_anim_ll), sizeof(lv_anim_t)); - last_task_run = lv_tick_get(); - lv_task_create(anim_task, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, NULL); -} - -/** - * Initialize an animation variable. - * E.g.: - * lv_anim_t a; - * lv_anim_init(&a); - * lv_anim_set_...(&a); - * lv_anim_craete(&a); - * @param a pointer to an `lv_anim_t` variable to initialize - */ -void lv_anim_init(lv_anim_t * a) -{ - memset(a, 0, sizeof(lv_anim_t)); - a->time = 500; - a->start = 0; - a->end = 100; - a->path_cb = lv_anim_path_linear; -} -/** - * Create an animation - * @param a an initialized 'anim_t' variable. Not required after call. - */ -void lv_anim_create(lv_anim_t * a) -{ - LV_LOG_TRACE("animation create started") - /* Do not let two animations for the same 'var' with the same 'fp'*/ - if(a->exec_cb != NULL) lv_anim_del(a->var, a->exec_cb); /*fp == NULL would delete all animations of var*/ - - /*Add the new animation to the animation linked list*/ - lv_anim_t * new_anim = lv_ll_ins_head(&LV_GC_ROOT(_lv_anim_ll)); - LV_ASSERT_MEM(new_anim); - if(new_anim == NULL) return; - - /*Initialize the animation descriptor*/ - a->playback_now = 0; - memcpy(new_anim, a, sizeof(lv_anim_t)); - - /*Set the start value*/ - if(new_anim->exec_cb) new_anim->exec_cb(new_anim->var, new_anim->start); - - /* Creating an animation changed the linked list. - * It's important if it happens in a ready callback. (see `anim_task`)*/ - anim_list_changed = true; - - LV_LOG_TRACE("animation created") -} - -/** - * Delete an animation 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 delete all the animations of 'var' - * @return true: at least 1 animation is deleted, false: no animation is deleted - */ -bool lv_anim_del(void * var, lv_anim_exec_xcb_t exec_cb) -{ - lv_anim_t * a; - lv_anim_t * a_next; - bool del = false; - a = lv_ll_get_head(&LV_GC_ROOT(_lv_anim_ll)); - while(a != NULL) { - /*'a' might be deleted, so get the next object while 'a' is valid*/ - a_next = lv_ll_get_next(&LV_GC_ROOT(_lv_anim_ll), a); - - if(a->var == var && (a->exec_cb == exec_cb || exec_cb == NULL)) { - lv_ll_rem(&LV_GC_ROOT(_lv_anim_ll), a); - lv_mem_free(a); - anim_list_changed = true; /*Read by `anim_task`. It need to know if a delete occurred in - the linked list*/ - del = true; - } - - a = a_next; - } - - return del; -} - -/** - * Get the number of currently running animations - * @return the number of running animations - */ -uint16_t lv_anim_count_running(void) -{ - uint16_t cnt = 0; - lv_anim_t * a; - LV_LL_READ(LV_GC_ROOT(_lv_anim_ll), a) cnt++; - - return cnt++; -} - -/** - * Calculate the time of an animation with a given speed and the start and end values - * @param speed speed of animation in unit/sec - * @param start start value of the animation - * @param end end value of the animation - * @return the required time [ms] for the animation with the given parameters - */ -uint32_t lv_anim_speed_to_time(uint16_t speed, lv_anim_value_t start, lv_anim_value_t end) -{ - int32_t d = LV_MATH_ABS((int32_t)start - end); - uint32_t time = (int32_t)((int32_t)(d * 1000) / speed); - - if(time > UINT32_MAX) time = UINT32_MAX; - - if(time == 0) { - time++; - } - - return time; -} - -/** - * Calculate the current value of an animation applying linear characteristic - * @param a pointer to an animation - * @return the current value to set - */ -lv_anim_value_t lv_anim_path_linear(const lv_anim_t * a) -{ - /*Calculate the current step*/ - uint32_t step; - if(a->time == a->act_time) { - step = LV_ANIM_RESOLUTION; /*Use the last value if the time fully elapsed*/ - } else { - step = ((int32_t)a->act_time * LV_ANIM_RESOLUTION) / a->time; - } - - /* Get the new value which will be proportional to `step` - * and the `start` and `end` values*/ - int32_t new_value; - new_value = (int32_t)step * (a->end - a->start); - new_value = new_value >> LV_ANIM_RES_SHIFT; - new_value += a->start; - - return (lv_anim_value_t)new_value; -} - -/** - * Calculate the current value of an animation slowing down the start phase - * @param a pointer to an animation - * @return the current value to set - */ -lv_anim_value_t lv_anim_path_ease_in(const lv_anim_t * a) -{ - /*Calculate the current step*/ - uint32_t t; - if(a->time == a->act_time) - t = 1024; - else - t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time; - - int32_t step = lv_bezier3(t, 0, 1, 1, 1024); - - int32_t new_value; - new_value = (int32_t)step * (a->end - a->start); - new_value = new_value >> 10; - new_value += a->start; - - return (lv_anim_value_t)new_value; -} - -/** - * Calculate the current value of an animation slowing down the end phase - * @param a pointer to an animation - * @return the current value to set - */ -lv_anim_value_t lv_anim_path_ease_out(const lv_anim_t * a) -{ - /*Calculate the current step*/ - - uint32_t t; - if(a->time == a->act_time) - t = 1024; - else - t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time; - - int32_t step = lv_bezier3(t, 0, 1023, 1023, 1024); - - int32_t new_value; - new_value = (int32_t)step * (a->end - a->start); - new_value = new_value >> 10; - new_value += a->start; - - return (lv_anim_value_t)new_value; -} - -/** - * Calculate the current value of an animation applying an "S" characteristic (cosine) - * @param a pointer to an animation - * @return the current value to set - */ -lv_anim_value_t lv_anim_path_ease_in_out(const lv_anim_t * a) -{ - /*Calculate the current step*/ - - uint32_t t; - if(a->time == a->act_time) - t = 1024; - else - t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time; - - int32_t step = lv_bezier3(t, 0, 100, 924, 1024); - - int32_t new_value; - new_value = (int32_t)step * (a->end - a->start); - new_value = new_value >> 10; - new_value += a->start; - - return (lv_anim_value_t)new_value; -} - -/** - * Calculate the current value of an animation with overshoot at the end - * @param a pointer to an animation - * @return the current value to set - */ -lv_anim_value_t lv_anim_path_overshoot(const lv_anim_t * a) -{ - /*Calculate the current step*/ - - uint32_t t; - if(a->time == a->act_time) - t = 1024; - else - t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time; - - int32_t step = lv_bezier3(t, 0, 600, 1300, 1024); - - int32_t new_value; - new_value = (int32_t)step * (a->end - a->start); - new_value = new_value >> 10; - new_value += a->start; - - return (lv_anim_value_t)new_value; -} - -/** - * Calculate the current value of an animation with 3 bounces - * @param a pointer to an animation - * @return the current value to set - */ -lv_anim_value_t lv_anim_path_bounce(const lv_anim_t * a) -{ - /*Calculate the current step*/ - uint32_t t; - if(a->time == a->act_time) - t = 1024; - else - t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time; - - int32_t diff = (a->end - a->start); - - /*3 bounces has 5 parts: 3 down and 2 up. One part is t / 5 long*/ - - if(t < 408) { - /*Go down*/ - t = (t * 2500) >> 10; /*[0..1024] range*/ - } else if(t >= 408 && t < 614) { - /*First bounce back*/ - t -= 408; - t = t * 5; /*to [0..1024] range*/ - t = 1024 - t; - diff = diff / 6; - } else if(t >= 614 && t < 819) { - /*Fall back*/ - t -= 614; - t = t * 5; /*to [0..1024] range*/ - diff = diff / 6; - } else if(t >= 819 && t < 921) { - /*Second bounce back*/ - t -= 819; - t = t * 10; /*to [0..1024] range*/ - t = 1024 - t; - diff = diff / 16; - } else if(t >= 921 && t <= 1024) { - /*Fall back*/ - t -= 921; - t = t * 10; /*to [0..1024] range*/ - diff = diff / 16; - } - - if(t > 1024) t = 1024; - - int32_t step = lv_bezier3(t, 1024, 1024, 800, 0); - - int32_t new_value; - new_value = (int32_t)step * diff; - new_value = new_value >> 10; - new_value = a->end - new_value; - - return (lv_anim_value_t)new_value; -} - -/** - * 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 - */ -lv_anim_value_t lv_anim_path_step(const lv_anim_t * a) -{ - if(a->act_time >= a->time) - return a->end; - else - return a->start; -} - -/********************** - * STATIC FUNCTIONS - **********************/ - -/** - * Periodically handle the animations. - * @param param unused - */ -static void anim_task(lv_task_t * param) -{ - (void)param; - - lv_anim_t * a; - LV_LL_READ(LV_GC_ROOT(_lv_anim_ll), a) - { - a->has_run = 0; - } - - uint32_t elaps = lv_tick_elaps(last_task_run); - - a = lv_ll_get_head(&LV_GC_ROOT(_lv_anim_ll)); - - while(a != NULL) { - /*It can be set by `lv_anim_del()` typically in `end_cb`. If set then an animation delete - * happened in `anim_ready_handler` which could make this linked list reading corrupt - * because the list is changed meanwhile - */ - anim_list_changed = false; - - if(!a->has_run) { - a->has_run = 1; /*The list readying might be reseted so need to know which anim has run already*/ - a->act_time += elaps; - if(a->act_time >= 0) { - if(a->act_time > a->time) a->act_time = a->time; - - int32_t new_value; - new_value = a->path_cb(a); - - /*Apply the calculated value*/ - if(a->exec_cb) a->exec_cb(a->var, new_value); - - /*If the time is elapsed the animation is ready*/ - if(a->act_time >= a->time) { - anim_ready_handler(a); - } - } - } - - /* If the linked list changed due to anim. delete then it's not safe to continue - * the reading of the list from here -> start from the head*/ - if(anim_list_changed) - a = lv_ll_get_head(&LV_GC_ROOT(_lv_anim_ll)); - else - a = lv_ll_get_next(&LV_GC_ROOT(_lv_anim_ll), a); - } - - last_task_run = lv_tick_get(); -} - -/** - * Called when an animation is ready to do the necessary thinks - * e.g. repeat, play back, delete etc. - * @param a pointer to an animation descriptor - * @return true: animation delete occurred nnd the `LV_GC_ROOT(_lv_anim_ll)` has changed - * */ -static bool anim_ready_handler(lv_anim_t * a) -{ - - /*Delete the animation if - * - no repeat and no play back (simple one shot animation) - * - no repeat, play back is enabled and play back is ready */ - if((a->repeat == 0 && a->playback == 0) || (a->repeat == 0 && a->playback == 1 && a->playback_now == 1)) { - - /*Create copy from the animation and delete the animation from the list. - * This way the `ready_cb` will see the animations like it's animation is ready deleted*/ - lv_anim_t a_tmp; - memcpy(&a_tmp, a, sizeof(lv_anim_t)); - lv_ll_rem(&LV_GC_ROOT(_lv_anim_ll), a); - lv_mem_free(a); - anim_list_changed = true; - - /* Call the callback function at the end*/ - if(a_tmp.ready_cb != NULL) a_tmp.ready_cb(&a_tmp); - } - /*If the animation is not deleted then restart it*/ - else { - a->act_time = -a->repeat_pause; /*Restart the animation*/ - /*Swap the start and end values in play back mode*/ - if(a->playback != 0) { - /*If now turning back use the 'playback_pause*/ - if(a->playback_now == 0) a->act_time = -a->playback_pause; - - /*Toggle the play back state*/ - a->playback_now = a->playback_now == 0 ? 1 : 0; - /*Swap the start and end values*/ - int32_t tmp; - tmp = a->start; - a->start = a->end; - a->end = tmp; - } - } - - return anim_list_changed; -} -#endif diff --git a/src/libs/lvgl/src/lv_misc/lv_anim.h b/src/libs/lvgl/src/lv_misc/lv_anim.h deleted file mode 100644 index b43035aa..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_anim.h +++ /dev/null @@ -1,331 +0,0 @@ -/** - * @file anim.h - * - */ - -#ifndef ANIM_H -#define ANIM_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ -#ifdef LV_CONF_INCLUDE_SIMPLE -#include "lv_conf.h" -#else -#include "../../../lv_conf.h" -#endif - -#include <stdint.h> -#include <stdbool.h> -#include <string.h> - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/** Can be used to indicate if animations are enabled or disabled in a case*/ -enum { - LV_ANIM_OFF, - LV_ANIM_ON, -}; - -typedef uint8_t lv_anim_enable_t; - -/** Type of the animated value*/ -typedef lv_coord_t lv_anim_value_t; - -#if LV_USE_ANIMATION - -struct _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 its 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 *, lv_anim_value_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)(struct _lv_anim_t *, lv_anim_value_t); - -/** Get the current value during an animation*/ -typedef lv_anim_value_t (*lv_anim_path_cb_t)(const struct _lv_anim_t *); - -/** Callback to call when the animation is ready*/ -typedef void (*lv_anim_ready_cb_t)(struct _lv_anim_t *); - -/** Describes an animation*/ -typedef struct _lv_anim_t -{ - void * var; /**<Variable to animate*/ - lv_anim_exec_xcb_t exec_cb; /**< Function to execute to animate*/ - lv_anim_path_cb_t path_cb; /**< Function to get the steps of animations*/ - lv_anim_ready_cb_t ready_cb; /**< Call it when the animation is ready*/ - int32_t start; /**< Start value*/ - int32_t end; /**< End value*/ - uint32_t time; /**< Animation time in ms*/ - int32_t act_time; /**< Current time in animation. Set to negative to make delay.*/ - uint16_t playback_pause; /**< Wait before play back*/ - uint16_t repeat_pause; /**< Wait before repeat*/ -#if LV_USE_USER_DATA - lv_anim_user_data_t user_data; /**< Custom user data*/ -#endif - - uint8_t playback : 1; /**< When the animation is ready play it back*/ - uint8_t repeat : 1; /**< Repeat the animation infinitely*/ - /*Animation system use these - user shouldn't set*/ - uint8_t playback_now : 1; /**< Play back is in progress*/ - uint32_t has_run : 1; /**< Indicates the animation has run in this round*/ -} lv_anim_t; - - -/********************** - * GLOBAL PROTOTYPES - **********************/ - -/** - * Init. the animation module - */ -void lv_anim_core_init(void); - -/** - * Initialize an animation variable. - * E.g.: - * lv_anim_t a; - * lv_anim_init(&a); - * lv_anim_set_...(&a); - * lv_anim_create(&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 function to execute on `var` - * @param a pointer to an initialized `lv_anim_t` variable - * @param var pointer to a variable to animate - * @param exec_cb a function to execute. - * LittelvGL's built-in functions can be used. - * E.g. lv_obj_set_x - */ -static inline void lv_anim_set_exec_cb(lv_anim_t * a, void * var, lv_anim_exec_xcb_t exec_cb) -{ - a->var = var; - a->exec_cb = exec_cb; -} - -/** - * Set the duration and delay of an animation - * @param a pointer to an initialized `lv_anim_t` variable - * @param duration duration of the animation in milliseconds - * @param delay delay before the animation in milliseconds - */ -static inline void lv_anim_set_time(lv_anim_t * a, uint16_t duration, int16_t delay) -{ - a->time = duration; - a->act_time = (int16_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 - */ -static inline void lv_anim_set_values(lv_anim_t * a, lv_anim_value_t start, lv_anim_value_t end) -{ - a->start = start; - a->end = end; -} - -/** - * Similar to `lv_anim_set_var_and_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 LittlevGL is binded 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. - */ -static inline void lv_anim_set_custom_exec_cb(lv_anim_t * a, lv_anim_custom_exec_cb_t exec_cb) -{ - a->var = a; - a->exec_cb = (lv_anim_exec_xcb_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 the get the current value of the animation. - * The built in functions starts with `lv_anim_path_...` - */ -static inline void lv_anim_set_path_cb(lv_anim_t * a, lv_anim_path_cb_t path_cb) -{ - a->path_cb = path_cb; -} - -/** - * Set a function call when the animation is ready - * @param a pointer to an initialized `lv_anim_t` variable - * @param ready_cb a function call when the animation is ready - */ -static inline void lv_anim_set_ready_cb(lv_anim_t * a, lv_anim_ready_cb_t ready_cb) -{ - a->ready_cb = ready_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 wait_time time in milliseconds to wait before starting the back direction - */ -static inline void lv_anim_set_playback(lv_anim_t * a, uint16_t wait_time) -{ - a->playback = 1; - a->playback_pause = wait_time; -} - -/** - * Disable playback. (Disabled after `lv_anim_init()`) - * @param a pointer to an initialized `lv_anim_t` variable - */ -static inline void lv_anim_clear_playback(lv_anim_t * a) -{ - a->playback = 0; -} - -/** - * Make the animation to start again when ready. - * @param a pointer to an initialized `lv_anim_t` variable - * @param wait_time time in milliseconds to wait before starting the animation again - */ -static inline void lv_anim_set_repeat(lv_anim_t * a, uint16_t wait_time) -{ - a->repeat = 1; - a->repeat_pause = wait_time; -} - -/** - * Disable repeat. (Disabled after `lv_anim_init()`) - * @param a pointer to an initialized `lv_anim_t` variable - */ -static inline void lv_anim_clear_repeat(lv_anim_t * a) -{ - a->repeat = 0; -} - -/** - * Create an animation - * @param a an initialized 'anim_t' variable. Not required after call. - */ -void lv_anim_create(lv_anim_t * a); - -/** - * Delete an animation 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_del(void * var, lv_anim_exec_xcb_t exec_cb); - -/** - * Delete an aniamation by getting the animated variable from `a`. - * Only animations with `exec_cb` will be deleted. - * This function exist becasue it's logical that all anim functions receives an - * `lv_anim_t` as their first parameter. It's not practical in C but might makes - * the API more conequent and makes easier to genrate 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 - */ -static inline bool lv_anim_custom_del(lv_anim_t * a, lv_anim_custom_exec_cb_t exec_cb) -{ - return lv_anim_del(a->var, (lv_anim_exec_xcb_t)exec_cb); -} - -/** - * Get the number of currently running animations - * @return the number of running animations - */ -uint16_t lv_anim_count_running(void); - -/** - * Calculate the time of an animation with a given speed and the start and end values - * @param speed speed of animation in unit/sec - * @param start start value of the animation - * @param end end value of the animation - * @return the required time [ms] for the animation with the given parameters - */ -uint32_t lv_anim_speed_to_time(uint16_t speed, lv_anim_value_t start, lv_anim_value_t end); - -/** - * Calculate the current value of an animation applying linear characteristic - * @param a pointer to an animation - * @return the current value to set - */ -lv_anim_value_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 - */ -lv_anim_value_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 - */ -lv_anim_value_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 - */ -lv_anim_value_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 - */ -lv_anim_value_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 - */ -lv_anim_value_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 - */ -lv_anim_value_t lv_anim_path_step(const lv_anim_t * a); - -/********************** - * MACROS - **********************/ - -#endif /*LV_USE_ANIMATION == 0*/ - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /*LV_ANIM_H*/ diff --git a/src/libs/lvgl/src/lv_misc/lv_area.c b/src/libs/lvgl/src/lv_misc/lv_area.c deleted file mode 100644 index de649c5b..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_area.c +++ /dev/null @@ -1,210 +0,0 @@ -/** - * @file lv_area.c - * - */ - -/********************* - * INCLUDES - *********************/ -#ifdef LV_CONF_INCLUDE_SIMPLE -#include "lv_conf.h" -#else -#include "../../../lv_conf.h" -#endif - -#include "lv_area.h" -#include "lv_math.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -/********************** - * STATIC VARIABLES - **********************/ - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -/** - * 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, lv_coord_t x1, lv_coord_t y1, lv_coord_t x2, lv_coord_t y2) -{ - area_p->x1 = x1; - area_p->y1 = y1; - area_p->x2 = x2; - area_p->y2 = y2; -} - -/** - * 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, lv_coord_t w) -{ - area_p->x2 = area_p->x1 + w - 1; -} - -/** - * 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, lv_coord_t h) -{ - area_p->y2 = area_p->y1 + h - 1; -} - -/** - * 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, lv_coord_t x, lv_coord_t y) -{ - lv_coord_t w = lv_area_get_width(area_p); - lv_coord_t h = lv_area_get_height(area_p); - area_p->x1 = x; - area_p->y1 = y; - lv_area_set_width(area_p, w); - lv_area_set_height(area_p, 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) -{ - uint32_t size; - - size = (uint32_t)(area_p->x2 - area_p->x1 + 1) * (area_p->y2 - area_p->y1 + 1); - - return size; -} - -/** - * Get the common parts of two areas - * @param 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 - * @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 the smaller area from 'a1_p' and 'a2_p' */ - res_p->x1 = LV_MATH_MAX(a1_p->x1, a2_p->x1); - res_p->y1 = LV_MATH_MAX(a1_p->y1, a2_p->y1); - res_p->x2 = LV_MATH_MIN(a1_p->x2, a2_p->x2); - res_p->y2 = LV_MATH_MIN(a1_p->y2, a2_p->y2); - - /*If x1 or y1 greater then x2 or y2 then the areas union is empty*/ - bool union_ok = true; - if((res_p->x1 > res_p->x2) || (res_p->y1 > res_p->y2)) { - union_ok = false; - } - - return union_ok; -} -/** - * Join two areas into a third which involves the other two - * @param 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) -{ - a_res_p->x1 = LV_MATH_MIN(a1_p->x1, a2_p->x1); - a_res_p->y1 = LV_MATH_MIN(a1_p->y1, a2_p->y1); - a_res_p->x2 = LV_MATH_MAX(a1_p->x2, a2_p->x2); - a_res_p->y2 = LV_MATH_MAX(a1_p->y2, a2_p->y2); -} - -/** - * Check if a point is on an area - * @param a_p pointer to an area - * @param p_p pointer to a point - * @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) -{ - bool is_on = false; - - if((p_p->x >= a_p->x1 && p_p->x <= a_p->x2) && ((p_p->y >= a_p->y1 && p_p->y <= a_p->y2))) { - is_on = true; - } - - return is_on; -} - -/** - * Check if two area has common parts - * @param a1_p pointer to an area. - * @param a2_p pointer to an other 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) -{ - if((a1_p->x1 <= a2_p->x2) && (a1_p->x2 >= a2_p->x1) && (a1_p->y1 <= a2_p->y2) && (a1_p->y2 >= a2_p->y1)) { - return true; - } else { - return false; - } -} - -/** - * Check if an area is fully on an other - * @param ain_p pointer to an area which could be in 'aholder_p' - * @param aholder pointer to an area which could involve 'ain_p' - * @return - */ -bool lv_area_is_in(const lv_area_t * ain_p, const lv_area_t * aholder_p) -{ - bool is_in = false; - - if(ain_p->x1 >= aholder_p->x1 && ain_p->y1 >= aholder_p->y1 && ain_p->x2 <= aholder_p->x2 && - ain_p->y2 <= aholder_p->y2) { - is_in = true; - } - - return is_in; -} - -/** - * Increment or decrement an area's size by a single amount - * @param a_p pointer to an area to grow - * @param amount amount to increment the area, or negative to decrement - */ -void lv_area_increment(lv_area_t * a_p, const lv_coord_t amount) -{ - a_p->x1 -= amount; - a_p->y1 -= amount; - a_p->x2 += amount; - a_p->y2 += amount; -} - -/********************** - * STATIC FUNCTIONS - **********************/ diff --git a/src/libs/lvgl/src/lv_misc/lv_area.h b/src/libs/lvgl/src/lv_misc/lv_area.h deleted file mode 100644 index 211bebd8..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_area.h +++ /dev/null @@ -1,186 +0,0 @@ -/** - * @file lv_area.h - * - */ - -#ifndef LV_AREA_H -#define LV_AREA_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ -#include <string.h> -#include <stdbool.h> -#include <stdint.h> -#ifdef LV_CONF_INCLUDE_SIMPLE -#include "lv_conf.h" -#else -#include "../../../lv_conf.h" -#endif - -/********************* - * DEFINES - *********************/ -/*To avoid overflow don't let the max ranges (reduce with 1000) */ -#define LV_COORD_MAX ((lv_coord_t)((uint32_t)((uint32_t)1 << (8 * sizeof(lv_coord_t) - 1)) - 1000)) -#define LV_COORD_MIN (-LV_COORD_MAX) - -LV_EXPORT_CONST_INT(LV_COORD_MAX); -LV_EXPORT_CONST_INT(LV_COORD_MIN); - -/********************** - * TYPEDEFS - **********************/ - -/** - * Represents a point on the screen. - */ -typedef struct -{ - lv_coord_t x; - lv_coord_t y; -} lv_point_t; - -/** Represents an area of the screen. */ -typedef struct -{ - lv_coord_t x1; - lv_coord_t y1; - lv_coord_t x2; - lv_coord_t y2; -} lv_area_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, lv_coord_t x1, lv_coord_t y1, lv_coord_t x2, lv_coord_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) -{ - memcpy(dest, src, sizeof(lv_area_t)); -} - -/** - * Get the width of an area - * @param area_p pointer to an area - * @return the width of the area (if x1 == x2 -> width = 1) - */ -static inline lv_coord_t lv_area_get_width(const lv_area_t * area_p) -{ - return (lv_coord_t)(area_p->x2 - area_p->x1 + 1); -} - -/** - * Get the height of an area - * @param area_p pointer to an area - * @return the height of the area (if y1 == y2 -> height = 1) - */ -static inline lv_coord_t lv_area_get_height(const lv_area_t * area_p) -{ - return (lv_coord_t)(area_p->y2 - area_p->y1 + 1); -} - -/** - * 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, lv_coord_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, lv_coord_t h); - -/** - * 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, lv_coord_t x, lv_coord_t y); - -/** - * 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); - -/** - * 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); - -/** - * Join two areas into a third which involves the other two - * @param 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 - * @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); - -/** - * Check if two area has common parts - * @param a1_p pointer to an area. - * @param a2_p pointer to an other 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 an other - * @param ain_p pointer to an area which could be on aholder_p - * @param aholder pointer to an area which could involve ain_p - * @return - */ -bool lv_area_is_in(const lv_area_t * ain_p, const lv_area_t * aholder_p); - -/** - * Increment or decrement an area's size by a single amount - * @param a_p pointer to an area to grow - * @param amount amount to increment the area, or negative to decrement - */ -void lv_area_increment(lv_area_t * a_p, const lv_coord_t amount); - -/********************** - * MACROS - **********************/ - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif diff --git a/src/libs/lvgl/src/lv_misc/lv_async.c b/src/libs/lvgl/src/lv_misc/lv_async.c deleted file mode 100644 index 2a836432..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_async.c +++ /dev/null @@ -1,75 +0,0 @@ -/** - * @file lv_async.c - * - */ - -/********************* - * INCLUDES - *********************/ - -#include "lv_async.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -static void lv_async_task_cb(lv_task_t *task); - -/********************** - * STATIC VARIABLES - **********************/ - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -lv_res_t lv_async_call(lv_async_cb_t async_xcb, void * user_data) -{ - /*Allocate an info structure */ - lv_async_info_t *info = lv_mem_alloc(sizeof(lv_async_info_t)); - - if(info == NULL) - return LV_RES_INV; - - /* Create a new task */ - /* Use highest priority so that it will run before a refresh */ - lv_task_t *task = lv_task_create(lv_async_task_cb, 0, LV_TASK_PRIO_HIGHEST, info); - - if(task == NULL) { - lv_mem_free(info); - return LV_RES_INV; - } - - info->cb = async_xcb; - info->user_data = user_data; - - /* Set the task's user data */ - task->user_data = info; - lv_task_once(task); - return LV_RES_OK; -} - -/********************** - * STATIC FUNCTIONS - **********************/ - -static void lv_async_task_cb(lv_task_t *task) -{ - lv_async_info_t *info = (lv_async_info_t *)task->user_data; - - info->cb(info->user_data); - - lv_mem_free(info); -} diff --git a/src/libs/lvgl/src/lv_misc/lv_async.h b/src/libs/lvgl/src/lv_misc/lv_async.h deleted file mode 100644 index 9423cd8e..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_async.h +++ /dev/null @@ -1,62 +0,0 @@ -/** - * @file lv_async.h - * - */ - -#ifndef LV_ASYNC_H -#define LV_ASYNC_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ - -#include "lv_task.h" -#include "lv_types.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/** - * Type for async callback. - */ -typedef void (*lv_async_cb_t)(void *); - -typedef struct _lv_async_info_t { - lv_async_cb_t cb; - void *user_data; -} lv_async_info_t; - -struct _lv_obj_t; - -/********************** - * GLOBAL PROTOTYPES - **********************/ - -/** - * Call an asynchronous function the next time lv_task_handler() is run. This function is likely to return - * **before** the call actually happens! - * @param task_xcb a callback which is the task itself. - * (the 'x' in the argument name indicates that its not a fully generic function because it not follows - * the `func_name(object, callback, ...)` convention) - * @param user_data custom parameter - */ -lv_res_t lv_async_call(lv_async_cb_t async_xcb, void * user_data); - -/********************** - * MACROS - **********************/ - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /*LV_TEMPL_H*/ diff --git a/src/libs/lvgl/src/lv_misc/lv_bidi.c b/src/libs/lvgl/src/lv_misc/lv_bidi.c deleted file mode 100644 index 6e50d926..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_bidi.c +++ /dev/null @@ -1,544 +0,0 @@ -/** - * @file lv_bidi.c - * - */ - -/********************* - * INCLUDES - *********************/ -#include <stddef.h> -#include "lv_bidi.h" -#include "lv_txt.h" -#include "../lv_draw/lv_draw.h" - -#if LV_USE_BIDI - -/********************* - * DEFINES - *********************/ -#define LV_BIDI_BRACKLET_DEPTH 4 - -// Highest bit of the 16-bit pos_conv value specifies whether this pos is RTL or not -#define GET_POS(x) ((x) & 0x7FFF) -#define IS_RTL_POS(x) (((x) & 0x8000) != 0) -#define SET_RTL_POS(x, is_rtl) (GET_POS(x) | ((is_rtl)? 0x8000: 0)) - -/********************** - * TYPEDEFS - **********************/ -typedef struct -{ - uint32_t bracklet_pos; - lv_bidi_dir_t dir; -}bracket_stack_t; - -/********************** - * STATIC PROTOTYPES - **********************/ -static lv_bidi_dir_t get_next_run(const char * txt, lv_bidi_dir_t base_dir, uint32_t max_len, uint32_t * len, uint16_t * pos_conv_len); -static void rtl_reverse(char * dest, const char * src, uint32_t len, uint16_t *pos_conv_out, uint16_t pos_conv_rd_base, uint16_t pos_conv_len); -static uint32_t char_change_to_pair(uint32_t letter); -static lv_bidi_dir_t bracket_process(const char * txt, uint32_t next_pos, uint32_t len, uint32_t letter, lv_bidi_dir_t base_dir); -static void fill_pos_conv(uint16_t * out, uint16_t len, uint16_t index); -static uint32_t get_txt_len(const char * txt, uint32_t max_len); - -/********************** - * STATIC VARIABLES - **********************/ -static const uint8_t bracket_left[] = {"<({["}; -static const uint8_t bracket_right[] = {">)}]"}; -static bracket_stack_t br_stack[LV_BIDI_BRACKLET_DEPTH]; -static uint8_t br_stack_p; - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -void lv_bidi_process(const char * str_in, char * str_out, lv_bidi_dir_t base_dir) -{ - if(base_dir == LV_BIDI_DIR_AUTO) base_dir = lv_bidi_detect_base_dir(str_in); - - uint32_t par_start = 0; - uint32_t par_len; - - while(str_in[par_start] == '\n' || str_in[par_start] == '\r') { - str_out[par_start] = str_in[par_start]; - par_start ++; - } - - while(str_in[par_start] != '\0') { - par_len = lv_bidi_get_next_paragraph(&str_in[par_start]); - lv_bidi_process_paragraph(&str_in[par_start], &str_out[par_start], par_len, base_dir, NULL, 0); - par_start += par_len; - - while(str_in[par_start] == '\n' || str_in[par_start] == '\r') { - str_out[par_start] = str_in[par_start]; - par_start ++; - } - } - - str_out[par_start] = '\0'; -} - -lv_bidi_dir_t lv_bidi_detect_base_dir(const char * txt) -{ - uint32_t i = 0; - uint32_t letter; - while(txt[i] != '\0') { - letter = lv_txt_encoded_next(txt, &i); - - lv_bidi_dir_t dir; - dir = lv_bidi_get_letter_dir(letter); - if(dir == LV_BIDI_DIR_RTL || dir == LV_BIDI_DIR_LTR) return dir; - } - - /*If there were no strong char earlier return with the default base dir */ - if(LV_BIDI_BASE_DIR_DEF == LV_BIDI_DIR_AUTO) return LV_BIDI_DIR_LTR; - else return LV_BIDI_BASE_DIR_DEF; -} - -lv_bidi_dir_t lv_bidi_get_letter_dir(uint32_t letter) -{ - if(lv_bidi_letter_is_rtl(letter)) return LV_BIDI_DIR_RTL; - if(lv_bidi_letter_is_neutral(letter)) return LV_BIDI_DIR_NEUTRAL; - if(lv_bidi_letter_is_weak(letter)) return LV_BIDI_DIR_WEAK; - - return LV_BIDI_DIR_LTR; -} - -bool lv_bidi_letter_is_weak(uint32_t letter) -{ - uint32_t i = 0; - static const char weaks[] = "0123456789"; - - do { - uint32_t x = lv_txt_encoded_next(weaks, &i); - if(letter == x) { - return true; - } - } while(weaks[i] != '\0'); - - return false; -} - -bool lv_bidi_letter_is_rtl(uint32_t letter) -{ - if(letter >= 0x5d0 && letter <= 0x5ea) return true; - if(letter == 0x202E) return true; /*Unicode of LV_BIDI_RLO*/ -// if(letter >= 'a' && letter <= 'z') return true; - - return false; -} - -bool lv_bidi_letter_is_neutral(uint32_t letter) -{ - uint16_t i; - static const char neutrals[] = " \t\n\r.,:;'\"`!?%/\\-=()[]{}<>@#&$|"; - for(i = 0; neutrals[i] != '\0'; i++) { - if(letter == (uint32_t)neutrals[i]) return true; - } - - return false; -} - -uint16_t lv_bidi_get_logical_pos(const char * str_in, char **bidi_txt, uint32_t len, lv_bidi_dir_t base_dir, uint32_t visual_pos, bool *is_rtl) -{ - uint32_t pos_conv_len = get_txt_len(str_in, len); - uint32_t txt_buf_size = len + 1; - txt_buf_size = (txt_buf_size + 3) & (~0x3); - void *buf = lv_draw_get_buf(txt_buf_size + pos_conv_len * sizeof(uint16_t)); - if (bidi_txt) *bidi_txt = buf; - uint16_t *pos_conv_buf = (uint16_t*) ((char*)buf + txt_buf_size); - lv_bidi_process_paragraph(str_in, bidi_txt? *bidi_txt: NULL, len, base_dir, pos_conv_buf, pos_conv_len); - if (is_rtl) *is_rtl = IS_RTL_POS(pos_conv_buf[visual_pos]); - return GET_POS(pos_conv_buf[visual_pos]); -} - -uint16_t lv_bidi_get_visual_pos(const char * str_in, char **bidi_txt, uint16_t len, lv_bidi_dir_t base_dir, uint32_t logical_pos, bool *is_rtl) -{ - uint32_t pos_conv_len = get_txt_len(str_in, len); - uint32_t txt_buf_size = len + 1; - txt_buf_size = (txt_buf_size + 3) & (~0x3); - void *buf = lv_draw_get_buf(txt_buf_size + pos_conv_len * sizeof(uint16_t)); - if (bidi_txt) *bidi_txt = buf; - uint16_t *pos_conv_buf = (uint16_t*) ((char*)buf + txt_buf_size); - lv_bidi_process_paragraph(str_in, bidi_txt? *bidi_txt: NULL, len, base_dir, pos_conv_buf, pos_conv_len); - for (uint16_t i = 0; i < pos_conv_len; i++){ - if (GET_POS(pos_conv_buf[i]) == logical_pos){ - if (is_rtl) *is_rtl = IS_RTL_POS(pos_conv_buf[i]); - return i; - } - } - return (uint16_t) -1; -} - -void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len, lv_bidi_dir_t base_dir, uint16_t *pos_conv_out, uint16_t pos_conv_len) -{ - uint32_t run_len = 0; - lv_bidi_dir_t run_dir; - uint32_t rd = 0; - uint32_t wr; - uint16_t pos_conv_run_len = 0; - uint16_t pos_conv_rd = 0; - uint16_t pos_conv_wr; - - if(base_dir == LV_BIDI_DIR_AUTO) base_dir = lv_bidi_detect_base_dir(str_in); - if(base_dir == LV_BIDI_DIR_RTL) { - wr = len; - pos_conv_wr = pos_conv_len; - } - else { - wr = 0; - pos_conv_wr = 0; - } - - if (str_out) str_out[len] = '\0'; - - lv_bidi_dir_t dir = base_dir; - - /*Empty the bracket stack*/ - br_stack_p = 0; - - /*Process neutral chars in the beginning*/ - while(rd < len) { - uint32_t letter = lv_txt_encoded_next(str_in, &rd); - pos_conv_rd++; - dir = lv_bidi_get_letter_dir(letter); - if(dir == LV_BIDI_DIR_NEUTRAL) dir = bracket_process(str_in, rd, len, letter, base_dir); - if(dir != LV_BIDI_DIR_NEUTRAL && dir != LV_BIDI_DIR_WEAK) break; - } - - if(rd && str_in[rd] != '\0') { - lv_txt_encoded_prev(str_in, &rd); - pos_conv_rd--; - } - - if(rd) { - if(base_dir == LV_BIDI_DIR_LTR) { - if (str_out) { - memcpy(&str_out[wr], str_in, rd); - wr += rd; - } - if (pos_conv_out) { - fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_rd, 0); - pos_conv_wr += pos_conv_rd; - } - } else { - wr -= rd; - pos_conv_wr -= pos_conv_rd; - rtl_reverse(str_out? &str_out[wr]: NULL, str_in, rd, pos_conv_out? &pos_conv_out[pos_conv_wr]: NULL, 0, pos_conv_rd); - } - } - - /*Get and process the runs*/ - - while(rd < len && str_in[rd]) { - run_dir = get_next_run(&str_in[rd], base_dir, len - rd, &run_len, &pos_conv_run_len); - - if(base_dir == LV_BIDI_DIR_LTR) { - if(run_dir == LV_BIDI_DIR_LTR) { - if (str_out) memcpy(&str_out[wr], &str_in[rd], run_len); - if (pos_conv_out) fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_run_len, pos_conv_rd); - } - else rtl_reverse(str_out? &str_out[wr]: NULL, &str_in[rd], run_len, pos_conv_out? &pos_conv_out[pos_conv_wr] : NULL, pos_conv_rd, pos_conv_run_len); - wr += run_len; - pos_conv_wr += pos_conv_run_len; - } else { - wr -= run_len; - pos_conv_wr -= pos_conv_run_len; - if(run_dir == LV_BIDI_DIR_LTR) { - if (str_out) memcpy(&str_out[wr], &str_in[rd], run_len); - if (pos_conv_out) fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_run_len, pos_conv_rd); - } - else rtl_reverse(str_out? &str_out[wr]: NULL, &str_in[rd], run_len, pos_conv_out? &pos_conv_out[pos_conv_wr] : NULL, pos_conv_rd, pos_conv_run_len); - } - - rd += run_len; - pos_conv_rd += pos_conv_run_len; - } -} - -uint32_t lv_bidi_get_next_paragraph(const char * txt) -{ - uint32_t i = 0; - - lv_txt_encoded_next(txt, &i); - - while(txt[i] != '\0' && txt[i] != '\n' && txt[i] != '\r') { - lv_txt_encoded_next(txt, &i); - } - - return i; -} - -/********************** - * STATIC FUNCTIONS - **********************/ - -static uint32_t get_txt_len(const char * txt, uint32_t max_len) -{ - uint32_t len = 0; - uint32_t i = 0; - - while(i < max_len && txt[i] != '\0') { - lv_txt_encoded_next(txt, &i); - len++; - } - - return len; -} - -static void fill_pos_conv(uint16_t * out, uint16_t len, uint16_t index) -{ - for (uint16_t i = 0; i < len; i++) - { - out[i] = SET_RTL_POS(index, false); - index++; - } -} - -static lv_bidi_dir_t get_next_run(const char * txt, lv_bidi_dir_t base_dir, uint32_t max_len, uint32_t * len, uint16_t * pos_conv_len) -{ - uint32_t i = 0; - uint32_t letter; - - uint16_t pos_conv_i = 0; - - letter = lv_txt_encoded_next(txt, NULL); - lv_bidi_dir_t dir = lv_bidi_get_letter_dir(letter); - if(dir == LV_BIDI_DIR_NEUTRAL) dir = bracket_process(txt, 0, max_len, letter, base_dir); - - /*Find the first strong char. Skip the neutrals*/ - while(dir == LV_BIDI_DIR_NEUTRAL || dir == LV_BIDI_DIR_WEAK) { - letter = lv_txt_encoded_next(txt, &i); - pos_conv_i++; - dir = lv_bidi_get_letter_dir(letter); - if(dir == LV_BIDI_DIR_NEUTRAL) dir = bracket_process(txt, i, max_len, letter, base_dir); - - if(i >= max_len || txt[i] == '\0' || txt[i] == '\n' || txt[i] == '\r') { - *len = i; - *pos_conv_len = pos_conv_i; - return base_dir; - } - } - - lv_bidi_dir_t run_dir = dir; - - uint32_t i_prev = i; - uint32_t i_last_strong = i; - uint16_t pos_conv_i_prev = pos_conv_i; - uint16_t pos_conv_i_last_strong = pos_conv_i; - - /*Find the next char which has different direction*/ - lv_bidi_dir_t next_dir = base_dir; - while(i_prev < max_len && txt[i] != '\0' && txt[i] != '\n' && txt[i] != '\r') { - letter = lv_txt_encoded_next(txt, &i); - pos_conv_i++; - next_dir = lv_bidi_get_letter_dir(letter); - if(next_dir == LV_BIDI_DIR_NEUTRAL) next_dir = bracket_process(txt, i, max_len, letter, base_dir); - - /*New dir found?*/ - if((next_dir == LV_BIDI_DIR_RTL || next_dir == LV_BIDI_DIR_LTR) && next_dir != run_dir) { - /*Include neutrals if `run_dir == base_dir` */ - if(run_dir == base_dir) { - *len = i_prev; - *pos_conv_len = pos_conv_i_prev; - } - /*Exclude neutrals if `run_dir != base_dir` */ - else { - *len = i_last_strong; - *pos_conv_len = pos_conv_i_last_strong; - } - - return run_dir; - } - - if(next_dir != LV_BIDI_DIR_NEUTRAL) { - i_last_strong = i; - pos_conv_i_last_strong = pos_conv_i; - } - - i_prev = i; - pos_conv_i_prev = pos_conv_i; - } - - /*Handle end of of string. Apply `base_dir` on trailing neutrals*/ - - /*Include neutrals if `run_dir == base_dir` */ - if(run_dir == base_dir) { - *len = i_prev; - *pos_conv_len = pos_conv_i_prev; - } - /*Exclude neutrals if `run_dir != base_dir` */ - else { - *len = i_last_strong; - *pos_conv_len = pos_conv_i_last_strong; - } - - return run_dir; -} - -static void rtl_reverse(char * dest, const char * src, uint32_t len, uint16_t *pos_conv_out, uint16_t pos_conv_rd_base, uint16_t pos_conv_len) -{ - uint32_t i = len; - uint32_t wr = 0; - uint16_t pos_conv_i = pos_conv_len; - uint16_t pos_conv_wr = 0; - - while(i) { - uint32_t letter = lv_txt_encoded_prev(src, &i); - uint16_t pos_conv_letter = --pos_conv_i; - - /*Keep weak letters (numbers) as LTR*/ - if(lv_bidi_letter_is_weak(letter)) { - uint32_t last_weak = i; - uint32_t first_weak = i; - uint16_t pos_conv_last_weak = pos_conv_i; - uint16_t pos_conv_first_weak = pos_conv_i; - while(i) { - letter = lv_txt_encoded_prev(src, &i); - pos_conv_letter = --pos_conv_i; - - /*No need to call `char_change_to_pair` because there not such chars here*/ - - /*Finish on non-weak char */ - /*but treat number and currency related chars as weak*/ - if (lv_bidi_letter_is_weak(letter) == false && letter != '.' && letter != ',' && letter != '$' && letter != '%') { - lv_txt_encoded_next(src, &i); /*Rewind one letter*/ - pos_conv_i++; - first_weak = i; - pos_conv_first_weak = pos_conv_i; - break; - } - } - if(i == 0) { - first_weak = 0; - pos_conv_first_weak = 0; - } - - if (dest) memcpy(&dest[wr], &src[first_weak], last_weak - first_weak + 1); - if (pos_conv_out) fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_last_weak - pos_conv_first_weak + 1, pos_conv_rd_base + pos_conv_first_weak); - wr += last_weak - first_weak + 1; - pos_conv_wr += pos_conv_last_weak - pos_conv_first_weak + 1; - } - - /*Simply store in reversed order*/ - else { - uint32_t letter_size = lv_txt_encoded_size((const char *)&src[i]); - /*Swap arithmetical symbols*/ - if(letter_size == 1) { - uint32_t new_letter = letter = char_change_to_pair(letter); - if (dest) dest[wr] = (uint8_t)new_letter; - if (pos_conv_out) pos_conv_out[pos_conv_wr] = SET_RTL_POS(pos_conv_rd_base + pos_conv_letter, true); - wr++; - pos_conv_wr++; - } - /*Just store the letter*/ - else { - if (dest) memcpy(&dest[wr], &src[i], letter_size); - if (pos_conv_out) pos_conv_out[pos_conv_wr] = SET_RTL_POS(pos_conv_rd_base + pos_conv_i, true); - wr += letter_size; - pos_conv_wr++; - } - } - } -} - -static uint32_t char_change_to_pair(uint32_t letter) -{ - - uint8_t i; - for(i = 0; bracket_left[i] != '\0'; i++) { - if(letter == bracket_left[i]) return bracket_right[i]; - } - - for(i = 0; bracket_right[i] != '\0'; i++) { - if(letter == bracket_right[i]) return bracket_left[i]; - } - - return letter; -} - -static lv_bidi_dir_t bracket_process(const char * txt, uint32_t next_pos, uint32_t len, uint32_t letter, lv_bidi_dir_t base_dir) -{ - lv_bidi_dir_t bracket_dir = LV_BIDI_DIR_NEUTRAL; - - uint8_t i; - /*Is the letter an opening bracket?*/ - for(i = 0; bracket_left[i] != '\0'; i++) { - if(bracket_left[i] == letter) { - /* If so find it's matching closing bracket. - * If a char with base dir. direction is found then the brackets will have `base_dir` direction*/ - uint32_t txt_i = next_pos; - while(txt_i < len) { - uint32_t letter_next = lv_txt_encoded_next(txt, &txt_i); - if(letter_next == bracket_right[i]) { - /*Closing bracket found*/ - break; - } else { - /*Save the dir*/ - lv_bidi_dir_t letter_dir = lv_bidi_get_letter_dir(letter_next); - if(letter_dir == base_dir) { - bracket_dir = base_dir; - } - } - } - - /*There were no matching closing bracket*/ - if(txt_i > len) return LV_BIDI_DIR_NEUTRAL; - - /*There where a strong char with base dir in the bracket so the dir is found.*/ - if(bracket_dir != LV_BIDI_DIR_NEUTRAL && bracket_dir != LV_BIDI_DIR_WEAK) break; - - /*If there were no matching strong chars in the brackets then check the previous chars*/ - txt_i = next_pos; - if(txt_i) lv_txt_encoded_prev(txt, &txt_i); - while(txt_i > 0) { - uint32_t letter_next = lv_txt_encoded_prev(txt, &txt_i); - lv_bidi_dir_t letter_dir = lv_bidi_get_letter_dir(letter_next); - if(letter_dir == LV_BIDI_DIR_LTR || letter_dir == LV_BIDI_DIR_RTL) { - bracket_dir = letter_dir; - break; - } - } - - - /*There where a previous strong char which can be used*/ - if(bracket_dir != LV_BIDI_DIR_NEUTRAL) break; - - /*There were no strong chars before the bracket, so use the base dir.*/ - if(txt_i == 0) bracket_dir = base_dir; - - break; - } - } - - - /*The letter was an opening bracket*/ - if(bracket_left[i] != '\0') { - - if(bracket_dir == LV_BIDI_DIR_NEUTRAL || br_stack_p == LV_BIDI_BRACKLET_DEPTH) return LV_BIDI_DIR_NEUTRAL; - - br_stack[br_stack_p].bracklet_pos = i; - br_stack[br_stack_p].dir = bracket_dir; - - br_stack_p++; - return bracket_dir; - } else if(br_stack_p > 0) { - /*Is the letter a closing bracket of the last opening?*/ - if(letter == bracket_right[br_stack[br_stack_p - 1].bracklet_pos]) { - bracket_dir = br_stack[br_stack_p - 1].dir; - br_stack_p--; - return bracket_dir; - } - } - - return LV_BIDI_DIR_NEUTRAL; -} - - -#endif /*LV_USE_BIDI*/ diff --git a/src/libs/lvgl/src/lv_misc/lv_bidi.h b/src/libs/lvgl/src/lv_misc/lv_bidi.h deleted file mode 100644 index 215727aa..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_bidi.h +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @file lv_bifi.h - * - */ - -#ifndef LV_BIDI_H -#define LV_BIDI_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ -#ifdef LV_CONF_INCLUDE_SIMPLE -#include "lv_conf.h" -#else -#include "../../../lv_conf.h" -#endif - -#include <stdbool.h> -#include <stdint.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 - **********************/ -enum -{ - /*The first 4 values are stored in `lv_obj_t` on 2 bits*/ - LV_BIDI_DIR_LTR = 0x00, - LV_BIDI_DIR_RTL = 0x01, - LV_BIDI_DIR_AUTO = 0x02, - LV_BIDI_DIR_INHERIT = 0x03, - - LV_BIDI_DIR_NEUTRAL = 0x20, - LV_BIDI_DIR_WEAK = 0x21, -}; - -typedef uint8_t lv_bidi_dir_t; - -/********************** - * GLOBAL PROTOTYPES - **********************/ -#if LV_USE_BIDI - -void lv_bidi_process(const char * str_in, char * str_out, lv_bidi_dir_t base_dir); -void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len, lv_bidi_dir_t base_dir, uint16_t *pos_conv_out, uint16_t pos_conv_len); -uint32_t lv_bidi_get_next_paragraph(const char * txt); -lv_bidi_dir_t lv_bidi_detect_base_dir(const char * txt); -lv_bidi_dir_t lv_bidi_get_letter_dir(uint32_t letter); -bool lv_bidi_letter_is_weak(uint32_t letter); -bool lv_bidi_letter_is_rtl(uint32_t letter); -bool lv_bidi_letter_is_neutral(uint32_t letter); -uint16_t lv_bidi_get_logical_pos(const char * str_in, char **bidi_txt, uint32_t len, lv_bidi_dir_t base_dir, uint32_t visual_pos, bool *is_rtl); -uint16_t lv_bidi_get_visual_pos(const char * str_in, char **bidi_txt, uint16_t len, lv_bidi_dir_t base_dir, uint32_t logical_pos, bool *is_rtl); - -/********************** - * MACROS - **********************/ - -#endif /*LV_USE_BIDI*/ - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /*LV_BIDI_H*/ diff --git a/src/libs/lvgl/src/lv_misc/lv_circ.c b/src/libs/lvgl/src/lv_misc/lv_circ.c deleted file mode 100644 index fc0e3e20..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_circ.c +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @file lv_circ.c - * Circle drawing algorithm (with Bresenham) - * Only a 1/8 circle is calculated. Use CIRC_OCT1_X, CIRC_OCT1_Y macros to get - * the other octets. - */ - -/********************* - * INCLUDES - *********************/ -#include "lv_circ.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -/********************** - * STATIC VARIABLES - **********************/ - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -/** - * Initialize the circle drawing - * @param c pointer to a point. The coordinates will be calculated here - * @param tmp point to a variable. It will store temporary data - * @param radius radius of the circle - */ -void lv_circ_init(lv_point_t * c, lv_coord_t * tmp, lv_coord_t radius) -{ - c->x = radius; - c->y = 0; - *tmp = 1 - radius; -} - -/** - * Test the circle drawing is ready or not - * @param c same as in circ_init - * @return true if the circle is not ready yet - */ -bool lv_circ_cont(lv_point_t * c) -{ - return c->y <= c->x ? true : false; -} - -/** - * Get the next point from the circle - * @param c same as in circ_init. The next point stored here. - * @param tmp same as in circ_init. - */ -void lv_circ_next(lv_point_t * c, lv_coord_t * tmp) -{ - c->y++; - - if(*tmp <= 0) { - (*tmp) += 2 * c->y + 1; /*Change in decision criterion for y -> y+1*/ - } else { - c->x--; - (*tmp) += 2 * (c->y - c->x) + 1; /*Change for y -> y+1, x -> x-1*/ - } -} - -/********************** - * STATIC FUNCTIONS - **********************/ diff --git a/src/libs/lvgl/src/lv_misc/lv_circ.h b/src/libs/lvgl/src/lv_misc/lv_circ.h deleted file mode 100644 index 405a4b6c..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_circ.h +++ /dev/null @@ -1,77 +0,0 @@ -/** - * @file lv_circ.h - * - */ - -#ifndef LV_CIRC_H -#define LV_CIRC_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ -#include <stddef.h> -#include "lv_area.h" - -/********************* - * DEFINES - *********************/ -#define LV_CIRC_OCT1_X(p) (p.x) -#define LV_CIRC_OCT1_Y(p) (p.y) -#define LV_CIRC_OCT2_X(p) (p.y) -#define LV_CIRC_OCT2_Y(p) (p.x) -#define LV_CIRC_OCT3_X(p) (-p.y) -#define LV_CIRC_OCT3_Y(p) (p.x) -#define LV_CIRC_OCT4_X(p) (-p.x) -#define LV_CIRC_OCT4_Y(p) (p.y) -#define LV_CIRC_OCT5_X(p) (-p.x) -#define LV_CIRC_OCT5_Y(p) (-p.y) -#define LV_CIRC_OCT6_X(p) (-p.y) -#define LV_CIRC_OCT6_Y(p) (-p.x) -#define LV_CIRC_OCT7_X(p) (p.y) -#define LV_CIRC_OCT7_Y(p) (-p.x) -#define LV_CIRC_OCT8_X(p) (p.x) -#define LV_CIRC_OCT8_Y(p) (-p.y) - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * GLOBAL PROTOTYPES - **********************/ - -/** - * Initialize the circle drawing - * @param c pointer to a point. The coordinates will be calculated here - * @param tmp point to a variable. It will store temporary data - * @param radius radius of the circle - */ -void lv_circ_init(lv_point_t * c, lv_coord_t * tmp, lv_coord_t radius); - -/** - * Test the circle drawing is ready or not - * @param c same as in circ_init - * @return true if the circle is not ready yet - */ -bool lv_circ_cont(lv_point_t * c); - -/** - * Get the next point from the circle - * @param c same as in circ_init. The next point stored here. - * @param tmp same as in circ_init. - */ -void lv_circ_next(lv_point_t * c, lv_coord_t * tmp); - -/********************** - * MACROS - **********************/ - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif diff --git a/src/libs/lvgl/src/lv_misc/lv_color.c b/src/libs/lvgl/src/lv_misc/lv_color.c deleted file mode 100644 index cd4825df..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_color.c +++ /dev/null @@ -1,171 +0,0 @@ -/** - * @file lv_color.c - * - */ - -/********************* - * INCLUDES - *********************/ -#include "lv_color.h" -#include "lv_math.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -/********************** - * STATIC VARIABLES - **********************/ - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -/********************** - * STATIC FUNCTIONS - **********************/ - -/** - * 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) -{ - h = (uint32_t)((uint32_t)h * 255) / 360; - s = (uint16_t)((uint16_t)s * 255) / 100; - v = (uint16_t)((uint16_t)v * 255) / 100; - - uint8_t r, g, b; - - uint8_t region, remainder, p, q, t; - - if(s == 0) { - r = v; - g = v; - b = v; - return lv_color_make(v, v, v); - } - - region = h / 43; - remainder = (h - (region * 43)) * 6; - - p = (v * (255 - s)) >> 8; - q = (v * (255 - ((s * remainder) >> 8))) >> 8; - t = (v * (255 - ((s * (255 - remainder)) >> 8))) >> 8; - - switch(region) { - case 0: - r = v; - g = t; - b = p; - break; - case 1: - r = q; - g = v; - b = p; - break; - case 2: - r = p; - g = v; - b = t; - break; - case 3: - r = p; - g = q; - b = v; - break; - case 4: - r = t; - g = p; - b = v; - break; - default: - r = v; - g = p; - b = q; - break; - } - - lv_color_t result = lv_color_make(r, g, b); - return result; -} - -/** - * 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) -{ - uint16_t r = ((uint32_t)r8 << 10) / 255; - uint16_t g = ((uint32_t)g8 << 10) / 255; - uint16_t b = ((uint32_t)b8 << 10) / 255; - - uint16_t rgbMin = r < g ? (r < b ? r : b) : (g < b ? g : b); - uint16_t rgbMax = r > g ? (r > b ? r : b) : (g > b ? g : b); - - lv_color_hsv_t hsv; - - // https://en.wikipedia.org/wiki/HSL_and_HSV#Lightness - hsv.v = (100 * rgbMax) >> 10; - - int32_t delta = rgbMax - rgbMin; - if (LV_MATH_ABS(delta) < 3) { - hsv.h = 0; - hsv.s = 0; - return hsv; - } - - // https://en.wikipedia.org/wiki/HSL_and_HSV#Saturation - hsv.s = 100 * delta / rgbMax; - if(hsv.s < 3) { - hsv.h = 0; - return hsv; - } - - // https://en.wikipedia.org/wiki/HSL_and_HSV#Hue_and_chroma - int32_t h; - if(rgbMax == r) - h = (((g - b) << 10) / delta) + (g < b ? (6 << 10) : 0); // between yellow & magenta - else if(rgbMax == g) - h = (((b - r) << 10) / delta) + (2 << 10); // between cyan & yellow - else if(rgbMax == b) - h = (((r - g) << 10) / delta) + (4 << 10); // between magenta & cyan - else - h = 0; - h *= 60; - h >>= 10; - if (h < 0) h += 360; - - hsv.h = h; - return hsv; -} - -/** - * 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) -{ - lv_color32_t color32; - color32.full = lv_color_to32(color); - return lv_color_rgb_to_hsv(color32.ch.red, color32.ch.green, color32.ch.blue); -} diff --git a/src/libs/lvgl/src/lv_misc/lv_color.h b/src/libs/lvgl/src/lv_misc/lv_color.h deleted file mode 100644 index 1febbdce..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_color.h +++ /dev/null @@ -1,526 +0,0 @@ -/** - * @file lv_color.h - * - */ - -#ifndef LV_COLOR_H -#define LV_COLOR_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ -#ifdef LV_CONF_INCLUDE_SIMPLE -#include "lv_conf.h" -#else -#include "../../../lv_conf.h" -#endif - -/*Error checking*/ -#if LV_COLOR_DEPTH == 24 -#error "LV_COLOR_DEPTH 24 is deprecated. Use LV_COLOR_DEPTH 32 instead (lv_conf.h)" -#endif - -#if LV_COLOR_DEPTH != 32 && LV_COLOR_SCREEN_TRANSP != 0 -#error "LV_COLOR_SCREEN_TRANSP requires LV_COLOR_DEPTH == 32. Set it in lv_conf.h" -#endif - -#if LV_COLOR_DEPTH != 16 && LV_COLOR_16_SWAP != 0 -#error "LV_COLOR_16_SWAP requires LV_COLOR_DEPTH == 16. Set it in lv_conf.h" -#endif - -#include <stdint.h> - -/********************* - * DEFINES - *********************/ -#define LV_COLOR_WHITE LV_COLOR_MAKE(0xFF, 0xFF, 0xFF) -#define LV_COLOR_SILVER LV_COLOR_MAKE(0xC0, 0xC0, 0xC0) -#define LV_COLOR_GRAY LV_COLOR_MAKE(0x80, 0x80, 0x80) -#define LV_COLOR_BLACK LV_COLOR_MAKE(0x00, 0x00, 0x00) -#define LV_COLOR_RED LV_COLOR_MAKE(0xFF, 0x00, 0x00) -#define LV_COLOR_MAROON LV_COLOR_MAKE(0x80, 0x00, 0x00) -#define LV_COLOR_YELLOW LV_COLOR_MAKE(0xFF, 0xFF, 0x00) -#define LV_COLOR_OLIVE LV_COLOR_MAKE(0x80, 0x80, 0x00) -#define LV_COLOR_LIME LV_COLOR_MAKE(0x00, 0xFF, 0x00) -#define LV_COLOR_GREEN LV_COLOR_MAKE(0x00, 0x80, 0x00) -#define LV_COLOR_CYAN LV_COLOR_MAKE(0x00, 0xFF, 0xFF) -#define LV_COLOR_AQUA LV_COLOR_CYAN -#define LV_COLOR_TEAL LV_COLOR_MAKE(0x00, 0x80, 0x80) -#define LV_COLOR_BLUE LV_COLOR_MAKE(0x00, 0x00, 0xFF) -#define LV_COLOR_NAVY LV_COLOR_MAKE(0x00, 0x00, 0x80) -#define LV_COLOR_MAGENTA LV_COLOR_MAKE(0xFF, 0x00, 0xFF) -#define LV_COLOR_PURPLE LV_COLOR_MAKE(0x80, 0x00, 0x80) -#define LV_COLOR_ORANGE LV_COLOR_MAKE(0xFF, 0xA5, 0x00) - -/** - * 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 16 /*Opacities below this will be transparent*/ -#define LV_OPA_MAX 251 /*Opacities above this will fully cover*/ - -#if LV_COLOR_DEPTH == 1 -#define LV_COLOR_SIZE 8 -#elif LV_COLOR_DEPTH == 8 -#define LV_COLOR_SIZE 8 -#elif LV_COLOR_DEPTH == 16 -#define LV_COLOR_SIZE 16 -#elif LV_COLOR_DEPTH == 32 -#define LV_COLOR_SIZE 32 -#else -#error "Invalid LV_COLOR_DEPTH in lv_conf.h! Set it to 1, 8, 16 or 32!" -#endif - -/*--------------------------------------- - * Macros for all existing color depths - * to set/get values of the color channels - *------------------------------------------*/ -# define LV_COLOR_SET_R1(c, v) (c).ch.red = (uint8_t)((v) & 0x1); -# define LV_COLOR_SET_G1(c, v) (c).ch.green = (uint8_t)((v) & 0x1); -# define LV_COLOR_SET_B1(c, v) (c).ch.blue = (uint8_t)((v) & 0x1); -# define LV_COLOR_SET_A1(c, v) - -# define LV_COLOR_GET_R1(c) (c).ch.red -# define LV_COLOR_GET_G1(c) (c).ch.green -# define LV_COLOR_GET_B1(c) (c).ch.blue -# define LV_COLOR_GET_A1(c) 1 - -# define LV_COLOR_SET_R8(c, v) (c).ch.red = (uint8_t)(v) & 0x7U; -# define LV_COLOR_SET_G8(c, v) (c).ch.green = (uint8_t)(v) & 0x7U; -# define LV_COLOR_SET_B8(c, v) (c).ch.blue = (uint8_t)(v) & 0x3U; -# define LV_COLOR_SET_A8(c, v) do {} while(0) - -# define LV_COLOR_GET_R8(c) (c).ch.red -# define LV_COLOR_GET_G8(c) (c).ch.green -# define LV_COLOR_GET_B8(c) (c).ch.blue -# define LV_COLOR_GET_A8(c) 0xFF - -# define LV_COLOR_SET_R16(c, v) (c).ch.red = (uint8_t)(v) & 0x1FU; -# define LV_COLOR_SET_G16(c, v) (c).ch.green = (uint8_t)(v) & 0x3FU; -# define LV_COLOR_SET_G16_SWAP(c, v) {(c).ch.green_h = (uint8_t)(((v) >> 3) & 0x7); (c).ch.green_l = (uint8_t)((v) & 0x7);} -# define LV_COLOR_SET_B16(c, v) (c).ch.blue = (uint8_t)(v) & 0x1FU; -# define LV_COLOR_SET_A16(c, v) do {} while(0) - -# define LV_COLOR_GET_R16(c) (c).ch.red -# define LV_COLOR_GET_G16(c) (c).ch.green -# define LV_COLOR_GET_G16_SWAP(c) (((c).ch.green_h << 3) + (c).ch.green_l) -# define LV_COLOR_GET_B16(c) (c).ch.blue -# define LV_COLOR_GET_A16(c) 0xFF - -# define LV_COLOR_SET_R32(c, v) (c).ch.red = (uint32_t)((v) & 0xFF); -# define LV_COLOR_SET_G32(c, v) (c).ch.green = (uint32_t)((v) & 0xFF); -# define LV_COLOR_SET_B32(c, v) (c).ch.blue = (uint32_t)((v) & 0xFF); -# define LV_COLOR_SET_A32(c, v) (c).ch.alpha = (uint32_t)((v) & 0xFF); - -# define LV_COLOR_GET_R32(c) (c).ch.red -# define LV_COLOR_GET_G32(c) (c).ch.green -# define LV_COLOR_GET_B32(c) (c).ch.blue -# define LV_COLOR_GET_A32(c) (c).ch.alpha - - -/*--------------------------------------- - * Macros for the current color depth - * to set/get values of the color channels - *------------------------------------------*/ -#if LV_COLOR_DEPTH == 1 -# define LV_COLOR_SET_R(c, v) LV_COLOR_SET_R1(c,v) -# define LV_COLOR_SET_G(c, v) LV_COLOR_SET_G1(c,v) -# define LV_COLOR_SET_B(c, v) LV_COLOR_SET_B1(c,v) -# define LV_COLOR_SET_A(c, v) LV_COLOR_SET_A1(c,v) - -# define LV_COLOR_GET_R(c) LV_COLOR_GET_R1(c) -# define LV_COLOR_GET_G(c) LV_COLOR_GET_G1(c) -# define LV_COLOR_GET_B(c) LV_COLOR_GET_B1(c) -# define LV_COLOR_GET_A(c) LV_COLOR_GET_A1(c) - -#elif LV_COLOR_DEPTH == 8 -# define LV_COLOR_SET_R(c, v) LV_COLOR_SET_R8(c,v) -# define LV_COLOR_SET_G(c, v) LV_COLOR_SET_G8(c,v) -# define LV_COLOR_SET_B(c, v) LV_COLOR_SET_B8(c,v) -# define LV_COLOR_SET_A(c, v) LV_COLOR_SET_A8(c,v) - -# define LV_COLOR_GET_R(c) LV_COLOR_GET_R8(c) -# define LV_COLOR_GET_G(c) LV_COLOR_GET_G8(c) -# define LV_COLOR_GET_B(c) LV_COLOR_GET_B8(c) -# define LV_COLOR_GET_A(c) LV_COLOR_GET_A8(c) - -#elif LV_COLOR_DEPTH == 16 -# define LV_COLOR_SET_R(c, v) LV_COLOR_SET_R16(c,v) -# if LV_COLOR_16_SWAP == 0 -# define LV_COLOR_SET_G(c, v) LV_COLOR_SET_G16(c,v) -# else -# define LV_COLOR_SET_G(c, v) LV_COLOR_SET_G16_SWAP(c,v) -# endif -# define LV_COLOR_SET_B(c, v) LV_COLOR_SET_B16(c,v) -# define LV_COLOR_SET_A(c, v) LV_COLOR_SET_A16(c,v) - -# define LV_COLOR_GET_R(c) LV_COLOR_GET_R16(c) -# if LV_COLOR_16_SWAP == 0 -# define LV_COLOR_GET_G(c) LV_COLOR_GET_G16(c) -# else -# define LV_COLOR_GET_G(c) LV_COLOR_GET_G16_SWAP(c) -# endif -# define LV_COLOR_GET_B(c) LV_COLOR_GET_B16(c) -# define LV_COLOR_GET_A(c) LV_COLOR_GET_A16(c) - -#elif LV_COLOR_DEPTH == 32 -# define LV_COLOR_SET_R(c, v) LV_COLOR_SET_R32(c,v) -# define LV_COLOR_SET_G(c, v) LV_COLOR_SET_G32(c,v) -# define LV_COLOR_SET_B(c, v) LV_COLOR_SET_B32(c,v) -# define LV_COLOR_SET_A(c, v) LV_COLOR_SET_A32(c,v) - -# define LV_COLOR_GET_R(c) LV_COLOR_GET_R32(c) -# define LV_COLOR_GET_G(c) LV_COLOR_GET_G32(c) -# define LV_COLOR_GET_B(c) LV_COLOR_GET_B32(c) -# define LV_COLOR_GET_A(c) LV_COLOR_GET_A32(c) -#endif - -/********************** - * TYPEDEFS - **********************/ - -typedef union -{ - struct - { - uint8_t blue : 1; - uint8_t green : 1; - uint8_t red : 1; - } ch; - uint8_t full; -} lv_color1_t; - -typedef union -{ - struct - { - uint8_t blue : 2; - uint8_t green : 3; - uint8_t red : 3; - } ch; - uint8_t full; -} lv_color8_t; - -typedef union -{ - struct - { -#if LV_COLOR_16_SWAP == 0 - uint16_t blue : 5; - uint16_t green : 6; - uint16_t red : 5; -#else - uint16_t green_h : 3; - uint16_t red : 5; - uint16_t blue : 5; - uint16_t green_l : 3; -#endif - } ch; - uint16_t full; -} lv_color16_t; - -typedef union -{ - struct - { - uint8_t blue; - uint8_t green; - uint8_t red; - uint8_t alpha; - } ch; - uint32_t full; -} lv_color32_t; - -#if LV_COLOR_DEPTH == 1 -typedef uint8_t lv_color_int_t; -typedef lv_color1_t lv_color_t; -#elif LV_COLOR_DEPTH == 8 -typedef uint8_t lv_color_int_t; -typedef lv_color8_t lv_color_t; -#elif LV_COLOR_DEPTH == 16 -typedef uint16_t lv_color_int_t; -typedef lv_color16_t lv_color_t; -#elif LV_COLOR_DEPTH == 32 -typedef uint32_t lv_color_int_t; -typedef lv_color32_t lv_color_t; -#else -#error "Invalid LV_COLOR_DEPTH in lv_conf.h! Set it to 1, 8, 16 or 32!" -#endif - -typedef uint8_t lv_opa_t; - -typedef struct -{ - uint16_t h; - uint8_t s; - uint8_t v; -} lv_color_hsv_t; - -/********************** - * GLOBAL PROTOTYPES - **********************/ - -/*In color conversations: - * - When converting to bigger color type the LSB weight of 1 LSB is calculated - * E.g. 16 bit Red has 5 bits - * 8 bit Red has 2 bits - * ---------------------- - * 8 bit red LSB = (2^5 - 1) / (2^2 - 1) = 31 / 3 = 10 - * - * - When calculating to smaller color type simply shift out the LSBs - * E.g. 8 bit Red has 2 bits - * 16 bit Red has 5 bits - * ---------------------- - * Shift right with 5 - 3 = 2 - */ - -static inline uint8_t lv_color_to1(lv_color_t color) -{ -#if LV_COLOR_DEPTH == 1 - return color.full; -#elif LV_COLOR_DEPTH == 8 - if((LV_COLOR_GET_R(color) & 0x4) || (LV_COLOR_GET_G(color) & 0x4) || (LV_COLOR_GET_B(color) & 0x2)) { - return 1; - } else { - return 0; - } -#elif LV_COLOR_DEPTH == 16 - if((LV_COLOR_GET_R(color) & 0x10) || (LV_COLOR_GET_G(color) & 0x20) || (LV_COLOR_GET_B(color) & 0x10)) { - return 1; - } else { - return 0; - } -#elif LV_COLOR_DEPTH == 32 - if((LV_COLOR_GET_R(color) & 0x80) || (LV_COLOR_GET_G(color) & 0x80) || (LV_COLOR_GET_B(color) & 0x80)) { - return 1; - } else { - return 0; - } -#endif -} - -static inline uint8_t lv_color_to8(lv_color_t color) -{ -#if LV_COLOR_DEPTH == 1 - if(color.full == 0) - return 0; - else - return 0xFF; -#elif LV_COLOR_DEPTH == 8 - return color.full; -#elif LV_COLOR_DEPTH == 16 - lv_color8_t ret; - LV_COLOR_SET_R8(ret, LV_COLOR_GET_R(color) >> 2); /* 5 - 3 = 2*/ - LV_COLOR_SET_G8(ret, LV_COLOR_GET_G(color) >> 3); /* 6 - 3 = 3*/ - LV_COLOR_SET_B8(ret, LV_COLOR_GET_B(color) >> 3); /* 5 - 2 = 3*/ - return ret.full; -#elif LV_COLOR_DEPTH == 32 - lv_color8_t ret; - LV_COLOR_SET_R8(ret, LV_COLOR_GET_R(color) >> 5); /* 8 - 3 = 5*/ - LV_COLOR_SET_G8(ret, LV_COLOR_GET_G(color) >> 5); /* 8 - 3 = 5*/ - LV_COLOR_SET_B8(ret, LV_COLOR_GET_B(color) >> 6); /* 8 - 2 = 6*/ - return ret.full; -#endif -} - -static inline uint16_t lv_color_to16(lv_color_t color) -{ -#if LV_COLOR_DEPTH == 1 - if(color.full == 0) - return 0; - else - return 0xFFFF; -#elif LV_COLOR_DEPTH == 8 - lv_color16_t ret; - LV_COLOR_SET_R16(ret, LV_COLOR_GET_R(color) * 4); /*(2^5 - 1)/(2^3 - 1) = 31/7 = 4*/ -#if LV_COLOR_16_SWAP == 0 - LV_COLOR_SET_G16(ret, LV_COLOR_GET_G(color) * 9); /*(2^6 - 1)/(2^3 - 1) = 63/7 = 9*/ -#else - LV_COLOR_SET_G16_SWAP(ret, (LV_COLOR_GET_G(color) * 9)); /*(2^6 - 1)/(2^3 - 1) = 63/7 = 9*/ -#endif - LV_COLOR_SET_B16(ret, LV_COLOR_GET_B(color) * 10); /*(2^5 - 1)/(2^2 - 1) = 31/3 = 10*/ - return ret.full; -#elif LV_COLOR_DEPTH == 16 - return color.full; -#elif LV_COLOR_DEPTH == 32 - lv_color16_t ret; - LV_COLOR_SET_R16(ret, LV_COLOR_GET_R(color) >> 3); /* 8 - 5 = 3*/ - -#if LV_COLOR_16_SWAP == 0 - LV_COLOR_SET_G16(ret, LV_COLOR_GET_G(color) >> 2); /* 8 - 6 = 2*/ -#else - LV_COLOR_SET_G16_SWAP(ret, ret.ch.green_h = (LV_COLOR_GET_G(color) >> 2); /*(2^6 - 1)/(2^3 - 1) = 63/7 = 9*/ -#endif - LV_COLOR_SET_B16(ret, LV_COLOR_GET_B(color) >> 3); /* 8 - 5 = 3*/ - return ret.full; -#endif -} - -static inline uint32_t lv_color_to32(lv_color_t color) -{ -#if LV_COLOR_DEPTH == 1 - if(color.full == 0) - return 0; - else - return 0xFFFFFFFF; -#elif LV_COLOR_DEPTH == 8 - lv_color32_t ret; - LV_COLOR_SET_R32(ret, LV_COLOR_GET_R(color) * 36); /*(2^8 - 1)/(2^3 - 1) = 255/7 = 36*/ - LV_COLOR_SET_G32(ret, LV_COLOR_GET_G(color) * 36); /*(2^8 - 1)/(2^3 - 1) = 255/7 = 36*/ - LV_COLOR_SET_B32(ret, LV_COLOR_GET_B(color) * 85); /*(2^8 - 1)/(2^2 - 1) = 255/3 = 85*/ - LV_COLOR_SET_A32(ret, 0xFF); - return ret.full; -#elif LV_COLOR_DEPTH == 16 - /** - * The floating point math for conversion is: - * valueto = valuefrom * ( (2^bitsto - 1) / (float)(2^bitsfrom - 1) ) - * The faster integer math for conversion is: - * valueto = ( valuefrom * multiplier + adder ) >> divisor - * multiplier = FLOOR( ( (2^bitsto - 1) << divisor ) / (float)(2^bitsfrom - 1) ) - * - * Find the first divisor where ( adder >> divisor ) <= 0 - * - * 5-bit to 8-bit: ( 31 * multiplier + adder ) >> divisor = 255 - * divisor multiplier adder min (0) max (31) - * 0 8 7 7 255 - * 1 16 14 7 255 - * 2 32 28 7 255 - * 3 65 25 3 255 - * 4 131 19 1 255 - * 5 263 7 0 255 - * - * 6-bit to 8-bit: 255 = ( 63 * multiplier + adder ) >> divisor - * divisor multiplier adder min (0) max (63) - * 0 4 3 3 255 - * 1 8 6 3 255 - * 2 16 12 3 255 - * 3 32 24 3 255 - * 4 64 48 3 255 - * 5 129 33 1 255 - * 6 259 3 0 255 - */ - lv_color32_t ret; - LV_COLOR_SET_R32(ret, (LV_COLOR_GET_R(color) * 263 + 7 ) >> 5); - LV_COLOR_SET_G32(ret, (LV_COLOR_GET_G(color) * 259 + 3 ) >> 6); - LV_COLOR_SET_B32(ret, (LV_COLOR_GET_B(color) * 263 + 7 ) >> 5); - LV_COLOR_SET_A32(ret, 0xFF); - return ret.full; -#elif LV_COLOR_DEPTH == 32 - return color.full; -#endif -} - -static inline lv_color_t lv_color_mix(lv_color_t c1, lv_color_t c2, uint8_t mix) -{ - lv_color_t ret; -#if LV_COLOR_DEPTH != 1 - /*LV_COLOR_DEPTH == 8, 16 or 32*/ - LV_COLOR_SET_R(ret, (uint16_t)((uint16_t) LV_COLOR_GET_R(c1) * mix + LV_COLOR_GET_R(c2) * (255 - mix)) >> 8); - LV_COLOR_SET_G(ret, (uint16_t)((uint16_t) LV_COLOR_GET_G(c1) * mix + LV_COLOR_GET_G(c2) * (255 - mix)) >> 8); - LV_COLOR_SET_B(ret, (uint16_t)((uint16_t) LV_COLOR_GET_B(c1) * mix + LV_COLOR_GET_B(c2) * (255 - mix)) >> 8); - LV_COLOR_SET_A(ret, 0xFF); -#else - /*LV_COLOR_DEPTH == 1*/ - ret.full = mix > LV_OPA_50 ? c1.full : c2.full; -#endif - - return ret; -} - -/** - * Get the brightness of a color - * @param color a color - * @return the brightness [0..255] - */ -static inline uint8_t lv_color_brightness(lv_color_t color) -{ - lv_color32_t c32; - c32.full = lv_color_to32(color); - uint16_t bright = (uint16_t)(3u * LV_COLOR_GET_R32(c32) + LV_COLOR_GET_B32(c32) + 4u * LV_COLOR_GET_G32(c32)); - return (uint8_t)(bright >> 3); -} - -/* The most simple macro to create a color from R,G and B values */ -#if LV_COLOR_DEPTH == 1 -#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){.full = (uint8_t)((b8 >> 7) | (g8 >> 7) | (r8 >> 7))}) -#elif LV_COLOR_DEPTH == 8 -#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{(uint8_t)((b8 >> 6) & 0x3U), (uint8_t)((g8 >> 5) & 0x7U), (uint8_t)((r8 >> 5) & 0x7U)}}) -#elif LV_COLOR_DEPTH == 16 -#if LV_COLOR_16_SWAP == 0 -#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{(uint16_t)((b8 >> 3) & 0x1FU), (uint16_t)((g8 >> 2) & 0x3FU), (uint16_t)((r8 >> 3) & 0x1FU)}}) -#else -#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{(uint16_t)((g8 >> 5) & 0x7U), (uint16_t)((r8 >> 3) & 0x1FU), (uint16_t)((b8 >> 3) & 0x1FU), (uint16_t)((g8 >> 2) & 0x7U)}}) -#endif -#elif LV_COLOR_DEPTH == 32 -#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{b8, g8, r8, 0xff}}) /*Fix 0xff alpha*/ -#endif - -static inline lv_color_t lv_color_make(uint8_t r, uint8_t g, uint8_t b) -{ - return LV_COLOR_MAKE(r, g, b); -} - -static inline lv_color_t lv_color_hex(uint32_t c) -{ - return lv_color_make((uint8_t)((c >> 16) & 0xFF), (uint8_t)((c >> 8) & 0xFF), (uint8_t)(c & 0xFF)); -} - -static inline lv_color_t lv_color_hex3(uint32_t c) -{ - return lv_color_make((uint8_t)(((c >> 4) & 0xF0) | ((c >> 8) & 0xF)), (uint8_t)((c & 0xF0) | ((c & 0xF0) >> 4)), - (uint8_t)((c & 0xF) | ((c & 0xF) << 4))); -} - -/** - * 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); - -/********************** - * MACROS - **********************/ - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /*USE_COLOR*/ diff --git a/src/libs/lvgl/src/lv_misc/lv_fs.c b/src/libs/lvgl/src/lv_misc/lv_fs.c deleted file mode 100644 index a23081ce..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_fs.c +++ /dev/null @@ -1,642 +0,0 @@ -/** - * @file lv_fs.c - * - */ - -/********************* - * INCLUDES - *********************/ -#include "lv_fs.h" -#if LV_USE_FILESYSTEM - -#include "../lv_core/lv_debug.h" -#include "lv_ll.h" -#include <string.h> -#include "lv_gc.h" - -#if defined(LV_GC_INCLUDE) -#include LV_GC_INCLUDE -#endif /* LV_ENABLE_GC */ - -/********************* - * DEFINES - *********************/ - -/* "free" is used as a function pointer (in lv_fs_drv_t). - * We must make sure "free" was not defined to a platform specific - * free function, otherwise compilation would fail. - */ -#ifdef free -#undef free -#endif - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ -static const char * lv_fs_get_real_path(const char * path); - -/********************** - * STATIC VARIABLES - **********************/ - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -/** - * Initialize the File system interface - */ -void lv_fs_init(void) -{ - lv_ll_init(&LV_GC_ROOT(_lv_drv_ll), sizeof(lv_fs_drv_t)); -} - -/** - * Test if a drive is rady 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) -{ - lv_fs_drv_t * drv = lv_fs_get_drv(letter); - - if(drv == NULL) return false; /*An unknown driver in not ready*/ - - if(drv->ready_cb == NULL) return true; /*Assume the driver is always ready if no handler provided*/ - - return drv->ready_cb(drv); -} - -/** - * 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) -{ - file_p->drv = NULL; - file_p->file_d = NULL; - - if(path == NULL) return LV_FS_RES_INV_PARAM; - - char letter = path[0]; - - file_p->drv = lv_fs_get_drv(letter); - - if(file_p->drv == NULL) { - file_p->file_d = NULL; - return LV_FS_RES_NOT_EX; - } - - if(file_p->drv->ready_cb != NULL) { - if(file_p->drv->ready_cb(file_p->drv) == false) { - file_p->drv = NULL; - file_p->file_d = NULL; - return LV_FS_RES_HW_ERR; - } - } - - file_p->file_d = lv_mem_alloc(file_p->drv->file_size); - LV_ASSERT_MEM(file_p->file_d); - if(file_p->file_d == NULL) { - file_p->drv = NULL; - return LV_FS_RES_OUT_OF_MEM; /* Out of memory */ - } - - if(file_p->drv->open_cb == NULL) { - return LV_FS_RES_NOT_IMP; - } - - const char * real_path = lv_fs_get_real_path(path); - lv_fs_res_t res = file_p->drv->open_cb(file_p->drv, file_p->file_d, real_path, mode); - - if(res != LV_FS_RES_OK) { - lv_mem_free(file_p->file_d); - file_p->file_d = NULL; - file_p->drv = NULL; - } - - return res; -} - -/** - * 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) -{ - if(file_p->drv == NULL) { - return LV_FS_RES_INV_PARAM; - } - - if(file_p->drv->close_cb == NULL) { - return LV_FS_RES_NOT_IMP; - } - - lv_fs_res_t res = file_p->drv->close_cb(file_p->drv, file_p->file_d); - - lv_mem_free(file_p->file_d); /*Clean up*/ - file_p->file_d = NULL; - file_p->drv = NULL; - file_p->file_d = NULL; - - return res; -} - -/** - * Delete a file - * @param path path of the file to delete - * @return LV_FS_RES_OK or any error from lv_fs_res_t enum - */ -lv_fs_res_t lv_fs_remove(const char * path) -{ - if(path == NULL) return LV_FS_RES_INV_PARAM; - lv_fs_drv_t * drv = NULL; - - char letter = path[0]; - - drv = lv_fs_get_drv(letter); - if(drv == NULL) return LV_FS_RES_NOT_EX; - if(drv->ready_cb != NULL) { - if(drv->ready_cb(drv) == false) return LV_FS_RES_HW_ERR; - } - - if(drv->remove_cb == NULL) return LV_FS_RES_NOT_IMP; - - const char * real_path = lv_fs_get_real_path(path); - lv_fs_res_t res = drv->remove_cb(drv, real_path); - - return res; -} - -/** - * 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) -{ - if(br != NULL) *br = 0; - if(file_p->drv == NULL) return LV_FS_RES_INV_PARAM; - if(file_p->drv->read_cb == NULL) return LV_FS_RES_NOT_IMP; - - uint32_t br_tmp = 0; - lv_fs_res_t res = file_p->drv->read_cb(file_p->drv, file_p->file_d, buf, btr, &br_tmp); - if(br != NULL) *br = br_tmp; - - return res; -} - -/** - * 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 btr Bytes To Write - * @param br 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) -{ - if(bw != NULL) *bw = 0; - - if(file_p->drv == NULL) { - return LV_FS_RES_INV_PARAM; - } - - if(file_p->drv->write_cb == NULL) { - return LV_FS_RES_NOT_IMP; - } - - uint32_t bw_tmp = 0; - lv_fs_res_t res = file_p->drv->write_cb(file_p->drv, file_p->file_d, buf, btw, &bw_tmp); - if(bw != NULL) *bw = bw_tmp; - - return res; -} - -/** - * 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) - * @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) -{ - if(file_p->drv == NULL) { - return LV_FS_RES_INV_PARAM; - } - - if(file_p->drv->seek_cb == NULL) { - return LV_FS_RES_NOT_IMP; - } - - lv_fs_res_t res = file_p->drv->seek_cb(file_p->drv, file_p->file_d, pos); - - return res; -} - -/** - * Give the position of the read write pointer - * @param file_p pointer to a lv_fs_file_t variable - * @param pos_p 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) -{ - if(file_p->drv == NULL) { - pos = 0; - return LV_FS_RES_INV_PARAM; - } - - if(file_p->drv->tell_cb == NULL) { - pos = 0; - return LV_FS_RES_NOT_IMP; - } - - lv_fs_res_t res = file_p->drv->tell_cb(file_p->drv, file_p->file_d, pos); - - return res; -} - -/** - * Truncate the file size to the current position of the read write pointer - * @param file_p pointer to an 'ufs_file_t' variable. (opened with lv_fs_open ) - * @return LV_FS_RES_OK: no error, the file is read - * any error from lv_fs_res_t enum - */ -lv_fs_res_t lv_fs_trunc(lv_fs_file_t * file_p) -{ - if(file_p->drv == NULL) { - return LV_FS_RES_INV_PARAM; - } - - if(file_p->drv->tell_cb == NULL) { - return LV_FS_RES_NOT_IMP; - } - - lv_fs_res_t res = file_p->drv->trunc_cb(file_p->drv, file_p->file_d); - - return res; -} -/** - * Give the size of a file bytes - * @param file_p pointer to a lv_fs_file_t variable - * @param size pointer to a variable to store the size - * @return LV_FS_RES_OK or any error from lv_fs_res_t enum - */ -lv_fs_res_t lv_fs_size(lv_fs_file_t * file_p, uint32_t * size) -{ - if(file_p->drv == NULL) { - return LV_FS_RES_INV_PARAM; - } - - if(file_p->drv->size_cb == NULL) return LV_FS_RES_NOT_IMP; - - if(size == NULL) return LV_FS_RES_INV_PARAM; - - lv_fs_res_t res = file_p->drv->size_cb(file_p->drv, file_p->file_d, size); - - return res; -} - -/** - * Rename a file - * @param oldname path to the file - * @param newname path with the new name - * @return LV_FS_RES_OK or any error from 'fs_res_t' - */ -lv_fs_res_t lv_fs_rename(const char * oldname, const char * newname) -{ - if(!oldname || !newname) return LV_FS_RES_INV_PARAM; - - char letter = oldname[0]; - - lv_fs_drv_t * drv = lv_fs_get_drv(letter); - - if(!drv) { - return LV_FS_RES_NOT_EX; - } - - if(drv->ready_cb != NULL) { - if(drv->ready_cb(drv) == false) { - return LV_FS_RES_HW_ERR; - } - } - - if(drv->rename_cb == NULL) return LV_FS_RES_NOT_IMP; - - const char * old_real = lv_fs_get_real_path(oldname); - const char * new_real = lv_fs_get_real_path(newname); - - lv_fs_res_t res = drv->rename_cb(drv, old_real, new_real); - - return res; -} - -/** - * Initialize a 'fs_read_dir_t' variable for directory reading - * @param rddir_p pointer to a 'fs_read_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) -{ - if(path == NULL) return LV_FS_RES_INV_PARAM; - - char letter = path[0]; - - rddir_p->drv = lv_fs_get_drv(letter); - - if(rddir_p->drv == NULL) { - rddir_p->dir_d = NULL; - return LV_FS_RES_NOT_EX; - } - - rddir_p->dir_d = lv_mem_alloc(rddir_p->drv->rddir_size); - LV_ASSERT_MEM(rddir_p->dir_d); - if(rddir_p->dir_d == NULL) { - rddir_p->dir_d = NULL; - return LV_FS_RES_OUT_OF_MEM; /* Out of memory */ - } - - if(rddir_p->drv->dir_open_cb == NULL) { - return LV_FS_RES_NOT_IMP; - } - - const char * real_path = lv_fs_get_real_path(path); - - lv_fs_res_t res = rddir_p->drv->dir_open_cb(rddir_p->drv, rddir_p->dir_d, real_path); - - return res; -} - -/** - * Read the next filename form a directory. - * The name of the directories will begin with '/' - * @param rddir_p pointer to an initialized 'fs_read_dir_t' variable - * @param fn pointer to a 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) -{ - if(rddir_p->drv == NULL || rddir_p->dir_d == NULL) { - fn[0] = '\0'; - return LV_FS_RES_INV_PARAM; - } - - if(rddir_p->drv->dir_read_cb == NULL) { - return LV_FS_RES_NOT_IMP; - } - - lv_fs_res_t res = rddir_p->drv->dir_read_cb(rddir_p->drv, rddir_p->dir_d, fn); - - return res; -} - -/** - * Close the directory reading - * @param rddir_p pointer to an initialized 'fs_read_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) -{ - if(rddir_p->drv == NULL || rddir_p->dir_d == NULL) { - return LV_FS_RES_INV_PARAM; - } - - lv_fs_res_t res; - - if(rddir_p->drv->dir_close_cb == NULL) { - res = LV_FS_RES_NOT_IMP; - } else { - res = rddir_p->drv->dir_close_cb(rddir_p->drv, rddir_p->dir_d); - } - - lv_mem_free(rddir_p->dir_d); /*Clean up*/ - rddir_p->dir_d = NULL; - rddir_p->drv = NULL; - rddir_p->dir_d = NULL; - - return res; -} - -/** - * Get the free and total size of a driver in kB - * @param letter the driver letter - * @param total_p pointer to store the total size [kB] - * @param free_p pointer to store the free size_cb [kB] - * @return LV_FS_RES_OK or any error from lv_fs_res_t enum - */ -lv_fs_res_t lv_fs_free_space(char letter, uint32_t * total_p, uint32_t * free_p) -{ - lv_fs_drv_t * drv = lv_fs_get_drv(letter); - - if(drv == NULL) { - return LV_FS_RES_INV_PARAM; - } - - lv_fs_res_t res; - - if(drv->free_space_cb == NULL) { - res = LV_FS_RES_NOT_IMP; - } else { - uint32_t total_tmp = 0; - uint32_t free_tmp = 0; - res = drv->free_space_cb(drv, &total_tmp, &free_tmp); - - if(total_p != NULL) *total_p = total_tmp; - if(free_p != NULL) *free_p = free_tmp; - } - - return res; -} - -/** - * Initialize a file system driver with default values. - * It is used to surly have known values in the fields ant 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) -{ - memset(drv, 0, sizeof(lv_fs_drv_t)); -} - -/** - * Add a new drive - * @param drv_p pointer to an lv_fs_drv_t structure which is inited with the - * corresponding function pointers. The data will be copied so the variable can be local. - */ -void lv_fs_drv_register(lv_fs_drv_t * drv_p) -{ - /*Save the new driver*/ - lv_fs_drv_t * new_drv; - new_drv = lv_ll_ins_head(&LV_GC_ROOT(_lv_drv_ll)); - LV_ASSERT_MEM(new_drv); - if(new_drv == NULL) return; - - memcpy(new_drv, drv_p, sizeof(lv_fs_drv_t)); -} - -/** - * 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) -{ - lv_fs_drv_t * drv; - - LV_LL_READ(LV_GC_ROOT(_lv_drv_ll), drv) - { - if(drv->letter == letter) { - return drv; - } - } - - return NULL; -} -/** - * 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) -{ - lv_fs_drv_t * drv; - uint8_t i = 0; - - LV_LL_READ(LV_GC_ROOT(_lv_drv_ll), drv) - { - buf[i] = drv->letter; - i++; - } - - buf[i] = '\0'; - - return 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) -{ - size_t i; - for(i = strlen(fn); i > 0; i--) { - if(fn[i] == '.') { - return &fn[i + 1]; - } else if(fn[i] == '/' || fn[i] == '\\') { - return ""; /*No extension if a '\' or '/' found*/ - } - } - - return ""; /*Empty string if no '.' in the file name. */ -} - -/** - * Step up one level - * @param path pointer to a file name - * @return the truncated file name - */ -char * lv_fs_up(char * path) -{ - size_t len = strlen(path); - if(len == 0) return path; - - len--; /*Go before the trailing '\0'*/ - - /*Ignore trailing '/' or '\'*/ - while(path[len] == '/' || path[len] == '\\') { - path[len] = '\0'; - if(len > 0) - len--; - else - return path; - } - - size_t i; - for(i = len; i > 0; i--) { - if(path[i] == '/' || path[i] == '\\') break; - } - - if(i > 0) path[i] = '\0'; - - return path; -} - -/** - * Get the last element of a path (e.g. U:/folder/file -> file) - * @param path a character sting with the path to search in - * @return pointer to the beginning of the last element in the path - */ -const char * lv_fs_get_last(const char * path) -{ - size_t len = strlen(path); - if(len == 0) return path; - - len--; /*Go before the trailing '\0'*/ - - /*Ignore trailing '/' or '\'*/ - while(path[len] == '/' || path[len] == '\\') { - if(len > 0) - len--; - else - return path; - } - - size_t i; - for(i = len; i > 0; i--) { - if(path[i] == '/' || path[i] == '\\') break; - } - - /*No '/' or '\' in the path so return with path itself*/ - if(i == 0) return path; - - return &path[i + 1]; -} -/********************** - * STATIC FUNCTIONS - **********************/ - -/** - * Leave the driver letters and / or \ letters from beginning of the path - * @param path path string (E.g. S:/folder/file.txt) - * @return pointer to the beginning of the real path (E.g. folder/file.txt) - */ -static const char * lv_fs_get_real_path(const char * path) -{ - /* Example path: "S:/folder/file.txt" - * Leave the letter and the : / \ characters*/ - - path++; /*Ignore the driver letter*/ - - while(*path != '\0') { - if(*path == ':' || *path == '\\' || *path == '/') { - path++; - } else { - break; - } - } - - return path; -} - -#endif /*LV_USE_FILESYSTEM*/ diff --git a/src/libs/lvgl/src/lv_misc/lv_fs.h b/src/libs/lvgl/src/lv_misc/lv_fs.h deleted file mode 100644 index f1824282..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_fs.h +++ /dev/null @@ -1,299 +0,0 @@ -/** - * @file lv_fs.h - * - */ - -#ifndef LV_FS_H -#define LV_FS_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ -#ifdef LV_CONF_INCLUDE_SIMPLE -#include "lv_conf.h" -#else -#include "../../../lv_conf.h" -#endif - -#if LV_USE_FILESYSTEM - -#include <stdint.h> -#include <stdbool.h> -#include "lv_mem.h" - -/********************* - * DEFINES - *********************/ -#define LV_FS_MAX_FN_LENGTH 64 -#define LV_FS_MAX_PATH_LENGTH 256 - -/********************** - * TYPEDEFS - **********************/ -/** - * Errors in the filesystem module. - */ -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*/ -}; -typedef uint8_t lv_fs_res_t; - -/** - * Filesystem mode. - */ -enum { - LV_FS_MODE_WR = 0x01, - LV_FS_MODE_RD = 0x02, -}; -typedef uint8_t lv_fs_mode_t; - -typedef struct _lv_fs_drv_t -{ - char letter; - uint16_t file_size; - uint16_t rddir_size; - bool (*ready_cb)(struct _lv_fs_drv_t * drv); - - lv_fs_res_t (*open_cb)(struct _lv_fs_drv_t * drv, void * file_p, const char * path, lv_fs_mode_t mode); - lv_fs_res_t (*close_cb)(struct _lv_fs_drv_t * drv, void * file_p); - lv_fs_res_t (*remove_cb)(struct _lv_fs_drv_t * drv, const char * fn); - lv_fs_res_t (*read_cb)(struct _lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br); - lv_fs_res_t (*write_cb)(struct _lv_fs_drv_t * drv, void * file_p, const void * buf, uint32_t btw, uint32_t * bw); - lv_fs_res_t (*seek_cb)(struct _lv_fs_drv_t * drv, void * file_p, uint32_t pos); - lv_fs_res_t (*tell_cb)(struct _lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p); - lv_fs_res_t (*trunc_cb)(struct _lv_fs_drv_t * drv, void * file_p); - lv_fs_res_t (*size_cb)(struct _lv_fs_drv_t * drv, void * file_p, uint32_t * size_p); - lv_fs_res_t (*rename_cb)(struct _lv_fs_drv_t * drv, const char * oldname, const char * newname); - lv_fs_res_t (*free_space_cb)(struct _lv_fs_drv_t * drv, uint32_t * total_p, uint32_t * free_p); - - lv_fs_res_t (*dir_open_cb)(struct _lv_fs_drv_t * drv, void * rddir_p, const char * path); - lv_fs_res_t (*dir_read_cb)(struct _lv_fs_drv_t * drv, void * rddir_p, char * fn); - lv_fs_res_t (*dir_close_cb)(struct _lv_fs_drv_t * drv, void * rddir_p); - -#if LV_USE_USER_DATA - lv_fs_drv_user_data_t user_data; /**< Custom file user data */ -#endif -} lv_fs_drv_t; - -typedef struct -{ - void * file_d; - lv_fs_drv_t * drv; -} lv_fs_file_t; - -typedef struct -{ - void * dir_d; - lv_fs_drv_t * drv; -} lv_fs_dir_t; - -/********************** - * GLOBAL PROTOTYPES - **********************/ - -/** - * Initialize the File system interface - */ -void lv_fs_init(void); - -/** - * Initialize a file system driver with default values. - * It is used to surly have known values in the fields ant 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_p pointer to an lv_fs_drv_t structure which is inited with the - * corresponding function pointers. The data will be copied so the variable can be local. - */ -void lv_fs_drv_register(lv_fs_drv_t * drv_p); - -/** - * 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 rady 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); - -/** - * 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); - -/** - * Delete a file - * @param path path of the file to delete - * @return LV_FS_RES_OK or any error from lv_fs_res_t enum - */ -lv_fs_res_t lv_fs_remove(const char * path); - -/** - * 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 btr Bytes To Write - * @param br 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) - * @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); - -/** - * Give the position of the read write pointer - * @param file_p pointer to a lv_fs_file_t variable - * @param pos_p 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); - -/** - * Truncate the file size to the current position of the read write pointer - * @param file_p pointer to an 'ufs_file_t' variable. (opened with lv_fs_open ) - * @return LV_FS_RES_OK: no error, the file is read - * any error from lv_fs_res_t enum - */ -lv_fs_res_t lv_fs_trunc(lv_fs_file_t * file_p); - -/** - * Give the size of a file bytes - * @param file_p pointer to a lv_fs_file_t variable - * @param size pointer to a variable to store the size - * @return LV_FS_RES_OK or any error from lv_fs_res_t enum - */ -lv_fs_res_t lv_fs_size(lv_fs_file_t * file_p, uint32_t * size); - -/** - * Rename a file - * @param oldname path to the file - * @param newname path with the new name - * @return LV_FS_RES_OK or any error from 'fs_res_t' - */ -lv_fs_res_t lv_fs_rename(const char * oldname, const char * newname); - -/** - * Initialize a 'fs_dir_t' variable for directory reading - * @param rddir_p pointer to a 'fs_read_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_rdir_t' variable - * @param fn pointer to a 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); - -/** - * 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); - -/** - * Get the free and total size of a driver in kB - * @param letter the driver letter - * @param total_p pointer to store the total size [kB] - * @param free_p pointer to store the free size [kB] - * @return LV_FS_RES_OK or any error from lv_fs_res_t enum - */ -lv_fs_res_t lv_fs_free_space(char letter, uint32_t * total_p, uint32_t * free_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 buf buffer to store the letters ('\0' added after the last letter) - * @return pointer to the beginning of the last element in the path - */ -const char * lv_fs_get_last(const char * path); - -/********************** - * MACROS - **********************/ - -#endif /*LV_USE_FILESYSTEM*/ - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /*LV_FS_H*/ diff --git a/src/libs/lvgl/src/lv_misc/lv_gc.c b/src/libs/lvgl/src/lv_misc/lv_gc.c deleted file mode 100644 index 94bf532a..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_gc.c +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @file lv_gc.c - * - */ - -/********************* - * INCLUDES - *********************/ - -#include "lv_gc.h" -#include "string.h" - -#if defined(LV_GC_INCLUDE) -#include LV_GC_INCLUDE -#endif /* LV_ENABLE_GC */ - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -/********************** - * STATIC VARIABLES - **********************/ -#if(!defined(LV_ENABLE_GC)) || LV_ENABLE_GC == 0 -LV_ROOTS -#endif /* LV_ENABLE_GC */ -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -void lv_gc_clear_roots(void) -{ -#define LV_CLEAR_ROOT(root_type, root_name) memset(&LV_GC_ROOT(root_name), 0, sizeof(LV_GC_ROOT(root_name))); - LV_ITERATE_ROOTS(LV_CLEAR_ROOT) -} - -/********************** - * STATIC FUNCTIONS - **********************/ diff --git a/src/libs/lvgl/src/lv_misc/lv_gc.h b/src/libs/lvgl/src/lv_misc/lv_gc.h deleted file mode 100644 index afd4d600..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_gc.h +++ /dev/null @@ -1,77 +0,0 @@ -/** - * @file lv_gc.h - * - */ - -#ifndef LV_GC_H -#define LV_GC_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ - -#ifdef LV_CONF_INCLUDE_SIMPLE -#include "lv_conf.h" -#else -#include "../../../lv_conf.h" -#endif - -#include <stdint.h> -#include <stdbool.h> -#include "lv_mem.h" -#include "lv_ll.h" -#include "../lv_draw/lv_img_cache.h" - -/********************* - * DEFINES - *********************/ - -#define LV_ITERATE_ROOTS(f) \ - f(lv_ll_t, _lv_task_ll) /*Linked list to store the lv_tasks*/ \ - f(lv_ll_t, _lv_disp_ll) /*Linked list of screens*/ \ - f(lv_ll_t, _lv_indev_ll) /*Linked list of screens*/ \ - f(lv_ll_t, _lv_drv_ll) \ - f(lv_ll_t, _lv_file_ll) \ - f(lv_ll_t, _lv_anim_ll) \ - f(lv_ll_t, _lv_group_ll) \ - f(lv_ll_t, _lv_img_defoder_ll) \ - f(lv_img_cache_entry_t*, _lv_img_cache_array) \ - f(void*, _lv_task_act) \ - f(void*, _lv_draw_buf) - -#define LV_DEFINE_ROOT(root_type, root_name) root_type root_name; -#define LV_ROOTS LV_ITERATE_ROOTS(LV_DEFINE_ROOT) - -#if LV_ENABLE_GC == 1 -#if LV_MEM_CUSTOM != 1 -#error "GC requires CUSTOM_MEM" -#endif /* LV_MEM_CUSTOM */ -#else /* LV_ENABLE_GC */ -#define LV_GC_ROOT(x) x -#define LV_EXTERN_ROOT(root_type, root_name) extern root_type root_name; -LV_ITERATE_ROOTS(LV_EXTERN_ROOT) -#endif /* LV_ENABLE_GC */ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * GLOBAL PROTOTYPES - **********************/ - -void lv_gc_clear_roots(void); - -/********************** - * MACROS - **********************/ - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /*LV_GC_H*/ diff --git a/src/libs/lvgl/src/lv_misc/lv_ll.c b/src/libs/lvgl/src/lv_misc/lv_ll.c deleted file mode 100644 index 99526659..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_ll.c +++ /dev/null @@ -1,422 +0,0 @@ -/** - * @file lv_ll.c - * Handle linked lists. - * The nodes are dynamically allocated by the 'lv_mem' module, - */ - -/********************* - * INCLUDES - *********************/ -#include <stdint.h> -#include <string.h> - -#include "lv_ll.h" -#include "lv_mem.h" - -/********************* - * DEFINES - *********************/ -#define LL_NODE_META_SIZE (sizeof(lv_ll_node_t *) + sizeof(lv_ll_node_t *)) -#define LL_PREV_P_OFFSET(ll_p) (ll_p->n_size) -#define LL_NEXT_P_OFFSET(ll_p) (ll_p->n_size + sizeof(lv_ll_node_t *)) - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ -static void node_set_prev(lv_ll_t * ll_p, lv_ll_node_t * act, lv_ll_node_t * prev); -static void node_set_next(lv_ll_t * ll_p, lv_ll_node_t * act, lv_ll_node_t * next); - -/********************** - * STATIC VARIABLES - **********************/ - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -/** - * Initialize linked list - * @param ll_dsc pointer to ll_dsc variable - * @param node_size the size of 1 node in bytes - */ -void lv_ll_init(lv_ll_t * ll_p, uint32_t node_size) -{ - ll_p->head = NULL; - ll_p->tail = NULL; -#ifdef LV_MEM_ENV64 - /*Round the size up to 8*/ - if(node_size & 0x7) { - node_size = node_size & (~0x7); - node_size += 8; - } -#else - /*Round the size up to 4*/ - if(node_size & 0x3) { - node_size = node_size & (~0x3); - node_size += 4; - } -#endif - - ll_p->n_size = 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) -{ - lv_ll_node_t * n_new; - - n_new = lv_mem_alloc(ll_p->n_size + LL_NODE_META_SIZE); - - if(n_new != NULL) { - node_set_prev(ll_p, n_new, NULL); /*No prev. before the new head*/ - node_set_next(ll_p, n_new, ll_p->head); /*After new comes the old head*/ - - if(ll_p->head != NULL) { /*If there is old head then before it goes the new*/ - node_set_prev(ll_p, ll_p->head, n_new); - } - - ll_p->head = n_new; /*Set the new head in the dsc.*/ - if(ll_p->tail == NULL) { /*If there is no tail (1. node) set the tail too*/ - ll_p->tail = n_new; - } - } - - return n_new; -} - -/** - * 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 head - */ -void * lv_ll_ins_prev(lv_ll_t * ll_p, void * n_act) -{ - lv_ll_node_t * n_new; - lv_ll_node_t * n_prev; - - if(NULL == ll_p || NULL == n_act) return NULL; - - if(lv_ll_get_head(ll_p) == n_act) { - n_new = lv_ll_ins_head(ll_p); - if(n_new == NULL) return NULL; - } else { - n_new = lv_mem_alloc(ll_p->n_size + LL_NODE_META_SIZE); - if(n_new == NULL) return NULL; - - n_prev = lv_ll_get_prev(ll_p, n_act); - node_set_next(ll_p, n_prev, n_new); - node_set_prev(ll_p, n_new, n_prev); - node_set_prev(ll_p, n_act, n_new); - node_set_next(ll_p, n_new, n_act); - } - - return n_new; -} - -/** - * 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) -{ - lv_ll_node_t * n_new; - - n_new = lv_mem_alloc(ll_p->n_size + LL_NODE_META_SIZE); - if(n_new == NULL) return NULL; - - if(n_new != NULL) { - node_set_next(ll_p, n_new, NULL); /*No next after the new tail*/ - node_set_prev(ll_p, n_new, ll_p->tail); /*The prev. before new is tho old tail*/ - if(ll_p->tail != NULL) { /*If there is old tail then the new comes after it*/ - node_set_next(ll_p, ll_p->tail, n_new); - } - - ll_p->tail = n_new; /*Set the new tail in the dsc.*/ - if(ll_p->head == NULL) { /*If there is no head (1. node) set the head too*/ - ll_p->head = n_new; - } - } - - return n_new; -} - -/** - * Remove the node 'node_p' from 'll_p' linked list. - * It does not free the 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_rem(lv_ll_t * ll_p, void * node_p) -{ - if(lv_ll_get_head(ll_p) == node_p) { - /*The new head will be the node after 'n_act'*/ - ll_p->head = lv_ll_get_next(ll_p, node_p); - if(ll_p->head == NULL) { - ll_p->tail = NULL; - } else { - node_set_prev(ll_p, ll_p->head, NULL); - } - } else if(lv_ll_get_tail(ll_p) == node_p) { - /*The new tail will be the node before 'n_act'*/ - ll_p->tail = lv_ll_get_prev(ll_p, node_p); - if(ll_p->tail == NULL) { - ll_p->head = NULL; - } else { - node_set_next(ll_p, ll_p->tail, NULL); - } - } else { - lv_ll_node_t * n_prev = lv_ll_get_prev(ll_p, node_p); - lv_ll_node_t * n_next = lv_ll_get_next(ll_p, node_p); - - node_set_next(ll_p, n_prev, n_next); - node_set_prev(ll_p, n_next, n_prev); - } -} - -/** - * 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) -{ - void * i; - void * i_next; - - i = lv_ll_get_head(ll_p); - i_next = NULL; - - while(i != NULL) { - i_next = lv_ll_get_next(ll_p, i); - - lv_ll_rem(ll_p, i); - lv_mem_free(i); - - i = i_next; - } -} - -/** - * 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 head 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) -{ - lv_ll_rem(ll_ori_p, node); - - if(head) { - /*Set node as head*/ - node_set_prev(ll_new_p, node, NULL); - node_set_next(ll_new_p, node, ll_new_p->head); - - if(ll_new_p->head != NULL) { /*If there is old head then before it goes the new*/ - node_set_prev(ll_new_p, ll_new_p->head, node); - } - - ll_new_p->head = node; /*Set the new head in the dsc.*/ - if(ll_new_p->tail == NULL) { /*If there is no tail (first node) set the tail too*/ - ll_new_p->tail = node; - } - } else { - /*Set node as tail*/ - node_set_prev(ll_new_p, node, ll_new_p->tail); - node_set_next(ll_new_p, node, NULL); - - if(ll_new_p->tail != NULL) { /*If there is old tail then after it goes the new*/ - node_set_next(ll_new_p, ll_new_p->tail, node); - } - - ll_new_p->tail = node; /*Set the new tail in the dsc.*/ - if(ll_new_p->head == NULL) { /*If there is no head (first node) set the head too*/ - ll_new_p->head = node; - } - } -} - -/** - * 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) -{ - void * head = NULL; - - if(ll_p != NULL) { - head = ll_p->head; - } - - return head; -} - -/** - * Return with tail node of the linked list - * @param ll_p pointer to linked list - * @return pointer to the head of 'll_p' - */ -void * lv_ll_get_tail(const lv_ll_t * ll_p) -{ - void * tail = NULL; - - if(ll_p != NULL) { - tail = ll_p->tail; - } - - return tail; -} - -/** - * 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) -{ - void * next = NULL; - - if(ll_p != NULL) { - const lv_ll_node_t * n_act_d = n_act; - memcpy(&next, n_act_d + LL_NEXT_P_OFFSET(ll_p), sizeof(void *)); - } - - return next; -} - -/** - * 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) -{ - void * prev = NULL; - - if(ll_p != NULL) { - const lv_ll_node_t * n_act_d = n_act; - memcpy(&prev, n_act_d + LL_PREV_P_OFFSET(ll_p), sizeof(void *)); - } - - return prev; -} - -/** - * 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) -{ - uint32_t len = 0; - void * node; - - for(node = lv_ll_get_head(ll_p); node != NULL; node = lv_ll_get_next(ll_p, node)) { - len++; - } - - return len; -} - -/** - * Move a nodw before an other 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) -{ - if(n_act == n_after) return; /*Can't move before itself*/ - - void * n_before; - if(n_after != NULL) - n_before = lv_ll_get_prev(ll_p, n_after); - else - n_before = lv_ll_get_tail(ll_p); /*if `n_after` is NULL `n_act` should be the new tail*/ - - if(n_act == n_before) return; /*Already before `n_after`*/ - - /*It's much easier to remove from the list and add again*/ - lv_ll_rem(ll_p, n_act); - - /*Add again by setting the prev. and next nodes*/ - node_set_next(ll_p, n_before, n_act); - node_set_prev(ll_p, n_act, n_before); - node_set_prev(ll_p, n_after, n_act); - node_set_next(ll_p, n_act, n_after); - - /*If `n_act` was moved before NULL then it become the new tail*/ - if(n_after == NULL) ll_p->tail = n_act; - - /*If `n_act` was moved before `NULL` then it's the new head*/ - if(n_before == NULL) ll_p->head = n_act; -} - -/** - * 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) -{ - if(ll_p == NULL) return true; - - if(ll_p->head == NULL && ll_p->tail == NULL) return true; - - return false; -} - -/********************** - * STATIC FUNCTIONS - **********************/ - -/** - * Set the 'pervious node pointer' of a node - * @param ll_p pointer to linked list - * @param act pointer to a node which prev. node pointer should be set - * @param prev pointer to a node which should be the previous node before 'act' - */ -static void node_set_prev(lv_ll_t * ll_p, lv_ll_node_t * act, lv_ll_node_t * prev) -{ - if(act == NULL) return; /*Can't set the prev node of `NULL`*/ - - uint32_t node_p_size = sizeof(lv_ll_node_t *); - if(prev) - memcpy(act + LL_PREV_P_OFFSET(ll_p), &prev, node_p_size); - else - memset(act + LL_PREV_P_OFFSET(ll_p), 0, node_p_size); -} - -/** - * Set the 'next node pointer' of a node - * @param ll_p pointer to linked list - * @param act pointer to a node which next node pointer should be set - * @param next pointer to a node which should be the next node before 'act' - */ -static void node_set_next(lv_ll_t * ll_p, lv_ll_node_t * act, lv_ll_node_t * next) -{ - if(act == NULL) return; /*Can't set the next node of `NULL`*/ - - uint32_t node_p_size = sizeof(lv_ll_node_t *); - if(next) - memcpy(act + LL_NEXT_P_OFFSET(ll_p), &next, node_p_size); - else - memset(act + LL_NEXT_P_OFFSET(ll_p), 0, node_p_size); -} diff --git a/src/libs/lvgl/src/lv_misc/lv_ll.h b/src/libs/lvgl/src/lv_misc/lv_ll.h deleted file mode 100644 index 2c02eb48..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_ll.h +++ /dev/null @@ -1,160 +0,0 @@ -/** - * @file lv_ll.c - * 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_mem.h" -#include <stdint.h> -#include <stddef.h> -#include <stdbool.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_dsc pointer to ll_dsc 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 head - */ -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 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_rem(lv_ll_t * ll_p, void * node_p); - -/** - * 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 head 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 head 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); - -/** - * Move a nodw before an other 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 diff --git a/src/libs/lvgl/src/lv_misc/lv_log.c b/src/libs/lvgl/src/lv_misc/lv_log.c deleted file mode 100644 index acbdfb73..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_log.c +++ /dev/null @@ -1,78 +0,0 @@ -/** - * @file lv_log.c - * - */ - -/********************* - * INCLUDES - *********************/ -#include "lv_log.h" -#if LV_USE_LOG - -#if LV_LOG_PRINTF -#include <stdio.h> -#endif - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -/********************** - * STATIC VARIABLES - **********************/ -static lv_log_print_g_cb_t custom_print_cb; - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -/** - * 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 consol 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) -{ - custom_print_cb = print_cb; -} - -/** - * 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 dsc description of the log - */ -void lv_log_add(lv_log_level_t level, const char * file, int line, const char * dsc) -{ - if(level >= _LV_LOG_LEVEL_NUM) return; /*Invalid level*/ - - if(level >= LV_LOG_LEVEL) { - -#if LV_LOG_PRINTF - static const char * lvl_prefix[] = {"Trace", "Info", "Warn", "Error"}; - printf("%s: %s \t(%s #%d)\n", lvl_prefix[level], dsc, file, line); -#else - if(custom_print_cb) custom_print_cb(level, file, line, dsc); -#endif - } -} - -/********************** - * STATIC FUNCTIONS - **********************/ - -#endif /*LV_USE_LOG*/ diff --git a/src/libs/lvgl/src/lv_misc/lv_log.h b/src/libs/lvgl/src/lv_misc/lv_log.h deleted file mode 100644 index 62c613b4..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_log.h +++ /dev/null @@ -1,144 +0,0 @@ -/** - * @file lv_log.h - * - */ - -#ifndef LV_LOG_H -#define LV_LOG_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ -#ifdef LV_CONF_INCLUDE_SIMPLE -#include "lv_conf.h" -#else -#include "../../../lv_conf.h" -#endif -#include <stdint.h> - -/********************* - * DEFINES - *********************/ - -/*Possible log level. For compatibility declare it independently from `LV_USE_LOG`*/ - -#define LV_LOG_LEVEL_TRACE 0 /**< A lot of logs to give detailed information*/ -#define LV_LOG_LEVEL_INFO 1 /**< Log important events*/ -#define LV_LOG_LEVEL_WARN 2 /**< Log if something unwanted happened but didn't caused problem*/ -#define LV_LOG_LEVEL_ERROR 3 /**< Only critical issue, when the system may fail*/ -#define LV_LOG_LEVEL_NONE 4 /**< Do not log anything*/ -#define _LV_LOG_LEVEL_NUM 5 /**< 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_NONE); - -typedef int8_t lv_log_level_t; - -#if LV_USE_LOG -/********************** - * TYPEDEFS - **********************/ - -/** - * Log print function. Receives "Log Level", "File path", "Line number" and "Description". - */ -typedef void (*lv_log_print_g_cb_t)(lv_log_level_t level, const char *, uint32_t, const char *); - -/********************** - * 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 consol 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); - -/** - * 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 dsc description of the log - */ -void lv_log_add(lv_log_level_t level, const char * file, int line, const char * dsc); - -/********************** - * MACROS - **********************/ - -#if LV_LOG_LEVEL <= LV_LOG_LEVEL_TRACE -#define LV_LOG_TRACE(dsc) lv_log_add(LV_LOG_LEVEL_TRACE, __FILE__, __LINE__, dsc); -#else -#define LV_LOG_TRACE(dsc) \ - { \ - ; \ - } -#endif - -#if LV_LOG_LEVEL <= LV_LOG_LEVEL_INFO -#define LV_LOG_INFO(dsc) lv_log_add(LV_LOG_LEVEL_INFO, __FILE__, __LINE__, dsc); -#else -#define LV_LOG_INFO(dsc) \ - { \ - ; \ - } -#endif - -#if LV_LOG_LEVEL <= LV_LOG_LEVEL_WARN -#define LV_LOG_WARN(dsc) lv_log_add(LV_LOG_LEVEL_WARN, __FILE__, __LINE__, dsc); -#else -#define LV_LOG_WARN(dsc) \ - { \ - ; \ - } -#endif - -#if LV_LOG_LEVEL <= LV_LOG_LEVEL_ERROR -#define LV_LOG_ERROR(dsc) lv_log_add(LV_LOG_LEVEL_ERROR, __FILE__, __LINE__, dsc); -#else -#define LV_LOG_ERROR(dsc) \ - { \ - ; \ - } -#endif - -#else /*LV_USE_LOG*/ - -/*Do nothing if `LV_USE_LOG 0`*/ -#define lv_log_add(level, file, line, dsc) \ - { \ - ; \ - } -#define LV_LOG_TRACE(dsc) \ - { \ - ; \ - } -#define LV_LOG_INFO(dsc) \ - { \ - ; \ - } -#define LV_LOG_WARN(dsc) \ - { \ - ; \ - } -#define LV_LOG_ERROR(dsc) \ - { \ - ; \ - } -#endif /*LV_USE_LOG*/ - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /*LV_LOG_H*/ diff --git a/src/libs/lvgl/src/lv_misc/lv_math.c b/src/libs/lvgl/src/lv_misc/lv_math.c deleted file mode 100644 index f015456e..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_math.c +++ /dev/null @@ -1,203 +0,0 @@ -/** - * @file lv_math.c - * - */ - -/********************* - * INCLUDES - *********************/ -#include "lv_math.h" -#include <stdbool.h> -#include <stdlib.h> - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -/********************** - * STATIC VARIABLES - **********************/ -static const int16_t sin0_90_table[] = { - 0, 572, 1144, 1715, 2286, 2856, 3425, 3993, 4560, 5126, 5690, 6252, 6813, 7371, 7927, 8481, - 9032, 9580, 10126, 10668, 11207, 11743, 12275, 12803, 13328, 13848, 14364, 14876, 15383, 15886, 16383, 16876, - 17364, 17846, 18323, 18794, 19260, 19720, 20173, 20621, 21062, 21497, 21925, 22347, 22762, 23170, 23571, 23964, - 24351, 24730, 25101, 25465, 25821, 26169, 26509, 26841, 27165, 27481, 27788, 28087, 28377, 28659, 28932, 29196, - 29451, 29697, 29934, 30162, 30381, 30591, 30791, 30982, 31163, 31335, 31498, 31650, 31794, 31927, 32051, 32165, - 32269, 32364, 32448, 32523, 32587, 32642, 32687, 32722, 32747, 32762, 32767}; - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -/** - * Return with sinus of an angle - * @param angle - * @return sinus of 'angle'. sin(-90) = -32767, sin(90) = 32767 - */ -int16_t lv_trigo_sin(int16_t angle) -{ - int16_t ret = 0; - angle = angle % 360; - - if(angle < 0) angle = 360 + angle; - - if(angle < 90) { - ret = sin0_90_table[angle]; - } else if(angle >= 90 && angle < 180) { - angle = 180 - angle; - ret = sin0_90_table[angle]; - } else if(angle >= 180 && angle < 270) { - angle = angle - 180; - ret = -sin0_90_table[angle]; - } else { /*angle >=270*/ - angle = 360 - angle; - ret = -sin0_90_table[angle]; - } - - return ret; -} - -/** - * Calculate a value of a Cubic Bezier function. - * @param t time in range of [0..LV_BEZIER_VAL_MAX] - * @param u0 start values in range of [0..LV_BEZIER_VAL_MAX] - * @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 end values in range of [0..LV_BEZIER_VAL_MAX] - * @return the value calculated from the given parameters in range of [0..LV_BEZIER_VAL_MAX] - */ -int32_t lv_bezier3(uint32_t t, int32_t u0, int32_t u1, int32_t u2, int32_t u3) -{ - uint32_t t_rem = 1024 - t; - uint32_t t_rem2 = (t_rem * t_rem) >> 10; - uint32_t t_rem3 = (t_rem2 * t_rem) >> 10; - uint32_t t2 = (t * t) >> 10; - uint32_t t3 = (t2 * t) >> 10; - - uint32_t v1 = ((uint32_t)t_rem3 * u0) >> 10; - uint32_t v2 = ((uint32_t)3 * t_rem2 * t * u1) >> 20; - uint32_t v3 = ((uint32_t)3 * t_rem * t2 * u2) >> 20; - uint32_t v4 = ((uint32_t)t3 * u3) >> 10; - - return v1 + v2 + v3 + v4; -} - -/** - * 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) -{ - // Fast XY vector to integer degree algorithm - Jan 2011 www.RomanBlack.com - // Converts any XY values including 0 to a degree value that should be - // within +/- 1 degree of the accurate value without needing - // large slow trig functions like ArcTan() or ArcCos(). - // NOTE! at least one of the X or Y values must be non-zero! - // This is the full version, for all 4 quadrants and will generate - // the angle in integer degrees from 0-360. - // Any values of X and Y are usable including negative values provided - // they are between -1456 and 1456 so the 16bit multiply does not overflow. - - unsigned char negflag; - unsigned char tempdegree; - unsigned char comp; - unsigned int degree; // this will hold the result - //signed int x; // these hold the XY vector at the start - //signed int y; // (and they will be destroyed) - unsigned int ux; - unsigned int uy; - - // Save the sign flags then remove signs and get XY as unsigned ints - negflag = 0; - if(x < 0) { - negflag += 0x01; // x flag bit - x = (0 - x); // is now + - } - ux = x; // copy to unsigned var before multiply - if(y < 0) { - negflag += 0x02; // y flag bit - y = (0 - y); // is now + - } - uy = y; // copy to unsigned var before multiply - - // 1. Calc the scaled "degrees" - if(ux > uy) { - degree = (uy * 45) / ux; // degree result will be 0-45 range - negflag += 0x10; // octant flag bit - } else { - degree = (ux * 45) / uy; // degree result will be 0-45 range - } - - // 2. Compensate for the 4 degree error curve - comp = 0; - tempdegree = degree; // use an unsigned char for speed! - if(tempdegree > 22) { // if top half of range - if(tempdegree <= 44) comp++; - if(tempdegree <= 41) comp++; - if(tempdegree <= 37) comp++; - if(tempdegree <= 32) comp++; // max is 4 degrees compensated - } else { // else is lower half of range - if(tempdegree >= 2) comp++; - if(tempdegree >= 6) comp++; - if(tempdegree >= 10) comp++; - if(tempdegree >= 15) comp++; // max is 4 degrees compensated - } - degree += comp; // degree is now accurate to +/- 1 degree! - - // Invert degree if it was X>Y octant, makes 0-45 into 90-45 - if(negflag & 0x10) degree = (90 - degree); - - // 3. Degree is now 0-90 range for this quadrant, - // need to invert it for whichever quadrant it was in - if(negflag & 0x02) { // if -Y - if(negflag & 0x01) // if -Y -X - degree = (180 + degree); - else // else is -Y +X - degree = (180 - degree); - } else { // else is +Y - if(negflag & 0x01) // if +Y -X - degree = (360 - degree); - } - return degree; -} - -/** - * Calculate the integer square root of a number. - * @param num - * @return square root of 'num' - */ -uint32_t lv_sqrt(uint32_t num) -{ - // http://www.codecodex.com/wiki/Calculate_an_integer_square_root#C - uint32_t root = 0; - uint32_t place = 0x40000000; - - while(place > num) place >>= 2; - while(place) { - if(num >= root + place) { - num -= root + place; - root += (place << 1); - } - root >>= 1; - place >>= 2; - } - return root; -} - -/********************** - * STATIC FUNCTIONS - **********************/ diff --git a/src/libs/lvgl/src/lv_misc/lv_math.h b/src/libs/lvgl/src/lv_misc/lv_math.h deleted file mode 100644 index 0f93a7c6..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_math.h +++ /dev/null @@ -1,85 +0,0 @@ -/** - * @file math_base.h - * - */ - -#ifndef LV_MATH_H -#define LV_MATH_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ -#include <stdint.h> - -/********************* - * DEFINES - *********************/ -#define LV_MATH_MIN(a, b) ((a) < (b) ? (a) : (b)) -#define LV_MATH_MAX(a, b) ((a) > (b) ? (a) : (b)) -#define LV_MATH_ABS(x) ((x) > 0 ? (x) : (-(x))) - -#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))) - -#define LV_TRIGO_SIN_MAX 32767 -#define LV_TRIGO_SHIFT 15 /**< >> LV_TRIGO_SHIFT to normalize*/ - -#define LV_BEZIER_VAL_MAX 1024 /**< Max time in Bezier functions (not [0..1] to use integers) */ -#define LV_BEZIER_VAL_SHIFT 10 /**< log2(LV_BEZIER_VAL_MAX): used to normalize up scaled values*/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * GLOBAL PROTOTYPES - **********************/ - -/** - * Return with sinus of an angle - * @param angle - * @return sinus of 'angle'. sin(-90) = -32767, sin(90) = 32767 - */ -int16_t lv_trigo_sin(int16_t angle); - -/** - * Calculate a value of a Cubic Bezier function. - * @param t time in range of [0..LV_BEZIER_VAL_MAX] - * @param u0 start values in range of [0..LV_BEZIER_VAL_MAX] - * @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 end values in range of [0..LV_BEZIER_VAL_MAX] - * @return the value calculated from the given parameters in range of [0..LV_BEZIER_VAL_MAX] - */ -int32_t lv_bezier3(uint32_t t, int32_t u0, int32_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); - -/** - * Calculate the integer square root of a number. - * @param num - * @return square root of 'num' - */ -uint32_t lv_sqrt(uint32_t num); - -/********************** - * MACROS - **********************/ - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif diff --git a/src/libs/lvgl/src/lv_misc/lv_mem.c b/src/libs/lvgl/src/lv_misc/lv_mem.c deleted file mode 100644 index 9e18310f..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_mem.c +++ /dev/null @@ -1,481 +0,0 @@ -/** - * @file lv_mem.c - * General and portable implementation of malloc and free. - * The dynamic memory monitoring is also supported. - */ - -/********************* - * INCLUDES - *********************/ -#include "lv_mem.h" -#include "lv_math.h" -#include <string.h> - -#if LV_MEM_CUSTOM != 0 -#include LV_MEM_CUSTOM_INCLUDE -#endif - -/********************* - * DEFINES - *********************/ -/*Add memory junk on alloc (0xaa) and free(0xbb) (just for testing purposes)*/ -#ifndef LV_MEM_ADD_JUNK -#define LV_MEM_ADD_JUNK 0 -#endif - -#ifdef LV_ARCH_64 -#define MEM_UNIT uint64_t -#else -#define MEM_UNIT uint32_t -#endif - -/********************** - * TYPEDEFS - **********************/ - -#if LV_ENABLE_GC == 0 /*gc custom allocations must not include header*/ - -/*The size of this union must be 4 bytes (uint32_t)*/ -typedef union -{ - struct - { - MEM_UNIT used : 1; /* 1: if the entry is used*/ - MEM_UNIT d_size : 31; /* Size off the data (1 means 4 bytes)*/ - } s; - MEM_UNIT header; /* The header (used + d_size)*/ -} lv_mem_header_t; - -typedef struct -{ - lv_mem_header_t header; - uint8_t first_data; /*First data byte in the allocated data (Just for easily create a pointer)*/ -} lv_mem_ent_t; - -#endif /* LV_ENABLE_GC */ - -/********************** - * STATIC PROTOTYPES - **********************/ -#if LV_MEM_CUSTOM == 0 -static lv_mem_ent_t * ent_get_next(lv_mem_ent_t * act_e); -static void * ent_alloc(lv_mem_ent_t * e, size_t size); -static void ent_trunc(lv_mem_ent_t * e, size_t size); -#endif - -/********************** - * STATIC VARIABLES - **********************/ -#if LV_MEM_CUSTOM == 0 -static uint8_t * work_mem; -#endif - -static uint32_t zero_mem; /*Give the address of this variable if 0 byte should be allocated*/ - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -/** - * Initiaiize the dyn_mem module (work memory and other variables) - */ -void lv_mem_init(void) -{ -#if LV_MEM_CUSTOM == 0 - -#if LV_MEM_ADR == 0 - /*Allocate a large array to store the dynamically allocated data*/ - static LV_MEM_ATTR MEM_UNIT work_mem_int[LV_MEM_SIZE / sizeof(MEM_UNIT)]; - work_mem = (uint8_t *)work_mem_int; -#else - work_mem = (uint8_t *)LV_MEM_ADR; -#endif - - lv_mem_ent_t * full = (lv_mem_ent_t *)work_mem; - full->header.s.used = 0; - /*The total mem size id reduced by the first header and the close patterns */ - full->header.s.d_size = LV_MEM_SIZE - sizeof(lv_mem_header_t); -#endif -} - -/** - * Clean up the memory buffer which frees all the allocated memories. - * @note It work only if `LV_MEM_CUSTOM == 0` - */ -void lv_mem_deinit(void) -{ -#if LV_MEM_CUSTOM == 0 - memset(work_mem, 0x00, (LV_MEM_SIZE / sizeof(MEM_UNIT)) * sizeof(MEM_UNIT)); - lv_mem_ent_t * full = (lv_mem_ent_t *)work_mem; - full->header.s.used = 0; - /*The total mem size id reduced by the first header and the close patterns */ - full->header.s.d_size = LV_MEM_SIZE - sizeof(lv_mem_header_t); -#endif -} - -/** - * Allocate a memory dynamically - * @param size size of the memory to allocate in bytes - * @return pointer to the allocated memory - */ -void * lv_mem_alloc(size_t size) -{ - if(size == 0) { - return &zero_mem; - } - -#ifdef LV_ARCH_64 - /*Round the size up to 8*/ - if(size & 0x7) { - size = size & (~0x7); - size += 8; - } -#else - /*Round the size up to 4*/ - if(size & 0x3) { - size = size & (~0x3); - size += 4; - } -#endif - void * alloc = NULL; - -#if LV_MEM_CUSTOM == 0 - /*Use the built-in allocators*/ - lv_mem_ent_t * e = NULL; - - /* Search for a appropriate entry*/ - do { - /* Get the next entry*/ - e = ent_get_next(e); - - /*If there is next entry then try to allocate there*/ - if(e != NULL) { - alloc = ent_alloc(e, size); - } - /* End if there is not next entry OR the alloc. is successful*/ - } while(e != NULL && alloc == NULL); - -#else -/*Use custom, user defined malloc function*/ -#if LV_ENABLE_GC == 1 /*gc must not include header*/ - alloc = LV_MEM_CUSTOM_ALLOC(size); -#else /* LV_ENABLE_GC */ - /*Allocate a header too to store the size*/ - alloc = LV_MEM_CUSTOM_ALLOC(size + sizeof(lv_mem_header_t)); - if(alloc != NULL) { - ((lv_mem_ent_t *)alloc)->header.s.d_size = size; - ((lv_mem_ent_t *)alloc)->header.s.used = 1; - - alloc = &((lv_mem_ent_t *)alloc)->first_data; - } -#endif /* LV_ENABLE_GC */ -#endif /* LV_MEM_CUSTOM */ - -#if LV_MEM_ADD_JUNK - if(alloc != NULL) memset(alloc, 0xaa, size); -#endif - - if(alloc == NULL) LV_LOG_WARN("Couldn't allocate memory"); - - return alloc; -} - -/** - * Free an allocated data - * @param data pointer to an allocated memory - */ -void lv_mem_free(const void * data) -{ - if(data == &zero_mem) return; - if(data == NULL) return; - -#if LV_MEM_ADD_JUNK - memset((void *)data, 0xbb, lv_mem_get_size(data)); -#endif - -#if LV_ENABLE_GC == 0 - /*e points to the header*/ - lv_mem_ent_t * e = (lv_mem_ent_t *)((uint8_t *)data - sizeof(lv_mem_header_t)); - e->header.s.used = 0; -#endif - -#if LV_MEM_CUSTOM == 0 -#if LV_MEM_AUTO_DEFRAG - /* Make a simple defrag. - * Join the following free entries after this*/ - lv_mem_ent_t * e_next; - e_next = ent_get_next(e); - while(e_next != NULL) { - if(e_next->header.s.used == 0) { - e->header.s.d_size += e_next->header.s.d_size + sizeof(e->header); - } else { - break; - } - e_next = ent_get_next(e_next); - } -#endif -#else /*Use custom, user defined free function*/ -#if LV_ENABLE_GC == 0 - LV_MEM_CUSTOM_FREE(e); -#else - LV_MEM_CUSTOM_FREE((void *)data); -#endif /*LV_ENABLE_GC*/ -#endif -} - -/** - * Reallocate a memory with a new size. The old content will be kept. - * @param data pointer to an allocated memory. - * Its content will be copied to the new memory block and freed - * @param new_size the desired new size in byte - * @return pointer to the new memory - */ - -#if LV_ENABLE_GC == 0 - -void * lv_mem_realloc(void * data_p, size_t new_size) -{ - /*data_p could be previously freed pointer (in this case it is invalid)*/ - if(data_p != NULL) { - lv_mem_ent_t * e = (lv_mem_ent_t *)((uint8_t *)data_p - sizeof(lv_mem_header_t)); - if(e->header.s.used == 0) { - data_p = NULL; - } - } - - uint32_t old_size = lv_mem_get_size(data_p); - if(old_size == new_size) return data_p; /*Also avoid reallocating the same memory*/ - -#if LV_MEM_CUSTOM == 0 - /* Truncate the memory if the new size is smaller. */ - if(new_size < old_size) { - lv_mem_ent_t * e = (lv_mem_ent_t *)((uint8_t *)data_p - sizeof(lv_mem_header_t)); - ent_trunc(e, new_size); - return &e->first_data; - } -#endif - - void * new_p; - new_p = lv_mem_alloc(new_size); - - if(new_p != NULL && data_p != NULL) { - /*Copy the old data to the new. Use the smaller size*/ - if(old_size != 0) { - memcpy(new_p, data_p, LV_MATH_MIN(new_size, old_size)); - lv_mem_free(data_p); - } - } - - if(new_p == NULL) LV_LOG_WARN("Couldn't allocate memory"); - - return new_p; -} - -#else /* LV_ENABLE_GC */ - -void * lv_mem_realloc(void * data_p, size_t new_size) -{ - void * new_p = LV_MEM_CUSTOM_REALLOC(data_p, new_size); - if(new_p == NULL) LV_LOG_WARN("Couldn't allocate memory"); - return new_p; -} - -#endif /* lv_enable_gc */ - -/** - * Join the adjacent free memory blocks - */ -void lv_mem_defrag(void) -{ -#if LV_MEM_CUSTOM == 0 - lv_mem_ent_t * e_free; - lv_mem_ent_t * e_next; - e_free = ent_get_next(NULL); - - while(1) { - /*Search the next free entry*/ - while(e_free != NULL) { - if(e_free->header.s.used != 0) { - e_free = ent_get_next(e_free); - } else { - break; - } - } - - if(e_free == NULL) return; - - /*Joint the following free entries to the free*/ - e_next = ent_get_next(e_free); - while(e_next != NULL) { - if(e_next->header.s.used == 0) { - e_free->header.s.d_size += e_next->header.s.d_size + sizeof(e_next->header); - } else { - break; - } - - e_next = ent_get_next(e_next); - } - - if(e_next == NULL) return; - - /*Continue from the lastly checked entry*/ - e_free = e_next; - } -#endif -} - -/** - * Give information about the work memory of dynamic allocation - * @param mon_p pointer to a dm_mon_p variable, - * the result of the analysis will be stored here - */ -void lv_mem_monitor(lv_mem_monitor_t * mon_p) -{ - /*Init the data*/ - memset(mon_p, 0, sizeof(lv_mem_monitor_t)); -#if LV_MEM_CUSTOM == 0 - lv_mem_ent_t * e; - e = NULL; - - e = ent_get_next(e); - - while(e != NULL) { - if(e->header.s.used == 0) { - mon_p->free_cnt++; - mon_p->free_size += e->header.s.d_size; - if(e->header.s.d_size > mon_p->free_biggest_size) { - mon_p->free_biggest_size = e->header.s.d_size; - } - } else { - mon_p->used_cnt++; - } - - e = ent_get_next(e); - } - mon_p->total_size = LV_MEM_SIZE; - mon_p->used_pct = 100 - (100U * mon_p->free_size) / mon_p->total_size; - mon_p->frag_pct = (uint32_t)mon_p->free_biggest_size * 100U / mon_p->free_size; - mon_p->frag_pct = 100 - mon_p->frag_pct; -#endif -} - -/** - * Give the size of an allocated memory - * @param data pointer to an allocated memory - * @return the size of data memory in bytes - */ - -#if LV_ENABLE_GC == 0 - -uint32_t lv_mem_get_size(const void * data) -{ - if(data == NULL) return 0; - if(data == &zero_mem) return 0; - - lv_mem_ent_t * e = (lv_mem_ent_t *)((uint8_t *)data - sizeof(lv_mem_header_t)); - - return e->header.s.d_size; -} - -#else /* LV_ENABLE_GC */ - -uint32_t lv_mem_get_size(const void * data) -{ - return LV_MEM_CUSTOM_GET_SIZE(data); -} - -#endif /*LV_ENABLE_GC*/ - -/********************** - * STATIC FUNCTIONS - **********************/ - -#if LV_MEM_CUSTOM == 0 -/** - * Give the next entry after 'act_e' - * @param act_e pointer to an entry - * @return pointer to an entry after 'act_e' - */ -static lv_mem_ent_t * ent_get_next(lv_mem_ent_t * act_e) -{ - lv_mem_ent_t * next_e = NULL; - - if(act_e == NULL) { /*NULL means: get the first entry*/ - next_e = (lv_mem_ent_t *)work_mem; - } else { /*Get the next entry */ - uint8_t * data = &act_e->first_data; - next_e = (lv_mem_ent_t *)&data[act_e->header.s.d_size]; - - if(&next_e->first_data >= &work_mem[LV_MEM_SIZE]) next_e = NULL; - } - - return next_e; -} - -/** - * Try to do the real allocation with a given size - * @param e try to allocate to this entry - * @param size size of the new memory in bytes - * @return pointer to the allocated memory or NULL if not enough memory in the entry - */ -static void * ent_alloc(lv_mem_ent_t * e, size_t size) -{ - void * alloc = NULL; - - /*If the memory is free and big enough then use it */ - if(e->header.s.used == 0 && e->header.s.d_size >= size) { - /*Truncate the entry to the desired size */ - ent_trunc(e, size), - - e->header.s.used = 1; - - /*Save the allocated data*/ - alloc = &e->first_data; - } - - return alloc; -} - -/** - * Truncate the data of entry to the given size - * @param e Pointer to an entry - * @param size new size in bytes - */ -static void ent_trunc(lv_mem_ent_t * e, size_t size) -{ -#ifdef LV_ARCH_64 - /*Round the size up to 8*/ - if(size & 0x7) { - size = size & (~0x7); - size += 8; - } -#else - /*Round the size up to 4*/ - if(size & 0x3) { - size = size & (~0x3); - size += 4; - } -#endif - - /*Don't let empty space only for a header without data*/ - if(e->header.s.d_size == size + sizeof(lv_mem_header_t)) { - size = e->header.s.d_size; - } - - /* Create the new entry after the current if there is space for it */ - if(e->header.s.d_size != size) { - uint8_t * e_data = &e->first_data; - lv_mem_ent_t * after_new_e = (lv_mem_ent_t *)&e_data[size]; - after_new_e->header.s.used = 0; - after_new_e->header.s.d_size = (uint32_t)e->header.s.d_size - size - sizeof(lv_mem_header_t); - } - - /* Set the new size for the original entry */ - e->header.s.d_size = (uint32_t)size; -} - -#endif diff --git a/src/libs/lvgl/src/lv_misc/lv_mem.h b/src/libs/lvgl/src/lv_misc/lv_mem.h deleted file mode 100644 index f7240742..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_mem.h +++ /dev/null @@ -1,113 +0,0 @@ -/** - * @file lv_mem.h - * - */ - -#ifndef LV_MEM_H -#define LV_MEM_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ -#ifdef LV_CONF_INCLUDE_SIMPLE -#include "lv_conf.h" -#else -#include "../../../lv_conf.h" -#endif - -#include <stdint.h> -#include <stddef.h> -#include "lv_log.h" -#include "lv_types.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/** - * Heap information structure. - */ -typedef struct -{ - uint32_t total_size; /**< Total heap size */ - uint32_t free_cnt; - uint32_t free_size; /**< Size of available memory */ - uint32_t free_biggest_size; - uint32_t used_cnt; - uint8_t used_pct; /**< Percentage used */ - uint8_t frag_pct; /**< Amount of fragmentation */ -} lv_mem_monitor_t; - -/********************** - * GLOBAL PROTOTYPES - **********************/ - -/** - * Initiaize the dyn_mem module (work memory and other variables) - */ -void lv_mem_init(void); - -/** - * Clean up the memory buffer which frees all the allocated memories. - * @note It work only if `LV_MEM_CUSTOM == 0` - */ -void lv_mem_deinit(void); - -/** - * Allocate a memory dynamically - * @param size size of the memory to allocate in bytes - * @return pointer to the allocated memory - */ -void * lv_mem_alloc(size_t size); - -/** - * Free an allocated data - * @param data pointer to an allocated memory - */ -void lv_mem_free(const void * data); - -/** - * Reallocate a memory with a new size. The old content will be kept. - * @param data pointer to an allocated memory. - * Its content will be copied to the new memory block and freed - * @param new_size the desired new size in byte - * @return pointer to the new memory - */ -void * lv_mem_realloc(void * data_p, size_t new_size); - -/** - * Join the adjacent free memory blocks - */ -void lv_mem_defrag(void); - -/** - * Give information about the work memory of dynamic allocation - * @param mon_p pointer to a dm_mon_p variable, - * the result of the analysis will be stored here - */ -void lv_mem_monitor(lv_mem_monitor_t * mon_p); - -/** - * Give the size of an allocated memory - * @param data pointer to an allocated memory - * @return the size of data memory in bytes - */ -uint32_t lv_mem_get_size(const void * data); - -/********************** - * MACROS - **********************/ - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /*LV_MEM_H*/ diff --git a/src/libs/lvgl/src/lv_misc/lv_misc.mk b/src/libs/lvgl/src/lv_misc/lv_misc.mk deleted file mode 100644 index 67f496ba..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_misc.mk +++ /dev/null @@ -1,22 +0,0 @@ -CSRCS += lv_circ.c -CSRCS += lv_area.c -CSRCS += lv_task.c -CSRCS += lv_fs.c -CSRCS += lv_anim.c -CSRCS += lv_mem.c -CSRCS += lv_ll.c -CSRCS += lv_color.c -CSRCS += lv_txt.c -CSRCS += lv_math.c -CSRCS += lv_log.c -CSRCS += lv_gc.c -CSRCS += lv_utils.c -CSRCS += lv_async.c -CSRCS += lv_printf.c -CSRCS += lv_bidi.c - - -DEPPATH += --dep-path $(LVGL_DIR)/lvgl/src/lv_misc -VPATH += :$(LVGL_DIR)/lvgl/src/lv_misc - -CFLAGS += "-I$(LVGL_DIR)/lvgl/src/lv_misc" diff --git a/src/libs/lvgl/src/lv_misc/lv_printf.c b/src/libs/lvgl/src/lv_misc/lv_printf.c deleted file mode 100644 index e05f35be..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_printf.c +++ /dev/null @@ -1,852 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// \author (c) Marco Paland (info@paland.com) -// 2014-2019, PALANDesign Hannover, Germany -// -// \license The MIT License (MIT) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// -// \brief Tiny printf, sprintf and (v)snprintf implementation, optimized for speed on -// embedded systems with a very limited resources. These routines are thread -// safe and reentrant! -// Use this instead of the bloated standard/newlib printf cause these use -// malloc for printf (and may not be thread safe). -// -/////////////////////////////////////////////////////////////////////////////// - -#include "lv_printf.h" - -#if LV_SPRINTF_CUSTOM == 0 - -#include <stdbool.h> -#include <stdint.h> - - -// 'ntoa' conversion buffer size, this must be big enough to hold one converted -// numeric number including padded zeros (dynamically created on stack) -// default: 32 byte -#ifndef PRINTF_NTOA_BUFFER_SIZE -#define PRINTF_NTOA_BUFFER_SIZE 32U -#endif - -// 'ftoa' conversion buffer size, this must be big enough to hold one converted -// float number including padded zeros (dynamically created on stack) -// default: 32 byte -#ifndef PRINTF_FTOA_BUFFER_SIZE -#define PRINTF_FTOA_BUFFER_SIZE 32U -#endif - -// support for the floating point type (%f) -// default: activated -#ifndef PRINTF_DISABLE_SUPPORT_FLOAT -#define PRINTF_SUPPORT_FLOAT -#endif - -// support for exponential floating point notation (%e/%g) -// default: activated -#ifndef PRINTF_DISABLE_SUPPORT_EXPONENTIAL -#define PRINTF_SUPPORT_EXPONENTIAL -#endif - -// define the default floating point precision -// default: 6 digits -#ifndef PRINTF_DEFAULT_FLOAT_PRECISION -#define PRINTF_DEFAULT_FLOAT_PRECISION 6U -#endif - -// define the largest float suitable to print with %f -// default: 1e9 -#ifndef PRINTF_MAX_FLOAT -#define PRINTF_MAX_FLOAT 1e9 -#endif - -// support for the long long types (%llu or %p) -// default: activated -#ifndef PRINTF_DISABLE_SUPPORT_LONG_LONG -#define PRINTF_SUPPORT_LONG_LONG -#endif - -// support for the ptrdiff_t type (%t) -// ptrdiff_t is normally defined in <stddef.h> as long or long long type -// default: activated -#ifndef PRINTF_DISABLE_SUPPORT_PTRDIFF_T -#define PRINTF_SUPPORT_PTRDIFF_T -#endif - -/////////////////////////////////////////////////////////////////////////////// - -// internal flag definitions -#define FLAGS_ZEROPAD (1U << 0U) -#define FLAGS_LEFT (1U << 1U) -#define FLAGS_PLUS (1U << 2U) -#define FLAGS_SPACE (1U << 3U) -#define FLAGS_HASH (1U << 4U) -#define FLAGS_UPPERCASE (1U << 5U) -#define FLAGS_CHAR (1U << 6U) -#define FLAGS_SHORT (1U << 7U) -#define FLAGS_LONG (1U << 8U) -#define FLAGS_LONG_LONG (1U << 9U) -#define FLAGS_PRECISION (1U << 10U) -#define FLAGS_ADAPT_EXP (1U << 11U) - - -// import float.h for DBL_MAX -#if defined(PRINTF_SUPPORT_FLOAT) -#include <float.h> -#endif - - -// output function type -typedef void (*out_fct_type)(char character, void* buffer, size_t idx, size_t maxlen); - - -// wrapper (used as buffer) for output function type -typedef struct { - void (*fct)(char character, void* arg); - void* arg; -} out_fct_wrap_type; - - -// internal buffer output -static inline void _out_buffer(char character, void* buffer, size_t idx, size_t maxlen) -{ - if (idx < maxlen) { - ((char*)buffer)[idx] = character; - } -} - - -// internal null output -static inline void _out_null(char character, void* buffer, size_t idx, size_t maxlen) -{ - (void)character; (void)buffer; (void)idx; (void)maxlen; -} - - - -// internal secure strlen -// \return The length of the string (excluding the terminating 0) limited by 'maxsize' -static inline unsigned int _strnlen_s(const char* str, size_t maxsize) -{ - const char* s; - for (s = str; *s && maxsize--; ++s); - return (unsigned int)(s - str); -} - - -// internal test if char is a digit (0-9) -// \return true if char is a digit -static inline bool _is_digit(char ch) -{ - return (ch >= '0') && (ch <= '9'); -} - - -// internal ASCII string to unsigned int conversion -static unsigned int _atoi(const char** str) -{ - unsigned int i = 0U; - while (_is_digit(**str)) { - i = i * 10U + (unsigned int)(*((*str)++) - '0'); - } - return i; -} - - -// output the specified string in reverse, taking care of any zero-padding -static size_t _out_rev(out_fct_type out, char* buffer, size_t idx, size_t maxlen, const char* buf, size_t len, unsigned int width, unsigned int flags) -{ - const size_t start_idx = idx; - - // pad spaces up to given width - if (!(flags & FLAGS_LEFT) && !(flags & FLAGS_ZEROPAD)) { - size_t i; - for (i = len; i < width; i++) { - out(' ', buffer, idx++, maxlen); - } - } - - // reverse string - while (len) { - out(buf[--len], buffer, idx++, maxlen); - } - - // append pad spaces up to given width - if (flags & FLAGS_LEFT) { - while (idx - start_idx < width) { - out(' ', buffer, idx++, maxlen); - } - } - - return idx; -} - - -// internal itoa format -static size_t _ntoa_format(out_fct_type out, char* buffer, size_t idx, size_t maxlen, char* buf, size_t len, bool negative, unsigned int base, unsigned int prec, unsigned int width, unsigned int flags) -{ - // pad leading zeros - if (!(flags & FLAGS_LEFT)) { - if (width && (flags & FLAGS_ZEROPAD) && (negative || (flags & (FLAGS_PLUS | FLAGS_SPACE)))) { - width--; - } - while ((len < prec) && (len < PRINTF_NTOA_BUFFER_SIZE)) { - buf[len++] = '0'; - } - while ((flags & FLAGS_ZEROPAD) && (len < width) && (len < PRINTF_NTOA_BUFFER_SIZE)) { - buf[len++] = '0'; - } - } - - // handle hash - if (flags & FLAGS_HASH) { - if (!(flags & FLAGS_PRECISION) && len && ((len == prec) || (len == width))) { - len--; - if (len && (base == 16U)) { - len--; - } - } - if ((base == 16U) && !(flags & FLAGS_UPPERCASE) && (len < PRINTF_NTOA_BUFFER_SIZE)) { - buf[len++] = 'x'; - } - else if ((base == 16U) && (flags & FLAGS_UPPERCASE) && (len < PRINTF_NTOA_BUFFER_SIZE)) { - buf[len++] = 'X'; - } - else if ((base == 2U) && (len < PRINTF_NTOA_BUFFER_SIZE)) { - buf[len++] = 'b'; - } - if (len < PRINTF_NTOA_BUFFER_SIZE) { - buf[len++] = '0'; - } - } - - if (len < PRINTF_NTOA_BUFFER_SIZE) { - if (negative) { - buf[len++] = '-'; - } - else if (flags & FLAGS_PLUS) { - buf[len++] = '+'; // ignore the space if the '+' exists - } - else if (flags & FLAGS_SPACE) { - buf[len++] = ' '; - } - } - - return _out_rev(out, buffer, idx, maxlen, buf, len, width, flags); -} - - -// internal itoa for 'long' type -static size_t _ntoa_long(out_fct_type out, char* buffer, size_t idx, size_t maxlen, unsigned long value, bool negative, unsigned long base, unsigned int prec, unsigned int width, unsigned int flags) -{ - char buf[PRINTF_NTOA_BUFFER_SIZE]; - size_t len = 0U; - - // no hash for 0 values - if (!value) { - flags &= ~FLAGS_HASH; - } - - // write if precision != 0 and value is != 0 - if (!(flags & FLAGS_PRECISION) || value) { - do { - const char digit = (char)(value % base); - buf[len++] = digit < 10 ? '0' + digit : (flags & FLAGS_UPPERCASE ? 'A' : 'a') + digit - 10; - value /= base; - } while (value && (len < PRINTF_NTOA_BUFFER_SIZE)); - } - - return _ntoa_format(out, buffer, idx, maxlen, buf, len, negative, (unsigned int)base, prec, width, flags); -} - - -// internal itoa for 'long long' type -#if defined(PRINTF_SUPPORT_LONG_LONG) -static size_t _ntoa_long_long(out_fct_type out, char* buffer, size_t idx, size_t maxlen, unsigned long long value, bool negative, unsigned long long base, unsigned int prec, unsigned int width, unsigned int flags) -{ - char buf[PRINTF_NTOA_BUFFER_SIZE]; - size_t len = 0U; - - // no hash for 0 values - if (!value) { - flags &= ~FLAGS_HASH; - } - - // write if precision != 0 and value is != 0 - if (!(flags & FLAGS_PRECISION) || value) { - do { - const char digit = (char)(value % base); - buf[len++] = digit < 10 ? '0' + digit : (flags & FLAGS_UPPERCASE ? 'A' : 'a') + digit - 10; - value /= base; - } while (value && (len < PRINTF_NTOA_BUFFER_SIZE)); - } - - return _ntoa_format(out, buffer, idx, maxlen, buf, len, negative, (unsigned int)base, prec, width, flags); -} -#endif // PRINTF_SUPPORT_LONG_LONG - - -#if defined(PRINTF_SUPPORT_FLOAT) - -#if defined(PRINTF_SUPPORT_EXPONENTIAL) -// forward declaration so that _ftoa can switch to exp notation for values > PRINTF_MAX_FLOAT -static size_t _etoa(out_fct_type out, char* buffer, size_t idx, size_t maxlen, double value, unsigned int prec, unsigned int width, unsigned int flags); -#endif - - -// internal ftoa for fixed decimal floating point -static size_t _ftoa(out_fct_type out, char* buffer, size_t idx, size_t maxlen, double value, unsigned int prec, unsigned int width, unsigned int flags) -{ - char buf[PRINTF_FTOA_BUFFER_SIZE]; - size_t len = 0U; - double diff = 0.0; - - // powers of 10 - static const double pow10[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 }; - - // test for special values - if (value != value) - return _out_rev(out, buffer, idx, maxlen, "nan", 3, width, flags); - if (value < -DBL_MAX) - return _out_rev(out, buffer, idx, maxlen, "fni-", 4, width, flags); - if (value > DBL_MAX) - return _out_rev(out, buffer, idx, maxlen, (flags & FLAGS_PLUS) ? "fni+" : "fni", (flags & FLAGS_PLUS) ? 4U : 3U, width, flags); - - // test for very large values - // standard printf behavior is to print EVERY whole number digit -- which could be 100s of characters overflowing your buffers == bad - if ((value > PRINTF_MAX_FLOAT) || (value < -PRINTF_MAX_FLOAT)) { -#if defined(PRINTF_SUPPORT_EXPONENTIAL) - return _etoa(out, buffer, idx, maxlen, value, prec, width, flags); -#else - return 0U; -#endif - } - - // test for negative - bool negative = false; - if (value < 0) { - negative = true; - value = 0 - value; - } - - // set default precision, if not set explicitly - if (!(flags & FLAGS_PRECISION)) { - prec = PRINTF_DEFAULT_FLOAT_PRECISION; - } - // limit precision to 9, cause a prec >= 10 can lead to overflow errors - while ((len < PRINTF_FTOA_BUFFER_SIZE) && (prec > 9U)) { - buf[len++] = '0'; - prec--; - } - - int whole = (int)value; - double tmp = (value - whole) * pow10[prec]; - unsigned long frac = (unsigned long)tmp; - diff = tmp - frac; - - if (diff > 0.5) { - ++frac; - // handle rollover, e.g. case 0.99 with prec 1 is 1.0 - if (frac >= pow10[prec]) { - frac = 0; - ++whole; - } - } - else if (diff < 0.5) { - } - else if ((frac == 0U) || (frac & 1U)) { - // if halfway, round up if odd OR if last digit is 0 - ++frac; - } - - if (prec == 0U) { - diff = value - (double)whole; - if ((!(diff < 0.5) || (diff > 0.5)) && (whole & 1)) { - // exactly 0.5 and ODD, then round up - // 1.5 -> 2, but 2.5 -> 2 - ++whole; - } - } - else { - unsigned int count = prec; - // now do fractional part, as an unsigned number - while (len < PRINTF_FTOA_BUFFER_SIZE) { - --count; - buf[len++] = (char)(48U + (frac % 10U)); - if (!(frac /= 10U)) { - break; - } - } - // add extra 0s - while ((len < PRINTF_FTOA_BUFFER_SIZE) && (count-- > 0U)) { - buf[len++] = '0'; - } - if (len < PRINTF_FTOA_BUFFER_SIZE) { - // add decimal - buf[len++] = '.'; - } - } - - // do whole part, number is reversed - while (len < PRINTF_FTOA_BUFFER_SIZE) { - buf[len++] = (char)(48 + (whole % 10)); - if (!(whole /= 10)) { - break; - } - } - - // pad leading zeros - if (!(flags & FLAGS_LEFT) && (flags & FLAGS_ZEROPAD)) { - if (width && (negative || (flags & (FLAGS_PLUS | FLAGS_SPACE)))) { - width--; - } - while ((len < width) && (len < PRINTF_FTOA_BUFFER_SIZE)) { - buf[len++] = '0'; - } - } - - if (len < PRINTF_FTOA_BUFFER_SIZE) { - if (negative) { - buf[len++] = '-'; - } - else if (flags & FLAGS_PLUS) { - buf[len++] = '+'; // ignore the space if the '+' exists - } - else if (flags & FLAGS_SPACE) { - buf[len++] = ' '; - } - } - - return _out_rev(out, buffer, idx, maxlen, buf, len, width, flags); -} - - -#if defined(PRINTF_SUPPORT_EXPONENTIAL) -// internal ftoa variant for exponential floating-point type, contributed by Martijn Jasperse <m.jasperse@gmail.com> -static size_t _etoa(out_fct_type out, char* buffer, size_t idx, size_t maxlen, double value, unsigned int prec, unsigned int width, unsigned int flags) -{ - // check for NaN and special values - if ((value != value) || (value > DBL_MAX) || (value < -DBL_MAX)) { - return _ftoa(out, buffer, idx, maxlen, value, prec, width, flags); - } - - // determine the sign - const bool negative = value < 0; - if (negative) { - value = -value; - } - - // default precision - if (!(flags & FLAGS_PRECISION)) { - prec = PRINTF_DEFAULT_FLOAT_PRECISION; - } - - // determine the decimal exponent - // based on the algorithm by David Gay (https://www.ampl.com/netlib/fp/dtoa.c) - union { - uint64_t U; - double F; - } conv; - - conv.F = value; - int exp2 = (int)((conv.U >> 52U) & 0x07FFU) - 1023; // effectively log2 - conv.U = (conv.U & ((1ULL << 52U) - 1U)) | (1023ULL << 52U); // drop the exponent so conv.F is now in [1,2) - // now approximate log10 from the log2 integer part and an expansion of ln around 1.5 - int expval = (int)(0.1760912590558 + exp2 * 0.301029995663981 + (conv.F - 1.5) * 0.289529654602168); - // now we want to compute 10^expval but we want to be sure it won't overflow - exp2 = (int)(expval * 3.321928094887362 + 0.5); - const double z = expval * 2.302585092994046 - exp2 * 0.6931471805599453; - const double z2 = z * z; - conv.U = (uint64_t)(exp2 + 1023) << 52U; - // compute exp(z) using continued fractions, see https://en.wikipedia.org/wiki/Exponential_function#Continued_fractions_for_ex - conv.F *= 1 + 2 * z / (2 - z + (z2 / (6 + (z2 / (10 + z2 / 14))))); - // correct for rounding errors - if (value < conv.F) { - expval--; - conv.F /= 10; - } - - // the exponent format is "%+03d" and largest value is "307", so set aside 4-5 characters - unsigned int minwidth = ((expval < 100) && (expval > -100)) ? 4U : 5U; - - // in "%g" mode, "prec" is the number of *significant figures* not decimals - if (flags & FLAGS_ADAPT_EXP) { - // do we want to fall-back to "%f" mode? - if ((value >= 1e-4) && (value < 1e6)) { - if ((int)prec > expval) { - prec = (unsigned)((int)prec - expval - 1); - } - else { - prec = 0; - } - flags |= FLAGS_PRECISION; // make sure _ftoa respects precision - // no characters in exponent - minwidth = 0U; - expval = 0; - } - else { - // we use one sigfig for the whole part - if ((prec > 0) && (flags & FLAGS_PRECISION)) { - --prec; - } - } - } - - // will everything fit? - unsigned int fwidth = width; - if (width > minwidth) { - // we didn't fall-back so subtract the characters required for the exponent - fwidth -= minwidth; - } else { - // not enough characters, so go back to default sizing - fwidth = 0U; - } - if ((flags & FLAGS_LEFT) && minwidth) { - // if we're padding on the right, DON'T pad the floating part - fwidth = 0U; - } - - // rescale the float value - if (expval) { - value /= conv.F; - } - - // output the floating part - const size_t start_idx = idx; - idx = _ftoa(out, buffer, idx, maxlen, negative ? -value : value, prec, fwidth, flags & ~FLAGS_ADAPT_EXP); - - // output the exponent part - if (minwidth) { - // output the exponential symbol - out((flags & FLAGS_UPPERCASE) ? 'E' : 'e', buffer, idx++, maxlen); - // output the exponent value - idx = _ntoa_long(out, buffer, idx, maxlen, (expval < 0) ? -expval : expval, expval < 0, 10, 0, minwidth-1, FLAGS_ZEROPAD | FLAGS_PLUS); - // might need to right-pad spaces - if (flags & FLAGS_LEFT) { - while (idx - start_idx < width) out(' ', buffer, idx++, maxlen); - } - } - return idx; -} -#endif // PRINTF_SUPPORT_EXPONENTIAL -#endif // PRINTF_SUPPORT_FLOAT - - -// internal vsnprintf -static int _vsnprintf(out_fct_type out, char* buffer, const size_t maxlen, const char* format, va_list va) -{ - unsigned int flags, width, precision, n; - size_t idx = 0U; - - if (!buffer) { - // use null output function - out = _out_null; - } - - while (*format) - { - // format specifier? %[flags][width][.precision][length] - if (*format != '%') { - // no - out(*format, buffer, idx++, maxlen); - format++; - continue; - } - else { - // yes, evaluate it - format++; - } - - // evaluate flags - flags = 0U; - do { - switch (*format) { - case '0': flags |= FLAGS_ZEROPAD; format++; n = 1U; break; - case '-': flags |= FLAGS_LEFT; format++; n = 1U; break; - case '+': flags |= FLAGS_PLUS; format++; n = 1U; break; - case ' ': flags |= FLAGS_SPACE; format++; n = 1U; break; - case '#': flags |= FLAGS_HASH; format++; n = 1U; break; - default : n = 0U; break; - } - } while (n); - - // evaluate width field - width = 0U; - if (_is_digit(*format)) { - width = _atoi(&format); - } - else if (*format == '*') { - const int w = va_arg(va, int); - if (w < 0) { - flags |= FLAGS_LEFT; // reverse padding - width = (unsigned int)-w; - } - else { - width = (unsigned int)w; - } - format++; - } - - // evaluate precision field - precision = 0U; - if (*format == '.') { - flags |= FLAGS_PRECISION; - format++; - if (_is_digit(*format)) { - precision = _atoi(&format); - } - else if (*format == '*') { - const int prec = (int)va_arg(va, int); - precision = prec > 0 ? (unsigned int)prec : 0U; - format++; - } - } - - // evaluate length field - switch (*format) { - case 'l' : - flags |= FLAGS_LONG; - format++; - if (*format == 'l') { - flags |= FLAGS_LONG_LONG; - format++; - } - break; - case 'h' : - flags |= FLAGS_SHORT; - format++; - if (*format == 'h') { - flags |= FLAGS_CHAR; - format++; - } - break; -#if defined(PRINTF_SUPPORT_PTRDIFF_T) - case 't' : - flags |= (sizeof(ptrdiff_t) == sizeof(long) ? FLAGS_LONG : FLAGS_LONG_LONG); - format++; - break; -#endif - case 'j' : - flags |= (sizeof(intmax_t) == sizeof(long) ? FLAGS_LONG : FLAGS_LONG_LONG); - format++; - break; - case 'z' : - flags |= (sizeof(size_t) == sizeof(long) ? FLAGS_LONG : FLAGS_LONG_LONG); - format++; - break; - default : - break; - } - - // evaluate specifier - switch (*format) { - case 'd' : - case 'i' : - case 'u' : - case 'x' : - case 'X' : - case 'o' : - case 'b' : { - // set the base - unsigned int base; - if (*format == 'x' || *format == 'X') { - base = 16U; - } - else if (*format == 'o') { - base = 8U; - } - else if (*format == 'b') { - base = 2U; - } - else { - base = 10U; - flags &= ~FLAGS_HASH; // no hash for dec format - } - // uppercase - if (*format == 'X') { - flags |= FLAGS_UPPERCASE; - } - - // no plus or space flag for u, x, X, o, b - if ((*format != 'i') && (*format != 'd')) { - flags &= ~(FLAGS_PLUS | FLAGS_SPACE); - } - - // ignore '0' flag when precision is given - if (flags & FLAGS_PRECISION) { - flags &= ~FLAGS_ZEROPAD; - } - - // convert the integer - if ((*format == 'i') || (*format == 'd')) { - // signed - if (flags & FLAGS_LONG_LONG) { -#if defined(PRINTF_SUPPORT_LONG_LONG) - const long long value = va_arg(va, long long); - idx = _ntoa_long_long(out, buffer, idx, maxlen, (unsigned long long)(value > 0 ? value : 0 - value), value < 0, base, precision, width, flags); -#endif - } - else if (flags & FLAGS_LONG) { - const long value = va_arg(va, long); - idx = _ntoa_long(out, buffer, idx, maxlen, (unsigned long)(value > 0 ? value : 0 - value), value < 0, base, precision, width, flags); - } - else { - const int value = (flags & FLAGS_CHAR) ? (char)va_arg(va, int) : (flags & FLAGS_SHORT) ? (short int)va_arg(va, int) : va_arg(va, int); - idx = _ntoa_long(out, buffer, idx, maxlen, (unsigned int)(value > 0 ? value : 0 - value), value < 0, base, precision, width, flags); - } - } - else { - // unsigned - if (flags & FLAGS_LONG_LONG) { -#if defined(PRINTF_SUPPORT_LONG_LONG) - idx = _ntoa_long_long(out, buffer, idx, maxlen, va_arg(va, unsigned long long), false, base, precision, width, flags); -#endif - } - else if (flags & FLAGS_LONG) { - idx = _ntoa_long(out, buffer, idx, maxlen, va_arg(va, unsigned long), false, base, precision, width, flags); - } - else { - const unsigned int value = (flags & FLAGS_CHAR) ? (unsigned char)va_arg(va, unsigned int) : (flags & FLAGS_SHORT) ? (unsigned short int)va_arg(va, unsigned int) : va_arg(va, unsigned int); - idx = _ntoa_long(out, buffer, idx, maxlen, value, false, base, precision, width, flags); - } - } - format++; - break; - } -#if defined(PRINTF_SUPPORT_FLOAT) - case 'f' : - case 'F' : - if (*format == 'F') flags |= FLAGS_UPPERCASE; - idx = _ftoa(out, buffer, idx, maxlen, va_arg(va, double), precision, width, flags); - format++; - break; -#if defined(PRINTF_SUPPORT_EXPONENTIAL) - case 'e': - case 'E': - case 'g': - case 'G': - if ((*format == 'g')||(*format == 'G')) flags |= FLAGS_ADAPT_EXP; - if ((*format == 'E')||(*format == 'G')) flags |= FLAGS_UPPERCASE; - idx = _etoa(out, buffer, idx, maxlen, va_arg(va, double), precision, width, flags); - format++; - break; -#endif // PRINTF_SUPPORT_EXPONENTIAL -#endif // PRINTF_SUPPORT_FLOAT - case 'c' : { - unsigned int l = 1U; - // pre padding - if (!(flags & FLAGS_LEFT)) { - while (l++ < width) { - out(' ', buffer, idx++, maxlen); - } - } - // char output - out((char)va_arg(va, int), buffer, idx++, maxlen); - // post padding - if (flags & FLAGS_LEFT) { - while (l++ < width) { - out(' ', buffer, idx++, maxlen); - } - } - format++; - break; - } - - case 's' : { - const char* p = va_arg(va, char*); - unsigned int l = _strnlen_s(p, precision ? precision : (size_t)-1); - // pre padding - if (flags & FLAGS_PRECISION) { - l = (l < precision ? l : precision); - } - if (!(flags & FLAGS_LEFT)) { - while (l++ < width) { - out(' ', buffer, idx++, maxlen); - } - } - // string output - while ((*p != 0) && (!(flags & FLAGS_PRECISION) || precision--)) { - out(*(p++), buffer, idx++, maxlen); - } - // post padding - if (flags & FLAGS_LEFT) { - while (l++ < width) { - out(' ', buffer, idx++, maxlen); - } - } - format++; - break; - } - - case 'p' : { - width = sizeof(void*) * 2U; - flags |= FLAGS_ZEROPAD | FLAGS_UPPERCASE; -#if defined(PRINTF_SUPPORT_LONG_LONG) - const bool is_ll = sizeof(uintptr_t) == sizeof(long long); - if (is_ll) { - idx = _ntoa_long_long(out, buffer, idx, maxlen, (uintptr_t)va_arg(va, void*), false, 16U, precision, width, flags); - } - else { -#endif - idx = _ntoa_long(out, buffer, idx, maxlen, (unsigned long)((uintptr_t)va_arg(va, void*)), false, 16U, precision, width, flags); -#if defined(PRINTF_SUPPORT_LONG_LONG) - } -#endif - format++; - break; - } - - case '%' : - out('%', buffer, idx++, maxlen); - format++; - break; - - default : - out(*format, buffer, idx++, maxlen); - format++; - break; - } - } - - // termination - out((char)0, buffer, idx < maxlen ? idx : maxlen - 1U, maxlen); - - // return written chars without terminating \0 - return (int)idx; -} - - -/////////////////////////////////////////////////////////////////////////////// - -int lv_snprintf(char* buffer, size_t count, const char* format, ...) -{ - va_list va; - va_start(va, format); - const int ret = _vsnprintf(_out_buffer, buffer, count, format, va); - va_end(va); - return ret; -} - -int lv_vsnprintf(char* buffer, size_t count, const char* format, va_list va) -{ - return _vsnprintf(_out_buffer, buffer, count, format, va); -} - -#endif /*LV_SPRINTF_CUSTOM*/ - diff --git a/src/libs/lvgl/src/lv_misc/lv_printf.h b/src/libs/lvgl/src/lv_misc/lv_printf.h deleted file mode 100644 index b3b8598d..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_printf.h +++ /dev/null @@ -1,75 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// \author (c) Marco Paland (info@paland.com) -// 2014-2019, PALANDesign Hannover, Germany -// -// \license The MIT License (MIT) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// -// \brief Tiny printf, sprintf and snprintf implementation, optimized for speed on -// embedded systems with a very limited resources. -// Use this instead of bloated standard/newlib printf. -// These routines are thread safe and reentrant. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _LV_PRINTF_H_ -#define _LV_PRINTF_H_ - - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifdef LV_CONF_INCLUDE_SIMPLE -#include "lv_conf.h" -#else -#include "../../../lv_conf.h" -#endif - -#if LV_SPRINTF_CUSTOM == 0 - -#include <stdarg.h> -#include <stddef.h> - -/** - * Tiny snprintf/vsnprintf implementation - * \param buffer A pointer to the buffer where to store the formatted string - * \param count The maximum number of characters to store in the buffer, including a terminating null character - * \param format A string that specifies the format of the output - * \param va A value identifying a variable arguments list - * \return The number of characters that COULD have been written into the buffer, not counting the terminating - * null character. A value equal or larger than count indicates truncation. Only when the returned value - * is non-negative and less than count, the string has been completely written. - */ -int lv_snprintf(char* buffer, size_t count, const char* format, ...); -int lv_vsnprintf(char* buffer, size_t count, const char* format, va_list va); - -#else -#include LV_SPRINTF_INCLUDE -#endif - - -#ifdef __cplusplus -} -#endif - - -#endif // _PRINTF_H_ diff --git a/src/libs/lvgl/src/lv_misc/lv_task.c b/src/libs/lvgl/src/lv_misc/lv_task.c deleted file mode 100644 index 5ac36edb..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_task.c +++ /dev/null @@ -1,382 +0,0 @@ -/** - * @file lv_task.c - * An 'lv_task' is a void (*fp) (void* param) type function which will be called periodically. - * A priority (5 levels + disable) can be assigned to lv_tasks. - */ - -/********************* - * INCLUDES - *********************/ -#include <stddef.h> -#include "lv_task.h" -#include "../lv_core/lv_debug.h" -#include "../lv_hal/lv_hal_tick.h" -#include "lv_gc.h" - -#if defined(LV_GC_INCLUDE) -#include LV_GC_INCLUDE -#endif /* LV_ENABLE_GC */ - -/********************* - * DEFINES - *********************/ -#define IDLE_MEAS_PERIOD 500 /*[ms]*/ -#define DEF_PRIO LV_TASK_PRIO_MID -#define DEF_PERIOD 500 - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ -static bool lv_task_exec(lv_task_t * task); - -/********************** - * STATIC VARIABLES - **********************/ -static bool lv_task_run = false; -static uint8_t idle_last = 0; -static bool task_deleted; -static bool task_created; - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -/** - * Init the lv_task module - */ -void lv_task_core_init(void) -{ - lv_ll_init(&LV_GC_ROOT(_lv_task_ll), sizeof(lv_task_t)); - - /*Initially enable the lv_task handling*/ - lv_task_enable(true); -} - -/** - * Call it periodically to handle lv_tasks. - */ -LV_ATTRIBUTE_TASK_HANDLER void lv_task_handler(void) -{ - LV_LOG_TRACE("lv_task_handler started"); - - /*Avoid concurrent running of the task handler*/ - static bool already_running = false; - if(already_running) return; - already_running = true; - - static uint32_t idle_period_start = 0; - static uint32_t handler_start = 0; - static uint32_t busy_time = 0; - - if(lv_task_run == false) { - already_running = false; /*Release mutex*/ - return; - } - - handler_start = lv_tick_get(); - - /* Run all task from the highest to the lowest priority - * If a lower priority task is executed check task again from the highest priority - * but on the priority of executed tasks don't run tasks before the executed*/ - lv_task_t * task_interrupter = NULL; - lv_task_t * next; - bool end_flag; - do { - end_flag = true; - task_deleted = false; - task_created = false; - LV_GC_ROOT(_lv_task_act) = lv_ll_get_head(&LV_GC_ROOT(_lv_task_ll)); - while(LV_GC_ROOT(_lv_task_act)) { - /* The task might be deleted if it runs only once ('once = 1') - * So get next element until the current is surely valid*/ - next = lv_ll_get_next(&LV_GC_ROOT(_lv_task_ll), LV_GC_ROOT(_lv_task_act)); - - /*We reach priority of the turned off task. There is nothing more to do.*/ - if(((lv_task_t *)LV_GC_ROOT(_lv_task_act))->prio == LV_TASK_PRIO_OFF) { - break; - } - - /*Here is the interrupter task. Don't execute it again.*/ - if(LV_GC_ROOT(_lv_task_act) == task_interrupter) { - task_interrupter = NULL; /*From this point only task after the interrupter comes, so - the interrupter is not interesting anymore*/ - LV_GC_ROOT(_lv_task_act) = next; - continue; /*Load the next task*/ - } - - /*Just try to run the tasks with highest priority.*/ - if(((lv_task_t *)LV_GC_ROOT(_lv_task_act))->prio == LV_TASK_PRIO_HIGHEST) { - lv_task_exec(LV_GC_ROOT(_lv_task_act)); - } - /*Tasks with higher priority than the interrupted shall be run in every case*/ - else if(task_interrupter) { - if(((lv_task_t *)LV_GC_ROOT(_lv_task_act))->prio > task_interrupter->prio) { - if(lv_task_exec(LV_GC_ROOT(_lv_task_act))) { - if(!task_created && !task_deleted) { - /*Check all tasks again from the highest priority */ - task_interrupter = LV_GC_ROOT(_lv_task_act); - end_flag = false; - break; - } - } - } - } - /* It is no interrupter task or we already reached it earlier. - * Just run the remaining tasks*/ - else { - if(lv_task_exec(LV_GC_ROOT(_lv_task_act))) { - if(!task_created && !task_deleted) { - task_interrupter = LV_GC_ROOT(_lv_task_act); /*Check all tasks again from the highest priority */ - end_flag = false; - break; - } - } - } - - /*If a task was created or deleted then this or the next item might be corrupted*/ - if(task_created || task_deleted) { - task_interrupter = NULL; - break; - } - - LV_GC_ROOT(_lv_task_act) = next; /*Load the next task*/ - } - } while(!end_flag); - - busy_time += lv_tick_elaps(handler_start); - uint32_t idle_period_time = lv_tick_elaps(idle_period_start); - if(idle_period_time >= IDLE_MEAS_PERIOD) { - - idle_last = (uint32_t)((uint32_t)busy_time * 100) / IDLE_MEAS_PERIOD; /*Calculate the busy percentage*/ - idle_last = idle_last > 100 ? 0 : 100 - idle_last; /*But we need idle time*/ - busy_time = 0; - idle_period_start = lv_tick_get(); - } - - already_running = false; /*Release the mutex*/ - - LV_LOG_TRACE("lv_task_handler ready"); -} -/** - * Create an "empty" task. It needs to initialzed with at least - * `lv_task_set_cb` and `lv_task_set_period` - * @return pointer to the craeted task - */ -lv_task_t * lv_task_create_basic(void) -{ - lv_task_t * new_task = NULL; - lv_task_t * tmp; - - /*Create task lists in order of priority from high to low*/ - tmp = lv_ll_get_head(&LV_GC_ROOT(_lv_task_ll)); - - /*It's the first task*/ - if(NULL == tmp) { - new_task = lv_ll_ins_head(&LV_GC_ROOT(_lv_task_ll)); - LV_ASSERT_MEM(new_task); - if(new_task == NULL) return NULL; - } - /*Insert the new task to proper place according to its priority*/ - else { - do { - if(tmp->prio <= DEF_PRIO) { - new_task = lv_ll_ins_prev(&LV_GC_ROOT(_lv_task_ll), tmp); - LV_ASSERT_MEM(new_task); - if(new_task == NULL) return NULL; - break; - } - tmp = lv_ll_get_next(&LV_GC_ROOT(_lv_task_ll), tmp); - } while(tmp != NULL); - - /*Only too high priority tasks were found. Add the task to the end*/ - if(tmp == NULL) { - new_task = lv_ll_ins_tail(&LV_GC_ROOT(_lv_task_ll)); - LV_ASSERT_MEM(new_task); - if(new_task == NULL) return NULL; - } - } - - new_task->period = DEF_PERIOD; - new_task->task_cb = NULL; - new_task->prio = DEF_PRIO; - - new_task->once = 0; - new_task->last_run = lv_tick_get(); - - new_task->user_data = NULL; - - task_created = true; - - return new_task; -} - -/** - * Create a new lv_task - * @param task_xcb a callback which is the task itself. It will be called periodically. - * (the 'x' in the argument name indicates that its not a fully generic function because it not follows - * the `func_name(object, callback, ...)` convention) - * @param period call period in ms unit - * @param prio priority of the task (LV_TASK_PRIO_OFF means the task is stopped) - * @param user_data custom parameter - * @return pointer to the new task - */ -lv_task_t * lv_task_create(lv_task_cb_t task_cb, uint32_t period, lv_task_prio_t prio, void * user_data) -{ - lv_task_t * new_task = lv_task_create_basic(); - LV_ASSERT_MEM(new_task); - if(new_task == NULL) return NULL; - - lv_task_set_cb(new_task, task_cb); - lv_task_set_period(new_task, period); - lv_task_set_prio(new_task, prio); - new_task->user_data = user_data; - - return new_task; -} - -/** - * Set the callback the task (the function to call periodically) - * @param task pointer to a task - * @param task_cb teh function to call periodically - */ -void lv_task_set_cb(lv_task_t * task, lv_task_cb_t task_cb) -{ - task->task_cb = task_cb; -} - -/** - * Delete a lv_task - * @param task pointer to task created by task - */ -void lv_task_del(lv_task_t * task) -{ - lv_ll_rem(&LV_GC_ROOT(_lv_task_ll), task); - - lv_mem_free(task); - - if(LV_GC_ROOT(_lv_task_act) == task) task_deleted = true; /*The active task was deleted*/ -} - -/** - * Set new priority for a lv_task - * @param task pointer to a lv_task - * @param prio the new priority - */ -void lv_task_set_prio(lv_task_t * task, lv_task_prio_t prio) -{ - if(task->prio == prio) return; - - /*Find the tasks with new priority*/ - lv_task_t * i; - LV_LL_READ(LV_GC_ROOT(_lv_task_ll), i) - { - if(i->prio <= prio) { - if(i != task) lv_ll_move_before(&LV_GC_ROOT(_lv_task_ll), task, i); - break; - } - } - - /*There was no such a low priority so far then add the node to the tail*/ - if(i == NULL) { - lv_ll_move_before(&LV_GC_ROOT(_lv_task_ll), task, NULL); - } - - task->prio = prio; -} - -/** - * Set new period for a lv_task - * @param task pointer to a lv_task - * @param period the new period - */ -void lv_task_set_period(lv_task_t * task, uint32_t period) -{ - task->period = period; -} - -/** - * Make a lv_task ready. It will not wait its period. - * @param task pointer to a lv_task. - */ -void lv_task_ready(lv_task_t * task) -{ - task->last_run = lv_tick_get() - task->period - 1; -} - -/** - * Delete the lv_task after one call - * @param task pointer to a lv_task. - */ -void lv_task_once(lv_task_t * task) -{ - task->once = 1; -} - -/** - * Reset a lv_task. - * It will be called the previously set period milliseconds later. - * @param task pointer to a lv_task. - */ -void lv_task_reset(lv_task_t * task) -{ - task->last_run = lv_tick_get(); -} - -/** - * Enable or disable the whole lv_task handling - * @param en: true: lv_task handling is running, false: lv_task handling is suspended - */ -void lv_task_enable(bool en) -{ - lv_task_run = en; -} - -/** - * Get idle percentage - * @return the lv_task idle in percentage - */ -uint8_t lv_task_get_idle(void) -{ - return idle_last; -} - -/********************** - * STATIC FUNCTIONS - **********************/ - -/** - * Execute task if its the priority is appropriate - * @param task pointer to lv_task - * @return true: execute, false: not executed - */ -static bool lv_task_exec(lv_task_t * task) -{ - bool exec = false; - - /*Execute if at least 'period' time elapsed*/ - uint32_t elp = lv_tick_elaps(task->last_run); - if(elp >= task->period) { - task->last_run = lv_tick_get(); - task_deleted = false; - task_created = false; - if(task->task_cb) task->task_cb(task); - - /*Delete if it was a one shot lv_task*/ - if(task_deleted == false) { /*The task might be deleted by itself as well*/ - if(task->once != 0) { - lv_task_del(task); - } - } - exec = true; - } - - return exec; -} diff --git a/src/libs/lvgl/src/lv_misc/lv_task.h b/src/libs/lvgl/src/lv_misc/lv_task.h deleted file mode 100644 index 05ff02b6..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_task.h +++ /dev/null @@ -1,177 +0,0 @@ -/** - * @file lv_task.c - * An 'lv_task' is a void (*fp) (void* param) type function which will be called periodically. - * A priority (5 levels + disable) can be assigned to lv_tasks. - */ - -#ifndef LV_TASK_H -#define LV_TASK_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ -#ifdef LV_CONF_INCLUDE_SIMPLE -#include "lv_conf.h" -#else -#include "../../../lv_conf.h" -#endif - -#include <stdint.h> -#include <stdbool.h> -#include "lv_mem.h" -#include "lv_ll.h" - -/********************* - * DEFINES - *********************/ -#ifndef LV_ATTRIBUTE_TASK_HANDLER -#define LV_ATTRIBUTE_TASK_HANDLER -#endif -/********************** - * TYPEDEFS - **********************/ - -struct _lv_task_t; - -/** - * Tasks execute this type type of functions. - */ -typedef void (*lv_task_cb_t)(struct _lv_task_t *); - -/** - * Possible priorities for lv_tasks - */ -enum { - LV_TASK_PRIO_OFF = 0, - LV_TASK_PRIO_LOWEST, - LV_TASK_PRIO_LOW, - LV_TASK_PRIO_MID, - LV_TASK_PRIO_HIGH, - LV_TASK_PRIO_HIGHEST, - _LV_TASK_PRIO_NUM, -}; -typedef uint8_t lv_task_prio_t; - -/** - * Descriptor of a lv_task - */ -typedef struct _lv_task_t -{ - uint32_t period; /**< How often the task should run */ - uint32_t last_run; /**< Last time the task ran */ - lv_task_cb_t task_cb; /**< Task function */ - - void * user_data; /**< Custom user data */ - - uint8_t prio : 3; /**< Task priority */ - uint8_t once : 1; /**< 1: one shot task */ -} lv_task_t; - -/********************** - * GLOBAL PROTOTYPES - **********************/ - -/** - * Init the lv_task module - */ -void lv_task_core_init(void); - -//! @cond Doxygen_Suppress - -/** - * Call it periodically to handle lv_tasks. - */ -LV_ATTRIBUTE_TASK_HANDLER void lv_task_handler(void); - -//! @endcond - -/** - * Create an "empty" task. It needs to initialzed with at least - * `lv_task_set_cb` and `lv_task_set_period` - * @return pointer to the craeted task - */ -lv_task_t * lv_task_create_basic(void); - -/** - * Create a new lv_task - * @param task_xcb a callback which is the task itself. It will be called periodically. - * (the 'x' in the argument name indicates that its not a fully generic function because it not follows - * the `func_name(object, callback, ...)` convention) - * @param period call period in ms unit - * @param prio priority of the task (LV_TASK_PRIO_OFF means the task is stopped) - * @param user_data custom parameter - * @return pointer to the new task - */ -lv_task_t * lv_task_create(lv_task_cb_t task_xcb, uint32_t period, lv_task_prio_t prio, void * user_data); - -/** - * Delete a lv_task - * @param task pointer to task_cb created by task - */ -void lv_task_del(lv_task_t * task); - -/** - * Set the callback the task (the function to call periodically) - * @param task pointer to a task - * @param task_cb the function to call periodically - */ -void lv_task_set_cb(lv_task_t * task, lv_task_cb_t task_cb); - -/** - * Set new priority for a lv_task - * @param task pointer to a lv_task - * @param prio the new priority - */ -void lv_task_set_prio(lv_task_t * task, lv_task_prio_t prio); - -/** - * Set new period for a lv_task - * @param task pointer to a lv_task - * @param period the new period - */ -void lv_task_set_period(lv_task_t * task, uint32_t period); - -/** - * Make a lv_task ready. It will not wait its period. - * @param task pointer to a lv_task. - */ -void lv_task_ready(lv_task_t * task); - -/** - * Delete the lv_task after one call - * @param task pointer to a lv_task. - */ -void lv_task_once(lv_task_t * task); - -/** - * Reset a lv_task. - * It will be called the previously set period milliseconds later. - * @param task pointer to a lv_task. - */ -void lv_task_reset(lv_task_t * task); - -/** - * Enable or disable the whole lv_task handling - * @param en: true: lv_task handling is running, false: lv_task handling is suspended - */ -void lv_task_enable(bool en); - -/** - * Get idle percentage - * @return the lv_task idle in percentage - */ -uint8_t lv_task_get_idle(void); - -/********************** - * MACROS - **********************/ - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif diff --git a/src/libs/lvgl/src/lv_misc/lv_templ.c b/src/libs/lvgl/src/lv_misc/lv_templ.c deleted file mode 100644 index c5bb68c0..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_templ.c +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @file lv_templ.c - * - */ - -/********************* - * INCLUDES - *********************/ - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/* This typedef exists purely to keep -Wpedantic happy when the file is empty. */ -/* It can be removed. */ -typedef int keep_pedantic_happy; - -/********************** - * STATIC PROTOTYPES - **********************/ - -/********************** - * STATIC VARIABLES - **********************/ - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -/********************** - * STATIC FUNCTIONS - **********************/ diff --git a/src/libs/lvgl/src/lv_misc/lv_templ.h b/src/libs/lvgl/src/lv_misc/lv_templ.h deleted file mode 100644 index 1f1b92d6..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_templ.h +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @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*/ diff --git a/src/libs/lvgl/src/lv_misc/lv_txt.c b/src/libs/lvgl/src/lv_misc/lv_txt.c deleted file mode 100644 index 9de132e9..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_txt.c +++ /dev/null @@ -1,845 +0,0 @@ -/** - * @file lv_text.c - * - */ - -/********************* - * INCLUDES - *********************/ -#include "lv_txt.h" -#include "lv_math.h" -#include "lv_log.h" - -/********************* - * DEFINES - *********************/ -#define NO_BREAK_FOUND UINT32_MAX - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ -static inline bool is_break_char(uint32_t letter); - -#if LV_TXT_ENC == LV_TXT_ENC_UTF8 -static uint8_t lv_txt_utf8_size(const char * str); -static uint32_t lv_txt_unicode_to_utf8(uint32_t letter_uni); -static uint32_t lv_txt_utf8_conv_wc(uint32_t c); -static uint32_t lv_txt_utf8_next(const char * txt, uint32_t * i); -static uint32_t lv_txt_utf8_prev(const char * txt, uint32_t * i_start); -static uint32_t lv_txt_utf8_get_byte_id(const char * txt, uint32_t utf8_id); -static uint32_t lv_txt_utf8_get_char_id(const char * txt, uint32_t byte_id); -static uint32_t lv_txt_utf8_get_length(const char * txt); -#elif LV_TXT_ENC == LV_TXT_ENC_ASCII -static uint8_t lv_txt_iso8859_1_size(const char * str); -static uint32_t lv_txt_unicode_to_iso8859_1(uint32_t letter_uni); -static uint32_t lv_txt_iso8859_1_conv_wc(uint32_t c); -static uint32_t lv_txt_iso8859_1_next(const char * txt, uint32_t * i); -static uint32_t lv_txt_iso8859_1_prev(const char * txt, uint32_t * i_start); -static uint32_t lv_txt_iso8859_1_get_byte_id(const char * txt, uint32_t utf8_id); -static uint32_t lv_txt_iso8859_1_get_char_id(const char * txt, uint32_t byte_id); -static uint32_t lv_txt_iso8859_1_get_length(const char * txt); -#endif -/********************** - * STATIC VARIABLES - **********************/ - -/********************** - * GLOBAL VARIABLES - **********************/ -#if LV_TXT_ENC == LV_TXT_ENC_UTF8 -uint8_t (*lv_txt_encoded_size)(const char *) = lv_txt_utf8_size; -uint32_t (*lv_txt_unicode_to_encoded)(uint32_t) = lv_txt_unicode_to_utf8; -uint32_t (*lv_txt_encoded_conv_wc)(uint32_t) = lv_txt_utf8_conv_wc; -uint32_t (*lv_txt_encoded_next)(const char *, uint32_t *) = lv_txt_utf8_next; -uint32_t (*lv_txt_encoded_prev)(const char *, uint32_t *) = lv_txt_utf8_prev; -uint32_t (*lv_txt_encoded_get_byte_id)(const char *, uint32_t) = lv_txt_utf8_get_byte_id; -uint32_t (*lv_txt_encoded_get_char_id)(const char *, uint32_t) = lv_txt_utf8_get_char_id; -uint32_t (*lv_txt_get_encoded_length)(const char *) = lv_txt_utf8_get_length; -#elif LV_TXT_ENC == LV_TXT_ENC_ASCII -uint8_t (*lv_txt_encoded_size)(const char *) = lv_txt_iso8859_1_size; -uint32_t (*lv_txt_unicode_to_encoded)(uint32_t) = lv_txt_unicode_to_iso8859_1; -uint32_t (*lv_txt_encoded_conv_wc)(uint32_t) = lv_txt_iso8859_1_conv_wc; -uint32_t (*lv_txt_encoded_next)(const char *, uint32_t *) = lv_txt_iso8859_1_next; -uint32_t (*lv_txt_encoded_prev)(const char *, uint32_t *) = lv_txt_iso8859_1_prev; -uint32_t (*lv_txt_encoded_get_byte_id)(const char *, uint32_t) = lv_txt_iso8859_1_get_byte_id; -uint32_t (*lv_txt_encoded_get_char_id)(const char *, uint32_t) = lv_txt_iso8859_1_get_char_id; -uint32_t (*lv_txt_get_encoded_length)(const char *) = lv_txt_iso8859_1_get_length; - -#endif - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -/** - * 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 pinter to font of the text - * @param letter_space letter space of the text - * @param txt.line_space line space of the text - * @param flags settings for the text from 'txt_flag_t' enum - * @param max_width max with of the text (break the lines to fit this size) Set CORD_MAX to avoid - * line breaks - */ -void lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t * font, lv_coord_t letter_space, - lv_coord_t line_space, lv_coord_t max_width, lv_txt_flag_t flag) -{ - size_res->x = 0; - size_res->y = 0; - - if(text == NULL) return; - if(font == NULL) return; - - if(flag & LV_TXT_FLAG_EXPAND) max_width = LV_COORD_MAX; - - uint32_t line_start = 0; - uint32_t new_line_start = 0; - lv_coord_t act_line_length; - uint8_t letter_height = lv_font_get_line_height(font); - - /*Calc. the height and longest line*/ - while(text[line_start] != '\0') { - new_line_start += lv_txt_get_next_line(&text[line_start], font, letter_space, max_width, flag); - - if ((unsigned long)size_res->y + (unsigned long)letter_height + (unsigned long)line_space > LV_MAX_OF(lv_coord_t)) { - LV_LOG_WARN("lv_txt_get_size: integer overflow while calculating text height"); - return; - } else { - size_res->y += letter_height; - size_res->y += line_space; - } - - /*Calculate the the longest line*/ - act_line_length = lv_txt_get_width(&text[line_start], new_line_start - line_start, font, letter_space, flag); - - size_res->x = LV_MATH_MAX(act_line_length, size_res->x); - line_start = new_line_start; - } - - /*Make the text one line taller if the last character is '\n' or '\r'*/ - if((line_start != 0) && (text[line_start - 1] == '\n' || text[line_start - 1] == '\r')) { - size_res->y += letter_height + line_space; - } - - /*Correction with the last line space or set the height manually if the text is empty*/ - if(size_res->y == 0) - size_res->y = letter_height; - else - size_res->y -= line_space; -} - -/** - * Get the next word of text. A word is delimited by break characters. - * - * If the word cannot fit in the max_width space, obey LV_TXT_LINE_BREAK_LONG_* rules. - * - * If the next word cannot fit anything, return 0. - * - * If the first character is a break character, returns the next index. - * - * Example calls from lv_txt_get_next_line() assuming sufficent max_width and - * txt = "Test text\n" - * 0123456789 - * - * Calls would be as follows: - * 1. Return i=4, pointing at breakchar ' ', for the string "Test" - * 2. Return i=5, since i=4 was a breakchar. - * 3. Return i=9, pointing at breakchar '\n' - * 4. Parenting lv_txt_get_next_line() would detect subsequent '\0' - * - * TODO: Returned word_w_ptr may overestimate the returned word's width when - * max_width is reached. In current usage, this has no impact. - * - * @param txt a '\0' terminated string - * @param font pointer to a font - * @param letter_space letter space - * @param max_width max with of the text (break the lines to fit this size) Set CORD_MAX to avoid line breaks - * @param flags settings for the text from 'txt_flag_type' enum - * @param[out] word_w_ptr width (in pixels) of the parsed word. May be NULL. - * @param force Force return the fraction of the word that can fit in the provided space. - * @return the index of the first char of the next word (in byte index not letter index. With UTF-8 they are different) - */ -static uint16_t lv_txt_get_next_word(const char * txt, const lv_font_t * font, - lv_coord_t letter_space, lv_coord_t max_width, - lv_txt_flag_t flag, uint32_t *word_w_ptr, lv_txt_cmd_state_t * cmd_state, bool force) -{ - if(txt == NULL || txt[0] == '\0') return 0; - if(font == NULL) return 0; - - if(flag & LV_TXT_FLAG_EXPAND) max_width = LV_COORD_MAX; - - uint32_t i = 0, i_next = 0, i_next_next = 0; /* Iterating index into txt */ - uint32_t letter = 0; /* Letter at i */ - uint32_t letter_next = 0; /* Letter at i_next */ - lv_coord_t letter_w; - lv_coord_t cur_w = 0; /* Pixel Width of transversed string */ - uint32_t word_len = 0; /* Number of characters in the transversed word */ - uint32_t break_index = NO_BREAK_FOUND; /* only used for "long" words */ - uint32_t break_letter_count = 0; /* Number of characters up to the long word break point */ - - letter = lv_txt_encoded_next(txt, &i_next); - i_next_next = i_next; - - /* Obtain the full word, regardless if it fits or not in max_width */ - while(txt[i] != '\0') { - letter_next = lv_txt_encoded_next(txt, &i_next_next); - word_len++; - - /*Handle the recolor command*/ - if((flag & LV_TXT_FLAG_RECOLOR) != 0) { - if(lv_txt_is_cmd(cmd_state, letter) != false) { - i = i_next; - i_next = i_next_next; - letter = letter_next; - continue; /*Skip the letter is it is part of a command*/ - } - } - - letter_w = lv_font_get_glyph_width(font, letter, letter_next); - cur_w += letter_w; - - if(letter_w > 0) { - cur_w += letter_space; - } - - /* Test if this character fits within max_width */ - if(break_index == NO_BREAK_FOUND && (cur_w - letter_space) > max_width) { - break_index = i; - break_letter_count = word_len - 1; - /* break_index is now pointing at the character that doesn't fit */ - } - - /*Check for new line chars and breakchars*/ - if(letter == '\n' || letter == '\r' || is_break_char(letter)) { - /* Update the output width on the first character if it fits. - * Must do this here incase first letter is a break character. */ - if(i == 0 && break_index == NO_BREAK_FOUND && word_w_ptr != NULL) *word_w_ptr = cur_w; - word_len--; - break; - } - - /* Update the output width */ - if( word_w_ptr != NULL && break_index == NO_BREAK_FOUND ) *word_w_ptr = cur_w; - - - i = i_next; - i_next = i_next_next; - letter = letter_next; - } - - /* Entire Word fits in the provided space */ - if( break_index == NO_BREAK_FOUND ) { - if( word_len == 0 || (letter == '\r' && letter_next == '\n') ) i = i_next; - return i; - } - -#if LV_TXT_LINE_BREAK_LONG_LEN > 0 - /* Word doesn't fit in provided space, but isn't "long" */ - if(word_len < LV_TXT_LINE_BREAK_LONG_LEN) { - if( force ) return break_index; - if(word_w_ptr != NULL) *word_w_ptr = 0; /* Return no word */ - return 0; - } - - /* Word is "long," but insufficient amounts can fit in provided space */ - if(break_letter_count < LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN) { - if( force ) return break_index; - if(word_w_ptr != NULL) *word_w_ptr = 0; - return 0; - } - - /* Word is a "long", but letters may need to be better distributed */ - { - i = break_index; - int32_t n_move = LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN - (word_len - break_letter_count); - /* Move pointer "i" backwards */ - for(;n_move>0; n_move--){ - lv_txt_encoded_prev(txt, &i); - // TODO: it would be appropriate to update the returned word width here - // However, in current usage, this doesn't impact anything. - } - } - return i; -#else - if( force ) return break_index; - if(word_w_ptr != NULL) *word_w_ptr = 0; /* Return no word */ - (void) break_letter_count; - return 0; -#endif -} - -/** - * Get the next line of text. Check line length and break chars too. - * - * A line of txt includes the \n character. - * - * @param txt a '\0' terminated string - * @param font pointer to a font - * @param letter_space letter space - * @param max_width max with of the text (break the lines to fit this size) Set CORD_MAX to avoid line breaks - * @param flags 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) - */ -uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font, - lv_coord_t letter_space, lv_coord_t max_width, lv_txt_flag_t flag) -{ - if(txt == NULL) return 0; - if(font == NULL) return 0; - - if(flag & LV_TXT_FLAG_EXPAND) max_width = LV_COORD_MAX; - lv_txt_cmd_state_t cmd_state = LV_TXT_CMD_STATE_WAIT; - uint32_t i = 0; /* Iterating index into txt */ - - while(txt[i] != '\0' && max_width > 0) { - uint32_t word_w = 0; - uint32_t advance = lv_txt_get_next_word(&txt[i], font, letter_space, max_width, flag, &word_w, &cmd_state, i==0); - max_width -= word_w; - - if( advance == 0 ){ - if(i == 0) lv_txt_encoded_next(txt, &i); // prevent inf loops - break; - } - - i += advance; - - if(txt[0] == '\n' || txt[0] == '\r') break; - - if(txt[i] == '\n' || txt[i] == '\r'){ - i++; /* Include the following newline in the current line */ - break; - } - - } - - /* Always step at least one to avoid infinite loops */ - if(i == 0) { - lv_txt_encoded_next(txt, &i); - } - - return i; -} - -/** - * 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 - * @param flags settings for the text from 'txt_flag_t' enum - * @return length of a char_num long text - */ -lv_coord_t lv_txt_get_width(const char * txt, uint16_t length, const lv_font_t * font, lv_coord_t letter_space, - lv_txt_flag_t flag) -{ - if(txt == NULL) return 0; - if(font == NULL) return 0; - - uint32_t i = 0; - lv_coord_t width = 0; - lv_txt_cmd_state_t cmd_state = LV_TXT_CMD_STATE_WAIT; - uint32_t letter; - uint32_t letter_next; - - if(length != 0) { - while(i < length) { - letter = lv_txt_encoded_next(txt, &i); - letter_next = lv_txt_encoded_next(&txt[i], NULL); - if((flag & LV_TXT_FLAG_RECOLOR) != 0) { - if(lv_txt_is_cmd(&cmd_state, letter) != false) { - continue; - } - } - - lv_coord_t char_width = lv_font_get_glyph_width(font, letter, letter_next); - if(char_width > 0) { - width += char_width; - width += letter_space; - } - } - - if(width > 0) { - width -= letter_space; /*Trim the last letter space. Important if the text is center - aligned */ - } - } - - return width; -} - -/** - * Check next character in a string and decide if the character is part of the command or not - * @param state pointer to a txt_cmd_state_t variable which stores the current state of command - * processing (Initied. to TXT_CMD_STATE_WAIT ) - * @param c the current character - * @return true: the character is part of a command and should not be written, - * false: the character should be written - */ -bool lv_txt_is_cmd(lv_txt_cmd_state_t * state, uint32_t c) -{ - bool ret = false; - - if(c == (uint32_t)LV_TXT_COLOR_CMD[0]) { - if(*state == LV_TXT_CMD_STATE_WAIT) { /*Start char*/ - *state = LV_TXT_CMD_STATE_PAR; - ret = true; - } - /*Other start char in parameter is escaped cmd. char */ - else if(*state == LV_TXT_CMD_STATE_PAR) { - *state = LV_TXT_CMD_STATE_WAIT; - } - /*Command end */ - else if(*state == LV_TXT_CMD_STATE_IN) { - *state = LV_TXT_CMD_STATE_WAIT; - ret = true; - } - } - - /*Skip the color parameter and wait the space after it*/ - if(*state == LV_TXT_CMD_STATE_PAR) { - if(c == ' ') { - *state = LV_TXT_CMD_STATE_IN; /*After the parameter the text is in the command*/ - } - ret = true; - } - - return ret; -} - -/** - * Insert a string into an other - * @param txt_buf the original text (must be big enough for the result text) - * @param pos position to insert. Expressed in character index and not byte index (Different in - * UTF-8) 0: before the original text, 1: after the first char etc. - * @param ins_txt text to insert - */ -void lv_txt_ins(char * txt_buf, uint32_t pos, const char * ins_txt) -{ - size_t old_len = strlen(txt_buf); - size_t ins_len = strlen(ins_txt); - size_t new_len = ins_len + old_len; - pos = lv_txt_encoded_get_byte_id(txt_buf, pos); /*Convert to byte index instead of letter index*/ - - /*Copy the second part into the end to make place to text to insert*/ - size_t i; - for(i = new_len; i >= pos + ins_len; i--) { - txt_buf[i] = txt_buf[i - ins_len]; - } - - /* Copy the text into the new space*/ - memcpy(txt_buf + pos, ins_txt, ins_len); -} - -/** - * Delete a part of a string - * @param txt string to modify - * @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_txt_cut(char * txt, uint32_t pos, uint32_t len) -{ - - size_t old_len = strlen(txt); - - pos = lv_txt_encoded_get_byte_id(txt, pos); /*Convert to byte index instead of letter index*/ - len = lv_txt_encoded_get_byte_id(&txt[pos], len); - - /*Copy the second part into the end to make place to text to insert*/ - uint32_t i; - for(i = pos; i <= old_len - len; i++) { - txt[i] = txt[i + len]; - } -} - -#if LV_TXT_ENC == LV_TXT_ENC_UTF8 -/******************************* - * UTF-8 ENCODER/DECOER - ******************************/ - -/** - * Give the size of an UTF-8 coded character - * @param str pointer to a character in a string - * @return length of the UTF-8 character (1,2,3 or 4). O on invalid code - */ -static uint8_t lv_txt_utf8_size(const char * str) -{ - if((str[0] & 0x80) == 0) - return 1; - else if((str[0] & 0xE0) == 0xC0) - return 2; - else if((str[0] & 0xF0) == 0xE0) - return 3; - else if((str[0] & 0xF8) == 0xF0) - return 4; - return 0; /*If the char was invalid tell it's 1 byte long*/ -} - -/** - * Convert an Unicode letter to UTF-8. - * @param letter_uni an Unicode letter - * @return UTF-8 coded character in Little Endian to be compatible with C chars (e.g. 'Á', 'Ű') - */ -static uint32_t lv_txt_unicode_to_utf8(uint32_t letter_uni) -{ - if(letter_uni < 128) return letter_uni; - uint8_t bytes[4]; - - if(letter_uni < 0x0800) { - bytes[0] = ((letter_uni >> 6) & 0x1F) | 0xC0; - bytes[1] = ((letter_uni >> 0) & 0x3F) | 0x80; - bytes[2] = 0; - bytes[3] = 0; - } else if(letter_uni < 0x010000) { - bytes[0] = ((letter_uni >> 12) & 0x0F) | 0xE0; - bytes[1] = ((letter_uni >> 6) & 0x3F) | 0x80; - bytes[2] = ((letter_uni >> 0) & 0x3F) | 0x80; - bytes[3] = 0; - } else if(letter_uni < 0x110000) { - bytes[0] = ((letter_uni >> 18) & 0x07) | 0xF0; - bytes[1] = ((letter_uni >> 12) & 0x3F) | 0x80; - bytes[2] = ((letter_uni >> 6) & 0x3F) | 0x80; - bytes[3] = ((letter_uni >> 0) & 0x3F) | 0x80; - } - - uint32_t * res_p = (uint32_t *)bytes; - return *res_p; -} - -/** - * Convert a wide character, e.g. 'Á' little endian to be UTF-8 compatible - * @param c a wide character or a Little endian number - * @return `c` in big endian - */ -static uint32_t lv_txt_utf8_conv_wc(uint32_t c) -{ - /*Swap the bytes (UTF-8 is big endian, but the MCUs are little endian)*/ - if((c & 0x80) != 0) { - uint32_t swapped; - uint8_t c8[4]; - memcpy(c8, &c, 4); - swapped = (c8[0] << 24) + (c8[1] << 16) + (c8[2] << 8) + (c8[3]); - uint8_t i; - for(i = 0; i < 4; i++) { - if((swapped & 0xFF) == 0) - swapped = (swapped >> 8); /*Ignore leading zeros (they were in the end originally)*/ - } - c = swapped; - } - - return c; -} - -/** - * Decode an UTF-8 character from a string. - * @param txt pointer to '\0' terminated string - * @param i start byte index in 'txt' where to start. - * After call it will point to the next UTF-8 char in 'txt'. - * NULL to use txt[0] as index - * @return the decoded Unicode character or 0 on invalid UTF-8 code - */ -static uint32_t lv_txt_utf8_next(const char * txt, uint32_t * i) -{ - /* Unicode to UTF-8 - * 00000000 00000000 00000000 0xxxxxxx -> 0xxxxxxx - * 00000000 00000000 00000yyy yyxxxxxx -> 110yyyyy 10xxxxxx - * 00000000 00000000 zzzzyyyy yyxxxxxx -> 1110zzzz 10yyyyyy 10xxxxxx - * 00000000 000wwwzz zzzzyyyy yyxxxxxx -> 11110www 10zzzzzz 10yyyyyy 10xxxxxx - * */ - - uint32_t result = 0; - - /*Dummy 'i' pointer is required*/ - uint32_t i_tmp = 0; - if(i == NULL) i = &i_tmp; - - /*Normal ASCII*/ - if((txt[*i] & 0x80) == 0) { - result = txt[*i]; - (*i)++; - } - /*Real UTF-8 decode*/ - else { - /*2 bytes UTF-8 code*/ - if((txt[*i] & 0xE0) == 0xC0) { - result = (uint32_t)(txt[*i] & 0x1F) << 6; - (*i)++; - if((txt[*i] & 0xC0) != 0x80) return 0; /*Invalid UTF-8 code*/ - result += (txt[*i] & 0x3F); - (*i)++; - } - /*3 bytes UTF-8 code*/ - else if((txt[*i] & 0xF0) == 0xE0) { - result = (uint32_t)(txt[*i] & 0x0F) << 12; - (*i)++; - - if((txt[*i] & 0xC0) != 0x80) return 0; /*Invalid UTF-8 code*/ - result += (uint32_t)(txt[*i] & 0x3F) << 6; - (*i)++; - - if((txt[*i] & 0xC0) != 0x80) return 0; /*Invalid UTF-8 code*/ - result += (txt[*i] & 0x3F); - (*i)++; - } - /*4 bytes UTF-8 code*/ - else if((txt[*i] & 0xF8) == 0xF0) { - result = (uint32_t)(txt[*i] & 0x07) << 18; - (*i)++; - - if((txt[*i] & 0xC0) != 0x80) return 0; /*Invalid UTF-8 code*/ - result += (uint32_t)(txt[*i] & 0x3F) << 12; - (*i)++; - - if((txt[*i] & 0xC0) != 0x80) return 0; /*Invalid UTF-8 code*/ - result += (uint32_t)(txt[*i] & 0x3F) << 6; - (*i)++; - - if((txt[*i] & 0xC0) != 0x80) return 0; /*Invalid UTF-8 code*/ - result += txt[*i] & 0x3F; - (*i)++; - } else { - (*i)++; /*Not UTF-8 char. Go the next.*/ - } - } - return result; -} - -/** - * Get previous UTF-8 character form a string. - * @param txt pointer to '\0' terminated string - * @param i start byte index in 'txt' where to start. After the call it will point to the previous - * UTF-8 char in 'txt'. - * @return the decoded Unicode character or 0 on invalid UTF-8 code - */ -static uint32_t lv_txt_utf8_prev(const char * txt, uint32_t * i) -{ - uint8_t c_size; - uint8_t cnt = 0; - - /*Try to find a !0 long UTF-8 char by stepping one character back*/ - (*i)--; - do { - if(cnt >= 4) return 0; /*No UTF-8 char found before the initial*/ - - c_size = lv_txt_encoded_size(&txt[*i]); - if(c_size == 0) { - if(*i != 0) - (*i)--; - else - return 0; - } - cnt++; - } while(c_size == 0); - - uint32_t i_tmp = *i; - uint32_t letter = lv_txt_encoded_next(txt, &i_tmp); /*Character found, get it*/ - - return letter; -} - -/** - * Convert a character index (in an UTF-8 text) to byte index. - * E.g. in "AÁRT" index of 'R' is 2th char 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 'utf8_id'th letter - */ -static uint32_t lv_txt_utf8_get_byte_id(const char * txt, uint32_t utf8_id) -{ - uint32_t i; - uint32_t byte_cnt = 0; - for(i = 0; i < utf8_id; i++) { - uint8_t c_size = lv_txt_encoded_size(&txt[byte_cnt]); - byte_cnt += c_size > 0 ? c_size : 1; - } - - return byte_cnt; -} - -/** - * Convert a byte index (in an UTF-8 text) to character index. - * E.g. in "AÁRT" index of 'R' is 2th char 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 - */ -static uint32_t lv_txt_utf8_get_char_id(const char * txt, uint32_t byte_id) -{ - uint32_t i = 0; - uint32_t char_cnt = 0; - - while(i < byte_id) { - lv_txt_encoded_next(txt, &i); /*'i' points to the next letter so use the prev. value*/ - char_cnt++; - } - - return char_cnt; -} - -/** - * Get the number of characters (and NOT bytes) in a string. Decode it with UTF-8 if enabled. - * E.g.: "ÁBC" is 3 characters (but 4 bytes) - * @param txt a '\0' terminated char string - * @return number of characters - */ -static uint32_t lv_txt_utf8_get_length(const char * txt) -{ - uint32_t len = 0; - uint32_t i = 0; - - while(txt[i] != '\0') { - lv_txt_encoded_next(txt, &i); - len++; - } - - return len; -} - -#elif LV_TXT_ENC == LV_TXT_ENC_ASCII -/******************************* - * ASCII ENCODER/DECOER - ******************************/ - -/** - * Give the size of an ISO8859-1 coded character - * @param str pointer to a character in a string - * @return length of the UTF-8 character (1,2,3 or 4). O on invalid code - */ -static uint8_t lv_txt_iso8859_1_size(const char * str) -{ - (void)str; /*Unused*/ - return 1; -} - -/** - * Convert an Unicode letter to ISO8859-1. - * @param letter_uni an Unicode letter - * @return ISO8859-1 coded character in Little Endian to be compatible with C chars (e.g. 'Á', 'Ű') - */ -static uint32_t lv_txt_unicode_to_iso8859_1(uint32_t letter_uni) -{ - if(letter_uni < 128) - return letter_uni; - else - return ' '; -} - -/** - * Convert wide characters to ASCII, however wide characters in ASCII range (e.g. 'A') are ASCII compatible by default. - * So this function does nothing just returns with `c`. - * @param c a character, e.g. 'A' - * @return same as `c` - */ -static uint32_t lv_txt_iso8859_1_conv_wc(uint32_t c) -{ - return c; -} - -/** - * Decode an ISO8859-1 character from a string. - * @param txt pointer to '\0' terminated string - * @param i start byte index in 'txt' where to start. - * After call it will point to the next UTF-8 char in 'txt'. - * NULL to use txt[0] as index - * @return the decoded Unicode character or 0 on invalid UTF-8 code - */ -static uint32_t lv_txt_iso8859_1_next(const char * txt, uint32_t * i) -{ - if(i == NULL) return txt[1]; /*Get the next char */ - - uint8_t letter = txt[*i]; - (*i)++; - return letter; -} - -/** - * Get previous ISO8859-1 character form a string. - * @param txt pointer to '\0' terminated string - * @param i start byte index in 'txt' where to start. After the call it will point to the previous UTF-8 char in 'txt'. - * @return the decoded Unicode character or 0 on invalid UTF-8 code - */ -static uint32_t lv_txt_iso8859_1_prev(const char * txt, uint32_t * i) -{ - if(i == NULL) return *(txt - 1); /*Get the prev. char */ - - (*i)--; - uint8_t letter = txt[*i]; - - return letter; -} - -/** - * Convert a character index (in an ISO8859-1 text) to byte index. - * E.g. in "AÁRT" index of 'R' is 2th char 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 'utf8_id'th letter - */ -static uint32_t lv_txt_iso8859_1_get_byte_id(const char * txt, uint32_t utf8_id) -{ - (void)txt; /*Unused*/ - return utf8_id; /*In Non encoded no difference*/ -} - -/** - * Convert a byte index (in an ISO8859-1 text) to character index. - * E.g. in "AÁRT" index of 'R' is 2th char 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 - */ -static uint32_t lv_txt_iso8859_1_get_char_id(const char * txt, uint32_t byte_id) -{ - (void)txt; /*Unused*/ - return byte_id; /*In Non encoded no difference*/ -} - -/** - * Get the number of characters (and NOT bytes) in a string. Decode it with UTF-8 if enabled. - * E.g.: "ÁBC" is 3 characters (but 4 bytes) - * @param txt a '\0' terminated char string - * @return number of characters - */ -static uint32_t lv_txt_iso8859_1_get_length(const char * txt) -{ - return strlen(txt); -} -#else - -#error "Invalid character encoding. See `LV_TXT_ENC` in `lv_conf.h`" - -#endif - -/********************** - * STATIC FUNCTIONS - **********************/ - -/** - * 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 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; -} diff --git a/src/libs/lvgl/src/lv_misc/lv_txt.h b/src/libs/lvgl/src/lv_misc/lv_txt.h deleted file mode 100644 index 6dbce5d4..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_txt.h +++ /dev/null @@ -1,211 +0,0 @@ -/** - * @file lv_text.h - * - */ - -#ifndef LV_TXT_H -#define LV_TXT_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ -#ifdef LV_CONF_INCLUDE_SIMPLE -#include "lv_conf.h" -#else -#include "../../../lv_conf.h" -#endif - -#include <stdbool.h> -#include "lv_area.h" -#include "lv_area.h" -#include "../lv_font/lv_font.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. - */ -enum { - LV_TXT_FLAG_NONE = 0x00, - LV_TXT_FLAG_RECOLOR = 0x01, /**< Enable parsing of recolor command*/ - LV_TXT_FLAG_EXPAND = 0x02, /**< Ignore width to avoid automatic word wrapping*/ - LV_TXT_FLAG_CENTER = 0x04, /**< Align the text to the middle*/ - LV_TXT_FLAG_RIGHT = 0x08, /**< Align the text to the right*/ -}; -typedef uint8_t lv_txt_flag_t; - -/** - * State machine for text renderer. */ -enum { - LV_TXT_CMD_STATE_WAIT, /**< Waiting for command*/ - LV_TXT_CMD_STATE_PAR, /**< Processing the parameter*/ - LV_TXT_CMD_STATE_IN, /**< Processing the command*/ -}; -typedef uint8_t lv_txt_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 pinter to font of the text - * @param letter_space letter space of the text - * @param line_space line space of the text - * @param flags settings for the text from 'txt_flag_t' enum - * @param max_width max with of the text (break the lines to fit this size) Set CORD_MAX to avoid - * line breaks - */ -void lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t * font, lv_coord_t letter_space, - lv_coord_t line_space, lv_coord_t max_width, lv_txt_flag_t flag); - -/** - * 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 with of the text (break the lines to fit this size) Set CORD_MAX to avoid - * line breaks - * @param flags 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) - */ -uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font, lv_coord_t letter_space, lv_coord_t max_width, - lv_txt_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 - * @param flags settings for the text from 'txt_flag_t' enum - * @return length of a char_num long text - */ -lv_coord_t lv_txt_get_width(const char * txt, uint16_t length, const lv_font_t * font, lv_coord_t letter_space, - lv_txt_flag_t flag); - -/** - * Check next character in a string and decide if te character is part of the command or not - * @param state pointer to a txt_cmd_state_t variable which stores the current state of command - * processing - * @param c the current character - * @return true: the character is part of a command and should not be written, - * false: the character should be written - */ -bool lv_txt_is_cmd(lv_txt_cmd_state_t * state, uint32_t c); - -/** - * Insert a string into an other - * @param txt_buf the original text (must be big enough for the result text) - * @param pos position to insert (0: before the original text, 1: after the first char etc.) - * @param ins_txt text to insert - */ -void lv_txt_ins(char * txt_buf, uint32_t pos, const char * ins_txt); - -/** - * Delete a part of a string - * @param txt string to modify - * @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_txt_cut(char * txt, uint32_t pos, uint32_t len); - -/*************************************************************** - * GLOBAL FUNCTION POINTERS FOR CAHRACTER ENCODING INTERFACE - ***************************************************************/ - -/** - * Give the size of an encoded character - * @param str pointer to a character in a string - * @return length of the encoded character (1,2,3 ...). O in invalid - */ -extern uint8_t (*lv_txt_encoded_size)(const char *); - -/** - * Convert an Unicode letter to encoded - * @param letter_uni an Unicode letter - * @return Encoded character in Little Endian to be compatible with C chars (e.g. 'Á', 'Ü') - */ -extern uint32_t (*lv_txt_unicode_to_encoded)(uint32_t); - -/** - * 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 (*lv_txt_encoded_conv_wc)(uint32_t c); - -/** - * Decode the next encoded character from 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 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 (*lv_txt_encoded_next)(const char *, uint32_t *); - -/** - * 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 (*lv_txt_encoded_prev)(const char *, uint32_t *); - -/** - * Convert a letter index (in an 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 enc_id letter index - * @return byte index of the 'enc_id'th letter - */ -extern uint32_t (*lv_txt_encoded_get_byte_id)(const char *, uint32_t); - -/** - * 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 (*lv_txt_encoded_get_char_id)(const char *, uint32_t); - -/** - * 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 (*lv_txt_get_encoded_length)(const char *); - -/********************** - * MACROS - **********************/ - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /*USE_TXT*/ diff --git a/src/libs/lvgl/src/lv_misc/lv_types.h b/src/libs/lvgl/src/lv_misc/lv_types.h deleted file mode 100644 index 2c28bca1..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_types.h +++ /dev/null @@ -1,64 +0,0 @@ -/** - * @file lv_types.h - * - */ - -#ifndef LV_TYPES_H -#define LV_TYPES_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ - -/********************* - * DEFINES - *********************/ -// Check windows -#ifdef _WIN64 -#define LV_ARCH_64 -#endif - -// Check GCC -#ifdef __GNUC__ -#if defined(__x86_64__) || defined(__ppc64__) -#define LV_ARCH_64 -#endif -#endif - -/********************** - * TYPEDEFS - **********************/ - -/** - * LittlevGL error codes. - */ -enum { - LV_RES_INV = 0, /*Typically indicates that the object is deleted (become invalid) in the action - function or an operation was failed*/ - LV_RES_OK, /*The object is valid (no deleted) after the action*/ -}; -typedef uint8_t lv_res_t; - -#ifdef LV_ARCH_64 -typedef uint64_t lv_uintptr_t; -#else -typedef uint32_t lv_uintptr_t; -#endif - -/********************** - * GLOBAL PROTOTYPES - **********************/ - -/********************** - * MACROS - **********************/ - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /*LV_TYPES_H*/ diff --git a/src/libs/lvgl/src/lv_misc/lv_utils.c b/src/libs/lvgl/src/lv_misc/lv_utils.c deleted file mode 100644 index 3f189560..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_utils.c +++ /dev/null @@ -1,115 +0,0 @@ -/** - * @file lv_utils.c - * - */ - -/********************* - * INCLUDES - *********************/ -#include <stdbool.h> - -#include "lv_utils.h" -#include "lv_math.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -/********************** - * STATIC VARIABLES - **********************/ - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -/** - * Convert a number to string - * @param num a number - * @param buf pointer to a `char` buffer. The result will be stored here (max 10 elements) - * @return same as `buf` (just for convenience) - */ -char * lv_utils_num_to_str(int32_t num, char * buf) -{ - if(num == 0) { - buf[0] = '0'; - buf[1] = '\0'; - return buf; - } - int8_t digitCount = 0; - int8_t i = 0; - if(num < 0) { - buf[digitCount++] = '-'; - num = LV_MATH_ABS(num); - ++i; - } - while(num) { - char digit = num % 10; - buf[digitCount++] = digit + 48; - num /= 10; - } - buf[digitCount] = '\0'; - digitCount--; - while(digitCount > i) { - char temp = buf[i]; - buf[i] = buf[digitCount]; - buf[digitCount] = temp; - digitCount--; - i++; - } - return buf; -} - -/** Searches base[0] to base[n - 1] for an item that matches *key. - * - * @note The function cmp must return negative if its first - * argument (the search key) is less that its 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 #lv_font_codeCompare 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, uint32_t n, uint32_t size, - int32_t (*cmp)(const void * pRef, const void * pElement)) -{ - const char * middle; - int32_t c; - - for(middle = base; n != 0;) { - middle += (n / 2) * size; - if((c = (*cmp)(key, middle)) > 0) { - n = (n / 2) - ((n & 1) == 0); - base = (middle += size); - } else if(c < 0) { - n /= 2; - middle = base; - } else { - return (char *)middle; - } - } - return NULL; -} - -/********************** - * STATIC FUNCTIONS - **********************/ diff --git a/src/libs/lvgl/src/lv_misc/lv_utils.h b/src/libs/lvgl/src/lv_misc/lv_utils.h deleted file mode 100644 index 6eed7950..00000000 --- a/src/libs/lvgl/src/lv_misc/lv_utils.h +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @file lv_utils.h - * - */ - -#ifndef LV_UTILS_H -#define LV_UTILS_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ -#include <stdint.h> -#include <stddef.h> - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * GLOBAL PROTOTYPES - **********************/ -/** - * Convert a number to string - * @param num a number - * @param buf pointer to a `char` buffer. The result will be stored here (max 10 elements) - * @return same as `buf` (just for convenience) - */ -char * lv_utils_num_to_str(int32_t num, char * buf); - -/** Searches base[0] to base[n - 1] for an item that matches *key. - * - * @note The function cmp must return negative if its first - * argument (the search key) is less that its 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 #lv_font_codeCompare 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, uint32_t n, uint32_t size, - int32_t (*cmp)(const void * pRef, const void * pElement)); - -/********************** - * MACROS - **********************/ - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif |