run astyle code formatter

This commit is contained in:
Gabor Kiss-Vamosi
2020-02-26 19:48:27 +01:00
parent 9d1a1d51d0
commit 41907f9f3c
149 changed files with 5105 additions and 4367 deletions

View File

@@ -77,7 +77,8 @@ static inline void lv_bar_set_sym(lv_obj_t * bar, bool en)
* @return true: symmetric is enabled; false: disable
* @deprecated As of v7.0, you should use `lv_bar_get_type` instead.
*/
static inline bool lv_bar_get_sym(lv_obj_t * bar) {
static inline bool lv_bar_get_sym(lv_obj_t * bar)
{
return lv_bar_get_type(bar) == LV_BAR_TYPE_SYM;
}
@@ -94,7 +95,7 @@ static inline bool lv_bar_get_sym(lv_obj_t * bar) {
*/
static inline void lv_slider_set_sym(lv_obj_t * slider, bool en)
{
lv_bar_set_sym(slider, en);
lv_bar_set_sym(slider, en);
}
/**
@@ -103,8 +104,9 @@ static inline void lv_slider_set_sym(lv_obj_t * slider, bool en)
* @return true: symmetric is enabled; false: disable
* @deprecated As of v7.0, you should use `lv_slider_get_type` instead.
*/
static inline bool lv_slider_get_sym(lv_obj_t * slider) {
return lv_bar_get_sym(slider);
static inline bool lv_slider_get_sym(lv_obj_t * slider)
{
return lv_bar_get_sym(slider);
}
#endif

View File

@@ -15,11 +15,11 @@
* DEFINES
*********************/
#ifndef LV_DEBUG_STR_MAX_LENGTH
#define LV_DEBUG_STR_MAX_LENGTH (1024 * 8)
#define LV_DEBUG_STR_MAX_LENGTH (1024 * 8)
#endif
#ifndef LV_DEBUG_STR_MAX_REPEAT
#define LV_DEBUG_STR_MAX_REPEAT 8
#define LV_DEBUG_STR_MAX_REPEAT 8
#endif
/**********************
* TYPEDEFS
@@ -126,7 +126,8 @@ bool lv_debug_check_str(const void * str)
if(s[i] != last_byte) {
last_byte = s[i];
rep = 1;
} else if(s[i] > 0x7F){
}
else if(s[i] > 0x7F) {
rep++;
if(rep > LV_DEBUG_STR_MAX_REPEAT) {
LV_LOG_WARN("lv_debug_check_str: a non-ASCII char has repeated more than LV_DEBUG_STR_MAX_REPEAT times)");
@@ -184,7 +185,8 @@ void lv_debug_log_error(const char * msg, uint64_t value)
*bufp = '\0';
LV_LOG_ERROR(buf);
} else {
}
else {
LV_LOG_ERROR(msg);
}
}

View File

@@ -50,13 +50,13 @@ void lv_debug_log_error(const char * msg, uint64_t value);
#ifndef LV_DEBUG_ASSERT
#define LV_DEBUG_ASSERT(expr, msg, value) \
do { \
if(!(expr)) { \
LV_LOG_ERROR(__func__); \
lv_debug_log_error(msg, (uint64_t)((uintptr_t)value)); \
while(1); \
} \
} while(0)
do { \
if(!(expr)) { \
LV_LOG_ERROR(__func__); \
lv_debug_log_error(msg, (uint64_t)((uintptr_t)value)); \
while(1); \
} \
} while(0)
#endif
/*----------------

View File

@@ -14,7 +14,7 @@
#include "../lv_misc/lv_gc.h"
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/*********************
@@ -93,8 +93,7 @@ void lv_group_del(lv_group_t * group)
/*Remove the objects from the group*/
lv_obj_t ** obj;
LV_LL_READ(group->obj_ll, obj)
{
LV_LL_READ(group->obj_ll, obj) {
(*obj)->group_p = NULL;
}
@@ -114,8 +113,7 @@ void lv_group_add_obj(lv_group_t * group, lv_obj_t * obj)
/*Do not add the object twice*/
lv_obj_t ** obj_i;
LV_LL_READ(group->obj_ll, obj_i)
{
LV_LL_READ(group->obj_ll, obj_i) {
if((*obj_i) == obj) {
LV_LOG_INFO("lv_group_add_obj: the object is already added to this group");
return;
@@ -175,8 +173,7 @@ void lv_group_remove_obj(lv_obj_t * obj)
/*Search the object and remove it from its group */
lv_obj_t ** i;
LV_LL_READ(g->obj_ll, i)
{
LV_LL_READ(g->obj_ll, i) {
if(*i == obj) {
lv_ll_remove(&g->obj_ll, i);
lv_mem_free(i);
@@ -201,8 +198,7 @@ void lv_group_remove_all_objs(lv_group_t * group)
/*Remove the objects from the group*/
lv_obj_t ** obj;
LV_LL_READ(group->obj_ll, obj)
{
LV_LL_READ(group->obj_ll, obj) {
(*obj)->group_p = NULL;
}
@@ -227,8 +223,7 @@ void lv_group_focus_obj(lv_obj_t * obj)
lv_group_set_editing(g, false);
lv_obj_t ** i;
LV_LL_READ(g->obj_ll, i)
{
LV_LL_READ(g->obj_ll, i) {
if(*i == obj) {
if(g->obj_focus != NULL) {
(*g->obj_focus)->signal_cb(*g->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
@@ -400,7 +395,8 @@ lv_style_t * lv_group_mod_style(lv_group_t * group, const lv_style_t * style)
if(group->editing) {
if(group->style_mod_edit_cb) group->style_mod_edit_cb(group, &group->style_tmp);
} else {
}
else {
if(group->style_mod_cb) group->style_mod_cb(group, &group->style_tmp);
}
return &group->style_tmp;
@@ -532,7 +528,8 @@ static void focus_next_core(lv_group_t * group, void * (*begin)(const lv_ll_t *)
obj_next = begin(&group->obj_ll);
can_move = false;
can_begin = false;
} else {
}
else {
/*Currently focused object is the last/first in the group, keep it that way*/
return;
}

View File

@@ -51,8 +51,7 @@ typedef void (*lv_group_focus_cb_t)(struct _lv_group_t *);
* Groups can be used to logically hold objects so that they can be individually focused.
* They are NOT for laying out objects on a screen (try `lv_cont` for that).
*/
typedef struct _lv_group_t
{
typedef struct _lv_group_t {
lv_ll_t obj_ll; /**< Linked list to store the objects in the group */
lv_obj_t ** obj_focus; /**< The object in focus*/

View File

@@ -21,7 +21,7 @@
*********************/
#if LV_INDEV_DEF_DRAG_THROW <= 0
#warning "LV_INDEV_DRAG_THROW must be greater than 0"
#warning "LV_INDEV_DRAG_THROW must be greater than 0"
#endif
/**********************
@@ -101,17 +101,21 @@ void lv_indev_read_task(lv_task_t * task)
/*Save the last activity time*/
if(indev_act->proc.state == LV_INDEV_STATE_PR) {
indev_act->driver.disp->last_activity_time = lv_tick_get();
} else if(indev_act->driver.type == LV_INDEV_TYPE_ENCODER && data.enc_diff) {
}
else if(indev_act->driver.type == LV_INDEV_TYPE_ENCODER && data.enc_diff) {
indev_act->driver.disp->last_activity_time = lv_tick_get();
}
if(indev_act->driver.type == LV_INDEV_TYPE_POINTER) {
indev_pointer_proc(indev_act, &data);
} else if(indev_act->driver.type == LV_INDEV_TYPE_KEYPAD) {
}
else if(indev_act->driver.type == LV_INDEV_TYPE_KEYPAD) {
indev_keypad_proc(indev_act, &data);
} else if(indev_act->driver.type == LV_INDEV_TYPE_ENCODER) {
}
else if(indev_act->driver.type == LV_INDEV_TYPE_ENCODER) {
indev_encoder_proc(indev_act, &data);
} else if(indev_act->driver.type == LV_INDEV_TYPE_BUTTON) {
}
else if(indev_act->driver.type == LV_INDEV_TYPE_BUTTON) {
indev_button_proc(indev_act, &data);
}
/*Handle reset query if it happened in during processing*/
@@ -159,7 +163,8 @@ void lv_indev_reset(lv_indev_t * indev, lv_obj_t * obj)
if(obj == NULL || indev->proc.types.pointer.last_pressed == obj) {
indev->proc.types.pointer.last_pressed = NULL;
}
} else {
}
else {
lv_indev_t * i = lv_indev_get_next(NULL);
while(i) {
i->proc.reset_query = 1;
@@ -245,7 +250,8 @@ void lv_indev_get_point(const lv_indev_t * indev, lv_point_t * point)
if(indev->driver.type != LV_INDEV_TYPE_POINTER && indev->driver.type != LV_INDEV_TYPE_BUTTON) {
point->x = -1;
point->y = -1;
} else {
}
else {
point->x = indev->proc.types.pointer.act_point.x;
point->y = indev->proc.types.pointer.act_point.y;
}
@@ -304,7 +310,8 @@ void lv_indev_get_vect(const lv_indev_t * indev, lv_point_t * point)
if(indev->driver.type != LV_INDEV_TYPE_POINTER && indev->driver.type != LV_INDEV_TYPE_BUTTON) {
point->x = 0;
point->y = 0;
} else {
}
else {
point->x = indev->proc.types.pointer.vect.x;
point->y = indev->proc.types.pointer.vect.y;
}
@@ -396,7 +403,8 @@ static void indev_pointer_proc(lv_indev_t * i, lv_indev_data_t * data)
if(i->proc.state == LV_INDEV_STATE_PR) {
indev_proc_press(&i->proc);
} else {
}
else {
indev_proc_release(&i->proc);
}
@@ -453,7 +461,8 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
if(indev_reset_check(&i->proc)) return;
lv_event_send(indev_obj_act, LV_EVENT_PRESSED, NULL);
if(indev_reset_check(&i->proc)) return;
} else if(data->key == LV_KEY_ESC) {
}
else if(data->key == LV_KEY_ESC) {
/*Send the ESC as a normal KEY*/
lv_group_send_data(g, LV_KEY_ESC);
@@ -589,7 +598,8 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
int32_t s;
if(data->enc_diff < 0) {
for(s = 0; s < -data->enc_diff; s++) lv_group_send_data(g, LV_KEY_LEFT);
} else if(data->enc_diff > 0) {
}
else if(data->enc_diff > 0) {
for(s = 0; s < data->enc_diff; s++) lv_group_send_data(g, LV_KEY_RIGHT);
}
}
@@ -598,7 +608,8 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
int32_t s;
if(data->enc_diff < 0) {
for(s = 0; s < -data->enc_diff; s++) lv_group_focus_prev(g);
} else if(data->enc_diff > 0) {
}
else if(data->enc_diff > 0) {
for(s = 0; s < data->enc_diff; s++) lv_group_focus_next(g);
}
}
@@ -715,7 +726,8 @@ static void indev_button_proc(lv_indev_t * i, lv_indev_data_t * data)
if(i->proc.types.pointer.last_point.x == i->proc.types.pointer.act_point.x &&
i->proc.types.pointer.last_point.y == i->proc.types.pointer.act_point.y && data->state == LV_INDEV_STATE_PR) {
indev_proc_press(&i->proc);
} else {
}
else {
/*If a new point comes always make a release*/
indev_proc_release(&i->proc);
}
@@ -741,16 +753,20 @@ static void indev_proc_press(lv_indev_proc_t * proc)
/*If there is no last object then search*/
if(indev_obj_act == NULL) {
indev_obj_act = lv_indev_search_obj(lv_disp_get_layer_sys(disp), &proc->types.pointer.act_point);
if(indev_obj_act == NULL) indev_obj_act = lv_indev_search_obj(lv_disp_get_layer_top(disp), &proc->types.pointer.act_point);
if(indev_obj_act == NULL) indev_obj_act = lv_indev_search_obj(lv_disp_get_scr_act(disp), &proc->types.pointer.act_point);
if(indev_obj_act == NULL) indev_obj_act = lv_indev_search_obj(lv_disp_get_layer_top(disp),
&proc->types.pointer.act_point);
if(indev_obj_act == NULL) indev_obj_act = lv_indev_search_obj(lv_disp_get_scr_act(disp),
&proc->types.pointer.act_point);
new_obj_searched = true;
}
/*If there is last object but it is not dragged and not protected also search*/
else if(proc->types.pointer.drag_in_prog == 0 &&
lv_obj_is_protected(indev_obj_act, LV_PROTECT_PRESS_LOST) == false) {
indev_obj_act = lv_indev_search_obj(lv_disp_get_layer_sys(disp), &proc->types.pointer.act_point);
if(indev_obj_act == NULL) indev_obj_act = lv_indev_search_obj(lv_disp_get_layer_top(disp), &proc->types.pointer.act_point);
if(indev_obj_act == NULL) indev_obj_act = lv_indev_search_obj(lv_disp_get_scr_act(disp), &proc->types.pointer.act_point);
if(indev_obj_act == NULL) indev_obj_act = lv_indev_search_obj(lv_disp_get_layer_top(disp),
&proc->types.pointer.act_point);
if(indev_obj_act == NULL) indev_obj_act = lv_indev_search_obj(lv_disp_get_scr_act(disp),
&proc->types.pointer.act_point);
new_obj_searched = true;
}
/*If a dragable or a protected object was the last then keep it*/
@@ -1009,7 +1025,7 @@ static void indev_proc_reset_query_handler(lv_indev_t * indev)
* @param point pointer to a point for searhing the most top child
* @return pointer to the found object or NULL if there was no suitable object
*/
lv_obj_t * lv_indev_search_obj(lv_obj_t * obj, lv_point_t *point)
lv_obj_t * lv_indev_search_obj(lv_obj_t * obj, lv_point_t * point)
{
lv_obj_t * found_p = NULL;
@@ -1017,8 +1033,7 @@ lv_obj_t * lv_indev_search_obj(lv_obj_t * obj, lv_point_t *point)
if(lv_obj_hittest(obj, point)) {
lv_obj_t * i;
LV_LL_READ(obj->child_ll, i)
{
LV_LL_READ(obj->child_ll, i) {
found_p = lv_indev_search_obj(i, point);
/*If a child was found then break*/
@@ -1029,7 +1044,8 @@ lv_obj_t * lv_indev_search_obj(lv_obj_t * obj, lv_point_t *point)
/*If then the children was not ok, and this obj is clickable
* and it or its parent is not hidden then save this object*/
if(found_p == NULL && lv_obj_get_click(obj) != false && (lv_obj_get_state(obj, LV_OBJ_PART_MAIN) & LV_STATE_DISABLED) == 0) {
if(found_p == NULL && lv_obj_get_click(obj) != false &&
(lv_obj_get_state(obj, LV_OBJ_PART_MAIN) & LV_STATE_DISABLED) == 0) {
lv_obj_t * hidden_i = obj;
while(hidden_i != NULL) {
if(lv_obj_get_hidden(hidden_i) == true) break;
@@ -1051,7 +1067,7 @@ static void indev_click_focus(lv_indev_proc_t * proc)
{
/*Handle click focus*/
if(lv_obj_is_protected(indev_obj_act, LV_PROTECT_CLICK_FOCUS) == false &&
proc->types.pointer.last_pressed != indev_obj_act) {
proc->types.pointer.last_pressed != indev_obj_act) {
#if LV_USE_GROUP
lv_group_t * g_act = lv_obj_get_group(indev_obj_act);
lv_group_t * g_prev = proc->types.pointer.last_pressed ? lv_obj_get_group(proc->types.pointer.last_pressed) : NULL;
@@ -1170,7 +1186,8 @@ static void indev_drag(lv_indev_proc_t * proc)
if(allowed_dirs == LV_DRAG_DIR_ONE) {
if(LV_MATH_ABS(proc->types.pointer.drag_sum.x) > LV_MATH_ABS(proc->types.pointer.drag_sum.y)) {
hor_en = true;
} else {
}
else {
ver_en = true;
}
}
@@ -1203,25 +1220,29 @@ static void indev_drag(lv_indev_proc_t * proc)
act_x += proc->types.pointer.drag_sum.x;
act_y += proc->types.pointer.drag_sum.y;
}
} else if(allowed_dirs == LV_DRAG_DIR_HOR) {
}
else if(allowed_dirs == LV_DRAG_DIR_HOR) {
if(drag_just_started) {
proc->types.pointer.drag_dir = LV_DRAG_DIR_HOR;
proc->types.pointer.drag_sum.y = 0;
act_x += proc->types.pointer.drag_sum.x;
}
} else if(allowed_dirs == LV_DRAG_DIR_VER) {
}
else if(allowed_dirs == LV_DRAG_DIR_VER) {
if(drag_just_started) {
proc->types.pointer.drag_dir = LV_DRAG_DIR_VER;
proc->types.pointer.drag_sum.x = 0;
act_y += proc->types.pointer.drag_sum.y;
}
} else if(allowed_dirs == LV_DRAG_DIR_ONE) {
}
else if(allowed_dirs == LV_DRAG_DIR_ONE) {
if(drag_just_started) {
if(LV_MATH_ABS(proc->types.pointer.drag_sum.x) > LV_MATH_ABS(proc->types.pointer.drag_sum.y)) {
proc->types.pointer.drag_dir = LV_DRAG_DIR_HOR;
proc->types.pointer.drag_sum.y = 0;
act_x += proc->types.pointer.drag_sum.x;
} else {
}
else {
proc->types.pointer.drag_dir = LV_DRAG_DIR_VER;
proc->types.pointer.drag_sum.x = 0;
act_y += proc->types.pointer.drag_sum.y;
@@ -1374,51 +1395,51 @@ static lv_obj_t * get_dragged_obj(lv_obj_t * obj)
static void indev_gesture(lv_indev_proc_t * proc)
{
if (proc->types.pointer.drag_in_prog) return;
if (proc->types.pointer.gesture_sent) return;
if(proc->types.pointer.drag_in_prog) return;
if(proc->types.pointer.gesture_sent) return;
lv_obj_t * gesture_obj = proc->types.pointer.act_obj;
lv_obj_t * gesture_obj = proc->types.pointer.act_obj;
/*If gesture parent is active check recursively the drag_parent attribute*/
while (gesture_obj && lv_obj_get_gesture_parent(gesture_obj)) {
gesture_obj = lv_obj_get_parent(gesture_obj);
}
/*If gesture parent is active check recursively the drag_parent attribute*/
while(gesture_obj && lv_obj_get_gesture_parent(gesture_obj)) {
gesture_obj = lv_obj_get_parent(gesture_obj);
}
if (gesture_obj == NULL) return;
if(gesture_obj == NULL) return;
if ((LV_MATH_ABS(proc->types.pointer.vect.x) < indev_act->driver.gesture_min_velocity) &&
(LV_MATH_ABS(proc->types.pointer.vect.y) < indev_act->driver.gesture_min_velocity)) {
proc->types.pointer.gesture_sum.x = 0;
proc->types.pointer.gesture_sum.y = 0;
}
if((LV_MATH_ABS(proc->types.pointer.vect.x) < indev_act->driver.gesture_min_velocity) &&
(LV_MATH_ABS(proc->types.pointer.vect.y) < indev_act->driver.gesture_min_velocity)) {
proc->types.pointer.gesture_sum.x = 0;
proc->types.pointer.gesture_sum.y = 0;
}
/*Count the movement by gesture*/
proc->types.pointer.gesture_sum.x += proc->types.pointer.vect.x;
proc->types.pointer.gesture_sum.y += proc->types.pointer.vect.y;
/*Count the movement by gesture*/
proc->types.pointer.gesture_sum.x += proc->types.pointer.vect.x;
proc->types.pointer.gesture_sum.y += proc->types.pointer.vect.y;
if ((LV_MATH_ABS(proc->types.pointer.gesture_sum.x) > indev_act->driver.gesture_limit) ||
(LV_MATH_ABS(proc->types.pointer.gesture_sum.y) > indev_act->driver.gesture_limit)){
if((LV_MATH_ABS(proc->types.pointer.gesture_sum.x) > indev_act->driver.gesture_limit) ||
(LV_MATH_ABS(proc->types.pointer.gesture_sum.y) > indev_act->driver.gesture_limit)) {
proc->types.pointer.gesture_sent = 1;
proc->types.pointer.gesture_sent = 1;
if (LV_MATH_ABS(proc->types.pointer.gesture_sum.x) > LV_MATH_ABS(proc->types.pointer.gesture_sum.y)){
if (proc->types.pointer.gesture_sum.x > 0)
proc->types.pointer.gesture_dir = LV_GESTURE_DIR_RIGHT;
else
proc->types.pointer.gesture_dir = LV_GESTURE_DIR_LEFT;
}
else{
if (proc->types.pointer.gesture_sum.y > 0)
proc->types.pointer.gesture_dir = LV_GESTURE_DIR_BOTTOM;
else
proc->types.pointer.gesture_dir = LV_GESTURE_DIR_TOP;
}
if(LV_MATH_ABS(proc->types.pointer.gesture_sum.x) > LV_MATH_ABS(proc->types.pointer.gesture_sum.y)) {
if(proc->types.pointer.gesture_sum.x > 0)
proc->types.pointer.gesture_dir = LV_GESTURE_DIR_RIGHT;
else
proc->types.pointer.gesture_dir = LV_GESTURE_DIR_LEFT;
}
else {
if(proc->types.pointer.gesture_sum.y > 0)
proc->types.pointer.gesture_dir = LV_GESTURE_DIR_BOTTOM;
else
proc->types.pointer.gesture_dir = LV_GESTURE_DIR_TOP;
}
gesture_obj->signal_cb(gesture_obj, LV_SIGNAL_GESTURE, indev_act);
if (indev_reset_check(proc)) return;
lv_event_send(gesture_obj, LV_EVENT_GESTURE, NULL);
if (indev_reset_check(proc)) return;
}
gesture_obj->signal_cb(gesture_obj, LV_SIGNAL_GESTURE, indev_act);
if(indev_reset_check(proc)) return;
lv_event_send(gesture_obj, LV_EVENT_GESTURE, NULL);
if(indev_reset_check(proc)) return;
}
}

View File

@@ -170,7 +170,7 @@ lv_obj_t * lv_indev_get_obj_act(void);
* @param point pointer to a point for searhing the most top child
* @return pointer to the found object or NULL if there was no suitable object
*/
lv_obj_t * lv_indev_search_obj(lv_obj_t * obj, lv_point_t *point);
lv_obj_t * lv_indev_search_obj(lv_obj_t * obj, lv_point_t * point);
/**********************
* MACROS

View File

@@ -28,12 +28,12 @@
#include <string.h>
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
#if defined(LV_USER_DATA_FREE_INCLUDE)
#include LV_USER_DATA_FREE_INCLUDE
#include LV_USER_DATA_FREE_INCLUDE
#endif /* LV_USE_USER_DATA_FREE */
/*********************
@@ -47,8 +47,7 @@
/**********************
* TYPEDEFS
**********************/
typedef struct _lv_event_temp_data
{
typedef struct _lv_event_temp_data {
lv_obj_t * obj;
bool deleted;
struct _lv_event_temp_data * prev;
@@ -63,14 +62,14 @@ typedef struct {
lv_style_int_t _int;
lv_opa_t _opa;
const void * _ptr;
}start_value;
} start_value;
union {
lv_color_t _color;
lv_style_int_t _int;
lv_opa_t _opa;
const void * _ptr;
}end_value;
}lv_style_trans_t;
} end_value;
} lv_style_trans_t;
/**********************
* STATIC PROTOTYPES
@@ -83,12 +82,13 @@ static void refresh_children_style(lv_obj_t * obj);
static void delete_children(lv_obj_t * obj);
static void base_dir_refr_children(lv_obj_t * obj);
#if LV_USE_ANIMATION
static lv_style_trans_t * trans_create(lv_obj_t * obj, lv_style_property_t prop, uint8_t part, lv_state_t prev_state, lv_state_t new_state);
static void trans_del(lv_obj_t * obj, uint8_t part, lv_style_property_t prop);
static void trans_anim_cb(lv_style_trans_t * tr, lv_anim_value_t v);
static void trans_anim_start_cb(lv_anim_t * a);
static void trans_anim_ready_cb(lv_anim_t * a);
static void opa_scale_anim(lv_obj_t * obj, lv_anim_value_t v);
static lv_style_trans_t * trans_create(lv_obj_t * obj, lv_style_property_t prop, uint8_t part, lv_state_t prev_state,
lv_state_t new_state);
static void trans_del(lv_obj_t * obj, uint8_t part, lv_style_property_t prop);
static void trans_anim_cb(lv_style_trans_t * tr, lv_anim_value_t v);
static void trans_anim_start_cb(lv_anim_t * a);
static void trans_anim_ready_cb(lv_anim_t * a);
static void opa_scale_anim(lv_obj_t * obj, lv_anim_value_t v);
#endif
static void lv_event_mark_deleted(lv_obj_t * obj);
static void lv_obj_del_async_cb(void * obj);
@@ -140,8 +140,8 @@ void lv_init(void)
lv_ll_init(&LV_GC_ROOT(_lv_obj_style_trans_ll), sizeof(lv_style_trans_t));
lv_theme_t * th = LV_THEME_DEFAULT_INIT(LV_THEME_DEFAULT_COLOR_PRIMARY, LV_THEME_DEFAULT_COLOR_SECONDARY,
LV_THEME_DEFAULT_FLAGS,
LV_THEME_DEFAULT_FONT_SMALL, LV_THEME_DEFAULT_FONT_NORMAL, LV_THEME_DEFAULT_FONT_SUBTITLE, LV_THEME_DEFAULT_FONT_TITLE);
LV_THEME_DEFAULT_FLAGS,
LV_THEME_DEFAULT_FONT_SMALL, LV_THEME_DEFAULT_FONT_NORMAL, LV_THEME_DEFAULT_FONT_SUBTITLE, LV_THEME_DEFAULT_FONT_TITLE);
lv_theme_set_act(th);
/*Initialize the screen refresh system*/
@@ -234,7 +234,8 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
if(lv_obj_get_base_dir(new_obj) == LV_BIDI_DIR_RTL) {
new_obj->coords.x2 = parent->coords.x2;
new_obj->coords.x1 = parent->coords.x2 - LV_OBJ_DEF_WIDTH;
} else {
}
else {
new_obj->coords.x1 = parent->coords.x1;
new_obj->coords.x2 = parent->coords.x1 + LV_OBJ_DEF_WIDTH;
}
@@ -304,7 +305,8 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
if(copy == NULL) {
if(parent != NULL) lv_theme_apply(new_obj, LV_THEME_OBJ);
else lv_theme_apply(new_obj, LV_THEME_SCR);
} else {
}
else {
lv_style_list_copy(&new_obj->style_list, &copy->style_list);
}
/*Copy the attributes if required*/
@@ -451,7 +453,8 @@ lv_res_t lv_obj_del(lv_obj_t * obj)
if(par == NULL) { /*It is a screen*/
lv_disp_t * d = lv_obj_get_disp(obj);
lv_ll_remove(&d->scr_ll, obj);
} else {
}
else {
lv_ll_remove(&(par->child_ll), obj);
}
@@ -613,7 +616,8 @@ void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent)
if(new_base_dir != LV_BIDI_DIR_RTL) {
old_pos.x = lv_obj_get_x(obj);
} else {
}
else {
old_pos.x = old_par->coords.x2 - obj->coords.x2;
}
@@ -623,10 +627,11 @@ void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent)
if(new_base_dir != LV_BIDI_DIR_RTL) {
lv_obj_set_pos(obj, old_pos.x, old_pos.y);
} else {
}
else {
/*Align to the right in case of RTL base dir*/
lv_coord_t new_x = lv_obj_get_width(parent) - old_pos.x - lv_obj_get_width(obj);
lv_obj_set_pos(obj, new_x , old_pos.y);
lv_obj_set_pos(obj, new_x, old_pos.y);
}
/*Notify the original parent because one of its children is lost*/
@@ -795,7 +800,8 @@ void lv_obj_set_size(lv_obj_t * obj, lv_coord_t w, lv_coord_t h)
obj->coords.y2 = obj->coords.y1 + h - 1;
if(lv_obj_get_base_dir(obj) == LV_BIDI_DIR_RTL) {
obj->coords.x1 = obj->coords.x2 - w + 1;
} else {
}
else {
obj->coords.x2 = obj->coords.x1 + w - 1;
}
@@ -1303,8 +1309,7 @@ void lv_obj_report_style_mod(lv_style_t * style)
while(d) {
lv_obj_t * i;
LV_LL_READ(d->scr_ll, i)
{
LV_LL_READ(d->scr_ll, i) {
report_style_mod_core(style, i);
}
d = lv_disp_get_next(d);
@@ -1339,7 +1344,8 @@ void lv_obj_set_hidden(lv_obj_t * obj, bool en)
* @param obj pointer to an object
* @param en true: advanced hit-testing is enabled
*/
void lv_obj_set_adv_hittest(lv_obj_t * obj, bool en) {
void lv_obj_set_adv_hittest(lv_obj_t * obj, bool en)
{
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
obj->adv_hittest = en == false ? 0 : 1;
@@ -1545,7 +1551,8 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state)
if(time == 0) {
trans_anim_cb(tr, 255);
} else {
}
else {
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_var(&a, tr);
@@ -1612,17 +1619,17 @@ void lv_obj_clear_state(lv_obj_t * obj, lv_state_t state)
*/
void lv_obj_finish_transitions(lv_obj_t * obj, uint8_t part)
{
/*Animate all related transition to the end value*/
lv_style_trans_t * tr;
tr = lv_ll_get_head(&LV_GC_ROOT(_lv_obj_style_trans_ll));
LV_LL_READ(LV_GC_ROOT(_lv_obj_style_trans_ll), tr) {
if(tr->obj == obj && (part == tr->part || part == LV_OBJ_PART_ALL)) {
trans_anim_cb(tr, 255);
}
}
/*Animate all related transition to the end value*/
lv_style_trans_t * tr;
tr = lv_ll_get_head(&LV_GC_ROOT(_lv_obj_style_trans_ll));
LV_LL_READ(LV_GC_ROOT(_lv_obj_style_trans_ll), tr) {
if(tr->obj == obj && (part == tr->part || part == LV_OBJ_PART_ALL)) {
trans_anim_cb(tr, 255);
}
}
/*Free all related transition data*/
trans_del(obj, part, 0xFF);
/*Free all related transition data*/
trans_del(obj, part, 0xFF);
}
#endif
@@ -1847,11 +1854,9 @@ lv_disp_t * lv_obj_get_disp(const lv_obj_t * obj)
scr = lv_obj_get_screen(obj); /*get the screen of `obj`*/
lv_disp_t * d;
LV_LL_READ(LV_GC_ROOT(_lv_disp_ll), d)
{
LV_LL_READ(LV_GC_ROOT(_lv_disp_ll), d) {
lv_obj_t * s;
LV_LL_READ(d->scr_ll, s)
{
LV_LL_READ(d->scr_ll, s) {
if(s == scr) return d;
}
}
@@ -1891,7 +1896,8 @@ lv_obj_t * lv_obj_get_child(const lv_obj_t * obj, const lv_obj_t * child)
if(child == NULL) {
result = lv_ll_get_head(&obj->child_ll);
} else {
}
else {
result = lv_ll_get_next(&obj->child_ll, child);
}
@@ -1913,7 +1919,8 @@ lv_obj_t * lv_obj_get_child_back(const lv_obj_t * obj, const lv_obj_t * child)
if(child == NULL) {
result = lv_ll_get_tail(&obj->child_ll);
} else {
}
else {
result = lv_ll_get_prev(&obj->child_ll, child);
}
@@ -1948,8 +1955,7 @@ uint16_t lv_obj_count_children_recursive(const lv_obj_t * obj)
lv_obj_t * i;
uint16_t cnt = 0;
LV_LL_READ(obj->child_ll, i)
{
LV_LL_READ(obj->child_ll, i) {
cnt++; /*Count the child*/
cnt += lv_obj_count_children_recursive(i); /*recursively count children's children*/
}
@@ -2007,7 +2013,8 @@ lv_coord_t lv_obj_get_x(const lv_obj_t * obj)
lv_obj_t * parent = lv_obj_get_parent(obj);
if(parent) {
rel_x = obj->coords.x1 - parent->coords.x1;
} else {
}
else {
rel_x = obj->coords.x1;
}
return rel_x;
@@ -2024,11 +2031,12 @@ lv_coord_t lv_obj_get_y(const lv_obj_t * obj)
lv_coord_t rel_y;
lv_obj_t * parent = lv_obj_get_parent(obj);
if(parent) {
rel_y = obj->coords.y1 - parent->coords.y1;
} else {
rel_y = obj->coords.y1;
}
if(parent) {
rel_y = obj->coords.y1 - parent->coords.y1;
}
else {
rel_y = obj->coords.y1;
}
return rel_y;
}
@@ -2197,14 +2205,14 @@ lv_coord_t lv_obj_get_ext_draw_pad(const lv_obj_t * obj)
lv_style_list_t * lv_obj_get_style_list(const lv_obj_t * obj, uint8_t part)
{
if(part == LV_OBJ_PART_MAIN) return &((lv_obj_t*)obj)->style_list;
if(part == LV_OBJ_PART_MAIN) return &((lv_obj_t *)obj)->style_list;
lv_get_style_info_t info;
info.part = part;
info.result = NULL;
lv_get_style_info_t info;
info.part = part;
info.result = NULL;
lv_res_t res;
res = lv_signal_send((lv_obj_t*)obj, LV_SIGNAL_GET_STYLE, &info);
res = lv_signal_send((lv_obj_t *)obj, LV_SIGNAL_GET_STYLE, &info);
if(res != LV_RES_OK) return NULL;
@@ -2259,14 +2267,14 @@ lv_style_int_t _lv_obj_get_style_int(const lv_obj_t * obj, uint8_t part, lv_styl
/*Handle unset values*/
prop = prop & (~LV_STYLE_STATE_MASK);
switch(prop) {
case LV_STYLE_BORDER_SIDE:
return LV_BORDER_SIDE_FULL;
case LV_STYLE_SIZE:
return LV_DPI / 20;
case LV_STYLE_SCALE_WIDTH:
return LV_DPI / 8;
case LV_STYLE_BG_GRAD_STOP:
return 255;
case LV_STYLE_BORDER_SIDE:
return LV_BORDER_SIDE_FULL;
case LV_STYLE_SIZE:
return LV_DPI / 20;
case LV_STYLE_SCALE_WIDTH:
return LV_DPI / 8;
case LV_STYLE_BG_GRAD_STOP:
return 255;
}
return 0;
@@ -2320,9 +2328,9 @@ lv_color_t _lv_obj_get_style_color(const lv_obj_t * obj, uint8_t part, lv_style_
/*Handle unset values*/
prop = prop & (~LV_STYLE_STATE_MASK);
switch(prop) {
case LV_STYLE_BG_COLOR:
case LV_STYLE_BG_GRAD_COLOR:
return LV_COLOR_WHITE;
case LV_STYLE_BG_COLOR:
case LV_STYLE_BG_GRAD_COLOR:
return LV_COLOR_WHITE;
}
return LV_COLOR_BLACK;
@@ -2376,10 +2384,10 @@ lv_opa_t _lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t part, lv_style_prop
/*Handle unset values*/
prop = prop & (~LV_STYLE_STATE_MASK);
switch(prop) {
case LV_STYLE_BG_OPA:
case LV_STYLE_IMAGE_RECOLOR_OPA:
case LV_STYLE_PATTERN_RECOLOR_OPA:
return LV_OPA_TRANSP;
case LV_STYLE_BG_OPA:
case LV_STYLE_IMAGE_RECOLOR_OPA:
case LV_STYLE_PATTERN_RECOLOR_OPA:
return LV_OPA_TRANSP;
}
return LV_OPA_COVER;
@@ -2433,12 +2441,12 @@ const void * _lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_
/*Handle unset values*/
prop = prop & (~LV_STYLE_STATE_MASK);
switch(prop) {
case LV_STYLE_TEXT_FONT:
case LV_STYLE_VALUE_FONT:
return LV_THEME_DEFAULT_FONT_NORMAL;
case LV_STYLE_TEXT_FONT:
case LV_STYLE_VALUE_FONT:
return LV_THEME_DEFAULT_FONT_NORMAL;
#if LV_USE_ANIMATION
case LV_STYLE_TRANSITION_PATH:
return lv_anim_path_linear;
case LV_STYLE_TRANSITION_PATH:
return lv_anim_path_linear;
#endif
}
@@ -2627,7 +2635,7 @@ lv_state_t lv_obj_get_state(const lv_obj_t * obj, uint8_t part)
{
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
if(part < _LV_OBJ_PART_REAL_LAST) return ((lv_obj_t*)obj)->state;
if(part < _LV_OBJ_PART_REAL_LAST) return ((lv_obj_t *)obj)->state;
/*If a real part is asked, then use the object's signal to get its state.
* A real object can be in different state then the main part
@@ -2635,7 +2643,7 @@ lv_state_t lv_obj_get_state(const lv_obj_t * obj, uint8_t part)
lv_get_state_info_t info;
info.part = part;
info.result = LV_STATE_DEFAULT;
lv_signal_send((lv_obj_t*)obj, LV_SIGNAL_GET_STATE_DSC, &info);
lv_signal_send((lv_obj_t *)obj, LV_SIGNAL_GET_STATE_DSC, &info);
return info.result;
@@ -2806,7 +2814,8 @@ bool lv_obj_is_focused(const lv_obj_t * obj)
* @param obj object to check
* @param point screen-space point
*/
bool lv_obj_is_point_on_coords(lv_obj_t * obj, const lv_point_t * point) {
bool lv_obj_is_point_on_coords(lv_obj_t * obj, const lv_point_t * point)
{
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY
lv_area_t ext_area;
ext_area.x1 = obj->coords.x1 - obj->ext_click_pad_hor;
@@ -2837,14 +2846,16 @@ bool lv_obj_is_point_on_coords(lv_obj_t * obj, const lv_point_t * point) {
* @param point screen-space point
* @return true if the object is considered under the point
*/
bool lv_obj_hittest(lv_obj_t * obj, lv_point_t * point) {
bool lv_obj_hittest(lv_obj_t * obj, lv_point_t * point)
{
if(obj->adv_hittest) {
lv_hit_test_info_t hit_info;
hit_info.point = point;
hit_info.result = true;
obj->signal_cb(obj, LV_SIGNAL_HIT_TEST, &hit_info);
return hit_info.result;
} else
}
else
return lv_obj_is_point_on_coords(obj, point);
}
@@ -2881,7 +2892,7 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
#if LV_USE_OPA_SCALE
lv_opa_t opa_scale = lv_obj_get_style_opa_scale(obj, part);
if(opa_scale <= LV_OPA_MIN) {
draw_dsc->bg_opa = LV_OPA_TRANSP;
draw_dsc->bg_opa = LV_OPA_TRANSP;
draw_dsc->border_opa = LV_OPA_TRANSP;
draw_dsc->shadow_opa = LV_OPA_TRANSP;
draw_dsc->pattern_opa = LV_OPA_TRANSP;
@@ -2946,7 +2957,8 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
if(lv_img_src_get_type(draw_dsc->pattern_image) == LV_IMG_SRC_SYMBOL) {
draw_dsc->pattern_recolor = lv_obj_get_style_pattern_recolor(obj, part);
draw_dsc->pattern_font = lv_obj_get_style_text_font(obj, part);
} else if(draw_dsc->pattern_recolor_opa > LV_OPA_MIN ) {
}
else if(draw_dsc->pattern_recolor_opa > LV_OPA_MIN) {
draw_dsc->pattern_recolor = lv_obj_get_style_pattern_recolor(obj, part);
}
#if LV_USE_BLEND_MODES
@@ -3106,7 +3118,7 @@ lv_coord_t lv_obj_get_draw_rect_ext_pad_size(lv_obj_t * obj, uint8_t part)
sh_width++;
sh_width += lv_obj_get_style_shadow_spread(obj, part);
sh_width += LV_MATH_MAX(LV_MATH_ABS(lv_obj_get_style_shadow_ofs_x(obj, part)),
LV_MATH_ABS(lv_obj_get_style_shadow_ofs_y(obj, part)));
LV_MATH_ABS(lv_obj_get_style_shadow_ofs_y(obj, part)));
s = LV_MATH_MAX(s, sh_width);
}
}
@@ -3172,18 +3184,18 @@ lv_coord_t lv_obj_get_draw_rect_ext_pad_size(lv_obj_t * obj, uint8_t part)
void lv_obj_fade_in(lv_obj_t * obj, uint32_t time, uint32_t delay)
{
#if LV_USE_ANIMATION
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_var(&a, obj);
lv_anim_set_values(&a, LV_OPA_TRANSP, LV_OPA_COVER);
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)opa_scale_anim);
lv_anim_set_time(&a, time);
lv_anim_set_delay(&a, delay);
lv_anim_start(&a);
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_var(&a, obj);
lv_anim_set_values(&a, LV_OPA_TRANSP, LV_OPA_COVER);
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)opa_scale_anim);
lv_anim_set_time(&a, time);
lv_anim_set_delay(&a, delay);
lv_anim_start(&a);
#else
(void) obj; /*Unused*/
(void) time; /*Unused*/
(void) delay; /*Unused*/
(void) obj; /*Unused*/
(void) time; /*Unused*/
(void) delay; /*Unused*/
#endif
}
@@ -3196,18 +3208,18 @@ void lv_obj_fade_in(lv_obj_t * obj, uint32_t time, uint32_t delay)
void lv_obj_fade_out(lv_obj_t * obj, uint32_t time, uint32_t delay)
{
#if LV_USE_ANIMATION
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_var(&a, obj);
lv_anim_set_values(&a, LV_OPA_COVER, LV_OPA_TRANSP);
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)opa_scale_anim);
lv_anim_set_time(&a, time);
lv_anim_set_delay(&a, delay);
lv_anim_start(&a);
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_var(&a, obj);
lv_anim_set_values(&a, LV_OPA_COVER, LV_OPA_TRANSP);
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)opa_scale_anim);
lv_anim_set_time(&a, time);
lv_anim_set_delay(&a, delay);
lv_anim_start(&a);
#else
(void) obj; /*Unused*/
(void) time; /*Unused*/
(void) delay; /*Unused*/
(void) obj; /*Unused*/
(void) time; /*Unused*/
(void) delay; /*Unused*/
#endif
}
@@ -3344,7 +3356,8 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
if(sign == LV_SIGNAL_CHILD_CHG) {
/*Return 'invalid' if the child change signal is not enabled*/
if(lv_obj_is_protected(obj, LV_PROTECT_CHILD_CHG) != false) res = LV_RES_INV;
} else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
}
else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
obj->ext_draw_pad = LV_MATH_MAX(obj->ext_draw_pad, lv_obj_get_draw_rect_ext_pad_size(obj, LV_OBJ_PART_MAIN));
}
#if LV_USE_OBJ_REALIGN
@@ -3369,11 +3382,13 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
uint8_t state = LV_STATE_FOCUSED;
state |= LV_STATE_EDITED;
lv_obj_add_state(obj, state);
} else {
}
else {
lv_obj_add_state(obj, LV_STATE_FOCUSED);
lv_obj_clear_state(obj, LV_STATE_EDITED);
}
} else if(sign == LV_SIGNAL_DEFOCUS) {
}
else if(sign == LV_SIGNAL_DEFOCUS) {
lv_obj_clear_state(obj, LV_STATE_FOCUSED | LV_STATE_EDITED);
}
#endif
@@ -3393,8 +3408,7 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
static void refresh_children_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coord_t y_diff)
{
lv_obj_t * i;
LV_LL_READ(obj->child_ll, i)
{
LV_LL_READ(obj->child_ll, i) {
i->coords.x1 += x_diff;
i->coords.y1 += y_diff;
i->coords.x2 += x_diff;
@@ -3556,7 +3570,8 @@ static void base_dir_refr_children(lv_obj_t * obj)
* @param new_state the new state of the object
* @return pointer to the allocated `the transaction` variable or `NULL` if no transtion created
*/
static lv_style_trans_t * trans_create(lv_obj_t * obj, lv_style_property_t prop, uint8_t part, lv_state_t prev_state, lv_state_t new_state)
static lv_style_trans_t * trans_create(lv_obj_t * obj, lv_style_property_t prop, uint8_t part, lv_state_t prev_state,
lv_state_t new_state)
{
lv_style_trans_t * tr;
lv_style_list_t * style_list = lv_obj_get_style_list(obj, part);
@@ -3630,9 +3645,10 @@ static lv_style_trans_t * trans_create(lv_obj_t * obj, lv_style_property_t prop,
tr = lv_ll_ins_head(&LV_GC_ROOT(_lv_obj_style_trans_ll));
LV_ASSERT_MEM(tr);
if(tr == NULL) return NULL;
tr->start_value._opa= o1;
tr->start_value._opa = o1;
tr->end_value._opa = o2;
} else { /*Ptr*/
}
else { /*Ptr*/
obj->state = prev_state;
style_list->skip_trans = 1;
const void * p1 = _lv_obj_get_style_ptr(obj, part, prop);
@@ -3649,7 +3665,7 @@ static lv_style_trans_t * trans_create(lv_obj_t * obj, lv_style_property_t prop,
tr = lv_ll_ins_head(&LV_GC_ROOT(_lv_obj_style_trans_ll));
LV_ASSERT_MEM(tr);
if(tr == NULL) return NULL;
tr->start_value._ptr= p1;
tr->start_value._ptr = p1;
tr->end_value._ptr = p2;
}
@@ -3669,9 +3685,9 @@ static void trans_del(lv_obj_t * obj, uint8_t part, lv_style_property_t prop)
lv_style_trans_t * tr;
lv_style_trans_t * tr_next;
tr = lv_ll_get_head(&LV_GC_ROOT(_lv_obj_style_trans_ll));
while(tr != NULL) {
/*'tr' might be deleted, so get the next object while 'tr' is valid*/
tr_next = lv_ll_get_next(&LV_GC_ROOT(_lv_obj_style_trans_ll), tr);
while(tr != NULL) {
/*'tr' might be deleted, so get the next object while 'tr' is valid*/
tr_next = lv_ll_get_next(&LV_GC_ROOT(_lv_obj_style_trans_ll), tr);
if(tr->obj == obj && (part == tr->part || part == 0xFF) && (prop == tr->prop || prop == 0xFF)) {
lv_anim_del(tr, NULL);
@@ -3707,7 +3723,8 @@ static void trans_anim_cb(lv_style_trans_t * tr, lv_anim_value_t v)
else if(v >= 255) x = tr->end_value._opa;
else x = tr->start_value._opa + (((tr->end_value._opa - tr->start_value._opa) * v) >> 8);
_lv_style_set_opa(style, tr->prop, x);
} else {
}
else {
const void * x;
if(v < 128) x = tr->start_value._ptr;
else x = tr->end_value._ptr;
@@ -3738,8 +3755,9 @@ static void trans_anim_start_cb(lv_anim_t * a)
}
else if((prop_tmp & 0xF) < LV_STYLE_ID_PTR) { /*Opa*/
tr->start_value._opa = _lv_obj_get_style_opa(tr->obj, tr->part, prop_tmp);
} else { /*Ptr*/
tr->start_value._ptr= _lv_obj_get_style_ptr(tr->obj, tr->part, prop_tmp);
}
else { /*Ptr*/
tr->start_value._ptr = _lv_obj_get_style_ptr(tr->obj, tr->part, prop_tmp);
}
@@ -3754,7 +3772,7 @@ static void trans_anim_ready_cb(lv_anim_t * a)
static void opa_scale_anim(lv_obj_t * obj, lv_anim_value_t v)
{
lv_obj_set_style_local_opa_scale(obj, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, v);
lv_obj_set_style_local_opa_scale(obj, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, v);
}
#endif

View File

@@ -93,12 +93,12 @@ enum {
LV_EVENT_DRAG_BEGIN,
LV_EVENT_DRAG_END,
LV_EVENT_DRAG_THROW_BEGIN,
LV_EVENT_GESTURE, /**< The object has been getture*/
LV_EVENT_GESTURE, /**< The object has been getture*/
LV_EVENT_KEY,
LV_EVENT_FOCUSED,
LV_EVENT_DEFOCUSED,
LV_EVENT_LEAVE,
LV_EVENT_VALUE_CHANGED, /**< The object's value has changed (i.e. slider moved) */
LV_EVENT_VALUE_CHANGED, /**< The object's value has changed (i.e. slider moved) */
LV_EVENT_INSERT,
LV_EVENT_REFRESH,
LV_EVENT_APPLY, /**< "Ok", "Apply" or similar specific button has clicked*/
@@ -141,7 +141,7 @@ enum {
LV_SIGNAL_DRAG_BEGIN,
LV_SIGNAL_DRAG_THROW_BEGIN,
LV_SIGNAL_DRAG_END,
LV_SIGNAL_GESTURE, /**< The object has been gesture*/
LV_SIGNAL_GESTURE, /**< The object has been gesture*/
LV_SIGNAL_LEAVE, /**< Another object is clicked or chosen via an input device */
/*Group related*/
@@ -155,8 +155,7 @@ typedef uint8_t lv_signal_t;
typedef lv_res_t (*lv_signal_cb_t)(struct _lv_obj_t * obj, lv_signal_t sign, void * param);
#if LV_USE_OBJ_REALIGN
typedef struct
{
typedef struct {
const struct _lv_obj_t * base;
lv_coord_t xofs;
lv_coord_t yofs;
@@ -193,8 +192,7 @@ enum {
typedef uint8_t lv_state_t;
typedef struct _lv_obj_t
{
typedef struct _lv_obj_t {
struct _lv_obj_t * parent; /**< Pointer to the parent object*/
lv_ll_t child_ll; /**< Linked list to store the children objects*/
@@ -217,18 +215,18 @@ typedef struct _lv_obj_t
lv_coord_t ext_draw_pad; /**< EXTtend the size in every direction for drawing. */
/*Attributes and states*/
uint8_t click :1; /**< 1: Can be pressed by an input device*/
uint8_t drag :1; /**< 1: Enable the dragging*/
uint8_t drag_throw :1; /**< 1: Enable throwing with drag*/
uint8_t drag_parent :1; /**< 1: Parent will be dragged instead*/
uint8_t hidden :1; /**< 1: Object is hidden*/
uint8_t top :1; /**< 1: If the object or its children is clicked it goes to the foreground*/
uint8_t parent_event :1; /**< 1: Send the object's events to the parent too. */
uint8_t adv_hittest :1; /**< 1: Use advanced hit-testing (slower) */
uint8_t click : 1; /**< 1: Can be pressed by an input device*/
uint8_t drag : 1; /**< 1: Enable the dragging*/
uint8_t drag_throw : 1; /**< 1: Enable throwing with drag*/
uint8_t drag_parent : 1; /**< 1: Parent will be dragged instead*/
uint8_t hidden : 1; /**< 1: Object is hidden*/
uint8_t top : 1; /**< 1: If the object or its children is clicked it goes to the foreground*/
uint8_t parent_event : 1; /**< 1: Send the object's events to the parent too. */
uint8_t adv_hittest : 1; /**< 1: Use advanced hit-testing (slower) */
uint8_t gesture_parent : 1; /**< 1: Parent will be gesture instead*/
lv_drag_dir_t drag_dir :3; /**< Which directions the object can be dragged in */
lv_bidi_dir_t base_dir :2; /**< Base direction of texts related to this object */
lv_drag_dir_t drag_dir : 3; /**< Which directions the object can be dragged in */
lv_bidi_dir_t base_dir : 2; /**< Base direction of texts related to this object */
#if LV_USE_GROUP != 0
void * group_p;
@@ -258,26 +256,22 @@ enum {
typedef uint8_t lv_obj_part_t;
/** Used by `lv_obj_get_type()`. The object's and its ancestor types are stored here*/
typedef struct
{
typedef struct {
const char * type[LV_MAX_ANCESTOR_NUM]; /**< [0]: the actual type, [1]: ancestor, [2] #1's ancestor
... [x]: "lv_obj" */
} lv_obj_type_t;
typedef struct
{
lv_point_t *point;
typedef struct {
lv_point_t * point;
bool result;
} lv_hit_test_info_t;
typedef struct
{
typedef struct {
uint8_t part;
lv_style_list_t * result;
} lv_get_style_info_t;
typedef struct
{
typedef struct {
uint8_t part;
lv_state_t result;
} lv_get_state_info_t;
@@ -334,7 +328,7 @@ void lv_obj_del_anim_ready_cb(lv_anim_t * a);
* @param obj object to delete
* @see lv_async_call
*/
void lv_obj_del_async(struct _lv_obj_t *obj);
void lv_obj_del_async(struct _lv_obj_t * obj);
/**
* Delete all children of an object

View File

@@ -60,41 +60,41 @@ extern "C" {
#define _LV_OBJ_STYLE_DECLARE_GET_scalar(prop_name, func_name, value_type, style_type) \
static inline value_type lv_obj_get_style_##func_name (const lv_obj_t * obj, uint8_t part) \
{ \
return (value_type) _lv_obj_get_style##style_type (obj, part, LV_STYLE_##prop_name); \
}
static inline value_type lv_obj_get_style_##func_name (const lv_obj_t * obj, uint8_t part) \
{ \
return (value_type) _lv_obj_get_style##style_type (obj, part, LV_STYLE_##prop_name); \
}
#define _LV_OBJ_STYLE_DECLARE_GET_nonscalar(prop_name, func_name, value_type, style_type) \
static inline value_type lv_obj_get_style_##func_name (const lv_obj_t * obj, uint8_t part) \
{ \
return _lv_obj_get_style##style_type (obj, part, LV_STYLE_##prop_name); \
}
static inline value_type lv_obj_get_style_##func_name (const lv_obj_t * obj, uint8_t part) \
{ \
return _lv_obj_get_style##style_type (obj, part, LV_STYLE_##prop_name); \
}
#define _LV_OBJ_STYLE_SET_GET_DECLARE(prop_name, func_name, value_type, style_type, scalar) \
_LV_OBJ_STYLE_DECLARE_GET_##scalar(prop_name, func_name, value_type, style_type) \
static inline void lv_obj_set_style_local_##func_name (lv_obj_t * obj, uint8_t part, lv_state_t state, value_type value) \
{ \
_lv_obj_set_style_local##style_type (obj, part, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \
} \
static inline void lv_obj_get_style_local_##func_name (lv_obj_t * obj, uint8_t part, lv_state_t state, void * res) \
{ \
_lv_style_get##style_type (lv_obj_get_local_style(obj, part), LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), res); \
} \
static inline void lv_obj_remove_style_local_##func_name (lv_obj_t * obj, uint8_t part, lv_state_t state) \
{ \
_lv_obj_remove_style_local_prop(obj, part, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS)); \
} \
static inline int16_t lv_style_get_##func_name (lv_style_t * style, lv_state_t state, void * res) \
{ \
return _lv_style_get##style_type (style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), res); \
} \
static inline void lv_style_set_##func_name (lv_style_t * style, lv_state_t state, value_type value) \
{ \
_lv_style_set##style_type (style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \
}
_LV_OBJ_STYLE_DECLARE_GET_##scalar(prop_name, func_name, value_type, style_type) \
static inline void lv_obj_set_style_local_##func_name (lv_obj_t * obj, uint8_t part, lv_state_t state, value_type value) \
{ \
_lv_obj_set_style_local##style_type (obj, part, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \
} \
static inline void lv_obj_get_style_local_##func_name (lv_obj_t * obj, uint8_t part, lv_state_t state, void * res) \
{ \
_lv_style_get##style_type (lv_obj_get_local_style(obj, part), LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), res); \
} \
static inline void lv_obj_remove_style_local_##func_name (lv_obj_t * obj, uint8_t part, lv_state_t state) \
{ \
_lv_obj_remove_style_local_prop(obj, part, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS)); \
} \
static inline int16_t lv_style_get_##func_name (lv_style_t * style, lv_state_t state, void * res) \
{ \
return _lv_style_get##style_type (style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), res); \
} \
static inline void lv_style_set_##func_name (lv_style_t * style, lv_state_t state, value_type value) \
{ \
_lv_style_set##style_type (style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \
}
_LV_OBJ_STYLE_SET_GET_DECLARE(RADIUS, radius, lv_style_int_t,_int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(RADIUS, radius, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(CLIP_CORNER, clip_corner, bool, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(SIZE, size, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSFORM_WIDTH, transform_width, lv_style_int_t, _int, scalar)
@@ -111,7 +111,7 @@ _LV_OBJ_STYLE_SET_GET_DECLARE(BG_GRAD_STOP, bg_grad_stop, lv_style_int_t, _int,
_LV_OBJ_STYLE_SET_GET_DECLARE(BG_GRAD_DIR, bg_grad_dir, lv_grad_dir_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(BG_COLOR, bg_color, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(BG_GRAD_COLOR, bg_grad_color, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(BG_OPA, bg_opa, lv_opa_t , _opa, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(BG_OPA, bg_opa, lv_opa_t, _opa, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(BORDER_WIDTH, border_width, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(BORDER_SIDE, border_side, lv_border_side_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(BORDER_BLEND_MODE, border_blend_mode, lv_blend_mode_t, _int, scalar)
@@ -144,8 +144,8 @@ _LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_OFS_Y, value_ofs_y, lv_style_int_t, _int, sc
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_ALIGN, value_align, lv_align_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_COLOR, value_color, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_OPA, value_opa, lv_opa_t, _opa, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_FONT, value_font, const lv_font_t * , _ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_STR, value_str, const char * , _ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_FONT, value_font, const lv_font_t *, _ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_STR, value_str, const char *, _ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_LETTER_SPACE, text_letter_space, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_LINE_SPACE, text_line_space, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_DECOR, text_decor, lv_text_decor_t, _int, scalar)
@@ -153,7 +153,7 @@ _LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_BLEND_MODE, text_blend_mode, lv_blend_mode_t,
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_COLOR, text_color, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_SEL_COLOR, text_sel_color, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_OPA, text_opa, lv_opa_t, _opa, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_FONT, text_font, const lv_font_t * , _ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_FONT, text_font, const lv_font_t *, _ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_WIDTH, line_width, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_BLEND_MODE, line_blend_mode, lv_blend_mode_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_DASH_WIDTH, line_dash_width, lv_style_int_t, _int, scalar)
@@ -174,9 +174,9 @@ _LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_4, transition_prop_4, lv_style_int
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_5, transition_prop_5, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_6, transition_prop_6, lv_style_int_t, _int, scalar)
#if LV_USE_ANIMATION
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PATH, transition_path, lv_anim_path_cb_t , _ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PATH, transition_path, lv_anim_path_cb_t, _ptr, scalar)
#else
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PATH, transition_path, void * , _ptr, scalar) /*For compatibility*/
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PATH, transition_path, void *, _ptr, scalar) /*For compatibility*/
#endif
_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_WIDTH, scale_width, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_BORDER_WIDTH, scale_border_width, lv_style_int_t, _int, scalar)

View File

@@ -17,7 +17,7 @@
#include "../lv_draw/lv_draw.h"
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/*********************
@@ -74,12 +74,13 @@ void lv_refr_init(void)
void lv_refr_now(lv_disp_t * disp)
{
#if LV_USE_ANIMATION
lv_anim_refr_now();
lv_anim_refr_now();
#endif
if(disp) {
lv_disp_refr_task(disp->refr_task);
} else {
}
else {
lv_disp_t * d;
d = lv_disp_get_next(NULL);
while(d) {
@@ -130,12 +131,13 @@ void lv_inv_area(lv_disp_t * disp, const lv_area_t * area_p)
/*Save the area*/
if(disp->inv_p < LV_INV_BUF_SIZE) {
lv_area_copy(&disp->inv_areas[disp->inv_p], &com_area);
} else { /*If no place for the area add the screen*/
}
else { /*If no place for the area add the screen*/
disp->inv_p = 0;
lv_area_copy(&disp->inv_areas[disp->inv_p], &scr_area);
}
disp->inv_p++;
lv_task_set_prio(disp->refr_task, LV_REFR_TASK_PRIO);
lv_task_set_prio(disp->refr_task, LV_REFR_TASK_PRIO);
}
}
@@ -169,16 +171,16 @@ void lv_disp_refr_task(lv_task_t * task)
uint32_t start = lv_tick_get();
/* Ensure the task does not run again automatically.
/* Ensure the task does not run again automatically.
* This is done before refreshing in case refreshing invalidates something else.
*/
lv_task_set_prio(task, LV_TASK_PRIO_OFF);
lv_task_set_prio(task, LV_TASK_PRIO_OFF);
disp_refr = task->user_data;
// extern rect_cache_t cache[];
// extern uint32_t cp;
// extern rect_cache_t cache[];
// extern uint32_t cp;
lv_refr_join_area();
@@ -348,7 +350,8 @@ static void lv_refr_area(const lv_area_t * area_p)
LV_LOG_WARN("Can't set VDB height using the round function. (Wrong round_cb or to "
"small VDB)");
return;
} else {
}
else {
max_row = tmp.y2 + 1;
}
}
@@ -433,12 +436,12 @@ static lv_obj_t * lv_refr_get_top_obj(const lv_area_t * area_p, lv_obj_t * obj)
/*If this object is fully cover the draw area check the children too */
if(lv_area_is_in(area_p, &obj->coords, 0) && obj->hidden == 0) {
lv_design_res_t design_res = obj->design_cb ? obj->design_cb(obj, area_p, LV_DESIGN_COVER_CHK) : LV_DESIGN_RES_NOT_COVER;
lv_design_res_t design_res = obj->design_cb ? obj->design_cb(obj, area_p,
LV_DESIGN_COVER_CHK) : LV_DESIGN_RES_NOT_COVER;
if(design_res == LV_DESIGN_RES_MASKED) return NULL;
lv_obj_t * i;
LV_LL_READ(obj->child_ll, i)
{
LV_LL_READ(obj->child_ll, i) {
found_p = lv_refr_get_top_obj(area_p, i);
/*If a children is ok then break*/
@@ -555,8 +558,7 @@ static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p)
lv_area_t mask_child; /*Mask from obj and its child*/
lv_obj_t * child_p;
lv_area_t child_area;
LV_LL_READ_BACK(obj->child_ll, child_p)
{
LV_LL_READ_BACK(obj->child_ll, child_p) {
lv_obj_get_coords(child_p, &child_area);
ext_size = child_p->ext_draw_pad;
child_area.x1 -= ext_size;

View File

@@ -106,8 +106,7 @@ bool lv_style_remove_prop(lv_style_t * style, lv_style_property_t prop)
attr_found.full = *(style->map + id + 1);
attr_goal.full = (prop >> 8) & 0xFFU;
if(attr_found.bits.state == attr_goal.bits.state)
{
if(attr_found.bits.state == attr_goal.bits.state) {
uint32_t map_size = lv_style_get_mem_size(style);
uint8_t prop_size = sizeof(lv_style_property_t);
if((prop & 0xF) < LV_STYLE_ID_COLOR) prop_size += sizeof(lv_style_int_t);
@@ -162,17 +161,20 @@ void lv_style_list_copy(lv_style_list_t * list_dest, const lv_style_list_t * lis
list_dest->style_list = lv_mem_alloc((list_src->style_cnt - 1) * sizeof(lv_style_t *));
memcpy(list_dest->style_list, list_src->style_list + 1, (list_src->style_cnt - 1) * sizeof(lv_style_t *));
list_dest->style_cnt = list_src->style_cnt - 1;
} else {
}
else {
list_dest->style_list = lv_mem_alloc(list_src->style_cnt * sizeof(lv_style_t *));
memcpy(list_dest->style_list, list_src->style_list, list_src->style_cnt * sizeof(lv_style_t *));
list_dest->style_cnt = list_src->style_cnt;
}
} else {
}
else {
if(list_src->has_trans) {
list_dest->style_list = lv_mem_alloc((list_src->style_cnt - 2) * sizeof(lv_style_t *));
memcpy(list_dest->style_list, list_src->style_list + 2, (list_src->style_cnt - 2) * sizeof(lv_style_t *));
list_dest->style_cnt = list_src->style_cnt - 2;
} else {
}
else {
list_dest->style_list = lv_mem_alloc((list_src->style_cnt - 1) * sizeof(lv_style_t *));
memcpy(list_dest->style_list, list_src->style_list + 1, (list_src->style_cnt - 1) * sizeof(lv_style_t *));
list_dest->style_cnt = list_src->style_cnt - 1;
@@ -336,10 +338,10 @@ uint16_t lv_style_get_mem_size(const lv_style_t * style)
size_t i = 0;
while(style->map[i] != _LV_STYLE_CLOSEING_PROP) {
/*Go to the next property*/
if((style->map[i] & 0xF) < LV_STYLE_ID_COLOR) i+= sizeof(lv_style_int_t);
else if((style->map[i] & 0xF) < LV_STYLE_ID_OPA) i+= sizeof(lv_color_t);
else if((style->map[i] & 0xF) < LV_STYLE_ID_PTR) i+= sizeof(lv_opa_t);
else i+= sizeof(void*);
if((style->map[i] & 0xF) < LV_STYLE_ID_COLOR) i += sizeof(lv_style_int_t);
else if((style->map[i] & 0xF) < LV_STYLE_ID_OPA) i += sizeof(lv_color_t);
else if((style->map[i] & 0xF) < LV_STYLE_ID_PTR) i += sizeof(lv_opa_t);
else i += sizeof(void *);
i += sizeof(lv_style_property_t);
}
@@ -388,7 +390,7 @@ void _lv_style_set_int(lv_style_t * style, lv_style_property_t prop, lv_style_in
LV_ASSERT_MEM(style->map);
if(style == NULL) return;
memcpy(style->map + size - new_prop_size - end_mark_size , &prop, sizeof(lv_style_property_t));
memcpy(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t));
memcpy(style->map + size - sizeof(lv_style_int_t) - end_mark_size, &value, sizeof(lv_style_int_t));
memcpy(style->map + size - end_mark_size, &end_mark, sizeof(end_mark));
}
@@ -529,8 +531,8 @@ void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, const void
LV_ASSERT_MEM(style->map);
if(style == NULL) return;
memcpy(style->map + size - new_prop_size - end_mark_size , &prop, sizeof(lv_style_property_t));
memcpy(style->map + size - sizeof(void *) - end_mark_size , &p, sizeof(void *));
memcpy(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t));
memcpy(style->map + size - sizeof(void *) - end_mark_size, &p, sizeof(void *));
memcpy(style->map + size - end_mark_size, &end_mark, sizeof(end_mark));
}
@@ -554,7 +556,8 @@ int16_t _lv_style_get_int(const lv_style_t * style, lv_style_property_t prop, vo
int32_t id = get_property_index(style, prop);
if(id < 0) {
return -1;
} else {
}
else {
memcpy(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_style_int_t));
lv_style_attr_t attr_act;
attr_act.full = style->map[id + 1];
@@ -589,7 +592,8 @@ int16_t _lv_style_get_opa(const lv_style_t * style, lv_style_property_t prop, vo
int32_t id = get_property_index(style, prop);
if(id < 0) {
return -1;
} else {
}
else {
memcpy(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_opa_t));
lv_style_attr_t attr_act;
attr_act.full = style->map[id + 1];
@@ -622,7 +626,8 @@ int16_t _lv_style_get_color(const lv_style_t * style, lv_style_property_t prop,
int32_t id = get_property_index(style, prop);
if(id < 0) {
return -1;
} else {
}
else {
memcpy(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_color_t));
lv_style_attr_t attr_act;
attr_act.full = style->map[id + 1];
@@ -649,14 +654,15 @@ int16_t _lv_style_get_color(const lv_style_t * style, lv_style_property_t prop,
*/
int16_t _lv_style_get_ptr(const lv_style_t * style, lv_style_property_t prop, void * v_res)
{
void **res = (void *)v_res;
void ** res = (void *)v_res;
if(style == NULL) return -1;
if(style->map == NULL) return -1;
int32_t id = get_property_index(style, prop);
if(id < 0) {
return -1;
} else {
memcpy(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(void*));
}
else {
memcpy(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(void *));
lv_style_attr_t attr_act;
attr_act.full = style->map[id + 1];
@@ -1021,8 +1027,8 @@ static inline int32_t get_property_index(const lv_style_t * style, lv_style_prop
size_t i = 0;
while(style->map[i] != _LV_STYLE_CLOSEING_PROP) {
if(style->map[i] == id_to_find) {
lv_style_attr_t attr_i;
attr_i.full = style->map[i + 1];
lv_style_attr_t attr_i;
attr_i.full = style->map[i + 1];
/*If the state perfectly matches return this property*/
if(attr_i.bits.state == attr.bits.state) {
@@ -1041,10 +1047,10 @@ static inline int32_t get_property_index(const lv_style_t * style, lv_style_prop
}
/*Go to the next property*/
if((style->map[i] & 0xF) < LV_STYLE_ID_COLOR) i+= sizeof(lv_style_int_t);
else if((style->map[i] & 0xF) < LV_STYLE_ID_OPA) i+= sizeof(lv_color_t);
else if((style->map[i] & 0xF) < LV_STYLE_ID_PTR) i+= sizeof(lv_opa_t);
else i+= sizeof(void*);
if((style->map[i] & 0xF) < LV_STYLE_ID_COLOR) i += sizeof(lv_style_int_t);
else if((style->map[i] & 0xF) < LV_STYLE_ID_OPA) i += sizeof(lv_color_t);
else if((style->map[i] & 0xF) < LV_STYLE_ID_PTR) i += sizeof(lv_opa_t);
else i += sizeof(void *);
i += sizeof(lv_style_property_t);
}

View File

@@ -79,11 +79,11 @@ typedef uint8_t lv_text_decor_t;
typedef union {
struct {
uint8_t state :7; /* To which state the property refers to*/
uint8_t inherit :1; /*1: The property can be inherited*/
}bits;
uint8_t state : 7; /* To which state the property refers to*/
uint8_t inherit : 1; /*1: The property can be inherited*/
} bits;
uint8_t full;
}lv_style_attr_t;
} lv_style_attr_t;
#define LV_STYLE_ID_VALUE 0x0 /*max 8 pcs*/
@@ -205,7 +205,7 @@ typedef struct {
#if LV_USE_ASSERT_STYLE
uint32_t sentinel;
#endif
}lv_style_t;
} lv_style_t;
typedef int16_t lv_style_int_t;
@@ -216,11 +216,11 @@ typedef struct {
uint32_t sentinel;
#endif
uint8_t style_cnt;
uint8_t has_local :1;
uint8_t has_trans :1;
uint8_t skip_trans :1; /*1: Temporally skip the transition style if any*/
uint8_t ignore_trans :1; /*1: Mark that this style list shouldn't receive transitions at all*/
}lv_style_list_t;
uint8_t has_local : 1;
uint8_t has_trans : 1;
uint8_t skip_trans : 1; /*1: Temporally skip the transition style if any*/
uint8_t ignore_trans : 1; /*1: Mark that this style list shouldn't receive transitions at all*/
} lv_style_list_t;
/**********************
* GLOBAL PROTOTYPES

View File

@@ -32,16 +32,16 @@ typedef struct {
lv_draw_rect_dsc_t * draw_dsc;
const lv_area_t * draw_area;
const lv_area_t * clip_area;
}quarter_draw_dsc_t;
} quarter_draw_dsc_t;
/**********************
* STATIC PROTOTYPES
**********************/
static void draw_quarter_0(quarter_draw_dsc_t* q);
static void draw_quarter_1(quarter_draw_dsc_t* q);
static void draw_quarter_2(quarter_draw_dsc_t* q);
static void draw_quarter_3(quarter_draw_dsc_t* q);
static void draw_quarter_0(quarter_draw_dsc_t * q);
static void draw_quarter_1(quarter_draw_dsc_t * q);
static void draw_quarter_2(quarter_draw_dsc_t * q);
static void draw_quarter_3(quarter_draw_dsc_t * q);
static void get_rounded_area(int16_t angle, lv_coord_t radius, uint8_t tickness, lv_area_t * res_area);
@@ -68,7 +68,8 @@ static void get_rounded_area(int16_t angle, lv_coord_t radius, uint8_t tickness,
* @param style style of the arc (`body.thickness`, `body.main_color`, `body.opa` is used)
* @param opa_scale scale down all opacities by the factor
*/
void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uint16_t start_angle, uint16_t end_angle, const lv_area_t * clip_area, lv_draw_line_dsc_t * dsc)
void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uint16_t start_angle, uint16_t end_angle,
const lv_area_t * clip_area, lv_draw_line_dsc_t * dsc)
{
if(dsc->opa <= LV_OPA_MIN) return;
if(dsc->width == 0) return;
@@ -104,7 +105,8 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin
int32_t angle_gap;
if(end_angle > start_angle) {
angle_gap = 360 - (end_angle - start_angle);
} else {
}
else {
angle_gap = start_angle - end_angle;
}
if(angle_gap > SPLIT_ANGLE_GAP_LIMIT && radius > SPLIT_RADIUS_LIMIT) {
@@ -115,7 +117,7 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin
q_dsc.radius = radius;
q_dsc.start_angle = start_angle;
q_dsc.end_angle = end_angle;
q_dsc.start_quarter= (start_angle / 90) & 0x3;
q_dsc.start_quarter = (start_angle / 90) & 0x3;
q_dsc.end_quarter = (end_angle / 90) & 0x3;
q_dsc.width = dsc->width;
q_dsc.draw_dsc = &cir_dsc;
@@ -126,7 +128,8 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin
draw_quarter_1(&q_dsc);
draw_quarter_2(&q_dsc);
draw_quarter_3(&q_dsc);
} else {
}
else {
lv_draw_rect(&area, clip_area, &cir_dsc);
}
lv_draw_mask_remove_id(mask_angle_id);
@@ -191,7 +194,7 @@ static void draw_quarter_0(quarter_draw_dsc_t * q)
bool ok = lv_area_intersect(&quarter_area, &quarter_area, q->clip_area);
if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc);
}
if(q->end_quarter == 0) {
if(q->end_quarter == 0) {
quarter_area.x2 = q->center_x + q->radius;
quarter_area.y1 = q->center_y;
@@ -244,12 +247,12 @@ static void draw_quarter_1(quarter_draw_dsc_t * q)
bool ok = lv_area_intersect(&quarter_area, &quarter_area, q->clip_area);
if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc);
}
if(q->end_quarter == 1) {
if(q->end_quarter == 1) {
quarter_area.x2 = q->center_x - 1;
quarter_area.y2 = q->center_y + q->radius;
quarter_area.y1 = q->center_y + ((lv_trigo_sin(q->end_angle) * (q->radius- q->width)) >> LV_TRIGO_SHIFT);
quarter_area.x1 = q->center_x + ((lv_trigo_sin(q->end_angle + 90) * (q->radius )) >> LV_TRIGO_SHIFT);
quarter_area.y1 = q->center_y + ((lv_trigo_sin(q->end_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT);
quarter_area.x1 = q->center_x + ((lv_trigo_sin(q->end_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT);
bool ok = lv_area_intersect(&quarter_area, &quarter_area, q->clip_area);
if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc);
@@ -291,13 +294,13 @@ static void draw_quarter_2(quarter_draw_dsc_t * q)
quarter_area.x2 = q->center_x - 1;
quarter_area.y1 = q->center_y - q->radius;
quarter_area.x1 = q->center_x + ((lv_trigo_sin(q->start_angle + 90) * (q->radius )) >> LV_TRIGO_SHIFT);
quarter_area.y2 = q->center_y + ((lv_trigo_sin(q->start_angle) * (q->radius- q->width)) >> LV_TRIGO_SHIFT);
quarter_area.x1 = q->center_x + ((lv_trigo_sin(q->start_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT);
quarter_area.y2 = q->center_y + ((lv_trigo_sin(q->start_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT);
bool ok = lv_area_intersect(&quarter_area, &quarter_area, q->clip_area);
if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc);
}
if(q->end_quarter == 2) {
if(q->end_quarter == 2) {
quarter_area.x1 = q->center_x - q->radius;
quarter_area.y2 = q->center_y - 1;
@@ -351,7 +354,7 @@ static void draw_quarter_3(quarter_draw_dsc_t * q)
bool ok = lv_area_intersect(&quarter_area, &quarter_area, q->clip_area);
if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc);
}
if(q->end_quarter == 3) {
if(q->end_quarter == 3) {
quarter_area.x1 = q->center_x;
quarter_area.y1 = q->center_y - q->radius;

View File

@@ -38,7 +38,8 @@ extern "C" {
* @param style style of the arc (`body.thickness`, `body.main_color`, `body.opa` is used)
* @param opa_scale scale down all opacities by the factor
*/
void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uint16_t start_angle, uint16_t end_angle, const lv_area_t * clip_area, lv_draw_line_dsc_t * dsc);
void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uint16_t start_angle, uint16_t end_angle,
const lv_area_t * clip_area, lv_draw_line_dsc_t * dsc);
/**********************
* MACROS

View File

@@ -28,28 +28,28 @@
**********************/
static void fill_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
lv_color_t color, lv_opa_t opa,
const lv_opa_t * mask, lv_draw_mask_res_t mask_res);
lv_color_t color, lv_opa_t opa,
const lv_opa_t * mask, lv_draw_mask_res_t mask_res);
static void fill_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
lv_color_t color, lv_opa_t opa,
const lv_opa_t * mask, lv_draw_mask_res_t mask_res);
lv_color_t color, lv_opa_t opa,
const lv_opa_t * mask, lv_draw_mask_res_t mask_res);
static void fill_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
lv_color_t color, lv_opa_t opa,
const lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_blend_mode_t mode);
lv_color_t color, lv_opa_t opa,
const lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_blend_mode_t mode);
static void map_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
const lv_opa_t * mask, lv_draw_mask_res_t mask_res);
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
const lv_opa_t * mask, lv_draw_mask_res_t mask_res);
static void map_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
const lv_opa_t * mask, lv_draw_mask_res_t mask_res);
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
const lv_opa_t * mask, lv_draw_mask_res_t mask_res);
static void map_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
const lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_blend_mode_t mode);
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
const lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_blend_mode_t mode);
static inline lv_color_t color_blend_true_color_additive(lv_color_t fg, lv_color_t bg, lv_opa_t opa);
static inline lv_color_t color_blend_true_color_subtractive(lv_color_t fg, lv_color_t bg, lv_opa_t opa);
@@ -81,8 +81,8 @@ static inline lv_color_t color_blend_true_color_subtractive(lv_color_t fg, lv_co
* @param mode
*/
void lv_blend_fill(const lv_area_t * clip_area, const lv_area_t * fill_area,
lv_color_t color, lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_opa_t opa,
lv_blend_mode_t mode)
lv_color_t color, lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_opa_t opa,
lv_blend_mode_t mode)
{
/*Do not draw transparent things*/
if(opa < LV_OPA_MIN) return;
@@ -112,7 +112,7 @@ void lv_blend_fill(const lv_area_t * clip_area, const lv_area_t * fill_area,
if(mask && disp->driver.antialiasing == 0) {
int32_t mask_w = lv_area_get_width(&draw_area);
int32_t i;
for (i = 0; i < mask_w; i++) mask[i] = mask[i] > 128 ? LV_OPA_COVER : LV_OPA_TRANSP;
for(i = 0; i < mask_w; i++) mask[i] = mask[i] > 128 ? LV_OPA_COVER : LV_OPA_TRANSP;
}
if(disp->driver.set_px_cb) {
@@ -128,8 +128,8 @@ void lv_blend_fill(const lv_area_t * clip_area, const lv_area_t * fill_area,
void lv_blend_map(const lv_area_t * clip_area, const lv_area_t * map_area, const lv_color_t * map_buf,
lv_opa_t * mask, lv_draw_mask_res_t mask_res,
lv_opa_t opa, lv_blend_mode_t mode)
lv_opa_t * mask, lv_draw_mask_res_t mask_res,
lv_opa_t opa, lv_blend_mode_t mode)
{
/*Do not draw transparent things*/
if(opa < LV_OPA_MIN) return;
@@ -158,14 +158,15 @@ void lv_blend_map(const lv_area_t * clip_area, const lv_area_t * map_area, const
if(mask && disp->driver.antialiasing == 0) {
int32_t mask_w = lv_area_get_width(&draw_area);
int32_t i;
for (i = 0; i < mask_w; i++) mask[i] = mask[i] > 128 ? LV_OPA_COVER : LV_OPA_TRANSP;
for(i = 0; i < mask_w; i++) mask[i] = mask[i] > 128 ? LV_OPA_COVER : LV_OPA_TRANSP;
}
if(disp->driver.set_px_cb) {
map_set_px(disp_area, disp_buf, &draw_area, map_area, map_buf, opa, mask, mask_res);
}
else if(mode == LV_BLEND_MODE_NORMAL) {
map_normal(disp_area, disp_buf, &draw_area, map_area, map_buf, opa, mask, mask_res);
} else {
}
else {
map_blended(disp_area, disp_buf, &draw_area, map_area, map_buf, opa, mask, mask_res, mode);
}
}
@@ -176,8 +177,8 @@ void lv_blend_map(const lv_area_t * clip_area, const lv_area_t * map_area, const
**********************/
static void fill_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
lv_color_t color, lv_opa_t opa,
const lv_opa_t * mask, lv_draw_mask_res_t mask_res)
lv_color_t color, lv_opa_t opa,
const lv_opa_t * mask, lv_draw_mask_res_t mask_res)
{
lv_disp_t * disp = lv_refr_get_disp_refreshing();
@@ -191,10 +192,11 @@ static void fill_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, con
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) {
for(y = draw_area->y1; y <= draw_area->y2; y++) {
for(x = draw_area->x1; x <= draw_area->x2; x++) {
disp->driver.set_px_cb(&disp->driver, (void*)disp_buf, disp_w, x, y, color, opa);
disp->driver.set_px_cb(&disp->driver, (void *)disp_buf, disp_w, x, y, color, opa);
}
}
} else {
}
else {
/* The mask is relative to the clipped area.
* In the cycles below mask will be indexed from `draw_area.x1`
* but it corresponds to zero index. So prepare `mask_tmp` accordingly. */
@@ -205,7 +207,8 @@ static void fill_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, con
for(y = draw_area->y1; y <= draw_area->y2; y++) {
for(x = draw_area->x1; x <= draw_area->x2; x++) {
disp->driver.set_px_cb(&disp->driver, (void*)disp_buf, disp_w, x, y, color, (uint32_t)((uint32_t)opa * mask_tmp[x]) >> 8);
disp->driver.set_px_cb(&disp->driver, (void *)disp_buf, disp_w, x, y, color,
(uint32_t)((uint32_t)opa * mask_tmp[x]) >> 8);
}
mask_tmp += draw_area_w;
}
@@ -213,8 +216,8 @@ static void fill_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, con
}
static void fill_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
lv_color_t color, lv_opa_t opa,
const lv_opa_t * mask, lv_draw_mask_res_t mask_res)
lv_color_t color, lv_opa_t opa,
const lv_opa_t * mask, lv_draw_mask_res_t mask_res)
{
#if LV_USE_GPU
@@ -247,7 +250,8 @@ static void fill_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, con
/*Fill the first line. Use `memcpy` because it's faster then simple value assignment*/
/*Set the first pixels manually*/
int32_t direct_fill_end = LV_MATH_MIN(draw_area->x2, draw_area->x1 + FILL_DIRECT_LEN + (draw_area_w & FILL_DIRECT_MASK) - 1);
int32_t direct_fill_end = LV_MATH_MIN(draw_area->x2,
draw_area->x1 + FILL_DIRECT_LEN + (draw_area_w & FILL_DIRECT_MASK) - 1);
for(x = draw_area->x1; x <= direct_fill_end ; x++) {
disp_buf_tmp[x].full = color.full;
}
@@ -286,8 +290,10 @@ static void fill_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, con
#if LV_COLOR_SCREEN_TRANSP
if(disp->driver.screen_transp) {
lv_color_mix_with_alpha(disp_buf_tmp[x], disp_buf_tmp[x].ch.alpha, color, opa, &last_res_color, &last_res_color.ch.alpha);
} else
lv_color_mix_with_alpha(disp_buf_tmp[x], disp_buf_tmp[x].ch.alpha, color, opa, &last_res_color,
&last_res_color.ch.alpha);
}
else
#endif
{
last_res_color = lv_color_mix(color, disp_buf_tmp[x], opa);
@@ -318,12 +324,13 @@ static void fill_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, con
for(y = draw_area->y1; y <= draw_area->y2; y++) {
for(x = draw_area->x1; x <= draw_area->x2; x++) {
if(mask_tmp[x] == 0) continue;
if(mask_tmp[x] != last_mask || last_dest_color.full != disp_buf_tmp[x].full)
{
if(mask_tmp[x] != last_mask || last_dest_color.full != disp_buf_tmp[x].full) {
#if LV_COLOR_SCREEN_TRANSP
if(disp->driver.screen_transp) {
lv_color_mix_with_alpha(disp_buf_tmp[x], disp_buf_tmp[x].ch.alpha, color, mask_tmp[x], &last_res_color, &last_res_color.ch.alpha);
} else
lv_color_mix_with_alpha(disp_buf_tmp[x], disp_buf_tmp[x].ch.alpha, color, mask_tmp[x], &last_res_color,
&last_res_color.ch.alpha);
}
else
#endif
{
if(mask_tmp[x] == LV_OPA_COVER) last_res_color = color;
@@ -349,13 +356,15 @@ static void fill_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, con
lv_opa_t opa_tmp = mask_tmp[x] == LV_OPA_COVER ? opa : (uint32_t)((uint32_t)mask_tmp[x] * opa) >> 8;
#if LV_COLOR_SCREEN_TRANSP
if(disp->driver.screen_transp) {
lv_color_mix_with_alpha(disp_buf_tmp[x], disp_buf_tmp[x].ch.alpha, color, opa_tmp, &last_res_color, &last_res_color.ch.alpha);
} else
lv_color_mix_with_alpha(disp_buf_tmp[x], disp_buf_tmp[x].ch.alpha, color, opa_tmp, &last_res_color,
&last_res_color.ch.alpha);
}
else
#endif
{
if(opa_tmp == LV_OPA_COVER) last_res_color = lv_color_mix(color, disp_buf_tmp[x], mask_tmp[x]);
else if(opa_tmp == LV_OPA_TRANSP) last_res_color = disp_buf_tmp[x];
else last_res_color = lv_color_mix(color, disp_buf_tmp[x],opa_tmp);
else last_res_color = lv_color_mix(color, disp_buf_tmp[x], opa_tmp);
}
last_mask = mask_tmp[x];
last_dest_color.full = disp_buf_tmp[x].full;
@@ -371,8 +380,8 @@ static void fill_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, con
static void fill_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
lv_color_t color, lv_opa_t opa,
const lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_blend_mode_t mode)
lv_color_t color, lv_opa_t opa,
const lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_blend_mode_t mode)
{
/*Get the width of the `disp_area` it will be used to go to the next line*/
int32_t disp_w = lv_area_get_width(disp_area);
@@ -382,17 +391,17 @@ static void fill_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, co
lv_color_t (*blend_fp)(lv_color_t, lv_color_t, lv_opa_t);
switch (mode) {
case LV_BLEND_MODE_ADDITIVE:
blend_fp = color_blend_true_color_additive;
break;
case LV_BLEND_MODE_SUBTRACTIVE:
blend_fp = color_blend_true_color_subtractive;
break;
default:
LV_LOG_WARN("fill_blended: unsupported blend mode");
return;
break;
switch(mode) {
case LV_BLEND_MODE_ADDITIVE:
blend_fp = color_blend_true_color_additive;
break;
case LV_BLEND_MODE_SUBTRACTIVE:
blend_fp = color_blend_true_color_subtractive;
break;
default:
LV_LOG_WARN("fill_blended: unsupported blend mode");
return;
break;
}
int32_t x;
@@ -449,8 +458,8 @@ static void fill_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, co
}
static void map_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
const lv_opa_t * mask, lv_draw_mask_res_t mask_res)
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
const lv_opa_t * mask, lv_draw_mask_res_t mask_res)
{
lv_disp_t * disp = lv_refr_get_disp_refreshing();
@@ -475,11 +484,12 @@ static void map_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, cons
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) {
for(y = draw_area->y1; y <= draw_area->y2; y++) {
for(x = draw_area->x1; x <= draw_area->x2; x++) {
disp->driver.set_px_cb(&disp->driver, (void*)disp_buf, disp_w, x, y, map_buf_tmp[x], opa);
disp->driver.set_px_cb(&disp->driver, (void *)disp_buf, disp_w, x, y, map_buf_tmp[x], opa);
}
map_buf_tmp += map_w;
}
} else {
}
else {
/* The mask is relative to the clipped area.
* In the cycles below mask will be indexed from `draw_area.x1`
* but it corresponds to zero index. So prepare `mask_tmp` accordingly. */
@@ -487,7 +497,8 @@ static void map_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, cons
for(y = draw_area->y1; y <= draw_area->y2; y++) {
for(x = draw_area->x1; x <= draw_area->x2; x++) {
disp->driver.set_px_cb(&disp->driver, (void*)disp_buf, disp_w, x, y, map_buf_tmp[x], (uint32_t)((uint32_t)opa * mask_tmp[x]) >> 8);
disp->driver.set_px_cb(&disp->driver, (void *)disp_buf, disp_w, x, y, map_buf_tmp[x],
(uint32_t)((uint32_t)opa * mask_tmp[x]) >> 8);
}
mask_tmp += draw_area_w;
map_buf_tmp += map_w;
@@ -497,8 +508,8 @@ static void map_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, cons
static void map_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
const lv_opa_t * mask, lv_draw_mask_res_t mask_res)
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
const lv_opa_t * mask, lv_draw_mask_res_t mask_res)
{
/*Get the width of the `disp_area` it will be used to go to the next line*/
@@ -533,8 +544,8 @@ static void map_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, cons
map_buf_tmp += (draw_area->x1 - (map_area->x1 - disp_area->x1));
#if LV_USE_GPU
if(disp->driver.gpu_blend_cb &&
((draw_area_w > GPU_WIDTH_LIMIT * 4 && opa == LV_OPA_COVER) ||
(draw_area_w > GPU_WIDTH_LIMIT && opa != LV_OPA_COVER))) {
((draw_area_w > GPU_WIDTH_LIMIT * 4 && opa == LV_OPA_COVER) ||
(draw_area_w > GPU_WIDTH_LIMIT && opa != LV_OPA_COVER))) {
for(y = draw_area->y1; y <= draw_area->y2; y++) {
disp->driver.gpu_blend_cb(&disp->driver, &disp_buf_tmp[draw_area->x1], map_buf_tmp, draw_area_w, opa);
disp_buf_tmp += disp_w;
@@ -558,8 +569,10 @@ static void map_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, cons
for(x = draw_area->x1; x <= draw_area->x2; x++) {
#if LV_COLOR_SCREEN_TRANSP
if(disp->driver.screen_transp) {
lv_color_mix_with_alpha(disp_buf_tmp[x], disp_buf_tmp[x].ch.alpha, map_buf_tmp[x], opa, &disp_buf_tmp[x], &disp_buf_tmp[x].ch.alpha);
} else
lv_color_mix_with_alpha(disp_buf_tmp[x], disp_buf_tmp[x].ch.alpha, map_buf_tmp[x], opa, &disp_buf_tmp[x],
&disp_buf_tmp[x].ch.alpha);
}
else
#endif
{
disp_buf_tmp[x] = lv_color_mix(map_buf_tmp[x], disp_buf_tmp[x], opa);
@@ -591,15 +604,17 @@ static void map_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, cons
for(x = draw_area->x1; x <= draw_area->x2; x++) {
if(mask_tmp[x] < LV_OPA_MIN) continue;
#if LV_COLOR_SCREEN_TRANSP
if(disp->driver.screen_transp) {
lv_color_mix_with_alpha(disp_buf_tmp[x], disp_buf_tmp[x].ch.alpha, map_buf_tmp[x], mask_tmp[x], &res_color, &opa_composed);
res_color.ch.alpha = opa_composed;
} else
if(disp->driver.screen_transp) {
lv_color_mix_with_alpha(disp_buf_tmp[x], disp_buf_tmp[x].ch.alpha, map_buf_tmp[x], mask_tmp[x], &res_color,
&opa_composed);
res_color.ch.alpha = opa_composed;
}
else
#endif
{
if(mask_tmp[x] > LV_OPA_MAX) res_color = map_buf_tmp[x];
else res_color = lv_color_mix(map_buf_tmp[x], disp_buf_tmp[x], mask_tmp[x]);
}
{
if(mask_tmp[x] > LV_OPA_MAX) res_color = map_buf_tmp[x];
else res_color = lv_color_mix(map_buf_tmp[x], disp_buf_tmp[x], mask_tmp[x]);
}
disp_buf_tmp[x] = res_color;//lv_color_mix(map_buf_tmp[x], disp_buf_tmp[x], mask_tmp[x]);
}
disp_buf_tmp += disp_w;
@@ -616,8 +631,10 @@ static void map_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, cons
lv_opa_t opa_tmp = mask_tmp[x] >= LV_OPA_MAX ? opa : ((opa * mask_tmp[x]) >> 8);
#if LV_COLOR_SCREEN_TRANSP
if(disp->driver.screen_transp) {
lv_color_mix_with_alpha(disp_buf_tmp[x], disp_buf_tmp[x].ch.alpha, map_buf_tmp[x], opa_tmp, &disp_buf_tmp[x], &disp_buf_tmp[x].ch.alpha);
} else
lv_color_mix_with_alpha(disp_buf_tmp[x], disp_buf_tmp[x].ch.alpha, map_buf_tmp[x], opa_tmp, &disp_buf_tmp[x],
&disp_buf_tmp[x].ch.alpha);
}
else
#endif
{
disp_buf_tmp[x] = lv_color_mix(map_buf_tmp[x], disp_buf_tmp[x], opa_tmp);
@@ -632,8 +649,8 @@ static void map_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, cons
}
static void map_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
const lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_blend_mode_t mode)
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
const lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_blend_mode_t mode)
{
/*Get the width of the `disp_area` it will be used to go to the next line*/
@@ -652,17 +669,17 @@ static void map_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, con
const lv_color_t * map_buf_tmp = map_buf + map_w * (draw_area->y1 - (map_area->y1 - disp_area->y1));
lv_color_t (*blend_fp)(lv_color_t, lv_color_t, lv_opa_t);
switch (mode) {
case LV_BLEND_MODE_ADDITIVE:
blend_fp = color_blend_true_color_additive;
break;
case LV_BLEND_MODE_SUBTRACTIVE:
blend_fp = color_blend_true_color_subtractive;
break;
default:
LV_LOG_WARN("fill_blended: unsupported blend mode");
return;
break;
switch(mode) {
case LV_BLEND_MODE_ADDITIVE:
blend_fp = color_blend_true_color_additive;
break;
case LV_BLEND_MODE_SUBTRACTIVE:
blend_fp = color_blend_true_color_subtractive;
break;
default:
LV_LOG_WARN("fill_blended: unsupported blend mode");
return;
break;
}
int32_t x;

View File

@@ -37,7 +37,7 @@ typedef uint8_t lv_blend_mode_t;
**********************/
void lv_blend_fill(const lv_area_t * clip_area, const lv_area_t * fill_area, lv_color_t color,
lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_opa_t opa, lv_blend_mode_t mode);
lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_opa_t opa, lv_blend_mode_t mode);
void lv_blend_map(const lv_area_t * clip_area, const lv_area_t * map_area, const lv_color_t * map_buf,

View File

@@ -25,10 +25,12 @@
/**********************
* STATIC PROTOTYPES
**********************/
static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mask, const void * src, lv_draw_img_dsc_t * draw_dsc);
static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mask, const void * src,
lv_draw_img_dsc_t * draw_dsc);
static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area, const uint8_t * map_p, lv_draw_img_dsc_t * draw_dsc,
bool chroma_key, bool alpha_byte);
static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area, const uint8_t * map_p,
lv_draw_img_dsc_t * draw_dsc,
bool chroma_key, bool alpha_byte);
void show_error(const lv_area_t * coords, const lv_area_t * clip_area, const char * msg);
/**********************
@@ -94,20 +96,36 @@ uint8_t lv_img_cf_get_px_size(lv_img_cf_t cf)
uint8_t px_size = 0;
switch(cf) {
case LV_IMG_CF_UNKNOWN:
case LV_IMG_CF_RAW: px_size = 0; break;
case LV_IMG_CF_TRUE_COLOR:
case LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED: px_size = LV_COLOR_SIZE; break;
case LV_IMG_CF_TRUE_COLOR_ALPHA: px_size = LV_IMG_PX_SIZE_ALPHA_BYTE << 3; break;
case LV_IMG_CF_INDEXED_1BIT:
case LV_IMG_CF_ALPHA_1BIT: px_size = 1; break;
case LV_IMG_CF_INDEXED_2BIT:
case LV_IMG_CF_ALPHA_2BIT: px_size = 2; break;
case LV_IMG_CF_INDEXED_4BIT:
case LV_IMG_CF_ALPHA_4BIT: px_size = 4; break;
case LV_IMG_CF_INDEXED_8BIT:
case LV_IMG_CF_ALPHA_8BIT: px_size = 8; break;
default: px_size = 0; break;
case LV_IMG_CF_UNKNOWN:
case LV_IMG_CF_RAW:
px_size = 0;
break;
case LV_IMG_CF_TRUE_COLOR:
case LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED:
px_size = LV_COLOR_SIZE;
break;
case LV_IMG_CF_TRUE_COLOR_ALPHA:
px_size = LV_IMG_PX_SIZE_ALPHA_BYTE << 3;
break;
case LV_IMG_CF_INDEXED_1BIT:
case LV_IMG_CF_ALPHA_1BIT:
px_size = 1;
break;
case LV_IMG_CF_INDEXED_2BIT:
case LV_IMG_CF_ALPHA_2BIT:
px_size = 2;
break;
case LV_IMG_CF_INDEXED_4BIT:
case LV_IMG_CF_ALPHA_4BIT:
px_size = 4;
break;
case LV_IMG_CF_INDEXED_8BIT:
case LV_IMG_CF_ALPHA_8BIT:
px_size = 8;
break;
default:
px_size = 0;
break;
}
return px_size;
@@ -123,17 +141,20 @@ bool lv_img_cf_is_chroma_keyed(lv_img_cf_t cf)
bool is_chroma_keyed = false;
switch(cf) {
case LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED:
case LV_IMG_CF_RAW_CHROMA_KEYED:
case LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED:
case LV_IMG_CF_RAW_CHROMA_KEYED:
#if LV_INDEXED_CHROMA
case LV_IMG_CF_INDEXED_1BIT:
case LV_IMG_CF_INDEXED_2BIT:
case LV_IMG_CF_INDEXED_4BIT:
case LV_IMG_CF_INDEXED_8BIT:
case LV_IMG_CF_INDEXED_1BIT:
case LV_IMG_CF_INDEXED_2BIT:
case LV_IMG_CF_INDEXED_4BIT:
case LV_IMG_CF_INDEXED_8BIT:
#endif
is_chroma_keyed = true; break;
is_chroma_keyed = true;
break;
default: is_chroma_keyed = false; break;
default:
is_chroma_keyed = false;
break;
}
return is_chroma_keyed;
@@ -149,17 +170,21 @@ bool lv_img_cf_has_alpha(lv_img_cf_t cf)
bool has_alpha = false;
switch(cf) {
case LV_IMG_CF_TRUE_COLOR_ALPHA:
case LV_IMG_CF_RAW_ALPHA:
case LV_IMG_CF_INDEXED_1BIT:
case LV_IMG_CF_INDEXED_2BIT:
case LV_IMG_CF_INDEXED_4BIT:
case LV_IMG_CF_INDEXED_8BIT:
case LV_IMG_CF_ALPHA_1BIT:
case LV_IMG_CF_ALPHA_2BIT:
case LV_IMG_CF_ALPHA_4BIT:
case LV_IMG_CF_ALPHA_8BIT: has_alpha = true; break;
default: has_alpha = false; break;
case LV_IMG_CF_TRUE_COLOR_ALPHA:
case LV_IMG_CF_RAW_ALPHA:
case LV_IMG_CF_INDEXED_1BIT:
case LV_IMG_CF_INDEXED_2BIT:
case LV_IMG_CF_INDEXED_4BIT:
case LV_IMG_CF_INDEXED_8BIT:
case LV_IMG_CF_ALPHA_1BIT:
case LV_IMG_CF_ALPHA_2BIT:
case LV_IMG_CF_ALPHA_4BIT:
case LV_IMG_CF_ALPHA_8BIT:
has_alpha = true;
break;
default:
has_alpha = false;
break;
}
return has_alpha;
@@ -183,9 +208,11 @@ lv_img_src_t lv_img_src_get_type(const void * src)
/*The first byte shows the type of the image source*/
if(u8_p[0] >= 0x20 && u8_p[0] <= 0x7F) {
img_src_type = LV_IMG_SRC_FILE; /*If it's an ASCII character then it's file name*/
} else if(u8_p[0] >= 0x80) {
}
else if(u8_p[0] >= 0x80) {
img_src_type = LV_IMG_SRC_SYMBOL; /*Symbols begins after 0x7F*/
} else {
}
else {
img_src_type = LV_IMG_SRC_VARIABLE; /*`lv_img_dsc_t` is design to the first byte < 0x20*/
}
@@ -200,7 +227,8 @@ lv_img_src_t lv_img_src_get_type(const void * src)
* STATIC FUNCTIONS
**********************/
static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mask, const void * src, lv_draw_img_dsc_t * draw_dsc)
static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mask, const void * src,
lv_draw_img_dsc_t * draw_dsc)
{
if(draw_dsc->opa <= LV_OPA_MIN) return LV_RES_OK;
@@ -255,7 +283,8 @@ static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mas
int32_t width = lv_area_get_width(&mask_com);
uint8_t * buf = lv_mem_buf_get(lv_area_get_width(&mask_com) * LV_IMG_PX_SIZE_ALPHA_BYTE); /*+1 because of the possible alpha byte*/
uint8_t * buf = lv_mem_buf_get(lv_area_get_width(&mask_com) *
LV_IMG_PX_SIZE_ALPHA_BYTE); /*+1 because of the possible alpha byte*/
lv_area_t line;
lv_area_copy(&line, &mask_com);
@@ -303,7 +332,8 @@ static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mas
* @param zoom zoom factor
* @param antialias anti-alias transformations (rotate, zoom) or not
*/
static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area, const uint8_t * map_p, lv_draw_img_dsc_t * draw_dsc, bool chroma_key, bool alpha_byte)
static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area, const uint8_t * map_p,
lv_draw_img_dsc_t * draw_dsc, bool chroma_key, bool alpha_byte)
{
/* Use the clip area as draw area*/
lv_area_t draw_area;
@@ -326,7 +356,8 @@ static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area,
if(other_mask_cnt == 0 && draw_dsc->angle == 0 && draw_dsc->zoom == LV_IMG_ZOOM_NONE &&
chroma_key == false && alpha_byte == false &&
draw_dsc->opa == LV_OPA_COVER && draw_dsc->recolor_opa == LV_OPA_TRANSP) {
lv_blend_map(clip_area, map_area, (lv_color_t *)map_p, NULL, LV_DRAW_MASK_RES_FULL_COVER, LV_OPA_COVER, draw_dsc->blend_mode);
lv_blend_map(clip_area, map_area, (lv_color_t *)map_p, NULL, LV_DRAW_MASK_RES_FULL_COVER, LV_OPA_COVER,
draw_dsc->blend_mode);
}
/*In the other cases every pixel need to be checked one-by-one*/
else {
@@ -406,7 +437,8 @@ static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area,
#endif
continue;
}
} else {
}
else {
mask_buf[px_i] = LV_OPA_COVER;
}
@@ -415,15 +447,16 @@ static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area,
#elif LV_COLOR_DEPTH == 16
c.full = map_px[0] + (map_px[1] << 8);
#elif LV_COLOR_DEPTH == 32
c.full = *((uint32_t*)map_px);
c.full = *((uint32_t *)map_px);
#endif
if (chroma_key) {
if(chroma_key) {
if(c.full == chroma_keyed_color.full) {
mask_buf[px_i] = LV_OPA_TRANSP;
continue;
}
}
} else {
}
else {
/*Rotate*/
bool ret;
int32_t rot_x = x + (disp_area->x1 + draw_area.x1) - map_area->x1;
@@ -432,7 +465,8 @@ static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area,
if(ret == false) {
mask_buf[px_i] = LV_OPA_TRANSP;
continue;
} else {
}
else {
mask_buf[px_i] = trans_dsc.res.opa;
c.full = trans_dsc.res.color.full;
}
@@ -448,11 +482,13 @@ static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area,
/*Apply the masks if any*/
if(other_mask_cnt) {
lv_draw_mask_res_t mask_res_sub;
mask_res_sub = lv_draw_mask_apply(mask_buf + px_i_start, draw_area.x1 + vdb->area.x1, y + draw_area.y1 + vdb->area.y1, lv_area_get_width(&draw_area));
mask_res_sub = lv_draw_mask_apply(mask_buf + px_i_start, draw_area.x1 + vdb->area.x1, y + draw_area.y1 + vdb->area.y1,
lv_area_get_width(&draw_area));
if(mask_res_sub == LV_DRAW_MASK_RES_FULL_TRANSP) {
memset(mask_buf + px_i_start, 0x00, lv_area_get_width(&draw_area));
mask_res = LV_DRAW_MASK_RES_CHANGED;
} else if(mask_res_sub == LV_DRAW_MASK_RES_CHANGED) {
}
else if(mask_res_sub == LV_DRAW_MASK_RES_CHANGED) {
mask_res = LV_DRAW_MASK_RES_CHANGED;
}
}
@@ -460,7 +496,8 @@ static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area,
map_buf_tmp += map_w * px_size_byte;
if(px_i + lv_area_get_width(&draw_area) < mask_buf_size) {
blend_area.y2 ++;
} else {
}
else {
lv_blend_map(clip_area, &blend_area, map2, mask_buf, mask_res, draw_dsc->opa, draw_dsc->blend_mode);
blend_area.y1 = blend_area.y2 + 1;

View File

@@ -40,7 +40,7 @@ typedef struct {
lv_blend_mode_t blend_mode;
uint8_t antialias :1;
uint8_t antialias : 1;
} lv_draw_img_dsc_t;
/**********************

View File

@@ -32,10 +32,13 @@ typedef uint8_t cmd_state_t;
/**********************
* STATIC PROTOTYPES
**********************/
static void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * clip_area, const lv_font_t * font_p, uint32_t letter,
lv_color_t color, lv_opa_t opa);
static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_dsc_t * g, const lv_area_t * clip_area, const uint8_t * map_p, lv_color_t color, lv_opa_t opa);
static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_dsc_t * g, const lv_area_t * clip_area, const uint8_t * map_p, lv_color_t color, lv_opa_t opa);
static void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * clip_area, const lv_font_t * font_p,
uint32_t letter,
lv_color_t color, lv_opa_t opa);
static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_dsc_t * g, const lv_area_t * clip_area,
const uint8_t * map_p, lv_color_t color, lv_opa_t opa);
static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_dsc_t * g, const lv_area_t * clip_area,
const uint8_t * map_p, lv_color_t color, lv_opa_t opa);
static uint8_t hex_char_to_num(char hex);
@@ -49,8 +52,9 @@ static const uint8_t bpp2_opa_table[4] = {0, 85, 170, 255}; /*Opacity mapping w
static const uint8_t bpp4_opa_table[16] = {0, 17, 34, 51, /*Opacity mapping with bpp = 4*/
68, 85, 102, 119,
136, 153, 170, 187,
204, 221, 238, 255};
/*clang-format on*/
204, 221, 238, 255
};
/*clang-format on*/
/**********************
* MACROS
@@ -87,7 +91,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab
int32_t w;
/*No need to waste processor time if string is empty*/
if (txt[0] == '\0') return;
if(txt[0] == '\0') return;
lv_area_t clipped_area;
bool clip_ok = lv_area_intersect(&clipped_area, coords, mask);
@@ -97,11 +101,12 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab
if((dsc->flag & LV_TXT_FLAG_EXPAND) == 0) {
/*Normally use the label's width as width*/
w = lv_area_get_width(coords);
} else {
}
else {
/*If EXAPND is enabled then not limit the text's width to the object's width*/
lv_point_t p;
lv_txt_get_size(&p, txt, dsc->font, dsc->letter_space, dsc->line_space, LV_COORD_MAX,
dsc->flag);
dsc->flag);
w = p.x;
}
@@ -209,10 +214,10 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab
cmd_state = CMD_STATE_WAIT;
i = 0;
#if LV_USE_BIDI
char *bidi_txt = lv_mem_buf_get(line_end - line_start + 1);
char * bidi_txt = lv_mem_buf_get(line_end - line_start + 1);
lv_bidi_process_paragraph(txt + line_start, bidi_txt, line_end - line_start, dsc->bidi_dir, NULL, 0);
#else
const char *bidi_txt = txt + line_start;
const char * bidi_txt = txt + line_start;
#endif
while(i < line_end - line_start) {
@@ -237,9 +242,11 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab
par_start = i;
cmd_state = CMD_STATE_PAR;
continue;
} else if(cmd_state == CMD_STATE_PAR) { /*Other start char in parameter escaped cmd. char */
}
else if(cmd_state == CMD_STATE_PAR) { /*Other start char in parameter escaped cmd. char */
cmd_state = CMD_STATE_WAIT;
} else if(cmd_state == CMD_STATE_IN) { /*Command end */
}
else if(cmd_state == CMD_STATE_IN) { /*Command end */
cmd_state = CMD_STATE_WAIT;
continue;
}
@@ -258,7 +265,8 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab
g = (hex_char_to_num(buf[2]) << 4) + hex_char_to_num(buf[3]);
b = (hex_char_to_num(buf[4]) << 4) + hex_char_to_num(buf[5]);
recolor = lv_color_make(r, g, b);
} else {
}
else {
recolor.full = dsc->color.full;
}
cmd_state = CMD_STATE_IN; /*After the parameter the text is in the command*/
@@ -323,7 +331,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab
/*Align to middle*/
if(dsc->flag & LV_TXT_FLAG_CENTER) {
line_width =
lv_txt_get_width(&txt[line_start], line_end - line_start, font, dsc->letter_space, dsc->flag);
lv_txt_get_width(&txt[line_start], line_end - line_start, font, dsc->letter_space, dsc->flag);
pos.x += (lv_area_get_width(coords) - line_width) / 2;
@@ -331,7 +339,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab
/*Align to the right*/
else if(dsc->flag & LV_TXT_FLAG_RIGHT) {
line_width =
lv_txt_get_width(&txt[line_start], line_end - line_start, font, dsc->letter_space, dsc->flag);
lv_txt_get_width(&txt[line_start], line_end - line_start, font, dsc->letter_space, dsc->flag);
pos.x += lv_area_get_width(coords) - line_width;
}
@@ -358,8 +366,9 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab
* @param color color of letter
* @param opa opacity of letter (0..255)
*/
static void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * clip_area, const lv_font_t * font_p, uint32_t letter,
lv_color_t color, lv_opa_t opa)
static void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * clip_area, const lv_font_t * font_p,
uint32_t letter,
lv_color_t color, lv_opa_t opa)
{
if(opa < LV_OPA_MIN) return;
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
@@ -385,9 +394,9 @@ static void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * clip_area
/*If the letter is completely out of mask don't draw it */
if(pos_x + g.box_w < clip_area->x1 ||
pos_x > clip_area->x2 ||
pos_y + g.box_h < clip_area->y1 ||
pos_y > clip_area->y2) return;
pos_x > clip_area->x2 ||
pos_y + g.box_h < clip_area->y1 ||
pos_y > clip_area->y2) return;
const uint8_t * map_p = lv_font_get_glyph_bitmap(font_p, letter);
@@ -398,13 +407,15 @@ static void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * clip_area
if(font_p->subpx) {
draw_letter_subpx(pos_x, pos_y, &g, clip_area, map_p, color, opa);
} else {
}
else {
draw_letter_normal(pos_x, pos_y, &g, clip_area, map_p, color, opa);
}
}
static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_dsc_t * g, const lv_area_t * clip_area, const uint8_t * map_p, lv_color_t color, lv_opa_t opa)
static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_dsc_t * g, const lv_area_t * clip_area,
const uint8_t * map_p, lv_color_t color, lv_opa_t opa)
{
const uint8_t * bpp_opa_table;
@@ -414,25 +425,25 @@ static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph
if(bpp == 3) bpp = 4;
switch(bpp) {
case 1:
bpp_opa_table = bpp1_opa_table;
bitmask_init = 0x80;
break;
case 2:
bpp_opa_table = bpp2_opa_table;
bitmask_init = 0xC0;
break;
case 4:
bpp_opa_table = bpp4_opa_table;
bitmask_init = 0xF0;
break;
case 8:
bpp_opa_table = NULL;
bitmask_init = 0xFF;
break; /*No opa table, pixel value will be used directly*/
default:
LV_LOG_WARN("lv_draw_letter: invalid bpp not found");
return; /*Invalid bpp. Can't render the letter*/
case 1:
bpp_opa_table = bpp1_opa_table;
bitmask_init = 0x80;
break;
case 2:
bpp_opa_table = bpp2_opa_table;
bitmask_init = 0xC0;
break;
case 4:
bpp_opa_table = bpp4_opa_table;
bitmask_init = 0xF0;
break;
case 8:
bpp_opa_table = NULL;
bitmask_init = 0xFF;
break; /*No opa table, pixel value will be used directly*/
default:
LV_LOG_WARN("lv_draw_letter: invalid bpp not found");
return; /*Invalid bpp. Can't render the letter*/
}
@@ -482,14 +493,16 @@ static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph
if(letter_px != 0) {
if(opa == LV_OPA_COVER) {
px_opa = bpp == 8 ? letter_px : bpp_opa_table[letter_px];
} else {
}
else {
px_opa = bpp == 8 ? (uint32_t)((uint32_t)letter_px * opa) >> 8
: (uint32_t)((uint32_t)bpp_opa_table[letter_px] * opa) >> 8;
: (uint32_t)((uint32_t)bpp_opa_table[letter_px] * opa) >> 8;
}
mask_buf[mask_p] = px_opa;
} else {
}
else {
mask_buf[mask_p] = 0;
}
@@ -497,7 +510,8 @@ static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph
if(col_bit < 8 - bpp) {
col_bit += bpp;
bitmask = bitmask >> bpp;
} else {
}
else {
col_bit = 0;
bitmask = bitmask_init;
map_p++;
@@ -509,7 +523,8 @@ static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph
/*Apply masks if any*/
if(other_mask_cnt) {
lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf + mask_p_start, fill_area.x1, fill_area.y2, lv_area_get_width(&fill_area));
lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf + mask_p_start, fill_area.x1, fill_area.y2,
lv_area_get_width(&fill_area));
if(mask_res == LV_DRAW_MASK_RES_FULL_TRANSP) {
memset(mask_buf + mask_p_start, 0x00, lv_area_get_width(&fill_area));
}
@@ -517,10 +532,11 @@ static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph
if((uint32_t) mask_p + (row_end - row_start) < mask_buf_size) {
fill_area.y2 ++;
} else {
}
else {
lv_blend_fill(clip_area, &fill_area,
color, mask_buf, LV_DRAW_MASK_RES_CHANGED, opa,
LV_BLEND_MODE_NORMAL);
color, mask_buf, LV_DRAW_MASK_RES_CHANGED, opa,
LV_BLEND_MODE_NORMAL);
fill_area.y1 = fill_area.y2 + 1;
fill_area.y2 = fill_area.y1;
@@ -537,15 +553,16 @@ static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph
if(fill_area.y1 != fill_area.y2) {
fill_area.y2--;
lv_blend_fill(clip_area, &fill_area,
color, mask_buf, LV_DRAW_MASK_RES_CHANGED, opa,
LV_BLEND_MODE_NORMAL);
color, mask_buf, LV_DRAW_MASK_RES_CHANGED, opa,
LV_BLEND_MODE_NORMAL);
mask_p = 0;
}
lv_mem_buf_release(mask_buf);
}
static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_dsc_t * g, const lv_area_t * clip_area, const uint8_t * map_p, lv_color_t color, lv_opa_t opa)
static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_dsc_t * g, const lv_area_t * clip_area,
const uint8_t * map_p, lv_color_t color, lv_opa_t opa)
{
const uint8_t * bpp_opa_table;
uint32_t bitmask_init;
@@ -554,25 +571,25 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
if(bpp == 3) bpp = 4;
switch(bpp) {
case 1:
bpp_opa_table = bpp1_opa_table;
bitmask_init = 0x80;
break;
case 2:
bpp_opa_table = bpp2_opa_table;
bitmask_init = 0xC0;
break;
case 4:
bpp_opa_table = bpp4_opa_table;
bitmask_init = 0xF0;
break;
case 8:
bpp_opa_table = NULL;
bitmask_init = 0xFF;
break; /*No opa table, pixel value will be used directly*/
default:
LV_LOG_WARN("lv_draw_letter: invalid bpp not found");
return; /*Invalid bpp. Can't render the letter*/
case 1:
bpp_opa_table = bpp1_opa_table;
bitmask_init = 0x80;
break;
case 2:
bpp_opa_table = bpp2_opa_table;
bitmask_init = 0xC0;
break;
case 4:
bpp_opa_table = bpp4_opa_table;
bitmask_init = 0xF0;
break;
case 8:
bpp_opa_table = NULL;
bitmask_init = 0xFF;
break; /*No opa table, pixel value will be used directly*/
default:
LV_LOG_WARN("lv_draw_letter: invalid bpp not found");
return; /*Invalid bpp. Can't render the letter*/
}
int32_t col, row;
@@ -644,11 +661,13 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
if(letter_px != 0) {
if(opa == LV_OPA_COVER) {
px_opa = bpp == 8 ? letter_px : bpp_opa_table[letter_px];
} else {
px_opa = bpp == 8 ? (uint32_t)((uint32_t)letter_px * opa) >> 8
: (uint32_t)((uint32_t)bpp_opa_table[letter_px] * opa) >> 8;
}
} else {
else {
px_opa = bpp == 8 ? (uint32_t)((uint32_t)letter_px * opa) >> 8
: (uint32_t)((uint32_t)bpp_opa_table[letter_px] * opa) >> 8;
}
}
else {
px_opa = 0;
}
@@ -660,11 +679,12 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
lv_color_t res_color;
#if LV_COLOR_16_SWAP == 0
uint8_t bg_rgb[3] = {vdb_buf_tmp->ch.red, vdb_buf_tmp->ch.green, vdb_buf_tmp->ch.blue};
uint8_t bg_rgb[3] = {vdb_buf_tmp->ch.red, vdb_buf_tmp->ch.green, vdb_buf_tmp->ch.blue};
#else
uint8_t bg_rgb[3] = {vdb_buf_tmp->ch.red,
(vdb_buf_tmp->ch.green_h << 3) + vdb_buf_tmp->ch.green_l,
vdb_buf_tmp->ch.blue};
uint8_t bg_rgb[3] = {vdb_buf_tmp->ch.red,
(vdb_buf_tmp->ch.green_h << 3) + vdb_buf_tmp->ch.green_l,
vdb_buf_tmp->ch.blue
};
#endif
#if LV_FONT_SUBPX_BGR
@@ -676,11 +696,11 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
#endif
#if LV_COLOR_16_SWAP == 0
res_color.ch.green = (uint32_t)((uint32_t)txt_rgb[1] * font_rgb[1] + (bg_rgb[1] * (255 - font_rgb[1]))) >> 8;
res_color.ch.green = (uint32_t)((uint32_t)txt_rgb[1] * font_rgb[1] + (bg_rgb[1] * (255 - font_rgb[1]))) >> 8;
#else
uint8_t green = (uint32_t)((uint32_t)txt_rgb[1] * font_rgb[1] + (bg_rgb[1] * (255 - font_rgb[1]))) >> 8;
res_color.ch.green_h = green >> 3;
res_color.ch.green_l = green & 0x7;
uint8_t green = (uint32_t)((uint32_t)txt_rgb[1] * font_rgb[1] + (bg_rgb[1] * (255 - font_rgb[1]))) >> 8;
res_color.ch.green_h = green >> 3;
res_color.ch.green_l = green & 0x7;
#endif
if(font_rgb[0] == 0 && font_rgb[1] == 0 && font_rgb[2] == 0) mask_buf[mask_p] = LV_OPA_TRANSP;
@@ -696,7 +716,8 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
if(col_bit < 8 - bpp) {
col_bit += bpp;
bitmask = bitmask >> bpp;
} else {
}
else {
col_bit = 0;
bitmask = bitmask_init;
map_p++;
@@ -705,7 +726,8 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
/*Apply masks if any*/
if(other_mask_cnt) {
lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf + mask_p_start, map_area.x1, map_area.y2, lv_area_get_width(&map_area));
lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf + mask_p_start, map_area.x1, map_area.y2,
lv_area_get_width(&map_area));
if(mask_res == LV_DRAW_MASK_RES_FULL_TRANSP) {
memset(mask_buf + mask_p_start, 0x00, lv_area_get_width(&map_area));
}
@@ -713,7 +735,8 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
if((uint32_t) mask_p + (row_end - row_start) < mask_buf_size) {
map_area.y2 ++;
} else {
}
else {
lv_blend_map(clip_area, &map_area, color_buf, mask_buf, LV_DRAW_MASK_RES_CHANGED, opa, LV_BLEND_MODE_NORMAL);
map_area.y1 = map_area.y2 + 1;
@@ -752,17 +775,32 @@ static uint8_t hex_char_to_num(char hex)
if(hex >= '0' && hex <= '9') {
result = hex - '0';
} else {
}
else {
if(hex >= 'a') hex -= 'a' - 'A'; /*Convert to upper case*/
switch(hex) {
case 'A': result = 10; break;
case 'B': result = 11; break;
case 'C': result = 12; break;
case 'D': result = 13; break;
case 'E': result = 14; break;
case 'F': result = 15; break;
default: result = 0; break;
case 'A':
result = 10;
break;
case 'B':
result = 11;
break;
case 'C':
result = 12;
break;
case 'D':
result = 13;
break;
case 'E':
result = 14;
break;
case 'F':
result = 15;
break;
default:
result = 0;
break;
}
}

View File

@@ -41,7 +41,7 @@ typedef struct {
lv_txt_flag_t flag;
lv_text_decor_t decor;
lv_blend_mode_t blend_mode;
}lv_draw_label_dsc_t;
} lv_draw_label_dsc_t;
/** Store some info to speed up drawing of very large texts
* It takes a lot of time to get the first visible character because
@@ -58,7 +58,7 @@ typedef struct {
/** The 'y1' coordinate of the label when the hint was saved.
* Used to invalidate the hint if the label has moved too much. */
int32_t coord_y;
}lv_draw_label_hint_t;
} lv_draw_label_hint_t;
/**********************
* GLOBAL PROTOTYPES

View File

@@ -24,9 +24,12 @@
/**********************
* STATIC PROTOTYPES
**********************/
static void draw_line_skew(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip, lv_draw_line_dsc_t * dsc);
static void draw_line_hor(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip, lv_draw_line_dsc_t * dsc);
static void draw_line_ver(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip, lv_draw_line_dsc_t * dsc);
static void draw_line_skew(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip,
lv_draw_line_dsc_t * dsc);
static void draw_line_hor(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip,
lv_draw_line_dsc_t * dsc);
static void draw_line_ver(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip,
lv_draw_line_dsc_t * dsc);
/**********************
* STATIC VARIABLES
@@ -56,7 +59,8 @@ void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc)
* @param style pointer to a line's style
* @param opa_scale scale down all opacities by the factor
*/
void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip, lv_draw_line_dsc_t * dsc)
void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip,
lv_draw_line_dsc_t * dsc)
{
if(dsc->width == 0) return;
if(dsc->opa <= LV_OPA_MIN) return;
@@ -64,10 +68,10 @@ void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv
if(point1->x == point2->x && point1->y == point2->y) return;
lv_area_t clip_line;
clip_line.x1 = LV_MATH_MIN(point1->x, point2->x) - dsc->width/2;
clip_line.x2 = LV_MATH_MAX(point1->x, point2->x) + dsc->width/2;
clip_line.y1 = LV_MATH_MIN(point1->y, point2->y) - dsc->width/2;
clip_line.y2 = LV_MATH_MAX(point1->y, point2->y) + dsc->width/2;
clip_line.x1 = LV_MATH_MIN(point1->x, point2->x) - dsc->width / 2;
clip_line.x2 = LV_MATH_MAX(point1->x, point2->x) + dsc->width / 2;
clip_line.y1 = LV_MATH_MIN(point1->y, point2->y) - dsc->width / 2;
clip_line.y2 = LV_MATH_MAX(point1->y, point2->y) + dsc->width / 2;
bool is_common;
is_common = lv_area_intersect(&clip_line, &clip_line, clip);
@@ -111,7 +115,8 @@ void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv
* STATIC FUNCTIONS
**********************/
static void draw_line_hor(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip, lv_draw_line_dsc_t * dsc)
static void draw_line_hor(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip,
lv_draw_line_dsc_t * dsc)
{
lv_opa_t opa = dsc->opa;
@@ -139,8 +144,8 @@ static void draw_line_hor(const lv_point_t * point1, const lv_point_t * point2,
/*If there is no mask then simply draw a rectangle*/
if(simple_mode) {
lv_blend_fill(clip, &draw_area,
dsc->color, NULL, LV_DRAW_MASK_RES_FULL_COVER,opa,
LV_BLEND_MODE_NORMAL);
dsc->color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa,
LV_BLEND_MODE_NORMAL);
}
/*If there other mask apply it*/
else {
@@ -170,42 +175,45 @@ static void draw_line_hor(const lv_point_t * point1, const lv_point_t * point2,
lv_opa_t * mask_buf = lv_mem_buf_get(draw_area_w);
int32_t h;
for(h = draw_area.y1; h <= draw_area.y2; h++) {
memset(mask_buf, LV_OPA_COVER, draw_area_w);
lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
memset(mask_buf, LV_OPA_COVER, draw_area_w);
lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
if(dashed) {
if(mask_res != LV_DRAW_MASK_RES_FULL_TRANSP) {
if(dashed) {
if(mask_res != LV_DRAW_MASK_RES_FULL_TRANSP) {
lv_style_int_t dash_cnt = dash_start;
uint32_t i;
for(i = 0; i < draw_area_w; i++, dash_cnt++) {
if(dash_cnt <= dsc->dash_width) {
int16_t diff = dsc->dash_width - dash_cnt;
i += diff;
dash_cnt += diff;
} else if(dash_cnt >= dsc->dash_gap + dsc->dash_width) {
dash_cnt = 0;
} else {
mask_buf[i] = 0x00;
}
}
uint32_t i;
for(i = 0; i < draw_area_w; i++, dash_cnt++) {
if(dash_cnt <= dsc->dash_width) {
int16_t diff = dsc->dash_width - dash_cnt;
i += diff;
dash_cnt += diff;
}
else if(dash_cnt >= dsc->dash_gap + dsc->dash_width) {
dash_cnt = 0;
}
else {
mask_buf[i] = 0x00;
}
}
mask_res = LV_DRAW_MASK_RES_CHANGED;
}
}
mask_res = LV_DRAW_MASK_RES_CHANGED;
}
}
lv_blend_fill(clip, &fill_area,
dsc->color, mask_buf, mask_res, dsc->opa,
dsc->blend_mode);
lv_blend_fill(clip, &fill_area,
dsc->color, mask_buf, mask_res, dsc->opa,
dsc->blend_mode);
fill_area.y1++;
fill_area.y2++;
}
fill_area.y1++;
fill_area.y2++;
}
lv_mem_buf_release(mask_buf);
}
}
static void draw_line_ver(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip, lv_draw_line_dsc_t * dsc)
static void draw_line_ver(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip,
lv_draw_line_dsc_t * dsc)
{
lv_opa_t opa = dsc->opa;
@@ -233,8 +241,8 @@ static void draw_line_ver(const lv_point_t * point1, const lv_point_t * point2,
/*If there is no mask then simply draw a rectangle*/
if(simple_mode) {
lv_blend_fill(clip, &draw_area,
dsc->color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa,
dsc->blend_mode);
dsc->color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa,
dsc->blend_mode);
}
/*If there other mask apply it*/
else {
@@ -266,35 +274,36 @@ static void draw_line_ver(const lv_point_t * point1, const lv_point_t * point2,
int32_t h;
for(h = draw_area.y1; h <= draw_area.y2; h++) {
memset(mask_buf, LV_OPA_COVER, draw_area_w);
lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
memset(mask_buf, LV_OPA_COVER, draw_area_w);
lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
if(dashed) {
if(mask_res != LV_DRAW_MASK_RES_FULL_TRANSP) {
if(dash_cnt > dsc->dash_width) {
mask_res = LV_DRAW_MASK_RES_FULL_TRANSP;
}
if(dashed) {
if(mask_res != LV_DRAW_MASK_RES_FULL_TRANSP) {
if(dash_cnt > dsc->dash_width) {
mask_res = LV_DRAW_MASK_RES_FULL_TRANSP;
}
if(dash_cnt >= dsc->dash_gap + dsc->dash_width) {
dash_cnt = 0;
}
}
dash_cnt ++;
}
if(dash_cnt >= dsc->dash_gap + dsc->dash_width) {
dash_cnt = 0;
}
}
dash_cnt ++;
}
lv_blend_fill(clip, &fill_area,
dsc->color, mask_buf, mask_res, dsc->opa,
LV_BLEND_MODE_NORMAL);
lv_blend_fill(clip, &fill_area,
dsc->color, mask_buf, mask_res, dsc->opa,
LV_BLEND_MODE_NORMAL);
fill_area.y1++;
fill_area.y2++;
}
fill_area.y1++;
fill_area.y2++;
}
lv_mem_buf_release(mask_buf);
}
}
static void draw_line_skew(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip, lv_draw_line_dsc_t * dsc)
static void draw_line_skew(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip,
lv_draw_line_dsc_t * dsc)
{
lv_opa_t opa = dsc->opa;
@@ -306,7 +315,8 @@ static void draw_line_skew(const lv_point_t * point1, const lv_point_t * point2,
p2.y = point2->y;
p1.x = point1->x;
p2.x = point2->x;
} else {
}
else {
p1.y = point2->y;
p2.y = point1->y;
p1.x = point2->x;
@@ -353,20 +363,28 @@ static void draw_line_skew(const lv_point_t * point1, const lv_point_t * point2,
if(flat) {
if(xdiff > 0) {
lv_draw_mask_line_points_init(&mask_left_param, p1.x, p1.y - w_half0, p2.x, p2.y - w_half0, LV_DRAW_MASK_LINE_SIDE_LEFT);
lv_draw_mask_line_points_init(&mask_right_param, p1.x, p1.y + w_half1, p2.x, p2.y + w_half1, LV_DRAW_MASK_LINE_SIDE_RIGHT);
} else {
lv_draw_mask_line_points_init(&mask_left_param, p1.x, p1.y + w_half1, p2.x, p2.y + w_half1, LV_DRAW_MASK_LINE_SIDE_LEFT);
lv_draw_mask_line_points_init(&mask_right_param, p1.x, p1.y - w_half0, p2.x, p2.y - w_half0, LV_DRAW_MASK_LINE_SIDE_RIGHT);
lv_draw_mask_line_points_init(&mask_left_param, p1.x, p1.y - w_half0, p2.x, p2.y - w_half0,
LV_DRAW_MASK_LINE_SIDE_LEFT);
lv_draw_mask_line_points_init(&mask_right_param, p1.x, p1.y + w_half1, p2.x, p2.y + w_half1,
LV_DRAW_MASK_LINE_SIDE_RIGHT);
}
} else {
lv_draw_mask_line_points_init(&mask_left_param, p1.x + w_half1, p1.y, p2.x + w_half1, p2.y, LV_DRAW_MASK_LINE_SIDE_LEFT);
lv_draw_mask_line_points_init(&mask_right_param, p1.x - w_half0, p1.y, p2.x - w_half0, p2.y, LV_DRAW_MASK_LINE_SIDE_RIGHT);
else {
lv_draw_mask_line_points_init(&mask_left_param, p1.x, p1.y + w_half1, p2.x, p2.y + w_half1,
LV_DRAW_MASK_LINE_SIDE_LEFT);
lv_draw_mask_line_points_init(&mask_right_param, p1.x, p1.y - w_half0, p2.x, p2.y - w_half0,
LV_DRAW_MASK_LINE_SIDE_RIGHT);
}
}
else {
lv_draw_mask_line_points_init(&mask_left_param, p1.x + w_half1, p1.y, p2.x + w_half1, p2.y,
LV_DRAW_MASK_LINE_SIDE_LEFT);
lv_draw_mask_line_points_init(&mask_right_param, p1.x - w_half0, p1.y, p2.x - w_half0, p2.y,
LV_DRAW_MASK_LINE_SIDE_RIGHT);
}
/*Use the normal vector for the endings*/
lv_draw_mask_line_points_init(&mask_top_param, p1.x, p1.y, p1.x - ydiff, p1.y + xdiff, LV_DRAW_MASK_LINE_SIDE_BOTTOM);
lv_draw_mask_line_points_init(&mask_bottom_param, p2.x, p2.y,p2.x - ydiff, p2.y + xdiff, LV_DRAW_MASK_LINE_SIDE_TOP);
lv_draw_mask_line_points_init(&mask_bottom_param, p2.x, p2.y, p2.x - ydiff, p2.y + xdiff, LV_DRAW_MASK_LINE_SIDE_TOP);
int16_t mask_left_id = lv_draw_mask_add(&mask_left_param, NULL);
int16_t mask_right_id = lv_draw_mask_add(&mask_right_param, NULL);
@@ -401,8 +419,8 @@ static void draw_line_skew(const lv_point_t * point1, const lv_point_t * point2,
lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
lv_blend_fill(clip, &fill_area,
dsc->color, mask_buf, mask_res, opa,
dsc->blend_mode);
dsc->color, mask_buf, mask_res, opa,
dsc->blend_mode);
fill_area.y1++;
fill_area.y2++;

View File

@@ -28,10 +28,10 @@ typedef struct {
lv_style_int_t dash_width;
lv_style_int_t dash_gap;
lv_opa_t opa;
lv_blend_mode_t blend_mode :2;
uint8_t round_start :1;
uint8_t round_end :1;
}lv_draw_line_dsc_t;
lv_blend_mode_t blend_mode : 2;
uint8_t round_start : 1;
uint8_t round_end : 1;
} lv_draw_line_dsc_t;
/**********************
* GLOBAL PROTOTYPES
@@ -45,7 +45,8 @@ typedef struct {
* @param style pointer to a line's style
* @param opa_scale scale down all opacities by the factor
*/
void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * mask, lv_draw_line_dsc_t * dsc);
void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * mask,
lv_draw_line_dsc_t * dsc);
void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc);

View File

@@ -19,23 +19,29 @@
/**********************
* TYPEDEFS
**********************/
typedef struct
{
typedef struct {
void * param;
void * custom_id;
}lv_mask_saved_t;
} lv_mask_saved_t;
/**********************
* STATIC PROTOTYPES
**********************/
static lv_draw_mask_res_t lv_draw_mask_line(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len, lv_draw_mask_line_param_t * param);
static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len, lv_draw_mask_radius_param_t * param);
static lv_draw_mask_res_t lv_draw_mask_angle(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len, lv_draw_mask_angle_param_t * param);
static lv_draw_mask_res_t lv_draw_mask_fade(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len, lv_draw_mask_fade_param_t * param);
static lv_draw_mask_res_t lv_draw_mask_map(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len, lv_draw_mask_map_param_t * param);
static lv_draw_mask_res_t lv_draw_mask_line(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len,
lv_draw_mask_line_param_t * param);
static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len,
lv_draw_mask_radius_param_t * param);
static lv_draw_mask_res_t lv_draw_mask_angle(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len,
lv_draw_mask_angle_param_t * param);
static lv_draw_mask_res_t lv_draw_mask_fade(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len,
lv_draw_mask_fade_param_t * param);
static lv_draw_mask_res_t lv_draw_mask_map(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len,
lv_draw_mask_map_param_t * param);
static lv_draw_mask_res_t line_mask_flat(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len, lv_draw_mask_line_param_t * p);
static lv_draw_mask_res_t line_mask_steep(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len, lv_draw_mask_line_param_t * p);
static lv_draw_mask_res_t line_mask_flat(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len,
lv_draw_mask_line_param_t * p);
static lv_draw_mask_res_t line_mask_steep(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len,
lv_draw_mask_line_param_t * p);
static inline lv_opa_t mask_mix(lv_opa_t mask_act, lv_opa_t mask_new);
@@ -98,7 +104,7 @@ lv_draw_mask_res_t lv_draw_mask_apply(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_
for(i = 0; i < LV_MASK_MAX_NUM; i++) {
if(mask_list[i].param) {
dsc = mask_list[i].param;
res = dsc->cb(mask_buf, abs_x, abs_y, len, (void*)mask_list[i].param);
res = dsc->cb(mask_buf, abs_x, abs_y, len, (void *)mask_list[i].param);
if(res == LV_DRAW_MASK_RES_FULL_TRANSP) return LV_DRAW_MASK_RES_FULL_TRANSP;
else if(res == LV_DRAW_MASK_RES_CHANGED) changed = true;
}
@@ -171,7 +177,8 @@ uint8_t lv_draw_mask_get_cnt(void)
* With `LV_DRAW_MASK_LINE_SIDE_LEFT/RIGHT` and horizontal line all pixels are kept
* With `LV_DRAW_MASK_LINE_SIDE_TOP/BOTTOM` and vertical line all pixels are kept
*/
void lv_draw_mask_line_points_init(lv_draw_mask_line_param_t * param, lv_coord_t p1x, lv_coord_t p1y, lv_coord_t p2x, lv_coord_t p2y, lv_draw_mask_line_side_t side)
void lv_draw_mask_line_points_init(lv_draw_mask_line_param_t * param, lv_coord_t p1x, lv_coord_t p1y, lv_coord_t p2x,
lv_coord_t p2y, lv_draw_mask_line_side_t side)
{
memset(param, 0x00, sizeof(lv_draw_mask_line_param_t));
@@ -194,14 +201,14 @@ void lv_draw_mask_line_points_init(lv_draw_mask_line_param_t * param, lv_coord_t
param->origo.x = p1x;
param->origo.y = p1y;
param->flat = (LV_MATH_ABS(p2x-p1x) > LV_MATH_ABS(p2y-p1y)) ? 1 : 0;
param->flat = (LV_MATH_ABS(p2x - p1x) > LV_MATH_ABS(p2y - p1y)) ? 1 : 0;
param->yx_steep = 0;
param->xy_steep = 0;
param->dsc.cb = (lv_draw_mask_cb_t)lv_draw_mask_line;
param->dsc.type = LV_DRAW_MASK_TYPE_LINE;
int32_t dx = p2x-p1x;
int32_t dy = p2y-p1y;
int32_t dx = p2x - p1x;
int32_t dy = p2y - p1y;
if(param->flat) {
/*Normalize the steep. Delta x should be relative to delta x = 1024*/
@@ -217,7 +224,8 @@ void lv_draw_mask_line_points_init(lv_draw_mask_line_param_t * param, lv_coord_t
param->xy_steep = (m * dx) >> 10;
}
param->steep = param->yx_steep;
} else {
}
else {
/*Normalize the steep. Delta y should be relative to delta x = 1024*/
int32_t m;
@@ -258,7 +266,8 @@ void lv_draw_mask_line_points_init(lv_draw_mask_line_param_t * param, lv_coord_t
* With `LV_DRAW_MASK_LINE_SIDE_LEFT/RIGHT` and horizontal line all pixels are kept
* With `LV_DRAW_MASK_LINE_SIDE_TOP/BOTTOM` and vertical line all pixels are kept
*/
void lv_draw_mask_line_angle_init(lv_draw_mask_line_param_t* param, lv_coord_t p1x, lv_coord_t py, int16_t angle, lv_draw_mask_line_side_t side)
void lv_draw_mask_line_angle_init(lv_draw_mask_line_param_t * param, lv_coord_t p1x, lv_coord_t py, int16_t angle,
lv_draw_mask_line_side_t side)
{
/* Find an optimal degree.
* lv_mask_line_points_init will swap the points to keep the smaller y in p1
@@ -285,7 +294,8 @@ void lv_draw_mask_line_angle_init(lv_draw_mask_line_param_t* param, lv_coord_t p
* @param start_angle start angle in degrees. 0 deg on the right, 90 deg, on the bottom
* @param end_angle end angle
*/
void lv_draw_mask_angle_init(lv_draw_mask_angle_param_t * param, lv_coord_t vertex_x, lv_coord_t vertex_y, lv_coord_t start_angle, lv_coord_t end_angle)
void lv_draw_mask_angle_init(lv_draw_mask_angle_param_t * param, lv_coord_t vertex_x, lv_coord_t vertex_y,
lv_coord_t start_angle, lv_coord_t end_angle)
{
lv_draw_mask_line_side_t start_side;
lv_draw_mask_line_side_t end_side;
@@ -303,7 +313,8 @@ void lv_draw_mask_angle_init(lv_draw_mask_angle_param_t * param, lv_coord_t vert
if(end_angle < start_angle) {
param->delta_deg = 360 - start_angle + end_angle;
} else {
}
else {
param->delta_deg = LV_MATH_ABS(end_angle - start_angle);
}
@@ -319,7 +330,8 @@ void lv_draw_mask_angle_init(lv_draw_mask_angle_param_t * param, lv_coord_t vert
}
else if(start_angle >= 180 && start_angle < 360) {
start_side = LV_DRAW_MASK_LINE_SIDE_RIGHT;
} else {
}
else {
LV_DEBUG_ASSERT(false, "Unexpected start_angle", start_angle);
return;
}
@@ -329,7 +341,8 @@ void lv_draw_mask_angle_init(lv_draw_mask_angle_param_t * param, lv_coord_t vert
}
else if(end_angle >= 180 && end_angle < 360) {
end_side = LV_DRAW_MASK_LINE_SIDE_LEFT;
} else {
}
else {
LV_DEBUG_ASSERT(false, "Unexpected end_angle", end_angle);
return;
}
@@ -369,12 +382,13 @@ void lv_draw_mask_radius_init(lv_draw_mask_radius_param_t * param, const lv_area
* @param opa_bottom opacity at the bottom
* @param y_bottom at which coordinate reach `opa_bottom`.
*/
void lv_draw_mask_fade_init(lv_draw_mask_fade_param_t * param, lv_area_t * coords, lv_opa_t opa_top, lv_coord_t y_top, lv_opa_t opa_bottom, lv_coord_t y_bottom)
void lv_draw_mask_fade_init(lv_draw_mask_fade_param_t * param, lv_area_t * coords, lv_opa_t opa_top, lv_coord_t y_top,
lv_opa_t opa_bottom, lv_coord_t y_bottom)
{
lv_area_copy(&param->cfg.coords, coords);
param->cfg.opa_top= opa_top;
param->cfg.opa_top = opa_top;
param->cfg.opa_bottom = opa_bottom;
param->cfg.y_top= y_top;
param->cfg.y_top = y_top;
param->cfg.y_bottom = y_bottom;
param->dsc.cb = (lv_draw_mask_cb_t)lv_draw_mask_fade;
param->dsc.type = LV_DRAW_MASK_TYPE_FADE;
@@ -400,7 +414,8 @@ void lv_draw_mask_map_init(lv_draw_mask_map_param_t * param, lv_area_t * coords,
* STATIC FUNCTIONS
**********************/
static lv_draw_mask_res_t lv_draw_mask_line(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len, lv_draw_mask_line_param_t * p)
static lv_draw_mask_res_t lv_draw_mask_line(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len,
lv_draw_mask_line_param_t * p)
{
/*Make to points relative to the vertex*/
abs_y -= p->origo.y;
@@ -411,8 +426,9 @@ static lv_draw_mask_res_t lv_draw_mask_line(lv_opa_t * mask_buf, lv_coord_t abs_
/*Horizontal*/
if(p->flat) {
/*Non sense: Can't be on the right/left of a horizontal line*/
if(p->cfg.side == LV_DRAW_MASK_LINE_SIDE_LEFT || p->cfg.side == LV_DRAW_MASK_LINE_SIDE_RIGHT) return LV_DRAW_MASK_RES_FULL_COVER;
else if(p->cfg.side == LV_DRAW_MASK_LINE_SIDE_TOP && abs_y+1 < 0) return LV_DRAW_MASK_RES_FULL_COVER;
if(p->cfg.side == LV_DRAW_MASK_LINE_SIDE_LEFT ||
p->cfg.side == LV_DRAW_MASK_LINE_SIDE_RIGHT) return LV_DRAW_MASK_RES_FULL_COVER;
else if(p->cfg.side == LV_DRAW_MASK_LINE_SIDE_TOP && abs_y + 1 < 0) return LV_DRAW_MASK_RES_FULL_COVER;
else if(p->cfg.side == LV_DRAW_MASK_LINE_SIDE_BOTTOM && abs_y > 0) return LV_DRAW_MASK_RES_FULL_COVER;
else {
return LV_DRAW_MASK_RES_FULL_TRANSP;
@@ -421,7 +437,8 @@ static lv_draw_mask_res_t lv_draw_mask_line(lv_opa_t * mask_buf, lv_coord_t abs_
/*Vertical*/
else {
/*Non sense: Can't be on the top/bottom of a vertical line*/
if(p->cfg.side == LV_DRAW_MASK_LINE_SIDE_TOP || p->cfg.side == LV_DRAW_MASK_LINE_SIDE_BOTTOM) return LV_DRAW_MASK_RES_FULL_COVER;
if(p->cfg.side == LV_DRAW_MASK_LINE_SIDE_TOP ||
p->cfg.side == LV_DRAW_MASK_LINE_SIDE_BOTTOM) return LV_DRAW_MASK_RES_FULL_COVER;
else if(p->cfg.side == LV_DRAW_MASK_LINE_SIDE_RIGHT && abs_x > 0) return LV_DRAW_MASK_RES_FULL_COVER;
else if(p->cfg.side == LV_DRAW_MASK_LINE_SIDE_LEFT) {
if(abs_x + len < 0) return LV_DRAW_MASK_RES_FULL_COVER;
@@ -438,7 +455,7 @@ static lv_draw_mask_res_t lv_draw_mask_line(lv_opa_t * mask_buf, lv_coord_t abs_
int32_t k = - abs_x;
if(k < 0) k = 0;
if(k >= len) return LV_DRAW_MASK_RES_FULL_TRANSP;
else if(k >= 0 && k < len) memset(&mask_buf[0], 0x00,k);
else if(k >= 0 && k < len) memset(&mask_buf[0], 0x00, k);
return LV_DRAW_MASK_RES_CHANGED;
}
}
@@ -448,14 +465,16 @@ static lv_draw_mask_res_t lv_draw_mask_line(lv_opa_t * mask_buf, lv_coord_t abs_
lv_draw_mask_res_t res;
if(p->flat) {
res = line_mask_flat(mask_buf, abs_x, abs_y, len, p);
} else {
}
else {
res = line_mask_steep(mask_buf, abs_x, abs_y, len, p);
}
return res;
}
static lv_draw_mask_res_t line_mask_flat(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len, lv_draw_mask_line_param_t * p)
static lv_draw_mask_res_t line_mask_flat(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len,
lv_draw_mask_line_param_t * p)
{
int32_t y_at_x;
y_at_x = (int32_t)((int32_t)p->yx_steep * abs_x) >> 10;
@@ -464,15 +483,18 @@ static lv_draw_mask_res_t line_mask_flat(lv_opa_t * mask_buf, lv_coord_t abs_x,
if(y_at_x > abs_y) {
if(p->inv) {
return LV_DRAW_MASK_RES_FULL_COVER;
} else {
}
else {
return LV_DRAW_MASK_RES_FULL_TRANSP;
}
}
} else {
}
else {
if(y_at_x < abs_y) {
if(p->inv) {
return LV_DRAW_MASK_RES_FULL_COVER;
} else {
}
else {
return LV_DRAW_MASK_RES_FULL_TRANSP;
}
}
@@ -485,15 +507,18 @@ static lv_draw_mask_res_t line_mask_flat(lv_opa_t * mask_buf, lv_coord_t abs_x,
if(y_at_x < abs_y) {
if(p->inv) {
return LV_DRAW_MASK_RES_FULL_TRANSP;
} else {
}
else {
return LV_DRAW_MASK_RES_FULL_COVER;
}
}
} else {
}
else {
if(y_at_x > abs_y) {
if(p->inv) {
return LV_DRAW_MASK_RES_FULL_TRANSP;
} else {
}
else {
return LV_DRAW_MASK_RES_FULL_COVER;
}
}
@@ -514,7 +539,7 @@ static lv_draw_mask_res_t line_mask_flat(lv_opa_t * mask_buf, lv_coord_t abs_x,
if(xef) {
if(k >= 0 && k < len) {
m = 255 - (((255-xef) * (255 - px_h)) >> 9);
m = 255 - (((255 - xef) * (255 - px_h)) >> 9);
if(p->inv) m = 255 - m;
mask_buf[k] = mask_mix(mask_buf[k], m);
}
@@ -547,11 +572,11 @@ static lv_draw_mask_res_t line_mask_flat(lv_opa_t * mask_buf, lv_coord_t abs_x,
if(k > len) {
return LV_DRAW_MASK_RES_FULL_TRANSP;
}
if(k >= 0)
{
if(k >= 0) {
memset(&mask_buf[0], 0x00, k);
}
} else {
}
else {
k++;
if(k < 0) {
return LV_DRAW_MASK_RES_FULL_TRANSP;
@@ -564,7 +589,8 @@ static lv_draw_mask_res_t line_mask_flat(lv_opa_t * mask_buf, lv_coord_t abs_x,
return LV_DRAW_MASK_RES_CHANGED;
}
static lv_draw_mask_res_t line_mask_steep(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len, lv_draw_mask_line_param_t * p)
static lv_draw_mask_res_t line_mask_steep(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len,
lv_draw_mask_line_param_t * p)
{
int32_t k;
int32_t x_at_y;
@@ -575,7 +601,8 @@ static lv_draw_mask_res_t line_mask_steep(lv_opa_t * mask_buf, lv_coord_t abs_x,
if(x_at_y < abs_x) {
if(p->inv) {
return LV_DRAW_MASK_RES_FULL_COVER;
} else {
}
else {
return LV_DRAW_MASK_RES_FULL_TRANSP;
}
}
@@ -586,7 +613,8 @@ static lv_draw_mask_res_t line_mask_steep(lv_opa_t * mask_buf, lv_coord_t abs_x,
if(x_at_y > abs_x + len) {
if(p->inv) {
return LV_DRAW_MASK_RES_FULL_TRANSP;
} else {
}
else {
return LV_DRAW_MASK_RES_FULL_COVER;
}
}
@@ -623,32 +651,34 @@ static lv_draw_mask_res_t line_mask_steep(lv_opa_t * mask_buf, lv_coord_t abs_x,
}
if(k >= 0) memset(&mask_buf[0], 0x00, k);
} else {
}
else {
if(k > len) k = len;
if(k == 0) return LV_DRAW_MASK_RES_FULL_TRANSP;
else if(k > 0) memset(&mask_buf[k] ,0x00, len - k);
else if(k > 0) memset(&mask_buf[k], 0x00, len - k);
}
} else {
}
else {
int32_t y_inters;
if(p->xy_steep < 0) {
y_inters = (xef * (-p->yx_steep)) >> 10;
if(k >= 0 && k < len ) {
if(k >= 0 && k < len) {
m = (y_inters * xef) >> 9;
if(p->inv) m = 255 - m;
mask_buf[k] = mask_mix(mask_buf[k], m);
}
k--;
int32_t x_inters = ((255-y_inters) * (-p->xy_steep)) >> 10;
int32_t x_inters = ((255 - y_inters) * (-p->xy_steep)) >> 10;
if(k >= 0 && k < len ) {
m = 255-(((255-y_inters) * x_inters) >> 9);
if(k >= 0 && k < len) {
m = 255 - (((255 - y_inters) * x_inters) >> 9);
if(p->inv) m = 255 - m;
mask_buf[k] = mask_mix(mask_buf[k], m);
}
k+=2;
k += 2;
if(p->inv) {
k = xei - abs_x - 1;
@@ -656,24 +686,26 @@ static lv_draw_mask_res_t line_mask_steep(lv_opa_t * mask_buf, lv_coord_t abs_x,
if(k > len) k = len;
else if(k > 0) memset(&mask_buf[0], 0x00, k);
} else {
}
else {
if(k > len) return LV_DRAW_MASK_RES_FULL_COVER;
if(k >= 0) memset(&mask_buf[k] ,0x00, len - k);
if(k >= 0) memset(&mask_buf[k], 0x00, len - k);
}
} else {
y_inters = ((255-xef) * p->yx_steep) >> 10;
if(k >= 0 && k < len ) {
m = 255 - ((y_inters * (255-xef)) >> 9);
}
else {
y_inters = ((255 - xef) * p->yx_steep) >> 10;
if(k >= 0 && k < len) {
m = 255 - ((y_inters * (255 - xef)) >> 9);
if(p->inv) m = 255 - m;
mask_buf[k] = mask_mix(mask_buf[k], m);
}
k++;
int32_t x_inters = ((255-y_inters) * p->xy_steep) >> 10;
if(k >= 0 && k < len ) {
m = ((255-y_inters) * x_inters) >> 9;
int32_t x_inters = ((255 - y_inters) * p->xy_steep) >> 10;
if(k >= 0 && k < len) {
m = ((255 - y_inters) * x_inters) >> 9;
if(p->inv) m = 255 - m;
mask_buf[k] = mask_mix(mask_buf[k], m);
}
@@ -684,10 +716,11 @@ static lv_draw_mask_res_t line_mask_steep(lv_opa_t * mask_buf, lv_coord_t abs_x,
if(k > len) return LV_DRAW_MASK_RES_FULL_TRANSP;
if(k >= 0) memset(&mask_buf[0], 0x00, k);
} else {
}
else {
if(k > len) k = len;
if(k == 0) return LV_DRAW_MASK_RES_FULL_TRANSP;
else if(k > 0) memset(&mask_buf[k] ,0x00, len - k);
else if(k > 0) memset(&mask_buf[k], 0x00, len - k);
}
}
@@ -697,7 +730,8 @@ static lv_draw_mask_res_t line_mask_steep(lv_opa_t * mask_buf, lv_coord_t abs_x,
}
static lv_draw_mask_res_t lv_draw_mask_angle(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len, lv_draw_mask_angle_param_t * p)
static lv_draw_mask_res_t lv_draw_mask_angle(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len,
lv_draw_mask_angle_param_t * p)
{
int32_t rel_y = abs_y - p->cfg.vertex_p.y;
int32_t rel_x = abs_x - p->cfg.vertex_p.x;
@@ -713,7 +747,7 @@ static lv_draw_mask_res_t lv_draw_mask_angle(lv_opa_t * mask_buf, lv_coord_t abs
/*Start angle mask can work only from the end of end angle mask */
int32_t end_angle_first = (rel_y * p->end_line.xy_steep) >> 10;
int32_t start_angle_last= ((rel_y+1) * p->start_line.xy_steep) >> 10;
int32_t start_angle_last = ((rel_y + 1) * p->start_line.xy_steep) >> 10;
/*Do not let the line end cross the vertex else it will affect the opposite part*/
@@ -742,9 +776,9 @@ static lv_draw_mask_res_t lv_draw_mask_angle(lv_opa_t * mask_buf, lv_coord_t abs
if(tmp > len) tmp = len;
if(tmp < 0) tmp = 0;
res2 = lv_draw_mask_line(&mask_buf[tmp], abs_x+tmp, abs_y, len-tmp, &p->end_line);
res2 = lv_draw_mask_line(&mask_buf[tmp], abs_x + tmp, abs_y, len - tmp, &p->end_line);
if(res2 == LV_DRAW_MASK_RES_FULL_TRANSP) {
memset(&mask_buf[tmp], 0x00, len-tmp);
memset(&mask_buf[tmp], 0x00, len - tmp);
}
if(res1 == res2) return res1;
else return LV_DRAW_MASK_RES_CHANGED;
@@ -757,7 +791,7 @@ static lv_draw_mask_res_t lv_draw_mask_angle(lv_opa_t * mask_buf, lv_coord_t abs
/*Start angle mask can work only from the end of end angle mask */
int32_t end_angle_first = (rel_y * p->end_line.xy_steep) >> 10;
int32_t start_angle_last= ((rel_y+1) * p->start_line.xy_steep) >> 10;
int32_t start_angle_last = ((rel_y + 1) * p->start_line.xy_steep) >> 10;
/*Do not let the line end cross the vertex else it will affect the opposite part*/
if(p->cfg.start_angle > 270 && p->cfg.start_angle <= 359 && start_angle_last < 0) start_angle_last = 0;
@@ -776,7 +810,7 @@ static lv_draw_mask_res_t lv_draw_mask_angle(lv_opa_t * mask_buf, lv_coord_t abs
int32_t tmp = start_angle_last + dist - rel_x;
if(tmp > len) tmp = len;
if(tmp > 0) {
res1 = lv_draw_mask_line(&mask_buf[0], abs_x, abs_y, tmp, (lv_draw_mask_line_param_t*)&p->end_line);
res1 = lv_draw_mask_line(&mask_buf[0], abs_x, abs_y, tmp, (lv_draw_mask_line_param_t *)&p->end_line);
if(res1 == LV_DRAW_MASK_RES_FULL_TRANSP) {
memset(&mask_buf[0], 0x00, tmp);
}
@@ -784,9 +818,9 @@ static lv_draw_mask_res_t lv_draw_mask_angle(lv_opa_t * mask_buf, lv_coord_t abs
if(tmp > len) tmp = len;
if(tmp < 0) tmp = 0;
res2 = lv_draw_mask_line(&mask_buf[tmp], abs_x+tmp, abs_y, len-tmp, (lv_draw_mask_line_param_t*)&p->start_line);
res2 = lv_draw_mask_line(&mask_buf[tmp], abs_x + tmp, abs_y, len - tmp, (lv_draw_mask_line_param_t *)&p->start_line);
if(res2 == LV_DRAW_MASK_RES_FULL_TRANSP) {
memset(&mask_buf[tmp], 0x00, len-tmp);
memset(&mask_buf[tmp], 0x00, len - tmp);
}
if(res1 == res2) return res1;
else return LV_DRAW_MASK_RES_CHANGED;
@@ -835,20 +869,22 @@ static lv_draw_mask_res_t lv_draw_mask_angle(lv_opa_t * mask_buf, lv_coord_t abs
}
}
static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len, lv_draw_mask_radius_param_t * p)
static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len,
lv_draw_mask_radius_param_t * p)
{
if(p->cfg.outer == 0) {
if(abs_y < p->cfg.rect.y1 || abs_y > p->cfg.rect.y2) {
return LV_DRAW_MASK_RES_FULL_TRANSP;
}
} else {
}
else {
if(abs_y < p->cfg.rect.y1 || abs_y > p->cfg.rect.y2) {
return LV_DRAW_MASK_RES_FULL_COVER;
}
}
if((abs_x >= p->cfg.rect.x1 + p->cfg.radius && abs_x + len <= p->cfg.rect.x2 - p->cfg.radius) ||
(abs_y >= p->cfg.rect.y1 + p->cfg.radius && abs_y <= p->cfg.rect.y2 - p->cfg.radius)) {
(abs_y >= p->cfg.rect.y1 + p->cfg.radius && abs_y <= p->cfg.rect.y2 - p->cfg.radius)) {
if(p->cfg.outer == 0) {
/*Remove the edges*/
int32_t last = p->cfg.rect.x1 - abs_x;
@@ -860,7 +896,7 @@ static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * mask_buf, lv_coord_t ab
int32_t first = p->cfg.rect.x2 - abs_x + 1;
if(first <= 0) return LV_DRAW_MASK_RES_FULL_TRANSP;
else if(first < len) {
memset(&mask_buf[first], 0x00, len-first);
memset(&mask_buf[first], 0x00, len - first);
}
if(last == 0 && first == len) return LV_DRAW_MASK_RES_FULL_COVER;
else return LV_DRAW_MASK_RES_CHANGED;
@@ -879,7 +915,7 @@ static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * mask_buf, lv_coord_t ab
return LV_DRAW_MASK_RES_CHANGED;
}
int32_t k = p->cfg.rect.x1 -abs_x; /*First relevant coordinate on the of the mask*/
int32_t k = p->cfg.rect.x1 - abs_x; /*First relevant coordinate on the of the mask*/
int32_t w = lv_area_get_width(&p->cfg.rect);
int32_t h = lv_area_get_height(&p->cfg.rect);
abs_x -= p->cfg.rect.x1;
@@ -900,7 +936,7 @@ static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * mask_buf, lv_coord_t ab
lv_sqrt(r2 - (y * y), &x0);
lv_sqrt_res_t x1;
lv_sqrt(r2 - ((y-1) * (y-1)), &x1);
lv_sqrt(r2 - ((y - 1) * (y - 1)), &x1);
/* If x1 is on the next round coordinate (e.g. x0: 3.5, x1:4.0)
* then treat x1 as x1: 3.99 to handle them as they were on the same pixel*/
@@ -923,7 +959,7 @@ static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * mask_buf, lv_coord_t ab
}
/*Right corner*/
int32_t kr = k+(w-ofs-1);
int32_t kr = k + (w - ofs - 1);
if(kr >= 0 && kr < len) {
mask_buf[kr] = mask_mix(mask_buf[kr], m);
}
@@ -941,14 +977,15 @@ static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * mask_buf, lv_coord_t ab
return LV_DRAW_MASK_RES_FULL_TRANSP;
}
if(kr <= len) {
memset(&mask_buf[kr], 0x00, len-kr);
memset(&mask_buf[kr], 0x00, len - kr);
}
} else {
}
else {
kl++;
int32_t first = kl;
if(first < 0) first = 0;
int32_t len_tmp = kr-first;
int32_t len_tmp = kr - first;
if(len_tmp + first > len) len_tmp = len - first;
if(first < len && len_tmp >= 0) {
memset(&mask_buf[first], 0x00, len_tmp);
@@ -959,13 +996,13 @@ static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * mask_buf, lv_coord_t ab
else {
int32_t ofs = p->cfg.radius - (x0.i + 1);
int32_t kl = k + ofs;
int32_t kr = k + (w - ofs -1);
int32_t kr = k + (w - ofs - 1);
if(p->cfg.outer) {
int32_t first = kl + 1;
if(first < 0) first = 0;
int32_t len_tmp = kr-first;
int32_t len_tmp = kr - first;
if(len_tmp + first > len) len_tmp = len - first;
if(first < len && len_tmp >= 0) {
memset(&mask_buf[first], 0x00, len_tmp);
@@ -987,7 +1024,7 @@ static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * mask_buf, lv_coord_t ab
/*The first y intersection is special as it might be in the previous line*/
if(y_prev.i >= y) {
lv_sqrt(r2 - (i * i), &y_next);
m = 255 - (((255-x0.f) * (255 - y_next.f)) >> 9);
m = 255 - (((255 - x0.f) * (255 - y_next.f)) >> 9);
if(p->cfg.outer) m = 255 - m;
if(kl >= 0 && kl < len) mask_buf[kl] = mask_mix(mask_buf[kl], m);
@@ -1041,7 +1078,8 @@ static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * mask_buf, lv_coord_t ab
}
static lv_draw_mask_res_t lv_draw_mask_fade(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len, lv_draw_mask_fade_param_t * p)
static lv_draw_mask_res_t lv_draw_mask_fade(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len,
lv_draw_mask_fade_param_t * p)
{
if(abs_y < p->cfg.coords.y1) return LV_DRAW_MASK_RES_FULL_COVER;
if(abs_y > p->cfg.coords.y2) return LV_DRAW_MASK_RES_FULL_COVER;
@@ -1064,12 +1102,14 @@ static lv_draw_mask_res_t lv_draw_mask_fade(lv_opa_t * mask_buf, lv_coord_t abs_
mask_buf[i] = mask_mix(mask_buf[i], p->cfg.opa_top);
}
return LV_DRAW_MASK_RES_CHANGED;
} else if(abs_y >= p->cfg.y_bottom) {
}
else if(abs_y >= p->cfg.y_bottom) {
for(i = 0; i < len; i++) {
mask_buf[i] = mask_mix(mask_buf[i], p->cfg.opa_bottom);
}
return LV_DRAW_MASK_RES_CHANGED;
} else {
}
else {
/*Calculate the opa proportionally*/
int16_t opa_diff = p->cfg.opa_bottom - p->cfg.opa_top;
int32_t y_diff = p->cfg.y_bottom - p->cfg.y_top + 1;
@@ -1086,7 +1126,8 @@ static lv_draw_mask_res_t lv_draw_mask_fade(lv_opa_t * mask_buf, lv_coord_t abs_
return LV_DRAW_MASK_RES_FULL_COVER;
}
static lv_draw_mask_res_t lv_draw_mask_map(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len, lv_draw_mask_map_param_t * p)
static lv_draw_mask_res_t lv_draw_mask_map(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len,
lv_draw_mask_map_param_t * p)
{
/*Handle out of the mask cases*/
if(abs_y < p->cfg.coords.y1) return LV_DRAW_MASK_RES_FULL_COVER;
@@ -1106,7 +1147,8 @@ static lv_draw_mask_res_t lv_draw_mask_map(lv_opa_t * mask_buf, lv_coord_t abs_x
x_ofs = p->cfg.coords.x1 - abs_x;
len -= x_ofs;
mask_buf += x_ofs;
} else {
}
else {
map_tmp += (abs_x - p->cfg.coords.x1);
}
@@ -1124,6 +1166,6 @@ static inline lv_opa_t mask_mix(lv_opa_t mask_act, lv_opa_t mask_new)
if(mask_new >= LV_OPA_MAX) return mask_act;
if(mask_new <= LV_OPA_MIN) return 0;
return (int32_t)((int32_t) (mask_act * mask_new) >> 8);
return (int32_t)((int32_t)(mask_act * mask_new) >> 8);
}

View File

@@ -53,14 +53,15 @@ enum {
LV_DRAW_MASK_LINE_SIDE_BOTTOM,
};
typedef lv_draw_mask_res_t (*lv_draw_mask_cb_t)(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len, void * p);
typedef lv_draw_mask_res_t (*lv_draw_mask_cb_t)(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len,
void * p);
typedef uint8_t lv_draw_mask_line_side_t;
typedef struct {
lv_draw_mask_cb_t cb;
lv_draw_mask_type_t type;
}lv_draw_mask_common_dsc_t;
} lv_draw_mask_common_dsc_t;
typedef struct {
/*The first element must be the common descriptor*/
@@ -74,8 +75,8 @@ typedef struct {
lv_point_t p2;
/*Which side to keep?*/
lv_draw_mask_line_side_t side :2;
}cfg;
lv_draw_mask_line_side_t side : 2;
} cfg;
/*A point of the line*/
lv_point_t origo;
@@ -93,13 +94,13 @@ typedef struct {
int32_t spx;
/*1: It's a flat line? (Near to horizontal)*/
uint8_t flat :1;
uint8_t flat : 1;
/* Invert the mask. The default is: Keep the left part.
* It is used to select left/right/top/bottom*/
uint8_t inv:1;
}lv_draw_mask_line_param_t;
uint8_t inv: 1;
} lv_draw_mask_line_param_t;
typedef struct {
/*The first element must be the common descriptor*/
@@ -109,12 +110,12 @@ typedef struct {
lv_point_t vertex_p;
lv_coord_t start_angle;
lv_coord_t end_angle;
}cfg;
} cfg;
lv_draw_mask_line_param_t start_line;
lv_draw_mask_line_param_t end_line;
uint16_t delta_deg;
}lv_draw_mask_angle_param_t;
} lv_draw_mask_angle_param_t;
typedef struct {
/*The first element must be the common descriptor*/
@@ -124,10 +125,10 @@ typedef struct {
lv_area_t rect;
lv_coord_t radius;
/* Invert the mask. 0: Keep the pixels inside.*/
uint8_t outer:1;
}cfg;
uint8_t outer: 1;
} cfg;
}lv_draw_mask_radius_param_t;
} lv_draw_mask_radius_param_t;
typedef struct {
/*The first element must be the common descriptor*/
@@ -139,9 +140,9 @@ typedef struct {
lv_coord_t y_bottom;
lv_opa_t opa_top;
lv_opa_t opa_bottom;
}cfg;
} cfg;
}lv_draw_mask_fade_param_t;
} lv_draw_mask_fade_param_t;
typedef struct _lv_draw_mask_map_param_t {
/*The first element must be the common descriptor*/
@@ -150,8 +151,8 @@ typedef struct _lv_draw_mask_map_param_t {
struct {
lv_area_t coords;
const lv_opa_t * map;
}cfg;
}lv_draw_mask_map_param_t;
} cfg;
} lv_draw_mask_map_param_t;
/**********************
* GLOBAL PROTOTYPES
@@ -211,7 +212,8 @@ uint8_t lv_draw_mask_get_cnt(void);
* With `LV_DRAW_MASK_LINE_SIDE_LEFT/RIGHT` and horizontal line all pixels are kept
* With `LV_DRAW_MASK_LINE_SIDE_TOP/BOTTOM` and vertical line all pixels are kept
*/
void lv_draw_mask_line_points_init(lv_draw_mask_line_param_t * param, lv_coord_t p1x, lv_coord_t p1y, lv_coord_t p2x, lv_coord_t p2y, lv_draw_mask_line_side_t side);
void lv_draw_mask_line_points_init(lv_draw_mask_line_param_t * param, lv_coord_t p1x, lv_coord_t p1y, lv_coord_t p2x,
lv_coord_t p2y, lv_draw_mask_line_side_t side);
/**
*Initialize a line mask from a point and an angle.
@@ -223,7 +225,8 @@ void lv_draw_mask_line_points_init(lv_draw_mask_line_param_t * param, lv_coord_t
* With `LV_DRAW_MASK_LINE_SIDE_LEFT/RIGHT` and horizontal line all pixels are kept
* With `LV_DRAW_MASK_LINE_SIDE_TOP/BOTTOM` and vertical line all pixels are kept
*/
void lv_draw_mask_line_angle_init(lv_draw_mask_line_param_t * param, lv_coord_t p1x, lv_coord_t py, int16_t angle, lv_draw_mask_line_side_t side);
void lv_draw_mask_line_angle_init(lv_draw_mask_line_param_t * param, lv_coord_t p1x, lv_coord_t py, int16_t angle,
lv_draw_mask_line_side_t side);
/**
* Initialize an angle mask.
@@ -233,7 +236,8 @@ void lv_draw_mask_line_angle_init(lv_draw_mask_line_param_t * param, lv_coord_t
* @param start_angle start angle in degrees. 0 deg on the right, 90 deg, on the bottom
* @param end_angle end angle
*/
void lv_draw_mask_angle_init(lv_draw_mask_angle_param_t * param, lv_coord_t vertex_x, lv_coord_t vertex_y, lv_coord_t start_angle, lv_coord_t end_angle);
void lv_draw_mask_angle_init(lv_draw_mask_angle_param_t * param, lv_coord_t vertex_x, lv_coord_t vertex_y,
lv_coord_t start_angle, lv_coord_t end_angle);
/**
* Initialize a fade mask.
@@ -253,7 +257,8 @@ void lv_draw_mask_radius_init(lv_draw_mask_radius_param_t * param, const lv_area
* @param opa_bottom opacity at the bottom
* @param y_bottom at which coordinate reach `opa_bottom`.
*/
void lv_draw_mask_fade_init(lv_draw_mask_fade_param_t * param, lv_area_t * coords, lv_opa_t opa_top, lv_coord_t y_top, lv_opa_t opa_bottom, lv_coord_t y_bottom);
void lv_draw_mask_fade_init(lv_draw_mask_fade_param_t * param, lv_area_t * coords, lv_opa_t opa_top, lv_coord_t y_top,
lv_opa_t opa_bottom, lv_coord_t y_bottom);
/**
* Initialize a map mask.

View File

@@ -100,27 +100,27 @@ void lv_draw_rect(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect
*/
void lv_draw_px(const lv_point_t * point, const lv_area_t * clip_area, const lv_style_t * style)
{
// lv_opa_t opa = style->body.opa;
// if(opa_scale != LV_OPA_COVER) opa = (opa * opa_scale) >> 8;
//
// if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
//
// lv_area_t fill_area;
// fill_area.x1 = point->x;
// fill_area.y1 = point->y;
// fill_area.x2 = point->x;
// fill_area.y2 = point->y;
//
// uint8_t mask_cnt = lv_draw_mask_get_cnt();
//
// if(mask_cnt == 0) {
// lv_blend_fill(clip_area, &fill_area, style->body.main_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, style->body.blend_mode);
// } else {
// uint8_t mask_buf;
// lv_draw_mask_res_t mask_res;
// mask_res = lv_draw_mask_apply(&mask_buf, point->x, point->y, 1);
// lv_blend_fill(clip_area, &fill_area, style->body.main_color, &mask_buf, mask_res, opa, style->body.blend_mode);
// }
// lv_opa_t opa = style->body.opa;
// if(opa_scale != LV_OPA_COVER) opa = (opa * opa_scale) >> 8;
//
// if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
//
// lv_area_t fill_area;
// fill_area.x1 = point->x;
// fill_area.y1 = point->y;
// fill_area.x2 = point->x;
// fill_area.y2 = point->y;
//
// uint8_t mask_cnt = lv_draw_mask_get_cnt();
//
// if(mask_cnt == 0) {
// lv_blend_fill(clip_area, &fill_area, style->body.main_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, style->body.blend_mode);
// } else {
// uint8_t mask_buf;
// lv_draw_mask_res_t mask_res;
// mask_res = lv_draw_mask_apply(&mask_buf, point->x, point->y, 1);
// lv_blend_fill(clip_area, &fill_area, style->body.main_color, &mask_buf, mask_res, opa, style->body.blend_mode);
// }
}
/**********************
@@ -188,8 +188,8 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re
/*Most simple case: just a plain rectangle*/
if(simple_mode && rout == 0 && (dsc->bg_grad_dir == LV_GRAD_DIR_NONE)) {
lv_blend_fill(clip, &coords_bg,
dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa,
dsc->bg_blend_mode);
dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa,
dsc->bg_blend_mode);
}
/*More complex case: there is a radius, gradient or other mask.*/
else {
@@ -226,7 +226,7 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re
/*In not corner areas apply the mask only if required*/
if(y > coords_bg.y1 + rout + 1 &&
y < coords_bg.y2 - rout - 1) {
y < coords_bg.y2 - rout - 1) {
mask_res = LV_DRAW_MASK_RES_FULL_COVER;
if(simple_mode == false) {
memset(mask_buf, LV_OPA_COVER, draw_area_w);
@@ -247,8 +247,8 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re
/* If there is not other mask and drawing the corner area split the drawing to corner and middle areas
* because it the middle mask shuldn't be taken into account (therefore its faster)*/
if(simple_mode &&
(y < coords_bg.y1 + rout + 1 ||
y > coords_bg.y2 - rout - 1)) {
(y < coords_bg.y1 + rout + 1 ||
y > coords_bg.y2 - rout - 1)) {
/*Left part*/
lv_area_t fill_area2;
@@ -258,7 +258,7 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re
fill_area2.y2 = fill_area.y2;
lv_blend_fill(clip, &fill_area2,
grad_color, mask_buf, mask_res, opa, dsc->bg_blend_mode);
grad_color, mask_buf, mask_res, opa, dsc->bg_blend_mode);
/*Right part*/
fill_area2.x1 = coords_bg.x2 - rout + 1;
@@ -267,16 +267,19 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re
int32_t mask_ofs = (coords_bg.x2 - rout + 1) - (vdb->area.x1 + draw_area.x1);
if(mask_ofs < 0) mask_ofs = 0;
lv_blend_fill(clip, &fill_area2,
grad_color, mask_buf + mask_ofs, mask_res, opa, dsc->bg_blend_mode);
} else {
grad_color, mask_buf + mask_ofs, mask_res, opa, dsc->bg_blend_mode);
}
else {
if(dsc->bg_grad_dir == LV_GRAD_DIR_HOR) {
lv_blend_map(clip, &fill_area, grad_map, mask_buf, mask_res, opa, dsc->bg_blend_mode);
} else if(dsc->bg_grad_dir == LV_GRAD_DIR_VER) {
}
else if(dsc->bg_grad_dir == LV_GRAD_DIR_VER) {
lv_blend_fill(clip, &fill_area,
grad_color,mask_buf, mask_res, opa, dsc->bg_blend_mode);
} else if(other_mask_cnt != 0) {
grad_color, mask_buf, mask_res, opa, dsc->bg_blend_mode);
}
else if(other_mask_cnt != 0) {
lv_blend_fill(clip, &fill_area,
grad_color,mask_buf, mask_res, opa, dsc->bg_blend_mode);
grad_color, mask_buf, mask_res, opa, dsc->bg_blend_mode);
}
}
fill_area.y1++;
@@ -292,13 +295,13 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re
fill_area.y2 = coords_bg.y1 + rout;
lv_blend_fill(clip, &fill_area,
dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->bg_blend_mode);
dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->bg_blend_mode);
fill_area.y1 = coords_bg.y2 - rout;
fill_area.y2 = coords_bg.y2;
lv_blend_fill(clip, &fill_area,
dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->bg_blend_mode);
dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->bg_blend_mode);
fill_area.x1 = coords_bg.x1;
fill_area.x2 = coords_bg.x2;
@@ -306,7 +309,7 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re
fill_area.y2 = coords_bg.y2 - rout - 1;
lv_blend_fill(clip, &fill_area,
dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->bg_blend_mode);
dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->bg_blend_mode);
}
@@ -448,7 +451,7 @@ static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_dra
fill_area.y1 = disp_area->y1 + lower_corner_end;
fill_area.y2 = fill_area.y1;
for(h = lower_corner_end; h <= draw_area.y2; h++) {
memset(mask_buf, LV_OPA_COVER, draw_area_w);
memset(mask_buf, LV_OPA_COVER, draw_area_w);
mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
lv_area_t fill_area2;
@@ -460,7 +463,7 @@ static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_dra
lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode);
/*Draw the bottom horizontal line*/
if(fill_area2.y2 > coords->y2 - dsc->border_width ) {
if(fill_area2.y2 > coords->y2 - dsc->border_width) {
fill_area2.x1 = coords->x1 + rout;
fill_area2.x2 = coords->x2 - rout;
@@ -499,8 +502,8 @@ static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_dra
fill_area.y1 = disp_area->y1 + draw_area.y1;
fill_area.y2 = fill_area.y1;
if(dsc->border_side == LV_BORDER_SIDE_LEFT) fill_area.x2 = coords->x1 + corner_size;
else if(dsc->border_side == LV_BORDER_SIDE_RIGHT) fill_area.x1 = coords->x2 - corner_size;
if(dsc->border_side == LV_BORDER_SIDE_LEFT) fill_area.x2 = coords->x1 + corner_size;
else if(dsc->border_side == LV_BORDER_SIDE_RIGHT) fill_area.x1 = coords->x2 - corner_size;
for(h = draw_area.y1; h <= draw_area.y2; h++) {
if((dsc->border_side == LV_BORDER_SIDE_BOTTOM && fill_area.y1 < coords->y2 - corner_size - 1) ||
@@ -513,7 +516,7 @@ static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_dra
memset(mask_buf, LV_OPA_COVER, draw_area_w);
mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
lv_blend_fill( clip, &fill_area, color, mask_buf, mask_res, opa, blend_mode);
lv_blend_fill(clip, &fill_area, color, mask_buf, mask_res, opa, blend_mode);
fill_area.y1++;
fill_area.y2++;
@@ -546,7 +549,7 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
if(dsc->shadow_opa <= LV_OPA_MIN) return;
if(dsc->shadow_width == 1 && dsc->shadow_ofs_x == 0 &&
dsc->shadow_ofs_y == 0 && dsc->shadow_spread <= 0) {
dsc->shadow_ofs_y == 0 && dsc->shadow_spread <= 0) {
return;
}
@@ -659,7 +662,7 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED;
lv_blend_fill(clip, &a,
dsc->shadow_color, mask_buf + first_px, mask_res, opa, dsc->shadow_blend_mode);
dsc->shadow_color, mask_buf + first_px, mask_res, opa, dsc->shadow_blend_mode);
a.y1++;
a.y2++;
sh_buf_tmp += corner_size;
@@ -677,7 +680,7 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED;
lv_blend_fill(clip, &a,
dsc->shadow_color, mask_buf + first_px, mask_res, opa, dsc->shadow_blend_mode);
dsc->shadow_color, mask_buf + first_px, mask_res, opa, dsc->shadow_blend_mode);
a.y1--;
a.y2--;
sh_buf_tmp += corner_size;
@@ -704,7 +707,7 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
lv_opa_t opa_tmp = sh_buf_tmp[x - a.x1 + first_px];
if(opa_tmp != LV_OPA_COVER || opa != LV_OPA_COVER) opa_tmp = (opa * opa_tmp) >> 8;
lv_blend_fill(clip, &va,
dsc->shadow_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa_tmp, dsc->shadow_blend_mode);
dsc->shadow_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa_tmp, dsc->shadow_blend_mode);
}
va.x1++;
va.x2++;
@@ -718,7 +721,7 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED;
lv_blend_fill(clip, &a,
dsc->shadow_color, mask_buf+first_px, mask_res, opa, dsc->shadow_blend_mode);
dsc->shadow_color, mask_buf + first_px, mask_res, opa, dsc->shadow_blend_mode);
a.y1++;
a.y2++;
}
@@ -741,8 +744,8 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
a.y1 = sh_area.y1;
a.y2 = a.y1;
if(a.x2 > sh_area.x1 + lv_area_get_width(&sh_area)/2 - 1) {
a.x2 = sh_area.x1 + lv_area_get_width(&sh_area)/2 -1 ;
if(a.x2 > sh_area.x1 + lv_area_get_width(&sh_area) / 2 - 1) {
a.x2 = sh_area.x1 + lv_area_get_width(&sh_area) / 2 - 1 ;
}
first_px = 0;
@@ -758,7 +761,7 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED;
lv_blend_fill(clip, &a,
dsc->shadow_color, mask_buf + first_px, mask_res, opa, dsc->shadow_blend_mode);
dsc->shadow_color, mask_buf + first_px, mask_res, opa, dsc->shadow_blend_mode);
a.y1++;
a.y2++;
sh_buf_tmp += corner_size;
@@ -776,14 +779,14 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED;
lv_blend_fill(clip, &a,
dsc->shadow_color, mask_buf + first_px, mask_res, opa, dsc->shadow_blend_mode);
dsc->shadow_color, mask_buf + first_px, mask_res, opa, dsc->shadow_blend_mode);
a.y1--;
a.y2--;
sh_buf_tmp += corner_size;
}
/*Fill the left side*/
a.y1 = sh_area.y1+corner_size;
a.y1 = sh_area.y1 + corner_size;
a.y2 = a.y1;
sh_buf_tmp = sh_buf + corner_size * (corner_size - 1);
@@ -801,7 +804,7 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
lv_opa_t opa_tmp = sh_buf_tmp[x - a.x1 + first_px];
if(opa_tmp != LV_OPA_COVER || opa != LV_OPA_COVER) opa_tmp = (opa * opa_tmp) >> 8;
lv_blend_fill(clip, &va,
dsc->shadow_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa_tmp, dsc->shadow_blend_mode);
dsc->shadow_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa_tmp, dsc->shadow_blend_mode);
va.x1++;
va.x2++;
}
@@ -814,7 +817,7 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED;
lv_blend_fill(clip, &a,
dsc->shadow_color, mask_buf + first_px, mask_res, opa, dsc->shadow_blend_mode);
dsc->shadow_color, mask_buf + first_px, mask_res, opa, dsc->shadow_blend_mode);
a.y1++;
a.y2++;
}
@@ -850,13 +853,14 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED;
lv_blend_fill(clip, &a,
dsc->shadow_color, mask_buf, mask_res, opa, dsc->shadow_blend_mode);
} else {
dsc->shadow_color, mask_buf, mask_res, opa, dsc->shadow_blend_mode);
}
else {
lv_opa_t opa_tmp = sh_buf_tmp[0];
if(opa_tmp != LV_OPA_COVER || opa != LV_OPA_COVER) opa_tmp = (opa * opa_tmp) >> 8;
lv_blend_fill(clip, &a,
dsc->shadow_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa_tmp, dsc->shadow_blend_mode);
dsc->shadow_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa_tmp, dsc->shadow_blend_mode);
}
a.y1++;
@@ -867,7 +871,7 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
/*Fill the bottom side*/
int32_t y_min = simple_mode ? (corner_size - (sh_area.y2 - coords->y2)) : ver_mid_dist;
if(y_min < 0) y_min = 0;
sh_buf_tmp = sh_buf + corner_size * (corner_size - y_min - 1 ) + corner_size - 1;
sh_buf_tmp = sh_buf + corner_size * (corner_size - y_min - 1) + corner_size - 1;
a.y1 = sh_area.y2 - corner_size + 1 + y_min;
a.y2 = a.y1;
@@ -878,12 +882,13 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
mask_res = lv_draw_mask_apply(mask_buf, a.x1, a.y1, lv_area_get_width(&a));
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED;
lv_blend_fill(clip, &a,
dsc->shadow_color, mask_buf, mask_res, opa, dsc->shadow_blend_mode);
} else {
dsc->shadow_color, mask_buf, mask_res, opa, dsc->shadow_blend_mode);
}
else {
lv_opa_t opa_tmp = sh_buf_tmp[0];
if(opa_tmp != LV_OPA_COVER || opa != LV_OPA_COVER) opa_tmp = (opa * opa_tmp) >> 8;
lv_blend_fill(clip, &a,
dsc->shadow_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa_tmp, dsc->shadow_blend_mode);
dsc->shadow_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa_tmp, dsc->shadow_blend_mode);
}
a.y1++;
@@ -901,7 +906,7 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
memset(mask_buf, 0xFF, lv_area_get_width(&a));
mask_res = lv_draw_mask_apply(mask_buf, a.x1, a.y1, lv_area_get_width(&a));
lv_blend_fill(clip, &a,
dsc->shadow_color, mask_buf, mask_res, opa, dsc->shadow_blend_mode);
dsc->shadow_color, mask_buf, mask_res, opa, dsc->shadow_blend_mode);
a.y1++;
a.y2++;
@@ -921,7 +926,7 @@ static void shadow_draw_corner_buf(const lv_area_t * coords, uint16_t * sh_buf,
lv_area_t sh_area;
lv_area_copy(&sh_area, coords);
sh_area.x2 = sw / 2 + r -1 - ((sw & 1) ? 0 : 1);
sh_area.x2 = sw / 2 + r - 1 - ((sw & 1) ? 0 : 1);
sh_area.y1 = sw / 2 + 1;
sh_area.x1 = sh_area.x2 - lv_area_get_width(coords);
@@ -944,11 +949,12 @@ static void shadow_draw_corner_buf(const lv_area_t * coords, uint16_t * sh_buf,
lv_draw_mask_res_t mask_res = mask_param.dsc.cb(mask_line, 0, y, size, &mask_param);
if(mask_res == LV_DRAW_MASK_RES_FULL_TRANSP) {
memset(sh_ups_tmp_buf, 0x00, size * sizeof(sh_ups_tmp_buf[0]));
} else {
}
else {
int32_t i;
sh_ups_tmp_buf[0] = (mask_line[0] << SHADOW_UPSACALE_SHIFT) / sw;
for(i = 1; i < size; i++) {
if(mask_line[i] == mask_line[i-1]) sh_ups_tmp_buf[i] = sh_ups_tmp_buf[i-1];
if(mask_line[i] == mask_line[i - 1]) sh_ups_tmp_buf[i] = sh_ups_tmp_buf[i - 1];
else sh_ups_tmp_buf[i] = (mask_line[i] << SHADOW_UPSACALE_SHIFT) / sw;
}
}
@@ -981,7 +987,7 @@ static void shadow_draw_corner_buf(const lv_area_t * coords, uint16_t * sh_buf,
uint32_t i;
sh_buf[0] = (sh_buf[0] << SHADOW_UPSACALE_SHIFT) / sw;
for(i = 1; i < (uint32_t) size * size; i++) {
if(sh_buf[i] == sh_buf[i-1]) sh_buf[i] = sh_buf[i-1];
if(sh_buf[i] == sh_buf[i - 1]) sh_buf[i] = sh_buf[i - 1];
else sh_buf[i] = (sh_buf[i] << SHADOW_UPSACALE_SHIFT) / sw;
}
@@ -1011,8 +1017,8 @@ static void shadow_blur_corner(lv_coord_t size, lv_coord_t sw, uint16_t * sh_ups
uint16_t * sh_ups_tmp_buf = sh_ups_buf;
for(y = 0; y < size; y++) {
int32_t v = sh_ups_tmp_buf[size-1] * sw;
for(x = size - 1; x >=0; x--) {
int32_t v = sh_ups_tmp_buf[size - 1] * sw;
for(x = size - 1; x >= 0; x--) {
sh_ups_blur_buf[x] = v;
/*Forget the right pixel*/
@@ -1034,7 +1040,7 @@ static void shadow_blur_corner(lv_coord_t size, lv_coord_t sw, uint16_t * sh_ups
uint32_t i;
sh_ups_buf[0] = sh_ups_buf[0] / sw;
for(i = 1; i < (uint32_t)size * size; i++) {
if(sh_ups_buf[i] == sh_ups_buf[i-1]) sh_ups_buf[i] = sh_ups_buf[i-1];
if(sh_ups_buf[i] == sh_ups_buf[i - 1]) sh_ups_buf[i] = sh_ups_buf[i - 1];
else sh_ups_buf[i] = sh_ups_buf[i] / sw;
}
@@ -1213,7 +1219,7 @@ static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_dr
lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode);
/*Draw the bottom horizontal line*/
if(fill_area2.y2 > area_outer.y2 - dsc->outline_width ) {
if(fill_area2.y2 > area_outer.y2 - dsc->outline_width) {
fill_area2.x1 = area_outer.x1 + rout;
fill_area2.x2 = area_outer.x2 - rout;
@@ -1256,7 +1262,7 @@ static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_dr
memset(mask_buf, LV_OPA_COVER, draw_area_w);
mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
lv_blend_fill( clip, &fill_area, color, mask_buf, mask_res, opa, blend_mode);
lv_blend_fill(clip, &fill_area, color, mask_buf, mask_res, opa, blend_mode);
fill_area.y1++;
fill_area.y2++;
@@ -1282,7 +1288,7 @@ static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, lv_dr
if(src_type == LV_IMG_SRC_FILE || src_type == LV_IMG_SRC_VARIABLE) {
lv_img_header_t header;
lv_res_t res = lv_img_decoder_get_info(dsc->pattern_image, &header);
if(res!= LV_RES_OK) {
if(res != LV_RES_OK) {
LV_LOG_WARN("draw_img: can't get image info");
return;
}
@@ -1294,17 +1300,20 @@ static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, lv_dr
img_dsc.opa = dsc->pattern_opa;
img_dsc.recolor_opa = dsc->pattern_recolor_opa;
img_dsc.recolor = dsc->pattern_recolor;
} else if(src_type == LV_IMG_SRC_SYMBOL) {
}
else if(src_type == LV_IMG_SRC_SYMBOL) {
lv_draw_label_dsc_init(&label_dsc);
label_dsc.color = dsc->pattern_recolor;
label_dsc.font = dsc->pattern_font;
label_dsc.opa = dsc->pattern_opa;
lv_point_t s;
lv_txt_get_size(&s, dsc->pattern_image, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX, LV_TXT_FLAG_NONE);
lv_txt_get_size(&s, dsc->pattern_image, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX,
LV_TXT_FLAG_NONE);
img_w = s.x;
img_h = s.y;
} else {
}
else {
/*Trigger the error handler of image drawer*/
LV_LOG_WARN("lv_img_design: image source type is unknown");
lv_draw_img(coords, clip, NULL, NULL);
@@ -1333,7 +1342,8 @@ static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, lv_dr
}
}
lv_draw_mask_remove_id(radius_mask_id);
} else {
}
else {
int32_t obj_w = lv_area_get_width(coords);
int32_t obj_h = lv_area_get_height(coords);
coords_tmp.x1 = coords->x1 + (obj_w - img_w) / 2;
@@ -1371,7 +1381,8 @@ static void draw_value(const lv_area_t * coords, const lv_area_t * clip, lv_draw
if(dsc->value_opa <= LV_OPA_MIN) return;
lv_point_t s;
lv_txt_get_size(&s, dsc->value_str, dsc->value_font, dsc->value_letter_space, dsc->value_line_space, LV_COORD_MAX, LV_TXT_FLAG_NONE);
lv_txt_get_size(&s, dsc->value_str, dsc->value_font, dsc->value_letter_space, dsc->value_line_space, LV_COORD_MAX,
LV_TXT_FLAG_NONE);
lv_area_t value_area;
value_area.x1 = 0;

View File

@@ -64,7 +64,7 @@ typedef struct {
lv_color_t pattern_recolor;
lv_opa_t pattern_opa;
lv_opa_t pattern_recolor_opa;
uint8_t pattern_repeat :1;
uint8_t pattern_repeat : 1;
lv_blend_mode_t pattern_blend_mode;
/*Value*/
@@ -78,7 +78,7 @@ typedef struct {
lv_style_int_t value_line_space;
lv_align_t value_align;
lv_blend_mode_t value_blend_mode;
}lv_draw_rect_dsc_t;
} lv_draw_rect_dsc_t;
/**********************
* GLOBAL PROTOTYPES

View File

@@ -52,7 +52,8 @@ void lv_draw_triangle(const lv_point_t * points, const lv_area_t * clip_area, lv
* @param clip_area polygon will be drawn only in this area
* @param draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable
*/
void lv_draw_polygon(const lv_point_t * points, uint16_t point_cnt, const lv_area_t * clip_area, lv_draw_rect_dsc_t * draw_dsc)
void lv_draw_polygon(const lv_point_t * points, uint16_t point_cnt, const lv_area_t * clip_area,
lv_draw_rect_dsc_t * draw_dsc)
{
if(point_cnt < 3) return;
if(points == NULL) return;
@@ -111,7 +112,8 @@ void lv_draw_polygon(const lv_point_t * points, uint16_t point_cnt, const lv_are
i_next_right = i_prev_right + 1;
if(i_next_right > point_cnt - 1) i_next_right = 0;
} else {
}
else {
i_next_left = i_prev_left + 1;
if(i_next_left > point_cnt - 1) i_next_left = 0;
@@ -121,10 +123,10 @@ void lv_draw_polygon(const lv_point_t * points, uint16_t point_cnt, const lv_are
if(points[i_next_left].y >= points[i_prev_left].y) {
if(points[i_next_left].y != points[i_prev_left].y &&
points[i_next_left].x != points[i_prev_left].x) {
points[i_next_left].x != points[i_prev_left].x) {
lv_draw_mask_line_points_init(mp_next, points[i_prev_left].x, points[i_prev_left].y,
points[i_next_left].x, points[i_next_left].y,
LV_DRAW_MASK_LINE_SIDE_RIGHT);
points[i_next_left].x, points[i_next_left].y,
LV_DRAW_MASK_LINE_SIDE_RIGHT);
lv_draw_mask_add(mp_next, mp);
mp_next++;
}
@@ -139,8 +141,8 @@ void lv_draw_polygon(const lv_point_t * points, uint16_t point_cnt, const lv_are
points[i_next_right].x != points[i_prev_right].x) {
lv_draw_mask_line_points_init(mp_next, points[i_prev_right].x, points[i_prev_right].y,
points[i_next_right].x, points[i_next_right].y,
LV_DRAW_MASK_LINE_SIDE_LEFT);
points[i_next_right].x, points[i_next_right].y,
LV_DRAW_MASK_LINE_SIDE_LEFT);
lv_draw_mask_add(mp_next, mp);
mp_next++;
}
@@ -148,7 +150,7 @@ void lv_draw_polygon(const lv_point_t * points, uint16_t point_cnt, const lv_are
i_prev_right = i_next_right;
}
}while( mask_cnt < point_cnt);
} while(mask_cnt < point_cnt);
lv_draw_rect(&poly_coords, clip_area, draw_dsc);

View File

@@ -42,7 +42,8 @@ void lv_draw_triangle(const lv_point_t * points, const lv_area_t * clip, lv_draw
* @param clip_area polygon will be drawn only in this area
* @param draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable
*/
void lv_draw_polygon(const lv_point_t * points, uint16_t point_cnt, const lv_area_t * mask, lv_draw_rect_dsc_t * draw_dsc);
void lv_draw_polygon(const lv_point_t * points, uint16_t point_cnt, const lv_area_t * mask,
lv_draw_rect_dsc_t * draw_dsc);
/**********************
* MACROS

View File

@@ -56,14 +56,15 @@ lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t
uint8_t * buf_u8 = (uint8_t *)dsc->data;
if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR || dsc->header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED ||
dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) {
dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) {
uint8_t px_size = lv_img_cf_get_px_size(dsc->header.cf) >> 3;
uint32_t px = dsc->header.w * y * px_size + x * px_size;
memcpy(&p_color, &buf_u8[px], sizeof(lv_color_t));
#if LV_COLOR_SIZE == 32
p_color.ch.alpha = 0xFF; /*Only the color should be get so use a deafult alpha value*/
#endif
} else if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT) {
}
else if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT) {
buf_u8 += 4 * 2;
uint8_t bit = x & 0x7;
x = x >> 3;
@@ -73,7 +74,8 @@ lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t
* so the possible real width are 8, 16, 24 ...*/
uint32_t px = ((dsc->header.w + 7) >> 3) * y + x;
p_color.full = (buf_u8[px] & (1 << (7 - bit))) >> (7 - bit);
} else if(dsc->header.cf == LV_IMG_CF_INDEXED_2BIT) {
}
else if(dsc->header.cf == LV_IMG_CF_INDEXED_2BIT) {
buf_u8 += 4 * 4;
uint8_t bit = (x & 0x3) * 2;
x = x >> 2;
@@ -83,7 +85,8 @@ lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t
* so the possible real width are 4, 8, 12 ...*/
uint32_t px = ((dsc->header.w + 3) >> 2) * y + x;
p_color.full = (buf_u8[px] & (3 << (6 - bit))) >> (6 - bit);
} else if(dsc->header.cf == LV_IMG_CF_INDEXED_4BIT) {
}
else if(dsc->header.cf == LV_IMG_CF_INDEXED_4BIT) {
buf_u8 += 4 * 16;
uint8_t bit = (x & 0x1) * 4;
x = x >> 1;
@@ -93,11 +96,13 @@ lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t
* so the possible real width are 2, 4, 6 ...*/
uint32_t px = ((dsc->header.w + 1) >> 1) * y + x;
p_color.full = (buf_u8[px] & (0xF << (4 - bit))) >> (4 - bit);
} else if(dsc->header.cf == LV_IMG_CF_INDEXED_8BIT) {
}
else if(dsc->header.cf == LV_IMG_CF_INDEXED_8BIT) {
buf_u8 += 4 * 256;
uint32_t px = dsc->header.w * y + x;
p_color.full = buf_u8[px];
} else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT || dsc->header.cf == LV_IMG_CF_ALPHA_2BIT ||
}
else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT || dsc->header.cf == LV_IMG_CF_ALPHA_2BIT ||
dsc->header.cf == LV_IMG_CF_ALPHA_4BIT || dsc->header.cf == LV_IMG_CF_ALPHA_8BIT) {
p_color = color;
}
@@ -119,7 +124,8 @@ lv_opa_t lv_img_buf_get_px_alpha(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y)
if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) {
uint32_t px = dsc->header.w * y * LV_IMG_PX_SIZE_ALPHA_BYTE + x * LV_IMG_PX_SIZE_ALPHA_BYTE;
return buf_u8[px + LV_IMG_PX_SIZE_ALPHA_BYTE - 1];
} else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT) {
}
else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT) {
uint8_t bit = x & 0x7;
x = x >> 3;
@@ -129,7 +135,8 @@ lv_opa_t lv_img_buf_get_px_alpha(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y)
uint32_t px = ((dsc->header.w + 7) >> 3) * y + x;
uint8_t px_opa = (buf_u8[px] & (1 << (7 - bit))) >> (7 - bit);
return px_opa ? LV_OPA_TRANSP : LV_OPA_COVER;
} else if(dsc->header.cf == LV_IMG_CF_ALPHA_2BIT) {
}
else if(dsc->header.cf == LV_IMG_CF_ALPHA_2BIT) {
const uint8_t opa_table[4] = {0, 85, 170, 255}; /*Opacity mapping with bpp = 2*/
uint8_t bit = (x & 0x3) * 2;
@@ -141,9 +148,11 @@ lv_opa_t lv_img_buf_get_px_alpha(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y)
uint32_t px = ((dsc->header.w + 3) >> 2) * y + x;
uint8_t px_opa = (buf_u8[px] & (3 << (6 - bit))) >> (6 - bit);
return opa_table[px_opa];
} else if(dsc->header.cf == LV_IMG_CF_ALPHA_4BIT) {
}
else if(dsc->header.cf == LV_IMG_CF_ALPHA_4BIT) {
const uint8_t opa_table[16] = {0, 17, 34, 51, /*Opacity mapping with bpp = 4*/
68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255};
68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255
};
uint8_t bit = (x & 0x1) * 4;
x = x >> 1;
@@ -154,7 +163,8 @@ lv_opa_t lv_img_buf_get_px_alpha(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y)
uint32_t px = ((dsc->header.w + 1) >> 1) * y + x;
uint8_t px_opa = (buf_u8[px] & (0xF << (4 - bit))) >> (4 - bit);
return opa_table[px_opa];
} else if(dsc->header.cf == LV_IMG_CF_ALPHA_8BIT) {
}
else if(dsc->header.cf == LV_IMG_CF_ALPHA_8BIT) {
uint32_t px = dsc->header.w * y + x;
return buf_u8[px];
}
@@ -178,7 +188,8 @@ void lv_img_buf_set_px_alpha(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_
uint8_t px_size = lv_img_cf_get_px_size(dsc->header.cf) >> 3;
uint32_t px = dsc->header.w * y * px_size + x * px_size;
buf_u8[px + px_size - 1] = opa;
} else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT) {
}
else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT) {
opa = opa >> 7; /*opa -> [0,1]*/
uint8_t bit = x & 0x7;
x = x >> 3;
@@ -189,7 +200,8 @@ void lv_img_buf_set_px_alpha(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_
uint32_t px = ((dsc->header.w + 7) >> 3) * y + x;
buf_u8[px] = buf_u8[px] & ~(1 << (7 - bit));
buf_u8[px] = buf_u8[px] | ((opa & 0x1) << (7 - bit));
} else if(dsc->header.cf == LV_IMG_CF_ALPHA_2BIT) {
}
else if(dsc->header.cf == LV_IMG_CF_ALPHA_2BIT) {
opa = opa >> 6; /*opa -> [0,3]*/
uint8_t bit = (x & 0x3) * 2;
x = x >> 2;
@@ -200,7 +212,8 @@ void lv_img_buf_set_px_alpha(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_
uint32_t px = ((dsc->header.w + 3) >> 2) * y + x;
buf_u8[px] = buf_u8[px] & ~(3 << (6 - bit));
buf_u8[px] = buf_u8[px] | ((opa & 0x3) << (6 - bit));
} else if(dsc->header.cf == LV_IMG_CF_ALPHA_4BIT) {
}
else if(dsc->header.cf == LV_IMG_CF_ALPHA_4BIT) {
opa = opa >> 4; /*opa -> [0,15]*/
uint8_t bit = (x & 0x1) * 4;
x = x >> 1;
@@ -211,7 +224,8 @@ void lv_img_buf_set_px_alpha(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_
uint32_t px = ((dsc->header.w + 1) >> 1) * y + x;
buf_u8[px] = buf_u8[px] & ~(0xF << (4 - bit));
buf_u8[px] = buf_u8[px] | ((opa & 0xF) << (4 - bit));
} else if(dsc->header.cf == LV_IMG_CF_ALPHA_8BIT) {
}
else if(dsc->header.cf == LV_IMG_CF_ALPHA_8BIT) {
uint32_t px = dsc->header.w * y + x;
buf_u8[px] = opa;
}
@@ -233,11 +247,13 @@ void lv_img_buf_set_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_
uint8_t px_size = lv_img_cf_get_px_size(dsc->header.cf) >> 3;
uint32_t px = dsc->header.w * y * px_size + x * px_size;
memcpy(&buf_u8[px], &c, px_size);
} else if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) {
}
else if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) {
uint8_t px_size = lv_img_cf_get_px_size(dsc->header.cf) >> 3;
uint32_t px = dsc->header.w * y * px_size + x * px_size;
memcpy(&buf_u8[px], &c, px_size - 1); /*-1 to not overwrite the alpha value*/
} else if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT) {
}
else if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT) {
buf_u8 += sizeof(lv_color32_t) * 2; /*Skip the palette*/
uint8_t bit = x & 0x7;
@@ -249,7 +265,8 @@ void lv_img_buf_set_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_
uint32_t px = ((dsc->header.w + 7) >> 3) * y + x;
buf_u8[px] = buf_u8[px] & ~(1 << (7 - bit));
buf_u8[px] = buf_u8[px] | ((c.full & 0x1) << (7 - bit));
} else if(dsc->header.cf == LV_IMG_CF_INDEXED_2BIT) {
}
else if(dsc->header.cf == LV_IMG_CF_INDEXED_2BIT) {
buf_u8 += sizeof(lv_color32_t) * 4; /*Skip the palette*/
uint8_t bit = (x & 0x3) * 2;
x = x >> 2;
@@ -261,7 +278,8 @@ void lv_img_buf_set_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_
buf_u8[px] = buf_u8[px] & ~(3 << (6 - bit));
buf_u8[px] = buf_u8[px] | ((c.full & 0x3) << (6 - bit));
} else if(dsc->header.cf == LV_IMG_CF_INDEXED_4BIT) {
}
else if(dsc->header.cf == LV_IMG_CF_INDEXED_4BIT) {
buf_u8 += sizeof(lv_color32_t) * 16; /*Skip the palette*/
uint8_t bit = (x & 0x1) * 4;
x = x >> 1;
@@ -272,7 +290,8 @@ void lv_img_buf_set_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_
uint32_t px = ((dsc->header.w + 1) >> 1) * y + x;
buf_u8[px] = buf_u8[px] & ~(0xF << (4 - bit));
buf_u8[px] = buf_u8[px] | ((c.full & 0xF) << (4 - bit));
} else if(dsc->header.cf == LV_IMG_CF_INDEXED_8BIT) {
}
else if(dsc->header.cf == LV_IMG_CF_INDEXED_8BIT) {
buf_u8 += sizeof(lv_color32_t) * 256; /*Skip the palette*/
uint32_t px = dsc->header.w * y + x;
buf_u8[px] = c.full;
@@ -292,7 +311,7 @@ void lv_img_buf_set_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_
void lv_img_buf_set_palette(lv_img_dsc_t * dsc, uint8_t id, lv_color_t c)
{
if((dsc->header.cf == LV_IMG_CF_ALPHA_1BIT && id > 1) || (dsc->header.cf == LV_IMG_CF_ALPHA_2BIT && id > 3) ||
(dsc->header.cf == LV_IMG_CF_ALPHA_4BIT && id > 15) || (dsc->header.cf == LV_IMG_CF_ALPHA_8BIT)) {
(dsc->header.cf == LV_IMG_CF_ALPHA_4BIT && id > 15) || (dsc->header.cf == LV_IMG_CF_ALPHA_8BIT)) {
LV_LOG_WARN("lv_img_buf_set_px_alpha: invalid 'id'");
return;
}
@@ -310,10 +329,10 @@ void lv_img_buf_set_palette(lv_img_dsc_t * dsc, uint8_t id, lv_color_t c)
* @param cf a color format (`LV_IMG_CF_...`)
* @return an allocated image, or NULL on failure
*/
lv_img_dsc_t *lv_img_buf_alloc(lv_coord_t w, lv_coord_t h, lv_img_cf_t cf)
lv_img_dsc_t * lv_img_buf_alloc(lv_coord_t w, lv_coord_t h, lv_img_cf_t cf)
{
/* Allocate image descriptor */
lv_img_dsc_t *dsc = lv_mem_alloc(sizeof(lv_img_dsc_t));
lv_img_dsc_t * dsc = lv_mem_alloc(sizeof(lv_img_dsc_t));
if(dsc == NULL)
return NULL;
@@ -346,7 +365,7 @@ lv_img_dsc_t *lv_img_buf_alloc(lv_coord_t w, lv_coord_t h, lv_img_cf_t cf)
* Free an allocated image buffer
* @param dsc image buffer to free
*/
void lv_img_buf_free(lv_img_dsc_t *dsc)
void lv_img_buf_free(lv_img_dsc_t * dsc)
{
if(dsc != NULL) {
if(dsc->data != NULL)
@@ -366,18 +385,30 @@ void lv_img_buf_free(lv_img_dsc_t *dsc)
uint32_t lv_img_buf_get_img_size(lv_coord_t w, lv_coord_t h, lv_img_cf_t cf)
{
switch(cf) {
case LV_IMG_CF_TRUE_COLOR: return LV_IMG_BUF_SIZE_TRUE_COLOR(w, h);
case LV_IMG_CF_TRUE_COLOR_ALPHA: return LV_IMG_BUF_SIZE_TRUE_COLOR_ALPHA(w, h);
case LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED: return LV_IMG_BUF_SIZE_TRUE_COLOR_CHROMA_KEYED(w, h);
case LV_IMG_CF_ALPHA_1BIT: return LV_IMG_BUF_SIZE_ALPHA_1BIT(w, h);
case LV_IMG_CF_ALPHA_2BIT: return LV_IMG_BUF_SIZE_ALPHA_2BIT(w, h);
case LV_IMG_CF_ALPHA_4BIT: return LV_IMG_BUF_SIZE_ALPHA_4BIT(w, h);
case LV_IMG_CF_ALPHA_8BIT: return LV_IMG_BUF_SIZE_ALPHA_8BIT(w, h);
case LV_IMG_CF_INDEXED_1BIT: return LV_IMG_BUF_SIZE_INDEXED_1BIT(w, h);
case LV_IMG_CF_INDEXED_2BIT: return LV_IMG_BUF_SIZE_INDEXED_2BIT(w, h);
case LV_IMG_CF_INDEXED_4BIT: return LV_IMG_BUF_SIZE_INDEXED_4BIT(w, h);
case LV_IMG_CF_INDEXED_8BIT: return LV_IMG_BUF_SIZE_INDEXED_8BIT(w, h);
default: return 0;
case LV_IMG_CF_TRUE_COLOR:
return LV_IMG_BUF_SIZE_TRUE_COLOR(w, h);
case LV_IMG_CF_TRUE_COLOR_ALPHA:
return LV_IMG_BUF_SIZE_TRUE_COLOR_ALPHA(w, h);
case LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED:
return LV_IMG_BUF_SIZE_TRUE_COLOR_CHROMA_KEYED(w, h);
case LV_IMG_CF_ALPHA_1BIT:
return LV_IMG_BUF_SIZE_ALPHA_1BIT(w, h);
case LV_IMG_CF_ALPHA_2BIT:
return LV_IMG_BUF_SIZE_ALPHA_2BIT(w, h);
case LV_IMG_CF_ALPHA_4BIT:
return LV_IMG_BUF_SIZE_ALPHA_4BIT(w, h);
case LV_IMG_CF_ALPHA_8BIT:
return LV_IMG_BUF_SIZE_ALPHA_8BIT(w, h);
case LV_IMG_CF_INDEXED_1BIT:
return LV_IMG_BUF_SIZE_INDEXED_1BIT(w, h);
case LV_IMG_CF_INDEXED_2BIT:
return LV_IMG_BUF_SIZE_INDEXED_2BIT(w, h);
case LV_IMG_CF_INDEXED_4BIT:
return LV_IMG_BUF_SIZE_INDEXED_4BIT(w, h);
case LV_IMG_CF_INDEXED_8BIT:
return LV_IMG_BUF_SIZE_INDEXED_8BIT(w, h);
default:
return 0;
}
}
@@ -405,7 +436,8 @@ void lv_img_buf_transform_init(lv_img_transform_dsc_t * dsc)
dsc->tmp.chroma_keyed = lv_img_cf_is_chroma_keyed(dsc->cfg.cf) ? 1 : 0;
dsc->tmp.has_alpha = lv_img_cf_has_alpha(dsc->cfg.cf) ? 1 : 0;
if(dsc->cfg.cf == LV_IMG_CF_TRUE_COLOR || dsc->cfg.cf == LV_IMG_CF_TRUE_COLOR_ALPHA || dsc->cfg.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) {
if(dsc->cfg.cf == LV_IMG_CF_TRUE_COLOR || dsc->cfg.cf == LV_IMG_CF_TRUE_COLOR_ALPHA ||
dsc->cfg.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) {
dsc->tmp.native_color = 1;
}
@@ -443,7 +475,8 @@ bool lv_img_buf_transform(lv_img_transform_dsc_t * dsc, lv_coord_t x, lv_coord_t
/*Get the source pixel from the upscaled image*/
xs = ((dsc->tmp.cosma * xt - dsc->tmp.sinma * yt) >> (LV_TRIGO_SHIFT - 8)) + dsc->tmp.pivot_x_256;
ys = ((dsc->tmp.sinma * xt + dsc->tmp.cosma * yt) >> (LV_TRIGO_SHIFT - 8)) + dsc->tmp.pivot_y_256;
} else {
}
else {
xt *= dsc->tmp.zoom_inv;
yt *= dsc->tmp.zoom_inv;
xs = ((dsc->tmp.cosma * xt - dsc->tmp.sinma * yt) >> (LV_TRIGO_SHIFT)) + dsc->tmp.pivot_x_256;
@@ -472,13 +505,15 @@ bool lv_img_buf_transform(lv_img_transform_dsc_t * dsc, lv_coord_t x, lv_coord_t
pxi = dsc->cfg.src_w * ys_int * px_size + xs_int * px_size;
memcpy(&dsc->res.color, &src_u8[pxi], px_size);
} else {
}
else {
px_size = LV_IMG_PX_SIZE_ALPHA_BYTE;
pxi = dsc->cfg.src_w * ys_int * px_size + xs_int * px_size;
memcpy(&dsc->res.color, &src_u8[pxi], px_size - 1);
dsc->res.opa = src_u8[pxi + px_size - 1];
}
} else {
}
else {
pxi = 0; /*unused*/
px_size = 0; /*unused*/
dsc->res.color = lv_img_buf_get_px_color(&dsc->tmp.img_dsc, xs_int, ys_int, dsc->cfg.color);
@@ -516,7 +551,8 @@ bool lv_img_buf_transform(lv_img_transform_dsc_t * dsc, lv_coord_t x, lv_coord_t
* @param zoom zoom, (256 no zoom)
* @param pivot x,y pivot coordinates of rotation
*/
void lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t h, int16_t angle, uint16_t zoom, lv_point_t * pivot)
void lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t h, int16_t angle, uint16_t zoom,
lv_point_t * pivot)
{
int32_t angle_low = angle / 10;
@@ -543,8 +579,8 @@ void lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t h
lv_area_t a;
a.x1 = ((-pivot->x) * zoom) >> 8;
a.y1 = ((-pivot->y) * zoom) >> 8;
a.x2 = ((w -pivot->x) * zoom) >> 8;
a.y2 = ((h -pivot->y) * zoom) >> 8;
a.x2 = ((w - pivot->x) * zoom) >> 8;
a.y2 = ((h - pivot->y) * zoom) >> 8;
xt = a.x1;
yt = a.y1;
@@ -587,14 +623,16 @@ static inline bool transform_anti_alias(lv_img_transform_dsc_t * dsc)
lv_opa_t xr; /*x mix ratio*/
if(xs_fract < 0x70) {
xn = - 1;
if(dsc->tmp.xs_int + xn < 0) xn = 0;
xr = xs_fract + 0x80;
} else if(xs_fract > 0x90) {
xn = - 1;
if(dsc->tmp.xs_int + xn < 0) xn = 0;
xr = xs_fract + 0x80;
}
else if(xs_fract > 0x90) {
xn = 1;
if(dsc->tmp.xs_int + xn >= dsc->cfg.src_w) xn = 0;
xr = (0xFF - xs_fract) + 0x80;
} else {
}
else {
xn = 0;
xr = 0xFF;
}
@@ -603,16 +641,18 @@ static inline bool transform_anti_alias(lv_img_transform_dsc_t * dsc)
lv_opa_t yr; /*x mix ratio*/
if(ys_fract < 0x70) {
yn = - 1;
if(dsc->tmp.ys_int + yn < 0) yn = 0;
yn = - 1;
if(dsc->tmp.ys_int + yn < 0) yn = 0;
yr = ys_fract + 0x80;
} else if(ys_fract > 0x90) {
yr = ys_fract + 0x80;
}
else if(ys_fract > 0x90) {
yn = 1;
if(dsc->tmp.ys_int + yn >= dsc->cfg.src_h) yn = 0;
yr = (0xFF - ys_fract) + 0x80;
} else {
}
else {
yn = 0;
yr = 0xFF;
}
@@ -630,13 +670,15 @@ static inline bool transform_anti_alias(lv_img_transform_dsc_t * dsc)
if(dsc->tmp.native_color) {
memcpy(&c01, &src_u8[dsc->tmp.pxi + dsc->tmp.px_size * xn], sizeof(lv_color_t));
memcpy(&c10, &src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn], sizeof(lv_color_t));
memcpy(&c11, &src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn + dsc->tmp.px_size * xn], sizeof(lv_color_t));
memcpy(&c11, &src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn + dsc->tmp.px_size * xn],
sizeof(lv_color_t));
if(dsc->tmp.has_alpha) {
a10 = src_u8[dsc->tmp.pxi + dsc->tmp.px_size * xn + dsc->tmp.px_size - 1];
a01 = src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn + dsc->tmp.px_size - 1];
a11 = src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn + dsc->tmp.px_size * xn + dsc->tmp.px_size - 1];
}
} else {
}
else {
c01 = lv_img_buf_get_px_color(&dsc->tmp.img_dsc, dsc->tmp.xs_int + xn, dsc->tmp.ys_int, dsc->cfg.color);
c10 = lv_img_buf_get_px_color(&dsc->tmp.img_dsc, dsc->tmp.xs_int, dsc->tmp.ys_int + yn, dsc->cfg.color);
c11 = lv_img_buf_get_px_color(&dsc->tmp.img_dsc, dsc->tmp.xs_int + xn, dsc->tmp.ys_int + yn, dsc->cfg.color);
@@ -662,7 +704,8 @@ static inline bool transform_anti_alias(lv_img_transform_dsc_t * dsc)
if(a10 <= LV_OPA_MIN) xr0 = LV_OPA_COVER;
if(a01 <= LV_OPA_MIN) xr1 = LV_OPA_TRANSP;
if(a11 <= LV_OPA_MIN) xr1 = LV_OPA_COVER;
} else {
}
else {
xr0 = xr;
xr1 = xr;
dsc->res.opa = LV_OPA_COVER;

View File

@@ -103,8 +103,7 @@ typedef uint8_t lv_img_cf_t;
/**
* LittlevGL image header
*/
typedef struct
{
typedef struct {
/* The first 8 bit is very important to distinguish the different source types.
* For more info see `lv_img_get_src_type()` in lv_img.c */
@@ -121,8 +120,7 @@ typedef struct
/** Image header it is compatible with
* the result from image converter utility*/
typedef struct
{
typedef struct {
lv_img_header_t header;
uint32_t data_size;
const uint8_t * data;
@@ -140,12 +138,12 @@ typedef struct {
lv_color_t color; /*a color used for `LV_IMG_CF_INDEXED_1/2/4/8BIT` color formats*/
lv_img_cf_t cf; /*color format of the image to rotate*/
bool antialias;
}cfg;
} cfg;
struct {
lv_color_t color;
lv_opa_t opa;
}res;
} res;
struct {
@@ -155,9 +153,9 @@ typedef struct {
int32_t sinma;
int32_t cosma;
uint8_t chroma_keyed :1;
uint8_t has_alpha :1;
uint8_t native_color :1;
uint8_t chroma_keyed : 1;
uint8_t has_alpha : 1;
uint8_t native_color : 1;
uint16_t zoom_inv;
@@ -168,8 +166,8 @@ typedef struct {
lv_coord_t ys_int;
uint32_t pxi;
uint8_t px_size;
}tmp;
}lv_img_transform_dsc_t;
} tmp;
} lv_img_transform_dsc_t;
/**********************
* GLOBAL PROTOTYPES
@@ -182,7 +180,7 @@ typedef struct {
* @param cf a color format (`LV_IMG_CF_...`)
* @return an allocated image, or NULL on failure
*/
lv_img_dsc_t *lv_img_buf_alloc(lv_coord_t w, lv_coord_t h, lv_img_cf_t cf);
lv_img_dsc_t * lv_img_buf_alloc(lv_coord_t w, lv_coord_t h, lv_img_cf_t cf);
/**
* Get the color of an image's pixel
@@ -242,7 +240,7 @@ void lv_img_buf_set_palette(lv_img_dsc_t * dsc, uint8_t id, lv_color_t c);
* Free an allocated image buffer
* @param dsc image buffer to free
*/
void lv_img_buf_free(lv_img_dsc_t *dsc);
void lv_img_buf_free(lv_img_dsc_t * dsc);
/**
* Get the memory consumption of a raw bitmap, given color format and dimensions.
@@ -279,7 +277,8 @@ bool lv_img_buf_transform(lv_img_transform_dsc_t * dsc, lv_coord_t x, lv_coord_t
* @param zoom zoom, (256 no zoom)
* @param pivot x,y pivot coordinates of rotation
*/
void lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t h, int16_t angle, uint16_t zoom, lv_point_t * pivot);
void lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t h, int16_t angle, uint16_t zoom,
lv_point_t * pivot);
/**********************
* MACROS

View File

@@ -14,7 +14,7 @@
#include "../lv_misc/lv_gc.h"
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/*********************
* DEFINES
@@ -30,7 +30,7 @@
#define LV_IMG_CACHE_LIFE_LIMIT 1000
#if LV_IMG_CACHE_DEF_SIZE < 1
#error "LV_IMG_CACHE_DEF_SIZE must be >= 1. See lv_conf.h"
#error "LV_IMG_CACHE_DEF_SIZE must be >= 1. See lv_conf.h"
#endif
/**********************
@@ -86,7 +86,8 @@ lv_img_cache_entry_t * lv_img_cache_open(const void * src, lv_color_t color)
lv_img_src_t src_type = lv_img_src_get_type(cache[i].dec_dsc.src);
if(src_type == LV_IMG_SRC_VARIABLE) {
if(cache[i].dec_dsc.src == src && cache[i].dec_dsc.color.full == color.full) match = true;
} else if(src_type == LV_IMG_SRC_FILE) {
}
else if(src_type == LV_IMG_SRC_FILE) {
if(strcmp(cache[i].dec_dsc.src, src) == 0) match = true;
}
@@ -116,7 +117,8 @@ lv_img_cache_entry_t * lv_img_cache_open(const void * src, lv_color_t color)
if(cached_src->dec_dsc.src) {
lv_img_decoder_close(&cached_src->dec_dsc);
LV_LOG_INFO("image draw: cache miss, close and reuse an entry");
} else {
}
else {
LV_LOG_INFO("image draw: cache miss, cached to an empty entry");
}

View File

@@ -28,8 +28,7 @@ extern "C" {
*
* To avoid repeating this heavy load images can be cached.
*/
typedef struct
{
typedef struct {
lv_img_decoder_dsc_t dec_dsc; /**< Image information */
/** Count the cache entries's life. Add `time_tio_open` to `life` when the entry is used.

View File

@@ -14,7 +14,7 @@
#include "../lv_misc/lv_gc.h"
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/*********************
@@ -26,8 +26,7 @@
/**********************
* TYPEDEFS
**********************/
typedef struct
{
typedef struct {
#if LV_USE_FILESYSTEM
lv_fs_file_t * f;
#endif
@@ -93,8 +92,7 @@ lv_res_t lv_img_decoder_get_info(const char * src, lv_img_header_t * header)
lv_res_t res = LV_RES_INV;
lv_img_decoder_t * d;
LV_LL_READ(LV_GC_ROOT(_lv_img_defoder_ll), d)
{
LV_LL_READ(LV_GC_ROOT(_lv_img_defoder_ll), d) {
res = LV_RES_INV;
if(d->info_cb) {
res = d->info_cb(d, src, header);
@@ -127,15 +125,15 @@ lv_res_t lv_img_decoder_open(lv_img_decoder_dsc_t * dsc, const void * src, lv_co
size_t fnlen = strlen(src);
dsc->src = lv_mem_alloc(fnlen + 1);
strcpy((char *)dsc->src, src);
} else {
}
else {
dsc->src = src;
}
lv_res_t res = LV_RES_INV;
lv_img_decoder_t * d;
LV_LL_READ(LV_GC_ROOT(_lv_img_defoder_ll), d)
{
LV_LL_READ(LV_GC_ROOT(_lv_img_defoder_ll), d) {
/*Info an Open callbacks are required*/
if(d->info_cb == NULL || d->open_cb == NULL) continue;
@@ -305,7 +303,8 @@ lv_res_t lv_img_decoder_built_in_info(lv_img_decoder_t * decoder, const void * s
/* Symbols always have transparent parts. Important because of cover check in the design
* function. The actual value doesn't matter because lv_draw_label will draw it*/
header->cf = LV_IMG_CF_ALPHA_1BIT;
} else {
}
else {
LV_LOG_WARN("Image get info found unknown src type");
return LV_RES_INV;
}
@@ -357,10 +356,11 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
LV_LOG_WARN("Image built-in decoder cannot read file because LV_USE_FILESYSTEM = 0");
return LV_RES_INV;
#endif
} else if(dsc->src_type == LV_IMG_SRC_VARIABLE) {
/*The variables should have valid data*/
}
else if(dsc->src_type == LV_IMG_SRC_VARIABLE) {
/*The variables should have valid data*/
if(((lv_img_dsc_t *)dsc->src)->data == NULL) {
return LV_RES_INV;
return LV_RES_INV;
}
}
@@ -372,7 +372,8 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
* So simply give its pointer*/
dsc->img_data = ((lv_img_dsc_t *)dsc->src)->data;
return LV_RES_OK;
} else {
}
else {
/*If it's a file it need to be read line by line later*/
dsc->img_data = NULL;
return LV_RES_OK;
@@ -421,7 +422,8 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
LV_LOG_WARN("Image built-in decoder can read the palette because LV_USE_FILESYSTEM = 0");
return LV_RES_INV;
#endif
} else {
}
else {
/*The palette begins in the beginning of the image data. Just point to it.*/
lv_color32_t * palette_p = (lv_color32_t *)((lv_img_dsc_t *)dsc->src)->data;
@@ -473,7 +475,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
* @return LV_RES_OK: ok; LV_RES_INV: failed
*/
lv_res_t lv_img_decoder_built_in_read_line(lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * dsc, lv_coord_t x,
lv_coord_t y, lv_coord_t len, uint8_t * buf)
lv_coord_t y, lv_coord_t len, uint8_t * buf)
{
(void)decoder; /*Unused*/
@@ -486,14 +488,17 @@ lv_res_t lv_img_decoder_built_in_read_line(lv_img_decoder_t * decoder, lv_img_de
if(dsc->src_type == LV_IMG_SRC_FILE) {
res = lv_img_decoder_built_in_line_true_color(dsc, x, y, len, buf);
}
} else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT || dsc->header.cf == LV_IMG_CF_ALPHA_2BIT ||
dsc->header.cf == LV_IMG_CF_ALPHA_4BIT || dsc->header.cf == LV_IMG_CF_ALPHA_8BIT) {
}
else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT || dsc->header.cf == LV_IMG_CF_ALPHA_2BIT ||
dsc->header.cf == LV_IMG_CF_ALPHA_4BIT || dsc->header.cf == LV_IMG_CF_ALPHA_8BIT) {
res = lv_img_decoder_built_in_line_alpha(dsc, x, y, len, buf);
} else if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT || dsc->header.cf == LV_IMG_CF_INDEXED_2BIT ||
dsc->header.cf == LV_IMG_CF_INDEXED_4BIT || dsc->header.cf == LV_IMG_CF_INDEXED_8BIT) {
}
else if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT || dsc->header.cf == LV_IMG_CF_INDEXED_2BIT ||
dsc->header.cf == LV_IMG_CF_INDEXED_4BIT || dsc->header.cf == LV_IMG_CF_INDEXED_8BIT) {
res = lv_img_decoder_built_in_line_indexed(dsc, x, y, len, buf);
} else {
}
else {
LV_LOG_WARN("Built-in image decoder read not supports the color format");
return LV_RES_INV;
}
@@ -570,7 +575,8 @@ static lv_res_t lv_img_decoder_built_in_line_alpha(lv_img_decoder_dsc_t * dsc, l
const lv_opa_t alpha1_opa_table[2] = {0, 255}; /*Opacity mapping with bpp = 1 (Just for compatibility)*/
const lv_opa_t alpha2_opa_table[4] = {0, 85, 170, 255}; /*Opacity mapping with bpp = 2*/
const lv_opa_t alpha4_opa_table[16] = {0, 17, 34, 51, /*Opacity mapping with bpp = 4*/
68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255};
68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255
};
/*Simply fill the buffer with the color. Later only the alpha value will be modified.*/
lv_color_t bg_color = dsc->color;
@@ -635,7 +641,8 @@ static lv_res_t lv_img_decoder_built_in_line_alpha(lv_img_decoder_dsc_t * dsc, l
const lv_img_dsc_t * img_dsc = dsc->src;
data_tmp = img_dsc->data + ofs;
} else {
}
else {
#if LV_USE_FILESYSTEM
lv_fs_seek(user_data->f, ofs + 4); /*+4 to skip the header*/
lv_fs_read(user_data->f, fs_buf, w, NULL);
@@ -720,7 +727,8 @@ static lv_res_t lv_img_decoder_built_in_line_indexed(lv_img_decoder_dsc_t * dsc,
if(dsc->src_type == LV_IMG_SRC_VARIABLE) {
const lv_img_dsc_t * img_dsc = dsc->src;
data_tmp = img_dsc->data + ofs;
} else {
}
else {
#if LV_USE_FILESYSTEM
lv_fs_seek(user_data->f, ofs + 4); /*+4 to skip the header*/
lv_fs_read(user_data->f, fs_buf, w, NULL);

View File

@@ -84,8 +84,7 @@ typedef lv_res_t (*lv_img_decoder_read_line_f_t)(struct _lv_img_decoder * decode
*/
typedef void (*lv_img_decoder_close_f_t)(struct _lv_img_decoder * decoder, struct _lv_img_decoder_dsc * dsc);
typedef struct _lv_img_decoder
{
typedef struct _lv_img_decoder {
lv_img_decoder_info_f_t info_cb;
lv_img_decoder_open_f_t open_cb;
lv_img_decoder_read_line_f_t read_line_cb;
@@ -97,8 +96,7 @@ typedef struct _lv_img_decoder
} lv_img_decoder_t;
/**Describe an image decoding session. Stores data about the decoding*/
typedef struct _lv_img_decoder_dsc
{
typedef struct _lv_img_decoder_dsc {
/**The decoder which was able to open the image source*/
lv_img_decoder_t * decoder;
@@ -254,7 +252,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
* @return LV_RES_OK: ok; LV_RES_INV: failed
*/
lv_res_t lv_img_decoder_built_in_read_line(lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * dsc, lv_coord_t x,
lv_coord_t y, lv_coord_t len, uint8_t * buf);
lv_coord_t y, lv_coord_t len, uint8_t * buf);
/**
* Close the pending decoding. Free resources etc.

View File

@@ -58,7 +58,8 @@ const uint8_t * lv_font_get_glyph_bitmap(const lv_font_t * font_p, uint32_t lett
* @return true: descriptor is successfully loaded into `dsc_out`.
* false: the letter was not found, no data is loaded to `dsc_out`
*/
bool lv_font_get_glyph_dsc(const lv_font_t * font_p, lv_font_glyph_dsc_t * dsc_out, uint32_t letter, uint32_t letter_next)
bool lv_font_get_glyph_dsc(const lv_font_t * font_p, lv_font_glyph_dsc_t * dsc_out, uint32_t letter,
uint32_t letter_next)
{
return font_p->get_glyph_dsc(font_p, dsc_out, letter, letter_next);
}

View File

@@ -39,15 +39,14 @@ extern "C" {
*-----------------*/
/** Describes the properties of a glyph. */
typedef struct
{
typedef struct {
uint16_t adv_w; /**< The glyph needs this space. Draw the next glyph after this width. 8 bit integer, 4 bit fractional */
uint16_t box_w; /**< Width of the glyph's bounding box*/
uint16_t box_h; /**< Height of the glyph's bounding box*/
int16_t ofs_x; /**< x offset of the bounding box*/
int16_t ofs_y; /**< y offset of the bounding box*/
uint8_t bpp; /**< Bit-per-pixel: 1, 2, 4, 8*/
}lv_font_glyph_dsc_t;
} lv_font_glyph_dsc_t;
/** The bitmaps might be upscaled by 3 to achieve subpixel rendering. */
@@ -61,8 +60,7 @@ enum {
typedef uint8_t lv_font_subpx_t;
/** Describe the properties of a font*/
typedef struct _lv_font_struct
{
typedef struct _lv_font_struct {
/** Get a glyph's descriptor from a font*/
bool (*get_glyph_dsc)(const struct _lv_font_struct *, lv_font_glyph_dsc_t *, uint32_t letter, uint32_t letter_next);
@@ -72,7 +70,7 @@ typedef struct _lv_font_struct
/*Pointer to the font in a font pack (must have the same line height)*/
lv_coord_t line_height; /**< The real line height where any text fits*/
lv_coord_t base_line; /**< Base line measured from the top of the line_height*/
uint8_t subpx :2; /**< An element of `lv_font_subpx_t`*/
uint8_t subpx : 2; /**< An element of `lv_font_subpx_t`*/
void * dsc; /**< Store implementation specific or run_time data or caching here*/
#if LV_USE_USER_DATA
lv_font_user_data_t user_data; /**< Custom user data for font. */
@@ -101,7 +99,8 @@ const uint8_t * lv_font_get_glyph_bitmap(const lv_font_t * font_p, uint32_t lett
* @return true: descriptor is successfully loaded into `dsc_out`.
* false: the letter was not found, no data is loaded to `dsc_out`
*/
bool lv_font_get_glyph_dsc(const lv_font_t * font_p, lv_font_glyph_dsc_t * dsc_out, uint32_t letter, uint32_t letter_next);
bool lv_font_get_glyph_dsc(const lv_font_t * font_p, lv_font_glyph_dsc_t * dsc_out, uint32_t letter,
uint32_t letter_next);
/**
* Get the width of a glyph with kerning

View File

@@ -26,7 +26,7 @@ typedef enum {
RLE_STATE_SINGLE = 0,
RLE_STATE_REPEATE,
RLE_STATE_COUNTER,
}rle_state_t;
} rle_state_t;
/**********************
* STATIC PROTOTYPES
@@ -76,7 +76,7 @@ static rle_state_t rle_state;
*/
const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unicode_letter)
{
if(unicode_letter == '\t') unicode_letter = ' ';
if(unicode_letter == '\t') unicode_letter = ' ';
lv_font_fmt_txt_dsc_t * fdsc = (lv_font_fmt_txt_dsc_t *) font->dsc;
uint32_t gid = get_glyph_dsc_id(font, unicode_letter);
@@ -88,8 +88,7 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic
if(gdsc) return &fdsc->glyph_bitmap[gdsc->bitmap_index];
}
/*Handle compressed bitmap*/
else
{
else {
static uint8_t * buf = NULL;
uint32_t gsize = gdsc->box_w * gdsc->box_h;
@@ -97,10 +96,18 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic
uint32_t buf_size = gsize;
switch(fdsc->bpp) {
case 1: buf_size = gsize >> 3; break;
case 2: buf_size = gsize >> 2; break;
case 3: buf_size = gsize >> 1; break;
case 4: buf_size = gsize >> 1; break;
case 1:
buf_size = gsize >> 3;
break;
case 2:
buf_size = gsize >> 2;
break;
case 3:
buf_size = gsize >> 1;
break;
case 4:
buf_size = gsize >> 1;
break;
}
if(lv_mem_get_size(buf) < buf_size) {
@@ -109,7 +116,7 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic
if(buf == NULL) return NULL;
}
decompress(&fdsc->glyph_bitmap[gdsc->bitmap_index], buf, gdsc->box_w , gdsc->box_h, (uint8_t)fdsc->bpp);
decompress(&fdsc->glyph_bitmap[gdsc->bitmap_index], buf, gdsc->box_w, gdsc->box_h, (uint8_t)fdsc->bpp);
return buf;
}
@@ -125,13 +132,14 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic
* @return true: descriptor is successfully loaded into `dsc_out`.
* false: the letter was not found, no data is loaded to `dsc_out`
*/
bool lv_font_get_glyph_dsc_fmt_txt(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next)
bool lv_font_get_glyph_dsc_fmt_txt(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter,
uint32_t unicode_letter_next)
{
bool is_tab = false;
if(unicode_letter == '\t') {
unicode_letter = ' ';
is_tab = true;
}
bool is_tab = false;
if(unicode_letter == '\t') {
unicode_letter = ' ';
is_tab = true;
}
lv_font_fmt_txt_dsc_t * fdsc = (lv_font_fmt_txt_dsc_t *) font->dsc;
uint32_t gid = get_glyph_dsc_id(font, unicode_letter);
if(!gid) return false;
@@ -195,7 +203,8 @@ static uint32_t get_glyph_dsc_id(const lv_font_t * font, uint32_t letter)
glyph_id = fdsc->cmaps[i].glyph_id_start + gid_ofs_8[rcp];
}
else if(fdsc->cmaps[i].type == LV_FONT_FMT_TXT_CMAP_SPARSE_TINY) {
uint8_t * p = lv_utils_bsearch(&rcp, fdsc->cmaps[i].unicode_list, fdsc->cmaps[i].list_length, sizeof(fdsc->cmaps[i].unicode_list[0]), unicode_list_compare);
uint8_t * p = lv_utils_bsearch(&rcp, fdsc->cmaps[i].unicode_list, fdsc->cmaps[i].list_length,
sizeof(fdsc->cmaps[i].unicode_list[0]), unicode_list_compare);
if(p) {
lv_uintptr_t ofs = (lv_uintptr_t)(p - (uint8_t *) fdsc->cmaps[i].unicode_list);
@@ -204,10 +213,11 @@ static uint32_t get_glyph_dsc_id(const lv_font_t * font, uint32_t letter)
}
}
else if(fdsc->cmaps[i].type == LV_FONT_FMT_TXT_CMAP_SPARSE_FULL) {
uint8_t * p = lv_utils_bsearch(&rcp, fdsc->cmaps[i].unicode_list, fdsc->cmaps[i].list_length, sizeof(fdsc->cmaps[i].unicode_list[0]), unicode_list_compare);
uint8_t * p = lv_utils_bsearch(&rcp, fdsc->cmaps[i].unicode_list, fdsc->cmaps[i].list_length,
sizeof(fdsc->cmaps[i].unicode_list[0]), unicode_list_compare);
if(p) {
lv_uintptr_t ofs = (lv_uintptr_t)(p - (uint8_t*) fdsc->cmaps[i].unicode_list);
lv_uintptr_t ofs = (lv_uintptr_t)(p - (uint8_t *) fdsc->cmaps[i].unicode_list);
ofs = ofs >> 1; /*The list stores `uint16_t` so the get the index divide by 2*/
const uint8_t * gid_ofs_16 = fdsc->cmaps[i].glyph_id_ofs_list;
glyph_id = fdsc->cmaps[i].glyph_id_start + gid_ofs_16[ofs];
@@ -248,7 +258,8 @@ static int8_t get_kern_value(const lv_font_t * font, uint32_t gid_left, uint32_t
ofs = ofs >> 1; /*ofs is for pair, divide by 2 to refer as a single value*/
value = kdsc->values[ofs];
}
} else if(kdsc->glyph_ids_size == 1) {
}
else if(kdsc->glyph_ids_size == 1) {
/* Use binary search to find the kern value.
* The pairs are ordered left_id first, then right_id secondly. */
const uint16_t * g_ids = kdsc->glyph_ids;
@@ -257,15 +268,17 @@ static int8_t get_kern_value(const lv_font_t * font, uint32_t gid_left, uint32_t
/*If the `g_id_both` were found get its index from the pointer*/
if(kid_p) {
lv_uintptr_t ofs = (lv_uintptr_t) (kid_p - (const uint8_t *)g_ids);
lv_uintptr_t ofs = (lv_uintptr_t)(kid_p - (const uint8_t *)g_ids);
ofs = ofs >> 4; /*ofs is 4 byte pairs, divide by 4 to refer as a single value*/
value = kdsc->values[ofs];
}
} else {
}
else {
/*Invalid value*/
}
} else {
}
else {
/*Kern classes*/
const lv_font_fmt_txt_kern_classes_t * kdsc = fdsc->kern_dsc;
uint8_t left_class = kdsc->left_class_mapping[gid_left];
@@ -274,7 +287,7 @@ static int8_t get_kern_value(const lv_font_t * font, uint32_t gid_left, uint32_t
/* If class = 0, kerning not exist for that glyph
* else got the value form `class_pair_values` 2D array*/
if(left_class > 0 && right_class > 0) {
value = kdsc->class_pair_values[(left_class-1)* kdsc->right_class_cnt + (right_class-1)];
value = kdsc->class_pair_values[(left_class - 1) * kdsc->right_class_cnt + (right_class - 1)];
}
}
@@ -325,7 +338,7 @@ static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord
lv_coord_t y;
lv_coord_t x;
for(x = 0; x < w; x++) {
bits_write(out,wrp, line_buf1[x], bpp);
bits_write(out, wrp, line_buf1[x], bpp);
wrp += wr_size;
}
@@ -334,7 +347,7 @@ static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord
for(x = 0; x < w; x++) {
line_buf1[x] = line_buf2[x] ^ line_buf1[x];
bits_write(out,wrp, line_buf1[x], bpp);
bits_write(out, wrp, line_buf1[x], bpp);
wrp += wr_size;
}
}
@@ -388,14 +401,30 @@ static void bits_write(uint8_t * out, uint32_t bit_pos, uint8_t val, uint8_t len
if(len == 3) {
len = 4;
switch(val) {
case 0: val = 0; break;
case 1: val = 2; break;
case 2: val = 4; break;
case 3: val = 6; break;
case 4: val = 9; break;
case 5: val = 11; break;
case 6: val = 13; break;
case 7: val = 15; break;
case 0:
val = 0;
break;
case 1:
val = 2;
break;
case 2:
val = 4;
break;
case 3:
val = 6;
break;
case 4:
val = 9;
break;
case 5:
val = 11;
break;
case 6:
val = 13;
break;
case 7:
val = 15;
break;
}
}
@@ -444,14 +473,16 @@ static uint8_t rle_next(void)
rle_rdp += 6;
if(rle_cnt != 0) {
rle_state = RLE_STATE_COUNTER;
} else {
}
else {
ret = get_bits(rle_in, rle_rdp, rle_bpp);
rle_prev_v = ret;
rle_rdp += rle_bpp;
rle_state = RLE_STATE_SINGLE;
}
}
} else {
}
else {
ret = get_bits(rle_in, rle_rdp, rle_bpp);
rle_prev_v = ret;
rle_rdp += rle_bpp;

View File

@@ -27,11 +27,10 @@ extern "C" {
**********************/
/** This describes a glyph. */
typedef struct
{
typedef struct {
#if LV_FONT_FMT_TXT_LARGE == 0
uint32_t bitmap_index : 20; /**< Start index of the bitmap. A font can be max 1 MB. */
uint32_t adv_w :12; /**< Draw the next glyph after this width. 8.4 format (real_value * 16 is stored). */
uint32_t adv_w : 12; /**< Draw the next glyph after this width. 8.4 format (real_value * 16 is stored). */
uint8_t box_w; /**< Width of the glyph's bounding box*/
uint8_t box_h; /**< Height of the glyph's bounding box*/
int8_t ofs_x; /**< x offset of the bounding box*/
@@ -44,7 +43,7 @@ typedef struct
int16_t ofs_x; /**< x offset of the bounding box*/
int16_t ofs_y; /**< y offset of the bounding box. Measured from the top of the line*/
#endif
}lv_font_fmt_txt_glyph_dsc_t;
} lv_font_fmt_txt_glyph_dsc_t;
/** Format of font character map. */
@@ -112,7 +111,7 @@ typedef struct {
/** Type of this character map*/
lv_font_fmt_txt_cmap_type_t type;
}lv_font_fmt_txt_cmap_t;
} lv_font_fmt_txt_cmap_t;
/** A simple mapping of kern values from pairs*/
typedef struct {
@@ -125,9 +124,9 @@ typedef struct {
*/
const void * glyph_ids;
const int8_t * values;
uint32_t pair_cnt :24;
uint32_t glyph_ids_size :2; /*0: `glyph_ids` is stored as `uint8_t`; 1: as `uint16_t`*/
}lv_font_fmt_txt_kern_pair_t;
uint32_t pair_cnt : 24;
uint32_t glyph_ids_size : 2; /*0: `glyph_ids` is stored as `uint8_t`; 1: as `uint16_t`*/
} lv_font_fmt_txt_kern_pair_t;
/** More complex but more optimal class based kern value storage*/
typedef struct {
@@ -144,14 +143,14 @@ typedef struct {
const uint8_t * right_class_mapping; /*Map the glyph_ids to classes: index -> glyph_id -> class_id*/
uint8_t left_class_cnt;
uint8_t right_class_cnt;
}lv_font_fmt_txt_kern_classes_t;
} lv_font_fmt_txt_kern_classes_t;
/** Bitmap formats*/
typedef enum {
LV_FONT_FMT_TXT_PLAIN = 0,
LV_FONT_FMT_TXT_COMPRESSED = 1,
}lv_font_fmt_txt_bitmap_format_t;
} lv_font_fmt_txt_bitmap_format_t;
/*Describe store additional data for fonts */
@@ -176,25 +175,25 @@ typedef struct {
uint16_t kern_scale;
/*Number of cmap tables*/
uint16_t cmap_num :10;
uint16_t cmap_num : 10;
/*Bit per pixel: 1, 2, 3, 4*/
uint16_t bpp :3;
uint16_t bpp : 3;
/*Type of `kern_dsc`*/
uint16_t kern_classes :1;
uint16_t kern_classes : 1;
/*
* storage format of the bitmap
* from `lv_font_fmt_txt_bitmap_format_t`
*/
uint16_t bitmap_format :2;
uint16_t bitmap_format : 2;
/*Cache the last letter and is glyph id*/
uint32_t last_letter;
uint32_t last_glyph_id;
}lv_font_fmt_txt_dsc_t;
} lv_font_fmt_txt_dsc_t;
/**********************
* GLOBAL PROTOTYPES
@@ -216,7 +215,8 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t lett
* @return true: descriptor is successfully loaded into `dsc_out`.
* false: the letter was not found, no data is loaded to `dsc_out`
*/
bool lv_font_get_glyph_dsc_fmt_txt(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next);
bool lv_font_get_glyph_dsc_fmt_txt(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter,
uint32_t unicode_letter_next);
/**********************
* MACROS

View File

@@ -7,7 +7,7 @@
******************************************************************************/
#ifndef LV_FONT_ROBOTO_12
#define LV_FONT_ROBOTO_12 1
#define LV_FONT_ROBOTO_12 1
#endif
#if LV_FONT_ROBOTO_12
@@ -1334,8 +1334,7 @@ static const uint16_t unicode_list_1[] = {
};
/*Collect the unicode lists and glyph_id offsets*/
static const lv_font_fmt_txt_cmap_t cmaps[] =
{
static const lv_font_fmt_txt_cmap_t cmaps[] = {
{
.range_start = 32, .range_length = 95, .glyph_id_start = 1,
.unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY
@@ -1352,8 +1351,7 @@ static const lv_font_fmt_txt_cmap_t cmaps[] =
/*Map glyph_ids to kern left classes*/
static const uint8_t kern_left_class_mapping[] =
{
static const uint8_t kern_left_class_mapping[] = {
0, 1, 0, 2, 0, 0, 0, 0,
2, 3, 0, 0, 0, 4, 0, 4,
5, 0, 0, 0, 0, 0, 0, 0,
@@ -1377,8 +1375,7 @@ static const uint8_t kern_left_class_mapping[] =
};
/*Map glyph_ids to kern right classes*/
static const uint8_t kern_right_class_mapping[] =
{
static const uint8_t kern_right_class_mapping[] = {
0, 1, 0, 2, 0, 0, 0, 3,
2, 0, 4, 5, 0, 6, 7, 6,
8, 0, 0, 0, 0, 0, 0, 0,
@@ -1402,8 +1399,7 @@ static const uint8_t kern_right_class_mapping[] =
};
/*Kern values between classes*/
static const int8_t kern_class_values[] =
{
static const int8_t kern_class_values[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, -4, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@@ -1583,8 +1579,7 @@ static const int8_t kern_class_values[] =
/*Collect the kern class' data in one place*/
static const lv_font_fmt_txt_kern_classes_t kern_classes =
{
static const lv_font_fmt_txt_kern_classes_t kern_classes = {
.class_pair_values = kern_class_values,
.left_class_mapping = kern_left_class_mapping,
.right_class_mapping = kern_right_class_mapping,

View File

@@ -7,7 +7,7 @@
******************************************************************************/
#ifndef LV_FONT_ROBOTO_12_SUBPX
#define LV_FONT_ROBOTO_12_SUBPX 1
#define LV_FONT_ROBOTO_12_SUBPX 1
#endif
#if LV_FONT_ROBOTO_12_SUBPX
@@ -3125,8 +3125,7 @@ static const uint16_t unicode_list_1[] = {
};
/*Collect the unicode lists and glyph_id offsets*/
static const lv_font_fmt_txt_cmap_t cmaps[] =
{
static const lv_font_fmt_txt_cmap_t cmaps[] = {
{
.range_start = 32, .range_length = 95, .glyph_id_start = 1,
.unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY
@@ -3143,8 +3142,7 @@ static const lv_font_fmt_txt_cmap_t cmaps[] =
/*Map glyph_ids to kern left classes*/
static const uint8_t kern_left_class_mapping[] =
{
static const uint8_t kern_left_class_mapping[] = {
0, 1, 0, 2, 0, 0, 0, 0,
2, 3, 0, 0, 0, 4, 0, 4,
5, 0, 0, 0, 0, 0, 0, 0,
@@ -3168,8 +3166,7 @@ static const uint8_t kern_left_class_mapping[] =
};
/*Map glyph_ids to kern right classes*/
static const uint8_t kern_right_class_mapping[] =
{
static const uint8_t kern_right_class_mapping[] = {
0, 1, 0, 2, 0, 0, 0, 3,
2, 0, 4, 5, 0, 6, 7, 6,
8, 0, 0, 0, 0, 0, 0, 0,
@@ -3193,8 +3190,7 @@ static const uint8_t kern_right_class_mapping[] =
};
/*Kern values between classes*/
static const int8_t kern_class_values[] =
{
static const int8_t kern_class_values[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, -4, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@@ -3374,8 +3370,7 @@ static const int8_t kern_class_values[] =
/*Collect the kern class' data in one place*/
static const lv_font_fmt_txt_kern_classes_t kern_classes =
{
static const lv_font_fmt_txt_kern_classes_t kern_classes = {
.class_pair_values = kern_class_values,
.left_class_mapping = kern_left_class_mapping,
.right_class_mapping = kern_right_class_mapping,

View File

@@ -7,7 +7,7 @@
******************************************************************************/
#ifndef LV_FONT_ROBOTO_16
#define LV_FONT_ROBOTO_16 1
#define LV_FONT_ROBOTO_16 1
#endif
#if LV_FONT_ROBOTO_16
@@ -1826,8 +1826,7 @@ static const uint16_t unicode_list_1[] = {
};
/*Collect the unicode lists and glyph_id offsets*/
static const lv_font_fmt_txt_cmap_t cmaps[] =
{
static const lv_font_fmt_txt_cmap_t cmaps[] = {
{
.range_start = 32, .range_length = 95, .glyph_id_start = 1,
.unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY
@@ -1844,8 +1843,7 @@ static const lv_font_fmt_txt_cmap_t cmaps[] =
/*Pair left and right glyphs for kerning*/
static const uint8_t kern_pair_glyph_ids[] =
{
static const uint8_t kern_pair_glyph_ids[] = {
1, 53,
3, 3,
3, 8,
@@ -2285,68 +2283,66 @@ static const uint8_t kern_pair_glyph_ids[] =
/* Kerning between the respective left and right glyphs
* 4.4 format which needs to scaled with `kern_scale`*/
static const int8_t kern_pair_values[] =
{
static const int8_t kern_pair_values[] = {
-5, -13, -13, -15, -6, -7, -7, -7,
-7, -2, -2, -8, -2, -7, -10, 1,
-13, -13, -15, -6, -7, -7, -7, -7,
-2, -2, -8, -2, -7, -10, 1, 3,
2, 3, -21, -21, -21, -21, -28, -15,
-15, -8, -1, -1, -1, -1, -16, -2,
-11, -9, -12, -1, -2, -1, -6, -4,
-6, 2, -3, -3, -7, -3, -4, -1,
-2, -13, -13, -3, -3, -3, -3, -5,
-3, 3, -2, -2, -2, -2, -2, -2,
-2, -2, -3, -3, -3, -29, -29, -21,
-33, 3, -4, -3, -3, -3, -3, -3,
-3, -3, -3, -3, -3, 2, -4, 2,
-3, 2, -4, 2, -3, -3, -8, -4,
-4, -4, -4, -3, -3, -3, -3, -3,
-3, -3, -3, -3, -3, -5, -8, -5,
-42, -42, 2, -8, -8, -8, -8, -34,
-7, -22, -18, -30, -5, -17, -11, -17,
2, -4, 2, -3, 2, -4, 2, -3,
-13, -13, -3, -3, -3, -3, -5, -3,
-40, -40, -17, -25, -4, -3, -1, -2,
-2, -2, -2, -2, -2, 2, 2, 2,
-5, -3, -2, -4, -10, -2, -6, -5,
-27, -29, -27, -10, -3, -3, -30, -3,
-3, -2, 2, 2, 2, 2, -14, -12,
-12, -12, -12, -14, -14, -12, -14, -12,
-9, -14, -12, -9, -7, -10, -9, -7,
-3, 3, -28, -5, -28, -9, -2, -2,
-2, -2, 2, -6, -5, -5, -5, -5,
-6, -5, -4, -3, -1, -1, 2, 2,
-15, -7, -15, -5, 2, 2, -4, -4,
-4, -4, -4, -4, -4, -3, -2, 2,
-6, -3, -3, -3, -3, 2, -3, -3,
-3, -3, -3, -3, -3, -4, -4, -4,
3, -6, -26, -6, -26, -12, -4, -4,
-12, -4, -4, -2, 2, -12, 2, 2,
2, 2, 2, -9, -8, -8, -8, -3,
-8, -5, -5, -8, -5, -8, -5, -7,
-3, -5, -2, -3, -2, -4, 2, -6,
2, -3, -3, -3, -3, -3, -3, -3,
-3, -3, -3, -2, -3, -3, -3, -2,
-2, -8, -8, -2, -2, -4, -4, -1,
-2, -1, -2, -1, -1, -2, -2, -2,
-2, 2, 2, 3, 2, -3, -3, -3,
-3, -3, 2, -13, -13, -2, -2, -2,
-2, -2, -13, -13, -13, -13, -17, -17,
-2, -3, -2, -2, -4, -4, -1, -2,
-1, -2, 2, 2, -15, -15, -5, -2,
-2, -2, 2, -2, -2, -2, 6, 2,
2, 2, -2, 2, 2, -13, -13, -2,
-2, -2, -2, 2, -2, -2, -2, -15,
-15, -2, -2, -2, -2, -2, -2, 2,
2, -13, -13, -2, -2, -2, -2, 2,
-2, -2, -2, -2, -2, -2, -2, -2,
-2, -2, -2
};
-7, -2, -2, -8, -2, -7, -10, 1,
-13, -13, -15, -6, -7, -7, -7, -7,
-2, -2, -8, -2, -7, -10, 1, 3,
2, 3, -21, -21, -21, -21, -28, -15,
-15, -8, -1, -1, -1, -1, -16, -2,
-11, -9, -12, -1, -2, -1, -6, -4,
-6, 2, -3, -3, -7, -3, -4, -1,
-2, -13, -13, -3, -3, -3, -3, -5,
-3, 3, -2, -2, -2, -2, -2, -2,
-2, -2, -3, -3, -3, -29, -29, -21,
-33, 3, -4, -3, -3, -3, -3, -3,
-3, -3, -3, -3, -3, 2, -4, 2,
-3, 2, -4, 2, -3, -3, -8, -4,
-4, -4, -4, -3, -3, -3, -3, -3,
-3, -3, -3, -3, -3, -5, -8, -5,
-42, -42, 2, -8, -8, -8, -8, -34,
-7, -22, -18, -30, -5, -17, -11, -17,
2, -4, 2, -3, 2, -4, 2, -3,
-13, -13, -3, -3, -3, -3, -5, -3,
-40, -40, -17, -25, -4, -3, -1, -2,
-2, -2, -2, -2, -2, 2, 2, 2,
-5, -3, -2, -4, -10, -2, -6, -5,
-27, -29, -27, -10, -3, -3, -30, -3,
-3, -2, 2, 2, 2, 2, -14, -12,
-12, -12, -12, -14, -14, -12, -14, -12,
-9, -14, -12, -9, -7, -10, -9, -7,
-3, 3, -28, -5, -28, -9, -2, -2,
-2, -2, 2, -6, -5, -5, -5, -5,
-6, -5, -4, -3, -1, -1, 2, 2,
-15, -7, -15, -5, 2, 2, -4, -4,
-4, -4, -4, -4, -4, -3, -2, 2,
-6, -3, -3, -3, -3, 2, -3, -3,
-3, -3, -3, -3, -3, -4, -4, -4,
3, -6, -26, -6, -26, -12, -4, -4,
-12, -4, -4, -2, 2, -12, 2, 2,
2, 2, 2, -9, -8, -8, -8, -3,
-8, -5, -5, -8, -5, -8, -5, -7,
-3, -5, -2, -3, -2, -4, 2, -6,
2, -3, -3, -3, -3, -3, -3, -3,
-3, -3, -3, -2, -3, -3, -3, -2,
-2, -8, -8, -2, -2, -4, -4, -1,
-2, -1, -2, -1, -1, -2, -2, -2,
-2, 2, 2, 3, 2, -3, -3, -3,
-3, -3, 2, -13, -13, -2, -2, -2,
-2, -2, -13, -13, -13, -13, -17, -17,
-2, -3, -2, -2, -4, -4, -1, -2,
-1, -2, 2, 2, -15, -15, -5, -2,
-2, -2, 2, -2, -2, -2, 6, 2,
2, 2, -2, 2, 2, -13, -13, -2,
-2, -2, -2, 2, -2, -2, -2, -15,
-15, -2, -2, -2, -2, -2, -2, 2,
2, -13, -13, -2, -2, -2, -2, 2,
-2, -2, -2, -2, -2, -2, -2, -2,
-2, -2, -2
};
/*Collect the kern pair's data in one place*/
static const lv_font_fmt_txt_kern_pair_t kern_pairs =
{
static const lv_font_fmt_txt_kern_pair_t kern_pairs = {
.glyph_ids = kern_pair_glyph_ids,
.values = kern_pair_values,
.pair_cnt = 435,

View File

@@ -7,7 +7,7 @@
******************************************************************************/
#ifndef LV_FONT_ROBOTO_22
#define LV_FONT_ROBOTO_22 1
#define LV_FONT_ROBOTO_22 1
#endif
#if LV_FONT_ROBOTO_22
@@ -2930,8 +2930,7 @@ static const uint16_t unicode_list_1[] = {
};
/*Collect the unicode lists and glyph_id offsets*/
static const lv_font_fmt_txt_cmap_t cmaps[] =
{
static const lv_font_fmt_txt_cmap_t cmaps[] = {
{
.range_start = 32, .range_length = 95, .glyph_id_start = 1,
.unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY
@@ -2948,8 +2947,7 @@ static const lv_font_fmt_txt_cmap_t cmaps[] =
/*Map glyph_ids to kern left classes*/
static const uint8_t kern_left_class_mapping[] =
{
static const uint8_t kern_left_class_mapping[] = {
0, 1, 0, 2, 0, 0, 0, 0,
2, 3, 0, 0, 0, 4, 0, 4,
5, 0, 0, 0, 0, 0, 0, 0,
@@ -2973,8 +2971,7 @@ static const uint8_t kern_left_class_mapping[] =
};
/*Map glyph_ids to kern right classes*/
static const uint8_t kern_right_class_mapping[] =
{
static const uint8_t kern_right_class_mapping[] = {
0, 1, 0, 2, 0, 0, 0, 3,
2, 0, 4, 5, 0, 6, 7, 6,
8, 0, 0, 0, 0, 0, 0, 0,
@@ -2998,8 +2995,7 @@ static const uint8_t kern_right_class_mapping[] =
};
/*Kern values between classes*/
static const int8_t kern_class_values[] =
{
static const int8_t kern_class_values[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, -7, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@@ -3179,8 +3175,7 @@ static const int8_t kern_class_values[] =
/*Collect the kern class' data in one place*/
static const lv_font_fmt_txt_kern_classes_t kern_classes =
{
static const lv_font_fmt_txt_kern_classes_t kern_classes = {
.class_pair_values = kern_class_values,
.left_class_mapping = kern_left_class_mapping,
.right_class_mapping = kern_right_class_mapping,

View File

@@ -7,7 +7,7 @@
******************************************************************************/
#ifndef LV_FONT_ROBOTO_28
#define LV_FONT_ROBOTO_28 1
#define LV_FONT_ROBOTO_28 1
#endif
#if LV_FONT_ROBOTO_28
@@ -4315,8 +4315,7 @@ static const uint16_t unicode_list_1[] = {
};
/*Collect the unicode lists and glyph_id offsets*/
static const lv_font_fmt_txt_cmap_t cmaps[] =
{
static const lv_font_fmt_txt_cmap_t cmaps[] = {
{
.range_start = 32, .range_length = 95, .glyph_id_start = 1,
.unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY
@@ -4333,8 +4332,7 @@ static const lv_font_fmt_txt_cmap_t cmaps[] =
/*Map glyph_ids to kern left classes*/
static const uint8_t kern_left_class_mapping[] =
{
static const uint8_t kern_left_class_mapping[] = {
0, 1, 0, 2, 0, 0, 0, 0,
2, 3, 0, 0, 0, 4, 0, 4,
5, 0, 0, 0, 0, 0, 0, 0,
@@ -4358,8 +4356,7 @@ static const uint8_t kern_left_class_mapping[] =
};
/*Map glyph_ids to kern right classes*/
static const uint8_t kern_right_class_mapping[] =
{
static const uint8_t kern_right_class_mapping[] = {
0, 1, 0, 2, 0, 0, 0, 3,
2, 0, 4, 5, 0, 6, 7, 6,
8, 0, 0, 0, 0, 0, 0, 0,
@@ -4383,8 +4380,7 @@ static const uint8_t kern_right_class_mapping[] =
};
/*Kern values between classes*/
static const int8_t kern_class_values[] =
{
static const int8_t kern_class_values[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, -9, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@@ -4564,8 +4560,7 @@ static const int8_t kern_class_values[] =
/*Collect the kern class' data in one place*/
static const lv_font_fmt_txt_kern_classes_t kern_classes =
{
static const lv_font_fmt_txt_kern_classes_t kern_classes = {
.class_pair_values = kern_class_values,
.left_class_mapping = kern_left_class_mapping,
.right_class_mapping = kern_right_class_mapping,

View File

@@ -7,7 +7,7 @@
******************************************************************************/
#ifndef LV_FONT_ROBOTO_28_COMPRESSED
#define LV_FONT_ROBOTO_28_COMPRESSED 1
#define LV_FONT_ROBOTO_28_COMPRESSED 1
#endif
#if LV_FONT_ROBOTO_28_COMPRESSED
@@ -2157,8 +2157,7 @@ static const uint16_t unicode_list_1[] = {
};
/*Collect the unicode lists and glyph_id offsets*/
static const lv_font_fmt_txt_cmap_t cmaps[] =
{
static const lv_font_fmt_txt_cmap_t cmaps[] = {
{
.range_start = 32, .range_length = 95, .glyph_id_start = 1,
.unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY
@@ -2175,8 +2174,7 @@ static const lv_font_fmt_txt_cmap_t cmaps[] =
/*Map glyph_ids to kern left classes*/
static const uint8_t kern_left_class_mapping[] =
{
static const uint8_t kern_left_class_mapping[] = {
0, 1, 0, 2, 0, 0, 0, 0,
2, 3, 0, 0, 0, 4, 0, 4,
5, 0, 0, 0, 0, 0, 0, 0,
@@ -2200,8 +2198,7 @@ static const uint8_t kern_left_class_mapping[] =
};
/*Map glyph_ids to kern right classes*/
static const uint8_t kern_right_class_mapping[] =
{
static const uint8_t kern_right_class_mapping[] = {
0, 1, 0, 2, 0, 0, 0, 3,
2, 0, 4, 5, 0, 6, 7, 6,
8, 0, 0, 0, 0, 0, 0, 0,
@@ -2225,8 +2222,7 @@ static const uint8_t kern_right_class_mapping[] =
};
/*Kern values between classes*/
static const int8_t kern_class_values[] =
{
static const int8_t kern_class_values[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, -9, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@@ -2406,8 +2402,7 @@ static const int8_t kern_class_values[] =
/*Collect the kern class' data in one place*/
static const lv_font_fmt_txt_kern_classes_t kern_classes =
{
static const lv_font_fmt_txt_kern_classes_t kern_classes = {
.class_pair_values = kern_class_values,
.left_class_mapping = kern_left_class_mapping,
.right_class_mapping = kern_right_class_mapping,

View File

@@ -7,7 +7,7 @@
******************************************************************************/
#ifndef LV_FONT_UNSCII_8
#define LV_FONT_UNSCII_8 1
#define LV_FONT_UNSCII_8 1
#endif
#if LV_FONT_UNSCII_8
@@ -418,8 +418,7 @@ static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = {
/*Collect the unicode lists and glyph_id offsets*/
static const lv_font_fmt_txt_cmap_t cmaps[] =
{
static const lv_font_fmt_txt_cmap_t cmaps[] = {
{
.range_start = 32, .range_length = 96, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY,
.glyph_id_start = 1, .unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0

View File

@@ -20,7 +20,7 @@
#include "../lv_themes/lv_theme.h"
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/*********************
@@ -170,8 +170,7 @@ void lv_disp_drv_update(lv_disp_t * disp, lv_disp_drv_t * new_drv)
memcpy(&disp->driver, new_drv, sizeof(lv_disp_drv_t));
lv_obj_t * scr;
LV_LL_READ(disp->scr_ll, scr)
{
LV_LL_READ(disp->scr_ll, scr) {
lv_obj_set_size(scr, lv_disp_get_hor_res(disp), lv_disp_get_ver_res(disp));
}
}
@@ -352,7 +351,8 @@ bool lv_disp_is_true_double_buf(lv_disp_t * disp)
if(lv_disp_is_double_buf(disp) && disp->driver.buffer->size == scr_size) {
return true;
} else {
}
else {
return false;
}
}

View File

@@ -44,8 +44,7 @@ struct _disp_drv_t;
/**
* Structure for holding display buffer information.
*/
typedef struct
{
typedef struct {
void * buf1; /**< First display buffer. */
void * buf2; /**< Second display buffer. */
@@ -59,8 +58,7 @@ typedef struct
/**
* Display Driver structure to be registered by HAL
*/
typedef struct _disp_drv_t
{
typedef struct _disp_drv_t {
lv_coord_t hor_res; /**< Horizontal resolution. */
lv_coord_t ver_res; /**< Vertical resolution. */
@@ -124,8 +122,7 @@ struct _lv_obj_t;
* Display structure.
* ::lv_disp_drv_t is the first member of the structure.
*/
typedef struct _disp_t
{
typedef struct _disp_t {
/**< Driver to the display*/
lv_disp_drv_t driver;

View File

@@ -16,7 +16,7 @@
#include "lv_hal_disp.h"
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/*********************
@@ -148,7 +148,8 @@ bool lv_indev_read(lv_indev_t * indev, lv_indev_data_t * data)
LV_LOG_TRACE("idnev read started");
cont = indev->driver.read_cb(&indev->driver, data);
LV_LOG_TRACE("idnev read finished");
} else {
}
else {
LV_LOG_WARN("indev function registered");
}

View File

@@ -61,16 +61,15 @@ enum {
typedef uint8_t lv_drag_dir_t;
enum {
LV_GESTURE_DIR_TOP, /**< Gesture dir up. */
LV_GESTURE_DIR_BOTTOM, /**< Gesture dir down. */
LV_GESTURE_DIR_LEFT, /**< Gesture dir left. */
LV_GESTURE_DIR_RIGHT, /**< Gesture dir right. */
LV_GESTURE_DIR_TOP, /**< Gesture dir up. */
LV_GESTURE_DIR_BOTTOM, /**< Gesture dir down. */
LV_GESTURE_DIR_LEFT, /**< Gesture dir left. */
LV_GESTURE_DIR_RIGHT, /**< Gesture dir right. */
};
typedef uint8_t lv_gesture_dir_t;
/** Data structure passed to an input driver to fill */
typedef struct
{
typedef struct {
lv_point_t point; /**< For LV_INDEV_TYPE_POINTER the currently pressed point*/
uint32_t key; /**< For LV_INDEV_TYPE_KEYPAD the currently pressed key*/
uint32_t btn_id; /**< For LV_INDEV_TYPE_BUTTON the currently pressed button*/
@@ -81,8 +80,7 @@ typedef struct
/** Initialized by the user and registered by 'lv_indev_add()'*/
typedef struct _lv_indev_drv_t
{
typedef struct _lv_indev_drv_t {
/**< Input device type*/
lv_indev_type_t type;
@@ -128,13 +126,11 @@ typedef struct _lv_indev_drv_t
/** Run time data of input devices
* Internally used by the library, you should not need to touch it.
*/
typedef struct _lv_indev_proc_t
{
typedef struct _lv_indev_proc_t {
lv_indev_state_t state; /**< Current state of the input device. */
union
{
struct
{ /*Pointer and button data*/
union {
struct {
/*Pointer and button data*/
lv_point_t act_point; /**< Current point of input device. */
lv_point_t last_point; /**< Last point of input device. */
lv_point_t vect; /**< Difference between `act_point` and `last_point`. */
@@ -145,16 +141,16 @@ typedef struct _lv_indev_proc_t
other post-release event)*/
struct _lv_obj_t * last_pressed; /*The lastly pressed object*/
lv_gesture_dir_t gesture_dir;
lv_point_t gesture_sum; /*Count the gesture pixels to check LV_INDEV_DEF_GESTURE_LIMIT*/
lv_gesture_dir_t gesture_dir;
lv_point_t gesture_sum; /*Count the gesture pixels to check LV_INDEV_DEF_GESTURE_LIMIT*/
/*Flags*/
uint8_t drag_limit_out : 1;
uint8_t drag_in_prog : 1;
lv_drag_dir_t drag_dir : 3;
uint8_t gesture_sent : 1;
uint8_t gesture_sent : 1;
} pointer;
struct
{ /*Keypad data*/
struct {
/*Keypad data*/
lv_indev_state_t last_state;
uint32_t last_key;
} keypad;
@@ -175,8 +171,7 @@ struct _lv_group_t;
/** The main input device descriptor with driver, runtime data ('proc') and some additional
* information*/
typedef struct _lv_indev_t
{
typedef struct _lv_indev_t {
lv_indev_drv_t driver;
lv_indev_proc_t proc;
struct _lv_obj_t * cursor; /**< Cursor for LV_INPUT_TYPE_POINTER*/

View File

@@ -10,7 +10,7 @@
#include <stddef.h>
#if LV_TICK_CUSTOM == 1
#include LV_TICK_CUSTOM_INCLUDE
#include LV_TICK_CUSTOM_INCLUDE
#endif
/*********************
@@ -81,7 +81,8 @@ uint32_t lv_tick_elaps(uint32_t prev_tick)
/*If there is no overflow in sys_time simple subtract*/
if(act_time >= prev_tick) {
prev_tick = act_time - prev_tick;
} else {
}
else {
prev_tick = UINT32_MAX - prev_tick + 1;
prev_tick += act_time;
}

View File

@@ -18,7 +18,7 @@
#include "lv_gc.h"
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/*********************
@@ -62,8 +62,8 @@ 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_anim_task = lv_task_create(anim_task, LV_DISP_DEF_REFR_PERIOD, LV_ANIM_TASK_PRIO, NULL);
anim_mark_list_change(); /*Turn off the animation task*/
anim_list_changed = false; /*The list has not actaully changed*/
anim_mark_list_change(); /*Turn off the animation task*/
anim_list_changed = false; /*The list has not actaully changed*/
}
/**
@@ -117,7 +117,7 @@ void lv_anim_start(lv_anim_t * a)
/* Creating an animation changed the linked list.
* It's important if it happens in a ready callback. (see `anim_task`)*/
anim_mark_list_change();
anim_mark_list_change();
LV_LOG_TRACE("animation created")
}
@@ -195,7 +195,7 @@ uint16_t lv_anim_speed_to_time(uint16_t speed, lv_anim_value_t start, lv_anim_va
*/
void lv_anim_refr_now(void)
{
anim_task(NULL);
anim_task(NULL);
}
/**
@@ -209,7 +209,8 @@ lv_anim_value_t lv_anim_path_linear(const lv_anim_t * a)
uint32_t step;
if(a->time == a->act_time) {
step = LV_ANIM_RESOLUTION; /*Use the last value if the time fully elapsed*/
} else {
}
else {
step = ((int32_t)a->act_time * LV_ANIM_RESOLUTION) / a->time;
}
@@ -344,24 +345,28 @@ lv_anim_value_t lv_anim_path_bounce(const lv_anim_t * a)
if(t < 408) {
/*Go down*/
t = (t * 2500) >> 10; /*[0..1024] range*/
} else if(t >= 408 && t < 614) {
}
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) {
}
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) {
}
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) {
}
else if(t >= 921 && t <= 1024) {
/*Fall back*/
t -= 921;
t = t * 10; /*to [0..1024] range*/
@@ -407,8 +412,7 @@ static void anim_task(lv_task_t * param)
(void)param;
lv_anim_t * a;
LV_LL_READ(LV_GC_ROOT(_lv_anim_ll), a)
{
LV_LL_READ(LV_GC_ROOT(_lv_anim_ll), a) {
a->has_run = 0;
}
@@ -483,8 +487,8 @@ static bool anim_ready_handler(lv_anim_t * a)
memcpy(&a_tmp, a, sizeof(lv_anim_t));
lv_ll_remove(&LV_GC_ROOT(_lv_anim_ll), a);
lv_mem_free(a);
/*Flag that the list has changed */
anim_mark_list_change();
/*Flag that the list has changed */
anim_mark_list_change();
/* Call the callback function at the end*/
if(a_tmp.ready_cb != NULL) a_tmp.ready_cb(&a_tmp);
@@ -513,10 +517,10 @@ static bool anim_ready_handler(lv_anim_t * a)
}
static void anim_mark_list_change(void)
{
anim_list_changed = true;
if(lv_ll_get_head(&LV_GC_ROOT(_lv_anim_ll)) == NULL)
lv_task_set_prio(_lv_anim_task, LV_TASK_PRIO_OFF);
else
lv_task_set_prio(_lv_anim_task, LV_ANIM_TASK_PRIO);
anim_list_changed = true;
if(lv_ll_get_head(&LV_GC_ROOT(_lv_anim_ll)) == NULL)
lv_task_set_prio(_lv_anim_task, LV_TASK_PRIO_OFF);
else
lv_task_set_prio(_lv_anim_task, LV_ANIM_TASK_PRIO);
}
#endif

View File

@@ -66,8 +66,7 @@ typedef void (*lv_anim_ready_cb_t)(struct _lv_anim_t *);
typedef void (*lv_anim_start_cb_t)(struct _lv_anim_t *);
/** Describes an animation*/
typedef struct _lv_anim_t
{
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*/
@@ -81,7 +80,7 @@ typedef struct _lv_anim_t
uint32_t playback_time; /**< Duration of playback animation*/
uint32_t repeat_delay; /**< Wait before repeat*/
uint16_t repeat_cnt; /**< Repeat count for the animation*/
uint8_t early_apply :1; /**< 1: Apply start value immediately even is there is `delay` */
uint8_t early_apply : 1; /**< 1: Apply start value immediately even is there is `delay` */
#if LV_USE_USER_DATA
lv_anim_user_data_t user_data; /**< Custom user data*/
#endif
@@ -268,7 +267,7 @@ void lv_anim_start(lv_anim_t * a);
*/
static inline int32_t lv_anim_get_delay(lv_anim_t * a)
{
return -a->act_time;
return -a->act_time;
}
/**

View File

@@ -215,7 +215,8 @@ 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 {
}
else {
return false;
}
}
@@ -284,108 +285,108 @@ void lv_area_align(const lv_area_t * base, const lv_area_t * to_align, lv_align_
{
switch(align) {
case LV_ALIGN_CENTER:
res->x = lv_area_get_width(base) / 2 - lv_area_get_width(to_align) / 2;
res->y = lv_area_get_height(base) / 2 - lv_area_get_height(to_align) / 2;
break;
case LV_ALIGN_CENTER:
res->x = lv_area_get_width(base) / 2 - lv_area_get_width(to_align) / 2;
res->y = lv_area_get_height(base) / 2 - lv_area_get_height(to_align) / 2;
break;
case LV_ALIGN_IN_TOP_LEFT:
res->x = 0;
res->y = 0;
break;
case LV_ALIGN_IN_TOP_MID:
res->x = lv_area_get_width(base) / 2 - lv_area_get_width(to_align) / 2;
res->y = 0;
break;
case LV_ALIGN_IN_TOP_LEFT:
res->x = 0;
res->y = 0;
break;
case LV_ALIGN_IN_TOP_MID:
res->x = lv_area_get_width(base) / 2 - lv_area_get_width(to_align) / 2;
res->y = 0;
break;
case LV_ALIGN_IN_TOP_RIGHT:
res->x = lv_area_get_width(base) - lv_area_get_width(to_align);
res->y = 0;
break;
case LV_ALIGN_IN_TOP_RIGHT:
res->x = lv_area_get_width(base) - lv_area_get_width(to_align);
res->y = 0;
break;
case LV_ALIGN_IN_BOTTOM_LEFT:
res->x = 0;
res->y = lv_area_get_height(base) - lv_area_get_height(to_align);
break;
case LV_ALIGN_IN_BOTTOM_MID:
res->x = lv_area_get_width(base) / 2 - lv_area_get_width(to_align) / 2;
res->y = lv_area_get_height(base) - lv_area_get_height(to_align);
break;
case LV_ALIGN_IN_BOTTOM_LEFT:
res->x = 0;
res->y = lv_area_get_height(base) - lv_area_get_height(to_align);
break;
case LV_ALIGN_IN_BOTTOM_MID:
res->x = lv_area_get_width(base) / 2 - lv_area_get_width(to_align) / 2;
res->y = lv_area_get_height(base) - lv_area_get_height(to_align);
break;
case LV_ALIGN_IN_BOTTOM_RIGHT:
res->x = lv_area_get_width(base) - lv_area_get_width(to_align);
res->y = lv_area_get_height(base) - lv_area_get_height(to_align);
break;
case LV_ALIGN_IN_BOTTOM_RIGHT:
res->x = lv_area_get_width(base) - lv_area_get_width(to_align);
res->y = lv_area_get_height(base) - lv_area_get_height(to_align);
break;
case LV_ALIGN_IN_LEFT_MID:
res->x = 0;
res->y = lv_area_get_height(base) / 2 - lv_area_get_height(to_align) / 2;
break;
case LV_ALIGN_IN_LEFT_MID:
res->x = 0;
res->y = lv_area_get_height(base) / 2 - lv_area_get_height(to_align) / 2;
break;
case LV_ALIGN_IN_RIGHT_MID:
res->x = lv_area_get_width(base) - lv_area_get_width(to_align);
res->y = lv_area_get_height(base) / 2 - lv_area_get_height(to_align) / 2;
break;
case LV_ALIGN_IN_RIGHT_MID:
res->x = lv_area_get_width(base) - lv_area_get_width(to_align);
res->y = lv_area_get_height(base) / 2 - lv_area_get_height(to_align) / 2;
break;
case LV_ALIGN_OUT_TOP_LEFT:
res->x = 0;
res->y = -lv_area_get_height(to_align);
break;
case LV_ALIGN_OUT_TOP_LEFT:
res->x = 0;
res->y = -lv_area_get_height(to_align);
break;
case LV_ALIGN_OUT_TOP_MID:
res->x = lv_area_get_width(base) / 2 - lv_area_get_width(to_align) / 2;
res->y = -lv_area_get_height(to_align);
break;
case LV_ALIGN_OUT_TOP_MID:
res->x = lv_area_get_width(base) / 2 - lv_area_get_width(to_align) / 2;
res->y = -lv_area_get_height(to_align);
break;
case LV_ALIGN_OUT_TOP_RIGHT:
res->x = lv_area_get_width(base) - lv_area_get_width(to_align);
res->y = -lv_area_get_height(to_align);
break;
case LV_ALIGN_OUT_TOP_RIGHT:
res->x = lv_area_get_width(base) - lv_area_get_width(to_align);
res->y = -lv_area_get_height(to_align);
break;
case LV_ALIGN_OUT_BOTTOM_LEFT:
res->x = 0;
res->y = lv_area_get_height(base);
break;
case LV_ALIGN_OUT_BOTTOM_LEFT:
res->x = 0;
res->y = lv_area_get_height(base);
break;
case LV_ALIGN_OUT_BOTTOM_MID:
res->x = lv_area_get_width(base) / 2 - lv_area_get_width(to_align) / 2;
res->y = lv_area_get_height(base);
break;
case LV_ALIGN_OUT_BOTTOM_MID:
res->x = lv_area_get_width(base) / 2 - lv_area_get_width(to_align) / 2;
res->y = lv_area_get_height(base);
break;
case LV_ALIGN_OUT_BOTTOM_RIGHT:
res->x = lv_area_get_width(base) - lv_area_get_width(to_align);
res->y = lv_area_get_height(base);
break;
case LV_ALIGN_OUT_BOTTOM_RIGHT:
res->x = lv_area_get_width(base) - lv_area_get_width(to_align);
res->y = lv_area_get_height(base);
break;
case LV_ALIGN_OUT_LEFT_TOP:
res->x = -lv_area_get_width(to_align);
res->y = 0;
break;
case LV_ALIGN_OUT_LEFT_TOP:
res->x = -lv_area_get_width(to_align);
res->y = 0;
break;
case LV_ALIGN_OUT_LEFT_MID:
res->x = -lv_area_get_width(to_align);
res->y = lv_area_get_height(base) / 2 - lv_area_get_height(to_align) / 2;
break;
case LV_ALIGN_OUT_LEFT_MID:
res->x = -lv_area_get_width(to_align);
res->y = lv_area_get_height(base) / 2 - lv_area_get_height(to_align) / 2;
break;
case LV_ALIGN_OUT_LEFT_BOTTOM:
res->x = -lv_area_get_width(to_align);
res->y = lv_area_get_height(base) - lv_area_get_height(to_align);
break;
case LV_ALIGN_OUT_LEFT_BOTTOM:
res->x = -lv_area_get_width(to_align);
res->y = lv_area_get_height(base) - lv_area_get_height(to_align);
break;
case LV_ALIGN_OUT_RIGHT_TOP:
res->x = lv_area_get_width(base);
res->y = 0;
break;
case LV_ALIGN_OUT_RIGHT_TOP:
res->x = lv_area_get_width(base);
res->y = 0;
break;
case LV_ALIGN_OUT_RIGHT_MID:
res->x = lv_area_get_width(base);
res->y = lv_area_get_height(base) / 2 - lv_area_get_height(to_align) / 2;
break;
case LV_ALIGN_OUT_RIGHT_MID:
res->x = lv_area_get_width(base);
res->y = lv_area_get_height(base) / 2 - lv_area_get_height(to_align) / 2;
break;
case LV_ALIGN_OUT_RIGHT_BOTTOM:
res->x = lv_area_get_width(base);
res->y = lv_area_get_height(base) - lv_area_get_height(to_align);
break;
case LV_ALIGN_OUT_RIGHT_BOTTOM:
res->x = lv_area_get_width(base);
res->y = lv_area_get_height(base) - lv_area_get_height(to_align);
break;
}
res->x += base->x1;
@@ -408,8 +409,8 @@ static bool lv_point_within_circle(const lv_area_t * area, const lv_point_t * p)
lv_coord_t px = p->x - cx;
lv_coord_t py = p->y - cy;
int32_t r_sqrd = r*r;
int32_t dist = (px*px) + (py*py);
int32_t r_sqrd = r * r;
int32_t dist = (px * px) + (py * py);
if(dist <= r_sqrd)
return true;

View File

@@ -35,15 +35,13 @@ LV_EXPORT_CONST_INT(LV_COORD_MIN);
/**
* Represents a point on the screen.
*/
typedef struct
{
typedef struct {
lv_coord_t x;
lv_coord_t y;
} lv_point_t;
/** Represents an area of the screen. */
typedef struct
{
typedef struct {
lv_coord_t x1;
lv_coord_t y1;
lv_coord_t x2;

View File

@@ -21,7 +21,7 @@
* STATIC PROTOTYPES
**********************/
static void lv_async_task_cb(lv_task_t *task);
static void lv_async_task_cb(lv_task_t * task);
/**********************
* STATIC VARIABLES
@@ -38,14 +38,14 @@ static void lv_async_task_cb(lv_task_t *task);
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));
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);
lv_task_t * task = lv_task_create(lv_async_task_cb, 0, LV_TASK_PRIO_HIGHEST, info);
if(task == NULL) {
lv_mem_free(info);
@@ -65,9 +65,9 @@ lv_res_t lv_async_call(lv_async_cb_t async_xcb, void * user_data)
* STATIC FUNCTIONS
**********************/
static void lv_async_task_cb(lv_task_t *task)
static void lv_async_task_cb(lv_task_t * task)
{
lv_async_info_t *info = (lv_async_info_t *)task->user_data;
lv_async_info_t * info = (lv_async_info_t *)task->user_data;
info->cb(info->user_data);

View File

@@ -32,7 +32,7 @@ typedef void (*lv_async_cb_t)(void *);
typedef struct _lv_async_info_t {
lv_async_cb_t cb;
void *user_data;
void * user_data;
} lv_async_info_t;
struct _lv_obj_t;

View File

@@ -26,19 +26,21 @@
/**********************
* TYPEDEFS
**********************/
typedef struct
{
typedef struct {
uint32_t bracklet_pos;
lv_bidi_dir_t dir;
}bracket_stack_t;
} 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 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 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);
@@ -151,7 +153,7 @@ bool lv_bidi_letter_is_weak(uint32_t letter)
*/
bool lv_bidi_letter_is_rtl(uint32_t letter)
{
if(letter >= 0x5d0 && letter <= 0x5ea) return true;
if(letter >= 0x5d0 && letter <= 0x5ea) return true;
if(letter == 0x202E) return true; /*Unicode of LV_BIDI_RLO*/
return false;
@@ -185,23 +187,24 @@ bool lv_bidi_letter_is_neutral(uint32_t letter)
* @param is_rtl tell the the char at `viasual_pos` is RTL or LTR context
* @return the logical character position
*/
uint16_t lv_bidi_get_logical_pos(const char * str_in, char **bidi_txt, uint32_t len, lv_bidi_dir_t base_dir, uint32_t visual_pos, bool *is_rtl)
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);
char * buf = lv_mem_buf_get(len + 1);
if(buf == NULL) return (uint16_t) -1;
uint16_t *pos_conv_buf = lv_mem_buf_get(pos_conv_len * sizeof(uint16_t));
uint16_t * pos_conv_buf = lv_mem_buf_get(pos_conv_len * sizeof(uint16_t));
if(pos_conv_buf == NULL) {
lv_mem_buf_release(buf);
return (uint16_t) -1;
}
if (bidi_txt) *bidi_txt = buf;
if(bidi_txt) *bidi_txt = buf;
lv_bidi_process_paragraph(str_in, bidi_txt? *bidi_txt: NULL, len, base_dir, pos_conv_buf, pos_conv_len);
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]);
if(is_rtl) *is_rtl = IS_RTL_POS(pos_conv_buf[visual_pos]);
if(bidi_txt == NULL) lv_mem_buf_release(buf);
uint16_t res = GET_POS(pos_conv_buf[visual_pos]);
@@ -221,26 +224,27 @@ uint16_t lv_bidi_get_logical_pos(const char * str_in, char **bidi_txt, uint32_t
* @param is_rtl tell the the char at `logical_pos` is RTL or LTR context
* @return the visual character position
*/
uint16_t lv_bidi_get_visual_pos(const char * str_in, char **bidi_txt, uint16_t len, lv_bidi_dir_t base_dir, uint32_t logical_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)
{
uint32_t pos_conv_len = get_txt_len(str_in, len);
char * buf = lv_mem_buf_get(len + 1);
if(buf == NULL) return (uint16_t) -1;
uint16_t *pos_conv_buf = lv_mem_buf_get(pos_conv_len * sizeof(uint16_t));
uint16_t * pos_conv_buf = lv_mem_buf_get(pos_conv_len * sizeof(uint16_t));
if(pos_conv_buf == NULL) {
lv_mem_buf_release(buf);
return (uint16_t) -1;
}
if (bidi_txt) *bidi_txt = buf;
if(bidi_txt) *bidi_txt = buf;
lv_bidi_process_paragraph(str_in, bidi_txt ? *bidi_txt: NULL, len, base_dir, pos_conv_buf, pos_conv_len);
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){
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]);
if(is_rtl) *is_rtl = IS_RTL_POS(pos_conv_buf[i]);
lv_mem_buf_release(pos_conv_buf);
if(bidi_txt == NULL) lv_mem_buf_release(buf);
@@ -262,7 +266,8 @@ uint16_t lv_bidi_get_visual_pos(const char * str_in, char **bidi_txt, uint16_t l
* Can be `NULL` is unused
* @param pos_conv_len length of `pos_conv_out` in element count
*/
void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len, lv_bidi_dir_t base_dir, uint16_t *pos_conv_out, uint16_t pos_conv_len)
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;
@@ -282,7 +287,7 @@ void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len
pos_conv_wr = 0;
}
if (str_out) str_out[len] = '\0';
if(str_out) str_out[len] = '\0';
lv_bidi_dir_t dir = base_dir;
@@ -299,24 +304,26 @@ void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len
}
if(rd && str_in[rd] != '\0') {
lv_txt_encoded_prev(str_in, &rd);
pos_conv_rd--;
lv_txt_encoded_prev(str_in, &rd);
pos_conv_rd--;
}
if(rd) {
if(base_dir == LV_BIDI_DIR_LTR) {
if (str_out) {
if(str_out) {
memcpy(&str_out[wr], str_in, rd);
wr += rd;
}
if (pos_conv_out) {
if(pos_conv_out) {
fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_rd, 0);
pos_conv_wr += pos_conv_rd;
}
} else {
}
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);
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);
}
}
@@ -327,21 +334,24 @@ void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t 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);
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);
}
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;
@@ -386,13 +396,14 @@ static uint32_t get_txt_len(const char * txt, uint32_t max_len)
static void fill_pos_conv(uint16_t * out, uint16_t len, uint16_t index)
{
uint16_t i;
for (i = 0; i < len; i++) {
for(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)
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;
@@ -473,7 +484,8 @@ static lv_bidi_dir_t get_next_run(const char * txt, lv_bidi_dir_t base_dir, uint
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)
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;
@@ -498,7 +510,7 @@ static void rtl_reverse(char * dest, const char * src, uint32_t len, uint16_t *p
/*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 != '%') {
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;
@@ -511,8 +523,9 @@ static void rtl_reverse(char * dest, const char * src, uint32_t len, uint16_t *p
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);
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;
}
@@ -523,15 +536,15 @@ static void rtl_reverse(char * dest, const char * src, uint32_t len, uint16_t *p
/*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);
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);
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++;
}
@@ -554,7 +567,8 @@ static uint32_t char_change_to_pair(uint32_t letter)
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)
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;
@@ -570,7 +584,8 @@ static lv_bidi_dir_t bracket_process(const char * txt, uint32_t next_pos, uint32
if(letter_next == bracket_right[i]) {
/*Closing bracket found*/
break;
} else {
}
else {
/*Save the dir*/
lv_bidi_dir_t letter_dir = lv_bidi_get_letter_dir(letter_next);
if(letter_dir == base_dir) {
@@ -619,7 +634,8 @@ static lv_bidi_dir_t bracket_process(const char * txt, uint32_t next_pos, uint32
br_stack_p++;
return bracket_dir;
} else if(br_stack_p > 0) {
}
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;

View File

@@ -29,8 +29,7 @@ extern "C" {
/**********************
* TYPEDEFS
**********************/
enum
{
enum {
/*The first 4 values are stored in `lv_obj_t` on 2 bits*/
LV_BIDI_DIR_LTR = 0x00,
LV_BIDI_DIR_RTL = 0x01,
@@ -104,7 +103,8 @@ bool lv_bidi_letter_is_neutral(uint32_t letter);
* @param is_rtl tell the the char at `viasual_pos` is RTL or LTR context
* @return the logical character position
*/
uint16_t lv_bidi_get_logical_pos(const char * str_in, char **bidi_txt, uint32_t len, lv_bidi_dir_t base_dir, uint32_t visual_pos, bool *is_rtl);
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);
/**
* Get the visual position of a character in a line
@@ -118,7 +118,8 @@ uint16_t lv_bidi_get_logical_pos(const char * str_in, char **bidi_txt, uint32_t
* @param is_rtl tell the the char at `logical_pos` is RTL or LTR context
* @return the visual character position
*/
uint16_t lv_bidi_get_visual_pos(const char * str_in, char **bidi_txt, uint16_t len, lv_bidi_dir_t base_dir, uint32_t logical_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);
/**
* Bidi process a paragraph of text
@@ -130,7 +131,8 @@ uint16_t lv_bidi_get_visual_pos(const char * str_in, char **bidi_txt, uint16_t l
* Can be `NULL` is unused
* @param pos_conv_len length of `pos_conv_out` in element count
*/
void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len, lv_bidi_dir_t base_dir, uint16_t *pos_conv_out, uint16_t pos_conv_len);
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);
/**
* Get the next paragraph from a text

View File

@@ -68,7 +68,8 @@ void lv_circ_next(lv_point_t * c, lv_coord_t * tmp)
if(*tmp <= 0) {
(*tmp) += 2 * c->y + 1; /*Change in decision criterion for y -> y+1*/
} else {
}
else {
c->x--;
(*tmp) += 2 * (c->y - c->x) + 1; /*Change for y -> y+1, x -> x-1*/
}

View File

@@ -138,7 +138,7 @@ lv_color_hsv_t lv_color_rgb_to_hsv(uint8_t r8, uint8_t g8, uint8_t b8)
hsv.v = (100 * rgbMax) >> 10;
int32_t delta = rgbMax - rgbMin;
if (LV_MATH_ABS(delta) < 3) {
if(LV_MATH_ABS(delta) < 3) {
hsv.h = 0;
hsv.s = 0;
return hsv;
@@ -163,7 +163,7 @@ lv_color_hsv_t lv_color_rgb_to_hsv(uint8_t r8, uint8_t g8, uint8_t b8)
h = 0;
h *= 60;
h >>= 10;
if (h < 0) h += 360;
if(h < 0) h += 360;
hsv.h = h;
return hsv;

View File

@@ -194,10 +194,8 @@ enum {
* TYPEDEFS
**********************/
typedef union
{
struct
{
typedef union {
struct {
uint8_t blue : 1;
uint8_t green : 1;
uint8_t red : 1;
@@ -205,10 +203,8 @@ typedef union
uint8_t full;
} lv_color1_t;
typedef union
{
struct
{
typedef union {
struct {
uint8_t blue : 2;
uint8_t green : 3;
uint8_t red : 3;
@@ -216,10 +212,8 @@ typedef union
uint8_t full;
} lv_color8_t;
typedef union
{
struct
{
typedef union {
struct {
#if LV_COLOR_16_SWAP == 0
uint16_t blue : 5;
uint16_t green : 6;
@@ -234,10 +228,8 @@ typedef union
uint16_t full;
} lv_color16_t;
typedef union
{
struct
{
typedef union {
struct {
uint8_t blue;
uint8_t green;
uint8_t red;
@@ -264,8 +256,7 @@ typedef lv_color32_t lv_color_t;
typedef uint8_t lv_opa_t;
typedef struct
{
typedef struct {
uint16_t h;
uint8_t s;
uint8_t v;
@@ -296,19 +287,22 @@ static inline uint8_t lv_color_to1(lv_color_t color)
#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 {
}
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 {
}
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 {
}
else {
return 0;
}
#endif
@@ -415,9 +409,9 @@ static inline uint32_t lv_color_to32(lv_color_t color)
* 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_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
@@ -459,7 +453,8 @@ static inline lv_color_t lv_color_mix(lv_color_t c1, lv_color_t c2, uint8_t mix)
* @param res_color the result color
* @param res_opa the result opacity
*/
static inline void lv_color_mix_with_alpha(lv_color_t bg_color, lv_opa_t bg_opa, lv_color_t fg_color, lv_opa_t fg_opa, lv_color_t * res_color, lv_opa_t * res_opa)
static inline void lv_color_mix_with_alpha(lv_color_t bg_color, lv_opa_t bg_opa, lv_color_t fg_color, lv_opa_t fg_opa,
lv_color_t * res_color, lv_opa_t * res_opa)
{
/* Pick the foreground if it's fully opaque or the Background is fully transparent*/
if(fg_opa > LV_OPA_MAX || bg_opa <= LV_OPA_MIN) {
@@ -487,7 +482,7 @@ static inline void lv_color_mix_with_alpha(lv_color_t bg_color, lv_opa_t bg_opa,
static lv_opa_t res_opa_saved = 0;
if(fg_opa != fg_opa_save || bg_opa != bg_opa_save || fg_color.full != fg_color_save.full ||
bg_color.full != bg_color_save.full) {
bg_color.full != bg_color_save.full) {
fg_opa_save = fg_opa;
bg_opa_save = bg_opa;
fg_color_save.full = fg_color.full;

View File

@@ -15,7 +15,7 @@
#include "lv_gc.h"
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/*********************
@@ -27,7 +27,7 @@
* free function, otherwise compilation would fail.
*/
#ifdef free
#undef free
#undef free
#endif
/**********************
@@ -422,7 +422,8 @@ lv_fs_res_t lv_fs_dir_close(lv_fs_dir_t * rddir_p)
if(rddir_p->drv->dir_close_cb == NULL) {
res = LV_FS_RES_NOT_IMP;
} else {
}
else {
res = rddir_p->drv->dir_close_cb(rddir_p->drv, rddir_p->dir_d);
}
@@ -453,7 +454,8 @@ lv_fs_res_t lv_fs_free_space(char letter, uint32_t * total_p, uint32_t * free_p)
if(drv->free_space_cb == NULL) {
res = LV_FS_RES_NOT_IMP;
} else {
}
else {
uint32_t total_tmp = 0;
uint32_t free_tmp = 0;
res = drv->free_space_cb(drv, &total_tmp, &free_tmp);
@@ -501,8 +503,7 @@ 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)
{
LV_LL_READ(LV_GC_ROOT(_lv_drv_ll), drv) {
if(drv->letter == letter) {
return drv;
}
@@ -520,8 +521,7 @@ 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)
{
LV_LL_READ(LV_GC_ROOT(_lv_drv_ll), drv) {
buf[i] = drv->letter;
i++;
}
@@ -542,7 +542,8 @@ const char * lv_fs_get_ext(const char * fn)
for(i = strlen(fn); i > 0; i--) {
if(fn[i] == '.') {
return &fn[i + 1];
} else if(fn[i] == '/' || fn[i] == '\\') {
}
else if(fn[i] == '/' || fn[i] == '\\') {
return ""; /*No extension if a '\' or '/' found*/
}
}
@@ -630,7 +631,8 @@ static const char * lv_fs_get_real_path(const char * path)
while(*path != '\0') {
if(*path == ':' || *path == '\\' || *path == '/') {
path++;
} else {
}
else {
break;
}
}

View File

@@ -60,8 +60,7 @@ enum {
};
typedef uint8_t lv_fs_mode_t;
typedef struct _lv_fs_drv_t
{
typedef struct _lv_fs_drv_t {
char letter;
uint16_t file_size;
uint16_t rddir_size;
@@ -88,14 +87,12 @@ typedef struct _lv_fs_drv_t
#endif
} lv_fs_drv_t;
typedef struct
{
typedef struct {
void * file_d;
lv_fs_drv_t * drv;
} lv_fs_file_t;
typedef struct
{
typedef struct {
void * dir_d;
lv_fs_drv_t * drv;
} lv_fs_dir_t;

View File

@@ -11,7 +11,7 @@
#include "string.h"
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/*********************
@@ -31,7 +31,7 @@
**********************/
#if(!defined(LV_ENABLE_GC)) || LV_ENABLE_GC == 0
LV_ROOTS
LV_ROOTS
#endif /* LV_ENABLE_GC */
/**********************

View File

@@ -111,7 +111,8 @@ void * lv_ll_ins_prev(lv_ll_t * ll_p, void * n_act)
if(lv_ll_get_head(ll_p) == n_act) {
n_new = lv_ll_ins_head(ll_p);
if(n_new == NULL) return NULL;
} else {
}
else {
n_new = lv_mem_alloc(ll_p->n_size + LL_NODE_META_SIZE);
if(n_new == NULL) return NULL;
@@ -166,18 +167,22 @@ void lv_ll_remove(lv_ll_t * ll_p, void * node_p)
ll_p->head = lv_ll_get_next(ll_p, node_p);
if(ll_p->head == NULL) {
ll_p->tail = NULL;
} else {
}
else {
node_set_prev(ll_p, ll_p->head, NULL);
}
} else if(lv_ll_get_tail(ll_p) == node_p) {
}
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 {
}
else {
node_set_next(ll_p, ll_p->tail, NULL);
}
} else {
}
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);
@@ -233,7 +238,8 @@ void lv_ll_chg_list(lv_ll_t * ll_ori_p, lv_ll_t * ll_new_p, void * node, bool he
if(ll_new_p->tail == NULL) { /*If there is no tail (first node) set the tail too*/
ll_new_p->tail = node;
}
} else {
}
else {
/*Set node as tail*/
node_set_prev(ll_new_p, node, ll_new_p->tail);
node_set_next(ll_new_p, node, NULL);

View File

@@ -30,8 +30,7 @@ extern "C" {
typedef uint8_t lv_ll_node_t;
/** Description of a linked list*/
typedef struct
{
typedef struct {
uint32_t n_size;
lv_ll_node_t * head;
lv_ll_node_t * tail;

View File

@@ -13,7 +13,7 @@
#include "lv_printf.h"
#if LV_LOG_PRINTF
#include <stdio.h>
#include <stdio.h>
#endif
/*********************

View File

@@ -32,7 +32,8 @@ static const int16_t sin0_90_table[] = {
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};
32269, 32364, 32448, 32523, 32587, 32642, 32687, 32722, 32747, 32762, 32767
};
/**********************
* MACROS
@@ -56,13 +57,16 @@ int16_t lv_trigo_sin(int16_t angle)
if(angle < 90) {
ret = sin0_90_table[angle];
} else if(angle >= 90 && angle < 180) {
}
else if(angle >= 90 && angle < 180) {
angle = 180 - angle;
ret = sin0_90_table[angle];
} else if(angle >= 180 && angle < 270) {
}
else if(angle >= 180 && angle < 270) {
angle = angle - 180;
ret = -sin0_90_table[angle];
} else { /*angle >=270*/
}
else { /*angle >=270*/
angle = 360 - angle;
ret = -sin0_90_table[angle];
}
@@ -114,96 +118,96 @@ void lv_sqrt(uint32_t x, lv_sqrt_res_t * q)
/*Look up for x=1..1024*/
/*Look up for x=1..1024*/
static const uint8_t ci[] = {
1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 31,
31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32,
};
static const uint8_t ci[] = {
1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 31,
31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32,
};
static const uint8_t cf[] = {
0, 106, 187, 0, 60, 115, 165, 212, 0, 42, 81, 119, 155, 190, 223, 0, 32, 62, 92, 121, 149, 177, 204, 230,
0, 25, 50, 75, 99, 122, 145, 168, 191, 213, 235, 0, 21, 42, 63, 83, 103, 123, 143, 162, 181, 200, 219,
238, 0, 18, 36, 54, 72, 89, 107, 124, 141, 158, 174, 191, 207, 224, 240, 0, 16, 32, 47, 63, 78, 94, 109,
124, 139, 154, 169, 184, 198, 213, 227, 242, 0, 14, 28, 42, 56, 70, 84, 97, 111, 125, 138, 151, 165, 178,
191, 204, 217, 230, 243, 0, 13, 25, 38, 51, 63, 76, 88, 100, 113, 125, 137, 149, 161, 173, 185, 197, 209,
221, 233, 244, 0, 12, 23, 35, 46, 58, 69, 80, 92, 103, 114, 125, 136, 147, 158, 169, 180, 191, 202, 213,
224, 235, 245, 0, 11, 21, 32, 42, 53, 63, 74, 84, 95, 105, 115, 125, 136, 146, 156, 166, 176, 186, 196,
206, 216, 226, 236, 246, 0, 10, 20, 29, 39, 49, 59, 68, 78, 87, 97, 107, 116, 126, 135, 145, 154, 163,
173, 182, 191, 201, 210, 219, 228, 238, 247, 0, 9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126,
135, 143, 152, 161, 170, 178, 187, 196, 204, 213, 222, 230, 239, 247, 0, 9, 17, 26, 34, 42, 51, 59, 68,
76, 84, 93, 101, 109, 118, 126, 134, 142, 151, 159, 167, 175, 183, 191, 200, 208, 216, 224, 232, 240, 248,
0, 8, 16, 24, 32, 40, 48, 56, 64, 71, 79, 87, 95, 103, 111, 118, 126, 134, 142, 149, 157, 165, 172, 180,
188, 195, 203, 211, 218, 226, 233, 241, 248, 0, 8, 15, 23, 30, 37, 45, 52, 60, 67, 75, 82, 89, 97, 104,
112, 119, 126, 133, 141, 148, 155, 163, 170, 177, 184, 192, 199, 206, 213, 220, 227, 235, 242, 249, 0, 7,
14, 21, 28, 35, 42, 50, 57, 64, 71, 78, 85, 92, 99, 105, 112, 119, 126, 133, 140, 147, 154, 161, 168, 174,
181, 188, 195, 202, 209, 215, 222, 229, 236, 243, 249, 0, 7, 13, 20, 27, 34, 40, 47, 54, 60, 67, 74, 80,
87, 93, 100, 107, 113, 120, 126, 133, 139, 146, 153, 159, 166, 172, 179, 185, 192, 198, 205, 211, 217,
224, 230, 237, 243, 250, 0, 6, 13, 19, 26, 32, 38, 45, 51, 57, 64, 70, 76, 83, 89, 95, 101, 108, 114, 120,
126, 133, 139, 145, 151, 158, 164, 170, 176, 182, 189, 195, 201, 207, 213, 219, 225, 232, 238, 244, 250,
0, 6, 12, 18, 24, 30, 36, 42, 49, 55, 61, 67, 73, 79, 85, 91, 97, 103, 109, 115, 121, 127, 132, 138, 144,
150, 156, 162, 168, 174, 180, 186, 192, 198, 203, 209, 215, 221, 227, 233, 239, 244, 250, 0, 6, 12, 17,
23, 29, 35, 41, 46, 52, 58, 64, 69, 75, 81, 87, 92, 98, 104, 109, 115, 121, 127, 132, 138, 144, 149, 155,
161, 166, 172, 178, 183, 189, 194, 200, 206, 211, 217, 223, 228, 234, 239, 245, 250, 0, 6, 11, 17, 22, 28,
33, 39, 44, 50, 55, 61, 66, 72, 77, 83, 88, 94, 99, 105, 110, 116, 121, 127, 132, 138, 143, 148, 154, 159,
165, 170, 175, 181, 186, 192, 197, 202, 208, 213, 219, 224, 229, 235, 240, 245, 251, 0, 5, 11, 16, 21, 27,
32, 37, 43, 48, 53, 58, 64, 69, 74, 79, 85, 90, 95, 101, 106, 111, 116, 121, 127, 132, 137, 142, 148, 153,
158, 163, 168, 174, 179, 184, 189, 194, 199, 205, 210, 215, 220, 225, 230, 235, 241, 246, 251, 0, 5, 10,
15, 20, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71, 76, 81, 86, 92, 97, 102, 107, 112, 117, 122, 127, 132,
137, 142, 147, 152, 157, 162, 167, 172, 177, 182, 187, 192, 197, 202, 207, 212, 216, 221, 226, 231, 236,
241, 246, 251, 0, 5, 10, 15, 20, 25, 29, 34, 39, 44, 49, 54, 59, 64, 69, 73, 78, 83, 88, 93, 98, 103, 107,
112, 117, 122, 127, 132, 136, 141, 146, 151, 156, 161, 165, 170, 175, 180, 185, 189, 194, 199, 204, 208,
213, 218, 223, 227, 232, 237, 242, 247, 251, 0, 5, 9, 14, 19, 24, 28, 33, 38, 43, 47, 52, 57, 61, 66, 71,
75, 80, 85, 89, 94, 99, 104, 108, 113, 118, 122, 127, 131, 136, 141, 145, 150, 155, 159, 164, 169, 173,
178, 182, 187, 192, 196, 201, 206, 210, 215, 219, 224, 229, 233, 238, 242, 247, 251, 0, 5, 9, 14, 18, 23,
27, 32, 36, 41, 46, 50, 55, 59, 64, 68, 73, 77, 82, 86, 91, 95, 100, 104, 109, 113, 118, 122, 127, 131,
136, 140, 145, 149, 154, 158, 163, 167, 172, 176, 181, 185, 189, 194, 198, 203, 207, 212, 216, 221, 225,
229, 234, 238, 243, 247, 252, 0, 4, 9, 13, 18, 22, 26, 31, 35, 40, 44, 48, 53, 57, 62, 66, 70, 75, 79, 83,
88, 92, 96, 101, 105, 110, 114, 118, 123, 127, 131, 136, 140, 144, 149, 153, 157, 162, 166, 170, 175, 179,
183, 187, 192, 196, 200, 205, 209, 213, 218, 222, 226, 230, 235, 239, 243, 247, 252, 0, 4, 9, 13, 17, 21,
26, 30, 34, 38, 43, 47, 51, 55, 60, 64, 68, 72, 76, 81, 85, 89, 93, 98, 102, 106, 110, 114, 119, 123,
127, 131, 135, 140, 144, 148, 152, 156, 160, 165, 169, 173, 177, 181, 185, 190, 194, 198, 202, 206, 210,
215, 219, 223, 227, 231, 235, 239, 244, 248, 252, 0, 4, 8, 12, 16, 21, 25, 29, 33, 37, 41, 45, 49, 53, 58,
62, 66, 70, 74, 78, 82, 86, 90, 94, 98, 103, 107, 111, 115, 119, 123, 127, 131, 135, 139, 143, 147, 151,
155, 159, 163, 168, 172, 176, 180, 184, 188, 192, 196, 200, 204, 208, 212, 216, 220, 224, 228, 232, 236,
240, 244, 248, 252, 0,
static const uint8_t cf[] = {
0, 106, 187, 0, 60, 115, 165, 212, 0, 42, 81, 119, 155, 190, 223, 0, 32, 62, 92, 121, 149, 177, 204, 230,
0, 25, 50, 75, 99, 122, 145, 168, 191, 213, 235, 0, 21, 42, 63, 83, 103, 123, 143, 162, 181, 200, 219,
238, 0, 18, 36, 54, 72, 89, 107, 124, 141, 158, 174, 191, 207, 224, 240, 0, 16, 32, 47, 63, 78, 94, 109,
124, 139, 154, 169, 184, 198, 213, 227, 242, 0, 14, 28, 42, 56, 70, 84, 97, 111, 125, 138, 151, 165, 178,
191, 204, 217, 230, 243, 0, 13, 25, 38, 51, 63, 76, 88, 100, 113, 125, 137, 149, 161, 173, 185, 197, 209,
221, 233, 244, 0, 12, 23, 35, 46, 58, 69, 80, 92, 103, 114, 125, 136, 147, 158, 169, 180, 191, 202, 213,
224, 235, 245, 0, 11, 21, 32, 42, 53, 63, 74, 84, 95, 105, 115, 125, 136, 146, 156, 166, 176, 186, 196,
206, 216, 226, 236, 246, 0, 10, 20, 29, 39, 49, 59, 68, 78, 87, 97, 107, 116, 126, 135, 145, 154, 163,
173, 182, 191, 201, 210, 219, 228, 238, 247, 0, 9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126,
135, 143, 152, 161, 170, 178, 187, 196, 204, 213, 222, 230, 239, 247, 0, 9, 17, 26, 34, 42, 51, 59, 68,
76, 84, 93, 101, 109, 118, 126, 134, 142, 151, 159, 167, 175, 183, 191, 200, 208, 216, 224, 232, 240, 248,
0, 8, 16, 24, 32, 40, 48, 56, 64, 71, 79, 87, 95, 103, 111, 118, 126, 134, 142, 149, 157, 165, 172, 180,
188, 195, 203, 211, 218, 226, 233, 241, 248, 0, 8, 15, 23, 30, 37, 45, 52, 60, 67, 75, 82, 89, 97, 104,
112, 119, 126, 133, 141, 148, 155, 163, 170, 177, 184, 192, 199, 206, 213, 220, 227, 235, 242, 249, 0, 7,
14, 21, 28, 35, 42, 50, 57, 64, 71, 78, 85, 92, 99, 105, 112, 119, 126, 133, 140, 147, 154, 161, 168, 174,
181, 188, 195, 202, 209, 215, 222, 229, 236, 243, 249, 0, 7, 13, 20, 27, 34, 40, 47, 54, 60, 67, 74, 80,
87, 93, 100, 107, 113, 120, 126, 133, 139, 146, 153, 159, 166, 172, 179, 185, 192, 198, 205, 211, 217,
224, 230, 237, 243, 250, 0, 6, 13, 19, 26, 32, 38, 45, 51, 57, 64, 70, 76, 83, 89, 95, 101, 108, 114, 120,
126, 133, 139, 145, 151, 158, 164, 170, 176, 182, 189, 195, 201, 207, 213, 219, 225, 232, 238, 244, 250,
0, 6, 12, 18, 24, 30, 36, 42, 49, 55, 61, 67, 73, 79, 85, 91, 97, 103, 109, 115, 121, 127, 132, 138, 144,
150, 156, 162, 168, 174, 180, 186, 192, 198, 203, 209, 215, 221, 227, 233, 239, 244, 250, 0, 6, 12, 17,
23, 29, 35, 41, 46, 52, 58, 64, 69, 75, 81, 87, 92, 98, 104, 109, 115, 121, 127, 132, 138, 144, 149, 155,
161, 166, 172, 178, 183, 189, 194, 200, 206, 211, 217, 223, 228, 234, 239, 245, 250, 0, 6, 11, 17, 22, 28,
33, 39, 44, 50, 55, 61, 66, 72, 77, 83, 88, 94, 99, 105, 110, 116, 121, 127, 132, 138, 143, 148, 154, 159,
165, 170, 175, 181, 186, 192, 197, 202, 208, 213, 219, 224, 229, 235, 240, 245, 251, 0, 5, 11, 16, 21, 27,
32, 37, 43, 48, 53, 58, 64, 69, 74, 79, 85, 90, 95, 101, 106, 111, 116, 121, 127, 132, 137, 142, 148, 153,
158, 163, 168, 174, 179, 184, 189, 194, 199, 205, 210, 215, 220, 225, 230, 235, 241, 246, 251, 0, 5, 10,
15, 20, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71, 76, 81, 86, 92, 97, 102, 107, 112, 117, 122, 127, 132,
137, 142, 147, 152, 157, 162, 167, 172, 177, 182, 187, 192, 197, 202, 207, 212, 216, 221, 226, 231, 236,
241, 246, 251, 0, 5, 10, 15, 20, 25, 29, 34, 39, 44, 49, 54, 59, 64, 69, 73, 78, 83, 88, 93, 98, 103, 107,
112, 117, 122, 127, 132, 136, 141, 146, 151, 156, 161, 165, 170, 175, 180, 185, 189, 194, 199, 204, 208,
213, 218, 223, 227, 232, 237, 242, 247, 251, 0, 5, 9, 14, 19, 24, 28, 33, 38, 43, 47, 52, 57, 61, 66, 71,
75, 80, 85, 89, 94, 99, 104, 108, 113, 118, 122, 127, 131, 136, 141, 145, 150, 155, 159, 164, 169, 173,
178, 182, 187, 192, 196, 201, 206, 210, 215, 219, 224, 229, 233, 238, 242, 247, 251, 0, 5, 9, 14, 18, 23,
27, 32, 36, 41, 46, 50, 55, 59, 64, 68, 73, 77, 82, 86, 91, 95, 100, 104, 109, 113, 118, 122, 127, 131,
136, 140, 145, 149, 154, 158, 163, 167, 172, 176, 181, 185, 189, 194, 198, 203, 207, 212, 216, 221, 225,
229, 234, 238, 243, 247, 252, 0, 4, 9, 13, 18, 22, 26, 31, 35, 40, 44, 48, 53, 57, 62, 66, 70, 75, 79, 83,
88, 92, 96, 101, 105, 110, 114, 118, 123, 127, 131, 136, 140, 144, 149, 153, 157, 162, 166, 170, 175, 179,
183, 187, 192, 196, 200, 205, 209, 213, 218, 222, 226, 230, 235, 239, 243, 247, 252, 0, 4, 9, 13, 17, 21,
26, 30, 34, 38, 43, 47, 51, 55, 60, 64, 68, 72, 76, 81, 85, 89, 93, 98, 102, 106, 110, 114, 119, 123,
127, 131, 135, 140, 144, 148, 152, 156, 160, 165, 169, 173, 177, 181, 185, 190, 194, 198, 202, 206, 210,
215, 219, 223, 227, 231, 235, 239, 244, 248, 252, 0, 4, 8, 12, 16, 21, 25, 29, 33, 37, 41, 45, 49, 53, 58,
62, 66, 70, 74, 78, 82, 86, 90, 94, 98, 103, 107, 111, 115, 119, 123, 127, 131, 135, 139, 143, 147, 151,
155, 159, 163, 168, 172, 176, 180, 184, 188, 192, 196, 200, 204, 208, 212, 216, 220, 224, 228, 232, 236,
240, 244, 248, 252, 0,
};
};
if(x <= 1024) {
x--;
q->i = ci[x];
@@ -274,7 +278,8 @@ uint16_t lv_atan2(int x, int y)
if(ux > uy) {
degree = (uy * 45) / ux; // degree result will be 0-45 range
negflag += 0x10; // octant flag bit
} else {
}
else {
degree = (ux * 45) / uy; // degree result will be 0-45 range
}
@@ -286,7 +291,8 @@ uint16_t lv_atan2(int x, int y)
if(tempdegree <= 41) comp++;
if(tempdegree <= 37) comp++;
if(tempdegree <= 32) comp++; // max is 4 degrees compensated
} else { // else is lower half of range
}
else { // else is lower half of range
if(tempdegree >= 2) comp++;
if(tempdegree >= 6) comp++;
if(tempdegree >= 10) comp++;
@@ -304,7 +310,8 @@ uint16_t lv_atan2(int x, int y)
degree = (180 + degree);
else // else is -Y +X
degree = (180 - degree);
} else { // else is +Y
}
else { // else is +Y
if(negflag & 0x01) // if +Y -X
degree = (360 - degree);
}

View File

@@ -44,9 +44,9 @@ extern "C" {
**********************/
typedef struct {
uint16_t i;
uint16_t f;
}lv_sqrt_res_t;
uint16_t i;
uint16_t f;
} lv_sqrt_res_t;
/**********************

View File

@@ -13,11 +13,11 @@
#include <string.h>
#if LV_MEM_CUSTOM != 0
#include LV_MEM_CUSTOM_INCLUDE
#include LV_MEM_CUSTOM_INCLUDE
#endif
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/*********************
@@ -25,13 +25,13 @@
*********************/
/*Add memory junk on alloc (0xaa) and free(0xbb) (just for testing purposes)*/
#ifndef LV_MEM_ADD_JUNK
#define LV_MEM_ADD_JUNK 1
#define LV_MEM_ADD_JUNK 1
#endif
#ifdef LV_ARCH_64
#define MEM_UNIT uint64_t
#define MEM_UNIT uint64_t
#else
#define MEM_UNIT uint32_t
#define MEM_UNIT uint32_t
#endif
/**********************
@@ -41,18 +41,15 @@
#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
{
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
{
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;
@@ -63,16 +60,16 @@ typedef struct
* 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);
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;
static uint8_t * work_mem;
#endif
static uint32_t zero_mem; /*Give the address of this variable if 0 byte should be allocated*/
@@ -165,7 +162,7 @@ void * lv_mem_alloc(size_t size)
} while(e != NULL && alloc == NULL);
#else
/*Use custom, user defined malloc function*/
/*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 */
@@ -217,7 +214,8 @@ void lv_mem_free(const void * data)
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 {
}
else {
break;
}
e_next = ent_get_next(e_next);
@@ -324,7 +322,8 @@ void lv_mem_defrag(void)
while(e_free != NULL) {
if(e_free->header.s.used != 0) {
e_free = ent_get_next(e_free);
} else {
}
else {
break;
}
}
@@ -336,7 +335,8 @@ void lv_mem_defrag(void)
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 {
}
else {
break;
}
@@ -358,7 +358,7 @@ lv_res_t lv_mem_test(void)
e = ent_get_next(NULL);
while(e) {
if((e->header.s.used && e->header.s.d_size > LV_MEM_SIZE) ||
(e->header.s.used == 0 && e->header.s.d_size > LV_MEM_SIZE)) {
(e->header.s.used == 0 && e->header.s.d_size > LV_MEM_SIZE)) {
return LV_RES_INV;
}
e = ent_get_next(e);
@@ -389,7 +389,8 @@ void lv_mem_monitor(lv_mem_monitor_t * mon_p)
if(e->header.s.d_size > mon_p->free_biggest_size) {
mon_p->free_biggest_size = e->header.s.d_size;
}
} else {
}
else {
mon_p->used_cnt++;
}
@@ -514,7 +515,8 @@ static lv_mem_ent_t * ent_get_next(lv_mem_ent_t * act_e)
if(act_e == NULL) { /*NULL means: get the first entry*/
next_e = (lv_mem_ent_t *)work_mem;
} else { /*Get the next entry */
}
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];
@@ -539,7 +541,7 @@ static void * ent_alloc(lv_mem_ent_t * e, size_t size)
/*Truncate the entry to the desired size */
ent_trunc(e, size),
e->header.s.used = 1;
e->header.s.used = 1;
/*Save the allocated data*/
alloc = &e->first_data;

View File

@@ -35,8 +35,7 @@ extern "C" {
/**
* Heap information structure.
*/
typedef struct
{
typedef struct {
uint32_t total_size; /**< Total heap size */
uint32_t free_cnt;
uint32_t free_size; /**< Size of available memory */
@@ -49,8 +48,8 @@ typedef struct
typedef struct {
void * p;
uint16_t size;
uint8_t used :1;
}lv_mem_buf_t;
uint8_t used : 1;
} lv_mem_buf_t;
typedef lv_mem_buf_t lv_mem_buf_arr_t[LV_MEM_BUF_MAX_NUM];
extern lv_mem_buf_arr_t _lv_mem_buf;

File diff suppressed because it is too large Load Diff

View File

@@ -54,8 +54,8 @@ extern "C" {
* 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);
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

View File

@@ -14,7 +14,7 @@
#include "lv_gc.h"
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/*********************
@@ -81,7 +81,7 @@ LV_ATTRIBUTE_TASK_HANDLER uint32_t lv_task_handler(void)
static uint32_t idle_period_start = 0;
static uint32_t handler_start = 0;
static uint32_t busy_time = 0;
static uint32_t time_till_next;
static uint32_t time_till_next;
if(lv_task_run == false) {
already_running = false; /*Release mutex*/
@@ -190,7 +190,7 @@ LV_ATTRIBUTE_TASK_HANDLER uint32_t lv_task_handler(void)
already_running = false; /*Release the mutex*/
LV_LOG_TRACE("lv_task_handler ready");
return time_till_next;
return time_till_next;
}
/**
* Create an "empty" task. It needs to initialzed with at least
@@ -305,8 +305,7 @@ void lv_task_set_prio(lv_task_t * task, lv_task_prio_t prio)
/*Find the tasks with new priority*/
lv_task_t * i;
LV_LL_READ(LV_GC_ROOT(_lv_task_ll), 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;
@@ -416,9 +415,9 @@ static bool lv_task_exec(lv_task_t * task)
*/
static uint32_t lv_task_time_remaining(lv_task_t * task)
{
/*Check if at least 'period' time elapsed*/
/*Check if at least 'period' time elapsed*/
uint32_t elp = lv_tick_elaps(task->last_run);
if(elp >= task->period)
return 0;
return task->period - elp;
if(elp >= task->period)
return 0;
return task->period - elp;
}

View File

@@ -57,8 +57,7 @@ typedef uint8_t lv_task_prio_t;
/**
* Descriptor of a lv_task
*/
typedef struct _lv_task_t
{
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 */

View File

@@ -25,23 +25,23 @@
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);
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);
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
@@ -51,23 +51,23 @@ static uint32_t lv_txt_iso8859_1_get_length(const char * txt);
* 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;
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;
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
@@ -109,10 +109,11 @@ void lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t *
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)) {
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 {
}
else {
size_res->y += letter_height;
size_res->y += line_space;
}
@@ -168,8 +169,8 @@ void lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t *
* @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)
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;
@@ -227,7 +228,7 @@ static uint16_t lv_txt_get_next_word(const char * txt, const lv_font_t * font,
}
/* Update the output width */
if( word_w_ptr != NULL && break_index == NO_BREAK_FOUND ) *word_w_ptr = cur_w;
if(word_w_ptr != NULL && break_index == NO_BREAK_FOUND) *word_w_ptr = cur_w;
i = i_next;
@@ -236,22 +237,22 @@ static uint16_t lv_txt_get_next_word(const char * txt, const lv_font_t * font,
}
/* 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;
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(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(force) return break_index;
if(word_w_ptr != NULL) *word_w_ptr = 0;
return 0;
}
@@ -261,7 +262,7 @@ static uint16_t lv_txt_get_next_word(const char * txt, const lv_font_t * font,
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--){
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.
@@ -269,7 +270,7 @@ static uint16_t lv_txt_get_next_word(const char * txt, const lv_font_t * font,
}
return i;
#else
if( force ) return break_index;
if(force) return break_index;
if(word_w_ptr != NULL) *word_w_ptr = 0; /* Return no word */
(void) break_letter_count;
return 0;
@@ -300,10 +301,10 @@ uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font,
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);
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(advance == 0) {
if(i == 0) lv_txt_encoded_next(txt, &i); // prevent inf loops
break;
}
@@ -312,7 +313,7 @@ uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font,
if(txt[0] == '\n' || txt[0] == '\r') break;
if(txt[i] == '\n' || txt[i] == '\r'){
if(txt[i] == '\n' || txt[i] == '\r') {
i++; /* Include the following newline in the current line */
break;
}
@@ -496,12 +497,14 @@ static uint32_t lv_txt_unicode_to_utf8(uint32_t letter_uni)
bytes[1] = ((letter_uni >> 0) & 0x3F) | 0x80;
bytes[2] = 0;
bytes[3] = 0;
} else if(letter_uni < 0x010000) {
}
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) {
}
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;
@@ -603,7 +606,8 @@ static uint32_t lv_txt_utf8_next(const char * txt, uint32_t * i)
if((txt[*i] & 0xC0) != 0x80) return 0; /*Invalid UTF-8 code*/
result += txt[*i] & 0x3F;
(*i)++;
} else {
}
else {
(*i)++; /*Not UTF-8 char. Go the next.*/
}
}

View File

@@ -100,10 +100,12 @@ void * lv_utils_bsearch(const void * key, const void * base, uint32_t n, uint32_
if((c = (*cmp)(key, middle)) > 0) {
n = (n / 2) - ((n & 1) == 0);
base = (middle += size);
} else if(c < 0) {
}
else if(c < 0) {
n /= 2;
middle = base;
} else {
}
else {
return (char *)middle;
}
}

View File

@@ -76,11 +76,11 @@ typedef enum {
LV_THEME_TILEVIEW,
LV_THEME_WIN,
LV_THEME_WIN_BTN, /*The buttons are initialized separately*/
}lv_theme_style_t;
} lv_theme_style_t;
typedef struct {
void (*apply_cb)(lv_obj_t *,lv_theme_style_t);
}lv_theme_t;
void (*apply_cb)(lv_obj_t *, lv_theme_style_t);
} lv_theme_t;
/**********************
* GLOBAL PROTOTYPES

File diff suppressed because it is too large Load Diff

View File

@@ -43,7 +43,7 @@ extern "C" {
* @return a pointer to reference this theme later
*/
lv_theme_t * lv_theme_material_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags,
lv_font_t * font_small, lv_font_t * font_normal, lv_font_t * font_subtitle, lv_font_t * font_title);
lv_font_t * font_small, lv_font_t * font_normal, lv_font_t * font_subtitle, lv_font_t * font_title);
/**********************
* MACROS
**********************/

View File

@@ -169,11 +169,11 @@ void lv_arc_set_end_angle(lv_obj_t * arc, int16_t end)
lv_obj_invalidate(arc);
}
/*Only a smaller incremental move*/
else if(ext->arc_angle_end > ext->arc_angle_start && end > ext->arc_angle_start ) {
else if(ext->arc_angle_end > ext->arc_angle_start && end > ext->arc_angle_start) {
inv_arc_area(arc, LV_MATH_MIN(ext->arc_angle_end, end), LV_MATH_MAX(ext->arc_angle_end, end));
}
/*Only a smaller incremental move*/
else if(ext->arc_angle_end < ext->arc_angle_start && end < ext->arc_angle_start ) {
else if(ext->arc_angle_end < ext->arc_angle_start && end < ext->arc_angle_start) {
inv_arc_area(arc, LV_MATH_MIN(ext->arc_angle_end, end), LV_MATH_MAX(ext->arc_angle_end, end));
}
/*Crossing the end angle makes the whole arc change*/
@@ -181,7 +181,7 @@ void lv_arc_set_end_angle(lv_obj_t * arc, int16_t end)
lv_obj_invalidate(arc);
}
ext->arc_angle_end= end;
ext->arc_angle_end = end;
}
@@ -259,11 +259,11 @@ void lv_arc_set_bg_end_angle(lv_obj_t * arc, int16_t end)
lv_obj_invalidate(arc);
}
/*Only a smaller incremental move*/
else if(ext->bg_angle_end > ext->bg_angle_start && end > ext->bg_angle_start ) {
else if(ext->bg_angle_end > ext->bg_angle_start && end > ext->bg_angle_start) {
inv_arc_area(arc, LV_MATH_MIN(ext->bg_angle_end, end), LV_MATH_MAX(ext->bg_angle_end, end));
}
/*Only a smaller incremental move*/
else if(ext->bg_angle_end < ext->bg_angle_start && end < ext->bg_angle_start ) {
else if(ext->bg_angle_end < ext->bg_angle_start && end < ext->bg_angle_start) {
inv_arc_area(arc, LV_MATH_MIN(ext->bg_angle_end, end), LV_MATH_MAX(ext->bg_angle_end, end));
}
/*Crossing the end angle makes the whole arc change*/
@@ -271,7 +271,7 @@ void lv_arc_set_bg_end_angle(lv_obj_t * arc, int16_t end)
lv_obj_invalidate(arc);
}
ext->bg_angle_end= end;
ext->bg_angle_end = end;
}
/**
@@ -439,14 +439,14 @@ static lv_style_list_t * lv_arc_get_style(lv_obj_t * arc, uint8_t part)
lv_style_list_t * style_dsc_p;
switch(part) {
case LV_ARC_PART_BG:
style_dsc_p = &arc->style_list;
break;
case LV_ARC_PART_ARC:
style_dsc_p = &ext->style_arc;
break;
default:
style_dsc_p = NULL;
case LV_ARC_PART_BG:
style_dsc_p = &arc->style_list;
break;
case LV_ARC_PART_ARC:
style_dsc_p = &ext->style_arc;
break;
default:
style_dsc_p = NULL;
}
return style_dsc_p;
@@ -513,32 +513,41 @@ static void inv_arc_area(lv_obj_t * arc, uint16_t start_angle, uint16_t end_angl
lv_obj_invalidate_area(arc, &inv_area);
}
} else if(start_quarter == 0 && end_quarter == 1) {
}
else if(start_quarter == 0 && end_quarter == 1) {
inv_area.x1 = x + ((lv_trigo_sin(end_angle + 90) * rout) >> LV_TRIGO_SHIFT) - extra_area;
inv_area.y1 = y + ((LV_MATH_MIN(lv_trigo_sin(end_angle), lv_trigo_sin(start_angle)) * rin) >> LV_TRIGO_SHIFT) - extra_area;
inv_area.y1 = y + ((LV_MATH_MIN(lv_trigo_sin(end_angle),
lv_trigo_sin(start_angle)) * rin) >> LV_TRIGO_SHIFT) - extra_area;
inv_area.x2 = x + ((lv_trigo_sin(start_angle + 90) * rout) >> LV_TRIGO_SHIFT) + extra_area;
inv_area.y2 = y + rout + extra_area;
lv_obj_invalidate_area(arc, &inv_area);
} else if(start_quarter == 1 && end_quarter == 2) {
}
else if(start_quarter == 1 && end_quarter == 2) {
inv_area.x1 = x - rout - extra_area;
inv_area.y1 = y + ((lv_trigo_sin(end_angle) * rout) >> LV_TRIGO_SHIFT) - extra_area;
inv_area.x2 = x + ((LV_MATH_MAX(lv_trigo_sin(start_angle + 90) , lv_trigo_sin(end_angle + 90)) * rin) >> LV_TRIGO_SHIFT) + extra_area;
inv_area.x2 = x + ((LV_MATH_MAX(lv_trigo_sin(start_angle + 90),
lv_trigo_sin(end_angle + 90)) * rin) >> LV_TRIGO_SHIFT) + extra_area;
inv_area.y2 = y + ((lv_trigo_sin(start_angle) * rout) >> LV_TRIGO_SHIFT) + extra_area;
lv_obj_invalidate_area(arc, &inv_area);
} else if(start_quarter == 2 && end_quarter == 3) {
}
else if(start_quarter == 2 && end_quarter == 3) {
inv_area.x1 = x + ((lv_trigo_sin(start_angle + 90) * rout) >> LV_TRIGO_SHIFT) - extra_area;
inv_area.y1 = y - rout - extra_area;
inv_area.x2 = x + ((lv_trigo_sin(end_angle + 90) * rout) >> LV_TRIGO_SHIFT) + extra_area;
inv_area.y2 = y + (LV_MATH_MAX(lv_trigo_sin(end_angle) * rin, lv_trigo_sin(start_angle) * rin) >> LV_TRIGO_SHIFT) + extra_area;
inv_area.y2 = y + (LV_MATH_MAX(lv_trigo_sin(end_angle) * rin,
lv_trigo_sin(start_angle) * rin) >> LV_TRIGO_SHIFT) + extra_area;
lv_obj_invalidate_area(arc, &inv_area);
} else if(start_quarter == 3 && end_quarter == 0) {
inv_area.x1 = x + ((LV_MATH_MIN(lv_trigo_sin(end_angle + 90), lv_trigo_sin(start_angle + 90)) * rin) >> LV_TRIGO_SHIFT) - extra_area;
}
else if(start_quarter == 3 && end_quarter == 0) {
inv_area.x1 = x + ((LV_MATH_MIN(lv_trigo_sin(end_angle + 90),
lv_trigo_sin(start_angle + 90)) * rin) >> LV_TRIGO_SHIFT) - extra_area;
inv_area.y1 = y + ((lv_trigo_sin(start_angle) * rout) >> LV_TRIGO_SHIFT) - extra_area;
inv_area.x2 = x + rout + extra_area;
inv_area.y2 = y + ((lv_trigo_sin(end_angle) * rout) >> LV_TRIGO_SHIFT) + extra_area;
lv_obj_invalidate_area(arc, &inv_area);
} else {
}
else {
lv_obj_invalidate(arc);
}
}

View File

@@ -27,8 +27,7 @@ extern "C" {
* TYPEDEFS
**********************/
/*Data of arc*/
typedef struct
{
typedef struct {
/*New data for this type */
lv_coord_t arc_angle_start;
lv_coord_t arc_angle_end;

View File

@@ -26,10 +26,10 @@
#define LV_BAR_SIZE_MIN 4 /*hor. pad and ver. pad cannot make the indicator smaller then this [px]*/
#if LV_USE_ANIMATION
#define LV_BAR_IS_ANIMATING(anim_struct) (((anim_struct).anim_state) != LV_BAR_ANIM_STATE_INV)
#define LV_BAR_GET_ANIM_VALUE(orig_value, anim_struct) (LV_BAR_IS_ANIMATING(anim_struct) ? ((anim_struct).anim_end) : (orig_value))
#define LV_BAR_IS_ANIMATING(anim_struct) (((anim_struct).anim_state) != LV_BAR_ANIM_STATE_INV)
#define LV_BAR_GET_ANIM_VALUE(orig_value, anim_struct) (LV_BAR_IS_ANIMATING(anim_struct) ? ((anim_struct).anim_end) : (orig_value))
#else
#define LV_BAR_GET_ANIM_VALUE(orig_value, anim_struct) (orig_value)
#define LV_BAR_GET_ANIM_VALUE(orig_value, anim_struct) (orig_value)
#endif
/**********************
* TYPEDEFS
@@ -46,10 +46,11 @@ static void draw_bg(lv_obj_t * bar, const lv_area_t * clip_area);
static void draw_indic(lv_obj_t * bar, const lv_area_t * clip_area);
#if LV_USE_ANIMATION
static void lv_bar_set_value_with_anim(lv_obj_t * bar, int16_t new_value, int16_t *value_ptr, lv_bar_anim_t *anim_info, lv_anim_enable_t en);
static void lv_bar_init_anim(lv_obj_t * bar, lv_bar_anim_t * bar_anim);
static void lv_bar_anim(lv_bar_anim_t * bar, lv_anim_value_t value);
static void lv_bar_anim_ready(lv_anim_t * a);
static void lv_bar_set_value_with_anim(lv_obj_t * bar, int16_t new_value, int16_t * value_ptr,
lv_bar_anim_t * anim_info, lv_anim_enable_t en);
static void lv_bar_init_anim(lv_obj_t * bar, lv_bar_anim_t * bar_anim);
static void lv_bar_anim(lv_bar_anim_t * bar, lv_anim_value_t value);
static void lv_bar_anim_ready(lv_anim_t * a);
#endif
/**********************
@@ -93,13 +94,13 @@ lv_obj_t * lv_bar_create(lv_obj_t * par, const lv_obj_t * copy)
}
ext->min_value = 0;
ext->start_value = 0;
ext->start_value = 0;
ext->max_value = 100;
ext->cur_value = 0;
#if LV_USE_ANIMATION
ext->anim_time = 200;
lv_bar_init_anim(bar, &ext->cur_value_anim);
lv_bar_init_anim(bar, &ext->start_value_anim);
lv_bar_init_anim(bar, &ext->cur_value_anim);
lv_bar_init_anim(bar, &ext->start_value_anim);
#endif
ext->type = LV_BAR_TYPE_NORMAL;
@@ -117,10 +118,11 @@ lv_obj_t * lv_bar_create(lv_obj_t * par, const lv_obj_t * copy)
lv_bar_set_value(bar, ext->cur_value, false);
lv_theme_apply(bar, LV_THEME_BAR);
} else {
}
else {
lv_bar_ext_t * ext_copy = lv_obj_get_ext_attr(copy);
ext->min_value = ext_copy->min_value;
ext->start_value = ext_copy->start_value;
ext->start_value = ext_copy->start_value;
ext->max_value = ext_copy->max_value;
ext->cur_value = ext_copy->cur_value;
ext->type = ext_copy->type;
@@ -164,7 +166,7 @@ void lv_bar_set_value(lv_obj_t * bar, int16_t value, lv_anim_enable_t anim)
ext->cur_value = new_value;
lv_obj_invalidate(bar);
#else
lv_bar_set_value_with_anim(bar, new_value, &ext->cur_value, &ext->cur_value_anim, anim);
lv_bar_set_value_with_anim(bar, new_value, &ext->cur_value, &ext->cur_value_anim, anim);
#endif
}
@@ -189,7 +191,7 @@ void lv_bar_set_start_value(lv_obj_t * bar, int16_t start_value, lv_anim_enable_
#if LV_USE_ANIMATION == 0
ext->start_value = new_value;
#else
lv_bar_set_value_with_anim(bar, new_value, &ext->start_value, &ext->start_value_anim, anim);
lv_bar_set_value_with_anim(bar, new_value, &ext->start_value, &ext->start_value_anim, anim);
#endif
}
@@ -230,14 +232,14 @@ void lv_bar_set_range(lv_obj_t * bar, int16_t min, int16_t max)
*/
void lv_bar_set_type(lv_obj_t * bar, lv_bar_type_t type)
{
LV_ASSERT_OBJ(bar, LV_OBJX_NAME);
LV_ASSERT_OBJ(bar, LV_OBJX_NAME);
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
ext->type = type;
if(ext->type != LV_BAR_TYPE_CUSTOM)
ext->start_value = ext->min_value;
ext->type = type;
if(ext->type != LV_BAR_TYPE_CUSTOM)
ext->start_value = ext->min_value;
lv_obj_invalidate(bar);
lv_obj_invalidate(bar);
}
/**
@@ -286,7 +288,7 @@ int16_t lv_bar_get_start_value(const lv_obj_t * bar)
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
if(ext->type != LV_BAR_TYPE_CUSTOM) return ext->min_value;
if(ext->type != LV_BAR_TYPE_CUSTOM) return ext->min_value;
return LV_BAR_GET_ANIM_VALUE(ext->start_value, ext->start_value_anim);
}
@@ -322,11 +324,12 @@ int16_t lv_bar_get_max_value(const lv_obj_t * bar)
* @param bar pointer to bar object
* @return bar type
*/
lv_bar_type_t lv_bar_get_type(lv_obj_t * bar) {
LV_ASSERT_OBJ(bar, LV_OBJX_NAME);
lv_bar_type_t lv_bar_get_type(lv_obj_t * bar)
{
LV_ASSERT_OBJ(bar, LV_OBJX_NAME);
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
return ext->type;
return ext->type;
}
/**
@@ -367,7 +370,8 @@ static lv_design_res_t lv_bar_design(lv_obj_t * bar, const lv_area_t * clip_area
if(mode == LV_DESIGN_COVER_CHK) {
/*Return false if the object is not covers the mask area*/
return ancestor_design_f(bar, clip_area, mode);
} else if(mode == LV_DESIGN_DRAW_MAIN) {
}
else if(mode == LV_DESIGN_DRAW_MAIN) {
draw_bg(bar, clip_area);
draw_indic(bar, clip_area);
@@ -382,7 +386,8 @@ static lv_design_res_t lv_bar_design(lv_obj_t * bar, const lv_area_t * clip_area
lv_obj_init_draw_rect_dsc(bar, LV_BAR_PART_BG, &draw_dsc);
lv_draw_rect(&bar->coords, clip_area, &draw_dsc);
} else if(mode == LV_DESIGN_DRAW_POST) {
}
else if(mode == LV_DESIGN_DRAW_POST) {
}
return LV_DESIGN_RES_OK;
@@ -407,7 +412,8 @@ static void draw_indic(lv_obj_t * bar, const lv_area_t * clip_area)
int32_t range = ext->max_value - ext->min_value;
bool hor = objw >= objh ? true : false;
bool sym = false;
if(ext->type == LV_BAR_TYPE_SYM && ext->min_value < 0 && ext->max_value > 0 && ext->start_value == ext->min_value) sym = true;
if(ext->type == LV_BAR_TYPE_SYM && ext->min_value < 0 && ext->max_value > 0 &&
ext->start_value == ext->min_value) sym = true;
/*Calculate the indicator area*/
lv_style_int_t bg_left = lv_obj_get_style_pad_left(bar, LV_BAR_PART_BG);
@@ -425,7 +431,8 @@ static void draw_indic(lv_obj_t * bar, const lv_area_t * clip_area)
if(hor && lv_area_get_height(&ext->indic_area) < LV_BAR_SIZE_MIN) {
ext->indic_area.y1 = bar->coords.y1 + (objh / 2) - (LV_BAR_SIZE_MIN / 2);
ext->indic_area.y2 = ext->indic_area.y1 + LV_BAR_SIZE_MIN;
} else if(!hor && lv_area_get_width(&ext->indic_area) < LV_BAR_SIZE_MIN) {
}
else if(!hor && lv_area_get_width(&ext->indic_area) < LV_BAR_SIZE_MIN) {
ext->indic_area.x1 = bar->coords.x1 + (objw / 2) - (LV_BAR_SIZE_MIN / 2);
ext->indic_area.x2 = ext->indic_area.x1 + LV_BAR_SIZE_MIN;
}
@@ -439,13 +446,14 @@ static void draw_indic(lv_obj_t * bar, const lv_area_t * clip_area)
lv_coord_t anim_cur_value_x, anim_start_value_x;
lv_coord_t * axis1, * axis2;
lv_coord_t (*indic_length_calc)(const lv_area_t *area);
lv_coord_t (*indic_length_calc)(const lv_area_t * area);
if(hor) {
axis1 = &ext->indic_area.x1;
axis2 = &ext->indic_area.x2;
indic_length_calc = lv_area_get_width;
} else {
}
else {
axis1 = &ext->indic_area.y1;
axis2 = &ext->indic_area.y2;
indic_length_calc = lv_area_get_height;
@@ -458,11 +466,13 @@ static void draw_indic(lv_obj_t * bar, const lv_area_t * clip_area)
lv_coord_t anim_start_value_end_x =
(int32_t)((int32_t)anim_length * (ext->start_value_anim.anim_end - ext->min_value)) / range;
anim_start_value_x = (((anim_start_value_end_x - anim_start_value_start_x) * ext->start_value_anim.anim_state) / LV_BAR_ANIM_STATE_END);
anim_start_value_x = (((anim_start_value_end_x - anim_start_value_start_x) * ext->start_value_anim.anim_state) /
LV_BAR_ANIM_STATE_END);
if(anim_start_value_end_x < anim_start_value_start_x)
anim_start_value_x += anim_start_value_start_x;
} else
}
else
#endif
{
anim_start_value_x = (int32_t)((int32_t)anim_length * (ext->start_value - ext->min_value)) / range;
@@ -475,11 +485,13 @@ static void draw_indic(lv_obj_t * bar, const lv_area_t * clip_area)
lv_coord_t anim_cur_value_end_x =
(int32_t)((int32_t)anim_length * (ext->cur_value_anim.anim_end - ext->min_value)) / range;
anim_cur_value_x = (((anim_cur_value_end_x - anim_cur_value_start_x) * ext->cur_value_anim.anim_state) / LV_BAR_ANIM_STATE_END);
anim_cur_value_x = (((anim_cur_value_end_x - anim_cur_value_start_x) * ext->cur_value_anim.anim_state) /
LV_BAR_ANIM_STATE_END);
if(anim_cur_value_end_x < anim_cur_value_start_x)
anim_cur_value_x += anim_cur_value_start_x;
} else
}
else
#endif
{
anim_cur_value_x = (int32_t)((int32_t)anim_length * (ext->cur_value - ext->min_value)) / range;
@@ -489,7 +501,8 @@ static void draw_indic(lv_obj_t * bar, const lv_area_t * clip_area)
if(hor) {
*axis2 = *axis1 + anim_cur_value_x;
*axis1 += anim_start_value_x;
} else {
}
else {
*axis2 -= anim_start_value_x;
*axis1 = *axis2 - anim_cur_value_x;
}
@@ -521,7 +534,7 @@ static void draw_indic(lv_obj_t * bar, const lv_area_t * clip_area)
* The radius of the bg and the indicator can make a strange shape where
* it'd be very difficult to draw shadow. */
if((hor && lv_area_get_width(&ext->indic_area) > bg_radius * 2) ||
(!hor && lv_area_get_height(&ext->indic_area) > bg_radius * 2)) {
(!hor && lv_area_get_height(&ext->indic_area) > bg_radius * 2)) {
lv_opa_t bg_opa = draw_indic_dsc.bg_opa;
lv_opa_t border_opa = draw_indic_dsc.border_opa;
lv_opa_t value_opa = draw_indic_dsc.border_opa;
@@ -560,7 +573,8 @@ static void draw_indic(lv_obj_t * bar, const lv_area_t * clip_area)
if(hor && lv_area_get_height(&mask_indic_max_area) < LV_BAR_SIZE_MIN) {
mask_indic_max_area.y1 = bar->coords.y1 + (objh / 2) - (LV_BAR_SIZE_MIN / 2);
mask_indic_max_area.y2 = mask_indic_max_area.y1 + LV_BAR_SIZE_MIN;
} else if(!hor && lv_area_get_width(&mask_indic_max_area) < LV_BAR_SIZE_MIN) {
}
else if(!hor && lv_area_get_width(&mask_indic_max_area) < LV_BAR_SIZE_MIN) {
mask_indic_max_area.x1 = bar->coords.x1 + (objw / 2) - (LV_BAR_SIZE_MIN / 2);
mask_indic_max_area.x2 = mask_indic_max_area.x1 + LV_BAR_SIZE_MIN;
}
@@ -623,14 +637,14 @@ static lv_res_t lv_bar_signal(lv_obj_t * bar, lv_signal_t sign, void * param)
bar->ext_draw_pad = LV_MATH_MAX(bar->ext_draw_pad, indic_size);
}
if(sign == LV_SIGNAL_CLEANUP) {
if(sign == LV_SIGNAL_CLEANUP) {
lv_obj_clean_style_list(bar, LV_BAR_PART_INDIC);
#if LV_USE_ANIMATION
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
lv_anim_del(&ext->cur_value_anim, NULL);
lv_anim_del(&ext->start_value_anim, NULL);
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
lv_anim_del(&ext->cur_value_anim, NULL);
lv_anim_del(&ext->start_value_anim, NULL);
#endif
}
}
return res;
}
@@ -643,14 +657,14 @@ static lv_style_list_t * lv_bar_get_style(lv_obj_t * bar, uint8_t part)
lv_style_list_t * style_dsc_p;
switch(part) {
case LV_BAR_PART_BG:
style_dsc_p = &bar->style_list;
break;
case LV_BAR_PART_INDIC:
style_dsc_p = &ext->style_indic;
break;
default:
style_dsc_p = NULL;
case LV_BAR_PART_BG:
style_dsc_p = &bar->style_list;
break;
case LV_BAR_PART_INDIC:
style_dsc_p = &ext->style_indic;
break;
default:
style_dsc_p = NULL;
}
return style_dsc_p;
@@ -665,22 +679,25 @@ static void lv_bar_anim(lv_bar_anim_t * var, lv_anim_value_t value)
static void lv_bar_anim_ready(lv_anim_t * a)
{
lv_bar_anim_t * var = a->var;
lv_bar_ext_t * ext = lv_obj_get_ext_attr(var->bar);
lv_bar_anim_t * var = a->var;
lv_bar_ext_t * ext = lv_obj_get_ext_attr(var->bar);
var->anim_state = LV_BAR_ANIM_STATE_INV;
if(var == &ext->cur_value_anim)
ext->cur_value = var->anim_end;
else if(var == &ext->start_value_anim)
ext->start_value = var->anim_end;
lv_obj_invalidate(var->bar);
if(var == &ext->cur_value_anim)
ext->cur_value = var->anim_end;
else if(var == &ext->start_value_anim)
ext->start_value = var->anim_end;
lv_obj_invalidate(var->bar);
}
static void lv_bar_set_value_with_anim(lv_obj_t * bar, int16_t new_value, int16_t *value_ptr, lv_bar_anim_t *anim_info, lv_anim_enable_t en) {
static void lv_bar_set_value_with_anim(lv_obj_t * bar, int16_t new_value, int16_t * value_ptr,
lv_bar_anim_t * anim_info, lv_anim_enable_t en)
{
if(en == LV_ANIM_OFF) {
*value_ptr = new_value;
lv_obj_invalidate(bar);
} else {
lv_bar_ext_t *ext = lv_obj_get_ext_attr(bar);
}
else {
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
/*No animation in progress -> simply set the values*/
if(anim_info->anim_state == LV_BAR_ANIM_STATE_INV) {
anim_info->anim_start = *value_ptr;
@@ -691,8 +708,8 @@ static void lv_bar_set_value_with_anim(lv_obj_t * bar, int16_t new_value, int16_
anim_info->anim_start = anim_info->anim_end;
anim_info->anim_end = new_value;
}
/* Stop the previous animation if it exists */
lv_anim_del(anim_info, NULL);
/* Stop the previous animation if it exists */
lv_anim_del(anim_info, NULL);
lv_anim_t a;
lv_anim_init(&a);
@@ -709,10 +726,10 @@ static void lv_bar_set_value_with_anim(lv_obj_t * bar, int16_t new_value, int16_
static void lv_bar_init_anim(lv_obj_t * bar, lv_bar_anim_t * bar_anim)
{
bar_anim->bar = bar;
bar_anim->anim_start = 0;
bar_anim->anim_end = 0;
bar_anim->anim_state = LV_BAR_ANIM_STATE_INV;
bar_anim->bar = bar;
bar_anim->anim_start = 0;
bar_anim->anim_end = 0;
bar_anim->anim_state = LV_BAR_ANIM_STATE_INV;
}
#endif

View File

@@ -44,24 +44,23 @@ extern "C" {
**********************/
enum {
LV_BAR_TYPE_NORMAL,
LV_BAR_TYPE_SYM,
LV_BAR_TYPE_CUSTOM
LV_BAR_TYPE_NORMAL,
LV_BAR_TYPE_SYM,
LV_BAR_TYPE_CUSTOM
};
typedef uint8_t lv_bar_type_t;
#if LV_USE_ANIMATION
typedef struct {
lv_obj_t * bar;
lv_anim_value_t anim_start;
lv_anim_value_t anim_start;
lv_anim_value_t anim_end;
lv_anim_value_t anim_state;
lv_anim_value_t anim_state;
} lv_bar_anim_t;
#endif
/** Data of bar*/
typedef struct
{
typedef struct {
/*No inherited ext, derived from the base object */
/*New data for this type */
@@ -73,9 +72,9 @@ typedef struct
#if LV_USE_ANIMATION
lv_anim_value_t anim_time;
lv_bar_anim_t cur_value_anim;
lv_bar_anim_t start_value_anim;
lv_bar_anim_t start_value_anim;
#endif
uint8_t type : 2; /*Type of bar*/
uint8_t type : 2; /*Type of bar*/
lv_style_list_t style_indic; /*Style of the indicator*/
} lv_bar_ext_t;

View File

@@ -152,8 +152,8 @@ void lv_btn_set_state(lv_obj_t * btn, lv_btn_state_t state)
break;
}
// /*Make the state change happen immediately, without transition*/
// btn->prev_state = btn->state;
// /*Make the state change happen immediately, without transition*/
// btn->prev_state = btn->state;
}
/**
@@ -168,7 +168,8 @@ void lv_btn_toggle(lv_obj_t * btn)
if(lv_obj_get_state(btn, LV_BTN_PART_MAIN) & LV_STATE_CHECKED) {
lv_obj_clear_state(btn, LV_STATE_CHECKED);
} else {
}
else {
lv_obj_add_state(btn, LV_STATE_CHECKED);
}
}
@@ -190,10 +191,12 @@ lv_btn_state_t lv_btn_get_state(const lv_obj_t * btn)
if(state & LV_STATE_DISABLED) {
return LV_BTN_STATE_DISABLED;
} else if(state & LV_STATE_CHECKED) {
}
else if(state & LV_STATE_CHECKED) {
if(state & LV_STATE_PRESSED) return LV_BTN_STATE_CHECKED_PRESSED;
else return LV_BTN_STATE_CHECKED_RELEASED;
} else {
}
else {
if(state & LV_STATE_PRESSED) return LV_BTN_STATE_PRESSED;
else return LV_BTN_STATE_RELEASED;
}
@@ -232,9 +235,11 @@ static lv_design_res_t lv_btn_design(lv_obj_t * btn, const lv_area_t * clip_area
{
if(mode == LV_DESIGN_COVER_CHK) {
return ancestor_design(btn, clip_area, mode);
} else if(mode == LV_DESIGN_DRAW_MAIN) {
}
else if(mode == LV_DESIGN_DRAW_MAIN) {
ancestor_design(btn, clip_area, mode);
} else if(mode == LV_DESIGN_DRAW_POST) {
}
else if(mode == LV_DESIGN_DRAW_POST) {
ancestor_design(btn, clip_area, mode);
}
@@ -267,7 +272,8 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
if(lv_obj_get_state(btn, LV_BTN_PART_MAIN) & LV_STATE_CHECKED) {
lv_btn_set_state(btn, LV_BTN_STATE_RELEASED);
toggled = 0;
} else {
}
else {
lv_btn_set_state(btn, LV_BTN_STATE_CHECKED_RELEASED);
toggled = 1;
}
@@ -275,7 +281,8 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
res = lv_event_send(btn, LV_EVENT_VALUE_CHANGED, &toggled);
if(res != LV_RES_OK) return res;
}
} else if(sign == LV_SIGNAL_CONTROL) {
}
else if(sign == LV_SIGNAL_CONTROL) {
char c = *((char *)param);
if(c == LV_KEY_RIGHT || c == LV_KEY_UP) {
if(lv_btn_get_checkable(btn)) {
@@ -286,7 +293,8 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
if(res != LV_RES_OK) return res;
}
} else if(c == LV_KEY_LEFT || c == LV_KEY_DOWN) {
}
else if(c == LV_KEY_LEFT || c == LV_KEY_DOWN) {
if(lv_btn_get_checkable(btn)) {
lv_btn_set_state(btn, LV_BTN_STATE_RELEASED);

View File

@@ -46,8 +46,7 @@ enum {
typedef uint8_t lv_btn_state_t;
/** Extended data of button*/
typedef struct
{
typedef struct {
/** Ext. of ancestor*/
lv_cont_ext_t cont;
@@ -57,7 +56,7 @@ typedef struct
/**Styles*/
enum {
LV_BTN_PART_MAIN = LV_OBJ_PART_MAIN ,
LV_BTN_PART_MAIN = LV_OBJ_PART_MAIN,
_LV_BTN_PART_VIRTUAL_LAST,
_LV_BTN_PART_REAL_LAST = _LV_OBJ_PART_REAL_LAST,
};

View File

@@ -112,9 +112,9 @@ lv_obj_t * lv_btnmatrix_create(lv_obj_t * par, const lv_obj_t * copy)
}
/*Copy an existing object*/
else {
// lv_btnmatrix_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
// memcpy((void*)ext->styles_btn, copy_ext->styles_btn, sizeof(ext->styles_btn));
// lv_btnmatrix_set_map(new_btnm, lv_btnmatrix_get_map_array(copy));
// lv_btnmatrix_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
// memcpy((void*)ext->styles_btn, copy_ext->styles_btn, sizeof(ext->styles_btn));
// lv_btnmatrix_set_map(new_btnm, lv_btnmatrix_get_map_array(copy));
}
LV_LOG_INFO("button matrix created");
@@ -199,7 +199,7 @@ void lv_btnmatrix_set_map(lv_obj_t * btnm, const char * map[])
/*Make sure the last row is at the bottom of 'btnm'*/
if(map_p_tmp[btn_cnt][0] == '\0') { /*Last row?*/
btn_h = lv_obj_get_height(btnm)- act_y - bottom - 1;
btn_h = lv_obj_get_height(btnm) - act_y - bottom - 1;
}
lv_bidi_dir_t base_dir = lv_obj_get_base_dir(btnm);
@@ -225,7 +225,8 @@ void lv_btnmatrix_set_map(lv_obj_t * btnm, const char * map[])
if(base_dir == LV_BIDI_DIR_RTL) {
act_x = (unit_act_cnt * all_unit_w) / unit_cnt + i * inner;
act_x = lv_obj_get_width(btnm) - right - act_x - act_unit_w - 1;
} else {
}
else {
act_x = (unit_act_cnt * all_unit_w) / unit_cnt + i * inner +
left;
}
@@ -235,7 +236,8 @@ void lv_btnmatrix_set_map(lv_obj_t * btnm, const char * map[])
if(inner == 0 && act_x != left) {
lv_area_set(&ext->button_areas[btn_i], ext->button_areas[btn_i - 1].x2, act_y, act_x + act_unit_w,
act_y + btn_h);
} else {
}
else {
lv_area_set(&ext->button_areas[btn_i], act_x, act_y, act_x + act_unit_w, act_y + btn_h);
}
@@ -480,7 +482,8 @@ const char * lv_btnmatrix_get_active_btn_text(const lv_obj_t * btnm)
lv_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);
if(ext->btn_id_act != LV_BTNMATRIX_BTN_NONE) {
return lv_btnmatrix_get_btn_text(btnm, ext->btn_id_act);
} else {
}
else {
return NULL;
}
}
@@ -652,29 +655,29 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl
bool tgl_state = button_get_tgl_state(ext->ctrl_bits[btn_i]);
if(tgl_state) {
if(!chk_inited) {
btnm->state = LV_STATE_CHECKED;
lv_draw_rect_dsc_init(&draw_rect_chk_dsc);
lv_draw_label_dsc_init(&draw_label_chk_dsc);
lv_obj_init_draw_rect_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_rect_chk_dsc);
lv_obj_init_draw_label_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_label_chk_dsc);
draw_label_chk_dsc.flag = txt_flag;
btnm->state = state_ori;
chk_inited = true;
}
if(!chk_inited) {
btnm->state = LV_STATE_CHECKED;
lv_draw_rect_dsc_init(&draw_rect_chk_dsc);
lv_draw_label_dsc_init(&draw_label_chk_dsc);
lv_obj_init_draw_rect_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_rect_chk_dsc);
lv_obj_init_draw_label_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_label_chk_dsc);
draw_label_chk_dsc.flag = txt_flag;
btnm->state = state_ori;
chk_inited = true;
}
}
if(button_is_inactive(ext->ctrl_bits[btn_i])) {
if(!disabled_inited) {
btnm->state = LV_STATE_DISABLED;
lv_draw_rect_dsc_init(&draw_rect_ina_dsc);
lv_draw_label_dsc_init(&draw_label_ina_dsc);
lv_obj_init_draw_rect_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_rect_ina_dsc);
lv_obj_init_draw_label_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_label_ina_dsc);
draw_label_ina_dsc.flag = txt_flag;
btnm->state = state_ori;
disabled_inited = true;
}
if(!disabled_inited) {
btnm->state = LV_STATE_DISABLED;
lv_draw_rect_dsc_init(&draw_rect_ina_dsc);
lv_draw_label_dsc_init(&draw_label_ina_dsc);
lv_obj_init_draw_rect_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_rect_ina_dsc);
lv_obj_init_draw_label_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_label_ina_dsc);
draw_label_ina_dsc.flag = txt_flag;
btnm->state = state_ori;
disabled_inited = true;
}
draw_rect_dsc_act = &draw_rect_ina_dsc;
draw_label_dsc_act = &draw_label_ina_dsc;
}
@@ -716,7 +719,8 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl
/*Left/right columns*/
if(txt_i == 0) { /*First button*/
draw_rect_dsc_act->border_side &= ~LV_BORDER_SIDE_LEFT;
} else if(strcmp(ext->map_p[txt_i - 1], "\n") == 0) {
}
else if(strcmp(ext->map_p[txt_i - 1], "\n") == 0) {
draw_rect_dsc_act->border_side &= ~LV_BORDER_SIDE_LEFT;
}
@@ -745,7 +749,8 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl
lv_draw_label(&area_tmp, clip_area, draw_label_dsc_act, txt, NULL);
}
} else if(mode == LV_DESIGN_DRAW_POST) {
}
else if(mode == LV_DESIGN_DRAW_POST) {
ancestor_design_f(btnm, clip_area, mode);
}
return LV_DESIGN_RES_OK;
@@ -779,13 +784,16 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * pa
lv_obj_clean_style_list(btnm, LV_BTNMATRIX_PART_BTN);
lv_mem_free(ext->button_areas);
lv_mem_free(ext->ctrl_bits);
} else if(sign == LV_SIGNAL_STYLE_CHG) {
}
else if(sign == LV_SIGNAL_STYLE_CHG) {
lv_btnmatrix_set_map(btnm, ext->map_p);
} else if(sign == LV_SIGNAL_COORD_CHG) {
}
else if(sign == LV_SIGNAL_COORD_CHG) {
if(lv_obj_get_width(btnm) != lv_area_get_width(param) || lv_obj_get_height(btnm) != lv_area_get_height(param)) {
lv_btnmatrix_set_map(btnm, ext->map_p);
}
} else if(sign == LV_SIGNAL_PRESSED) {
}
else if(sign == LV_SIGNAL_PRESSED) {
invalidate_button_area(btnm, ext->btn_id_pr);
lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
@@ -797,7 +805,7 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * pa
/*Handle the case where there is no button there*/
if(btn_pr != LV_BTNMATRIX_BTN_NONE) {
if(button_is_inactive(ext->ctrl_bits[btn_pr]) == false &&
button_is_hidden(ext->ctrl_bits[btn_pr]) == false) {
button_is_hidden(ext->ctrl_bits[btn_pr]) == false) {
invalidate_button_area(btnm, ext->btn_id_pr) /*Invalidate the old area*/;
ext->btn_id_pr = btn_pr;
ext->btn_id_act = btn_pr;
@@ -806,7 +814,8 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * pa
}
}
#if LV_USE_GROUP
else if(indev_type == LV_INDEV_TYPE_KEYPAD || (indev_type == LV_INDEV_TYPE_ENCODER && lv_group_get_editing(lv_obj_get_group(btnm)))) {
else if(indev_type == LV_INDEV_TYPE_KEYPAD || (indev_type == LV_INDEV_TYPE_ENCODER &&
lv_group_get_editing(lv_obj_get_group(btnm)))) {
ext->btn_id_pr = ext->btn_id_focused;
invalidate_button_area(btnm, ext->btn_id_focused);
}
@@ -820,7 +829,8 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * pa
res = lv_event_send(btnm, LV_EVENT_VALUE_CHANGED, &b);
}
}
} else if(sign == LV_SIGNAL_PRESSING) {
}
else if(sign == LV_SIGNAL_PRESSING) {
uint16_t btn_pr;
/*Search the pressed area*/
lv_indev_get_point(param, &p);
@@ -845,14 +855,16 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * pa
ext->btn_id_pr = btn_pr;
ext->btn_id_act = btn_pr;
} else if(sign == LV_SIGNAL_RELEASED) {
}
else if(sign == LV_SIGNAL_RELEASED) {
if(ext->btn_id_pr != LV_BTNMATRIX_BTN_NONE) {
/*Toggle the button if enabled*/
if(button_is_tgl_enabled(ext->ctrl_bits[ext->btn_id_pr]) &&
!button_is_inactive(ext->ctrl_bits[ext->btn_id_pr])) {
!button_is_inactive(ext->ctrl_bits[ext->btn_id_pr])) {
if(button_get_tgl_state(ext->ctrl_bits[ext->btn_id_pr])) {
ext->ctrl_bits[ext->btn_id_pr] &= (~LV_BTNMATRIX_CTRL_CHECK_STATE);
} else {
}
else {
ext->ctrl_bits[ext->btn_id_pr] |= LV_BTNMATRIX_CTRL_CHECK_STATE;
}
if(ext->one_toggle) make_one_button_toggled(btnm, ext->btn_id_pr);
@@ -877,7 +889,8 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * pa
res = lv_event_send(btnm, LV_EVENT_VALUE_CHANGED, &b);
}
}
} else if(sign == LV_SIGNAL_LONG_PRESS_REP) {
}
else if(sign == LV_SIGNAL_LONG_PRESS_REP) {
if(ext->btn_id_act != LV_BTNMATRIX_BTN_NONE) {
if(button_is_repeat_disabled(ext->ctrl_bits[ext->btn_id_act]) == false &&
button_is_inactive(ext->ctrl_bits[ext->btn_id_act]) == false &&
@@ -886,11 +899,13 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * pa
res = lv_event_send(btnm, LV_EVENT_VALUE_CHANGED, &b);
}
}
} else if(sign == LV_SIGNAL_PRESS_LOST) {
}
else if(sign == LV_SIGNAL_PRESS_LOST) {
ext->btn_id_pr = LV_BTNMATRIX_BTN_NONE;
ext->btn_id_act = LV_BTNMATRIX_BTN_NONE;
lv_obj_invalidate(btnm);
} else if(sign == LV_SIGNAL_FOCUS) {
}
else if(sign == LV_SIGNAL_FOCUS) {
#if LV_USE_GROUP
lv_indev_t * indev = lv_indev_get_act();
lv_indev_type_t indev_type = lv_indev_get_type(indev);
@@ -901,14 +916,16 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * pa
indev_type = lv_indev_get_type(indev);
}
if(indev_type == LV_INDEV_TYPE_ENCODER) {
if(indev_type == LV_INDEV_TYPE_ENCODER) {
/*In navigation mode don't select any button but in edit mode select the fist*/
if(lv_group_get_editing(lv_obj_get_group(btnm))) {
ext->btn_id_focused = 0;
} else {
}
else {
ext->btn_id_focused = LV_BTNMATRIX_BTN_NONE;
}
} else if (indev_type == LV_INDEV_TYPE_KEYPAD) {
}
else if(indev_type == LV_INDEV_TYPE_KEYPAD) {
ext->btn_id_focused = 0;
}
@@ -921,7 +938,8 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * pa
ext->btn_id_focused = LV_BTNMATRIX_BTN_NONE;
ext->btn_id_pr = LV_BTNMATRIX_BTN_NONE;
ext->btn_id_act = LV_BTNMATRIX_BTN_NONE;
} else if(sign == LV_SIGNAL_CONTROL) {
}
else if(sign == LV_SIGNAL_CONTROL) {
char c = *((char *)param);
if(c == LV_KEY_RIGHT) {
if(ext->btn_id_focused == LV_BTNMATRIX_BTN_NONE)
@@ -931,17 +949,20 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * pa
if(ext->btn_id_focused >= ext->btn_cnt - 1) ext->btn_id_focused = ext->btn_cnt - 1;
ext->btn_id_act = ext->btn_id_focused;
lv_obj_invalidate(btnm);
} else if(c == LV_KEY_LEFT) {
}
else if(c == LV_KEY_LEFT) {
if(ext->btn_id_focused == LV_BTNMATRIX_BTN_NONE) ext->btn_id_focused = 0;
if(ext->btn_id_focused > 0) ext->btn_id_focused--;
ext->btn_id_act = ext->btn_id_focused;
lv_obj_invalidate(btnm);
} else if(c == LV_KEY_DOWN) {
}
else if(c == LV_KEY_DOWN) {
lv_style_int_t pad_inner = lv_obj_get_style_pad_inner(btnm, LV_BTNMATRIX_PART_BG);
/*Find the area below the the current*/
if(ext->btn_id_focused == LV_BTNMATRIX_BTN_NONE) {
ext->btn_id_focused = 0;
} else {
}
else {
uint16_t area_below;
lv_coord_t pr_center =
ext->button_areas[ext->btn_id_focused].x1 + (lv_area_get_width(&ext->button_areas[ext->btn_id_focused]) >> 1);
@@ -960,12 +981,14 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * pa
}
ext->btn_id_act = ext->btn_id_focused;
lv_obj_invalidate(btnm);
} else if(c == LV_KEY_UP) {
}
else if(c == LV_KEY_UP) {
lv_style_int_t pad_inner = lv_obj_get_style_pad_inner(btnm, LV_BTNMATRIX_PART_BG);
/*Find the area below the the current*/
if(ext->btn_id_focused == LV_BTNMATRIX_BTN_NONE) {
ext->btn_id_focused = 0;
} else {
}
else {
int16_t area_above;
lv_coord_t pr_center =
ext->button_areas[ext->btn_id_focused].x1 + (lv_area_get_width(&ext->button_areas[ext->btn_id_focused]) >> 1);
@@ -984,7 +1007,8 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * pa
ext->btn_id_act = ext->btn_id_focused;
lv_obj_invalidate(btnm);
}
} else if(sign == LV_SIGNAL_GET_EDITABLE) {
}
else if(sign == LV_SIGNAL_GET_EDITABLE) {
bool * editable = (bool *)param;
*editable = true;
}
@@ -1006,14 +1030,14 @@ static lv_style_list_t * lv_btnmatrix_get_style(lv_obj_t * btnm, uint8_t part)
lv_style_list_t * style_dsc_p;
switch(part) {
case LV_BTNMATRIX_PART_BG:
style_dsc_p = &btnm->style_list;
break;
case LV_BTNMATRIX_PART_BTN:
style_dsc_p = &ext->style_btn;
break;
default:
style_dsc_p = NULL;
case LV_BTNMATRIX_PART_BG:
style_dsc_p = &btnm->style_list;
break;
case LV_BTNMATRIX_PART_BTN:
style_dsc_p = &ext->style_btn;
break;
default:
style_dsc_p = NULL;
}
return style_dsc_p;

View File

@@ -46,8 +46,7 @@ enum {
typedef uint16_t lv_btnmatrix_ctrl_t;
/*Data of button matrix*/
typedef struct
{
typedef struct {
/*No inherited ext.*/ /*Ext. of ancestor*/
/*New data for this type */
const char ** map_p; /*Pointer to the current map*/

View File

@@ -59,7 +59,8 @@ static lv_signal_cb_t ancestor_signal;
static lv_design_cb_t ancestor_design;
static const char * day_name[7] = {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"};
static const char * month_name[12] = {"January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"};
"July", "August", "September", "October", "November", "December"
};
/**********************
* MACROS
@@ -131,7 +132,7 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
if(copy == NULL) {
lv_theme_apply(calendar, LV_THEME_CALENDAR);
lv_obj_set_size(calendar, 5*LV_DPI/2, 5*LV_DPI/2);
lv_obj_set_size(calendar, 5 * LV_DPI / 2, 5 * LV_DPI / 2);
}
/*Copy an existing calendar*/
@@ -153,7 +154,7 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
ext->style_header = copy_ext->style_header;
ext->style_day_names = copy_ext->style_day_names;
/*Refresh the style with new signal function*/
// lv_obj_refresh_style(new_calendar);
// lv_obj_refresh_style(new_calendar);
}
LV_LOG_INFO("calendar created");
@@ -432,7 +433,8 @@ static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void *
lv_obj_clean_style_list(calendar, LV_CALENDAR_PART_HEADER);
lv_obj_clean_style_list(calendar, LV_CALENDAR_PART_DAY_NAMES);
lv_obj_clean_style_list(calendar, LV_CALENDAR_PART_DATE);
} else if(sign == LV_SIGNAL_PRESSING) {
}
else if(sign == LV_SIGNAL_PRESSING) {
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
lv_area_t header_area;
lv_area_copy(&header_area, &calendar->coords);
@@ -447,7 +449,8 @@ static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void *
if(p.x < header_area.x1 + lv_area_get_width(&header_area) / 2) {
if(ext->btn_pressing != -1) lv_obj_invalidate(calendar);
ext->btn_pressing = -1;
} else {
}
else {
if(ext->btn_pressing != 1) lv_obj_invalidate(calendar);
ext->btn_pressing = 1;
}
@@ -469,7 +472,8 @@ static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void *
ext->pressed_date.month = 0;
ext->pressed_date.day = 0;
}
} else if(sign == LV_SIGNAL_PRESS_LOST) {
}
else if(sign == LV_SIGNAL_PRESS_LOST) {
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
ext->btn_pressing = 0;
ext->pressed_date.year = 0;
@@ -477,23 +481,28 @@ static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void *
ext->pressed_date.day = 0;
lv_obj_invalidate(calendar);
} else if(sign == LV_SIGNAL_RELEASED) {
}
else if(sign == LV_SIGNAL_RELEASED) {
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
if(ext->btn_pressing < 0) {
if(ext->showed_date.month <= 1) {
ext->showed_date.month = 12;
ext->showed_date.year--;
} else {
}
else {
ext->showed_date.month--;
}
} else if(ext->btn_pressing > 0) {
}
else if(ext->btn_pressing > 0) {
if(ext->showed_date.month >= 12) {
ext->showed_date.month = 1;
ext->showed_date.year++;
} else {
}
else {
ext->showed_date.month++;
}
} else if(ext->pressed_date.year != 0) {
}
else if(ext->pressed_date.year != 0) {
res = lv_event_send(calendar, LV_EVENT_VALUE_CHANGED, NULL);
if(res != LV_RES_OK) return res;
@@ -504,22 +513,26 @@ static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void *
ext->pressed_date.month = 0;
ext->pressed_date.day = 0;
lv_obj_invalidate(calendar);
} else if(sign == LV_SIGNAL_CONTROL) {
}
else if(sign == LV_SIGNAL_CONTROL) {
uint8_t c = *((uint8_t *)param);
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
if(c == LV_KEY_RIGHT || c == LV_KEY_UP) {
if(ext->showed_date.month >= 12) {
ext->showed_date.month = 1;
ext->showed_date.year++;
} else {
}
else {
ext->showed_date.month++;
}
lv_obj_invalidate(calendar);
} else if(c == LV_KEY_LEFT || c == LV_KEY_DOWN) {
}
else if(c == LV_KEY_LEFT || c == LV_KEY_DOWN) {
if(ext->showed_date.month <= 1) {
ext->showed_date.month = 12;
ext->showed_date.year--;
} else {
}
else {
ext->showed_date.month--;
}
lv_obj_invalidate(calendar);
@@ -544,20 +557,20 @@ static lv_style_list_t * lv_calendar_get_style(lv_obj_t * calendar, uint8_t part
switch(part) {
case LV_CALENDAR_PART_BG:
style_dsc_p = &calendar->style_list;
break;
case LV_CALENDAR_PART_HEADER:
style_dsc_p = &ext->style_header;
break;
case LV_CALENDAR_PART_DAY_NAMES:
style_dsc_p = &ext->style_day_names;
break;
case LV_CALENDAR_PART_DATE:
style_dsc_p = &ext->style_date_nums;
break;
default:
style_dsc_p = NULL;
case LV_CALENDAR_PART_BG:
style_dsc_p = &calendar->style_list;
break;
case LV_CALENDAR_PART_HEADER:
style_dsc_p = &ext->style_header;
break;
case LV_CALENDAR_PART_DAY_NAMES:
style_dsc_p = &ext->style_day_names;
break;
case LV_CALENDAR_PART_DATE:
style_dsc_p = &ext->style_date_nums;
break;
default:
style_dsc_p = NULL;
}
return style_dsc_p;
@@ -602,20 +615,23 @@ static bool calculate_touched_day(lv_obj_t * calendar, const lv_point_t * touche
ext->pressed_date.year = ext->showed_date.year - (ext->showed_date.month == 1 ? 1 : 0);
ext->pressed_date.month = ext->showed_date.month == 1 ? 12 : (ext->showed_date.month - 1);
ext->pressed_date.day = get_month_length(ext->pressed_date.year, ext->pressed_date.month) -
get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1) + 1 + i_pos;
} else if(i_pos < (get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1) +
get_month_length(ext->showed_date.year, ext->showed_date.month))) {
get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1) + 1 + i_pos;
}
else if(i_pos < (get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1) +
get_month_length(ext->showed_date.year, ext->showed_date.month))) {
ext->pressed_date.year = ext->showed_date.year;
ext->pressed_date.month = ext->showed_date.month;
ext->pressed_date.day = i_pos + 1 - get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1);
} else if(i_pos < 42) {
}
else if(i_pos < 42) {
ext->pressed_date.year = ext->showed_date.year + (ext->showed_date.month == 12 ? 1 : 0);
ext->pressed_date.month = ext->showed_date.month == 12 ? 1 : (ext->showed_date.month + 1);
ext->pressed_date.day = i_pos + 1 - get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1) -
get_month_length(ext->showed_date.year, ext->showed_date.month);
get_month_length(ext->showed_date.year, ext->showed_date.month);
}
return true;
} else {
}
else {
return false;
}
}
@@ -688,7 +704,7 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask)
lv_draw_label_dsc_init(&label_dsc);
lv_obj_init_draw_label_dsc(calendar, LV_CALENDAR_PART_HEADER, &label_dsc);
label_dsc.flag = LV_TXT_FLAG_CENTER;
lv_draw_label(&header_area, mask, &label_dsc,txt_buf, NULL);
lv_draw_label(&header_area, mask, &label_dsc, txt_buf, NULL);
calendar->state = state_ori; /*Restore the state*/
@@ -708,7 +724,8 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask)
if(ext->btn_pressing > 0) calendar->state |= LV_STATE_PRESSED;
else calendar->state &= ~(LV_STATE_PRESSED);
header_area.x1 = header_area.x2 - header_right - lv_txt_get_width(LV_SYMBOL_RIGHT, (uint16_t)strlen(LV_SYMBOL_RIGHT), font, 0, LV_TXT_FLAG_NONE);
header_area.x1 = header_area.x2 - header_right - lv_txt_get_width(LV_SYMBOL_RIGHT, (uint16_t)strlen(LV_SYMBOL_RIGHT),
font, 0, LV_TXT_FLAG_NONE);
lv_draw_label_dsc_init(&label_dsc);
lv_obj_init_draw_label_dsc(calendar, LV_CALENDAR_PART_HEADER, &label_dsc);
@@ -805,7 +822,8 @@ static void draw_dates(lv_obj_t * calendar, const lv_area_t * clip_area)
day_cnt = 1;
draw_state = DAY_DRAW_ACT_MONTH;
month_state = 0;
} else {
}
else {
draw_state = DAY_DRAW_PREV_MONTH;
day_cnt = get_month_length(ext->showed_date.year, ext->showed_date.month - 1); /*Length of the previous month*/
day_cnt -= month_start_day - 1; /*First visible number of the previous month*/
@@ -850,7 +868,7 @@ static void draw_dates(lv_obj_t * calendar, const lv_area_t * clip_area)
}
/*The current month is over*/
else if(draw_state == DAY_DRAW_ACT_MONTH &&
day_cnt > get_month_length(ext->showed_date.year, ext->showed_date.month)) {
day_cnt > get_month_length(ext->showed_date.year, ext->showed_date.month)) {
draw_state = DAY_DRAW_NEXT_MONTH;
day_cnt = 1;
month_state = LV_STATE_DISABLED;
@@ -923,7 +941,8 @@ static bool is_highlighted(lv_obj_t * calendar, day_draw_state_t draw_state, int
if(draw_state == DAY_DRAW_PREV_MONTH) {
year -= month == 1 ? 1 : 0;
month = month == 1 ? 12 : month - 1;
} else if(draw_state == DAY_DRAW_NEXT_MONTH) {
}
else if(draw_state == DAY_DRAW_NEXT_MONTH) {
year += month == 12 ? 1 : 0;
month = month == 12 ? 1 : month + 1;
}
@@ -956,7 +975,8 @@ static bool is_pressed(lv_obj_t * calendar, day_draw_state_t draw_state, int32_t
if(draw_state == DAY_DRAW_PREV_MONTH) {
year -= month == 1 ? 1 : 0;
month = month == 1 ? 12 : month - 1;
} else if(draw_state == DAY_DRAW_NEXT_MONTH) {
}
else if(draw_state == DAY_DRAW_NEXT_MONTH) {
year += month == 12 ? 1 : 0;
month = month == 12 ? 1 : month + 1;
}

View File

@@ -30,16 +30,14 @@ extern "C" {
/**
* Represents a date on the calendar object (platform-agnostic).
*/
typedef struct
{
typedef struct {
uint16_t year;
int8_t month;
int8_t day;
} lv_calendar_date_t;
/*Data of calendar*/
typedef struct
{
typedef struct {
/*None*/ /*Ext. of ancestor*/
/*New data for this type */
lv_calendar_date_t today; /*Date of today*/

View File

@@ -31,21 +31,22 @@
static lv_res_t lv_canvas_signal(lv_obj_t * canvas, lv_signal_t sign, void * param);
static void set_set_px_cb(lv_disp_drv_t * disp_drv, lv_img_cf_t cf);
static void set_px_true_color_alpha(lv_disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
lv_color_t color, lv_opa_t opa);
static void set_px_true_color_alpha(lv_disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x,
lv_coord_t y,
lv_color_t color, lv_opa_t opa);
static void set_px_cb_alpha1(lv_disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
lv_color_t color, lv_opa_t opa);
lv_color_t color, lv_opa_t opa);
static void set_px_cb_alpha2(lv_disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
lv_color_t color, lv_opa_t opa);
lv_color_t color, lv_opa_t opa);
static void set_px_cb_alpha4(lv_disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
lv_color_t color, lv_opa_t opa);
lv_color_t color, lv_opa_t opa);
static void set_px_cb_alpha8(lv_disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
lv_color_t color, lv_opa_t opa);
lv_color_t color, lv_opa_t opa);
static void set_px_alpha_generic(lv_img_dsc_t * d, lv_coord_t x, lv_coord_t y, lv_color_t color, lv_opa_t opa);
@@ -274,8 +275,9 @@ void lv_canvas_copy_buf(lv_obj_t * canvas, const void * to_copy, lv_coord_t x, l
* Set to `source height / 2` to rotate around the center
* @param antialias apply anti-aliasing during the transformation. Looks better but slower.
*/
void lv_canvas_transform(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle, uint16_t zoom, lv_coord_t offset_x, lv_coord_t offset_y,
int32_t pivot_x, int32_t pivot_y, bool antialias)
void lv_canvas_transform(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle, uint16_t zoom, lv_coord_t offset_x,
lv_coord_t offset_y,
int32_t pivot_x, int32_t pivot_y, bool antialias)
{
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
LV_ASSERT_NULL(img);
@@ -314,7 +316,8 @@ void lv_canvas_transform(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle, u
/*If the image has no alpha channel just simple set the result color on the canvas*/
if(lv_img_cf_has_alpha(img->header.cf) == false) {
lv_img_buf_set_px_color(&ext_dst->dsc, x + offset_x, y + offset_y, dsc.res.color);
} else {
}
else {
lv_color_t bg_color = lv_img_buf_get_px_color(&ext_dst->dsc, x + offset_x, y + offset_y, dsc.cfg.color);
/*If the canvas has no alpha but the image has mix the image's color with
@@ -384,7 +387,8 @@ void lv_canvas_blur_hor(lv_obj_t * canvas, const lv_area_t * area, uint16_t r)
if(a.y1 < 0) a.y1 = 0;
if(a.x2 > ext->dsc.header.w - 1) a.x2 = ext->dsc.header.w - 1;
if(a.y2 > ext->dsc.header.h - 1) a.y2 = ext->dsc.header.h - 1;
} else {
}
else {
a.x1 = 0;
a.y1 = 0;
a.x2 = ext->dsc.header.w - 1;
@@ -425,7 +429,7 @@ void lv_canvas_blur_hor(lv_obj_t * canvas, const lv_area_t * area, uint16_t r)
memcpy(line_buf, &ext->dsc.data[y * line_w], line_w);
for(x = a.x1 -r_back; x <= a.x1 + r_front; x++) {
for(x = a.x1 - r_back; x <= a.x1 + r_front; x++) {
x_safe = x < 0 ? 0 : x;
x_safe = x_safe > ext->dsc.header.w - 1 ? ext->dsc.header.w - 1 : x_safe;
@@ -447,8 +451,8 @@ void lv_canvas_blur_hor(lv_obj_t * canvas, const lv_area_t * area, uint16_t r)
for(x = a.x1; x <= a.x2; x++) {
if(asum) {
c.ch.red = rsum / r;
if(asum) {
c.ch.red = rsum / r;
#if LV_COLOR_DEPTH == 16 && LV_COLOR_16_SWAP
uint8_t gtmp = gsum / r;
c.ch.green_h = gtmp >> 3;
@@ -456,12 +460,12 @@ void lv_canvas_blur_hor(lv_obj_t * canvas, const lv_area_t * area, uint16_t r)
#else
c.ch.green = gsum / r;
#endif
c.ch.blue = bsum / r;
if(has_alpha) opa = asum / r;
c.ch.blue = bsum / r;
if(has_alpha) opa = asum / r;
lv_img_buf_set_px_color(&ext->dsc, x, y, c);
}
if(has_alpha) lv_img_buf_set_px_alpha(&ext->dsc, x, y, opa);
lv_img_buf_set_px_color(&ext->dsc, x, y, c);
}
if(has_alpha) lv_img_buf_set_px_alpha(&ext->dsc, x, y, opa);
x_safe = x - r_back;
x_safe = x_safe < 0 ? 0 : x_safe;
@@ -519,7 +523,8 @@ void lv_canvas_blur_ver(lv_obj_t * canvas, const lv_area_t * area, uint16_t r)
if(a.y1 < 0) a.y1 = 0;
if(a.x2 > ext->dsc.header.w - 1) a.x2 = ext->dsc.header.w - 1;
if(a.y2 > ext->dsc.header.h - 1) a.y2 = ext->dsc.header.h - 1;
} else {
}
else {
a.x1 = 0;
a.y1 = 0;
a.x2 = ext->dsc.header.w - 1;
@@ -557,7 +562,7 @@ void lv_canvas_blur_ver(lv_obj_t * canvas, const lv_area_t * area, uint16_t r)
lv_color_t c;
lv_opa_t opa = LV_OPA_COVER;
for(y = a.y1 -r_back; y <= a.y1 + r_front; y++) {
for(y = a.y1 - r_back; y <= a.y1 + r_front; y++) {
y_safe = y < 0 ? 0 : y;
y_safe = y_safe > ext->dsc.header.h - 1 ? ext->dsc.header.h - 1 : y_safe;
@@ -581,21 +586,21 @@ void lv_canvas_blur_ver(lv_obj_t * canvas, const lv_area_t * area, uint16_t r)
if(has_alpha == false) asum = LV_OPA_COVER;
for(y = a.y1; y <= a.y2; y++) {
if(asum) {
c.ch.red = rsum / r;
if(asum) {
c.ch.red = rsum / r;
#if LV_COLOR_DEPTH == 16 && LV_COLOR_16_SWAP
uint8_t gtmp = gsum / r;
uint8_t gtmp = gsum / r;
c.ch.green_h = gtmp >> 3;
c.ch.green_l = gtmp & 0x7;
#else
c.ch.green = gsum / r;
#endif
c.ch.blue = bsum / r;
if(has_alpha) opa = asum / r;
c.ch.blue = bsum / r;
if(has_alpha) opa = asum / r;
lv_img_buf_set_px_color(&ext->dsc, x, y, c);
}
if(has_alpha) lv_img_buf_set_px_alpha(&ext->dsc, x, y, opa);
lv_img_buf_set_px_color(&ext->dsc, x, y, c);
}
if(has_alpha) lv_img_buf_set_px_alpha(&ext->dsc, x, y, opa);
y_safe = y - r_back;
y_safe = y_safe < 0 ? 0 : y_safe;
@@ -714,8 +719,7 @@ void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord
/*Disable anti-aliasing if drawing with transparent color to chroma keyed canvas*/
lv_color_t ctransp = LV_COLOR_TRANSP;
if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED &&
rect_dsc->bg_color.full == ctransp.full)
{
rect_dsc->bg_color.full == ctransp.full) {
disp.driver.antialiasing = 0;
}
#endif
@@ -740,7 +744,8 @@ void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord
* @param txt text to display
* @param align align of the text (`LV_LABEL_ALIGN_LEFT/RIGHT/CENTER`)
*/
void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t max_w, lv_draw_label_dsc_t * label_draw_dsc,
void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t max_w,
lv_draw_label_dsc_t * label_draw_dsc,
const char * txt, lv_label_align_t align)
{
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
@@ -786,10 +791,18 @@ void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord
lv_txt_flag_t flag;
switch(align) {
case LV_LABEL_ALIGN_LEFT: flag = LV_TXT_FLAG_NONE; break;
case LV_LABEL_ALIGN_RIGHT: flag = LV_TXT_FLAG_RIGHT; break;
case LV_LABEL_ALIGN_CENTER: flag = LV_TXT_FLAG_CENTER; break;
default: flag = LV_TXT_FLAG_NONE; break;
case LV_LABEL_ALIGN_LEFT:
flag = LV_TXT_FLAG_NONE;
break;
case LV_LABEL_ALIGN_RIGHT:
flag = LV_TXT_FLAG_RIGHT;
break;
case LV_LABEL_ALIGN_CENTER:
flag = LV_TXT_FLAG_CENTER;
break;
default:
flag = LV_TXT_FLAG_NONE;
break;
}
label_draw_dsc->flag = flag;
@@ -807,7 +820,8 @@ void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord
* @param src image source. Can be a pointer an `lv_img_dsc_t` variable or a path an image.
* @param style style of the image (`image` properties are used)
*/
void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const void * src, lv_draw_img_dsc_t * img_draw_dsc)
void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const void * src,
lv_draw_img_dsc_t * img_draw_dsc)
{
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
@@ -871,7 +885,8 @@ void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const voi
* @param point_cnt number of points
* @param style style of the line (`line` properties are used)
*/
void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t * points, uint32_t point_cnt, lv_draw_line_dsc_t * line_draw_dsc)
void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t * points, uint32_t point_cnt,
lv_draw_line_dsc_t * line_draw_dsc)
{
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
@@ -908,8 +923,7 @@ void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t * points, uint32_t
/*Disable anti-aliasing if drawing with transparent color to chroma keyed canvas*/
lv_color_t ctransp = LV_COLOR_TRANSP;
if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED &&
line_draw_dsc->color.full == ctransp.full)
{
line_draw_dsc->color.full == ctransp.full) {
disp.driver.antialiasing = 0;
}
#endif
@@ -934,7 +948,8 @@ void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t * points, uint32_t
* @param point_cnt number of points
* @param style style of the polygon (`body.main_color` and `body.opa` is used)
*/
void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t * points, uint32_t point_cnt, lv_draw_rect_dsc_t * poly_draw_dsc)
void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t * points, uint32_t point_cnt,
lv_draw_rect_dsc_t * poly_draw_dsc)
{
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
@@ -972,8 +987,7 @@ void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t * points, uint32
/*Disable anti-aliasing if drawing with transparent color to chroma keyed canvas*/
lv_color_t ctransp = LV_COLOR_TRANSP;
if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED &&
poly_draw_dsc->bg_color.full == ctransp.full)
{
poly_draw_dsc->bg_color.full == ctransp.full) {
disp.driver.antialiasing = 0;
}
#endif
@@ -981,7 +995,7 @@ void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t * points, uint32
lv_disp_t * refr_ori = lv_refr_get_disp_refreshing();
lv_refr_set_disp_refreshing(&disp);
// lv_draw_polygon(points, point_cnt, &mask, poly_draw_dsc);
// lv_draw_polygon(points, point_cnt, &mask, poly_draw_dsc);
lv_refr_set_disp_refreshing(refr_ori);
@@ -1037,8 +1051,7 @@ void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_
/*Disable anti-aliasing if drawing with transparent color to chroma keyed canvas*/
lv_color_t ctransp = LV_COLOR_TRANSP;
if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED &&
arc_draw_dsc->color.full == ctransp.full)
{
arc_draw_dsc->color.full == ctransp.full) {
disp.driver.antialiasing = 0;
}
#endif
@@ -1083,17 +1096,28 @@ static lv_res_t lv_canvas_signal(lv_obj_t * canvas, lv_signal_t sign, void * par
static void set_set_px_cb(lv_disp_drv_t * disp_drv, lv_img_cf_t cf)
{
switch(cf) {
case LV_IMG_CF_TRUE_COLOR_ALPHA: disp_drv->set_px_cb = set_px_true_color_alpha; break;
case LV_IMG_CF_ALPHA_1BIT: disp_drv->set_px_cb = set_px_cb_alpha1; break;
case LV_IMG_CF_ALPHA_2BIT: disp_drv->set_px_cb = set_px_cb_alpha2; break;
case LV_IMG_CF_ALPHA_4BIT: disp_drv->set_px_cb = set_px_cb_alpha4; break;
case LV_IMG_CF_ALPHA_8BIT: disp_drv->set_px_cb = set_px_cb_alpha8; break;
default: disp_drv->set_px_cb = NULL;
case LV_IMG_CF_TRUE_COLOR_ALPHA:
disp_drv->set_px_cb = set_px_true_color_alpha;
break;
case LV_IMG_CF_ALPHA_1BIT:
disp_drv->set_px_cb = set_px_cb_alpha1;
break;
case LV_IMG_CF_ALPHA_2BIT:
disp_drv->set_px_cb = set_px_cb_alpha2;
break;
case LV_IMG_CF_ALPHA_4BIT:
disp_drv->set_px_cb = set_px_cb_alpha4;
break;
case LV_IMG_CF_ALPHA_8BIT:
disp_drv->set_px_cb = set_px_cb_alpha8;
break;
default:
disp_drv->set_px_cb = NULL;
}
}
static void set_px_cb_alpha1(lv_disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
lv_color_t color, lv_opa_t opa)
lv_color_t color, lv_opa_t opa)
{
(void) disp_drv; /*Unused*/
@@ -1107,7 +1131,7 @@ static void set_px_cb_alpha1(lv_disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t
}
static void set_px_cb_alpha2(lv_disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
lv_color_t color, lv_opa_t opa)
lv_color_t color, lv_opa_t opa)
{
(void) disp_drv; /*Unused*/
@@ -1121,7 +1145,7 @@ static void set_px_cb_alpha2(lv_disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t
}
static void set_px_cb_alpha4(lv_disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
lv_color_t color, lv_opa_t opa)
lv_color_t color, lv_opa_t opa)
{
(void) disp_drv; /*Unused*/
@@ -1135,7 +1159,7 @@ static void set_px_cb_alpha4(lv_disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t
}
static void set_px_cb_alpha8(lv_disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
lv_color_t color, lv_opa_t opa)
lv_color_t color, lv_opa_t opa)
{
(void) disp_drv; /*Unused*/
@@ -1163,8 +1187,9 @@ static void set_px_alpha_generic(lv_img_dsc_t * d, lv_coord_t x, lv_coord_t y, l
}
static void set_px_true_color_alpha(lv_disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
lv_color_t color, lv_opa_t opa)
static void set_px_true_color_alpha(lv_disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x,
lv_coord_t y,
lv_color_t color, lv_opa_t opa)
{
(void) disp_drv; /*Unused*/

View File

@@ -29,8 +29,7 @@ extern "C" {
* TYPEDEFS
**********************/
/*Data of canvas*/
typedef struct
{
typedef struct {
lv_img_ext_t img; /*Ext. of ancestor*/
/*New data for this type */
lv_img_dsc_t dsc;
@@ -145,8 +144,9 @@ void lv_canvas_copy_buf(lv_obj_t * canvas, const void * to_copy, lv_coord_t x, l
* Set to `source height / 2` to rotate around the center
* @param antialias apply anti-aliasing during the transformation. Looks better but slower.
*/
void lv_canvas_transform(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle, uint16_t zoom, lv_coord_t offset_x, lv_coord_t offset_y,
int32_t pivot_x, int32_t pivot_y, bool antialias);
void lv_canvas_transform(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle, uint16_t zoom, lv_coord_t offset_x,
lv_coord_t offset_y,
int32_t pivot_x, int32_t pivot_y, bool antialias);
@@ -194,7 +194,8 @@ void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord
* @param txt text to display
* @param align align of the text (`LV_LABEL_ALIGN_LEFT/RIGHT/CENTER`)
*/
void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t max_w, lv_draw_label_dsc_t * label_draw_dsc,
void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t max_w,
lv_draw_label_dsc_t * label_draw_dsc,
const char * txt, lv_label_align_t align);
/**
@@ -203,7 +204,8 @@ void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord
* @param src image source. Can be a pointer an `lv_img_dsc_t` variable or a path an image.
* @param style style of the image (`image` properties are used)
*/
void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const void * src, lv_draw_img_dsc_t * img_draw_dsc);
void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const void * src,
lv_draw_img_dsc_t * img_draw_dsc);
/**
* Draw a line on the canvas
@@ -212,7 +214,8 @@ void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const voi
* @param point_cnt number of points
* @param style style of the line (`line` properties are used)
*/
void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t * points, uint32_t point_cnt, lv_draw_line_dsc_t * line_draw_dsc);
void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t * points, uint32_t point_cnt,
lv_draw_line_dsc_t * line_draw_dsc);
/**
* Draw a polygon on the canvas
@@ -221,7 +224,8 @@ void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t * points, uint32_t
* @param point_cnt number of points
* @param style style of the polygon (`body.main_color` and `body.opa` is used)
*/
void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t * points, uint32_t point_cnt, lv_draw_rect_dsc_t * poly_draw_dsc);
void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t * points, uint32_t point_cnt,
lv_draw_rect_dsc_t * poly_draw_dsc);
/**
* Draw an arc on the canvas

View File

@@ -134,7 +134,8 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
lv_theme_apply(chart, LV_THEME_CHART);
} else {
}
else {
lv_chart_ext_t * ext_copy = lv_obj_get_ext_attr(copy);
lv_style_list_copy(&ext->style_series, &ext_copy->style_series);
@@ -301,8 +302,7 @@ void lv_chart_set_point_count(lv_obj_t * chart, uint16_t point_cnt)
if(point_cnt < 1) point_cnt = 1;
LV_LL_READ_BACK(ext->series_ll, ser)
{
LV_LL_READ_BACK(ext->series_ll, ser) {
if(ser->start_point != 0) {
lv_coord_t * new_points = lv_mem_alloc(sizeof(lv_coord_t) * point_cnt);
LV_ASSERT_MEM(new_points);
@@ -316,7 +316,8 @@ void lv_chart_set_point_count(lv_obj_t * chart, uint16_t point_cnt)
for(i = point_cnt_old; i < point_cnt; i++) {
new_points[i] = def; /*Fill up the rest with default value*/
}
} else {
}
else {
for(i = 0; i < point_cnt; i++) {
new_points[i] =
ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/
@@ -326,7 +327,8 @@ void lv_chart_set_point_count(lv_obj_t * chart, uint16_t point_cnt)
/*Switch over pointer from old to new*/
lv_mem_free(ser->points);
ser->points = new_points;
} else {
}
else {
ser->points = lv_mem_realloc(ser->points, sizeof(lv_coord_t) * point_cnt);
LV_ASSERT_MEM(ser->points);
if(ser->points == NULL) return;
@@ -400,7 +402,8 @@ void lv_chart_set_next(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t y)
y; /*This was the place of the former left most value, after shifting it is the rightmost*/
ser->start_point = (ser->start_point + 1) % ext->point_cnt;
lv_chart_refresh(chart);
} else if(ext->update_mode == LV_CHART_UPDATE_MODE_CIRCULAR) {
}
else if(ext->update_mode == LV_CHART_UPDATE_MODE_CIRCULAR) {
ser->points[ser->start_point] = y;
if(ext->type & LV_CHART_TYPE_LINE) invalidate_lines(chart, ser->start_point);
@@ -479,11 +482,11 @@ void lv_chart_set_secondary_y_tick_length(lv_obj_t * chart, uint8_t major_tick_l
/**
* Set the x-axis tick count and labels of a chart
* @param chart pointer to a chart object
* @param list_of_values list of string values, terminated with \n, except the last
* @param num_tick_marks if list_of_values is NULL: total number of ticks per axis
* else number of ticks between two value labels
* @param options extra options
* @param chart pointer to a chart object
* @param list_of_values list of string values, terminated with \n, except the last
* @param num_tick_marks if list_of_values is NULL: total number of ticks per axis
* else number of ticks between two value labels
* @param options extra options
*/
void lv_chart_set_x_tick_texts(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks,
lv_chart_axis_options_t options)
@@ -526,7 +529,7 @@ void lv_chart_set_y_tick_texts(lv_obj_t * chart, const char * list_of_values, ui
* @param options extra options
*/
void lv_chart_set_secondary_y_tick_texts(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks,
lv_chart_axis_options_t options)
lv_chart_axis_options_t options)
{
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
LV_ASSERT_NULL(list_of_values);
@@ -600,7 +603,8 @@ static lv_design_res_t lv_chart_design(lv_obj_t * chart, const lv_area_t * clip_
{
if(mode == LV_DESIGN_COVER_CHK) {
return ancestor_design(chart, clip_area, mode);
} else if(mode == LV_DESIGN_DRAW_MAIN) {
}
else if(mode == LV_DESIGN_DRAW_MAIN) {
/*Draw the background*/
lv_draw_rect_dsc_t bg_dsc;
lv_draw_rect_dsc_init(&bg_dsc);
@@ -647,8 +651,7 @@ static lv_res_t lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param
if(sign == LV_SIGNAL_CLEANUP) {
lv_coord_t ** datal;
LV_LL_READ(ext->series_ll, datal)
{
LV_LL_READ(ext->series_ll, datal) {
lv_mem_free(*datal);
}
lv_ll_clear(&ext->series_ll);
@@ -675,17 +678,17 @@ static lv_style_list_t * lv_chart_get_style(lv_obj_t * chart, uint8_t part)
lv_style_list_t * style_dsc_p;
switch(part) {
case LV_CHART_PART_BG:
style_dsc_p = &chart->style_list;
break;
case LV_CHART_PART_SERIES_BG:
style_dsc_p = &ext->style_series_bg;
break;
case LV_CHART_PART_SERIES:
style_dsc_p = &ext->style_series;
break;
default:
style_dsc_p = NULL;
case LV_CHART_PART_BG:
style_dsc_p = &chart->style_list;
break;
case LV_CHART_PART_SERIES_BG:
style_dsc_p = &ext->style_series_bg;
break;
case LV_CHART_PART_SERIES:
style_dsc_p = &ext->style_series;
break;
default:
style_dsc_p = NULL;
}
return style_dsc_p;
@@ -725,7 +728,8 @@ static void draw_series_bg(lv_obj_t * chart, const lv_area_t * series_area, cons
if(bg_dsc.border_width != 0) {
div_i_start = 1;
div_i_end = ext->hdiv_cnt;
} else {
}
else {
div_i_start = 0;
div_i_end = ext->hdiv_cnt + 1;
}
@@ -745,7 +749,8 @@ static void draw_series_bg(lv_obj_t * chart, const lv_area_t * series_area, cons
if(bg_dsc.border_width != 0) {
div_i_start = 1;
div_i_end = ext->vdiv_cnt;
} else {
}
else {
div_i_start = 0;
div_i_end = ext->vdiv_cnt + 1;
}
@@ -797,7 +802,8 @@ static void draw_series_line(lv_obj_t * chart, const lv_area_t * series_area, co
has_fade = area_dsc.bg_grad_dir == LV_GRAD_DIR_VER ? true : false;
if(has_fade) {
lv_draw_mask_fade_init(&mask_fade_p, &chart->coords, area_dsc.bg_main_color_stop, chart->coords.y1, area_dsc.bg_grad_color_stop, chart->coords.y2);
lv_draw_mask_fade_init(&mask_fade_p, &chart->coords, area_dsc.bg_main_color_stop, chart->coords.y1,
area_dsc.bg_grad_color_stop, chart->coords.y2);
}
}
@@ -809,8 +815,7 @@ static void draw_series_line(lv_obj_t * chart, const lv_area_t * series_area, co
lv_coord_t point_radius = lv_obj_get_style_size(chart, LV_CHART_PART_SERIES);
/*Go through all data lines*/
LV_LL_READ_BACK(ext->series_ll, ser)
{
LV_LL_READ_BACK(ext->series_ll, ser) {
line_dsc.color = ser->color;
point_dsc.bg_color = ser->color;
area_dsc.bg_color = ser->color;
@@ -942,8 +947,7 @@ static void draw_series_column(lv_obj_t * chart, const lv_area_t * series_area,
x_act += series_area->x1 + x_ofs;
/*Draw the current point of all data line*/
LV_LL_READ_BACK(ext->series_ll, ser)
{
LV_LL_READ_BACK(ext->series_ll, ser) {
lv_coord_t start_point = ext->update_mode == LV_CHART_UPDATE_MODE_SHIFT ? ser->start_point : 0;
col_a.x1 = x_act;
@@ -1047,14 +1051,15 @@ static lv_chart_label_iterator_t create_axis_label_iter(const char * list, uint8
/* count number of list items */
for(j = 0; list[j] != '\0'; j++) {
if(list[j] == '\n')
iterator.items_left++;
if(list[j] == '\n')
iterator.items_left++;
}
if(iterator_dir == LV_CHART_LABEL_ITERATOR_FORWARD) {
iterator.is_reverse_iter = 0;
iterator.current_pos = list;
} else {
}
else {
iterator.is_reverse_iter = 1;
// -1 to skip '\0' at the end of the string
iterator.current_pos = list + j - 1;
@@ -1071,42 +1076,45 @@ static lv_chart_label_iterator_t create_axis_label_iter(const char * list, uint8
static void get_next_axis_label(lv_chart_label_iterator_t * iterator, char * buf)
{
uint8_t label_len = 0;
if (iterator->is_reverse_iter) {
if(iterator->is_reverse_iter) {
const char * label_start;
/* count the length of the current label*/
while ((*iterator->current_pos != '\n') &&
(iterator->current_pos != iterator->list_start)) {
while((*iterator->current_pos != '\n') &&
(iterator->current_pos != iterator->list_start)) {
iterator->current_pos--;
label_len++;
}
label_start = iterator->current_pos;
if (*iterator->current_pos == '\n') {
if(*iterator->current_pos == '\n') {
/* do not copy \n symbol, +1 to skip it*/
label_start++;
/* skip newline*/
iterator->current_pos--;
} else {
}
else {
/* it is last label in list (first one from the beginning )*/
label_len++;
}
/* do not allow output buffer overflow */
if (label_len > LV_CHART_AXIS_TICK_LABEL_MAX_LEN) {
if(label_len > LV_CHART_AXIS_TICK_LABEL_MAX_LEN) {
label_len = LV_CHART_AXIS_TICK_LABEL_MAX_LEN;
}
strncpy(buf, label_start, label_len);
} else {
}
else {
/* search for tick string */
while(iterator->current_pos[label_len] != '\n' &&
iterator->current_pos[label_len] != '\0') {
iterator->current_pos[label_len] != '\0') {
/* do not overflow the buffer, but move to the end of the current label */
if(label_len < LV_CHART_AXIS_TICK_LABEL_MAX_LEN) {
buf[label_len] = iterator->current_pos[label_len];
label_len++;
} else {
}
else {
label_len++;
}
}
@@ -1114,7 +1122,7 @@ static void get_next_axis_label(lv_chart_label_iterator_t * iterator, char * buf
iterator->current_pos += label_len;
/* do not allow output buffer overflow */
if (label_len > LV_CHART_AXIS_TICK_LABEL_MAX_LEN) {
if(label_len > LV_CHART_AXIS_TICK_LABEL_MAX_LEN) {
label_len = LV_CHART_AXIS_TICK_LABEL_MAX_LEN;
}
@@ -1141,7 +1149,7 @@ static void draw_y_ticks(lv_obj_t * chart, const lv_area_t * series_area, const
{
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
lv_chart_axis_cfg_t * y_axis = (which_axis == LV_CHART_AXIS_PRIMARY_Y) ?
&ext->y_axis : &ext->secondary_y_axis;
&ext->y_axis : &ext->secondary_y_axis;
if(y_axis->list_of_values == NULL && y_axis->num_tick_marks == 0) return;
@@ -1183,7 +1191,8 @@ static void draw_y_ticks(lv_obj_t * chart, const lv_area_t * series_area, const
minor_tick_len *= -1;
}
iter_dir = (y_axis->options & LV_CHART_AXIS_INVERSE_LABELS_ORDER) ? LV_CHART_LABEL_ITERATOR_REVERSE : LV_CHART_LABEL_ITERATOR_FORWARD;
iter_dir = (y_axis->options & LV_CHART_AXIS_INVERSE_LABELS_ORDER) ? LV_CHART_LABEL_ITERATOR_REVERSE :
LV_CHART_LABEL_ITERATOR_FORWARD;
iter = create_axis_label_iter(y_axis->list_of_values, iter_dir);
/*determine the number of options */
@@ -1199,7 +1208,7 @@ static void draw_y_ticks(lv_obj_t * chart, const lv_area_t * series_area, const
num_scale_ticks = (y_axis->num_tick_marks * (num_of_labels - 1));
lv_style_int_t label_dist = which_axis == LV_CHART_AXIS_PRIMARY_Y ?
lv_obj_get_style_pad_left(chart, LV_CHART_PART_SERIES_BG) : lv_obj_get_style_pad_right(chart, LV_CHART_PART_SERIES_BG);
lv_obj_get_style_pad_left(chart, LV_CHART_PART_SERIES_BG) : lv_obj_get_style_pad_right(chart, LV_CHART_PART_SERIES_BG);
lv_draw_line_dsc_t line_dsc;
lv_draw_line_dsc_init(&line_dsc);
@@ -1210,11 +1219,11 @@ static void draw_y_ticks(lv_obj_t * chart, const lv_area_t * series_area, const
lv_obj_init_draw_label_dsc(chart, LV_CHART_PART_BG, &label_dsc);
for(i = 0; i < (num_scale_ticks + 1); i++) { /* one extra loop - it may not exist in the list, empty label */
/* first point of the tick */
/* first point of the tick */
p1.x = x_ofs;
/* move extra pixel out of chart boundary */
if (which_axis == LV_CHART_AXIS_PRIMARY_Y)
if(which_axis == LV_CHART_AXIS_PRIMARY_Y)
p1.x--;
else
p1.x++;
@@ -1227,7 +1236,7 @@ static void draw_y_ticks(lv_obj_t * chart, const lv_area_t * series_area, const
/* draw a line at moving y position */
p2.y = p1.y =
y_ofs + (int32_t)((int32_t)(h - line_dsc.width) * i) / num_scale_ticks;
y_ofs + (int32_t)((int32_t)(h - line_dsc.width) * i) / num_scale_ticks;
if(y_axis->options & LV_CHART_AXIS_INVERSE_LABELS_ORDER) {
/*if label order is inversed last tick have number 0*/
@@ -1235,7 +1244,8 @@ static void draw_y_ticks(lv_obj_t * chart, const lv_area_t * series_area, const
lv_draw_line(&p1, &p2, mask, &line_dsc);
else if((y_axis->options & LV_CHART_AXIS_DRAW_LAST_TICK) != 0)
lv_draw_line(&p1, &p2, mask, &line_dsc);
} else {
}
else {
if(i != num_scale_ticks)
lv_draw_line(&p1, &p2, mask, &line_dsc);
else if((y_axis->options & LV_CHART_AXIS_DRAW_LAST_TICK) != 0)
@@ -1260,7 +1270,8 @@ static void draw_y_ticks(lv_obj_t * chart, const lv_area_t * series_area, const
if(which_axis == LV_CHART_AXIS_PRIMARY_Y) {
a.x1 = p2.x - size.x - label_dist;
a.x2 = p2.x - label_dist;
} else {
}
else {
a.x1 = p2.x + label_dist;
a.x2 = p2.x + size.x + label_dist;
}
@@ -1352,11 +1363,12 @@ static void draw_x_ticks(lv_obj_t * chart, const lv_area_t * series_area, const
/* reserve appropriate area */
lv_point_t size;
lv_txt_get_size(&size, buf, label_dsc.font, label_dsc.letter_space, label_dsc.line_space,
LV_COORD_MAX, LV_TXT_FLAG_CENTER);
LV_COORD_MAX, LV_TXT_FLAG_CENTER);
/* set the area at some distance of the major tick len under of the tick */
lv_area_t a = {(p2.x - size.x / 2), (p2.y + label_dist), (p2.x + size.x / 2),
(p2.y + size.y + label_dist)};
(p2.y + size.y + label_dist)
};
lv_draw_label(&a, mask, &label_dsc, buf, NULL);
}
}

View File

@@ -52,8 +52,7 @@ enum {
};
typedef uint8_t lv_chart_update_mode_t;
typedef struct
{
typedef struct {
lv_coord_t * points;
lv_color_t color;
uint16_t start_point;
@@ -67,8 +66,7 @@ enum {
};
typedef uint8_t lv_chart_axis_options_t;
typedef struct
{
typedef struct {
const char * list_of_values;
lv_chart_axis_options_t options;
uint8_t num_tick_marks;
@@ -77,8 +75,7 @@ typedef struct
} lv_chart_axis_cfg_t;
/*Data of chart */
typedef struct
{
typedef struct {
/*No inherited ext*/ /*Ext. of ancestor*/
/*New data for this type */
lv_ll_t series_ll; /*Linked list for the data line pointers (stores lv_chart_dl_t)*/
@@ -250,7 +247,7 @@ void lv_chart_set_x_tick_texts(lv_obj_t * chart, const char * list_of_values, ui
* @param options extra options
*/
void lv_chart_set_secondary_y_tick_texts(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks,
lv_chart_axis_options_t options);
lv_chart_axis_options_t options);
/**
* Set the y-axis tick count and labels of a chart

View File

@@ -85,13 +85,14 @@ lv_obj_t * lv_checkbox_create(lv_obj_t * par, const lv_obj_t * copy)
lv_theme_apply(cb, LV_THEME_CHECKBOX);
} else {
}
else {
lv_checkbox_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
ext->bullet = lv_obj_create(cb, copy_ext->bullet);
ext->label = lv_label_create(cb, copy_ext->label);
/*Refresh the style with new signal function*/
// lv_obj_refresh_style(cb);
// lv_obj_refresh_style(cb);
}
LV_LOG_INFO("check box created");
@@ -181,10 +182,12 @@ static lv_res_t lv_checkbox_signal(lv_obj_t * cb, lv_signal_t sign, void * param
lv_coord_t line_height = lv_font_get_line_height(font);
lv_obj_set_size(ext->bullet, line_height, line_height);
lv_obj_set_state(ext->bullet, lv_obj_get_state(cb, LV_CHECKBOX_PART_BG));
} else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST ||
}
else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST ||
sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS) {
lv_obj_set_state(ext->bullet, lv_obj_get_state(cb, LV_CHECKBOX_PART_BG));
} else if(sign == LV_SIGNAL_CONTROL) {
}
else if(sign == LV_SIGNAL_CONTROL) {
char c = *((char *)param);
if(c == LV_KEY_RIGHT || c == LV_KEY_DOWN || c == LV_KEY_LEFT || c == LV_KEY_UP) {
/*Follow the backgrounds state with the bullet*/
@@ -202,14 +205,14 @@ static lv_style_list_t * lv_checkbox_get_style(lv_obj_t * cb, uint8_t type)
lv_checkbox_ext_t * ext = lv_obj_get_ext_attr(cb);
switch(type) {
case LV_CHECKBOX_PART_BG:
style_dsc_p = &cb->style_list;
break;
case LV_CHECKBOX_PART_BULLET:
style_dsc_p = lv_obj_get_style_list(ext->bullet, LV_BTN_PART_MAIN);
break;
default:
style_dsc_p = NULL;
case LV_CHECKBOX_PART_BG:
style_dsc_p = &cb->style_list;
break;
case LV_CHECKBOX_PART_BULLET:
style_dsc_p = lv_obj_get_style_list(ext->bullet, LV_BTN_PART_MAIN);
break;
default:
style_dsc_p = NULL;
}
return style_dsc_p;

View File

@@ -39,8 +39,7 @@ extern "C" {
**********************/
/*Data of check box*/
typedef struct
{
typedef struct {
lv_btn_ext_t bg_btn; /*Ext. of ancestor*/
/*New data for this type */
lv_obj_t * bullet; /*Pointer to button*/
@@ -93,7 +92,7 @@ void lv_checkbox_set_static_text(lv_obj_t * cb, const char * txt);
*/
static inline void lv_checkbox_set_checked(lv_obj_t * cb, bool checked)
{
lv_btn_set_state(cb, checked ? LV_BTN_STATE_CHECKED_RELEASED: LV_BTN_STATE_RELEASED);
lv_btn_set_state(cb, checked ? LV_BTN_STATE_CHECKED_RELEASED : LV_BTN_STATE_RELEASED);
}
/**
@@ -141,7 +140,7 @@ static inline bool lv_checkbox_is_checked(const lv_obj_t * cb)
*/
static inline bool lv_checkbox_is_inactive(const lv_obj_t * cb)
{
return lv_btn_get_state(cb) == LV_BTN_STATE_DISABLED ? true :false;
return lv_btn_get_state(cb) == LV_BTN_STATE_DISABLED ? true : false;
}

View File

@@ -76,7 +76,7 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy)
if(cont == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(cont);
if(ancestor_design == NULL) ancestor_design= lv_obj_get_design_cb(cont);
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(cont);
lv_obj_allocate_ext_attr(cont, sizeof(lv_cont_ext_t));
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
@@ -270,15 +270,18 @@ static lv_res_t lv_cont_signal(lv_obj_t * cont, lv_signal_t sign, void * param)
if(sign == LV_SIGNAL_STYLE_CHG) { /*Recalculate the padding if the style changed*/
lv_cont_refr_layout(cont);
lv_cont_refr_autofit(cont);
} else if(sign == LV_SIGNAL_CHILD_CHG) {
}
else if(sign == LV_SIGNAL_CHILD_CHG) {
lv_cont_refr_layout(cont);
lv_cont_refr_autofit(cont);
} else if(sign == LV_SIGNAL_COORD_CHG) {
}
else if(sign == LV_SIGNAL_COORD_CHG) {
if(lv_obj_get_width(cont) != lv_area_get_width(param) || lv_obj_get_height(cont) != lv_area_get_height(param)) {
lv_cont_refr_layout(cont);
lv_cont_refr_autofit(cont);
}
} else if(sign == LV_SIGNAL_PARENT_SIZE_CHG) {
}
else if(sign == LV_SIGNAL_PARENT_SIZE_CHG) {
/*FLOOD and FILL fit needs to be refreshed if the parent's size has changed*/
lv_cont_refr_autofit(cont);
}
@@ -291,11 +294,11 @@ static lv_style_list_t * lv_cont_get_style(lv_obj_t * cont, uint8_t type)
{
lv_style_list_t * style_dsc_p;
switch(type) {
case LV_CONT_PART_MAIN:
style_dsc_p = &cont->style_list;
break;
default:
style_dsc_p = NULL;
case LV_CONT_PART_MAIN:
style_dsc_p = &cont->style_list;
break;
default:
style_dsc_p = NULL;
}
return style_dsc_p;
@@ -316,13 +319,17 @@ static void lv_cont_refr_layout(lv_obj_t * cont)
if(type == LV_LAYOUT_CENTER) {
lv_cont_layout_center(cont);
} else if(type == LV_LAYOUT_COLUMN_LEFT || type == LV_LAYOUT_COLUMN_MID || type == LV_LAYOUT_COLUMN_RIGHT) {
}
else if(type == LV_LAYOUT_COLUMN_LEFT || type == LV_LAYOUT_COLUMN_MID || type == LV_LAYOUT_COLUMN_RIGHT) {
lv_cont_layout_col(cont);
} else if(type == LV_LAYOUT_ROW_TOP || type == LV_LAYOUT_ROW_MID || type == LV_LAYOUT_ROW_BOTTOM) {
}
else if(type == LV_LAYOUT_ROW_TOP || type == LV_LAYOUT_ROW_MID || type == LV_LAYOUT_ROW_BOTTOM) {
lv_cont_layout_row(cont);
} else if(type == LV_LAYOUT_PRETTY_MID || type == LV_LAYOUT_PRETTY_TOP || type == LV_LAYOUT_PRETTY_BOTTOM) {
}
else if(type == LV_LAYOUT_PRETTY_MID || type == LV_LAYOUT_PRETTY_TOP || type == LV_LAYOUT_PRETTY_BOTTOM) {
lv_cont_layout_pretty(cont);
} else if(type == LV_LAYOUT_GRID) {
}
else if(type == LV_LAYOUT_GRID) {
lv_cont_layout_grid(cont);
}
}
@@ -369,8 +376,7 @@ static void lv_cont_layout_col(lv_obj_t * cont)
lv_obj_add_protect(cont, LV_PROTECT_CHILD_CHG);
/* Align the children */
lv_coord_t last_cord = top;
LV_LL_READ_BACK(cont->child_ll, child)
{
LV_LL_READ_BACK(cont->child_ll, child) {
if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
lv_obj_align(child, cont, align, hpad_corr, last_cord);
@@ -401,11 +407,11 @@ static void lv_cont_layout_row(lv_obj_t * cont)
break;
case LV_LAYOUT_ROW_MID:
vpad_corr = 0;
align = base_dir == LV_BIDI_DIR_RTL ? LV_ALIGN_IN_RIGHT_MID: LV_ALIGN_IN_LEFT_MID;
align = base_dir == LV_BIDI_DIR_RTL ? LV_ALIGN_IN_RIGHT_MID : LV_ALIGN_IN_LEFT_MID;
break;
case LV_LAYOUT_ROW_BOTTOM:
vpad_corr = -lv_obj_get_style_pad_bottom(cont, LV_CONT_PART_MAIN);
align = base_dir == LV_BIDI_DIR_RTL ? LV_ALIGN_IN_BOTTOM_RIGHT: LV_ALIGN_IN_BOTTOM_LEFT;
align = base_dir == LV_BIDI_DIR_RTL ? LV_ALIGN_IN_BOTTOM_RIGHT : LV_ALIGN_IN_BOTTOM_LEFT;
break;
default:
vpad_corr = 0;
@@ -424,8 +430,7 @@ static void lv_cont_layout_row(lv_obj_t * cont)
lv_coord_t inner = lv_obj_get_style_pad_inner(cont, LV_CONT_PART_MAIN);
LV_LL_READ_BACK(cont->child_ll, child)
{
LV_LL_READ_BACK(cont->child_ll, child) {
if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
if(base_dir == LV_BIDI_DIR_RTL) lv_obj_align(child, cont, align, -last_cord, vpad_corr);
@@ -448,8 +453,7 @@ static void lv_cont_layout_center(lv_obj_t * cont)
lv_coord_t h_tot = 0;
lv_coord_t inner = lv_obj_get_style_pad_inner(cont, LV_CONT_PART_MAIN);
LV_LL_READ(cont->child_ll, child)
{
LV_LL_READ(cont->child_ll, child) {
if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
h_tot += lv_obj_get_height(child) + inner;
obj_num++;
@@ -465,8 +469,7 @@ static void lv_cont_layout_center(lv_obj_t * cont)
/* Align the children */
lv_coord_t last_cord = -(h_tot / 2);
LV_LL_READ_BACK(cont->child_ll, child)
{
LV_LL_READ_BACK(cont->child_ll, child) {
if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
lv_obj_align(child, cont, LV_ALIGN_CENTER, 0, last_cord + lv_obj_get_height(child) / 2);
@@ -549,20 +552,20 @@ static void lv_cont_layout_pretty(lv_obj_t * cont)
w_row = lv_obj_get_width(obj1) + lv_obj_get_width(obj2);
lv_coord_t pad = (w_obj - w_row) / 3;
switch(type) {
case LV_LAYOUT_PRETTY_TOP:
lv_obj_align(obj1, cont, LV_ALIGN_IN_TOP_LEFT, pad, act_y);
lv_obj_align(obj2, cont, LV_ALIGN_IN_TOP_RIGHT, -pad, act_y);
break;
case LV_LAYOUT_PRETTY_MID:
lv_obj_align(obj1, cont, LV_ALIGN_IN_TOP_LEFT, pad, act_y + (h_row - lv_obj_get_height(obj1)) / 2);
lv_obj_align(obj2, cont, LV_ALIGN_IN_TOP_RIGHT, -pad, act_y + (h_row - lv_obj_get_height(obj2)) / 2);
break;
case LV_LAYOUT_PRETTY_BOTTOM:
lv_obj_align(obj1, cont, LV_ALIGN_IN_TOP_LEFT, pad, act_y + h_row - lv_obj_get_height(obj1));
lv_obj_align(obj2, cont, LV_ALIGN_IN_TOP_RIGHT, -pad, act_y + h_row - lv_obj_get_height(obj2));
break;
default:
break;
case LV_LAYOUT_PRETTY_TOP:
lv_obj_align(obj1, cont, LV_ALIGN_IN_TOP_LEFT, pad, act_y);
lv_obj_align(obj2, cont, LV_ALIGN_IN_TOP_RIGHT, -pad, act_y);
break;
case LV_LAYOUT_PRETTY_MID:
lv_obj_align(obj1, cont, LV_ALIGN_IN_TOP_LEFT, pad, act_y + (h_row - lv_obj_get_height(obj1)) / 2);
lv_obj_align(obj2, cont, LV_ALIGN_IN_TOP_RIGHT, -pad, act_y + (h_row - lv_obj_get_height(obj2)) / 2);
break;
case LV_LAYOUT_PRETTY_BOTTOM:
lv_obj_align(obj1, cont, LV_ALIGN_IN_TOP_LEFT, pad, act_y + h_row - lv_obj_get_height(obj1));
lv_obj_align(obj2, cont, LV_ALIGN_IN_TOP_RIGHT, -pad, act_y + h_row - lv_obj_get_height(obj2));
break;
default:
break;
}
}
/* Align the children (from child_rs to child_rc)*/
@@ -574,21 +577,21 @@ static void lv_cont_layout_pretty(lv_obj_t * cont)
while(child_tmp != NULL) {
if(lv_obj_get_hidden(child_tmp) == false && lv_obj_is_protected(child_tmp, LV_PROTECT_POS) == false) {
switch(type) {
case LV_LAYOUT_PRETTY_TOP:
lv_obj_align(child_tmp, cont, LV_ALIGN_IN_TOP_LEFT, act_x,
act_y);
break;
case LV_LAYOUT_PRETTY_MID:
lv_obj_align(child_tmp, cont, LV_ALIGN_IN_TOP_LEFT, act_x,
act_y + (h_row - lv_obj_get_height(child_tmp)) / 2);
case LV_LAYOUT_PRETTY_TOP:
lv_obj_align(child_tmp, cont, LV_ALIGN_IN_TOP_LEFT, act_x,
act_y);
break;
case LV_LAYOUT_PRETTY_MID:
lv_obj_align(child_tmp, cont, LV_ALIGN_IN_TOP_LEFT, act_x,
act_y + (h_row - lv_obj_get_height(child_tmp)) / 2);
break;
case LV_LAYOUT_PRETTY_BOTTOM:
lv_obj_align(child_tmp, cont, LV_ALIGN_IN_TOP_LEFT, act_x,
act_y + h_row - lv_obj_get_height(child_tmp));
break;
default:
break;
break;
case LV_LAYOUT_PRETTY_BOTTOM:
lv_obj_align(child_tmp, cont, LV_ALIGN_IN_TOP_LEFT, act_x,
act_y + h_row - lv_obj_get_height(child_tmp));
break;
default:
break;
}
act_x += lv_obj_get_width(child_tmp) + new_opad;
@@ -622,7 +625,8 @@ static void lv_cont_layout_grid(lv_obj_t * cont)
lv_coord_t x_ofs;
if(obj_row > 1) {
x_ofs = w_obj + (w_fit - (obj_row * w_obj)) / (obj_row - 1);
} else {
}
else {
x_ofs = w_tot / 2 - w_obj / 2;
}
lv_coord_t y_ofs = h_obj + inner;
@@ -636,14 +640,14 @@ static void lv_cont_layout_grid(lv_obj_t * cont)
lv_coord_t act_x = left;
lv_coord_t act_y = lv_obj_get_style_pad_top(cont, LV_CONT_PART_MAIN);
uint16_t obj_cnt = 0;
LV_LL_READ_BACK(cont->child_ll, child)
{
LV_LL_READ_BACK(cont->child_ll, child) {
if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
if(obj_row > 1) {
lv_obj_set_pos(child, act_x, act_y);
act_x += x_ofs;
} else {
}
else {
lv_obj_set_pos(child, x_ofs, act_y);
}
obj_cnt++;
@@ -695,8 +699,7 @@ static void lv_cont_refr_autofit(lv_obj_t * cont)
tight_area.x2 = LV_COORD_MIN;
tight_area.y2 = LV_COORD_MIN;
LV_LL_READ(cont->child_ll, child_i)
{
LV_LL_READ(cont->child_ll, child_i) {
if(lv_obj_get_hidden(child_i) != false) continue;
tight_area.x1 = LV_MATH_MIN(tight_area.x1, child_i->coords.x1);
tight_area.y1 = LV_MATH_MIN(tight_area.y1, child_i->coords.y1);
@@ -714,31 +717,59 @@ static void lv_cont_refr_autofit(lv_obj_t * cont)
lv_area_copy(&new_area, &ori);
switch(ext->fit_left) {
case LV_FIT_TIGHT: new_area.x1 = tight_area.x1; break;
case LV_FIT_PARENT: new_area.x1 = flood_area.x1; break;
case LV_FIT_MAX: new_area.x1 = has_children ? LV_MATH_MIN(tight_area.x1, flood_area.x1) : flood_area.x1; break;
default: break;
case LV_FIT_TIGHT:
new_area.x1 = tight_area.x1;
break;
case LV_FIT_PARENT:
new_area.x1 = flood_area.x1;
break;
case LV_FIT_MAX:
new_area.x1 = has_children ? LV_MATH_MIN(tight_area.x1, flood_area.x1) : flood_area.x1;
break;
default:
break;
}
switch(ext->fit_right) {
case LV_FIT_TIGHT: new_area.x2 = tight_area.x2; break;
case LV_FIT_PARENT: new_area.x2 = flood_area.x2; break;
case LV_FIT_MAX: new_area.x2 = has_children ? LV_MATH_MAX(tight_area.x2, flood_area.x2) : flood_area.x2; break;
default: break;
case LV_FIT_TIGHT:
new_area.x2 = tight_area.x2;
break;
case LV_FIT_PARENT:
new_area.x2 = flood_area.x2;
break;
case LV_FIT_MAX:
new_area.x2 = has_children ? LV_MATH_MAX(tight_area.x2, flood_area.x2) : flood_area.x2;
break;
default:
break;
}
switch(ext->fit_top) {
case LV_FIT_TIGHT: new_area.y1 = tight_area.y1; break;
case LV_FIT_PARENT: new_area.y1 = flood_area.y1; break;
case LV_FIT_MAX: new_area.y1 = has_children ? LV_MATH_MIN(tight_area.y1, flood_area.y1) : flood_area.y1; break;
default: break;
case LV_FIT_TIGHT:
new_area.y1 = tight_area.y1;
break;
case LV_FIT_PARENT:
new_area.y1 = flood_area.y1;
break;
case LV_FIT_MAX:
new_area.y1 = has_children ? LV_MATH_MIN(tight_area.y1, flood_area.y1) : flood_area.y1;
break;
default:
break;
}
switch(ext->fit_bottom) {
case LV_FIT_TIGHT: new_area.y2 = tight_area.y2; break;
case LV_FIT_PARENT: new_area.y2 = flood_area.y2; break;
case LV_FIT_MAX: new_area.y2 = has_children ? LV_MATH_MAX(tight_area.y2, flood_area.y2) : flood_area.y2; break;
default: break;
case LV_FIT_TIGHT:
new_area.y2 = tight_area.y2;
break;
case LV_FIT_PARENT:
new_area.y2 = flood_area.y2;
break;
case LV_FIT_MAX:
new_area.y2 = has_children ? LV_MATH_MAX(tight_area.y2, flood_area.y2) : flood_area.y2;
break;
default:
break;
}
/*Do nothing if the coordinates are not changed*/

View File

@@ -97,8 +97,7 @@ enum {
};
typedef uint8_t lv_fit_t;
typedef struct
{
typedef struct {
/*Inherited from 'base_obj' so no inherited ext. */ /*Ext. of ancestor*/
/*New data for this type */
lv_layout_t layout : 4; /*A layout from 'lv_layout_t' enum*/

View File

@@ -23,27 +23,27 @@
#define LV_OBJX_NAME "lv_cpicker"
#ifndef LV_CPICKER_DEF_TYPE
#define LV_CPICKER_DEF_TYPE LV_CPICKER_TYPE_DISC
#define LV_CPICKER_DEF_TYPE LV_CPICKER_TYPE_DISC
#endif
#ifndef LV_CPICKER_DEF_HUE
#define LV_CPICKER_DEF_HUE 0
#define LV_CPICKER_DEF_HUE 0
#endif
#ifndef LV_CPICKER_DEF_SATURATION
#define LV_CPICKER_DEF_SATURATION 100
#define LV_CPICKER_DEF_SATURATION 100
#endif
#ifndef LV_CPICKER_DEF_VALUE
#define LV_CPICKER_DEF_VALUE 100
#define LV_CPICKER_DEF_VALUE 100
#endif
#ifndef LV_CPICKER_DEF_HSV
#define LV_CPICKER_DEF_HSV ((lv_color_hsv_t){LV_CPICKER_DEF_HUE, LV_CPICKER_DEF_SATURATION, LV_CPICKER_DEF_VALUE})
#define LV_CPICKER_DEF_HSV ((lv_color_hsv_t){LV_CPICKER_DEF_HUE, LV_CPICKER_DEF_SATURATION, LV_CPICKER_DEF_VALUE})
#endif
#ifndef LV_CPICKER_DEF_QF /*quantization factor*/
#define LV_CPICKER_DEF_QF 3
#define LV_CPICKER_DEF_QF 3
#endif
#define TRI_OFFSET 2
@@ -225,19 +225,19 @@ bool lv_cpicker_set_hsv(lv_obj_t * cpicker, lv_color_hsv_t hsv)
{
LV_ASSERT_OBJ(cpicker, LV_OBJX_NAME);
if (hsv.h > 360) hsv.h %= 360;
if (hsv.s > 100) hsv.s = 100;
if (hsv.v > 100) hsv.v = 100;
if(hsv.h > 360) hsv.h %= 360;
if(hsv.s > 100) hsv.s = 100;
if(hsv.v > 100) hsv.v = 100;
lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker);
if (ext->hsv.h == hsv.h && ext->hsv.s == hsv.s && ext->hsv.v == hsv.v) return false;
if(ext->hsv.h == hsv.h && ext->hsv.s == hsv.s && ext->hsv.v == hsv.v) return false;
ext->hsv = hsv;
refr_indic_pos(cpicker);
if (ext->type == LV_CPICKER_TYPE_DISC) {
if(ext->type == LV_CPICKER_TYPE_DISC) {
lv_obj_invalidate(cpicker);
}
@@ -258,7 +258,7 @@ bool lv_cpicker_set_color(lv_obj_t * cpicker, lv_color_t color)
c32.full = lv_color_to32(color);
return lv_cpicker_set_hsv(cpicker,
lv_color_rgb_to_hsv(c32.ch.red, c32.ch.green, c32.ch.blue));
lv_color_rgb_to_hsv(c32.ch.red, c32.ch.green, c32.ch.blue));
}
/**
@@ -452,7 +452,8 @@ static lv_design_res_t lv_cpicker_design(lv_obj_t * cpicker, const lv_area_t * c
if(ext->type == LV_CPICKER_TYPE_DISC) {
draw_disc_grad(cpicker, clip_area);
} else if(ext->type == LV_CPICKER_TYPE_RECT) {
}
else if(ext->type == LV_CPICKER_TYPE_RECT) {
draw_rect_grad(cpicker, clip_area);
}
@@ -482,14 +483,14 @@ static void draw_disc_grad(lv_obj_t * cpicker, const lv_area_t * mask)
uint16_t i;
lv_coord_t cir_w = lv_obj_get_style_scale_width(cpicker, LV_CPICKER_PART_MAIN);
for(i = 0; i <= 360; i+= LV_CPICKER_DEF_QF) {
for(i = 0; i <= 360; i += LV_CPICKER_DEF_QF) {
line_dsc.color = angle_to_mode_color(cpicker, i);
lv_point_t p[2];
p[0].x = cx + (r * lv_trigo_sin(i) >> LV_TRIGO_SHIFT);
p[0].y = cy + (r * lv_trigo_sin(i+ 90) >> LV_TRIGO_SHIFT);
p[1].x = cx + ((r-cir_w) * lv_trigo_sin(i) >> LV_TRIGO_SHIFT);
p[1].y = cy + ((r-cir_w) * lv_trigo_sin(i+ 90) >> LV_TRIGO_SHIFT);
p[0].y = cy + (r * lv_trigo_sin(i + 90) >> LV_TRIGO_SHIFT);
p[1].x = cx + ((r - cir_w) * lv_trigo_sin(i) >> LV_TRIGO_SHIFT);
p[1].y = cy + ((r - cir_w) * lv_trigo_sin(i + 90) >> LV_TRIGO_SHIFT);
lv_draw_line(&p[0], &p[1], mask, &line_dsc);
}
@@ -564,7 +565,7 @@ static void draw_rect_grad(lv_obj_t * cpicker, const lv_area_t * mask)
uint16_t i;
for(i = 0; i < 360; i += i_step) {
bg_dsc.bg_color = angle_to_mode_color(cpicker, i);
bg_dsc.bg_color = angle_to_mode_color(cpicker, i);
/*the following attribute might need changing between index to add border, shadow, radius etc*/
lv_area_t rect_area;
@@ -592,7 +593,7 @@ static void draw_indic(lv_obj_t * cpicker, const lv_area_t * mask)
cir_dsc.radius = LV_RADIUS_CIRCLE;
if(ext->indic.colored) {
cir_dsc.bg_color = lv_cpicker_get_color(cpicker);
cir_dsc.bg_color = lv_cpicker_get_color(cpicker);
}
lv_area_t indic_area = get_indic_area(cpicker);
@@ -614,7 +615,7 @@ static lv_area_t get_indic_area(lv_obj_t * cpicker)
/*Get indicator's radius*/
uint16_t r = 0;
if(ext->type == LV_CPICKER_TYPE_DISC) {
r = lv_obj_get_style_scale_width(cpicker, LV_CPICKER_PART_MAIN) / 2;
r = lv_obj_get_style_scale_width(cpicker, LV_CPICKER_PART_MAIN) / 2;
}
else if(ext->type == LV_CPICKER_TYPE_RECT) {
lv_coord_t h = lv_obj_get_height(cpicker);
@@ -648,10 +649,10 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p
lv_res_t res;
if(sign == LV_SIGNAL_GET_STYLE) {
lv_get_style_info_t * info = param;
info->result = lv_cpicker_get_style(cpicker, info->part);
if(info->result != NULL) return LV_RES_OK;
else return ancestor_signal(cpicker, sign, param);
lv_get_style_info_t * info = param;
info->result = lv_cpicker_get_style(cpicker, info->part);
if(info->result != NULL) return LV_RES_OK;
else return ancestor_signal(cpicker, sign, param);
}
res = ancestor_signal(cpicker, sign, param);
@@ -662,7 +663,8 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p
if(sign == LV_SIGNAL_CLEANUP) {
lv_obj_clean_style_list(cpicker, LV_CPICKER_PART_INDIC);
} else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
}
else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
lv_style_int_t left = lv_obj_get_style_pad_left(cpicker, LV_CPICKER_PART_INDIC);
lv_style_int_t right = lv_obj_get_style_pad_right(cpicker, LV_CPICKER_PART_INDIC);
lv_style_int_t top = lv_obj_get_style_pad_top(cpicker, LV_CPICKER_PART_INDIC);
@@ -672,11 +674,13 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p
if(ext->type == LV_CPICKER_TYPE_DISC) {
cpicker->ext_draw_pad = LV_MATH_MAX(cpicker->ext_draw_pad, indic_pad);
} else {
}
else {
indic_pad += lv_obj_get_height(cpicker) / 2;
cpicker->ext_draw_pad = LV_MATH_MAX(cpicker->ext_draw_pad, indic_pad);
}
} else if(sign == LV_SIGNAL_COORD_CHG) {
}
else if(sign == LV_SIGNAL_COORD_CHG) {
/*Refresh extended draw area to make knob visible*/
if(lv_obj_get_width(cpicker) != lv_area_get_width(param) ||
lv_obj_get_height(cpicker) != lv_area_get_height(param)) {
@@ -684,7 +688,8 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p
refr_indic_pos(cpicker);
lv_obj_invalidate(cpicker);
}
} else if(sign == LV_SIGNAL_STYLE_CHG) {
}
else if(sign == LV_SIGNAL_STYLE_CHG) {
/*Refresh extended draw area to make knob visible*/
lv_obj_refresh_ext_draw_pad(cpicker);
refr_indic_pos(cpicker);
@@ -697,18 +702,18 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p
hsv_cur = ext->hsv;
switch(ext->color_mode) {
case LV_CPICKER_COLOR_MODE_HUE:
hsv_cur.h = (ext->hsv.h + 1) % 360;
break;
case LV_CPICKER_COLOR_MODE_SATURATION:
hsv_cur.s = (ext->hsv.s + 1) % 100;
break;
case LV_CPICKER_COLOR_MODE_VALUE:
hsv_cur.v = (ext->hsv.v + 1) % 100;
break;
case LV_CPICKER_COLOR_MODE_HUE:
hsv_cur.h = (ext->hsv.h + 1) % 360;
break;
case LV_CPICKER_COLOR_MODE_SATURATION:
hsv_cur.s = (ext->hsv.s + 1) % 100;
break;
case LV_CPICKER_COLOR_MODE_VALUE:
hsv_cur.v = (ext->hsv.v + 1) % 100;
break;
}
if (lv_cpicker_set_hsv(cpicker, hsv_cur)) {
if(lv_cpicker_set_hsv(cpicker, hsv_cur)) {
res = lv_event_send(cpicker, LV_EVENT_VALUE_CHANGED, NULL);
if(res != LV_RES_OK) return res;
}
@@ -718,18 +723,18 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p
hsv_cur = ext->hsv;
switch(ext->color_mode) {
case LV_CPICKER_COLOR_MODE_HUE:
hsv_cur.h = ext->hsv.h > 0?(ext->hsv.h - 1) : 360;
break;
case LV_CPICKER_COLOR_MODE_SATURATION:
hsv_cur.s = ext->hsv.s > 0?(ext->hsv.s - 1) : 100;
break;
case LV_CPICKER_COLOR_MODE_VALUE:
hsv_cur.v = ext->hsv.v > 0?(ext->hsv.v - 1) : 100;
break;
case LV_CPICKER_COLOR_MODE_HUE:
hsv_cur.h = ext->hsv.h > 0 ? (ext->hsv.h - 1) : 360;
break;
case LV_CPICKER_COLOR_MODE_SATURATION:
hsv_cur.s = ext->hsv.s > 0 ? (ext->hsv.s - 1) : 100;
break;
case LV_CPICKER_COLOR_MODE_VALUE:
hsv_cur.v = ext->hsv.v > 0 ? (ext->hsv.v - 1) : 100;
break;
}
if (lv_cpicker_set_hsv(cpicker, hsv_cur)) {
if(lv_cpicker_set_hsv(cpicker, hsv_cur)) {
res = lv_event_send(cpicker, LV_EVENT_VALUE_CHANGED, NULL);
if(res != LV_RES_OK) return res;
}
@@ -740,7 +745,8 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p
lv_indev_get_point(lv_indev_get_act(), &ext->last_press_point);
res = double_click_reset(cpicker);
if(res != LV_RES_OK) return res;
} else if(sign == LV_SIGNAL_PRESSING) {
}
else if(sign == LV_SIGNAL_PRESSING) {
lv_indev_t * indev = lv_indev_get_act();
if(indev == NULL) return res;
@@ -748,7 +754,7 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p
lv_indev_get_point(indev, &p);
if((LV_MATH_ABS(p.x - ext->last_press_point.x) > indev->driver.drag_limit / 2) ||
(LV_MATH_ABS(p.y - ext->last_press_point.y) > indev->driver.drag_limit / 2)) {
(LV_MATH_ABS(p.y - ext->last_press_point.y) > indev->driver.drag_limit / 2)) {
ext->last_change_time = lv_tick_get();
ext->last_press_point.x = p.x;
ext->last_press_point.y = p.y;
@@ -775,7 +781,8 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p
if(angle < 0) angle = 0;
if(angle >= 360) angle = 359;
} else if(ext->type == LV_CPICKER_TYPE_DISC) {
}
else if(ext->type == LV_CPICKER_TYPE_DISC) {
lv_style_int_t scale_w = lv_obj_get_style_scale_width(cpicker, LV_CPICKER_PART_MAIN);
lv_coord_t r_in = w / 2;
@@ -812,23 +819,24 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p
hsv_cur = ext->hsv;
switch(ext->color_mode) {
case LV_CPICKER_COLOR_MODE_HUE:
hsv_cur.h = angle;
break;
case LV_CPICKER_COLOR_MODE_SATURATION:
hsv_cur.s = (angle * 100) / 360;
break;
case LV_CPICKER_COLOR_MODE_VALUE:
hsv_cur.v = (angle * 100) / 360;
break;
case LV_CPICKER_COLOR_MODE_HUE:
hsv_cur.h = angle;
break;
case LV_CPICKER_COLOR_MODE_SATURATION:
hsv_cur.s = (angle * 100) / 360;
break;
case LV_CPICKER_COLOR_MODE_VALUE:
hsv_cur.v = (angle * 100) / 360;
break;
}
if (lv_cpicker_set_hsv(cpicker, hsv_cur)) {
if(lv_cpicker_set_hsv(cpicker, hsv_cur)) {
res = lv_event_send(cpicker, LV_EVENT_VALUE_CHANGED, NULL);
if(res != LV_RES_OK) return res;
}
} else if(sign == LV_SIGNAL_HIT_TEST) {
lv_hit_test_info_t *info = param;
}
else if(sign == LV_SIGNAL_HIT_TEST) {
lv_hit_test_info_t * info = param;
info->result = lv_cpicker_hit(cpicker, info->point);
}
@@ -850,14 +858,14 @@ static lv_style_list_t * lv_cpicker_get_style(lv_obj_t * cpicker, uint8_t part)
lv_style_list_t * style_dsc_p;
switch(part) {
case LV_CPICKER_PART_MAIN :
style_dsc_p = &cpicker->style_list;
break;
case LV_CPICKER_PART_INDIC:
style_dsc_p = &ext->indic.style_list;
break;
default:
style_dsc_p = NULL;
case LV_CPICKER_PART_MAIN :
style_dsc_p = &cpicker->style_list;
break;
case LV_CPICKER_PART_INDIC:
style_dsc_p = &ext->indic.style_list;
break;
default:
style_dsc_p = NULL;
}
return style_dsc_p;
@@ -898,20 +906,21 @@ static void refr_indic_pos(lv_obj_t * cpicker)
if(ext->type == LV_CPICKER_TYPE_RECT) {
lv_coord_t ind_pos = 0;
switch(ext->color_mode) {
case LV_CPICKER_COLOR_MODE_HUE:
ind_pos += (ext->hsv.h * w) / 360;
break;
case LV_CPICKER_COLOR_MODE_SATURATION:
ind_pos += (ext->hsv.s * w) / 100;
break;
case LV_CPICKER_COLOR_MODE_VALUE:
ind_pos += (ext->hsv.v * w) / 100;
break;
case LV_CPICKER_COLOR_MODE_HUE:
ind_pos += (ext->hsv.h * w) / 360;
break;
case LV_CPICKER_COLOR_MODE_SATURATION:
ind_pos += (ext->hsv.s * w) / 100;
break;
case LV_CPICKER_COLOR_MODE_VALUE:
ind_pos += (ext->hsv.v * w) / 100;
break;
}
ext->indic.pos.x = ind_pos;
ext->indic.pos.y = h / 2;
} else if(ext->type == LV_CPICKER_TYPE_DISC) {
}
else if(ext->type == LV_CPICKER_TYPE_DISC) {
lv_style_int_t scale_w = lv_obj_get_style_scale_width(cpicker, LV_CPICKER_PART_MAIN);
lv_coord_t r = (w - scale_w) / 2;
uint16_t angle = get_angle(cpicker);
@@ -934,20 +943,20 @@ static lv_res_t double_click_reset(lv_obj_t * cpicker)
hsv_cur = ext->hsv;
switch(ext->color_mode) {
case LV_CPICKER_COLOR_MODE_HUE:
hsv_cur.h = LV_CPICKER_DEF_HUE;
break;
case LV_CPICKER_COLOR_MODE_SATURATION:
hsv_cur.s = LV_CPICKER_DEF_SATURATION;
break;
case LV_CPICKER_COLOR_MODE_VALUE:
hsv_cur.v = LV_CPICKER_DEF_VALUE;
break;
case LV_CPICKER_COLOR_MODE_HUE:
hsv_cur.h = LV_CPICKER_DEF_HUE;
break;
case LV_CPICKER_COLOR_MODE_SATURATION:
hsv_cur.s = LV_CPICKER_DEF_SATURATION;
break;
case LV_CPICKER_COLOR_MODE_VALUE:
hsv_cur.v = LV_CPICKER_DEF_VALUE;
break;
}
lv_indev_wait_release(indev);
if (lv_cpicker_set_hsv(cpicker, hsv_cur)) {
if(lv_cpicker_set_hsv(cpicker, hsv_cur)) {
lv_res_t res = lv_event_send(cpicker, LV_EVENT_VALUE_CHANGED, NULL);
if(res != LV_RES_OK) return res;
}
@@ -961,18 +970,17 @@ static lv_color_t angle_to_mode_color(lv_obj_t * cpicker, uint16_t angle)
{
lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker);
lv_color_t color;
switch(ext->color_mode)
{
default:
case LV_CPICKER_COLOR_MODE_HUE:
color = lv_color_hsv_to_rgb(angle % 360, ext->hsv.s, ext->hsv.v);
break;
case LV_CPICKER_COLOR_MODE_SATURATION:
color = lv_color_hsv_to_rgb(ext->hsv.h, ((angle % 360) * 100) / 360, ext->hsv.v);
break;
case LV_CPICKER_COLOR_MODE_VALUE:
color = lv_color_hsv_to_rgb(ext->hsv.h, ext->hsv.s, ((angle % 360) * 100) / 360);
break;
switch(ext->color_mode) {
default:
case LV_CPICKER_COLOR_MODE_HUE:
color = lv_color_hsv_to_rgb(angle % 360, ext->hsv.s, ext->hsv.v);
break;
case LV_CPICKER_COLOR_MODE_SATURATION:
color = lv_color_hsv_to_rgb(ext->hsv.h, ((angle % 360) * 100) / 360, ext->hsv.v);
break;
case LV_CPICKER_COLOR_MODE_VALUE:
color = lv_color_hsv_to_rgb(ext->hsv.h, ext->hsv.s, ((angle % 360) * 100) / 360);
break;
}
return color;
}
@@ -981,18 +989,17 @@ static uint16_t get_angle(lv_obj_t * cpicker)
{
lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker);
uint16_t angle;
switch(ext->color_mode)
{
default:
case LV_CPICKER_COLOR_MODE_HUE:
angle = ext->hsv.h;
break;
case LV_CPICKER_COLOR_MODE_SATURATION:
angle = (ext->hsv.s * 360) / 100;
break;
case LV_CPICKER_COLOR_MODE_VALUE:
angle = (ext->hsv.v * 360) / 100 ;
break;
switch(ext->color_mode) {
default:
case LV_CPICKER_COLOR_MODE_HUE:
angle = ext->hsv.h;
break;
case LV_CPICKER_COLOR_MODE_SATURATION:
angle = (ext->hsv.s * 360) / 100;
break;
case LV_CPICKER_COLOR_MODE_VALUE:
angle = (ext->hsv.v * 360) / 100 ;
break;
}
return angle;
}

Some files were not shown because too many files have changed in this diff Show More