From a8c21f8e184d235b980af50244d5d68e191d2b1a Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Wed, 31 Mar 2021 16:18:24 +0800 Subject: [PATCH 1/2] fix(style): auto formatted --- examples/widgets/arc/lv_example_arc_1.c | 2 +- examples/widgets/arc/lv_example_arc_2.c | 2 +- lv_conf_template.h | 2 +- lvgl.h | 2 +- src/core/lv_obj.c | 10 ++--- src/core/lv_obj_pos.c | 40 ++++++++++---------- src/core/lv_obj_tree.c | 38 +++++++++---------- src/core/lv_refr.c | 6 +-- src/extra/layouts/flex/lv_flex.c | 2 +- src/extra/widgets/colorwheel/lv_colorwheel.c | 18 ++++----- src/widgets/lv_chart.c | 18 ++++----- src/widgets/lv_label.c | 2 +- src/widgets/lv_slider.c | 34 ++++++++--------- tests/lv_test_core/lv_test_font_loader.c | 2 +- 14 files changed, 89 insertions(+), 89 deletions(-) diff --git a/examples/widgets/arc/lv_example_arc_1.c b/examples/widgets/arc/lv_example_arc_1.c index 9250d0ab8..2bb90b3e7 100644 --- a/examples/widgets/arc/lv_example_arc_1.c +++ b/examples/widgets/arc/lv_example_arc_1.c @@ -2,7 +2,7 @@ #if LV_USE_ARC && LV_BUILD_EXAMPLES -void lv_example_arc_1(void) +void lv_example_arc_1(void) { /*Create an Arc*/ lv_obj_t * arc = lv_arc_create(lv_scr_act()); diff --git a/examples/widgets/arc/lv_example_arc_2.c b/examples/widgets/arc/lv_example_arc_2.c index 3431419bc..214402fc5 100644 --- a/examples/widgets/arc/lv_example_arc_2.c +++ b/examples/widgets/arc/lv_example_arc_2.c @@ -1,4 +1,4 @@ -#include "../../../lvgl.h" +#include "../../../lvgl.h" #if LV_USE_ARC && LV_BUILD_EXAMPLES diff --git a/lv_conf_template.h b/lv_conf_template.h index 99fb56547..b131763cc 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -471,7 +471,7 @@ typedef void * lv_user_data_t; # define LV_THEME_DEFAULT_PALETTE_LIGHT 1 /*1: Enable grow on press*/ -# define LV_THEME_DEFAULT_GROW 1 +# define LV_THEME_DEFAULT_GROW 1 /*Default transition time in [ms]*/ # define LV_THEME_DEFAULT_TRANSITON_TIME 80 diff --git a/lvgl.h b/lvgl.h index 022b1d11f..59ec15670 100644 --- a/lvgl.h +++ b/lvgl.h @@ -2,7 +2,7 @@ * @file lvgl.h * Include all LVGL related headers */ - + #ifndef LVGL_H #define LVGL_H diff --git a/src/core/lv_obj.c b/src/core/lv_obj.c index d449657da..82143233f 100644 --- a/src/core/lv_obj.c +++ b/src/core/lv_obj.c @@ -350,7 +350,7 @@ void lv_obj_add_flag(lv_obj_t * obj, lv_obj_flag_t f) obj->flags |= f; if(f & LV_OBJ_FLAG_HIDDEN) { - lv_obj_invalidate(obj); + lv_obj_invalidate(obj); } if((was_on_layout != lv_obj_is_layout_positioned(obj)) || (f & (LV_OBJ_FLAG_LAYOUT_1 | LV_OBJ_FLAG_LAYOUT_2))) { @@ -367,10 +367,10 @@ void lv_obj_clear_flag(lv_obj_t * obj, lv_obj_flag_t f) obj->flags &= (~f); if(f & LV_OBJ_FLAG_HIDDEN) { - lv_obj_invalidate(obj); - if(lv_obj_is_layout_positioned(obj)) { - lv_obj_mark_layout_as_dirty(lv_obj_get_parent(obj)); - } + lv_obj_invalidate(obj); + if(lv_obj_is_layout_positioned(obj)) { + lv_obj_mark_layout_as_dirty(lv_obj_get_parent(obj)); + } } if((was_on_layout != lv_obj_is_layout_positioned(obj)) || (f & (LV_OBJ_FLAG_LAYOUT_1 | LV_OBJ_FLAG_LAYOUT_2))) { diff --git a/src/core/lv_obj_pos.c b/src/core/lv_obj_pos.c index 5b12941cf..7bc299338 100644 --- a/src/core/lv_obj_pos.c +++ b/src/core/lv_obj_pos.c @@ -749,32 +749,32 @@ bool lv_obj_area_is_visible(const lv_obj_t * obj, lv_area_t * area) obj_scr != lv_disp_get_layer_top(disp) && obj_scr != lv_disp_get_layer_sys(disp)) { - return false; + return false; } - /*Truncate the area to the object*/ - lv_area_t obj_coords; - lv_coord_t ext_size = _lv_obj_get_ext_draw_size(obj); - lv_area_copy(&obj_coords, &obj->coords); - obj_coords.x1 -= ext_size; - obj_coords.y1 -= ext_size; - obj_coords.x2 += ext_size; - obj_coords.y2 += ext_size; + /*Truncate the area to the object*/ + lv_area_t obj_coords; + lv_coord_t ext_size = _lv_obj_get_ext_draw_size(obj); + lv_area_copy(&obj_coords, &obj->coords); + obj_coords.x1 -= ext_size; + obj_coords.y1 -= ext_size; + obj_coords.x2 += ext_size; + obj_coords.y2 += ext_size; - bool is_common; + bool is_common; - is_common = _lv_area_intersect(area, area, &obj_coords); - if(is_common == false) return false; /*The area is not on the object*/ + is_common = _lv_area_intersect(area, area, &obj_coords); + if(is_common == false) return false; /*The area is not on the object*/ - /*Truncate recursively to the parents*/ - lv_obj_t * par = lv_obj_get_parent(obj); - while(par != NULL) { - is_common = _lv_area_intersect(area, area, &par->coords); - if(is_common == false) return false; /*If no common parts with parent break;*/ - if(lv_obj_has_flag(par, LV_OBJ_FLAG_HIDDEN)) return false; /*If the parent is hidden then the child is hidden and won't be drawn*/ + /*Truncate recursively to the parents*/ + lv_obj_t * par = lv_obj_get_parent(obj); + while(par != NULL) { + is_common = _lv_area_intersect(area, area, &par->coords); + if(is_common == false) return false; /*If no common parts with parent break;*/ + if(lv_obj_has_flag(par, LV_OBJ_FLAG_HIDDEN)) return false; /*If the parent is hidden then the child is hidden and won't be drawn*/ - par = lv_obj_get_parent(par); - } + par = lv_obj_get_parent(par); + } return true; } diff --git a/src/core/lv_obj_tree.c b/src/core/lv_obj_tree.c index d13ff2ae6..747e858ed 100644 --- a/src/core/lv_obj_tree.c +++ b/src/core/lv_obj_tree.c @@ -370,29 +370,29 @@ static void obj_del_core(lv_obj_t * obj) /*Remove the screen for the screen list*/ if(obj->parent == NULL) { - lv_disp_t * disp = lv_obj_get_disp(obj); - uint32_t i; - /*Find the screen in the list*/ - for(i = 0; i < disp->screen_cnt; i++) { - if(disp->screens[i] == obj) break; - } + lv_disp_t * disp = lv_obj_get_disp(obj); + uint32_t i; + /*Find the screen in the list*/ + for(i = 0; i < disp->screen_cnt; i++) { + if(disp->screens[i] == obj) break; + } - uint32_t id = i; - for(i = id; i < disp->screen_cnt - 1; i++) { - disp->screens[i] = disp->screens[i + 1]; - } - disp->screen_cnt--; - disp->screens = lv_mem_realloc(disp->screens, disp->screen_cnt * sizeof(lv_obj_t *)); + uint32_t id = i; + for(i = id; i < disp->screen_cnt - 1; i++) { + disp->screens[i] = disp->screens[i + 1]; + } + disp->screen_cnt--; + disp->screens = lv_mem_realloc(disp->screens, disp->screen_cnt * sizeof(lv_obj_t *)); } /*Remove the object from the child list of its parent*/ else { - uint32_t id = lv_obj_get_child_id(obj); - uint32_t i; - for(i = id; i < obj->parent->spec_attr->child_cnt - 1; i++) { - obj->parent->spec_attr->children[i] = obj->parent->spec_attr->children[i + 1]; - } - obj->parent->spec_attr->child_cnt--; - obj->parent->spec_attr->children = lv_mem_realloc(obj->parent->spec_attr->children, obj->parent->spec_attr->child_cnt * sizeof(lv_obj_t *)); + uint32_t id = lv_obj_get_child_id(obj); + uint32_t i; + for(i = id; i < obj->parent->spec_attr->child_cnt - 1; i++) { + obj->parent->spec_attr->children[i] = obj->parent->spec_attr->children[i + 1]; + } + obj->parent->spec_attr->child_cnt--; + obj->parent->spec_attr->children = lv_mem_realloc(obj->parent->spec_attr->children, obj->parent->spec_attr->child_cnt * sizeof(lv_obj_t *)); } /*Free the object itself*/ diff --git a/src/core/lv_refr.c b/src/core/lv_refr.c index e64cb5cc9..edfd1a796 100644 --- a/src/core/lv_refr.c +++ b/src/core/lv_refr.c @@ -751,7 +751,7 @@ static void draw_buf_rotate_180(lv_disp_drv_t *drv, lv_area_t *area, lv_color_t } static LV_ATTRIBUTE_FAST_MEM void draw_buf_rotate_90(bool invert_i, lv_coord_t area_w, lv_coord_t area_h, lv_color_t *orig_color_p, lv_color_t *rot_buf) { - + uint32_t invert = (area_w * area_h) - 1; uint32_t initial_i = ((area_w - 1) * area_h); for(lv_coord_t y = 0; y < area_h; y++) { @@ -823,7 +823,7 @@ static void draw_buf_rotate(lv_area_t *area, lv_color_t *color_p) { call_flush_cb(drv, area, color_p); } else if(drv->rotated == LV_DISP_ROT_90 || drv->rotated == LV_DISP_ROT_270) { /*Allocate a temporary buffer to store rotated image*/ - lv_color_t * rot_buf = NULL; + lv_color_t * rot_buf = NULL; lv_disp_draw_buf_t * draw_buf = lv_disp_get_draw_buf(disp_refr); lv_coord_t area_w = lv_area_get_width(area); lv_coord_t area_h = lv_area_get_height(area); @@ -862,7 +862,7 @@ static void draw_buf_rotate(lv_area_t *area, lv_color_t *color_p) { /*Rotate other areas using a maximum buffer size*/ if(rot_buf == NULL) rot_buf = lv_mem_buf_get(LV_DISP_ROT_MAX_BUF); draw_buf_rotate_90(drv->rotated == LV_DISP_ROT_270, area_w, height, color_p, rot_buf); - + if(drv->rotated == LV_DISP_ROT_90) { area->x1 = init_y_off + row; area->x2 = init_y_off + row + height - 1; diff --git a/src/extra/layouts/flex/lv_flex.c b/src/extra/layouts/flex/lv_flex.c index 72b30b29b..f58e183f2 100644 --- a/src/extra/layouts/flex/lv_flex.c +++ b/src/extra/layouts/flex/lv_flex.c @@ -253,7 +253,7 @@ static int32_t find_track_end(lv_obj_t * cont, flex_t * f, int32_t item_start_id if(t->track_main_size > 0) t->track_main_size -= item_gap; /*There is no gap after the last item*/ if(grow_item_cnt && grow_sum) { - lv_coord_t s = max_main_size - t->track_main_size; /*The remaining size for grow items*/ + lv_coord_t s = max_main_size - t->track_main_size; /*The remaining size for grow items*/ t->grow_unit = s / grow_sum; t->track_main_size = max_main_size; /*If there is at least one "grow item" the track takes the full space*/ } else { diff --git a/src/extra/widgets/colorwheel/lv_colorwheel.c b/src/extra/widgets/colorwheel/lv_colorwheel.c index d9d3194d5..4dbf0a706 100644 --- a/src/extra/widgets/colorwheel/lv_colorwheel.c +++ b/src/extra/widgets/colorwheel/lv_colorwheel.c @@ -268,7 +268,7 @@ static void draw_disc_grad(lv_obj_t * obj) for(i = 0; i <= 256; i += LV_CPICKER_DEF_QF, a += 360 * LV_CPICKER_DEF_QF) { line_dsc.color = angle_to_mode_color_fast(obj, i); uint16_t angle_trigo = (uint16_t)(a >> 8); /*i * 360 / 256 is the scale to apply, but we can skip multiplication here*/ - + lv_point_t p[2]; p[0].x = cx + ((r + cir_w_extra) * lv_trigo_sin(angle_trigo) >> LV_TRIGO_SHIFT); p[0].y = cy + ((r + cir_w_extra) * lv_trigo_cos(angle_trigo) >> LV_TRIGO_SHIFT); @@ -575,18 +575,18 @@ static lv_res_t double_click_reset(lv_obj_t * obj) #define SWAPPTR(A, B) do { uint8_t * t = A; A = B; B = t; } while(0) #define HSV_PTR_SWAP(sextant,r,g,b) if((sextant) & 2) { SWAPPTR((r), (b)); } if((sextant) & 4) { SWAPPTR((g), (b)); } if(!((sextant) & 6)) { \ - if(!((sextant) & 1)) { SWAPPTR((r), (g)); } } else { if((sextant) & 1) { SWAPPTR((r), (g)); } } + if(!((sextant) & 1)) { SWAPPTR((r), (g)); } } else { if((sextant) & 1) { SWAPPTR((r), (g)); } } /** * Based on the idea from https://www.vagrearg.org/content/hsvrgb - * Here we want to compute an approximate RGB value from a HSV input color space. We don't want to be accurate + * Here we want to compute an approximate RGB value from a HSV input color space. We don't want to be accurate * (for that, there's lv_color_hsv_to_rgb), but we want to be fast. * * Few tricks are used here: Hue is in range [0; 6 * 256] (so that the sextant is in the high byte and the fractional part is in the low byte) * both s and v are in [0; 255] range (very convenient to avoid divisions). * * We fold all symmetry by swapping the R, G, B pointers so that the code is the same for all sextants. - * We replace division by 255 by a division by 256, a.k.a a shift right by 8 bits. + * We replace division by 255 by a division by 256, a.k.a a shift right by 8 bits. * This is wrong, but since this is only used to compute the pixels on the screen and not the final color, it's ok. */ static void fast_hsv2rgb(uint16_t h, uint8_t s, uint8_t v, uint8_t *r, uint8_t *g , uint8_t *b); @@ -597,7 +597,7 @@ static void fast_hsv2rgb(uint16_t h, uint8_t s, uint8_t v, uint8_t *r, uint8_t * uint8_t sextant = h >> 8; HSV_PTR_SWAP(sextant, r, g, b); /*Swap pointers so the conversion code is the same*/ - *g = v; + *g = v; uint8_t bb = ~s; uint16_t ww = v * bb; /*Don't try to be precise, but instead, be fast*/ @@ -605,10 +605,10 @@ static void fast_hsv2rgb(uint16_t h, uint8_t s, uint8_t v, uint8_t *r, uint8_t * uint8_t h_frac = h & 0xff; - if(!(sextant & 1)) { + if(!(sextant & 1)) { /*Up slope*/ ww = !h_frac ? ((uint16_t)s << 8) : (s * (uint8_t)(-h_frac)); /*Skip multiply if not required*/ - } else { + } else { /*Down slope*/ ww = s * h_frac; } @@ -624,7 +624,7 @@ static lv_color_t angle_to_mode_color_fast(lv_obj_t * obj, uint16_t angle) uint8_t r = 0, g = 0, b = 0; static uint16_t h = 0; static uint8_t s = 0, v = 0, m = 255; - + switch(ext->mode) { default: case LV_COLORWHEEL_MODE_HUE: @@ -638,7 +638,7 @@ static lv_color_t angle_to_mode_color_fast(lv_obj_t * obj, uint16_t angle) case LV_COLORWHEEL_MODE_SATURATION: /*Don't recompute costly scaling if it does not change*/ if (m != ext->mode) { - h = (uint16_t)(((uint32_t)ext->hsv.h * 6 * 256) / 360); v = (uint8_t)(((uint16_t)ext->hsv.v * 51) / 20); + h = (uint16_t)(((uint32_t)ext->hsv.h * 6 * 256) / 360); v = (uint8_t)(((uint16_t)ext->hsv.v * 51) / 20); m = ext->mode; } fast_hsv2rgb(h, angle, v, &r, &g, &b); diff --git a/src/widgets/lv_chart.c b/src/widgets/lv_chart.c index be6f64144..9f8b71f79 100644 --- a/src/widgets/lv_chart.c +++ b/src/widgets/lv_chart.c @@ -369,7 +369,7 @@ void lv_chart_remove_series(lv_obj_t * obj, lv_chart_series_t * series) { LV_ASSERT_OBJ(obj, MY_CLASS); LV_ASSERT_NULL(series); - + lv_chart_t * chart = (lv_chart_t *)obj; if(!series->ext_buf_assigned && series->points) lv_mem_free(series->points); @@ -906,17 +906,17 @@ static void draw_series_bar(lv_obj_t * obj, const lv_area_t * clip_area) lv_obj_draw_dsc_t dsc; lv_obj_draw_dsc_init(&dsc, &series_mask); - dsc.part = LV_PART_ITEMS; + dsc.part = LV_PART_ITEMS; /*Go through all points*/ for(i = 0; i < chart->point_cnt; i++) { lv_coord_t x_act = (int32_t)((int32_t)(w + block_gap) * i) / (chart->point_cnt) + obj->coords.x1 + x_ofs; - dsc.id = i; + dsc.id = i; /*Draw the current point of all data line*/ _LV_LL_READ_BACK(&chart->series_ll, ser) { - if (ser->hidden) continue; + if (ser->hidden) continue; lv_coord_t start_point = chart->update_mode == LV_CHART_UPDATE_MODE_SHIFT ? ser->last_point : 0; col_a.x1 = x_act; @@ -934,13 +934,13 @@ static void draw_series_bar(lv_obj_t * obj, const lv_area_t * clip_area) col_a.y1 = h - y_tmp + obj->coords.y1 + y_ofs; if(ser->points[p_act] != LV_CHART_POINT_NONE) { - dsc.draw_area = &col_a; - dsc.rect_dsc = &col_dsc; - dsc.sub_part_ptr = ser; + dsc.draw_area = &col_a; + dsc.rect_dsc = &col_dsc; + dsc.sub_part_ptr = ser; dsc.value = ser->points[p_act]; - lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &dsc); + lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &dsc); lv_draw_rect(&col_a, &series_mask, &col_dsc); - lv_event_send(obj, LV_EVENT_DRAW_PART_END, &dsc); + lv_event_send(obj, LV_EVENT_DRAW_PART_END, &dsc); } } } diff --git a/src/widgets/lv_label.c b/src/widgets/lv_label.c index ee907c9a1..44e4b548a 100644 --- a/src/widgets/lv_label.c +++ b/src/widgets/lv_label.c @@ -1,4 +1,4 @@ -/** +/** * @file lv_label.c * */ diff --git a/src/widgets/lv_slider.c b/src/widgets/lv_slider.c index 3e085c26d..1ec64bc44 100644 --- a/src/widgets/lv_slider.c +++ b/src/widgets/lv_slider.c @@ -361,21 +361,21 @@ static void draw_knob(lv_obj_t * obj) lv_obj_draw_dsc_init(&dsc, clip_area); dsc.part = LV_PART_KNOB; dsc.id = 0; - dsc.draw_area = &slider->right_knob_area; - dsc.rect_dsc = &knob_rect_dsc; + dsc.draw_area = &slider->right_knob_area; + dsc.rect_dsc = &knob_rect_dsc; if(lv_slider_get_mode(obj) != LV_SLIDER_MODE_RANGE) { - lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &dsc); - lv_draw_rect(&slider->right_knob_area, clip_area, &knob_rect_dsc); - lv_event_send(obj, LV_EVENT_DRAW_PART_END, &dsc); + lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &dsc); + lv_draw_rect(&slider->right_knob_area, clip_area, &knob_rect_dsc); + lv_event_send(obj, LV_EVENT_DRAW_PART_END, &dsc); } else { - /*Save the draw dsc. because it can be modified in the event*/ - lv_draw_rect_dsc_t knob_rect_dsc_tmp; - lv_memcpy(&knob_rect_dsc_tmp, &knob_rect_dsc, sizeof(lv_draw_rect_dsc_t)); + /*Save the draw dsc. because it can be modified in the event*/ + lv_draw_rect_dsc_t knob_rect_dsc_tmp; + lv_memcpy(&knob_rect_dsc_tmp, &knob_rect_dsc, sizeof(lv_draw_rect_dsc_t)); - lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &dsc); - lv_draw_rect(&slider->right_knob_area, clip_area, &knob_rect_dsc); - lv_event_send(obj, LV_EVENT_DRAW_PART_END, &dsc); + lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &dsc); + lv_draw_rect(&slider->right_knob_area, clip_area, &knob_rect_dsc); + lv_event_send(obj, LV_EVENT_DRAW_PART_END, &dsc); /*Draw a second knob for the start_value side*/ if(hor) { @@ -387,14 +387,14 @@ static void draw_knob(lv_obj_t * obj) position_knob(obj, &knob_area, knob_size, hor); lv_area_copy(&slider->left_knob_area, &knob_area); - lv_memcpy(&knob_rect_dsc, &knob_rect_dsc_tmp, sizeof(lv_draw_rect_dsc_t)); - dsc.draw_area = &slider->left_knob_area; - dsc.rect_dsc = &knob_rect_dsc; - dsc.id = 1; + lv_memcpy(&knob_rect_dsc, &knob_rect_dsc_tmp, sizeof(lv_draw_rect_dsc_t)); + dsc.draw_area = &slider->left_knob_area; + dsc.rect_dsc = &knob_rect_dsc; + dsc.id = 1; - lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &dsc); + lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &dsc); lv_draw_rect(&slider->left_knob_area, clip_area, &knob_rect_dsc); - lv_event_send(obj, LV_EVENT_DRAW_PART_END, &dsc); + lv_event_send(obj, LV_EVENT_DRAW_PART_END, &dsc); } } diff --git a/tests/lv_test_core/lv_test_font_loader.c b/tests/lv_test_core/lv_test_font_loader.c index 575c9c6d3..e0d804bf7 100644 --- a/tests/lv_test_core/lv_test_font_loader.c +++ b/tests/lv_test_core/lv_test_font_loader.c @@ -14,7 +14,7 @@ #include "../../src/font/lv_font.h" #include "../../src/font/lv_font_loader.h" -#include "lv_test_font_loader.h" +#include "lv_test_font_loader.h" /********************* * DEFINES From 07a9b3232d3853cdca523bdd4ad0018d48812039 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Wed, 31 Mar 2021 12:31:56 -0500 Subject: [PATCH 2/2] fix(style_api_gen.py) extract style_get_cast and style_set_cast (#2174) --- scripts/style_api_gen.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/scripts/style_api_gen.py b/scripts/style_api_gen.py index a460f54f4..79b9edd52 100755 --- a/scripts/style_api_gen.py +++ b/scripts/style_api_gen.py @@ -87,9 +87,14 @@ props = [ {'name': 'ARC_IMG_SRC', 'style_type': 'ptr', 'var_type': 'const void *' }, ] +def style_get_cast(style_type, var_type): + cast = "" + if style_type != 'color': + cast = "(" + var_type + ")" + return cast + def obj_style_get(p): - is_struct = p['style_type'] == 'color' - cast = "(" + p['var_type'] + ")" if not is_struct else "" + cast = style_get_cast(p['style_type'], p['var_type']) print("static inline " + p['var_type'] + " lv_obj_get_style_" + p['name'].lower() +"(const struct _lv_obj_t * obj, uint32_t part)") print("{") print(" lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_" + p['name'] + ");") @@ -97,29 +102,29 @@ def obj_style_get(p): print("}") print("") -def get_func_cast(style): - func_cast = "" - if style == 'num': - func_cast = "(int32_t)" - return func_cast +def style_set_cast(style_type): + cast = "" + if style_type == 'num': + cast = "(int32_t)" + return cast def style_set(p): - func_cast = get_func_cast(p['style_type']) + cast = style_set_cast(p['style_type']) print("static inline void lv_style_set_" + p['name'].lower() +"(lv_style_t * style, "+ p['var_type'] +" value)") print("{") print(" lv_style_value_t v = {") - print(" ." + p['style_type'] +" = " + func_cast + "value") + print(" ." + p['style_type'] +" = " + cast + "value") print(" };") print(" lv_style_set_prop(style, LV_STYLE_" + p['name'] +", v);") print("}") print("") def local_style_set(p): - func_cast = get_func_cast(p['style_type']) + cast = style_set_cast(p['style_type']) print("static inline void lv_obj_set_style_" + p['name'].lower() + "(struct _lv_obj_t * obj, uint32_t part, uint32_t state, " + p['var_type'] +" value)") print("{") print(" lv_style_value_t v = {") - print(" ." + p['style_type'] +" = " + func_cast + "value") + print(" ." + p['style_type'] +" = " + cast + "value") print(" };") print(" lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_" + p['name'] +", v);") print("}")