diff --git a/examples/widgets/btn/lv_example_btn_1.c b/examples/widgets/btn/lv_example_btn_1.c index fefd615a0..56cf9b8ac 100644 --- a/examples/widgets/btn/lv_example_btn_1.c +++ b/examples/widgets/btn/lv_example_btn_1.c @@ -3,6 +3,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { + LV_UNUSED(obj); if(event == LV_EVENT_CLICKED) { LV_LOG_USER("Clicked\n"); } diff --git a/examples/widgets/chart/lv_example_chart_2.c b/examples/widgets/chart/lv_example_chart_2.c index 62ebc43a0..4351477e7 100644 --- a/examples/widgets/chart/lv_example_chart_2.c +++ b/examples/widgets/chart/lv_example_chart_2.c @@ -45,6 +45,7 @@ static void event_cb(lv_obj_t * obj, lv_event_t e) static void add_data(lv_timer_t * timer) { + LV_UNUSED(timer); static uint32_t cnt = 0; lv_chart_set_next_value(chart1, ser1, lv_rand(20, 90)); diff --git a/examples/widgets/chart/lv_example_chart_3.c b/examples/widgets/chart/lv_example_chart_3.c index a49af647c..c7b5de872 100644 --- a/examples/widgets/chart/lv_example_chart_3.c +++ b/examples/widgets/chart/lv_example_chart_3.c @@ -3,6 +3,7 @@ static void event_cb(lv_obj_t * chart, lv_event_t e) { + LV_UNUSED(chart); if(e == LV_EVENT_DRAW_PART_BEGIN) { lv_obj_draw_hook_dsc_t * hook_dsc = lv_event_get_param(); if(hook_dsc->part == LV_PART_MARKER && hook_dsc->sub_part_id == LV_CHART_AXIS_X) { diff --git a/examples/widgets/img/lv_example_img_2.c b/examples/widgets/img/lv_example_img_2.c index 632d85311..280d7d98b 100644 --- a/examples/widgets/img/lv_example_img_2.c +++ b/examples/widgets/img/lv_example_img_2.c @@ -40,6 +40,8 @@ void lv_example_img_2(void) static void slider_event_cb(lv_obj_t * slider, lv_event_t event) { + LV_UNUSED(slider); + if(event == LV_EVENT_VALUE_CHANGED) { /* Recolor the image based on the sliders' values */ lv_color_t color = lv_color_make(lv_slider_get_value(red_slider), lv_slider_get_value(green_slider), lv_slider_get_value(blue_slider)); diff --git a/examples/widgets/spinbox/lv_example_spinbox_1.c b/examples/widgets/spinbox/lv_example_spinbox_1.c index 8ae5ff6a4..0e5c55990 100644 --- a/examples/widgets/spinbox/lv_example_spinbox_1.c +++ b/examples/widgets/spinbox/lv_example_spinbox_1.c @@ -6,6 +6,7 @@ static lv_obj_t * spinbox; static void lv_spinbox_increment_event_cb(lv_obj_t * btn, lv_event_t e) { + LV_UNUSED(btn); if(e == LV_EVENT_SHORT_CLICKED || e == LV_EVENT_LONG_PRESSED_REPEAT) { lv_spinbox_increment(spinbox); } @@ -13,6 +14,7 @@ static void lv_spinbox_increment_event_cb(lv_obj_t * btn, lv_event_t e) static void lv_spinbox_decrement_event_cb(lv_obj_t * btn, lv_event_t e) { + LV_UNUSED(btn); if(e == LV_EVENT_SHORT_CLICKED || e == LV_EVENT_LONG_PRESSED_REPEAT) { lv_spinbox_decrement(spinbox); } diff --git a/lv_conf_template.h b/lv_conf_template.h index e360df2dd..832a3aabe 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -163,7 +163,7 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */ #define LV_USE_ASSERT_OBJ 1 /*Check the object's type and existence (e.g. not deleted). (Slow) */ /*Add a custom handler when assert happens e.g. to restart the MCU*/ -#define LV_ASSERT_HANDLER_INCLUDE +#define LV_ASSERT_HANDLER_INCLUDE #define LV_ASSERT_HANDLER while(1); /*Halt by default*/ /*------------- diff --git a/src/extra/layouts/flex/lv_flex.c b/src/extra/layouts/flex/lv_flex.c index f3abd7718..96cf8ea34 100644 --- a/src/extra/layouts/flex/lv_flex.c +++ b/src/extra/layouts/flex/lv_flex.c @@ -153,6 +153,8 @@ void lv_obj_set_flex_grow(struct _lv_obj_t * obj, uint8_t grow) static void flex_update(lv_obj_t * cont, lv_obj_t * item) { + LV_UNUSED(item); + if(cont->spec_attr == NULL) return; const lv_flex_t * f = (const lv_flex_t *)cont->spec_attr->layout_dsc; @@ -187,7 +189,7 @@ static void flex_update(lv_obj_t * cont, lv_obj_t * item) if(track_cross_place != LV_FLEX_PLACE_START) { track_first_item = f->rev ? cont->spec_attr->child_cnt - 1 : 0; track_t t; - while(track_first_item < cont->spec_attr->child_cnt && track_first_item >= 0) { + while(track_first_item < (int32_t)cont->spec_attr->child_cnt && track_first_item >= 0) { /*Search the first item of the next row */ next_track_first_item = find_track_end(cont, track_first_item, max_main_size, item_gap, &t); total_track_cross_size += t.track_cross_size + track_gap; @@ -217,7 +219,7 @@ static void flex_update(lv_obj_t * cont, lv_obj_t * item) *cross_pos += total_track_cross_size; } - while(track_first_item < cont->spec_attr->child_cnt && track_first_item >= 0) { + while(track_first_item < (int32_t)cont->spec_attr->child_cnt && track_first_item >= 0) { track_t t; /*Search the first item of the next row */ next_track_first_item = find_track_end(cont, track_first_item, max_main_size, item_gap, &t); @@ -234,7 +236,7 @@ static void flex_update(lv_obj_t * cont, lv_obj_t * item) *cross_pos += t.track_cross_size + gap + track_gap; } } - LV_ASSERT_MALLOC_INTEGRITY(); + LV_ASSERT_MEM_INTEGRITY(); } /** @@ -440,7 +442,7 @@ static lv_obj_t * get_next_item(lv_obj_t * cont, bool rev, int32_t * item_id) else return NULL; } else { (*item_id)++; - if((*item_id) < cont->spec_attr->child_cnt) return cont->spec_attr->children[*item_id]; + if((*item_id) < (int32_t)cont->spec_attr->child_cnt) return cont->spec_attr->children[*item_id]; else return NULL; } } diff --git a/src/extra/layouts/grid/lv_grid.c b/src/extra/layouts/grid/lv_grid.c index c6c92630d..bdb24e48c 100644 --- a/src/extra/layouts/grid/lv_grid.c +++ b/src/extra/layouts/grid/lv_grid.c @@ -53,7 +53,7 @@ static lv_coord_t grid_place(lv_coord_t cont_size, bool auto_size, uint8_t plac /********************** * GLOBAL VARIABLES **********************/ -const static lv_coord_t grid_12_template[12] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), +static const lv_coord_t grid_12_template[12] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1)}; const lv_grid_t grid_12 = {.base.update_cb = grid_update, .col_dsc = grid_12_template, .col_dsc_len = 12, .row_dsc = grid_12_template, .row_dsc_len = 12}; @@ -210,7 +210,7 @@ static void calc(struct _lv_obj_t * cont, _lv_grid_calc_t * calc_out) lv_coord_t cont_h = lv_obj_get_height_fit(cont); calc_out->grid_h = grid_place(cont_h, auto_h, g->row_place, row_gap, calc_out->row_num, calc_out->h, calc_out->y, false); - LV_ASSERT_MALLOC_INTEGRITY(); + LV_ASSERT_MEM_INTEGRITY(); } /** diff --git a/src/extra/themes/default/lv_theme_default.c b/src/extra/themes/default/lv_theme_default.c index 7db84a4b5..eafee398f 100644 --- a/src/extra/themes/default/lv_theme_default.c +++ b/src/extra/themes/default/lv_theme_default.c @@ -190,7 +190,7 @@ static bool inited; static void style_init(void) { - const static lv_style_prop_t trans_props[] = { + static const lv_style_prop_t trans_props[] = { LV_STYLE_BG_OPA, LV_STYLE_BG_COLOR, LV_STYLE_CONTENT_OPA, LV_STYLE_TRANSFORM_WIDTH, LV_STYLE_TRANSFORM_HEIGHT, LV_STYLE_TRANSFORM_ZOOM, LV_STYLE_TRANSFORM_ANGLE, diff --git a/src/extra/widgets/calendar/lv_calendar.c b/src/extra/widgets/calendar/lv_calendar.c index a544d068c..f654ec916 100644 --- a/src/extra/widgets/calendar/lv_calendar.c +++ b/src/extra/widgets/calendar/lv_calendar.c @@ -23,7 +23,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void my_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); +static void my_constructor(lv_obj_t * obj, const lv_obj_t * copy); static void draw_event_cb(lv_obj_t * obj, lv_event_t e); static uint8_t get_day_of_week(uint32_t year, uint32_t month, uint32_t day); @@ -67,7 +67,7 @@ void lv_calendar_set_day_names(lv_obj_t * obj, const char * day_names[]) lv_calendar_t * calendar = (lv_calendar_t *) obj; uint32_t i; for(i = 0; i < 7; i++) { - calendar->map[i] = day_names_def[i]; + calendar->map[i] = day_names[i]; } } @@ -207,8 +207,9 @@ bool lv_calendar_get_pressed_date(const lv_obj_t * obj, lv_calendar_date_t * dat * STATIC FUNCTIONS **********************/ -static void my_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +static void my_constructor(lv_obj_t * obj, const lv_obj_t * copy) { + LV_UNUSED(copy); lv_calendar_t * calendar = (lv_calendar_t *) obj; /*Initialize the allocated 'ext' */ diff --git a/src/extra/widgets/colorwheel/lv_colorwheel.c b/src/extra/widgets/colorwheel/lv_colorwheel.c index 681a2e595..98fbf3047 100644 --- a/src/extra/widgets/colorwheel/lv_colorwheel.c +++ b/src/extra/widgets/colorwheel/lv_colorwheel.c @@ -31,7 +31,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_colorwheel_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); +static void lv_colorwheel_constructor(lv_obj_t * obj, const lv_obj_t * copy); static lv_draw_res_t lv_colorwheel_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode); static lv_res_t lv_colorwheel_signal(lv_obj_t * obj, lv_signal_t sign, void * param); @@ -208,8 +208,10 @@ bool lv_colorwheel_get_color_mode_fixed(lv_obj_t * obj) * STATIC FUNCTIONS **********************/ -static void lv_colorwheel_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +static void lv_colorwheel_constructor(lv_obj_t * obj, const lv_obj_t * copy) { + LV_UNUSED(copy); + lv_colorwheel_t * colorwheel = (lv_colorwheel_t *) obj; colorwheel->hsv.h = 0; colorwheel->hsv.s = 100; diff --git a/src/extra/widgets/colorwheel/lv_colorwheel.h b/src/extra/widgets/colorwheel/lv_colorwheel.h index d046bdb45..59484a52c 100644 --- a/src/extra/widgets/colorwheel/lv_colorwheel.h +++ b/src/extra/widgets/colorwheel/lv_colorwheel.h @@ -67,70 +67,66 @@ lv_obj_t * lv_colorwheel_create(lv_obj_t * parent, bool knob_recolor); *====================*/ /** - * Set the current hsv of a color picker. - * @param colorwheel pointer to color picker object - * @param hsv current selected hsv + * Set the current hsv of a color wheel. + * @param colorwheel pointer to color wheel object + * @param color current selected hsv * @return true if changed, otherwise false */ -bool lv_colorwheel_set_hsv(lv_obj_t * colorwheel, lv_color_hsv_t hsv); +bool lv_colorwheel_set_hsv(lv_obj_t * obj, lv_color_hsv_t hsv); /** - * Set the current color of a color picker. - * @param colorwheel pointer to color picker object + * Set the current color of a color wheel. + * @param colorwheel pointer to color wheel object * @param color current selected color * @return true if changed, otherwise false */ -bool lv_colorwheel_set_rgb(lv_obj_t * colorwheel, lv_color_t color); +bool lv_colorwheel_set_rgb(lv_obj_t * obj, lv_color_t color); /** * Set the current color mode. - * @param colorwheel pointer to color picker object + * @param colorwheel pointer to color wheel object * @param mode color mode (hue/sat/val) */ -void lv_colorwheel_set_mode(lv_obj_t * colorwheel, lv_colorwheel_mode_t mode); +void lv_colorwheel_set_mode(lv_obj_t * obj, lv_colorwheel_mode_t mode); /** * Set if the color mode is changed on long press on center - * @param colorwheel pointer to color picker object + * @param colorwheel pointer to color wheel object * @param fixed color mode cannot be changed on long press */ -void lv_colorwheel_set_fixed_mode(lv_obj_t * colorwheel, bool fixed); +void lv_colorwheel_set_mode_fixed(lv_obj_t * obj, bool fixed); /*===================== * Getter functions *====================*/ +/** + * Get the current selected hsv of a color wheel. + * @param colorwheel pointer to color wheel object + * @return current selected hsv + */ +lv_color_hsv_t lv_colorwheel_get_hsv(lv_obj_t * obj); + +/** + * Get the current selected color of a color wheel. + * @param colorwheel pointer to color wheel object + * @return color current selected color + */ +lv_color_t lv_colorwheel_get_rgb(lv_obj_t * obj); + /** * Get the current color mode. - * @param colorwheel pointer to color picker object + * @param colorwheel pointer to color wheel object * @return color mode (hue/sat/val) */ -lv_colorwheel_mode_t lv_colorwheel_get_mode(lv_obj_t * colorwheel); - -/** - * Get the current hue of a color picker. - * @param colorwheel pointer to color picker object - * @return current selected hue - */ -lv_color_hsv_t lv_colorwheel_get_hsv(lv_obj_t * colorwheel); - -/** - * Get the current selected color of a color picker. - * @param colorwheel pointer to color picker object - * @return current selected color - */ -lv_color_t lv_colorwheel_get_rgb(lv_obj_t * colorwheel); +lv_colorwheel_mode_t lv_colorwheel_get_color_mode(lv_obj_t * obj); /** * Get if the color mode is changed on long press on center - * @param colorwheel pointer to color picker object + * @param colorwheel pointer to color wheel object * @return mode cannot be changed on long press */ -bool lv_colorwheel_get_fix_mode(lv_obj_t * colorwheel); - -/*===================== - * Other functions - *====================*/ +bool lv_colorwheel_get_color_mode_fixed(lv_obj_t * obj); /********************** * MACROS diff --git a/src/extra/widgets/imgbtn/lv_imgbtn.c b/src/extra/widgets/imgbtn/lv_imgbtn.c index d7af625c6..37fafc045 100644 --- a/src/extra/widgets/imgbtn/lv_imgbtn.c +++ b/src/extra/widgets/imgbtn/lv_imgbtn.c @@ -23,7 +23,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_imgbtn_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); +static void lv_imgbtn_constructor(lv_obj_t * obj, const lv_obj_t * copy); static lv_draw_res_t lv_imgbtn_draw(lv_obj_t * imgbtn, const lv_area_t * clip_area, lv_draw_mode_t mode); static lv_res_t lv_imgbtn_signal(lv_obj_t * imgbtn, lv_signal_t sign, void * param); static void refr_img(lv_obj_t * imgbtn); @@ -150,8 +150,10 @@ const void * lv_imgbtn_get_src_right(lv_obj_t * obj, lv_imgbtn_state_t state) * STATIC FUNCTIONS **********************/ -static void lv_imgbtn_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +static void lv_imgbtn_constructor(lv_obj_t * obj, const lv_obj_t * copy) { + LV_UNUSED(copy); + lv_imgbtn_t * imgbtn = (lv_imgbtn_t *) obj; /*Initialize the allocated 'ext' */ lv_memset_00((void *)imgbtn->img_src_mid, sizeof(imgbtn->img_src_mid)); @@ -186,7 +188,6 @@ static lv_draw_res_t lv_imgbtn_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_obj_draw_base(&lv_imgbtn_class, obj, clip_area, mode); /*Just draw an image*/ - lv_imgbtn_t * imgbtn = (lv_imgbtn_t *) obj; lv_imgbtn_state_t state = suggest_state(obj, get_state(obj)); /*Simply draw the middle src if no tiled*/ diff --git a/src/extra/widgets/keyboard/lv_keyboard.c b/src/extra/widgets/keyboard/lv_keyboard.c index 389f9a7dd..22300ab89 100644 --- a/src/extra/widgets/keyboard/lv_keyboard.c +++ b/src/extra/widgets/keyboard/lv_keyboard.c @@ -23,7 +23,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void my_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); +static void lv_keyboard_constructor(lv_obj_t * obj, const lv_obj_t * copy); static void lv_keyboard_update_map(lv_obj_t * obj); @@ -31,7 +31,7 @@ static void lv_keyboard_update_map(lv_obj_t * obj); * STATIC VARIABLES **********************/ const lv_obj_class_t lv_keyboard_class = { - .constructor_cb = my_constructor, + .constructor_cb = lv_keyboard_constructor, .instance_size = sizeof(lv_keyboard_t), .editable = 1, .base_class = &lv_btnmatrix_class @@ -255,7 +255,7 @@ void lv_keyboard_def_event_cb(lv_obj_t * obj, lv_event_t event) if(res != LV_RES_OK) return; if(keyboard->ta) { - lv_res_t res = lv_event_send(keyboard->ta, LV_EVENT_CANCEL, NULL); + res = lv_event_send(keyboard->ta, LV_EVENT_CANCEL, NULL); if(res != LV_RES_OK) return; } lv_keyboard_set_textarea(obj, NULL); /*De-assign the text area to hide it cursor if needed*/ @@ -266,7 +266,7 @@ void lv_keyboard_def_event_cb(lv_obj_t * obj, lv_event_t event) if(res != LV_RES_OK) return; if(keyboard->ta) { - lv_res_t res = lv_event_send(keyboard->ta, LV_EVENT_READY, NULL); + res = lv_event_send(keyboard->ta, LV_EVENT_READY, NULL); if(res != LV_RES_OK) return; } @@ -315,14 +315,17 @@ void lv_keyboard_def_event_cb(lv_obj_t * obj, lv_event_t event) * STATIC FUNCTIONS **********************/ -static void my_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +static void lv_keyboard_constructor(lv_obj_t * obj, const lv_obj_t * copy) { + LV_UNUSED(copy); + lv_obj_clear_flag(obj, LV_OBJ_FLAG_CLICK_FOCUSABLE); lv_keyboard_t * keyboard = (lv_keyboard_t *) obj; keyboard->ta = NULL; keyboard->mode = LV_KEYBOARD_MODE_TEXT_LOWER; + lv_obj_t * parent = lv_obj_get_parent(obj); lv_obj_set_size(obj, lv_obj_get_width_fit(parent), lv_obj_get_height_fit(parent) / 2); lv_obj_align(obj, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0); lv_obj_add_event_cb(obj, lv_keyboard_def_event_cb, NULL); diff --git a/src/extra/widgets/led/lv_led.c b/src/extra/widgets/led/lv_led.c index acf1d8138..b65344e7e 100644 --- a/src/extra/widgets/led/lv_led.c +++ b/src/extra/widgets/led/lv_led.c @@ -31,7 +31,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_led_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); +static void lv_led_constructor(lv_obj_t * obj, const lv_obj_t * copy); static lv_draw_res_t lv_led_draw(lv_obj_t * led, const lv_area_t * clip_area, lv_draw_mode_t mode); /********************** @@ -72,10 +72,13 @@ lv_obj_t * lv_led_create(lv_obj_t * parent) * @param led pointer to a LED object * @param color the color of the the LED */ -void lv_led_set_color(lv_obj_t * led, lv_color_t color) +void lv_led_set_color(lv_obj_t * obj, lv_color_t color) { - + lv_led_t * led = (lv_led_t *) obj; + led->color = color; + lv_obj_invalidate(obj); } + /** * Set the brightness of a LED object * @param led pointer to a LED object @@ -83,7 +86,6 @@ void lv_led_set_color(lv_obj_t * led, lv_color_t color) */ void lv_led_set_brightness(lv_obj_t * obj, uint8_t bright) { - /*Set the brightness*/ lv_led_t * led = (lv_led_t *) obj; if(led->bright == bright) return; @@ -146,9 +148,9 @@ uint8_t lv_led_get_brightness(const lv_obj_t * obj) * STATIC FUNCTIONS **********************/ -static void lv_led_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +static void lv_led_constructor(lv_obj_t * obj, const lv_obj_t * copy) { - + LV_UNUSED(copy); lv_led_t * led = (lv_led_t *) obj; led->color = lv_theme_get_color_primary(); led->bright = LV_LED_BRIGHT_MAX; diff --git a/src/extra/widgets/spinbox/lv_spinbox.c b/src/extra/widgets/spinbox/lv_spinbox.c index fac783135..42e81a6c4 100644 --- a/src/extra/widgets/spinbox/lv_spinbox.c +++ b/src/extra/widgets/spinbox/lv_spinbox.c @@ -22,8 +22,7 @@ * STATIC PROTOTYPES **********************/ -static void lv_spinbox_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); -static void lv_spinbox_destructor(lv_obj_t * obj); +static void lv_spinbox_constructor(lv_obj_t * obj, const lv_obj_t * copy); static lv_res_t lv_spinbox_signal(lv_obj_t * obj, lv_signal_t sign, void * param); static void lv_spinbox_updatevalue(lv_obj_t * obj); @@ -32,7 +31,6 @@ static void lv_spinbox_updatevalue(lv_obj_t * obj); **********************/ const lv_obj_class_t lv_spinbox_class = { .constructor_cb = lv_spinbox_constructor, - .destructor_cb = lv_spinbox_destructor, .signal_cb = lv_spinbox_signal, .instance_size = sizeof(lv_spinbox_t), .editable = LV_OBJ_CLASS_EDITABLE_TRUE, @@ -266,10 +264,11 @@ void lv_spinbox_decrement(lv_obj_t * obj) * STATIC FUNCTIONS **********************/ -static void lv_spinbox_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +static void lv_spinbox_constructor(lv_obj_t * obj, const lv_obj_t * copy) { - LV_LOG_TRACE("spinbox create started"); + LV_UNUSED(copy); + LV_LOG_TRACE("spinbox create started"); lv_spinbox_t * spinbox = (lv_spinbox_t *) obj; @@ -291,11 +290,6 @@ static void lv_spinbox_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_o LV_LOG_INFO("spinbox created"); } -static void lv_spinbox_destructor(lv_obj_t * obj) -{ - -} - static lv_res_t lv_spinbox_signal(lv_obj_t * obj, lv_signal_t sign, void * param) { /* Include the ancient signal function */ diff --git a/src/extra/widgets/tabview/lv_tabview.c b/src/extra/widgets/tabview/lv_tabview.c index 9640348f4..35c7569e4 100644 --- a/src/extra/widgets/tabview/lv_tabview.c +++ b/src/extra/widgets/tabview/lv_tabview.c @@ -20,7 +20,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_tabview_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); +static void lv_tabview_constructor(lv_obj_t * obj, const lv_obj_t * copy); static void lv_tabview_destructor(lv_obj_t * obj); static void btns_event_cb(lv_obj_t * btns, lv_event_t e); static void cont_event_cb(lv_obj_t * cont, lv_event_t e); @@ -145,8 +145,9 @@ lv_obj_t * lv_tabview_get_tab_btns(lv_obj_t * tv) * STATIC FUNCTIONS **********************/ -static void lv_tabview_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +static void lv_tabview_constructor(lv_obj_t * obj, const lv_obj_t * copy) { + LV_UNUSED(copy); lv_tabview_t * tabview = (lv_tabview_t *) obj; tabview->tab_pos = tabpos_create; diff --git a/src/extra/widgets/tileview/lv_tileview.c b/src/extra/widgets/tileview/lv_tileview.c index 9434b7874..6d1d501e4 100644 --- a/src/extra/widgets/tileview/lv_tileview.c +++ b/src/extra/widgets/tileview/lv_tileview.c @@ -20,8 +20,8 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_tileview_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); -static void lv_tileview_tile_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); +static void lv_tileview_constructor(lv_obj_t * obj, const lv_obj_t * copy); +static void lv_tileview_tile_constructor(lv_obj_t * obj, const lv_obj_t * copy); static void tileview_event_cb(lv_obj_t * tv, lv_event_t e); /********************** @@ -107,8 +107,9 @@ void lv_obj_set_tile_id(lv_obj_t * tv, uint32_t col_id, uint32_t row_id, lv_anim * STATIC FUNCTIONS **********************/ -static void lv_tileview_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +static void lv_tileview_constructor(lv_obj_t * obj, const lv_obj_t * copy) { + LV_UNUSED(copy); lv_obj_set_size(obj, LV_SIZE_PCT(100), LV_SIZE_PCT(100)); lv_obj_add_event_cb(obj, tileview_event_cb, NULL); lv_obj_add_flag(obj, LV_OBJ_FLAG_SCROLL_ONE); @@ -117,8 +118,10 @@ static void lv_tileview_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_ } -static void lv_tileview_tile_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +static void lv_tileview_tile_constructor(lv_obj_t * obj, const lv_obj_t * copy) { + LV_UNUSED(copy); + lv_obj_t * parent = lv_obj_get_parent(obj); lv_obj_set_size(obj, LV_SIZE_PCT(100), LV_SIZE_PCT(100)); lv_obj_set_pos(obj, create_col_id * lv_obj_get_width_fit(parent), create_row_id * lv_obj_get_height_fit(parent)); diff --git a/src/extra/widgets/win/lv_win.c b/src/extra/widgets/win/lv_win.c index ee74ff36b..ce48b05bb 100644 --- a/src/extra/widgets/win/lv_win.c +++ b/src/extra/widgets/win/lv_win.c @@ -21,7 +21,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_win_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); +static void lv_win_constructor(lv_obj_t * obj, const lv_obj_t * copy); /********************** * STATIC VARIABLES @@ -80,8 +80,10 @@ lv_obj_t * lv_win_get_content(lv_obj_t * win) * STATIC FUNCTIONS **********************/ -static void lv_win_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +static void lv_win_constructor(lv_obj_t * obj, const lv_obj_t * copy) { + LV_UNUSED(copy); + lv_obj_t * parent = lv_obj_get_parent(obj); lv_obj_set_size(obj, lv_obj_get_width(parent), lv_obj_get_height(parent)); lv_obj_set_layout(obj, &lv_flex_stacked); diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index abd8da699..9900b49ee 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -401,7 +401,7 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */ # ifdef CONFIG_LV_ASSERT_HANDLER_INCLUDE # define LV_ASSERT_HANDLER_INCLUDE CONFIG_LV_ASSERT_HANDLER_INCLUDE # else -# define LV_ASSERT_HANDLER_INCLUDE +# define LV_ASSERT_HANDLER_INCLUDE # endif #endif #ifndef LV_ASSERT_HANDLER diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index d85b442d4..a2ea1792f 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -68,7 +68,7 @@ static void draw_scrollbar(lv_obj_t * obj, const lv_area_t * clip_area); static lv_res_t scrollbar_init_draw_dsc(lv_obj_t * obj, lv_draw_rect_dsc_t * dsc); static bool obj_valid_child(const lv_obj_t * parent, const lv_obj_t * obj_to_find); static void base_dir_refr_children(lv_obj_t * obj); -static void lv_obj_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); +static void lv_obj_constructor(lv_obj_t * obj, const lv_obj_t * copy); static void lv_obj_destructor(lv_obj_t * obj); /********************** @@ -585,8 +585,9 @@ bool lv_obj_is_valid(const lv_obj_t * obj) * STATIC FUNCTIONS **********************/ -static void lv_obj_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +static void lv_obj_constructor(lv_obj_t * obj, const lv_obj_t * copy) { + lv_obj_t * parent = obj->parent; /*Create a screen*/ if(parent == NULL) { LV_LOG_TRACE("Screen create started"); diff --git a/src/lv_core/lv_obj_class.c b/src/lv_core/lv_obj_class.c index b995fda54..adbf828e1 100644 --- a/src/lv_core/lv_obj_class.c +++ b/src/lv_core/lv_obj_class.c @@ -46,7 +46,7 @@ lv_obj_t * lv_obj_create_from_class(const lv_obj_class_t * class_p, lv_obj_t * p lv_obj_t * obj = lv_mem_alloc(s); lv_memset_00(obj, s); obj->class_p = class_p; - + obj->parent = parent; const lv_obj_class_t * class_start = class_p; while(class_start && class_start->constructor_cb == NULL) class_start = class_start->base_class; @@ -54,8 +54,6 @@ lv_obj_t * lv_obj_create_from_class(const lv_obj_class_t * class_p, lv_obj_t * p // class_start->constructor_cb(obj, parent, copy); lv_obj_construct(obj, parent, copy); -// lv_obj_set_pos(obj, 0, 0); - if(parent) { /* Send a signal to the parent to notify it about the new child. * Also triggers layout update*/ @@ -144,7 +142,7 @@ static void lv_obj_construct(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * /*Restore the original class*/ obj->class_p = original_class_p; - if(obj->class_p->constructor_cb) obj->class_p->constructor_cb(obj, parent, copy); + if(obj->class_p->constructor_cb) obj->class_p->constructor_cb(obj, copy); } diff --git a/src/lv_core/lv_obj_class.h b/src/lv_core/lv_obj_class.h index bfb89a6e5..246862462 100644 --- a/src/lv_core/lv_obj_class.h +++ b/src/lv_core/lv_obj_class.h @@ -39,7 +39,7 @@ typedef enum { */ typedef struct _lv_obj_class_t{ const struct _lv_obj_class_t * base_class; - void (*constructor_cb)(struct _lv_obj_t * obj, struct _lv_obj_t * parent, const struct _lv_obj_t * copy); + void (*constructor_cb)(struct _lv_obj_t * obj, const struct _lv_obj_t * copy); void (*destructor_cb)(struct _lv_obj_t * obj); lv_signal_cb_t signal_cb; /**< Object type specific signal function*/ lv_draw_cb_t draw_cb; /**< Object type specific draw function*/ diff --git a/src/lv_core/lv_obj_style.c b/src/lv_core/lv_obj_style.c index cc88d785b..2d1efbd99 100644 --- a/src/lv_core/lv_obj_style.c +++ b/src/lv_core/lv_obj_style.c @@ -42,7 +42,6 @@ typedef enum { /********************** * GLOBAL PROTOTYPES **********************/ -uint8_t lv_style_get_prop_group(lv_style_prop_t prop); /********************** * STATIC PROTOTYPES @@ -491,7 +490,7 @@ static bool get_prop_core(const lv_obj_t * obj, uint8_t part, lv_style_prop_t pr break; } - uint8_t group = 1 << lv_style_get_prop_group(prop); + uint8_t group = 1 << _lv_style_get_prop_group(prop); int32_t weight = -1; lv_state_t state = obj->state; lv_state_t state_inv = ~state; diff --git a/src/lv_core/lv_obj_tree.c b/src/lv_core/lv_obj_tree.c index 8d6561f82..8124f7645 100644 --- a/src/lv_core/lv_obj_tree.c +++ b/src/lv_core/lv_obj_tree.c @@ -25,8 +25,6 @@ * TYPEDEFS **********************/ -void lv_obj_destruct(lv_obj_t * obj); - /********************** * STATIC PROTOTYPES **********************/ diff --git a/src/lv_core/lv_refr.c b/src/lv_core/lv_refr.c index 486fed1fd..3a5a25a45 100644 --- a/src/lv_core/lv_refr.c +++ b/src/lv_core/lv_refr.c @@ -276,14 +276,14 @@ void _lv_disp_refr_task(lv_timer_t * tmr) static lv_obj_t * perf_label = NULL; if(perf_label == NULL) { perf_label = lv_label_create(lv_layer_sys(), NULL); - lv_label_set_align(perf_label, LV_TEXT_ALIGN_RIGHT); - lv_obj_set_style_local_bg_opa(perf_label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_obj_set_style_local_bg_color(perf_label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); - lv_obj_set_style_local_text_color(perf_label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); - lv_obj_set_style_local_pad_top(perf_label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, 3); - lv_obj_set_style_local_pad_bottom(perf_label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, 3); - lv_obj_set_style_local_pad_left(perf_label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, 3); - lv_obj_set_style_local_pad_right(perf_label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, 3); + lv_obj_set_style_bg_opa(perf_label, LV_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER); + lv_obj_set_style_bg_color(perf_label, LV_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); + lv_obj_set_style_text_color(perf_label, LV_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); + lv_obj_set_style_pad_top(perf_label, LV_PART_MAIN, LV_STATE_DEFAULT, 3); + lv_obj_set_style_pad_bottom(perf_label, LV_PART_MAIN, LV_STATE_DEFAULT, 3); + lv_obj_set_style_pad_left(perf_label, LV_PART_MAIN, LV_STATE_DEFAULT, 3); + lv_obj_set_style_pad_right(perf_label, LV_PART_MAIN, LV_STATE_DEFAULT, 3); + lv_obj_set_style_text_align(perf_label, LV_PART_MAIN, LV_STATE_DEFAULT, LV_TEXT_ALIGN_RIGHT); lv_label_set_text(perf_label, "?"); lv_obj_align(perf_label, NULL, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0); } @@ -311,7 +311,7 @@ void _lv_disp_refr_task(lv_timer_t * tmr) fps_sum_all += fps; fps_sum_cnt ++; - uint32_t cpu = 100 - lv_task_get_idle(); + uint32_t cpu = 100 - lv_timer_get_idle(); lv_label_set_text_fmt(perf_label, "%d FPS\n%d%% CPU", fps, cpu); lv_obj_align(perf_label, NULL, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0); } diff --git a/src/lv_draw/lv_draw_arc.c b/src/lv_draw/lv_draw_arc.c index 1df0adfa2..3e8c74e04 100644 --- a/src/lv_draw/lv_draw_arc.c +++ b/src/lv_draw/lv_draw_arc.c @@ -209,6 +209,13 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin } #else LV_LOG_WARN("Can't draw arc with LV_DRAW_COMPLEX == 0"); + LV_UNUSED(center_x); + LV_UNUSED(center_y); + LV_UNUSED(radius); + LV_UNUSED(start_angle); + LV_UNUSED(end_angle); + LV_UNUSED(clip_area); + LV_UNUSED(dsc); #endif /*LV_DRAW_COMPLEX*/ } diff --git a/src/lv_draw/lv_draw_blend.c b/src/lv_draw/lv_draw_blend.c index 3aa17a3bd..e2dccc15a 100644 --- a/src/lv_draw/lv_draw_blend.c +++ b/src/lv_draw/lv_draw_blend.c @@ -675,7 +675,7 @@ LV_ATTRIBUTE_FAST_MEM static void map_normal(const lv_area_t * disp_area, lv_col const lv_color_t * map_buf_first = map_buf + map_w * (draw_area->y1 - (map_area->y1 - disp_area->y1)); map_buf_first += (draw_area->x1 - (map_area->x1 - disp_area->x1)); -#if LV_COLOR_SCREEN_TRANSP || LV_USE_GPU +#if LV_COLOR_SCREEN_TRANSP lv_disp_t * disp = _lv_refr_get_disp_refreshing(); #endif diff --git a/src/lv_draw/lv_draw_label.c b/src/lv_draw/lv_draw_label.c index d70e362f1..cb0c18173 100644 --- a/src/lv_draw/lv_draw_label.c +++ b/src/lv_draw/lv_draw_label.c @@ -38,10 +38,10 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_letter(const lv_point_t * pos_p, const LV_ATTRIBUTE_FAST_MEM 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, lv_blend_mode_t blend_mode); - +#if LV_DRAW_COMPLEX 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, lv_blend_mode_t blend_mode); - +#endif static uint8_t hex_char_to_num(char hex); /********************** @@ -381,7 +381,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area if(pos.y > mask->y2) return; } - LV_ASSERT_MALLOC_INTEGRITY(); + LV_ASSERT_MEM_INTEGRITY(); } /********************** @@ -441,8 +441,15 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_letter(const lv_point_t * pos_p, const return; } - if(font_p->subpx) draw_letter_subpx(pos_x, pos_y, &g, clip_area, map_p, color, opa, blend_mode); - else draw_letter_normal(pos_x, pos_y, &g, clip_area, map_p, color, opa, blend_mode); + if(font_p->subpx) { +#if LV_DRAW_COMPLEX + draw_letter_subpx(pos_x, pos_y, &g, clip_area, map_p, color, opa, blend_mode); +#else + LV_LOG_WARN("Can't draw sub-pixel rendered letter because LV_USE_FONT_SUBPX == 0 in lv_conf.h"); +#endif + } else { + draw_letter_normal(pos_x, pos_y, &g, clip_area, map_p, color, opa, blend_mode); + } } LV_ATTRIBUTE_FAST_MEM static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_dsc_t * g, @@ -526,15 +533,17 @@ LV_ATTRIBUTE_FAST_MEM static void draw_letter_normal(lv_coord_t pos_x, lv_coord_ fill_area.x2 = col_end + pos_x - 1; fill_area.y1 = row_start + pos_y; fill_area.y2 = fill_area.y1; - +#if LV_DRAW_COMPLEX uint8_t other_mask_cnt = lv_draw_mask_get_cnt(); +#endif uint32_t col_bit_max = 8 - bpp; uint32_t col_bit_row_ofs = (box_w + col_start - col_end) * bpp; for(row = row_start ; row < row_end; row++) { +#if LV_DRAW_COMPLEX int32_t mask_p_start = mask_p; - +#endif bitmask = bitmask_init >> col_bit; for(col = col_start; col < col_end; col++) { /*Load the pixel's opacity into the mask*/ @@ -602,10 +611,10 @@ LV_ATTRIBUTE_FAST_MEM static void draw_letter_normal(lv_coord_t pos_x, lv_coord_ lv_mem_buf_release(mask_buf); } +#if LV_DRAW_COMPLEX 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, lv_blend_mode_t blend_mode) { -#if LV_DRAW_COMPLEX const uint8_t * bpp_opa_table; uint32_t bitmask_init; uint32_t bitmask; @@ -804,10 +813,8 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_ lv_mem_buf_release(mask_buf); lv_mem_buf_release(color_buf); -#else - LV_LOG_WARN("Can't draw sub-pixel rendered letter because LV_USE_FONT_SUBPX == 0 in lv_conf.h"); -#endif } +#endif /** * Convert a hexadecimal characters to a number (0..15) diff --git a/src/lv_draw/lv_draw_line.c b/src/lv_draw/lv_draw_line.c index d191842f3..486db383e 100644 --- a/src/lv_draw/lv_draw_line.c +++ b/src/lv_draw/lv_draw_line.c @@ -124,11 +124,6 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_hor(const lv_point_t * point1, const { lv_opa_t opa = dsc->opa; - lv_disp_t * disp = _lv_refr_get_disp_refreshing(); - lv_disp_buf_t * vdb = lv_disp_get_buf(disp); - - const lv_area_t * disp_area = &vdb->area; - int32_t w = dsc->width - 1; int32_t w_half0 = w >> 1; int32_t w_half1 = w_half0 + (w & 0x1); /*Compensate rounding error*/ @@ -154,6 +149,9 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_hor(const lv_point_t * point1, const #if LV_DRAW_COMPLEX /*If there other mask apply it*/ else { + lv_disp_t * disp = _lv_refr_get_disp_refreshing(); + lv_disp_buf_t * vdb = lv_disp_get_buf(disp); + const lv_area_t * disp_area = &vdb->area; /* Get clipped fill area which is the real draw area. * It is always the same or inside `fill_area` */ bool is_common; @@ -226,11 +224,6 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_ver(const lv_point_t * point1, const { lv_opa_t opa = dsc->opa; - lv_disp_t * disp = _lv_refr_get_disp_refreshing(); - lv_disp_buf_t * vdb = lv_disp_get_buf(disp); - - const lv_area_t * disp_area = &vdb->area; - int32_t w = dsc->width - 1; int32_t w_half0 = w >> 1; int32_t w_half1 = w_half0 + (w & 0x1); /*Compensate rounding error*/ @@ -257,6 +250,9 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_ver(const lv_point_t * point1, const #if LV_DRAW_COMPLEX /*If there other mask apply it*/ else { + lv_disp_t * disp = _lv_refr_get_disp_refreshing(); + lv_disp_buf_t * vdb = lv_disp_get_buf(disp); + const lv_area_t * disp_area = &vdb->area; /* Get clipped fill area which is the real draw area. * It is always the same or inside `fill_area` */ bool is_common; @@ -484,6 +480,10 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_skew(const lv_point_t * point1, cons lv_draw_mask_remove_id(mask_top_id); lv_draw_mask_remove_id(mask_bottom_id); #else + LV_UNUSED(point1); + LV_UNUSED(point2); + LV_UNUSED(clip); + LV_UNUSED(dsc); LV_LOG_WARN("Can't draw skewed line with LV_DRAW_COMPLEX == 0"); #endif /*LV_DRAW_COMPLEX*/ } diff --git a/src/lv_draw/lv_draw_rect.c b/src/lv_draw/lv_draw_rect.c index 1a2a7fb10..57922b836 100644 --- a/src/lv_draw/lv_draw_rect.c +++ b/src/lv_draw/lv_draw_rect.c @@ -56,7 +56,7 @@ LV_ATTRIBUTE_FAST_MEM static inline lv_color_t grad_get(const lv_draw_rect_dsc_t /********************** * STATIC VARIABLES **********************/ -#if LV_SHADOW_CACHE_SIZE +#if defined(LV_SHADOW_CACHE_SIZE) && LV_SHADOW_CACHE_SIZE > 0 static uint8_t sh_cache[LV_SHADOW_CACHE_SIZE * LV_SHADOW_CACHE_SIZE]; static int32_t sh_cache_size = -1; static int32_t sh_cache_r = -1; @@ -112,7 +112,7 @@ void lv_draw_rect(const lv_area_t * coords, const lv_area_t * clip, const lv_dra draw_outline(coords, clip, dsc); - LV_ASSERT_MALLOC_INTEGRITY(); + LV_ASSERT_MEM_INTEGRITY(); } /********************** @@ -1186,7 +1186,7 @@ static void draw_content(const lv_area_t * coords, const lv_area_t * clip, const #if LV_USE_ARABIC_PERSIAN_CHARS size_t len = _lv_txt_ap_calc_bytes_cnt(dsc->content_text) + 1; - const char * txt = txt = lv_mem_buf_get(len); + char * txt = txt = lv_mem_buf_get(len); _lv_txt_ap_proc(dsc->content_text, txt); #else const char * txt = dsc->content_text; @@ -1414,5 +1414,15 @@ static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * are lv_draw_mask_remove_id(mask_rin_id); lv_draw_mask_remove_id(mask_rout_id); lv_mem_buf_release(mask_buf); + +#else /*LV_DRAW_COMPLEX*/ + LV_UNUSED(area_inner); + LV_UNUSED(area_outer); + LV_UNUSED(clip); + LV_UNUSED(radius); + LV_UNUSED(radius_is_in); + LV_UNUSED(color); + LV_UNUSED(opa); + LV_UNUSED(blend_mode); #endif /*LV_DRAW_COMPLEX*/ } diff --git a/src/lv_draw/lv_draw_triangle.c b/src/lv_draw/lv_draw_triangle.c index ea685e0d1..17f562aad 100644 --- a/src/lv_draw/lv_draw_triangle.c +++ b/src/lv_draw/lv_draw_triangle.c @@ -45,6 +45,9 @@ void lv_draw_triangle(const lv_point_t points[], const lv_area_t * clip_area, co #if LV_DRAW_COMPLEX lv_draw_polygon(points, 3, clip_area, draw_dsc); #else + LV_UNUSED(points); + LV_UNUSED(clip_area); + LV_UNUSED(draw_dsc); LV_LOG_WARN("Can't draw triangle with LV_DRAW_COMPLEX == 0"); #endif /*LV_DRAW_COMPLEX*/ } @@ -199,6 +202,10 @@ void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_are lv_mem_buf_release(mp); lv_mem_buf_release(p); #else + LV_UNUSED(points); + LV_UNUSED(point_cnt); + LV_UNUSED(clip_area); + LV_UNUSED(draw_dsc); LV_LOG_WARN("Can't draw polygon with LV_DRAW_COMPLEX == 0"); #endif /*LV_DRAW_COMPLEX*/ } diff --git a/src/lv_draw/lv_img_cache.c b/src/lv_draw/lv_img_cache.c index 1d45f0bfe..3ae10d515 100644 --- a/src/lv_draw/lv_img_cache.c +++ b/src/lv_draw/lv_img_cache.c @@ -195,6 +195,7 @@ void lv_img_cache_set_size(uint16_t new_entry_cnt) */ void lv_img_cache_invalidate_src(const void * src) { + LV_UNUSED(src); #if LV_IMG_CACHE_DEF_SIZE lv_img_cache_entry_t * cache = LV_GC_ROOT(_lv_img_cache_array); diff --git a/src/lv_misc/lv_assert.h b/src/lv_misc/lv_assert.h index 40dbc0901..5975fb168 100644 --- a/src/lv_misc/lv_assert.h +++ b/src/lv_misc/lv_assert.h @@ -15,6 +15,7 @@ extern "C" { *********************/ #include "../lv_conf_internal.h" #include +#include LV_ASSERT_HANDLER_INCLUDE /********************* * DEFINES @@ -68,9 +69,9 @@ extern "C" { #endif #if LV_USE_ASSERT_MEM_INTEGRITY -# define LV_ASSERT_MALLOC_INTEGRITY() LV_ASSERT_MSG(lv_mem_test() == LV_RES_OK, "Memory integrity error"); +# define LV_ASSERT_MEM_INTEGRITY() LV_ASSERT_MSG(lv_mem_test() == LV_RES_OK, "Memory integrity error"); #else -# define LV_ASSERT_MALLOC_INTEGRIT() +# define LV_ASSERT_MEM_INTEGRITY() #endif #ifdef __cplusplus diff --git a/src/lv_misc/lv_misc.mk b/src/lv_misc/lv_misc.mk index 66e6c84d6..3a79fb83d 100644 --- a/src/lv_misc/lv_misc.mk +++ b/src/lv_misc/lv_misc.mk @@ -14,6 +14,7 @@ CSRCS += lv_utils.c CSRCS += lv_async.c CSRCS += lv_printf.c CSRCS += lv_bidi.c +CSRCS += lv_style.c DEPPATH += --dep-path $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_misc VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_misc diff --git a/src/lv_misc/lv_style.c b/src/lv_misc/lv_style.c index ddc8f9042..09200fec5 100644 --- a/src/lv_misc/lv_style.c +++ b/src/lv_misc/lv_style.c @@ -95,12 +95,12 @@ bool lv_style_remove_prop(lv_style_t * style, lv_style_prop_t prop) size_t size = style->prop_cnt * (sizeof(lv_style_value_t) + sizeof(uint16_t)); uint8_t * new_values_and_props = lv_mem_alloc(size); - uint8_t * tmp = new_values_and_props + style->prop_cnt * sizeof(lv_style_value_t); + tmp = new_values_and_props + style->prop_cnt * sizeof(lv_style_value_t); uint16_t * new_props = (uint16_t *) tmp; lv_style_value_t * new_values = (lv_style_value_t *)new_values_and_props; uint32_t j; - for(j = 0; j < style->prop_cnt + 1; j++) { /* +1: because prop_cnt already reduced but all the old props. needs to be checked. */ + for(j = 0; j < (uint32_t)style->prop_cnt + 1; j++) { /* +1: because prop_cnt already reduced but all the old props. needs to be checked. */ if(props[j] != prop) { *new_values = values[j]; *new_props = props[j]; @@ -119,24 +119,11 @@ bool lv_style_remove_prop(lv_style_t * style, lv_style_prop_t prop) return false; } -/** - * Tell the group of a property. If the a property from a group is set in a style the (1 << group) bit of style->has_group is set. - * It allows early skipping the style if the property is not exists in the style at all. - * @param prop a style property - * @return the group [0..7] 7 means all the custom properties with index > 112 - */ -uint8_t lv_style_get_prop_group(lv_style_prop_t prop) -{ - uint16_t group = (prop & 0x1FF) >> 4; - if(group > 7) group = 7; /*The MSB marks all the custom properties*/ - return (uint8_t)group; -} - void lv_style_set_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t value) { LV_ASSERT_STYLE(style); - uint8_t group = lv_style_get_prop_group(prop); + uint8_t group = _lv_style_get_prop_group(prop); style->has_group |= 1 << group; if(style->allocated) { @@ -280,6 +267,12 @@ bool lv_style_is_empty(const lv_style_t * style) return style->prop_cnt == 0 ? true : false; } +uint8_t _lv_style_get_prop_group(lv_style_prop_t prop) +{ + uint16_t group = (prop & 0x1FF) >> 4; + if(group > 7) group = 7; /*The MSB marks all the custom properties*/ + return (uint8_t)group; +} /********************** * STATIC FUNCTIONS **********************/ diff --git a/src/lv_misc/lv_style.h b/src/lv_misc/lv_style.h index 56decfb68..18d02068c 100644 --- a/src/lv_misc/lv_style.h +++ b/src/lv_misc/lv_style.h @@ -360,6 +360,14 @@ lv_style_value_t lv_style_prop_get_default(lv_style_prop_t prop); */ bool lv_style_is_empty(const lv_style_t * style); +/** + * Tell the group of a property. If the a property from a group is set in a style the (1 << group) bit of style->has_group is set. + * It allows early skipping the style if the property is not exists in the style at all. + * @param prop a style property + * @return the group [0..7] 7 means all the custom properties with index > 112 + */ +uint8_t _lv_style_get_prop_group(lv_style_prop_t prop); + static inline void lv_style_set_radius(lv_style_t * style, lv_coord_t value) { lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_RADIUS, v); } diff --git a/src/lv_misc/lv_timer.c b/src/lv_misc/lv_timer.c index 508c3dda8..1a8ac4172 100644 --- a/src/lv_misc/lv_timer.c +++ b/src/lv_misc/lv_timer.c @@ -307,7 +307,7 @@ static bool lv_timer_exec(lv_timer_t * timer) timer_deleted = false; timer_created = false; if(timer->timer_cb) timer->timer_cb(timer); - LV_ASSERT_MALLOC_INTEGRITY(); + LV_ASSERT_MEM_INTEGRITY(); /*Delete if it was a one shot lv_timer*/ if(timer_deleted == false) { /*The timer might be deleted by itself as well*/ diff --git a/src/lv_misc/lv_txt_ap.c b/src/lv_misc/lv_txt_ap.c index 6bd7124ac..5651618c5 100644 --- a/src/lv_misc/lv_txt_ap.c +++ b/src/lv_misc/lv_txt_ap.c @@ -10,6 +10,7 @@ #include "lv_bidi.h" #include "lv_txt.h" #include "lv_txt_ap.h" +#include "lv_mem.h" #include "../lv_draw/lv_draw.h" /********************* diff --git a/src/lv_widgets/lv_arc.c b/src/lv_widgets/lv_arc.c index 46186611b..345d2251d 100644 --- a/src/lv_widgets/lv_arc.c +++ b/src/lv_widgets/lv_arc.c @@ -30,7 +30,7 @@ * STATIC PROTOTYPES **********************/ -static void lv_arc_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); +static void lv_arc_constructor(lv_obj_t * obj, const lv_obj_t * copy); static lv_draw_res_t lv_arc_draw(lv_obj_t * arc, const lv_area_t * clip_area, lv_draw_mode_t mode); static lv_res_t lv_arc_signal(lv_obj_t * arc, lv_signal_t sign, void * param); static void inv_arc_area(lv_obj_t * arc, uint16_t start_angle, uint16_t end_angle, uint8_t part); @@ -480,7 +480,7 @@ lv_arc_type_t lv_arc_get_type(const lv_obj_t * obj) * STATIC FUNCTIONS **********************/ -static void lv_arc_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +static void lv_arc_constructor(lv_obj_t * obj, const lv_obj_t * copy) { LV_LOG_TRACE("lv_arc create started"); diff --git a/src/lv_widgets/lv_bar.c b/src/lv_widgets/lv_bar.c index ef00c9ea4..b780fd8a4 100644 --- a/src/lv_widgets/lv_bar.c +++ b/src/lv_widgets/lv_bar.c @@ -45,7 +45,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_bar_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); +static void lv_bar_constructor(lv_obj_t * obj, const lv_obj_t * copy); static void lv_bar_destructor(lv_obj_t * obj); static lv_draw_res_t lv_bar_draw(lv_obj_t * bar, const lv_area_t * clip_area, lv_draw_mode_t mode); static lv_res_t lv_bar_signal(lv_obj_t * bar, lv_signal_t sign, void * param); @@ -199,7 +199,7 @@ lv_bar_type_t lv_bar_get_type(lv_obj_t * obj) * STATIC FUNCTIONS **********************/ -static void lv_bar_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +static void lv_bar_constructor(lv_obj_t * obj, const lv_obj_t * copy) { LV_LOG_TRACE("lv_bar create started"); diff --git a/src/lv_widgets/lv_btn.c b/src/lv_widgets/lv_btn.c index 13018eddf..96c67b701 100644 --- a/src/lv_widgets/lv_btn.c +++ b/src/lv_widgets/lv_btn.c @@ -22,7 +22,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_btn_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); +static void lv_btn_constructor(lv_obj_t * obj, const lv_obj_t * copy); /********************** * STATIC VARIABLES @@ -50,12 +50,14 @@ lv_obj_t * lv_btn_create(lv_obj_t * parent, const lv_obj_t * copy) * STATIC FUNCTIONS **********************/ -static void lv_btn_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +static void lv_btn_constructor(lv_obj_t * obj, const lv_obj_t * copy) { LV_LOG_TRACE("lv_btn create started"); - lv_obj_set_size(obj, LV_DPI_DEF, LV_DPI_DEF / 3); - lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); + if(copy == NULL) { + lv_obj_set_size(obj, LV_DPI_DEF, LV_DPI_DEF / 3); + lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); + } LV_LOG_INFO("btn created"); } diff --git a/src/lv_widgets/lv_btnmatrix.c b/src/lv_widgets/lv_btnmatrix.c index 9697f4e0b..10a7c87cb 100644 --- a/src/lv_widgets/lv_btnmatrix.c +++ b/src/lv_widgets/lv_btnmatrix.c @@ -32,7 +32,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_btnmatrix_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); +static void lv_btnmatrix_constructor(lv_obj_t * obj, const lv_obj_t * copy); static void lv_btnmatrix_destructor(lv_obj_t * obj); static lv_res_t lv_btnmatrix_signal(lv_obj_t * obj, lv_signal_t sign, void * param); static lv_draw_res_t lv_btnmatrix_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode); @@ -372,7 +372,7 @@ bool lv_btnmatrix_get_one_checked(const lv_obj_t * obj) * STATIC FUNCTIONS **********************/ -static void lv_btnmatrix_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +static void lv_btnmatrix_constructor(lv_obj_t * obj, const lv_obj_t * copy) { lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj; btnm->btn_cnt = 0; diff --git a/src/lv_widgets/lv_canvas.c b/src/lv_widgets/lv_canvas.c index 0d465c64f..92a415efe 100644 --- a/src/lv_widgets/lv_canvas.c +++ b/src/lv_widgets/lv_canvas.c @@ -27,8 +27,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_canvas_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); -static void lv_canvas_destructor(lv_obj_t * obj); +static void lv_canvas_constructor(lv_obj_t * obj, const lv_obj_t * copy); 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, @@ -54,7 +53,6 @@ static void set_px_alpha_generic(lv_img_dsc_t * d, lv_coord_t x, lv_coord_t y, l **********************/ const lv_obj_class_t lv_canvas_class = { .constructor_cb = lv_canvas_constructor, - .destructor_cb = lv_canvas_destructor, .instance_size = sizeof(lv_canvas_t), .base_class = &lv_img_class }; @@ -878,6 +876,13 @@ void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_ lv_obj_invalidate(canvas); #else + LV_UNUSED(canvas); + LV_UNUSED(x); + LV_UNUSED(y); + LV_UNUSED(r); + LV_UNUSED(start_angle); + LV_UNUSED(end_angle); + LV_UNUSED(draw_dsc); LV_LOG_WARN("Can't draw arc with LV_DRAW_COMPLEX == 0"); #endif } @@ -886,8 +891,9 @@ void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_ * STATIC FUNCTIONS **********************/ -static void lv_canvas_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +static void lv_canvas_constructor(lv_obj_t * obj, const lv_obj_t * copy) { + LV_UNUSED(copy); LV_LOG_TRACE("canvas create started"); lv_canvas_t * canvas = (lv_canvas_t *) obj; @@ -905,11 +911,6 @@ static void lv_canvas_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_ob LV_LOG_INFO("canvas created"); } -static void lv_canvas_destructor(lv_obj_t * obj) -{ - -} - static void set_set_px_cb(lv_disp_drv_t * disp_drv, lv_img_cf_t cf) { switch(cf) { diff --git a/src/lv_widgets/lv_chart.c b/src/lv_widgets/lv_chart.c index 355496533..329e78263 100644 --- a/src/lv_widgets/lv_chart.c +++ b/src/lv_widgets/lv_chart.c @@ -36,7 +36,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_chart_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); +static void lv_chart_constructor(lv_obj_t * obj, const lv_obj_t * copy); static void lv_chart_destructor(lv_obj_t * obj); static lv_draw_res_t lv_chart_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode); static lv_res_t lv_chart_signal(lv_obj_t * obj, lv_signal_t sign, void * param); @@ -258,6 +258,7 @@ uint16_t lv_chart_get_point_count(const lv_obj_t * obj) uint16_t lv_chart_get_x_start_point(const lv_obj_t * obj, lv_chart_series_t * ser) { + LV_UNUSED(obj); LV_ASSERT_NULL(ser); return(ser->last_point); @@ -474,6 +475,7 @@ void lv_chart_set_ext_array(lv_obj_t * obj, lv_chart_series_t * ser, lv_coord_t lv_coord_t * lv_chart_get_array(const lv_obj_t * obj, lv_chart_series_t * ser) { + LV_UNUSED(obj); LV_ASSERT_OBJ(obj, MY_CLASS); LV_ASSERT_NULL(ser); return ser->points; @@ -489,7 +491,7 @@ int32_t lv_chart_get_pressed_point(const lv_obj_t * obj) * STATIC FUNCTIONS **********************/ -static void lv_chart_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +static void lv_chart_constructor(lv_obj_t * obj, const lv_obj_t * copy) { LV_LOG_TRACE("chart create started"); @@ -505,7 +507,7 @@ static void lv_chart_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj chart->hdiv_cnt = LV_CHART_HDIV_DEF; chart->vdiv_cnt = LV_CHART_VDIV_DEF; chart->point_cnt = LV_CHART_POINT_CNT_DEF; - chart->pressed_point_id = -1; + chart->pressed_point_id = LV_CHART_POINT_ID_NONE; chart->type = LV_CHART_TYPE_LINE; chart->update_mode = LV_CHART_UPDATE_MODE_SHIFT; chart->zoom_x = LV_IMG_ZOOM_NONE; @@ -590,8 +592,7 @@ static lv_res_t lv_chart_signal(lv_obj_t * obj, lv_signal_t sign, void * param) lv_event_send(obj, LV_EVENT_VALUE_CHANGED, NULL); } } else if(sign == LV_SIGNAL_RELEASED) { -// invalidate_point(obj, chart->pressed_point_id); - chart->pressed_point_id = -1; + chart->pressed_point_id = LV_CHART_POINT_ID_NONE; } else if(sign == LV_SIGNAL_REFR_EXT_DRAW_SIZE) { lv_coord_t * s = param; *s = LV_MAX4(*s, chart->tick[LV_CHART_AXIS_X].draw_size, @@ -609,7 +610,7 @@ static void draw_div_lines(lv_obj_t * obj, const lv_area_t * clip_area) bool mask_ret = _lv_area_intersect(&series_mask, &obj->coords, clip_area); if(mask_ret == false) return; - uint32_t i; + uint16_t i; lv_point_t p1; lv_point_t p2; lv_coord_t pad_left = lv_obj_get_style_pad_left(obj, LV_PART_MAIN); diff --git a/src/lv_widgets/lv_chart.h b/src/lv_widgets/lv_chart.h index d929a71f9..e567fa59e 100644 --- a/src/lv_widgets/lv_chart.h +++ b/src/lv_widgets/lv_chart.h @@ -28,6 +28,9 @@ extern "C" { #define LV_CHART_POINT_DEF (LV_COORD_MIN) LV_EXPORT_CONST_INT(LV_CHART_POINT_DEF); +#define LV_CHART_POINT_ID_NONE 0xFFFF +LV_EXPORT_CONST_INT(LV_CHART_POINT_ID_NONE); + /********************** * TYPEDEFS **********************/ @@ -86,14 +89,13 @@ typedef struct { typedef struct { lv_obj_t obj; lv_ll_t series_ll; /**< Linked list for the data line pointers (stores lv_chart_series_t)*/ - lv_chart_tick_dsc_t tick[_LV_CHART_AXIS_LAST]; - int32_t pressed_point_id; - uint8_t hdiv_cnt; /**< Number of horizontal division lines*/ - uint8_t vdiv_cnt; /**< Number of vertical division lines*/ - uint16_t point_cnt; /**< Point number in a data line*/ lv_coord_t ymin[2]; lv_coord_t ymax[2]; + uint16_t pressed_point_id; + uint16_t hdiv_cnt; /**< Number of horizontal division lines*/ + uint16_t vdiv_cnt; /**< Number of vertical division lines*/ + uint16_t point_cnt; /**< Point number in a data line*/ uint16_t zoom_x; uint16_t zoom_y; lv_chart_type_t type :2; /**< Line or column chart */ diff --git a/src/lv_widgets/lv_checkbox.c b/src/lv_widgets/lv_checkbox.c index e474702c0..5f136f361 100644 --- a/src/lv_widgets/lv_checkbox.c +++ b/src/lv_widgets/lv_checkbox.c @@ -10,6 +10,7 @@ #if LV_USE_CHECKBOX != 0 #include "../lv_misc/lv_assert.h" +#include "../lv_misc/lv_txt_ap.h" #include "../lv_core/lv_group.h" #include "../lv_draw/lv_draw.h" @@ -25,7 +26,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_checkbox_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); +static void lv_checkbox_constructor(lv_obj_t * obj, const lv_obj_t * copy); static void lv_checkbox_destructor(lv_obj_t * obj); static lv_draw_res_t lv_checkbox_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode); static lv_res_t lv_checkbox_signal(lv_obj_t * obj, lv_signal_t sign, void * param); @@ -63,7 +64,7 @@ void lv_checkbox_set_text(lv_obj_t * obj, const char * txt) { lv_checkbox_t * cb = (lv_checkbox_t *) obj; #if LV_USE_ARABIC_PERSIAN_CHARS - size_t len = _lv_txt_ap_proc(txt); + size_t len = _lv_txt_ap_calc_bytes_cnt(txt); #else size_t len = strlen(txt); #endif @@ -107,7 +108,7 @@ const char * lv_checkbox_get_text(const lv_obj_t * obj) * STATIC FUNCTIONS **********************/ -static void lv_checkbox_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +static void lv_checkbox_constructor(lv_obj_t * obj, const lv_obj_t * copy) { LV_LOG_TRACE("lv_checkbox create started"); diff --git a/src/lv_widgets/lv_dropdown.c b/src/lv_widgets/lv_dropdown.c index 0b65cef96..cdd3c3ad3 100644 --- a/src/lv_widgets/lv_dropdown.c +++ b/src/lv_widgets/lv_dropdown.c @@ -36,12 +36,12 @@ * STATIC PROTOTYPES **********************/ static lv_obj_t * lv_dropdown_list_create(lv_obj_t * parent, const lv_obj_t * copy); -static void lv_dropdown_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); +static void lv_dropdown_constructor(lv_obj_t * obj, const lv_obj_t * copy); static void lv_dropdown_destructor(lv_obj_t * obj); static lv_draw_res_t lv_dropdown_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode); static lv_res_t lv_dropdown_signal(lv_obj_t * obj, lv_signal_t sign, void * param); -static void lv_dropdown_list_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); +static void lv_dropdown_list_constructor(lv_obj_t * obj, const lv_obj_t * copy); static void lv_dropdown_list_destructor(lv_obj_t * list_obj); static lv_draw_res_t lv_dropdown_list_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode); static lv_res_t lv_dropdown_list_signal(lv_obj_t * list, lv_signal_t sign, void * param); @@ -520,7 +520,7 @@ static lv_obj_t * lv_dropdown_list_create(lv_obj_t * parent, const lv_obj_t * co return lv_obj_create_from_class(&lv_dropdown_list_class, parent, copy); } -static void lv_dropdown_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +static void lv_dropdown_constructor(lv_obj_t * obj, const lv_obj_t * copy) { LV_LOG_TRACE("dropdown create started"); @@ -761,8 +761,9 @@ static lv_draw_res_t lv_dropdown_list_draw(lv_obj_t * list_obj, const lv_area_t return LV_DRAW_RES_OK; } -static void lv_dropdown_list_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +static void lv_dropdown_list_constructor(lv_obj_t * obj, const lv_obj_t * copy) { + LV_UNUSED(copy); lv_label_create(obj, NULL); } diff --git a/src/lv_widgets/lv_img.c b/src/lv_widgets/lv_img.c index f6cfa1f80..d28a8969f 100644 --- a/src/lv_widgets/lv_img.c +++ b/src/lv_widgets/lv_img.c @@ -28,7 +28,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_img_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); +static void lv_img_constructor(lv_obj_t * obj, const lv_obj_t * copy); static void lv_img_destructor(lv_obj_t * obj); static lv_draw_res_t lv_img_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode); static lv_res_t lv_img_signal(lv_obj_t * obj, lv_signal_t sign, void * param); @@ -360,7 +360,7 @@ bool lv_img_get_antialias(lv_obj_t * obj) * STATIC FUNCTIONS **********************/ -static void lv_img_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +static void lv_img_constructor(lv_obj_t * obj, const lv_obj_t * copy) { LV_LOG_TRACE("lv_bar create started"); @@ -386,7 +386,7 @@ static void lv_img_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t /* Enable auto size for non screens * because image screens are wallpapers * and must be screen sized*/ - if(parent) lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); + if(obj->parent) lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); } else { lv_img_t * copy_img = (lv_img_t *) copy; diff --git a/src/lv_widgets/lv_label.c b/src/lv_widgets/lv_label.c index 779966d5c..7d7902fb6 100644 --- a/src/lv_widgets/lv_label.c +++ b/src/lv_widgets/lv_label.c @@ -34,7 +34,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_label_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); +static void lv_label_constructor(lv_obj_t * obj, const lv_obj_t * copy); static void lv_label_destructor(lv_obj_t * obj); static lv_res_t lv_label_signal(lv_obj_t * label, lv_signal_t sign, void * param); static lv_draw_res_t lv_label_draw(lv_obj_t * label, const lv_area_t * clip_area, lv_draw_mode_t mode); @@ -695,7 +695,7 @@ void lv_label_cut_text(lv_obj_t * obj, uint32_t pos, uint32_t cnt) * STATIC FUNCTIONS **********************/ -static void lv_label_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +static void lv_label_constructor(lv_obj_t * obj, const lv_obj_t * copy) { LV_LOG_TRACE("label create started"); @@ -722,9 +722,11 @@ static void lv_label_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj label->dot.tmp_ptr = NULL; label->dot_tmp_alloc = 0; - lv_obj_clear_flag(obj, LV_OBJ_FLAG_CLICKABLE); - lv_label_set_long_mode(obj, LV_LABEL_LONG_EXPAND); - lv_label_set_text(obj, "Text"); + if(copy == NULL) { + lv_obj_clear_flag(obj, LV_OBJ_FLAG_CLICKABLE); + lv_label_set_long_mode(obj, LV_LABEL_LONG_EXPAND); + lv_label_set_text(obj, "Text"); + } LV_LOG_INFO("label created"); } diff --git a/src/lv_widgets/lv_line.c b/src/lv_widgets/lv_line.c index 2b2ac7ff4..897fc8ec0 100644 --- a/src/lv_widgets/lv_line.c +++ b/src/lv_widgets/lv_line.c @@ -28,8 +28,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_line_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); -static void lv_line_destructor(lv_obj_t * obj); +static void lv_line_constructor(lv_obj_t * obj, const lv_obj_t * copy); static lv_draw_res_t lv_line_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode); static lv_res_t lv_line_signal(lv_obj_t * obj, lv_signal_t sign, void * param); @@ -38,7 +37,6 @@ static lv_res_t lv_line_signal(lv_obj_t * obj, lv_signal_t sign, void * param); **********************/ const lv_obj_class_t lv_line_class = { .constructor_cb = lv_line_constructor, - .destructor_cb = lv_line_destructor, .signal_cb = lv_line_signal, .draw_cb = lv_line_draw, .instance_size = sizeof(lv_line_t), @@ -104,7 +102,7 @@ bool lv_line_get_y_invert(const lv_obj_t * obj) * STATIC FUNCTIONS **********************/ -static void lv_line_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +static void lv_line_constructor(lv_obj_t * obj, const lv_obj_t * copy) { LV_LOG_TRACE("line create started"); @@ -131,11 +129,6 @@ static void lv_line_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_ LV_LOG_INFO("line created"); } -static void lv_line_destructor(lv_obj_t * obj) -{ - -} - static lv_draw_res_t lv_line_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode) { /*A line never covers an area*/ diff --git a/src/lv_widgets/lv_meter.c b/src/lv_widgets/lv_meter.c index c08a93086..693bcd0d0 100644 --- a/src/lv_widgets/lv_meter.c +++ b/src/lv_widgets/lv_meter.c @@ -27,7 +27,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_meter_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); +static void lv_meter_constructor(lv_obj_t * obj, const lv_obj_t * copy); static void lv_meter_destructor(lv_obj_t * obj); static lv_draw_res_t lv_meter_draw(lv_obj_t * lmeter, const lv_area_t * clip_area, lv_draw_mode_t mode); static void draw_arcs(lv_obj_t * obj, const lv_area_t * clip_area, const lv_area_t * scale_area); @@ -207,7 +207,7 @@ void lv_meter_set_indicator_end_value(lv_obj_t * obj, lv_meter_indicator_t * ind * STATIC FUNCTIONS **********************/ -static void lv_meter_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +static void lv_meter_constructor(lv_obj_t * obj, const lv_obj_t * copy) { LV_LOG_TRACE("line meter create started"); diff --git a/src/lv_widgets/lv_meter.h b/src/lv_widgets/lv_meter.h index cfa3f3cdd..16239bd42 100644 --- a/src/lv_widgets/lv_meter.h +++ b/src/lv_widgets/lv_meter.h @@ -73,7 +73,7 @@ typedef struct { uint16_t tick_width; lv_color_t tick_major_color; - int16_t tick_major_nth; + uint16_t tick_major_nth; uint16_t tick_major_length; uint16_t tick_major_width; diff --git a/src/lv_widgets/lv_roller.c b/src/lv_widgets/lv_roller.c index 823dca4fe..f24b58778 100644 --- a/src/lv_widgets/lv_roller.c +++ b/src/lv_widgets/lv_roller.c @@ -28,7 +28,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_roller_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); +static void lv_roller_constructor(lv_obj_t * obj, const lv_obj_t * copy); static lv_draw_res_t lv_roller_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode); static lv_draw_res_t lv_roller_label_draw(lv_obj_t * label_obj, const lv_area_t * clip_area, lv_draw_mode_t mode); static lv_res_t lv_roller_signal(lv_obj_t * obj, lv_signal_t sign, void * param); @@ -282,7 +282,7 @@ uint16_t lv_roller_get_option_cnt(const lv_obj_t * obj) **********************/ -static void lv_roller_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +static void lv_roller_constructor(lv_obj_t * obj, const lv_obj_t * copy) { lv_roller_t * roller = (lv_roller_t*)obj; diff --git a/src/lv_widgets/lv_slider.c b/src/lv_widgets/lv_slider.c index 0f612e4d5..41283ee6c 100644 --- a/src/lv_widgets/lv_slider.c +++ b/src/lv_widgets/lv_slider.c @@ -1,4 +1,3 @@ - /** * @file lv_slider.c * @@ -32,8 +31,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_slider_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); -static void lv_slider_destructor(lv_obj_t * obj); +static void lv_slider_constructor(lv_obj_t * obj, const lv_obj_t * copy); static lv_draw_res_t lv_slider_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode); static lv_res_t lv_slider_signal(lv_obj_t * obj, lv_signal_t sign, void * param); static void position_knob(lv_obj_t * obj, lv_area_t * knob_area, lv_coord_t knob_size, bool hor); @@ -44,7 +42,6 @@ static void draw_knob(lv_obj_t * obj, const lv_area_t * clip_area); **********************/ const lv_obj_class_t lv_slider_class = { .constructor_cb = lv_slider_constructor, - .destructor_cb = lv_slider_destructor, .signal_cb = lv_slider_signal, .draw_cb = lv_slider_draw, .editable = LV_OBJ_CLASS_EDITABLE_TRUE, @@ -78,7 +75,7 @@ bool lv_slider_is_dragged(const lv_obj_t * obj) * STATIC FUNCTIONS **********************/ -static void lv_slider_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +static void lv_slider_constructor(lv_obj_t * obj, const lv_obj_t * copy) { lv_slider_t * slider = (lv_slider_t *)obj; @@ -101,15 +98,6 @@ static void lv_slider_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_ob } -static void lv_slider_destructor(lv_obj_t * obj) -{ -// lv_slider_t * slider = obj; -// -// _lv_obj_reset_style_list_no_refr(obj, LV_PART_KNOB); -// -// slider->class_p->base_p->destructor(obj); -} - static lv_draw_res_t lv_slider_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode) { /*Return false if the object is not covers the mask_p area*/ diff --git a/src/lv_widgets/lv_switch.c b/src/lv_widgets/lv_switch.c index ffd43fa33..3d1ea563f 100644 --- a/src/lv_widgets/lv_switch.c +++ b/src/lv_widgets/lv_switch.c @@ -33,8 +33,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_switch_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); -static void lv_switch_destructor(lv_obj_t * obj); +static void lv_switch_constructor(lv_obj_t * obj, const lv_obj_t * copy); static lv_res_t lv_switch_signal(lv_obj_t * obj, lv_signal_t sign, void * param); static lv_draw_res_t lv_switch_draw(lv_obj_t * sw, const lv_area_t * clip_area, lv_draw_mode_t mode); @@ -43,7 +42,6 @@ static lv_draw_res_t lv_switch_draw(lv_obj_t * sw, const lv_area_t * clip_area, **********************/ const lv_obj_class_t lv_switch_class = { .constructor_cb = lv_switch_constructor, - .destructor_cb = lv_switch_destructor, .signal_cb = lv_switch_signal, .draw_cb = lv_switch_draw, .instance_size = sizeof(lv_switch_t), @@ -74,7 +72,7 @@ lv_obj_t * lv_switch_create(lv_obj_t * parent, const lv_obj_t * copy) * STATIC FUNCTIONS **********************/ -static void lv_switch_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +static void lv_switch_constructor(lv_obj_t * obj, const lv_obj_t * copy) { LV_LOG_TRACE("switch create started"); @@ -87,16 +85,6 @@ static void lv_switch_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_ob LV_LOG_INFO("switch created"); } -static void lv_switch_destructor(lv_obj_t * obj) -{ -// lv_bar_t * bar = obj; -// -// _lv_obj_reset_style_list_no_refr(obj, LV_BAR_PART_INDIC); -// _lv_obj_reset_style_list_no_refr(sw, LV_PART_KNOB); -// -// bar->class_p->base_p->destructor(obj); -} - static lv_draw_res_t lv_switch_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode) { /*Return false if the object is not covers the mask_p area*/ diff --git a/src/lv_widgets/lv_table.c b/src/lv_widgets/lv_table.c index ee5a8d5bb..474186457 100644 --- a/src/lv_widgets/lv_table.c +++ b/src/lv_widgets/lv_table.c @@ -29,7 +29,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_table_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); +static void lv_table_constructor(lv_obj_t * obj, const lv_obj_t * copy); static void lv_table_destructor(lv_obj_t * obj); static lv_draw_res_t lv_table_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode); static lv_res_t lv_table_signal(lv_obj_t * obj, lv_signal_t sign, void * param); @@ -560,7 +560,7 @@ lv_res_t lv_table_get_pressed_cell(lv_obj_t * obj, uint16_t * row, uint16_t * co * STATIC FUNCTIONS **********************/ -static void lv_table_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +static void lv_table_constructor(lv_obj_t * obj, const lv_obj_t * copy) { LV_LOG_TRACE("lv_table create started"); @@ -597,21 +597,18 @@ static void lv_table_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj static void lv_table_destructor(lv_obj_t * obj) { -// /*Free the cell texts*/ -// uint16_t i; -// for(i = 0; i < table->col_cnt * table->row_cnt; i++) { -// if(table->cell_data[i]) { -// lv_mem_free(table->cell_data[i]); -// table->cell_data[i] = NULL; -// } -// } -// -// if(table->cell_data) lv_mem_free(table->cell_data); -// if(table->row_h) lv_mem_free(table->row_h); -// -// for(i = 0; i < LV_TABLE_CELL_STYLE_CNT; i++) { -// _lv_obj_reset_style_list_no_refr(obj, LV_TABLE_PART_CELL1 + i); -// } + lv_table_t * table = (lv_table_t *) obj; + /*Free the cell texts*/ + uint16_t i; + for(i = 0; i < table->col_cnt * table->row_cnt; i++) { + if(table->cell_data[i]) { + lv_mem_free(table->cell_data[i]); + table->cell_data[i] = NULL; + } + } + + if(table->cell_data) lv_mem_free(table->cell_data); + if(table->row_h) lv_mem_free(table->row_h); } static lv_draw_res_t lv_table_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode) diff --git a/src/lv_widgets/lv_textarea.c b/src/lv_widgets/lv_textarea.c index f377adb49..7db868b48 100644 --- a/src/lv_widgets/lv_textarea.c +++ b/src/lv_widgets/lv_textarea.c @@ -45,7 +45,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_textarea_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); +static void lv_textarea_constructor(lv_obj_t * obj, const lv_obj_t * copy); static void lv_textarea_destructor(lv_obj_t * obj); static lv_draw_res_t lv_textarea_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode); static lv_res_t lv_textarea_signal(lv_obj_t * obj, lv_signal_t sign, void * param); @@ -944,7 +944,7 @@ void lv_textarea_cursor_up(lv_obj_t * obj) * STATIC FUNCTIONS **********************/ -static void lv_textarea_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +static void lv_textarea_constructor(lv_obj_t * obj, const lv_obj_t * copy) { LV_LOG_TRACE("text area create started"); diff --git a/tests/build.py b/tests/build.py index 1c154aa79..7ba6bb080 100755 --- a/tests/build.py +++ b/tests/build.py @@ -51,11 +51,10 @@ def build(name, defines): minimal_monochrome = { "LV_COLOR_DEPTH":1, - "LV_MEM_SIZE":4 * 1024, + "LV_MEM_SIZE":64 * 1024, "LV_DPI_DEF":40, "LV_DRAW_COMPLEX":0, - "LV_USE_LOG":0, "LV_USE_LOG":0, @@ -83,246 +82,148 @@ minimal_monochrome = { # "LV_THEME_DEFAULT_FONT_TITLE" : "\\\"&lv_font_unscii_8\\\"", } -all_obj_minimal_features = { - "LV_DPI":60, - "LV_MEM_SIZE":12*1024, - "LV_HOR_RES_MAX":320, - "LV_VER_RES_MAX":240, - "LV_COLOR_DEPTH":8, - "LV_USE_GROUP":0, - "LV_USE_ANIMATION":0, - "LV_ANTIALIAS":0, - "LV_GPU":0, - "LV_USE_FILESYSTEM":0, - "LV_USE_IMG_TRANSFORM":0, - "LV_USE_API_EXTENSION_V6":0, - "LV_USE_USER_DATA":0, - "LV_USE_USER_DATA_FREE":0, + +minimal_16bit = { + "LV_COLOR_DEPTH":16, + "LV_MEM_SIZE":64 * 1024, + + "LV_DPI_DEF":40, + "LV_DRAW_COMPLEX":0, + "LV_USE_LOG":0, - "LV_USE_THEME_MATERIAL":1, - "LV_THEME_DEFAULT_INIT": "\\\"lv_theme_material_init\\\"", - "LV_THEME_DEFAULT_COLOR_PRIMARY": "\\\"LV_COLOR_RED\\\"", - "LV_THEME_DEFAULT_COLOR_SECONDARY": "\\\"LV_COLOR_BLUE\\\"", - "LV_THEME_DEFAULT_FLAG" : "\\\"LV_THEME_MATERIAL_FLAG_LIGHT\\\"", - "LV_THEME_DEFAULT_FONT_SMALL" : "\\\"&lv_font_montserrat_16\\\"", - "LV_THEME_DEFAULT_FONT_NORMAL" : "\\\"&lv_font_montserrat_16\\\"", - "LV_THEME_DEFAULT_FONT_SUBTITLE" : "\\\"&lv_font_montserrat_16\\\"", - "LV_THEME_DEFAULT_FONT_TITLE" : "\\\"&lv_font_montserrat_16\\\"", - "LV_USE_DEBUG":0, - "LV_USE_ASSERT_NULL":0, - "LV_USE_ASSERT_MEM":0, - "LV_USE_ASSERT_STR":0, - "LV_USE_ASSERT_OBJ":0, - "LV_USE_ASSERT_STYLE":0, - "LV_FONT_MONTSERRAT_12":0, - "LV_FONT_MONTSERRAT_16":1, - "LV_FONT_MONTSERRAT_22":0, - "LV_FONT_MONTSERRAT_28":0, - "LV_FONT_MONTSERRAT_12_SUBPX":0, - "LV_FONT_MONTSERRAT_28_COMPRESSED":0, - "LV_FONT_UNSCII_8":0, - "LV_USE_BIDI": 0, - "LV_USE_OBJ_REALIGN": 0, - "LV_USE_EXT_CLICK_AREA":"LV_EXT_CLICK_AREA_TINY", - "LV_USE_ARC":1, - "LV_USE_BAR":1, - "LV_USE_BTN":1, - "LV_USE_BTNM":1, - "LV_USE_CALENDAR":1, - "LV_USE_CANVAS":1, - "LV_USE_CHECKBOX":1, - "LV_USE_CHART":1, - "LV_USE_CONT":1, - "LV_USE_CPICKER":1, - "LV_USE_DROPDOWN":1, - "LV_USE_GAUGE":1, - "LV_USE_IMG":1, - "LV_USE_IMGBTN":1, - "LV_USE_KEYBOARD":1, - "LV_USE_LABEL":1, - "LV_USE_LED":1, - "LV_USE_LINE":1, - "LV_USE_LIST":1, - "LV_USE_LINEMETER":1, - "LV_USE_OBJMASK":1, - "LV_USE_MBOX":1, - "LV_USE_PAGE":1, - "LV_USE_SPINNER":0, #Disabled beacsue needs anim - "LV_USE_ROLLER":1, - "LV_USE_SLIDER":1, - "LV_USE_SPINBOX":1, - "LV_USE_SWITCH":1, - "LV_USE_TEXTAREA":1, - "LV_USE_TABLE":1, - "LV_USE_TABVIEW":1, - "LV_USE_TILEVIEW":1, - "LV_USE_WIN":1 -} -all_obj_all_features = { - "LV_DPI":100, - "LV_MEM_SIZE":32*1024, - "LV_HOR_RES_MAX":480, - "LV_VER_RES_MAX":320, - "LV_COLOR_DEPTH":32, - "LV_COLOR_SCREEN_TRANSP":1, - "LV_USE_GROUP":1, - "LV_USE_ANIMATION":1, - "LV_ANTIALIAS":1, - "LV_GPU":1, - "LV_USE_FILESYSTEM":1, - "LV_USE_IMG_TRANSFORM":1, - "LV_USE_API_EXTENSION_V6":1, - "LV_USE_USER_DATA":1, - "LV_USE_USER_DATA_FREE":0, - "LV_USE_LOG":1, - "LV_USE_THEME_MATERIAL":1, - "LV_USE_THEME_EMPTY":1, - "LV_USE_THEME_MONO":1, - "LV_THEME_DEFAULT_INIT": "\\\"lv_theme_material_init\\\"", - "LV_THEME_DEFAULT_COLOR_PRIMARY": "\\\"LV_COLOR_RED\\\"", - "LV_THEME_DEFAULT_COLOR_SECONDARY": "\\\"LV_COLOR_BLUE\\\"", - "LV_THEME_DEFAULT_FLAG" : "\\\"LV_THEME_MATERIAL_FLAG_LIGHT\\\"", - "LV_THEME_DEFAULT_FONT_SMALL" : "\\\"&lv_font_montserrat_12\\\"", - "LV_THEME_DEFAULT_FONT_NORMAL" : "\\\"&lv_font_montserrat_16\\\"", - "LV_THEME_DEFAULT_FONT_SUBTITLE" : "\\\"&lv_font_montserrat_22\\\"", - "LV_THEME_DEFAULT_FONT_TITLE" : "\\\"&lv_font_montserrat_28\\\"", - "LV_LOG_PRINTF":0, - "LV_USE_DEBUG":0, "LV_USE_ASSERT_NULL":0, - "LV_USE_ASSERT_MEM":0, - "LV_USE_ASSERT_STR":0, + "LV_USE_ASSERT_MALLOC":0, + "LV_USE_ASSERT_MEM_INTEGRITY":0, "LV_USE_ASSERT_OBJ":0, "LV_USE_ASSERT_STYLE":0, - "LV_FONT_MONTSERRAT_12":1, - "LV_FONT_MONTSERRAT_16":1, - "LV_FONT_MONTSERRAT_22":1, - "LV_FONT_MONTSERRAT_28":1, - "LV_FONT_MONTSERRAT_12_SUBPX":1, - "LV_FONT_MONTSERRAT_28_COMPRESSED":1, + + "LV_USE_USER_DATA": 0, + "LV_FONT_UNSCII_8":1, - "LV_USE_ARC":1, - "LV_USE_BAR":1, - "LV_USE_BTN":1, - "LV_USE_BTNM":1, - "LV_USE_CALENDAR":1, - "LV_USE_CANVAS":1, - "LV_USE_CHECKBOX":1, - "LV_USE_CHART":1, - "LV_USE_CONT":1, - "LV_USE_CPICKER":1, - "LV_USE_DROPDOWN":1, - "LV_USE_GAUGE":1, - "LV_USE_IMG":1, - "LV_USE_IMGBTN":1, - "LV_USE_KEYBOARD":1, - "LV_USE_LABEL":1, - "LV_USE_LED":1, - "LV_USE_LINE":1, - "LV_USE_LIST":1, - "LV_USE_LINEMETER":1, - "LV_USE_OBJMASK":1, - "LV_USE_MBOX":1, - "LV_USE_PAGE":1, - "LV_USE_SPINNER":1, - "LV_USE_ROLLER":1, - "LV_USE_SLIDER":1, - "LV_USE_SPINBOX":1, - "LV_USE_SWITCH":1, - "LV_USE_TEXTAREA":1, - "LV_USE_TABLE":1, - "LV_USE_TABVIEW":1, - "LV_USE_TILEVIEW":1, - "LV_USE_WIN":1 + + "LV_USE_BIDI": 0, + "LV_USE_ARABIC_PERSIAN_CHARS":0, + +# "LV_USE_THEME_MONO":1, +# "LV_THEME_DEFAULT_INIT": "\\\"lv_theme_mono_init\\\"", +# "LV_THEME_DEFAULT_COLOR_PRIMARY": "\\\"LV_COLOR_RED\\\"", +# "LV_THEME_DEFAULT_COLOR_SECONDARY": "\\\"LV_COLOR_BLUE\\\"", +# "LV_THEME_DEFAULT_FLAG" : "0", +# "LV_THEME_DEFAULT_FONT_SMALL" : "\\\"&lv_font_unscii_8\\\"", +# "LV_THEME_DEFAULT_FONT_NORMAL" : "\\\"&lv_font_unscii_8\\\"", +# "LV_THEME_DEFAULT_FONT_SUBTITLE" : "\\\"&lv_font_unscii_8\\\"", +# "LV_THEME_DEFAULT_FONT_TITLE" : "\\\"&lv_font_unscii_8\\\"", } -advanced_features = { - "LV_DPI":100, - "LV_MEM_SIZE":4*1024*1024, - "LV_MEM_CUSTOM":1, - "LV_HOR_RES_MAX":800, - "LV_VER_RES_MAX":480, +minimal_16bit_swap = { + "LV_COLOR_DEPTH":16, + "LV_COLOR_16_SWAP":1, + + "LV_MEM_SIZE":64 * 1024, + + "LV_DPI_DEF":40, + "LV_DRAW_COMPLEX":0, + + "LV_USE_LOG":0, + + "LV_USE_ASSERT_NULL":0, + "LV_USE_ASSERT_MALLOC":0, + "LV_USE_ASSERT_MEM_INTEGRITY":0, + "LV_USE_ASSERT_OBJ":0, + "LV_USE_ASSERT_STYLE":0, + + "LV_USE_USER_DATA": 0, + + "LV_FONT_UNSCII_8":1, + + "LV_USE_BIDI": 0, + "LV_USE_ARABIC_PERSIAN_CHARS":0, + +# "LV_USE_THEME_MONO":1, +# "LV_THEME_DEFAULT_INIT": "\\\"lv_theme_mono_init\\\"", +# "LV_THEME_DEFAULT_COLOR_PRIMARY": "\\\"LV_COLOR_RED\\\"", +# "LV_THEME_DEFAULT_COLOR_SECONDARY": "\\\"LV_COLOR_BLUE\\\"", +# "LV_THEME_DEFAULT_FLAG" : "0", +# "LV_THEME_DEFAULT_FONT_SMALL" : "\\\"&lv_font_unscii_8\\\"", +# "LV_THEME_DEFAULT_FONT_NORMAL" : "\\\"&lv_font_unscii_8\\\"", +# "LV_THEME_DEFAULT_FONT_SUBTITLE" : "\\\"&lv_font_unscii_8\\\"", +# "LV_THEME_DEFAULT_FONT_TITLE" : "\\\"&lv_font_unscii_8\\\"", +} + + +full_32bit = { "LV_COLOR_DEPTH":32, - "LV_COLOR_16_SWAP":0, - "LV_COLOR_SCREEN_TRANSP":1, - "LV_USE_GROUP":1, - "LV_USE_ANIMATION":1, - "LV_ANTIALIAS":1, - "LV_GPU":1, - "LV_USE_FILESYSTEM":1, - "LV_USE_IMG_TRANSFORM":1, - "LV_USE_API_EXTENSION_V6":1, - "LV_USE_USER_DATA":1, + "LV_MEM_SIZE":8 * 1024 * 1024, + + "LV_DPI_DEF":160, + "LV_DRAW_COMPLEX":1, + "LV_SHADOW_CACHE_SIZE":1, "LV_IMG_CACHE_DEF_SIZE":32, + "LV_USE_LOG":1, - "LV_USE_THEME_MATERIAL":1, - "LV_USE_THEME_EMPTY":1, - "LV_THEME_DEFAULT_INIT": "\\\"lv_theme_material_init\\\"", - "LV_THEME_DEFAULT_COLOR_PRIMARY": "\\\"LV_COLOR_RED\\\"", - "LV_THEME_DEFAULT_COLOR_SECONDARY": "\\\"LV_COLOR_BLUE\\\"", - "LV_THEME_DEFAULT_FLAG" : "\\\"LV_THEME_MATERIAL_FLAG_LIGHT\\\"", - "LV_THEME_DEFAULT_FONT_SMALL" : "\\\"&lv_font_montserrat_12\\\"", - "LV_THEME_DEFAULT_FONT_NORMAL" : "\\\"&lv_font_montserrat_16\\\"", - "LV_THEME_DEFAULT_FONT_SUBTITLE" : "\\\"&lv_font_montserrat_22\\\"", - "LV_THEME_DEFAULT_FONT_TITLE" : "\\\"&lv_font_montserrat_28\\\"", "LV_LOG_PRINTF":1, - "LV_USE_DEBUG":1, + "LV_FONT_SUBPX_BGR":1, + "LV_USE_PERF_MONITOR":1, + "LV_USE_ASSERT_NULL":1, - "LV_USE_ASSERT_MEM":1, - "LV_USE_ASSERT_STR":1, + "LV_USE_ASSERT_MALLOC":1, + "LV_USE_ASSERT_MEM_INTEGRITY":1, "LV_USE_ASSERT_OBJ":1, "LV_USE_ASSERT_STYLE":1, + + "LV_USE_USER_DATA": 1, + + "LV_USE_LARGE_COORD": 1, + + "LV_FONT_MONTSERRAT_8":1, + "LV_FONT_MONTSERRAT_10":1, "LV_FONT_MONTSERRAT_12":1, + "LV_FONT_MONTSERRAT_14":1, "LV_FONT_MONTSERRAT_16":1, + "LV_FONT_MONTSERRAT_18":1, + "LV_FONT_MONTSERRAT_20":1, "LV_FONT_MONTSERRAT_22":1, + "LV_FONT_MONTSERRAT_24":1, + "LV_FONT_MONTSERRAT_26":1, "LV_FONT_MONTSERRAT_28":1, - "LV_FONT_MONTSERRAT_12_SUBPX":1, - "LV_FONT_MONTSERRAT_28_COMPRESSED":1, + "LV_FONT_MONTSERRAT_30":1, + "LV_FONT_MONTSERRAT_32":1, + "LV_FONT_MONTSERRAT_34":1, + "LV_FONT_MONTSERRAT_36":1, + "LV_FONT_MONTSERRAT_38":1, + "LV_FONT_MONTSERRAT_40":1, + "LV_FONT_MONTSERRAT_42":1, + "LV_FONT_MONTSERRAT_44":1, + "LV_FONT_MONTSERRAT_46":1, + "LV_FONT_MONTSERRAT_48":1, + "LV_FONT_MONTSERRAT_12_SUBPX":1, + "LV_FONT_MONTSERRAT_28_COMPRESSED":1, + "LV_FONT_DEJAVU_16_PERSIAN_HEBREW":1, + "LV_FONT_SIMSUN_16_CJK":1, "LV_FONT_UNSCII_8":1, - "LV_USE_BIDI": 1, - "LV_USE_REVERSE_ARABIC_PERSIAN_CHARS":1, - "LV_USE_OBJ_REALIGN": 1, + "LV_FONT_UNSCII_16":1, "LV_FONT_FMT_TXT_LARGE":1, - "LV_FONT_SUBPX_BGR":1, + "LV_FONT_FMT_TXT_LARGE":1, + "LV_USE_BIDI": 1, - "LV_USE_OBJ_REALIGN": 1, - "LV_USE_EXT_CLICK_AREA":"LV_EXT_CLICK_AREA_FULL", - "LV_USE_ARC":1, - "LV_USE_BAR":1, - "LV_USE_BTN":1, - "LV_USE_BTNM":1, - "LV_USE_CALENDAR":1, - "LV_USE_CANVAS":1, - "LV_USE_CHECKBOX":1, - "LV_USE_CHART":1, - "LV_USE_CONT":1, - "LV_USE_CPICKER":1, - "LV_USE_DROPDOWN":1, - "LV_USE_GAUGE":1, - "LV_USE_IMG":1, - "LV_USE_IMGBTN":1, - "LV_USE_KEYBOARD":1, - "LV_USE_LABEL":1, - "LV_USE_LED":1, - "LV_USE_LINE":1, - "LV_USE_LIST":1, - "LV_USE_LINEMETER":1, - "LV_USE_OBJMASK":1, - "LV_USE_MBOX":1, - "LV_USE_PAGE":1, - "LV_USE_SPINNER":1, - "LV_USE_ROLLER":1, - "LV_USE_SLIDER":1, - "LV_USE_SPINBOX":1, - "LV_USE_SWITCH":1, - "LV_USE_TEXTAREA":1, - "LV_USE_TABLE":1, - "LV_USE_TABVIEW":1, - "LV_USE_TILEVIEW":1, - "LV_USE_WIN":1 + "LV_USE_ARABIC_PERSIAN_CHARS":1, + +# "LV_USE_THEME_MONO":1, +# "LV_THEME_DEFAULT_INIT": "\\\"lv_theme_mono_init\\\"", +# "LV_THEME_DEFAULT_COLOR_PRIMARY": "\\\"LV_COLOR_RED\\\"", +# "LV_THEME_DEFAULT_COLOR_SECONDARY": "\\\"LV_COLOR_BLUE\\\"", +# "LV_THEME_DEFAULT_FLAG" : "0", +# "LV_THEME_DEFAULT_FONT_SMALL" : "\\\"&lv_font_unscii_8\\\"", +# "LV_THEME_DEFAULT_FONT_NORMAL" : "\\\"&lv_font_unscii_8\\\"", +# "LV_THEME_DEFAULT_FONT_SUBTITLE" : "\\\"&lv_font_unscii_8\\\"", +# "LV_THEME_DEFAULT_FONT_TITLE" : "\\\"&lv_font_unscii_8\\\"", } -build("Minimal monochrome", minimal_monochrome) +build("Minimal config monochrome", minimal_monochrome) +build("Minimal config, 16 bit color depth", minimal_16bit) +build("Minimal config, 16 bit color depth swapped", minimal_16bit_swap) +build("Full config, 32 bit color depth", full_32bit) #build("All objects, minimal features", all_obj_minimal_features) #build("All objects, all common features", all_obj_all_features) #build("All objects, with advanced features", advanced_features) diff --git a/tests/lv_test_assert.c b/tests/lv_test_assert.c index c78fe33d7..b8b2eef15 100644 --- a/tests/lv_test_assert.c +++ b/tests/lv_test_assert.c @@ -159,6 +159,7 @@ void lv_test_assert_ptr_eq(const void * p_ref, const void * p_act, const char * void lv_test_assert_color_eq(lv_color_t c_ref, lv_color_t c_act, const char * s) { +#if LV_COLOR_16_SWAP == 0 if(c_ref.full != c_act.full) { lv_test_error(" FAIL: %s. (Expected: R:%02x, G:%02x, B:%02x, Actual: R:%02x, G:%02x, B:%02x)", s, c_ref.ch.red, c_ref.ch.green, c_ref.ch.blue, @@ -167,6 +168,12 @@ void lv_test_assert_color_eq(lv_color_t c_ref, lv_color_t c_act, const char * s) lv_test_print(" PASS: %s. (Expected: R:%02x, G:%02x, B:%02x)", s, c_ref.ch.red, c_ref.ch.green, c_ref.ch.blue); } +#else + LV_UNUSED(c_ref); + LV_UNUSED(c_act); + LV_UNUSED(s); + lv_test_print(" SKIP"); +#endif } void lv_test_assert_img_eq(const char * fn_ref, const char * s) diff --git a/tests/lv_test_core/lv_test_core.c b/tests/lv_test_core/lv_test_core.c index d500211ea..8fff22405 100644 --- a/tests/lv_test_core/lv_test_core.c +++ b/tests/lv_test_core/lv_test_core.c @@ -46,7 +46,7 @@ void lv_test_core(void) lv_test_print("*******************"); lv_test_obj(); - lv_test_style(); +// lv_test_style(); lv_test_font_loader(); } diff --git a/tests/lv_test_core/lv_test_font_loader.c b/tests/lv_test_core/lv_test_font_loader.c index ff9c6be13..6a38dc79f 100644 --- a/tests/lv_test_core/lv_test_font_loader.c +++ b/tests/lv_test_core/lv_test_font_loader.c @@ -10,9 +10,9 @@ #include "../../lvgl.h" #if LV_BUILD_TEST #include "../lv_test_assert.h" -#include "../src/lv_font/lv_font_fmt_txt.h" -#include "../src/lv_font/lv_font.h" -#include "../src/lv_font/lv_font_loader.h" +#include "../../src/lv_font/lv_font_fmt_txt.h" +#include "../../src/lv_font/lv_font.h" +#include "../../src/lv_font/lv_font_loader.h" #include "lv_test_font_loader.h" @@ -28,9 +28,7 @@ * STATIC PROTOTYPES **********************/ -#if LV_USE_FILESYSTEM static int compare_fonts(lv_font_t * f1, lv_font_t * f2); -#endif /********************** * STATIC VARIABLES @@ -50,7 +48,6 @@ extern lv_font_t font_3; void lv_test_font_loader(void) { -#if LV_USE_FILESYSTEM lv_font_t * font_1_bin = lv_font_load("F:font_1.fnt"); lv_font_t * font_2_bin = lv_font_load("F:font_2.fnt"); lv_font_t * font_3_bin = lv_font_load("F:font_3.fnt"); @@ -62,12 +59,8 @@ void lv_test_font_loader(void) lv_font_free(font_1_bin); lv_font_free(font_2_bin); lv_font_free(font_3_bin); -#else - lv_test_print("SKIP: font load test because it requires LV_USE_FILESYSTEM 1 and LV_FONT_FMT_TXT_LARGE 0"); -#endif } -#if LV_USE_FILESYSTEM static int compare_fonts(lv_font_t * f1, lv_font_t * f2) { lv_test_assert_true(f1 != NULL && f2 != NULL, "font not null"); @@ -205,7 +198,6 @@ static int compare_fonts(lv_font_t * f1, lv_font_t * f2) LV_LOG_INFO("No differences found!"); return 0; } -#endif /********************** * STATIC FUNCTIONS diff --git a/tests/lv_test_core/lv_test_obj.c b/tests/lv_test_core/lv_test_obj.c index e4708a18b..ba22bfac5 100644 --- a/tests/lv_test_core/lv_test_obj.c +++ b/tests/lv_test_core/lv_test_obj.c @@ -59,30 +59,30 @@ static void create_delete_change_parent(void) lv_test_print("-------------------------------------------------"); lv_test_print("Create an object on the default screen"); - lv_test_assert_int_eq(0, lv_obj_count_children(lv_scr_act()), "Screen's children count before creation"); + lv_test_assert_int_eq(0, lv_obj_get_child_cnt(lv_scr_act()), "Screen's children count before creation"); lv_obj_t * obj = lv_obj_create(lv_scr_act(), NULL); - lv_test_assert_int_eq(1, lv_obj_count_children(lv_scr_act()), "Screen's children count after creation"); - lv_test_assert_int_eq(0, lv_obj_count_children(obj), "New object's children count after creation"); + lv_test_assert_int_eq(1, lv_obj_get_child_cnt(lv_scr_act()), "Screen's children count after creation"); + lv_test_assert_int_eq(0, lv_obj_get_child_cnt(obj), "New object's children count after creation"); lv_test_print("Delete the created object"); lv_obj_del(obj); obj = NULL; - lv_test_assert_int_eq(0, lv_obj_count_children(lv_scr_act()), "Screen's children count after delete"); + lv_test_assert_int_eq(0, lv_obj_get_child_cnt(lv_scr_act()), "Screen's children count after delete"); lv_test_print("Create two objects"); lv_obj_t * obj_parent = lv_obj_create(lv_scr_act(), NULL); lv_obj_t * obj_child = lv_obj_create(lv_scr_act(), NULL); - lv_test_assert_int_eq(2, lv_obj_count_children(lv_scr_act()), "Screen's children count after creation"); + lv_test_assert_int_eq(2, lv_obj_get_child_cnt(lv_scr_act()), "Screen's children count after creation"); lv_test_print("Change the parent of the second object to the first"); lv_obj_set_parent(obj_child, obj_parent); - lv_test_assert_int_eq(1, lv_obj_count_children(lv_scr_act()), "Screen's children count after parent change"); - lv_test_assert_int_eq(1, lv_obj_count_children(obj_parent), "Parent object's children count after parent change"); - lv_test_assert_int_eq(0, lv_obj_count_children(obj_child), "Child object's children count after parent change"); + lv_test_assert_int_eq(1, lv_obj_get_child_cnt(lv_scr_act()), "Screen's children count after parent change"); + lv_test_assert_int_eq(1, lv_obj_get_child_cnt(obj_parent), "Parent object's children count after parent change"); + lv_test_assert_int_eq(0, lv_obj_get_child_cnt(obj_child), "Child object's children count after parent change"); lv_test_print("Remove the parent object"); lv_obj_del(obj_parent); - lv_test_assert_int_eq(0, lv_obj_count_children(lv_scr_act()), "Screen's children count after delete"); + lv_test_assert_int_eq(0, lv_obj_get_child_cnt(lv_scr_act()), "Screen's children count after delete"); } #endif diff --git a/tests/lv_test_core/lv_test_style.c b/tests/lv_test_core/lv_test_style.c index 46ac16da8..de47960cb 100644 --- a/tests/lv_test_core/lv_test_style.c +++ b/tests/lv_test_core/lv_test_style.c @@ -1,624 +1,621 @@ -/** - * @file lv_test_style.c - * - */ - -/********************* - * INCLUDES - *********************/ -#include "../../lvgl.h" -#include "../lv_test_assert.h" -#include "lv_test_style.h" - -#if LV_BUILD_TEST - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ -static void empty_style(void); -static void add_remove_read_prop(void); -static void cascade(void); -static void copy(void); -static void states(void); -static void mem_leak(void); - -/********************** - * STATIC VARIABLES - **********************/ - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -void lv_test_style(void) -{ - lv_test_print(""); - lv_test_print("===================="); - lv_test_print("Start lv_style tests"); - lv_test_print("===================="); - - empty_style(); - add_remove_read_prop(); - cascade(); - copy(); - states(); - mem_leak(); -} - -/********************** - * STATIC FUNCTIONS - **********************/ - -static void empty_style(void) -{ - lv_test_print(""); - lv_test_print("Test empty styles:"); - lv_test_print("-----------------"); - - lv_style_list_t style_list; - lv_style_list_init(&style_list); - - lv_res_t found; - lv_coord_t value; - lv_opa_t opa; - const void * ptr; - lv_color_t color; - - lv_test_print("Get a properties from an empty style"); - - found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value); - lv_test_assert_int_eq(LV_RES_INV, found, "Get an 'int' property"); - - found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA, &opa); - lv_test_assert_int_eq(LV_RES_INV, found, "Get an 'opa' property"); - - found = _lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr); - lv_test_assert_int_eq(LV_RES_INV, found, "Get a 'ptr' property"); - - found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color); - lv_test_assert_int_eq(LV_RES_INV, found, "Get a 'color' property"); -} - -static void add_remove_read_prop(void) -{ - lv_test_print(""); - lv_test_print("Add, remove and read properties:"); - lv_test_print("--------------------------------"); - - lv_style_list_t style_list; - lv_style_list_init(&style_list); - - lv_style_t style; - lv_style_init(&style); - - _lv_style_list_add_style(&style_list, &style); - - lv_res_t found; - lv_coord_t value; - lv_opa_t opa; - const void * ptr; - lv_color_t color; - - lv_test_print("Add an empty style and read properties"); - - found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value); - lv_test_assert_int_eq(LV_RES_INV, found, "Get a non existing 'int' property"); - - found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA, &opa); - lv_test_assert_int_eq(LV_RES_INV, found, "Get a non existing 'opa' property"); - - found = _lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr); - lv_test_assert_int_eq(LV_RES_INV, found, "Get a non existing 'ptr' property"); - - found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color); - lv_test_assert_int_eq(LV_RES_INV, found, "Get a non existing 'color' property"); - - lv_test_print("Set properties and read back the values"); - _lv_style_set_int(&style, LV_STYLE_TEXT_LINE_SPACE, 5); - _lv_style_set_opa(&style, LV_STYLE_BG_OPA, LV_OPA_50); - _lv_style_set_ptr(&style, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL); - _lv_style_set_color(&style, LV_STYLE_BG_COLOR, LV_COLOR_RED); - - found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value); - lv_test_assert_int_eq(LV_RES_OK, found, "Get an existing 'int' property"); - lv_test_assert_int_eq(5, value, "Get the value of an 'int' property"); - - found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA, &opa); - lv_test_assert_int_eq(LV_RES_OK, found, "Get an existing 'opa' property"); - lv_test_assert_int_eq(LV_OPA_50, opa, "Get the value of an 'opa' property"); - - found = _lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr); - lv_test_assert_int_eq(LV_RES_OK, found, "Get an existing 'ptr' property"); - lv_test_assert_ptr_eq(LV_THEME_DEFAULT_FONT_NORMAL, ptr, "Get the value of a 'ptr' property"); - - found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color); - lv_test_assert_int_eq(LV_RES_OK, found, "Get an existing 'color' property"); - lv_test_assert_color_eq(LV_COLOR_RED, color, "Get the value of a 'color' property"); - - lv_test_print("Reset the style"); - lv_style_reset(&style); - found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value); - lv_test_assert_int_eq(LV_RES_INV, found, "Get an 'int' property from a reseted style"); - - found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA, &opa); - lv_test_assert_int_eq(LV_RES_INV, found, "Get an 'opa' property from a reseted style"); - - found = _lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr); - lv_test_assert_int_eq(LV_RES_INV, found, "Get an 'ptr' property from a reseted style"); - - found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color); - lv_test_assert_int_eq(LV_RES_INV, found, "Get an 'color' property from a reseted style"); - - /*Clean-up*/ - _lv_style_list_reset(&style_list); -} - -static void cascade(void) -{ - lv_test_print(""); - lv_test_print("Cascade style styles:"); - lv_test_print("----------------------"); - - lv_style_list_t style_list; - lv_style_list_init(&style_list); - - lv_style_t style_first; - lv_style_init(&style_first); - _lv_style_list_add_style(&style_list, &style_first); - - lv_style_t style_second; - lv_style_init(&style_second); - _lv_style_list_add_style(&style_list, &style_second); - - lv_res_t found; - lv_coord_t value; - lv_opa_t opa; - const void * ptr; - lv_color_t color; - - lv_test_print("Read properties set only in the firstly added style"); - - _lv_style_set_int(&style_first, LV_STYLE_TEXT_LINE_SPACE, 5); - _lv_style_set_opa(&style_first, LV_STYLE_BG_OPA, LV_OPA_50); - _lv_style_set_ptr(&style_first, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL); - _lv_style_set_color(&style_first, LV_STYLE_BG_COLOR, LV_COLOR_RED); - - found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value); - lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'int' property"); - lv_test_assert_int_eq(5, value, "Get the value of an 'int' property"); - - found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA, &opa); - lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'opa' property"); - lv_test_assert_int_eq(LV_OPA_50, opa, "Get the value of an 'opa' property"); - - found = _lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr); - lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'ptr' property"); - lv_test_assert_ptr_eq(LV_THEME_DEFAULT_FONT_NORMAL, ptr, "Get the value of a 'ptr' property"); - - found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color); - lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'color' property"); - lv_test_assert_color_eq(LV_COLOR_RED, color, "Get the value of a 'color' property"); - - lv_test_print("Overwrite the properties from the second style"); - - _lv_style_set_int(&style_second, LV_STYLE_TEXT_LINE_SPACE, 10); - _lv_style_set_opa(&style_second, LV_STYLE_BG_OPA, LV_OPA_60); - _lv_style_set_ptr(&style_second, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL + 1); - _lv_style_set_color(&style_second, LV_STYLE_BG_COLOR, LV_COLOR_BLUE); - - found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value); - lv_test_assert_int_eq(LV_RES_OK, found, "Get an overwritten 'int' property"); - lv_test_assert_int_eq(10, value, "Get the value of an overwritten 'int' property"); - - found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA, &opa); - lv_test_assert_int_eq(LV_RES_OK, found, "Get an overwritten 'opa' property"); - lv_test_assert_int_eq(LV_OPA_60, opa, "Get the value of an overwritten 'opa' property"); - - found = _lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr); - lv_test_assert_int_eq(LV_RES_OK, found, "Get an overwritten 'ptr' property"); - lv_test_assert_ptr_eq(LV_THEME_DEFAULT_FONT_NORMAL + 1, ptr, "Get the value of an overwritten 'ptr' property"); - - found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color); - lv_test_assert_int_eq(LV_RES_OK, found, "Get an overwritten 'color' property"); - lv_test_assert_color_eq(LV_COLOR_BLUE, color, "Get the value of an overwritten 'color' property"); - - lv_test_print("Overwrite the properties with the local style"); - _lv_style_list_set_local_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, 20); - _lv_style_list_set_local_opa(&style_list, LV_STYLE_BG_OPA, LV_OPA_70); - _lv_style_list_set_local_ptr(&style_list, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL + 2); - _lv_style_list_set_local_color(&style_list, LV_STYLE_BG_COLOR, LV_COLOR_LIME); - - found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value); - lv_test_assert_int_eq(LV_RES_OK, found, "Get a local 'int' property"); - lv_test_assert_int_eq(20, value, "Get the value of a local 'int' property"); - - found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA, &opa); - lv_test_assert_int_eq(LV_RES_OK, found, "Get a local 'opa' property"); - lv_test_assert_int_eq(LV_OPA_70, opa, "Get the value of a local 'opa' property"); - - found = _lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr); - lv_test_assert_int_eq(LV_RES_OK, found, "Get a local 'ptr' property"); - lv_test_assert_ptr_eq(LV_THEME_DEFAULT_FONT_NORMAL + 2, ptr, "Get the value of a local'ptr' property"); - - found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color); - lv_test_assert_int_eq(LV_RES_OK, found, "Get a local 'color' property"); - lv_test_assert_color_eq(LV_COLOR_LIME, color, "Get the value of a local'color' property"); - - /*Clean-up*/ - _lv_style_list_reset(&style_list); -} - -static void copy(void) -{ - lv_test_print(""); - lv_test_print("Copy styles and style lists"); - lv_test_print("---------------------------"); - - lv_test_print("Copy a style"); - lv_style_t style_src; - lv_style_init(&style_src); - _lv_style_set_int(&style_src, LV_STYLE_TEXT_LINE_SPACE, 5); - - lv_style_t style_dest; - lv_style_init(&style_dest); - lv_style_copy(&style_dest, &style_src); - - int16_t weight; - lv_coord_t value; - - weight = _lv_style_get_int(&style_dest, LV_STYLE_TEXT_LINE_SPACE, &value); - lv_test_assert_int_eq(0, weight, "Get a copied property from a style"); - lv_test_assert_int_eq(5, value, "Get the value of a copied from a property"); - - lv_test_print("Copy a style list"); - lv_style_list_t list_src; - lv_style_list_init(&list_src); - _lv_style_list_add_style(&list_src, &style_src); - _lv_style_list_set_local_int(&list_src, LV_STYLE_LINE_DASH_WIDTH, 20); - - lv_style_list_t list_dest; - lv_style_list_init(&list_dest); - lv_style_list_copy(&list_dest, &list_src); - - lv_res_t found; - found = _lv_style_list_get_int(&list_dest, LV_STYLE_TEXT_LINE_SPACE, &value); - lv_test_assert_int_eq(LV_RES_OK, found, "Get a copied property from a list"); - lv_test_assert_int_eq(5, value, "Get the value of a copied property from a list"); - found = _lv_style_list_get_int(&list_dest, LV_STYLE_LINE_DASH_WIDTH, &value); - lv_test_assert_int_eq(LV_RES_OK, found, "Get a copied local property from a list"); - lv_test_assert_int_eq(20, value, "Get the value of a copied local property from a list"); - - /*Clean up*/ - _lv_style_list_reset(&list_dest); - _lv_style_list_reset(&list_src); - - lv_style_reset(&style_dest); - lv_style_reset(&style_src); -} - -static void states(void) -{ - lv_test_print(""); - lv_test_print("Test style states:"); - lv_test_print("------------------"); - - lv_style_list_t style_list; - lv_style_list_init(&style_list); - - lv_style_t style_first; - lv_style_init(&style_first); - _lv_style_list_add_style(&style_list, &style_first); - - lv_style_t style_second; - lv_style_init(&style_second); - _lv_style_list_add_style(&style_list, &style_second); - - lv_test_print("Test state precedence in 1 style"); - _lv_style_set_int(&style_first, LV_STYLE_TEXT_LINE_SPACE, 5); - _lv_style_set_int(&style_first, LV_STYLE_TEXT_LINE_SPACE | (LV_STATE_CHECKED) << LV_STYLE_STATE_POS, 6); - _lv_style_set_int(&style_first, LV_STYLE_TEXT_LINE_SPACE | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, 7); - - lv_res_t found; - lv_coord_t value; - - found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value); - lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'int' property in normal state"); - lv_test_assert_int_eq(5, value, "Get the value of an 'int' property in normal state"); - - found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE | (LV_STATE_CHECKED) << LV_STYLE_STATE_POS, &value); - lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'int' property in checked state"); - lv_test_assert_int_eq(6, value, "Get the value of an 'int' in checked state"); - - found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, &value); - lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'int' property in pressed state"); - lv_test_assert_int_eq(7, value, "Get the value of an 'int' in pressed state"); - - found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE | (LV_STATE_HOVERED) << LV_STYLE_STATE_POS, &value); - lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'int' property in hover (unspecified) state"); - lv_test_assert_int_eq(5, value, "Get the value of an 'int' in hover (unspecified) state"); - - found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE | (LV_STATE_CHECKED | LV_STATE_PRESSED | LV_STATE_HOVERED) << LV_STYLE_STATE_POS, &value); - lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'int' property in checked pressed hovered state"); - lv_test_assert_int_eq(7, value, "Get the value of an 'int' in checked pressed hovered state"); - - lv_test_print("Test state precedence in 1 style with combined states"); - _lv_style_set_opa(&style_first, LV_STYLE_BG_OPA, LV_OPA_50); - _lv_style_set_opa(&style_first, LV_STYLE_BG_OPA | (LV_STATE_CHECKED | LV_STATE_PRESSED) << LV_STYLE_STATE_POS, LV_OPA_60); - - lv_opa_t opa; - found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA , &opa); - lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'opa' property in normal state"); - lv_test_assert_int_eq(LV_OPA_50, opa, "Get the value of an 'int' in normal state"); - - found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA | (LV_STATE_CHECKED) << LV_STYLE_STATE_POS, &opa); - lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'opa' property in checked (unspecified) state"); - lv_test_assert_int_eq(LV_OPA_50, opa, "Get the value of an 'int' in checked (unspecified) state"); - - found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA | (LV_STATE_CHECKED | LV_STATE_PRESSED) << LV_STYLE_STATE_POS, &opa); - lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'opa' property in checked pressed state"); - lv_test_assert_int_eq(LV_OPA_60, opa, "Get the value of an 'int' in checked pressed state"); - - found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA | (LV_STATE_CHECKED | LV_STATE_PRESSED | LV_STATE_HOVERED) << LV_STYLE_STATE_POS, &opa); - lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'opa' property in checked pressed hovered state"); - lv_test_assert_int_eq(LV_OPA_60, opa, "Get the value of an 'int' in checked pressed hovered state"); - - lv_test_print("Test state precedence in 2 styles"); - _lv_style_set_color(&style_first, LV_STYLE_BG_COLOR, LV_COLOR_YELLOW); - _lv_style_set_color(&style_first, LV_STYLE_BG_COLOR | (LV_STATE_HOVERED) << LV_STYLE_STATE_POS, LV_COLOR_RED); - _lv_style_set_color(&style_second, LV_STYLE_BG_COLOR | (LV_STATE_CHECKED) << LV_STYLE_STATE_POS, LV_COLOR_LIME); - _lv_style_set_color(&style_second, LV_STYLE_BG_COLOR | (LV_STATE_HOVERED | LV_STATE_PRESSED) << LV_STYLE_STATE_POS, LV_COLOR_BLUE); - - lv_color_t color; - - found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color); - lv_test_assert_int_eq(LV_RES_OK, found, "Get a 'color' property in normal state"); - lv_test_assert_color_eq(LV_COLOR_YELLOW, color, "Get the value of a 'color' property in normal state"); - - found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR | (LV_STATE_HOVERED) << LV_STYLE_STATE_POS, &color); - lv_test_assert_int_eq(LV_RES_OK, found, "Get a 'color' property in hovered state"); - lv_test_assert_color_eq(LV_COLOR_RED, color, "Get the value of a 'color' in hovered state"); - - found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR | (LV_STATE_CHECKED) << LV_STYLE_STATE_POS, &color); - lv_test_assert_int_eq(LV_RES_OK, found, "Get a 'color' property in checked state"); - lv_test_assert_color_eq(LV_COLOR_LIME, color, "Get the value of a 'color' in checked state"); - - found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR | (LV_STATE_HOVERED | LV_STATE_PRESSED) << LV_STYLE_STATE_POS, &color); - lv_test_assert_int_eq(LV_RES_OK, found, "Get a 'color' property in hover pressed state"); - lv_test_assert_color_eq(LV_COLOR_BLUE, color, "Get the value of a 'color' in hover pressed state"); - - found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR | (LV_STATE_EDITED) << LV_STYLE_STATE_POS, &color); - lv_test_assert_int_eq(LV_RES_OK, found, "Get a 'color' property in edit (unspecified) state"); - lv_test_assert_color_eq(LV_COLOR_YELLOW, color, "Get the value of a 'color' in edit (unspecified) state"); - - found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR | (LV_STATE_CHECKED | LV_STATE_EDITED) << LV_STYLE_STATE_POS, &color); - lv_test_assert_int_eq(LV_RES_OK, found, "Get a 'color' property in checked edit state"); - lv_test_assert_color_eq(LV_COLOR_LIME, color, "Get the value of a 'color' in checked edit state"); - - /*Clean-up*/ - _lv_style_list_reset(&style_list); -} - -static void mem_leak(void) -{ - - lv_test_print(""); - lv_test_print("Test style set, add, remove memory leak"); - lv_test_print("----------------------------------------"); - - lv_mem_monitor_t mon_start; - lv_mem_monitor_t mon_end; - - lv_style_list_t style_list; - lv_style_list_init(&style_list); - - lv_style_t style1; - lv_style_init(&style1); - - lv_style_t style2; - lv_style_init(&style2); - - lv_style_t style3; - lv_style_init(&style3); - - uint32_t i; - - lv_test_print("Set style properties"); - lv_mem_monitor(&mon_start); - for(i = 0; i < 100; i++) { - _lv_style_set_color(&style2, LV_STYLE_LINE_COLOR, LV_COLOR_RED); - - _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR, LV_COLOR_RED); - _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR | (LV_STATE_EDITED) << LV_STYLE_STATE_POS, LV_COLOR_BLUE); - _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR, LV_COLOR_BLUE); - _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR | (LV_STATE_EDITED | LV_STATE_FOCUSED) << LV_STYLE_STATE_POS, LV_COLOR_GREEN); - - _lv_style_set_color(&style3, LV_STYLE_BG_COLOR, LV_COLOR_RED); - - _lv_style_set_color(&style3, LV_STYLE_IMAGE_RECOLOR, LV_COLOR_RED); - - lv_style_reset(&style1); - lv_style_reset(&style2); - lv_style_reset(&style3); - - } - - lv_test_assert_int_eq(LV_RES_OK, lv_mem_test(), "Memory integrity check"); - lv_mem_defrag(); - lv_mem_monitor(&mon_end); - lv_test_assert_int_lt(sizeof(void*) * 8, mon_start.free_size - mon_end.free_size, "Style memory leak"); - - lv_test_print("Use local style"); - lv_mem_monitor(&mon_start); - for(i = 0; i < 100; i++) { - _lv_style_list_set_local_ptr(&style_list, LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, LV_THEME_DEFAULT_FONT_NORMAL); - - _lv_style_list_reset(&style_list); - - _lv_style_list_set_local_ptr(&style_list, LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, NULL); - _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK); - _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK); - _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK); - _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK); - _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK); - _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK); - - _lv_style_list_reset(&style_list); - } - - _lv_style_list_reset(&style_list); - lv_test_assert_int_eq(LV_RES_OK, lv_mem_test(), "Memory integrity check"); - lv_mem_defrag(); - lv_mem_monitor(&mon_end); - lv_test_assert_int_lt(sizeof(void*) * 8, mon_start.free_size - mon_end.free_size, "Style memory leak"); - - lv_test_print("Add styles"); - lv_mem_monitor(&mon_start); - for(i = 0; i < 100; i++) { - _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR, LV_COLOR_RED); - _lv_style_set_color(&style2, LV_STYLE_LINE_COLOR, LV_COLOR_RED); - _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR, LV_COLOR_RED); - - _lv_style_list_add_style(&style_list, &style1); - _lv_style_list_remove_style(&style_list, &style1); - - _lv_style_list_add_style(&style_list, &style2); - _lv_style_list_add_style(&style_list, &style3); - - _lv_style_list_remove_style(&style_list, &style2); - _lv_style_list_add_style(&style_list, &style1); - - _lv_style_list_reset(&style_list); - lv_style_reset(&style1); - lv_style_reset(&style2); - lv_style_reset(&style3); - } - - lv_test_assert_int_eq(LV_RES_OK, lv_mem_test(), "Memory integrity check"); - lv_mem_defrag(); - lv_mem_monitor(&mon_end); - lv_test_assert_int_lt(sizeof(void*) * 8, mon_start.free_size - mon_end.free_size, "Style memory leak"); - - lv_test_print("Add styles and use local style"); - lv_mem_monitor(&mon_start); - for(i = 0; i < 100; i++) { - _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR, LV_COLOR_RED); - _lv_style_set_color(&style2, LV_STYLE_LINE_COLOR, LV_COLOR_RED); - _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR, LV_COLOR_RED); - - if(i % 2 == 0) _lv_style_list_set_local_color(&style_list, LV_STYLE_LINE_COLOR, LV_COLOR_RED); - - _lv_style_list_add_style(&style_list, &style1); - _lv_style_list_remove_style(&style_list, &style1); - - _lv_style_list_add_style(&style_list, &style2); - _lv_style_list_add_style(&style_list, &style3); - - _lv_style_list_remove_style(&style_list, &style2); - _lv_style_list_add_style(&style_list, &style1); - - if(i % 2 != 0) _lv_style_list_set_local_color(&style_list, LV_STYLE_LINE_COLOR, LV_COLOR_RED); - - _lv_style_list_reset(&style_list); - lv_style_reset(&style1); - lv_style_reset(&style2); - lv_style_reset(&style3); - } - - lv_test_assert_int_eq(LV_RES_OK, lv_mem_test(), "Memory integrity check"); - lv_mem_defrag(); - lv_mem_monitor(&mon_end); - lv_test_assert_int_lt(sizeof(void*) * 8, mon_start.free_size - mon_end.free_size, "Style memory leak"); - - lv_test_print("Complex test"); - - lv_mem_monitor(&mon_start); - - for(i = 0; i < 100; i++) { - if(i % 2 == 0) { - _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_CLOSE); - } - - _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR, LV_COLOR_RED); - _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR | (LV_STATE_EDITED) << LV_STYLE_STATE_POS, LV_COLOR_BLUE); - _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR, LV_COLOR_BLUE); - _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR | (LV_STATE_EDITED | LV_STATE_FOCUSED) << LV_STYLE_STATE_POS, LV_COLOR_GREEN); - - _lv_style_list_add_style(&style_list, &style1); - - if(i % 4 == 0) { - _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_CLOSE); - } - - _lv_style_list_remove_style(&style_list, &style1); - - _lv_style_set_opa(&style2, LV_STYLE_TEXT_OPA, LV_OPA_10); - _lv_style_set_opa(&style2, LV_STYLE_TEXT_OPA, LV_OPA_20); - _lv_style_set_opa(&style2, LV_STYLE_TEXT_OPA, LV_OPA_30); - _lv_style_set_opa(&style2, LV_STYLE_TEXT_OPA, LV_OPA_40); - _lv_style_set_opa(&style2, LV_STYLE_TEXT_OPA, LV_OPA_50); - _lv_style_set_opa(&style2, LV_STYLE_TEXT_OPA, LV_OPA_60); - - _lv_style_list_add_style(&style_list, &style2); - - if(i % 8 == 0) { - _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_CLOSE); - } - - _lv_style_list_add_style(&style_list, &style2); - _lv_style_list_add_style(&style_list, &style2); - _lv_style_list_add_style(&style_list, &style2); - _lv_style_list_add_style(&style_list, &style2); - _lv_style_list_remove_style(&style_list, &style2); - - _lv_style_set_int(&style3, LV_STYLE_PAD_LEFT, 10); - _lv_style_set_int(&style3, LV_STYLE_PAD_RIGHT, 20); - _lv_style_set_int(&style3, LV_STYLE_PAD_LEFT, 11); - _lv_style_set_int(&style3, LV_STYLE_PAD_RIGHT, 21); - _lv_style_set_int(&style3, LV_STYLE_PAD_LEFT, 12); - _lv_style_set_int(&style3, LV_STYLE_PAD_RIGHT, 22); - _lv_style_set_int(&style3, LV_STYLE_PAD_LEFT, 12); - _lv_style_set_int(&style3, LV_STYLE_PAD_RIGHT, 23); - - _lv_style_list_set_local_ptr(&style_list, LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, LV_THEME_DEFAULT_FONT_NORMAL); - _lv_style_list_set_local_ptr(&style_list, LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, NULL); - _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK); - _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK); - _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK); - _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK); - _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK); - _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK); - - _lv_style_list_add_style(&style_list, &style3); - _lv_style_list_add_style(&style_list, &style2); - _lv_style_list_add_style(&style_list, &style1); - - _lv_style_list_reset(&style_list); - lv_style_reset(&style1); - lv_style_reset(&style2); - lv_style_reset(&style3); - - } - - _lv_style_list_reset(&style_list); - lv_style_reset(&style1); - lv_style_reset(&style2); - lv_style_reset(&style3); - - lv_test_assert_int_eq(LV_RES_OK, lv_mem_test(), "Memory integrity check"); - lv_mem_defrag(); - lv_mem_monitor(&mon_end); - lv_test_assert_int_lt(sizeof(void*) * 8, mon_start.free_size - mon_end.free_size, "Style memory leak"); -} -#endif +///** +// * @file lv_test_style.c +// * +// */ +// +///********************* +// * INCLUDES +// *********************/ +//#include "../../lvgl.h" +//#include "../lv_test_assert.h" +//#include "lv_test_style.h" +// +//#if LV_BUILD_TEST +// +///********************* +// * DEFINES +// *********************/ +// +///********************** +// * TYPEDEFS +// **********************/ +// +///********************** +// * STATIC PROTOTYPES +// **********************/ +//static void empty_style(void); +//static void add_remove_read_prop(void); +//static void cascade(void); +//static void copy(void); +//static void states(void); +//static void mem_leak(void); +// +///********************** +// * STATIC VARIABLES +// **********************/ +// +///********************** +// * MACROS +// **********************/ +// +///********************** +// * GLOBAL FUNCTIONS +// **********************/ +// +//void lv_test_style(void) +//{ +// lv_test_print(""); +// lv_test_print("===================="); +// lv_test_print("Start lv_style tests"); +// lv_test_print("===================="); +// +// empty_style(); +// add_remove_read_prop(); +// cascade(); +// copy(); +// states(); +// mem_leak(); +//} +// +///********************** +// * STATIC FUNCTIONS +// **********************/ +// +//static void empty_style(void) +//{ +// lv_test_print(""); +// lv_test_print("Test empty styles:"); +// lv_test_print("-----------------"); +// +// lv_res_t found; +// lv_coord_t value; +// lv_opa_t opa; +// const void * ptr; +// lv_color_t color; +// +// lv_test_print("Get a properties from an empty style"); +// +// found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value); +// lv_test_assert_int_eq(LV_RES_INV, found, "Get an 'int' property"); +// +// found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA, &opa); +// lv_test_assert_int_eq(LV_RES_INV, found, "Get an 'opa' property"); +// +// found = _lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr); +// lv_test_assert_int_eq(LV_RES_INV, found, "Get a 'ptr' property"); +// +// found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color); +// lv_test_assert_int_eq(LV_RES_INV, found, "Get a 'color' property"); +//} +// +//static void add_remove_read_prop(void) +//{ +// lv_test_print(""); +// lv_test_print("Add, remove and read properties:"); +// lv_test_print("--------------------------------"); +// +// lv_style_list_t style_list; +// lv_style_list_init(&style_list); +// +// lv_style_t style; +// lv_style_init(&style); +// +// _lv_style_list_add_style(&style_list, &style); +// +// lv_res_t found; +// lv_coord_t value; +// lv_opa_t opa; +// const void * ptr; +// lv_color_t color; +// +// lv_test_print("Add an empty style and read properties"); +// +// found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value); +// lv_test_assert_int_eq(LV_RES_INV, found, "Get a non existing 'int' property"); +// +// found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA, &opa); +// lv_test_assert_int_eq(LV_RES_INV, found, "Get a non existing 'opa' property"); +// +// found = _lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr); +// lv_test_assert_int_eq(LV_RES_INV, found, "Get a non existing 'ptr' property"); +// +// found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color); +// lv_test_assert_int_eq(LV_RES_INV, found, "Get a non existing 'color' property"); +// +// lv_test_print("Set properties and read back the values"); +// _lv_style_set_int(&style, LV_STYLE_TEXT_LINE_SPACE, 5); +// _lv_style_set_opa(&style, LV_STYLE_BG_OPA, LV_OPA_50); +// _lv_style_set_ptr(&style, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL); +// _lv_style_set_color(&style, LV_STYLE_BG_COLOR, LV_COLOR_RED); +// +// found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get an existing 'int' property"); +// lv_test_assert_int_eq(5, value, "Get the value of an 'int' property"); +// +// found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA, &opa); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get an existing 'opa' property"); +// lv_test_assert_int_eq(LV_OPA_50, opa, "Get the value of an 'opa' property"); +// +// found = _lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get an existing 'ptr' property"); +// lv_test_assert_ptr_eq(LV_THEME_DEFAULT_FONT_NORMAL, ptr, "Get the value of a 'ptr' property"); +// +// found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get an existing 'color' property"); +// lv_test_assert_color_eq(LV_COLOR_RED, color, "Get the value of a 'color' property"); +// +// lv_test_print("Reset the style"); +// lv_style_reset(&style); +// found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value); +// lv_test_assert_int_eq(LV_RES_INV, found, "Get an 'int' property from a reseted style"); +// +// found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA, &opa); +// lv_test_assert_int_eq(LV_RES_INV, found, "Get an 'opa' property from a reseted style"); +// +// found = _lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr); +// lv_test_assert_int_eq(LV_RES_INV, found, "Get an 'ptr' property from a reseted style"); +// +// found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color); +// lv_test_assert_int_eq(LV_RES_INV, found, "Get an 'color' property from a reseted style"); +// +// /*Clean-up*/ +// _lv_style_list_reset(&style_list); +//} +// +//static void cascade(void) +//{ +// lv_test_print(""); +// lv_test_print("Cascade style styles:"); +// lv_test_print("----------------------"); +// +// lv_style_list_t style_list; +// lv_style_list_init(&style_list); +// +// lv_style_t style_first; +// lv_style_init(&style_first); +// _lv_style_list_add_style(&style_list, &style_first); +// +// lv_style_t style_second; +// lv_style_init(&style_second); +// _lv_style_list_add_style(&style_list, &style_second); +// +// lv_res_t found; +// lv_coord_t value; +// lv_opa_t opa; +// const void * ptr; +// lv_color_t color; +// +// lv_test_print("Read properties set only in the firstly added style"); +// +// _lv_style_set_int(&style_first, LV_STYLE_TEXT_LINE_SPACE, 5); +// _lv_style_set_opa(&style_first, LV_STYLE_BG_OPA, LV_OPA_50); +// _lv_style_set_ptr(&style_first, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL); +// _lv_style_set_color(&style_first, LV_STYLE_BG_COLOR, LV_COLOR_RED); +// +// found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'int' property"); +// lv_test_assert_int_eq(5, value, "Get the value of an 'int' property"); +// +// found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA, &opa); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'opa' property"); +// lv_test_assert_int_eq(LV_OPA_50, opa, "Get the value of an 'opa' property"); +// +// found = _lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'ptr' property"); +// lv_test_assert_ptr_eq(LV_THEME_DEFAULT_FONT_NORMAL, ptr, "Get the value of a 'ptr' property"); +// +// found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'color' property"); +// lv_test_assert_color_eq(LV_COLOR_RED, color, "Get the value of a 'color' property"); +// +// lv_test_print("Overwrite the properties from the second style"); +// +// _lv_style_set_int(&style_second, LV_STYLE_TEXT_LINE_SPACE, 10); +// _lv_style_set_opa(&style_second, LV_STYLE_BG_OPA, LV_OPA_60); +// _lv_style_set_ptr(&style_second, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL + 1); +// _lv_style_set_color(&style_second, LV_STYLE_BG_COLOR, LV_COLOR_BLUE); +// +// found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get an overwritten 'int' property"); +// lv_test_assert_int_eq(10, value, "Get the value of an overwritten 'int' property"); +// +// found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA, &opa); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get an overwritten 'opa' property"); +// lv_test_assert_int_eq(LV_OPA_60, opa, "Get the value of an overwritten 'opa' property"); +// +// found = _lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get an overwritten 'ptr' property"); +// lv_test_assert_ptr_eq(LV_THEME_DEFAULT_FONT_NORMAL + 1, ptr, "Get the value of an overwritten 'ptr' property"); +// +// found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get an overwritten 'color' property"); +// lv_test_assert_color_eq(LV_COLOR_BLUE, color, "Get the value of an overwritten 'color' property"); +// +// lv_test_print("Overwrite the properties with the local style"); +// _lv_style_list_set_local_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, 20); +// _lv_style_list_set_local_opa(&style_list, LV_STYLE_BG_OPA, LV_OPA_70); +// _lv_style_list_set_local_ptr(&style_list, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL + 2); +// _lv_style_list_set_local_color(&style_list, LV_STYLE_BG_COLOR, LV_COLOR_LIME); +// +// found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get a local 'int' property"); +// lv_test_assert_int_eq(20, value, "Get the value of a local 'int' property"); +// +// found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA, &opa); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get a local 'opa' property"); +// lv_test_assert_int_eq(LV_OPA_70, opa, "Get the value of a local 'opa' property"); +// +// found = _lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get a local 'ptr' property"); +// lv_test_assert_ptr_eq(LV_THEME_DEFAULT_FONT_NORMAL + 2, ptr, "Get the value of a local'ptr' property"); +// +// found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get a local 'color' property"); +// lv_test_assert_color_eq(LV_COLOR_LIME, color, "Get the value of a local'color' property"); +// +// /*Clean-up*/ +// _lv_style_list_reset(&style_list); +//} +// +//static void copy(void) +//{ +// lv_test_print(""); +// lv_test_print("Copy styles and style lists"); +// lv_test_print("---------------------------"); +// +// lv_test_print("Copy a style"); +// lv_style_t style_src; +// lv_style_init(&style_src); +// _lv_style_set_int(&style_src, LV_STYLE_TEXT_LINE_SPACE, 5); +// +// lv_style_t style_dest; +// lv_style_init(&style_dest); +// lv_style_copy(&style_dest, &style_src); +// +// int16_t weight; +// lv_coord_t value; +// +// weight = _lv_style_get_int(&style_dest, LV_STYLE_TEXT_LINE_SPACE, &value); +// lv_test_assert_int_eq(0, weight, "Get a copied property from a style"); +// lv_test_assert_int_eq(5, value, "Get the value of a copied from a property"); +// +// lv_test_print("Copy a style list"); +// lv_style_list_t list_src; +// lv_style_list_init(&list_src); +// _lv_style_list_add_style(&list_src, &style_src); +// _lv_style_list_set_local_int(&list_src, LV_STYLE_LINE_DASH_WIDTH, 20); +// +// lv_style_list_t list_dest; +// lv_style_list_init(&list_dest); +// lv_style_list_copy(&list_dest, &list_src); +// +// lv_res_t found; +// found = _lv_style_list_get_int(&list_dest, LV_STYLE_TEXT_LINE_SPACE, &value); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get a copied property from a list"); +// lv_test_assert_int_eq(5, value, "Get the value of a copied property from a list"); +// found = _lv_style_list_get_int(&list_dest, LV_STYLE_LINE_DASH_WIDTH, &value); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get a copied local property from a list"); +// lv_test_assert_int_eq(20, value, "Get the value of a copied local property from a list"); +// +// /*Clean up*/ +// _lv_style_list_reset(&list_dest); +// _lv_style_list_reset(&list_src); +// +// lv_style_reset(&style_dest); +// lv_style_reset(&style_src); +//} +// +//static void states(void) +//{ +// lv_test_print(""); +// lv_test_print("Test style states:"); +// lv_test_print("------------------"); +// +// lv_style_list_t style_list; +// lv_style_list_init(&style_list); +// +// lv_style_t style_first; +// lv_style_init(&style_first); +// _lv_style_list_add_style(&style_list, &style_first); +// +// lv_style_t style_second; +// lv_style_init(&style_second); +// _lv_style_list_add_style(&style_list, &style_second); +// +// lv_test_print("Test state precedence in 1 style"); +// _lv_style_set_int(&style_first, LV_STYLE_TEXT_LINE_SPACE, 5); +// _lv_style_set_int(&style_first, LV_STYLE_TEXT_LINE_SPACE | (LV_STATE_CHECKED) << LV_STYLE_STATE_POS, 6); +// _lv_style_set_int(&style_first, LV_STYLE_TEXT_LINE_SPACE | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, 7); +// +// lv_res_t found; +// lv_coord_t value; +// +// found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'int' property in normal state"); +// lv_test_assert_int_eq(5, value, "Get the value of an 'int' property in normal state"); +// +// found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE | (LV_STATE_CHECKED) << LV_STYLE_STATE_POS, &value); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'int' property in checked state"); +// lv_test_assert_int_eq(6, value, "Get the value of an 'int' in checked state"); +// +// found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, &value); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'int' property in pressed state"); +// lv_test_assert_int_eq(7, value, "Get the value of an 'int' in pressed state"); +// +// found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE | (LV_STATE_HOVERED) << LV_STYLE_STATE_POS, &value); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'int' property in hover (unspecified) state"); +// lv_test_assert_int_eq(5, value, "Get the value of an 'int' in hover (unspecified) state"); +// +// found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE | (LV_STATE_CHECKED | LV_STATE_PRESSED | LV_STATE_HOVERED) << LV_STYLE_STATE_POS, &value); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'int' property in checked pressed hovered state"); +// lv_test_assert_int_eq(7, value, "Get the value of an 'int' in checked pressed hovered state"); +// +// lv_test_print("Test state precedence in 1 style with combined states"); +// _lv_style_set_opa(&style_first, LV_STYLE_BG_OPA, LV_OPA_50); +// _lv_style_set_opa(&style_first, LV_STYLE_BG_OPA | (LV_STATE_CHECKED | LV_STATE_PRESSED) << LV_STYLE_STATE_POS, LV_OPA_60); +// +// lv_opa_t opa; +// found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA , &opa); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'opa' property in normal state"); +// lv_test_assert_int_eq(LV_OPA_50, opa, "Get the value of an 'int' in normal state"); +// +// found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA | (LV_STATE_CHECKED) << LV_STYLE_STATE_POS, &opa); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'opa' property in checked (unspecified) state"); +// lv_test_assert_int_eq(LV_OPA_50, opa, "Get the value of an 'int' in checked (unspecified) state"); +// +// found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA | (LV_STATE_CHECKED | LV_STATE_PRESSED) << LV_STYLE_STATE_POS, &opa); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'opa' property in checked pressed state"); +// lv_test_assert_int_eq(LV_OPA_60, opa, "Get the value of an 'int' in checked pressed state"); +// +// found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA | (LV_STATE_CHECKED | LV_STATE_PRESSED | LV_STATE_HOVERED) << LV_STYLE_STATE_POS, &opa); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'opa' property in checked pressed hovered state"); +// lv_test_assert_int_eq(LV_OPA_60, opa, "Get the value of an 'int' in checked pressed hovered state"); +// +// lv_test_print("Test state precedence in 2 styles"); +// _lv_style_set_color(&style_first, LV_STYLE_BG_COLOR, LV_COLOR_YELLOW); +// _lv_style_set_color(&style_first, LV_STYLE_BG_COLOR | (LV_STATE_HOVERED) << LV_STYLE_STATE_POS, LV_COLOR_RED); +// _lv_style_set_color(&style_second, LV_STYLE_BG_COLOR | (LV_STATE_CHECKED) << LV_STYLE_STATE_POS, LV_COLOR_LIME); +// _lv_style_set_color(&style_second, LV_STYLE_BG_COLOR | (LV_STATE_HOVERED | LV_STATE_PRESSED) << LV_STYLE_STATE_POS, LV_COLOR_BLUE); +// +// lv_color_t color; +// +// found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get a 'color' property in normal state"); +// lv_test_assert_color_eq(LV_COLOR_YELLOW, color, "Get the value of a 'color' property in normal state"); +// +// found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR | (LV_STATE_HOVERED) << LV_STYLE_STATE_POS, &color); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get a 'color' property in hovered state"); +// lv_test_assert_color_eq(LV_COLOR_RED, color, "Get the value of a 'color' in hovered state"); +// +// found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR | (LV_STATE_CHECKED) << LV_STYLE_STATE_POS, &color); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get a 'color' property in checked state"); +// lv_test_assert_color_eq(LV_COLOR_LIME, color, "Get the value of a 'color' in checked state"); +// +// found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR | (LV_STATE_HOVERED | LV_STATE_PRESSED) << LV_STYLE_STATE_POS, &color); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get a 'color' property in hover pressed state"); +// lv_test_assert_color_eq(LV_COLOR_BLUE, color, "Get the value of a 'color' in hover pressed state"); +// +// found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR | (LV_STATE_EDITED) << LV_STYLE_STATE_POS, &color); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get a 'color' property in edit (unspecified) state"); +// lv_test_assert_color_eq(LV_COLOR_YELLOW, color, "Get the value of a 'color' in edit (unspecified) state"); +// +// found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR | (LV_STATE_CHECKED | LV_STATE_EDITED) << LV_STYLE_STATE_POS, &color); +// lv_test_assert_int_eq(LV_RES_OK, found, "Get a 'color' property in checked edit state"); +// lv_test_assert_color_eq(LV_COLOR_LIME, color, "Get the value of a 'color' in checked edit state"); +// +// /*Clean-up*/ +// _lv_style_list_reset(&style_list); +//} +// +//static void mem_leak(void) +//{ +// +// lv_test_print(""); +// lv_test_print("Test style set, add, remove memory leak"); +// lv_test_print("----------------------------------------"); +// +// lv_mem_monitor_t mon_start; +// lv_mem_monitor_t mon_end; +// +// lv_style_list_t style_list; +// lv_style_list_init(&style_list); +// +// lv_style_t style1; +// lv_style_init(&style1); +// +// lv_style_t style2; +// lv_style_init(&style2); +// +// lv_style_t style3; +// lv_style_init(&style3); +// +// uint32_t i; +// +// lv_test_print("Set style properties"); +// lv_mem_monitor(&mon_start); +// for(i = 0; i < 100; i++) { +// _lv_style_set_color(&style2, LV_STYLE_LINE_COLOR, LV_COLOR_RED); +// +// _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR, LV_COLOR_RED); +// _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR | (LV_STATE_EDITED) << LV_STYLE_STATE_POS, LV_COLOR_BLUE); +// _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR, LV_COLOR_BLUE); +// _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR | (LV_STATE_EDITED | LV_STATE_FOCUSED) << LV_STYLE_STATE_POS, LV_COLOR_GREEN); +// +// _lv_style_set_color(&style3, LV_STYLE_BG_COLOR, LV_COLOR_RED); +// +// _lv_style_set_color(&style3, LV_STYLE_IMAGE_RECOLOR, LV_COLOR_RED); +// +// lv_style_reset(&style1); +// lv_style_reset(&style2); +// lv_style_reset(&style3); +// +// } +// +// lv_test_assert_int_eq(LV_RES_OK, lv_mem_test(), "Memory integrity check"); +// lv_mem_defrag(); +// lv_mem_monitor(&mon_end); +// lv_test_assert_int_lt(sizeof(void*) * 8, mon_start.free_size - mon_end.free_size, "Style memory leak"); +// +// lv_test_print("Use local style"); +// lv_mem_monitor(&mon_start); +// for(i = 0; i < 100; i++) { +// _lv_style_list_set_local_ptr(&style_list, LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, LV_THEME_DEFAULT_FONT_NORMAL); +// +// _lv_style_list_reset(&style_list); +// +// _lv_style_list_set_local_ptr(&style_list, LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, NULL); +// _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK); +// _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK); +// _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK); +// _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK); +// _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK); +// _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK); +// +// _lv_style_list_reset(&style_list); +// } +// +// _lv_style_list_reset(&style_list); +// lv_test_assert_int_eq(LV_RES_OK, lv_mem_test(), "Memory integrity check"); +// lv_mem_defrag(); +// lv_mem_monitor(&mon_end); +// lv_test_assert_int_lt(sizeof(void*) * 8, mon_start.free_size - mon_end.free_size, "Style memory leak"); +// +// lv_test_print("Add styles"); +// lv_mem_monitor(&mon_start); +// for(i = 0; i < 100; i++) { +// _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR, LV_COLOR_RED); +// _lv_style_set_color(&style2, LV_STYLE_LINE_COLOR, LV_COLOR_RED); +// _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR, LV_COLOR_RED); +// +// _lv_style_list_add_style(&style_list, &style1); +// _lv_style_list_remove_style(&style_list, &style1); +// +// _lv_style_list_add_style(&style_list, &style2); +// _lv_style_list_add_style(&style_list, &style3); +// +// _lv_style_list_remove_style(&style_list, &style2); +// _lv_style_list_add_style(&style_list, &style1); +// +// _lv_style_list_reset(&style_list); +// lv_style_reset(&style1); +// lv_style_reset(&style2); +// lv_style_reset(&style3); +// } +// +// lv_test_assert_int_eq(LV_RES_OK, lv_mem_test(), "Memory integrity check"); +// lv_mem_defrag(); +// lv_mem_monitor(&mon_end); +// lv_test_assert_int_lt(sizeof(void*) * 8, mon_start.free_size - mon_end.free_size, "Style memory leak"); +// +// lv_test_print("Add styles and use local style"); +// lv_mem_monitor(&mon_start); +// for(i = 0; i < 100; i++) { +// _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR, LV_COLOR_RED); +// _lv_style_set_color(&style2, LV_STYLE_LINE_COLOR, LV_COLOR_RED); +// _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR, LV_COLOR_RED); +// +// if(i % 2 == 0) _lv_style_list_set_local_color(&style_list, LV_STYLE_LINE_COLOR, LV_COLOR_RED); +// +// _lv_style_list_add_style(&style_list, &style1); +// _lv_style_list_remove_style(&style_list, &style1); +// +// _lv_style_list_add_style(&style_list, &style2); +// _lv_style_list_add_style(&style_list, &style3); +// +// _lv_style_list_remove_style(&style_list, &style2); +// _lv_style_list_add_style(&style_list, &style1); +// +// if(i % 2 != 0) _lv_style_list_set_local_color(&style_list, LV_STYLE_LINE_COLOR, LV_COLOR_RED); +// +// _lv_style_list_reset(&style_list); +// lv_style_reset(&style1); +// lv_style_reset(&style2); +// lv_style_reset(&style3); +// } +// +// lv_test_assert_int_eq(LV_RES_OK, lv_mem_test(), "Memory integrity check"); +// lv_mem_defrag(); +// lv_mem_monitor(&mon_end); +// lv_test_assert_int_lt(sizeof(void*) * 8, mon_start.free_size - mon_end.free_size, "Style memory leak"); +// +// lv_test_print("Complex test"); +// +// lv_mem_monitor(&mon_start); +// +// for(i = 0; i < 100; i++) { +// if(i % 2 == 0) { +// _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_CLOSE); +// } +// +// _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR, LV_COLOR_RED); +// _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR | (LV_STATE_EDITED) << LV_STYLE_STATE_POS, LV_COLOR_BLUE); +// _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR, LV_COLOR_BLUE); +// _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR | (LV_STATE_EDITED | LV_STATE_FOCUSED) << LV_STYLE_STATE_POS, LV_COLOR_GREEN); +// +// _lv_style_list_add_style(&style_list, &style1); +// +// if(i % 4 == 0) { +// _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_CLOSE); +// } +// +// _lv_style_list_remove_style(&style_list, &style1); +// +// _lv_style_set_opa(&style2, LV_STYLE_TEXT_OPA, LV_OPA_10); +// _lv_style_set_opa(&style2, LV_STYLE_TEXT_OPA, LV_OPA_20); +// _lv_style_set_opa(&style2, LV_STYLE_TEXT_OPA, LV_OPA_30); +// _lv_style_set_opa(&style2, LV_STYLE_TEXT_OPA, LV_OPA_40); +// _lv_style_set_opa(&style2, LV_STYLE_TEXT_OPA, LV_OPA_50); +// _lv_style_set_opa(&style2, LV_STYLE_TEXT_OPA, LV_OPA_60); +// +// _lv_style_list_add_style(&style_list, &style2); +// +// if(i % 8 == 0) { +// _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_CLOSE); +// } +// +// _lv_style_list_add_style(&style_list, &style2); +// _lv_style_list_add_style(&style_list, &style2); +// _lv_style_list_add_style(&style_list, &style2); +// _lv_style_list_add_style(&style_list, &style2); +// _lv_style_list_remove_style(&style_list, &style2); +// +// _lv_style_set_int(&style3, LV_STYLE_PAD_LEFT, 10); +// _lv_style_set_int(&style3, LV_STYLE_PAD_RIGHT, 20); +// _lv_style_set_int(&style3, LV_STYLE_PAD_LEFT, 11); +// _lv_style_set_int(&style3, LV_STYLE_PAD_RIGHT, 21); +// _lv_style_set_int(&style3, LV_STYLE_PAD_LEFT, 12); +// _lv_style_set_int(&style3, LV_STYLE_PAD_RIGHT, 22); +// _lv_style_set_int(&style3, LV_STYLE_PAD_LEFT, 12); +// _lv_style_set_int(&style3, LV_STYLE_PAD_RIGHT, 23); +// +// _lv_style_list_set_local_ptr(&style_list, LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, LV_THEME_DEFAULT_FONT_NORMAL); +// _lv_style_list_set_local_ptr(&style_list, LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, NULL); +// _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK); +// _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK); +// _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK); +// _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK); +// _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK); +// _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK); +// +// _lv_style_list_add_style(&style_list, &style3); +// _lv_style_list_add_style(&style_list, &style2); +// _lv_style_list_add_style(&style_list, &style1); +// +// _lv_style_list_reset(&style_list); +// lv_style_reset(&style1); +// lv_style_reset(&style2); +// lv_style_reset(&style3); +// +// } +// +// _lv_style_list_reset(&style_list); +// lv_style_reset(&style1); +// lv_style_reset(&style2); +// lv_style_reset(&style3); +// +// lv_test_assert_int_eq(LV_RES_OK, lv_mem_test(), "Memory integrity check"); +// lv_mem_defrag(); +// lv_mem_monitor(&mon_end); +// lv_test_assert_int_lt(sizeof(void*) * 8, mon_start.free_size - mon_end.free_size, "Style memory leak"); +//} +//#endif diff --git a/tests/lv_test_main.c b/tests/lv_test_main.c index f4f0a7c9c..e992ab889 100644 --- a/tests/lv_test_main.c +++ b/tests/lv_test_main.c @@ -4,7 +4,7 @@ #include "lv_test_core/lv_test_core.h" #include "lv_test_widgets/lv_test_label.h" -#if LV_BUILD_TEST +#if LV_BUILD_TEST && !defined(LV_BUILD_TEST_NO_MAIN) #include #define HOR_RES 800 @@ -23,13 +23,12 @@ int main(void) hal_init(); lv_test_core(); - lv_test_label(); +// lv_test_label(); printf("Exit with success!\n"); return 0; } -#if LV_USE_FILESYSTEM static void * open_cb(struct _lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode) { (void) drv; @@ -89,7 +88,6 @@ static lv_fs_res_t tell_cb(struct _lv_fs_drv_t * drv, void * file_p, uint32_t * return LV_FS_RES_OK; } -#endif static void hal_init(void) { @@ -106,7 +104,6 @@ static void hal_init(void) disp_drv.ver_res = VER_RES; lv_disp_drv_register(&disp_drv); -#if LV_USE_FILESYSTEM lv_fs_drv_t drv; lv_fs_drv_init(&drv); /*Basic initialization*/ @@ -118,7 +115,6 @@ static void hal_init(void) drv.tell_cb = tell_cb; /*Callback to tell the cursor position */ lv_fs_drv_register(&drv); /*Finally register the drive*/ -#endif } #include diff --git a/tests/lv_test_widgets/lv_test_label.c b/tests/lv_test_widgets/lv_test_label.c index 586ebd286..fb5c61d6f 100644 --- a/tests/lv_test_widgets/lv_test_label.c +++ b/tests/lv_test_widgets/lv_test_label.c @@ -1,69 +1,69 @@ -/** - * @file lv_test_label.c - * - */ - -/********************* - * INCLUDES - *********************/ -#include "../../lvgl.h" -#include "../lv_test_assert.h" -#include "lv_test_label.h" - -#if LV_BUILD_TEST - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ -static void create_copy(void); - -/********************** - * STATIC VARIABLES - **********************/ - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -void lv_test_label(void) -{ - lv_test_print(""); - lv_test_print("==================="); - lv_test_print("Start lv_label tests"); - lv_test_print("==================="); - -#if LV_USE_LABEL - create_copy(); -#else - lv_test_print("Skip label test: LV_USE_LABEL == 0"); -#endif -} - -/********************** - * STATIC FUNCTIONS - **********************/ - -static void create_copy(void) -{ - lv_test_print(""); - lv_test_print("Create a label"); - lv_test_print("---------------------------"); - - lv_label_create(lv_scr_act(), NULL); -#if LV_COLOR_DEPTH == 32 - lv_test_assert_img_eq("lv_test_img32_label_1.png", "Create a label and leave the default settings"); -#endif -} -#endif +///** +// * @file lv_test_label.c +// * +// */ +// +///********************* +// * INCLUDES +// *********************/ +//#include "../../lvgl.h" +//#include "../lv_test_assert.h" +//#include "lv_test_label.h" +// +//#if LV_BUILD_TEST +// +///********************* +// * DEFINES +// *********************/ +// +///********************** +// * TYPEDEFS +// **********************/ +// +///********************** +// * STATIC PROTOTYPES +// **********************/ +//static void create_copy(void); +// +///********************** +// * STATIC VARIABLES +// **********************/ +// +///********************** +// * MACROS +// **********************/ +// +///********************** +// * GLOBAL FUNCTIONS +// **********************/ +// +//void lv_test_label(void) +//{ +// lv_test_print(""); +// lv_test_print("==================="); +// lv_test_print("Start lv_label tests"); +// lv_test_print("==================="); +// +//#if LV_USE_LABEL +// create_copy(); +//#else +// lv_test_print("Skip label test: LV_USE_LABEL == 0"); +//#endif +//} +// +///********************** +// * STATIC FUNCTIONS +// **********************/ +// +//static void create_copy(void) +//{ +// lv_test_print(""); +// lv_test_print("Create a label"); +// lv_test_print("---------------------------"); +// +// lv_label_create(lv_scr_act(), NULL); +//#if LV_COLOR_DEPTH == 32 +// lv_test_assert_img_eq("lv_test_img32_label_1.png", "Create a label and leave the default settings"); +//#endif +//} +//#endif