diff --git a/lv_conf_template.h b/lv_conf_template.h index f1f06fe07b..14424ba353 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -196,6 +196,12 @@ typedef void * lv_img_decoder_user_data_t; * font's bitmaps */ #define LV_ATTRIBUTE_LARGE_CONST +/* Export integer constant to binding. + * This macro is used with constants in the form of LV_ that + * should also appear on lvgl binding API such as Micropython + */ +#define LV_EXPORT_CONST_INT(int_value) + /*=================== * HAL settings *==================*/ diff --git a/scripts/lv_conf_checker.py b/scripts/lv_conf_checker.py old mode 100644 new mode 100755 index 7929dcf527..c2171ff8a9 --- a/scripts/lv_conf_checker.py +++ b/scripts/lv_conf_checker.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3.6 + ''' Generates a checker file for lv_conf.h from lv_conf_templ.h define all the not defined values ''' @@ -34,9 +36,11 @@ for i in fin.read().splitlines(): if '/*--END OF LV_CONF_H--*/' in i: break r = re.search(r'^ *# *define ([^\s]+).*$', i) + if r: + line = re.sub('\(.*?\)', '', r[1], 1) #remove parentheses from macros fout.write( - f'#ifndef {r[1]}\n' + f'#ifndef {line}\n' f'{i}\n' '#endif\n' ) diff --git a/src/lv_conf_checker.h b/src/lv_conf_checker.h index 7accfd2596..d7edb6dffa 100644 --- a/src/lv_conf_checker.h +++ b/src/lv_conf_checker.h @@ -266,6 +266,14 @@ #define LV_ATTRIBUTE_LARGE_CONST #endif +/* Export integer constant to binding. + * This macro is used with constants in the form of LV_ that + * should also appear on lvgl binding API such as Micropython + */ +#ifndef LV_EXPORT_CONST_INT +#define LV_EXPORT_CONST_INT(int_value) +#endif + /*=================== * HAL settings *==================*/ diff --git a/src/lv_core/lv_core.mk b/src/lv_core/lv_core.mk index 5cd51bfb58..eb1c5e0ca9 100644 --- a/src/lv_core/lv_core.mk +++ b/src/lv_core/lv_core.mk @@ -4,6 +4,7 @@ CSRCS += lv_disp.c CSRCS += lv_obj.c CSRCS += lv_refr.c CSRCS += lv_style.c +CSRCS += lv_debug.c DEPPATH += --dep-path $(LVGL_DIR)/lvgl/src/lv_core VPATH += :$(LVGL_DIR)/lvgl/src/lv_core diff --git a/src/lv_core/lv_style.h b/src/lv_core/lv_style.h index 0055529def..a334a4a5e8 100644 --- a/src/lv_core/lv_style.h +++ b/src/lv_core/lv_style.h @@ -25,6 +25,8 @@ extern "C" { #define LV_RADIUS_CIRCLE (LV_COORD_MAX) /**< A very big radius to always draw as circle*/ #define LV_STYLE_DEGUG_SENTINEL_VALUE 0x12345678 +LV_EXPORT_CONST_INT(LV_RADIUS_CIRCLE); + /********************** * TYPEDEFS **********************/ diff --git a/src/lv_font/lv_font_fmt_txt.h b/src/lv_font/lv_font_fmt_txt.h index 0fd41347bb..b7efcb3d57 100644 --- a/src/lv_font/lv_font_fmt_txt.h +++ b/src/lv_font/lv_font_fmt_txt.h @@ -45,7 +45,7 @@ typedef struct uint8_t box_w; /**< Width of the glyph's bounding box*/ uint8_t box_h; /**< Height of the glyph's bounding box*/ int8_t ofs_x; /**< x offset of the bounding box*/ - uint8_t ofs_y; /**< y offset of the bounding box. Measured from the top of the line*/ + int8_t ofs_y; /**< y offset of the bounding box. Measured from the top of the line*/ }lv_font_fmt_txt_glyph_dsc_t; @@ -141,7 +141,7 @@ typedef struct { 3. value = class_pair_values[(left_class-1)*right_class_cnt + (righ_class-1)] */ - const uint8_t * class_pair_values; /*left_class_num * right_class_num value*/ + const int8_t * class_pair_values; /*left_class_num * right_class_num value*/ const uint8_t * left_class_mapping; /*Map the glyph_ids to classes: index -> glyph_id -> class_id*/ const uint8_t * right_class_mapping; /*Map the glyph_ids to classes: index -> glyph_id -> class_id*/ uint8_t left_class_cnt; diff --git a/src/lv_font/lv_font_roboto_12.c b/src/lv_font/lv_font_roboto_12.c index b201120d1e..ac78094392 100644 --- a/src/lv_font/lv_font_roboto_12.c +++ b/src/lv_font/lv_font_roboto_12.c @@ -1,4 +1,4 @@ -#include "lvgl/lvgl.h" +#include "../../lvgl.h" /******************************************************************************* * Size: 12 px diff --git a/src/lv_font/lv_font_roboto_16.c b/src/lv_font/lv_font_roboto_16.c index a8df9c3a05..859a3d504a 100644 --- a/src/lv_font/lv_font_roboto_16.c +++ b/src/lv_font/lv_font_roboto_16.c @@ -1,4 +1,4 @@ -#include "lvgl/lvgl.h" +#include "../../lvgl.h" /******************************************************************************* * Size: 16 px diff --git a/src/lv_font/lv_font_roboto_22.c b/src/lv_font/lv_font_roboto_22.c index 4e33b05d11..d85712c6ea 100644 --- a/src/lv_font/lv_font_roboto_22.c +++ b/src/lv_font/lv_font_roboto_22.c @@ -1,4 +1,4 @@ -#include "lvgl/lvgl.h" +#include "../../lvgl.h" /******************************************************************************* * Size: 22 px diff --git a/src/lv_font/lv_font_roboto_28.c b/src/lv_font/lv_font_roboto_28.c index a19af47267..66ae045906 100644 --- a/src/lv_font/lv_font_roboto_28.c +++ b/src/lv_font/lv_font_roboto_28.c @@ -1,4 +1,4 @@ -#include "lvgl/lvgl.h" +#include "../../lvgl.h" /******************************************************************************* * Size: 28 px diff --git a/src/lv_font/lv_font_unscii_8.c b/src/lv_font/lv_font_unscii_8.c index e86727cf90..1b96823e85 100644 --- a/src/lv_font/lv_font_unscii_8.c +++ b/src/lv_font/lv_font_unscii_8.c @@ -311,7 +311,7 @@ static LV_ATTRIBUTE_LARGE_CONST const uint8_t gylph_bitmap[] = { * GLYPH DESCRIPTION *--------------------*/ -static lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = { +static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = { {.bitmap_index = 0, .adv_w = 0, .box_h = 0, .box_w = 0, .ofs_x = 0, .ofs_y = 0} /* id = 0 reserved */, {.bitmap_index = 0, .adv_w = 128, .box_h = 0, .box_w = 0, .ofs_x = 0, .ofs_y = 0}, {.bitmap_index = 0, .adv_w = 128, .box_h = 7, .box_w = 1, .ofs_x = 3, .ofs_y = -1}, @@ -460,4 +460,3 @@ lv_font_t lv_font_unscii_8 = { }; #endif /*#if LV_FONT_UNSCII_8*/ - diff --git a/src/lv_misc/lv_area.h b/src/lv_misc/lv_area.h index 30b62cbec5..149df23026 100644 --- a/src/lv_misc/lv_area.h +++ b/src/lv_misc/lv_area.h @@ -29,6 +29,9 @@ extern "C" { #define LV_COORD_MAX ((lv_coord_t)((uint32_t)((uint32_t)1 << (8 * sizeof(lv_coord_t) - 1)) - 1000)) #define LV_COORD_MIN (-LV_COORD_MAX) +LV_EXPORT_CONST_INT(LV_COORD_MAX); +LV_EXPORT_CONST_INT(LV_COORD_MIN); + /********************** * TYPEDEFS **********************/ diff --git a/src/lv_misc/lv_log.h b/src/lv_misc/lv_log.h index 6a6c2d2a4b..d85bcde432 100644 --- a/src/lv_misc/lv_log.h +++ b/src/lv_misc/lv_log.h @@ -26,13 +26,14 @@ extern "C" { /*Possible log level. For compatibility declare it independently from `LV_USE_LOG`*/ -#define LV_LOG_LEVEL_TRACE 0 /**< A lot of logs to give detailed information*/ -#define LV_LOG_LEVEL_INFO 1 /**< Log important events*/ -#define LV_LOG_LEVEL_WARN 2 /**< Log if something unwanted happened but didn't caused problem*/ -#define LV_LOG_LEVEL_ERROR 3 /**< Only critical issue, when the system may fail*/ -#define LV_LOG_LEVEL_NONE 4 /**< Do not log anything*/ -#define _LV_LOG_LEVEL_NUM 5 /**< Number of log levels */ - +enum { + LV_LOG_LEVEL_TRACE = 0, /**< A lot of logs to give detailed information*/ + LV_LOG_LEVEL_INFO = 1, /**< Log important events*/ + LV_LOG_LEVEL_WARN = 2, /**< Log if something unwanted happened but didn't caused problem*/ + LV_LOG_LEVEL_ERROR = 3, /**< Only critical issue, when the system may fail*/ + LV_LOG_LEVEL_NONE = 4, /**< Do not log anything*/ + _LV_LOG_LEVEL_NUM = 5 /**< Number of log levels */ +}; typedef int8_t lv_log_level_t; #if LV_USE_LOG diff --git a/src/lv_objx/lv_bar.h b/src/lv_objx/lv_bar.h index 14c558e7a7..9ffdbdd62f 100644 --- a/src/lv_objx/lv_bar.h +++ b/src/lv_objx/lv_bar.h @@ -43,6 +43,11 @@ extern "C" { /** log2(LV_BAR_ANIM_STATE_END) used to normalize data*/ #define LV_BAR_ANIM_STATE_NORM 8 +LV_EXPORT_CONST_INT(LV_BAR_ANIM_STATE_START); +LV_EXPORT_CONST_INT(LV_BAR_ANIM_STATE_END); +LV_EXPORT_CONST_INT(LV_BAR_ANIM_STATE_INV); +LV_EXPORT_CONST_INT(LV_BAR_ANIM_STATE_NORM); + /********************** * TYPEDEFS **********************/ diff --git a/src/lv_objx/lv_btnm.h b/src/lv_objx/lv_btnm.h index bedcdf436d..44bc4efbbf 100644 --- a/src/lv_objx/lv_btnm.h +++ b/src/lv_objx/lv_btnm.h @@ -31,6 +31,8 @@ extern "C" { #define LV_BTNM_WIDTH_MASK 0x0007 #define LV_BTNM_BTN_NONE 0xFFFF +LV_EXPORT_CONST_INT(LV_BTNM_BTN_NONE); + /********************** * TYPEDEFS **********************/ diff --git a/src/lv_objx/lv_canvas.c b/src/lv_objx/lv_canvas.c index a39c11a311..855e2bcad0 100644 --- a/src/lv_objx/lv_canvas.c +++ b/src/lv_objx/lv_canvas.c @@ -695,11 +695,37 @@ void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t * points, uint32_t lv_disp_t * refr_ori = lv_refr_get_disp_refreshing(); lv_refr_set_disp_refreshing(&disp); + lv_style_t circle_style_tmp; /*If rounded...*/ + if(style->line.rounded) { + lv_style_copy(&circle_style_tmp, style); + circle_style_tmp.body.radius = LV_RADIUS_CIRCLE; + circle_style_tmp.body.main_color = style->line.color; + circle_style_tmp.body.grad_color = style->line.color; + circle_style_tmp.body.opa = style->line.opa; + } + lv_area_t circle_area; uint32_t i; for(i = 0; i < point_cnt - 1; i++) { lv_draw_line(&points[i], &points[i + 1], &mask, style, LV_OPA_COVER); + + /*Draw circle on the joints if enabled*/ + if(style->line.rounded) { + circle_area.x1 = points[i].x - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1); + circle_area.y1 = points[i].y - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1); + circle_area.x2 = points[i].x + ((style->line.width - 1) >> 1); + circle_area.y2 = points[i].y + ((style->line.width - 1) >> 1); + lv_draw_rect(&circle_area, &mask, &circle_style_tmp, LV_OPA_COVER); + } } - + /*Draw circle on the last point too if enabled*/ + if(style->line.rounded) { + circle_area.x1 = points[i].x - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1); + circle_area.y1 = points[i].y - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1); + circle_area.x2 = points[i].x + ((style->line.width - 1) >> 1); + circle_area.y2 = points[i].y + ((style->line.width - 1) >> 1); + lv_draw_rect(&circle_area, &mask, &circle_style_tmp, LV_OPA_COVER); + } + lv_refr_set_disp_refreshing(refr_ori); } diff --git a/src/lv_objx/lv_chart.c b/src/lv_objx/lv_chart.c index 9bee1ec0f1..c326c8c6bb 100644 --- a/src/lv_objx/lv_chart.c +++ b/src/lv_objx/lv_chart.c @@ -1270,7 +1270,7 @@ static void lv_chart_draw_y_ticks(lv_obj_t * chart, const lv_area_t * mask, uint const lv_style_t * style = lv_obj_get_style(chart); lv_opa_t opa_scale = lv_obj_get_opa_scale(chart); - uint8_t i, j; + uint8_t i; uint8_t num_of_labels; uint8_t num_scale_ticks; int8_t major_tick_len, minor_tick_len; @@ -1396,8 +1396,7 @@ static void lv_chart_draw_x_ticks(lv_obj_t * chart, const lv_area_t * mask) const lv_style_t * style = lv_obj_get_style(chart); lv_opa_t opa_scale = lv_obj_get_opa_scale(chart); - uint8_t i, j; - uint8_t list_index; + uint8_t i; uint8_t num_of_labels; uint8_t num_scale_ticks; uint8_t major_tick_len, minor_tick_len; diff --git a/src/lv_objx/lv_chart.h b/src/lv_objx/lv_chart.h index dd2c9be8b9..55fb929990 100644 --- a/src/lv_objx/lv_chart.h +++ b/src/lv_objx/lv_chart.h @@ -34,6 +34,9 @@ extern "C" { /**Automatically calculate the tick length*/ #define LV_CHART_TICK_LENGTH_AUTO 255 +LV_EXPORT_CONST_INT(LV_CHART_POINT_DEF); +LV_EXPORT_CONST_INT(LV_CHART_TICK_LENGTH_AUTO); + /********************** * TYPEDEFS **********************/ diff --git a/src/lv_objx/lv_gauge.c b/src/lv_objx/lv_gauge.c index 3ebb1cb7c3..aedb63c2a1 100644 --- a/src/lv_objx/lv_gauge.c +++ b/src/lv_objx/lv_gauge.c @@ -135,7 +135,6 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, const lv_obj_t * copy) void lv_gauge_set_needle_count(lv_obj_t * gauge, uint8_t needle_cnt, const lv_color_t colors[]) { LV_ASSERT_OBJ(gauge, LV_OBJX_NAME); - LV_ASSERT_NULL(colors); lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge); diff --git a/src/lv_objx/lv_label.h b/src/lv_objx/lv_label.h index 2804ef700e..2de59cdf0b 100644 --- a/src/lv_objx/lv_label.h +++ b/src/lv_objx/lv_label.h @@ -35,6 +35,10 @@ extern "C" { #define LV_LABEL_POS_LAST 0xFFFF #define LV_LABEL_TEXT_SEL_OFF 0xFFFF +LV_EXPORT_CONST_INT(LV_LABEL_DOT_NUM); +LV_EXPORT_CONST_INT(LV_LABEL_POS_LAST); +LV_EXPORT_CONST_INT(LV_LABEL_TEXT_SEL_OFF); + /********************** * TYPEDEFS **********************/ diff --git a/src/lv_objx/lv_line.c b/src/lv_objx/lv_line.c index a9dbd7e2d4..ec9e35da43 100644 --- a/src/lv_objx/lv_line.c +++ b/src/lv_objx/lv_line.c @@ -237,11 +237,13 @@ static bool lv_line_design(lv_obj_t * line, const lv_area_t * mask, lv_design_mo uint16_t i; lv_style_t circle_style_tmp; /*If rounded...*/ - lv_style_copy(&circle_style_tmp, style); - circle_style_tmp.body.radius = LV_RADIUS_CIRCLE; - circle_style_tmp.body.main_color = style->line.color; - circle_style_tmp.body.grad_color = style->line.color; - circle_style_tmp.body.opa = style->line.opa; + if(style->line.rounded) { + lv_style_copy(&circle_style_tmp, style); + circle_style_tmp.body.radius = LV_RADIUS_CIRCLE; + circle_style_tmp.body.main_color = style->line.color; + circle_style_tmp.body.grad_color = style->line.color; + circle_style_tmp.body.opa = style->line.opa; + } lv_area_t circle_area; /*Read all points and draw the lines*/ diff --git a/src/lv_objx/lv_spinbox.c b/src/lv_objx/lv_spinbox.c index b5b2f33af3..bd46b99525 100644 --- a/src/lv_objx/lv_spinbox.c +++ b/src/lv_objx/lv_spinbox.c @@ -406,9 +406,11 @@ static void lv_spinbox_updatevalue(lv_obj_t * spinbox) memset(buf, 0, sizeof(buf)); char * buf_p = buf; - /*Add the sign*/ - (*buf_p) = ext->value >= 0 ? '+' : '-'; - buf_p++; + if (ext->range_min < 0) { // hide sign if there are only positive values + /*Add the sign*/ + (*buf_p) = ext->value >= 0 ? '+' : '-'; + buf_p++; + } int i; /*padding left*/ diff --git a/src/lv_objx/lv_ta.h b/src/lv_objx/lv_ta.h index 4d3a4a4e3e..ec2854e49b 100644 --- a/src/lv_objx/lv_ta.h +++ b/src/lv_objx/lv_ta.h @@ -39,6 +39,8 @@ extern "C" { *********************/ #define LV_TA_CURSOR_LAST (0x7FFF) /*Put the cursor after the last character*/ +LV_EXPORT_CONST_INT(LV_TA_CURSOR_LAST); + /********************** * TYPEDEFS **********************/ diff --git a/src/lv_objx/lv_tabview.c b/src/lv_objx/lv_tabview.c index da48aad114..158ff53939 100644 --- a/src/lv_objx/lv_tabview.c +++ b/src/lv_objx/lv_tabview.c @@ -746,21 +746,19 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p } if(sign == LV_SIGNAL_FOCUS) { + + lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act()); /*With ENCODER select the first button only in edit mode*/ if(indev_type == LV_INDEV_TYPE_ENCODER) { #if LV_USE_GROUP lv_group_t * g = lv_obj_get_group(tabview); if(lv_group_get_editing(g)) { - lv_btnm_ext_t * btnm_ext = lv_obj_get_ext_attr(ext->btns); - btnm_ext->btn_id_pr = 0; - lv_obj_invalidate(ext->btns); + lv_btnm_set_pressed(ext->btns, ext->tab_cur); } #endif } else { - lv_btnm_ext_t * btnm_ext = lv_obj_get_ext_attr(ext->btns); - btnm_ext->btn_id_pr = 0; - lv_obj_invalidate(ext->btns); + lv_btnm_set_pressed(ext->btns, ext->tab_cur); } } } else if(sign == LV_SIGNAL_GET_EDITABLE) { diff --git a/src/lv_objx/lv_win.c b/src/lv_objx/lv_win.c index 58bdcd8b64..03c689a0f8 100644 --- a/src/lv_objx/lv_win.c +++ b/src/lv_objx/lv_win.c @@ -254,6 +254,8 @@ void lv_win_set_content_size(lv_obj_t * win, lv_coord_t w, lv_coord_t h) lv_win_ext_t * ext = lv_obj_get_ext_attr(win); h += lv_obj_get_height(ext->header); + + lv_obj_set_size(win, w, h); } /**