From f23873e3f50f2003d4a01e6f758f7d78765c9462 Mon Sep 17 00:00:00 2001 From: pete-pjb Date: Mon, 15 Jun 2020 17:15:05 +0100 Subject: [PATCH 001/205] Added Functions to extend chart functionality as follows: /** * Set the index of the x-axis start point in the data array * @param chart pointer to a chart object * @param ser pointer to a data series on 'chart' * @param id the index of the x point in the data array */ void lv_chart_set_x_start_point(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id); /** * Set an external array of data points to use for the chart * NOTE: It is the users responsibility to make sure the point_cnt matches the external array size. * @param chart pointer to a chart object * @param ser pointer to a data series on 'chart' * @param array external array of points for chart */ void lv_chart_set_ext_array(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t array[], uint16_t point_cnt ); /** * Set an individual point value in the chart series directly based on index * @param chart pointer to a chart object * @param ser pointer to a data series on 'chart' * @param value value to assign to array point * @param id the index of the x point in the array */ void lv_chart_set_point_id(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t value, uint16_t id); /** * get the current index of the x-axis start point in the data array * @param chart pointer to a chart object * @param ser pointer to a data series on 'chart' * @return the index of the current x start point in the data array */ uint16_t lv_chart_get_x_start_point(lv_obj_t * chart, lv_chart_series_t * ser); /** * Get an individual point value in the chart series directly based on index * @param chart pointer to a chart object * @param ser pointer to a data series on 'chart' * @param id the index of the x point in the array * @return value of array point at index id */ lv_coord_t lv_chart_get_point_id(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id); --- src/lv_widgets/lv_chart.c | 161 +++++++++++++++++++++++++++++--------- src/lv_widgets/lv_chart.h | 46 ++++++++++- 2 files changed, 171 insertions(+), 36 deletions(-) diff --git a/src/lv_widgets/lv_chart.c b/src/lv_widgets/lv_chart.c index 35e421b01..f3e82b4cd 100644 --- a/src/lv_widgets/lv_chart.c +++ b/src/lv_widgets/lv_chart.c @@ -303,43 +303,44 @@ void lv_chart_set_point_count(lv_obj_t * chart, uint16_t point_cnt) if(point_cnt < 1) point_cnt = 1; _LV_LL_READ_BACK(ext->series_ll, ser) { - if(ser->start_point != 0) { - lv_coord_t * new_points = lv_mem_alloc(sizeof(lv_coord_t) * point_cnt); - LV_ASSERT_MEM(new_points); - if(new_points == NULL) return; + if( !ser->ext_buf_assigned ) { + if(ser->start_point != 0) { + lv_coord_t * new_points = lv_mem_alloc(sizeof(lv_coord_t) * point_cnt); + LV_ASSERT_MEM(new_points); + if(new_points == NULL) return; - if(point_cnt >= point_cnt_old) { - for(i = 0; i < point_cnt_old; i++) { - new_points[i] = - ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/ - } - for(i = point_cnt_old; i < point_cnt; i++) { - new_points[i] = def; /*Fill up the rest with default value*/ - } - } - else { - for(i = 0; i < point_cnt; i++) { - new_points[i] = - ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/ - } - } - - /*Switch over pointer from old to new*/ - lv_mem_free(ser->points); - ser->points = new_points; - } - else { - ser->points = lv_mem_realloc(ser->points, sizeof(lv_coord_t) * point_cnt); - LV_ASSERT_MEM(ser->points); - if(ser->points == NULL) return; - /*Initialize the new points*/ - if(point_cnt > point_cnt_old) { - for(i = point_cnt_old - 1; i < point_cnt; i++) { - ser->points[i] = def; - } - } - } + if(point_cnt >= point_cnt_old) { + for(i = 0; i < point_cnt_old; i++) { + new_points[i] = + ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/ + } + for(i = point_cnt_old; i < point_cnt; i++) { + new_points[i] = def; /*Fill up the rest with default value*/ + } + } + else { + for(i = 0; i < point_cnt; i++) { + new_points[i] = + ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/ + } + } + /*Switch over pointer from old to new*/ + lv_mem_free(ser->points); + ser->points = new_points; + } + else { + ser->points = lv_mem_realloc(ser->points, sizeof(lv_coord_t) * point_cnt); + LV_ASSERT_MEM(ser->points); + if(ser->points == NULL) return; + /*Initialize the new points*/ + if(point_cnt > point_cnt_old) { + for(i = point_cnt_old - 1; i < point_cnt; i++) { + ser->points[i] = def; + } + } + } + } ser->start_point = 0; } @@ -540,6 +541,64 @@ void lv_chart_set_secondary_y_tick_texts(lv_obj_t * chart, const char * list_of_ ext->secondary_y_axis.options = options; } +/** + * Set the index of the x-axis start point in the data array + * @param chart pointer to a chart object + * @param ser pointer to a data series on 'chart' + * @param id the index of the x point in the data array + */ +void lv_chart_set_x_start_point(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id) +{ + LV_ASSERT_OBJ(chart, LV_OBJX_NAME); + LV_ASSERT_NULL(ser); + + if(chart == NULL || ser == NULL) return; + lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); + if(ext == NULL) return; + if( id >= ext->point_cnt ) return; + ser->start_point = id; +} + +/** + * Set an external array of data points to use for the chart + * NOTE: It is the users responsibility to make sure the point_cnt matches the external array size. + * @param chart pointer to a chart object + * @param ser pointer to a data series on 'chart' + * @param array external array of points for chart + * @param point_cnt number of external points in the array + */ +void lv_chart_set_ext_array(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t array[], uint16_t point_cnt) +{ + LV_ASSERT_OBJ(chart, LV_OBJX_NAME); + LV_ASSERT_NULL(ser); + + if(chart == NULL || ser == NULL) return; + lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); + if( !ser->ext_buf_assigned && ser->points ) lv_mem_free(ser->points); + ser->ext_buf_assigned = true; + ser->points = array; + ext->point_cnt = point_cnt; +} + +/** + * Set an individual point y value in the chart series directly based on index + * @param chart pointer to a chart object + * @param ser pointer to a data series on 'chart' + * @param value value to assign to array point + * @param id the index of the x point in the array + */ +void lv_chart_set_point_id(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t value, uint16_t id) +{ + LV_ASSERT_OBJ(chart, LV_OBJX_NAME); + LV_ASSERT_NULL(ser); + + if(chart == NULL || ser == NULL) return; + lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); + if(ext == NULL) return; + if( id >= ext->point_cnt ) return; + ser->points[id] = value; +} + /*===================== * Getter functions *====================*/ @@ -570,6 +629,38 @@ uint16_t lv_chart_get_point_count(const lv_obj_t * chart) return ext->point_cnt; } +/** + * Get the current index of the x-axis start point in the data array + * @param chart pointer to a chart object + * @param ser pointer to a data series on 'chart' + * @return the index of the current x start point in the data array + */ +uint16_t lv_chart_get_x_start_point(lv_obj_t * chart, lv_chart_series_t * ser) +{ + LV_ASSERT_OBJ(chart, LV_OBJX_NAME); + LV_ASSERT_NULL(ser); + + return(ser->start_point); +} + +/** + * Get an individual point y value in the chart series directly based on index + * @param chart pointer to a chart object + * @param ser pointer to a data series on 'chart' + * @param id the index of the x point in the array + * @return value of array point at index id + */ +lv_coord_t lv_chart_get_point_id(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id) +{ + LV_ASSERT_OBJ(chart, LV_OBJX_NAME); + LV_ASSERT_NULL(serie); + + lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); + if( id >= ext->point_cnt ) id = 0; + return(ser->points[id]); + +} + /*===================== * Other functions *====================*/ diff --git a/src/lv_widgets/lv_chart.h b/src/lv_widgets/lv_chart.h index 77534cc8c..c1ff2b524 100644 --- a/src/lv_widgets/lv_chart.h +++ b/src/lv_widgets/lv_chart.h @@ -56,13 +56,14 @@ typedef struct { lv_coord_t * points; lv_color_t color; uint16_t start_point; + uint8_t ext_buf_assigned : 1; } lv_chart_series_t; /** Data of axis */ enum { LV_CHART_AXIS_SKIP_LAST_TICK = 0x00, /**< don't draw the last tick */ LV_CHART_AXIS_DRAW_LAST_TICK = 0x01, /**< draw the last tick */ - LV_CHART_AXIS_INVERSE_LABELS_ORDER = 0x02 /**< draw tick labels in an inversed order*/ + LV_CHART_AXIS_INVERSE_LABELS_ORDER = 0x02 /**< draw tick labels in an inverted order*/ }; typedef uint8_t lv_chart_axis_options_t; @@ -260,6 +261,32 @@ void lv_chart_set_secondary_y_tick_texts(lv_obj_t * chart, const char * list_of_ void lv_chart_set_y_tick_texts(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks, lv_chart_axis_options_t options); +/** + * Set the index of the x-axis start point in the data array + * @param chart pointer to a chart object + * @param ser pointer to a data series on 'chart' + * @param id the index of the x point in the data array + */ +void lv_chart_set_x_start_point(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id); + +/** + * Set an external array of data points to use for the chart + * NOTE: It is the users responsibility to make sure the point_cnt matches the external array size. + * @param chart pointer to a chart object + * @param ser pointer to a data series on 'chart' + * @param array external array of points for chart + */ +void lv_chart_set_ext_array(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t array[], uint16_t point_cnt ); + +/** + * Set an individual point value in the chart series directly based on index + * @param chart pointer to a chart object + * @param ser pointer to a data series on 'chart' + * @param value value to assign to array point + * @param id the index of the x point in the array + */ +void lv_chart_set_point_id(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t value, uint16_t id); + /*===================== * Getter functions *====================*/ @@ -278,6 +305,23 @@ lv_chart_type_t lv_chart_get_type(const lv_obj_t * chart); */ uint16_t lv_chart_get_point_count(const lv_obj_t * chart); +/** + * get the current index of the x-axis start point in the data array + * @param chart pointer to a chart object + * @param ser pointer to a data series on 'chart' + * @return the index of the current x start point in the data array + */ +uint16_t lv_chart_get_x_start_point(lv_obj_t * chart, lv_chart_series_t * ser); + +/** + * Get an individual point value in the chart series directly based on index + * @param chart pointer to a chart object + * @param ser pointer to a data series on 'chart' + * @param id the index of the x point in the array + * @return value of array point at index id + */ +lv_coord_t lv_chart_get_point_id(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id); + /*===================== * Other functions *====================*/ From fe5663908c70b3df40e8d8b82b90c61b660b1eb1 Mon Sep 17 00:00:00 2001 From: pete-pjb Date: Mon, 15 Jun 2020 17:29:33 +0100 Subject: [PATCH 002/205] Fix unused variable --- src/lv_widgets/lv_chart.c | 3 +-- src/lv_widgets/lv_chart.h | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/lv_widgets/lv_chart.c b/src/lv_widgets/lv_chart.c index f3e82b4cd..cdea00cc2 100644 --- a/src/lv_widgets/lv_chart.c +++ b/src/lv_widgets/lv_chart.c @@ -631,11 +631,10 @@ uint16_t lv_chart_get_point_count(const lv_obj_t * chart) /** * Get the current index of the x-axis start point in the data array - * @param chart pointer to a chart object * @param ser pointer to a data series on 'chart' * @return the index of the current x start point in the data array */ -uint16_t lv_chart_get_x_start_point(lv_obj_t * chart, lv_chart_series_t * ser) +uint16_t lv_chart_get_x_start_point(lv_chart_series_t * ser) { LV_ASSERT_OBJ(chart, LV_OBJX_NAME); LV_ASSERT_NULL(ser); diff --git a/src/lv_widgets/lv_chart.h b/src/lv_widgets/lv_chart.h index c1ff2b524..85e66afe1 100644 --- a/src/lv_widgets/lv_chart.h +++ b/src/lv_widgets/lv_chart.h @@ -307,11 +307,10 @@ uint16_t lv_chart_get_point_count(const lv_obj_t * chart); /** * get the current index of the x-axis start point in the data array - * @param chart pointer to a chart object * @param ser pointer to a data series on 'chart' * @return the index of the current x start point in the data array */ -uint16_t lv_chart_get_x_start_point(lv_obj_t * chart, lv_chart_series_t * ser); +uint16_t lv_chart_get_x_start_point(lv_chart_series_t * ser); /** * Get an individual point value in the chart series directly based on index From 832dbd644b21352a46298de8328d4aef47773e4e Mon Sep 17 00:00:00 2001 From: pete-pjb Date: Tue, 16 Jun 2020 09:31:37 +0100 Subject: [PATCH 003/205] Remove redundant assert --- src/lv_widgets/lv_chart.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lv_widgets/lv_chart.c b/src/lv_widgets/lv_chart.c index cdea00cc2..8e6c37fb1 100644 --- a/src/lv_widgets/lv_chart.c +++ b/src/lv_widgets/lv_chart.c @@ -636,7 +636,6 @@ uint16_t lv_chart_get_point_count(const lv_obj_t * chart) */ uint16_t lv_chart_get_x_start_point(lv_chart_series_t * ser) { - LV_ASSERT_OBJ(chart, LV_OBJX_NAME); LV_ASSERT_NULL(ser); return(ser->start_point); From f746ac854287c09cc1677f70aaee6b664019e230 Mon Sep 17 00:00:00 2001 From: Pete Bone Date: Tue, 16 Jun 2020 14:53:21 +0100 Subject: [PATCH 004/205] Added functions to extend chart functionality (#1581) --- src/lv_widgets/lv_chart.c | 159 +++++++++++++++++++++++++++++--------- src/lv_widgets/lv_chart.h | 45 ++++++++++- 2 files changed, 168 insertions(+), 36 deletions(-) diff --git a/src/lv_widgets/lv_chart.c b/src/lv_widgets/lv_chart.c index 35e421b01..8e6c37fb1 100644 --- a/src/lv_widgets/lv_chart.c +++ b/src/lv_widgets/lv_chart.c @@ -303,43 +303,44 @@ void lv_chart_set_point_count(lv_obj_t * chart, uint16_t point_cnt) if(point_cnt < 1) point_cnt = 1; _LV_LL_READ_BACK(ext->series_ll, ser) { - if(ser->start_point != 0) { - lv_coord_t * new_points = lv_mem_alloc(sizeof(lv_coord_t) * point_cnt); - LV_ASSERT_MEM(new_points); - if(new_points == NULL) return; + if( !ser->ext_buf_assigned ) { + if(ser->start_point != 0) { + lv_coord_t * new_points = lv_mem_alloc(sizeof(lv_coord_t) * point_cnt); + LV_ASSERT_MEM(new_points); + if(new_points == NULL) return; - if(point_cnt >= point_cnt_old) { - for(i = 0; i < point_cnt_old; i++) { - new_points[i] = - ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/ - } - for(i = point_cnt_old; i < point_cnt; i++) { - new_points[i] = def; /*Fill up the rest with default value*/ - } - } - else { - for(i = 0; i < point_cnt; i++) { - new_points[i] = - ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/ - } - } - - /*Switch over pointer from old to new*/ - lv_mem_free(ser->points); - ser->points = new_points; - } - else { - ser->points = lv_mem_realloc(ser->points, sizeof(lv_coord_t) * point_cnt); - LV_ASSERT_MEM(ser->points); - if(ser->points == NULL) return; - /*Initialize the new points*/ - if(point_cnt > point_cnt_old) { - for(i = point_cnt_old - 1; i < point_cnt; i++) { - ser->points[i] = def; - } - } - } + if(point_cnt >= point_cnt_old) { + for(i = 0; i < point_cnt_old; i++) { + new_points[i] = + ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/ + } + for(i = point_cnt_old; i < point_cnt; i++) { + new_points[i] = def; /*Fill up the rest with default value*/ + } + } + else { + for(i = 0; i < point_cnt; i++) { + new_points[i] = + ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/ + } + } + /*Switch over pointer from old to new*/ + lv_mem_free(ser->points); + ser->points = new_points; + } + else { + ser->points = lv_mem_realloc(ser->points, sizeof(lv_coord_t) * point_cnt); + LV_ASSERT_MEM(ser->points); + if(ser->points == NULL) return; + /*Initialize the new points*/ + if(point_cnt > point_cnt_old) { + for(i = point_cnt_old - 1; i < point_cnt; i++) { + ser->points[i] = def; + } + } + } + } ser->start_point = 0; } @@ -540,6 +541,64 @@ void lv_chart_set_secondary_y_tick_texts(lv_obj_t * chart, const char * list_of_ ext->secondary_y_axis.options = options; } +/** + * Set the index of the x-axis start point in the data array + * @param chart pointer to a chart object + * @param ser pointer to a data series on 'chart' + * @param id the index of the x point in the data array + */ +void lv_chart_set_x_start_point(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id) +{ + LV_ASSERT_OBJ(chart, LV_OBJX_NAME); + LV_ASSERT_NULL(ser); + + if(chart == NULL || ser == NULL) return; + lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); + if(ext == NULL) return; + if( id >= ext->point_cnt ) return; + ser->start_point = id; +} + +/** + * Set an external array of data points to use for the chart + * NOTE: It is the users responsibility to make sure the point_cnt matches the external array size. + * @param chart pointer to a chart object + * @param ser pointer to a data series on 'chart' + * @param array external array of points for chart + * @param point_cnt number of external points in the array + */ +void lv_chart_set_ext_array(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t array[], uint16_t point_cnt) +{ + LV_ASSERT_OBJ(chart, LV_OBJX_NAME); + LV_ASSERT_NULL(ser); + + if(chart == NULL || ser == NULL) return; + lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); + if( !ser->ext_buf_assigned && ser->points ) lv_mem_free(ser->points); + ser->ext_buf_assigned = true; + ser->points = array; + ext->point_cnt = point_cnt; +} + +/** + * Set an individual point y value in the chart series directly based on index + * @param chart pointer to a chart object + * @param ser pointer to a data series on 'chart' + * @param value value to assign to array point + * @param id the index of the x point in the array + */ +void lv_chart_set_point_id(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t value, uint16_t id) +{ + LV_ASSERT_OBJ(chart, LV_OBJX_NAME); + LV_ASSERT_NULL(ser); + + if(chart == NULL || ser == NULL) return; + lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); + if(ext == NULL) return; + if( id >= ext->point_cnt ) return; + ser->points[id] = value; +} + /*===================== * Getter functions *====================*/ @@ -570,6 +629,36 @@ uint16_t lv_chart_get_point_count(const lv_obj_t * chart) return ext->point_cnt; } +/** + * Get the current index of the x-axis start point in the data array + * @param ser pointer to a data series on 'chart' + * @return the index of the current x start point in the data array + */ +uint16_t lv_chart_get_x_start_point(lv_chart_series_t * ser) +{ + LV_ASSERT_NULL(ser); + + return(ser->start_point); +} + +/** + * Get an individual point y value in the chart series directly based on index + * @param chart pointer to a chart object + * @param ser pointer to a data series on 'chart' + * @param id the index of the x point in the array + * @return value of array point at index id + */ +lv_coord_t lv_chart_get_point_id(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id) +{ + LV_ASSERT_OBJ(chart, LV_OBJX_NAME); + LV_ASSERT_NULL(serie); + + lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); + if( id >= ext->point_cnt ) id = 0; + return(ser->points[id]); + +} + /*===================== * Other functions *====================*/ diff --git a/src/lv_widgets/lv_chart.h b/src/lv_widgets/lv_chart.h index 77534cc8c..85e66afe1 100644 --- a/src/lv_widgets/lv_chart.h +++ b/src/lv_widgets/lv_chart.h @@ -56,13 +56,14 @@ typedef struct { lv_coord_t * points; lv_color_t color; uint16_t start_point; + uint8_t ext_buf_assigned : 1; } lv_chart_series_t; /** Data of axis */ enum { LV_CHART_AXIS_SKIP_LAST_TICK = 0x00, /**< don't draw the last tick */ LV_CHART_AXIS_DRAW_LAST_TICK = 0x01, /**< draw the last tick */ - LV_CHART_AXIS_INVERSE_LABELS_ORDER = 0x02 /**< draw tick labels in an inversed order*/ + LV_CHART_AXIS_INVERSE_LABELS_ORDER = 0x02 /**< draw tick labels in an inverted order*/ }; typedef uint8_t lv_chart_axis_options_t; @@ -260,6 +261,32 @@ void lv_chart_set_secondary_y_tick_texts(lv_obj_t * chart, const char * list_of_ void lv_chart_set_y_tick_texts(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks, lv_chart_axis_options_t options); +/** + * Set the index of the x-axis start point in the data array + * @param chart pointer to a chart object + * @param ser pointer to a data series on 'chart' + * @param id the index of the x point in the data array + */ +void lv_chart_set_x_start_point(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id); + +/** + * Set an external array of data points to use for the chart + * NOTE: It is the users responsibility to make sure the point_cnt matches the external array size. + * @param chart pointer to a chart object + * @param ser pointer to a data series on 'chart' + * @param array external array of points for chart + */ +void lv_chart_set_ext_array(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t array[], uint16_t point_cnt ); + +/** + * Set an individual point value in the chart series directly based on index + * @param chart pointer to a chart object + * @param ser pointer to a data series on 'chart' + * @param value value to assign to array point + * @param id the index of the x point in the array + */ +void lv_chart_set_point_id(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t value, uint16_t id); + /*===================== * Getter functions *====================*/ @@ -278,6 +305,22 @@ lv_chart_type_t lv_chart_get_type(const lv_obj_t * chart); */ uint16_t lv_chart_get_point_count(const lv_obj_t * chart); +/** + * get the current index of the x-axis start point in the data array + * @param ser pointer to a data series on 'chart' + * @return the index of the current x start point in the data array + */ +uint16_t lv_chart_get_x_start_point(lv_chart_series_t * ser); + +/** + * Get an individual point value in the chart series directly based on index + * @param chart pointer to a chart object + * @param ser pointer to a data series on 'chart' + * @param id the index of the x point in the array + * @return value of array point at index id + */ +lv_coord_t lv_chart_get_point_id(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id); + /*===================== * Other functions *====================*/ From ad215c5b4b7f35ddbf0a6eb525b21aae1e6e576b Mon Sep 17 00:00:00 2001 From: PeterB Date: Tue, 16 Jun 2020 16:24:37 +0100 Subject: [PATCH 005/205] Finalise changes for new Chart Functions --- src/lv_widgets/lv_chart.c | 6 +++--- src/lv_widgets/lv_chart.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lv_widgets/lv_chart.c b/src/lv_widgets/lv_chart.c index 8e6c37fb1..d32f6565d 100644 --- a/src/lv_widgets/lv_chart.c +++ b/src/lv_widgets/lv_chart.c @@ -739,9 +739,9 @@ static lv_res_t lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); if(sign == LV_SIGNAL_CLEANUP) { - lv_coord_t ** datal; - _LV_LL_READ(ext->series_ll, datal) { - lv_mem_free(*datal); + lv_chart_series_t * ser; + _LV_LL_READ(ext->series_ll, ser) { + if(!ser->ext_buf_assigned) lv_mem_free(ser->points); } _lv_ll_clear(&ext->series_ll); diff --git a/src/lv_widgets/lv_chart.h b/src/lv_widgets/lv_chart.h index 85e66afe1..f9181abb2 100644 --- a/src/lv_widgets/lv_chart.h +++ b/src/lv_widgets/lv_chart.h @@ -79,7 +79,7 @@ typedef struct { typedef struct { /*No inherited ext*/ /*Ext. of ancestor*/ /*New data for this type */ - lv_ll_t series_ll; /*Linked list for the data line pointers (stores lv_chart_dl_t)*/ + lv_ll_t series_ll; /*Linked list for the data line pointers (stores lv_chart_series_t)*/ lv_coord_t ymin; /*y min value (used to scale the data)*/ lv_coord_t ymax; /*y max value (used to scale the data)*/ uint8_t hdiv_cnt; /*Number of horizontal division lines*/ From ae748cfffab87e3f6a78e26e5d855e77ca46197f Mon Sep 17 00:00:00 2001 From: pete-pjb Date: Tue, 16 Jun 2020 18:04:36 +0100 Subject: [PATCH 006/205] Fix initialisation problem. Found that new structure parmaeter ext_buf_assigned needs to be initialised to false in lv_chart_add_series() as sometimes is set true depending on what was previously in the heap where it was allocated. --- src/lv_widgets/lv_chart.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lv_widgets/lv_chart.c b/src/lv_widgets/lv_chart.c index d32f6565d..1b7963b0c 100644 --- a/src/lv_widgets/lv_chart.c +++ b/src/lv_widgets/lv_chart.c @@ -191,6 +191,7 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color) } ser->start_point = 0; + ser->ext_buf_assigned = false; uint16_t i; lv_coord_t * p_tmp = ser->points; From 4a953b9d9da0a90059950165f115c826f2763532 Mon Sep 17 00:00:00 2001 From: pete-pjb Date: Tue, 16 Jun 2020 18:24:05 +0100 Subject: [PATCH 007/205] Free memory for series_ll --- src/lv_widgets/lv_chart.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lv_widgets/lv_chart.c b/src/lv_widgets/lv_chart.c index 1b7963b0c..fb9c5c1c2 100644 --- a/src/lv_widgets/lv_chart.c +++ b/src/lv_widgets/lv_chart.c @@ -743,6 +743,7 @@ static lv_res_t lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param lv_chart_series_t * ser; _LV_LL_READ(ext->series_ll, ser) { if(!ser->ext_buf_assigned) lv_mem_free(ser->points); + lv_mem_free(ser); } _lv_ll_clear(&ext->series_ll); From 65d029279bcf82ce10316b235189a0ded6ce9cb7 Mon Sep 17 00:00:00 2001 From: Diego Herranz Date: Wed, 17 Jun 2020 21:09:40 +0100 Subject: [PATCH 008/205] lv_calendar: add option to start week on Monday (#1589) --- lv_conf_template.h | 3 +++ src/lv_conf_internal.h | 5 +++++ src/lv_widgets/lv_calendar.c | 10 +++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lv_conf_template.h b/lv_conf_template.h index de2287cf4..d381b596c 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -536,6 +536,9 @@ typedef void * lv_obj_user_data_t; /*Calendar (dependencies: -)*/ #define LV_USE_CALENDAR 1 +#if LV_USE_CALENDAR +# define LV_CALENDAR_WEEK_STARTS_MONDAY 0 +#endif /*Canvas (dependencies: lv_img)*/ #define LV_USE_CANVAS 1 diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index da8f7d8d1..6c653bf61 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -799,6 +799,11 @@ #ifndef LV_USE_CALENDAR #define LV_USE_CALENDAR 1 #endif +#if LV_USE_CALENDAR +#ifndef LV_CALENDAR_WEEK_STARTS_MONDAY +# define LV_CALENDAR_WEEK_STARTS_MONDAY 0 +#endif +#endif /*Canvas (dependencies: lv_img)*/ #ifndef LV_USE_CANVAS diff --git a/src/lv_widgets/lv_calendar.c b/src/lv_widgets/lv_calendar.c index d1b205bb4..b624ebfb7 100644 --- a/src/lv_widgets/lv_calendar.c +++ b/src/lv_widgets/lv_calendar.c @@ -57,7 +57,11 @@ static uint8_t is_leap_year(uint32_t year); **********************/ static lv_signal_cb_t ancestor_signal; static lv_design_cb_t ancestor_design; +#if LV_CALENDAR_WEEK_STARTS_MONDAY != 0 +static const char * day_name[7] = {"Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"}; +#else static const char * day_name[7] = {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}; +#endif static const char * month_name[12] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; @@ -1057,14 +1061,18 @@ static uint8_t is_leap_year(uint32_t year) * @param year a year * @param month a month * @param day a day - * @return [0..6] which means [Sun..Sat] + * @return [0..6] which means [Sun..Sat] or [Mon..Sun] depending on LV_CALENDAR_WEEK_STARTS_MONDAY */ static uint8_t get_day_of_week(uint32_t year, uint32_t month, uint32_t day) { uint32_t a = month < 3 ? 1 : 0; uint32_t b = year - a; + #if LV_CALENDAR_WEEK_STARTS_MONDAY + uint32_t day_of_week = (day + (31 * (month - 2 + 12 * a) / 12) + b + (b / 4) - (b / 100) + (b / 400) - 1) % 7; + #else uint32_t day_of_week = (day + (31 * (month - 2 + 12 * a) / 12) + b + (b / 4) - (b / 100) + (b / 400)) % 7; + #endif return day_of_week; } From 1523cc06342912f4c55ffaa8dc754b5ba50d0d9e Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 18 Jun 2020 06:03:49 +0200 Subject: [PATCH 009/205] fix typo --- src/lv_widgets/lv_chart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_widgets/lv_chart.c b/src/lv_widgets/lv_chart.c index b5e141f73..099296f0d 100644 --- a/src/lv_widgets/lv_chart.c +++ b/src/lv_widgets/lv_chart.c @@ -651,7 +651,7 @@ uint16_t lv_chart_get_x_start_point(lv_chart_series_t * ser) lv_coord_t lv_chart_get_point_id(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id) { LV_ASSERT_OBJ(chart, LV_OBJX_NAME); - LV_ASSERT_NULL(serie); + LV_ASSERT_NULL(ser); lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); if( id >= ext->point_cnt ) id = 0; From 156a3c005dc09ccef24e64b87d878afa325848b0 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 18 Jun 2020 12:35:38 +0200 Subject: [PATCH 010/205] Update CHANGELOG.md --- CHANGELOG.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f419954c8..84f012495 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,12 @@ # Changelog -## v7.1.0 (under development) -*Available in the `dev` branch* +## v7.2.0 (planned on 04.08.2020) + +### New features +- Add `LV_CALENDAR_WEEK_STARTS_MONDAY` + +## v7.1.0 (planned on 07.07.2020) +*Available in the `master` branch* ### New features - Add `focus_parent` attribute to `lv_obj` From 6ae7f67ef5064ac2e49db7a64a94273c871fb37a Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 18 Jun 2020 12:36:05 +0200 Subject: [PATCH 011/205] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84f012495..5b57e4011 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## v7.2.0 (planned on 04.08.2020) +Available in the `dev` branch ### New features - Add `LV_CALENDAR_WEEK_STARTS_MONDAY` From 765b6c4015e714da4f8e329573f7fc64fcd42bc9 Mon Sep 17 00:00:00 2001 From: Pete Bone Date: Thu, 18 Jun 2020 14:38:07 +0100 Subject: [PATCH 012/205] Update CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b57e4011..74d3961d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ Available in the `dev` branch ### New features - Add `LV_CALENDAR_WEEK_STARTS_MONDAY` +- Add `lv_chart_set_x_start_point()` function - Set the index of the x-axis start point in the data array +- Add `lv_chart_set_ext_array()` function - Set an external array of data points to use for the chart +- Add `lv_chart_set_point_id()` function - Set an individual point value in the chart series directly based on index +- Add `lv_chart_get_x_start_point()` function - Get the current index of the x-axis start point in the data array +- Add `lv_chart_get_point_id()` funtion - Get an individual point value in the chart series directly based on index +- Add `ext_buf_assigned` bit field to `lv_chart_series_t` structure - it's true if external buffer is assigned to series ## v7.1.0 (planned on 07.07.2020) *Available in the `master` branch* From 64be5e209618daa1a7bc2fc22e31916d3c1ccba6 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 18 Jun 2020 16:08:17 +0200 Subject: [PATCH 013/205] Update CONTRIBUTING.md --- docs/CONTRIBUTING.md | 113 +------------------------------------------ 1 file changed, 2 insertions(+), 111 deletions(-) diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 36d9b936a..9c9184681 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -1,114 +1,5 @@ # Contributing to LVGL -Thank you for considering contributing to LVGL. If you have some spare time to spend with programming you will certainly find a way to helpimproving LVGL. Do not afraid to take the first step! Everybody is welcome independently from gender, age, color, location, or skill level. So don't be shy, pick a point from the list below that you are interested in, and let's go! :rocket: +Thank you for considering contributing to LVGL. -- [Overview](#overview) -- [How to send a pull request?](#how-to-send-a-pull-request) -- [Help others in the Forum](help-others-in-the-forum) -- [Improve or translate the documentation](#improve-or-translate-the-documentation) -- [Write a blog post](#write-a-blog-post) -- [Report or fix bugs](#report-or-fix-bugs) -- [Suggest or implement new features](#suggest-or-implement-new-features) -- [Summary](#summary) - - -## Overview - -There are many ways to join the community. If you have some time to work with us you will surely find something that fits you! You can: -- **Help others** in the [Forum](https://forum.lvgl.io). -- **Inspire people** by speaking about your project in [My project](https://forum.lvgl.io/c/my-projects) category in the Forum. -- **Improve and/or translate the documentation.** Go to the [Documentation](https://github.com/lvgl/docs) repository to learn more. -- **Write a blog post** about your experiences. See how to do it in the [Blog](https://github.com/lvgl/blog) repository -- **Report and/or fix bugs** in [GitHub's issue tracker](https://github.com/lvgl/lvgl/issues) -- **Help the development**. Check the [Open issues](https://github.com/lvgl/lvgl/issues) especially the ones with [Help wanted](https://github.com/lvgl/lvgl/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) label and tell your ideas about a topic or implement a feature. - -We have some simple rules: -- Be kind and friendly. -- Speak about one thing in one issue/topic. -- Give feedback and close the issue or mark the topic as solved if your question is answered. -- Tell what you experience or expect. _"The button is not working"_ is not enough info to get help. -- Use [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) to format your post. -- We use the [Forum](https://forum.lvgl.io/) to ask and answer questions and [GitHub's issue tracker](https://github.com/lvgl/lvgl/issues) for development-related discussion. -- If possible send an absolute minimal code example in order to reproduce the issue - - -## How to send a pull request? - -Merging new code into LVGL, documentation, blog, and examples happens via *Pull requests*. If you are still not familiar with Pull Requests (PR for short) here is a short guide. It's about the `lvgl` repository but it works the same way for other repositories too. -1. **Fork** the [lvgl repository](https://github.com/lvgl/lvgl). To do this click the "Fork" button in the top right corner. It will "copy" the `lvgl` repository to your GitHub account (`https://github.com/your_name?tab=repositories`) -2. **Clone** the forked repository and add your changes -3. **Create a PR** on GitHub from the page of your `lvgl` repository (`https://github.com/your_name/lvgl`) by hitting the "New pull request" button -4. **Set the base branch**. It means where you want to merge your update. Fixes go to `master`, new features to feature branch. -5. **Describe** what is in the update. An example code is welcome if applicable. -6. **Update** your `lvgl` branch with new commits. They will appear in the PR too. - -Some advice: -- For non-trivial fixes and features it's better open an issue first to discuss the details. -- Maybe your fix or update won't be perfect at first. Don't be afraid, just improve it and push the new commits. The PR will be updated accordingly. -- If your update needs some extra work it's okay to say: _"I'm busy now and I will improve it soon"_ or _"Sorry, I don't have time to improve it, I hope it helps in this form too"_. -So it's better to say don't have time to continue than saying nothing. -- Please read and follow this [guide about the coding style](https://github.com/lvgl/lvgl/blob/master/docs/CODING_STYLE.md) - -## Help others in the Forum - -It's a great way to contribute to the library if you already use it. -Just go to [https://forum.lvgl.io/](https://forum.lvgl.io/) a register (Google and GitHub login also works). -Log in, read the titles and if you are already familiar with a topic, don't be shy, and write your suggestion. - -## Improve or translate the documentation - -If you would like to contribute to LVGL the documentation is the best place to start. - -### Fix typos, add missing parts - -If you find a typo, an obscure sentence or something which is not explained well enough in the [English documentation](https://docs.lvgl.io/en/html/index.html) -click the *"Edit on GitHub"* button in the top right corner and fix the issue by sending a Pull Request. - -### Translate the documentation - -If you have time and interest you can translate the documentation to your native language or any language you speak well. -You can join others to work on an already existing language or you can start a new one. - -To translate the documentation we use [Zanata](https://zanata.org) which is an online translation platform. -You will find the LVGL project here: [LVGL on Zanata](https://translate.zanata.org/iteration/view/littlevgl-docs/v6.0-doc1?dswid=3430) - -To get started you need to: -- register at [Zanata](https://zanata.org) which is an online translation platform. -- comment to [this post](https://forum.lvgl.io/t/translate-the-documentation/238?u=kisvegabor) -- tell your username at *Zanata* and your selected language(s) to get permission the edit the translations - -Note that a translation will be added to the documentation only if the following parts are translated: -- [Home page](https://docs.lvgl.io/en/v7/) -- [Porting section](https://docs.lvgl.io/en/v7/html/porting/index.html) -- [Quick overview](https://docs.lvgl.io/v7/en/html/get-started/quick-overview.html) - -## Write a blog post - -Have you ported LVGL to a new platform or created a fancy GUI? Do you know a great trick? -You can share your knowledge on LVGL's blog! It's super easy to add your own post: -- Fork and clone the [blog repository](https://github.com/lvgl/blog) -- Add your post in Markdown to the `_posts` folder. -- Store the images and other resources in a dedicated folder in `assets` -- Create a Pull Request - -The blog uses [Jekyll](https://jekyllrb.com/) to convert the `.md` files to a webpage. You can easily [run Jekyll offline](https://jekyllrb.com/docs/) to check your post before creating the Pull request - -## Report or fix bugs -For simple bugfixes (typos, missing error handling, fixing a warning) it's fine to send a Pull request directly. However, for more complex bugs it's better to open an issue first. In the issue, you should describe how to reproduce the bug and add the minimal code snippet. - -## Suggest or implement new features -If you have a good idea don't hesitate to share with us. It's even better if you have time to deal with its implementation. Don't be afraid if you still don't know LVGL well enough. We will help you to get started. - -To share your ideas use [Feature request](https://forum.lvgl.io/c/feature-request/9) category of the forum. - -If you are ready to get involved into the development of this faetures feel free to pen a [new issue](https://github.com/lvgl/lvgl/issues) for it on GitHub. - -During the implementation don't forget the [Code style guide](https://github.com/lvgl/lvgl/blob/master/docs/CODING_STYLE.md). - -If you implemented a new feature it's important to record it in the documentation and if applicable create an example for it: -- Go to the [docs](https://github.com/lvgl/docs/tree/master/v7/en) repository and update the relevant part of the English documentation. -- Go to the [examples](https://github.com/lvgl/lv_examples) repository and add a new file about the new feature in the related directory. - -## Summary - -I hope you have taken a liking to contribute to LVGL. A helpful and friendly community is waiting for you! :) +For a detailed description of contribution opportinities, please visit the [Contributing](https://docs.lvgl.io/latest/en/html/contributing/index.html) section of the documentation. From 2678068a86afb7b827aa8bf654c6f86a0152cf30 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 18 Jun 2020 16:09:07 +0200 Subject: [PATCH 014/205] Update CONTRIBUTING.md --- docs/CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 9c9184681..1a3941f42 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -2,4 +2,4 @@ Thank you for considering contributing to LVGL. -For a detailed description of contribution opportinities, please visit the [Contributing](https://docs.lvgl.io/latest/en/html/contributing/index.html) section of the documentation. +For a detailed description of contribution opportunities, please visit the [Contributing](https://docs.lvgl.io/latest/en/html/contributing/index.html) section of the documentation. From 8ac337d515bd78a973c87006ce96714c52bf8f47 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 18 Jun 2020 16:13:04 +0200 Subject: [PATCH 015/205] Update README.md --- README.md | 255 ++++++++---------------------------------------------- 1 file changed, 36 insertions(+), 219 deletions(-) diff --git a/README.md b/README.md index c8f796fd5..e61714767 100644 --- a/README.md +++ b/README.md @@ -14,43 +14,32 @@ LVGL provides everything you need to create embedded GUI with easy-to-use graphi

Website · -Live demo · +Online demo · Docs · Forum · -Blog

--- -- [Features](#features) -- [Supported devices](#supported-devices) -- [Quick start in a simulator](#quick-start-in-a-simulator) -- [Add LVGL to your project](#add-lvgl-to-your-project) -- [Learn the basics](#learn-the-basics) -- [Examples](#examples) -- [Release policy](#release-policy) -- [Contributing](#contributing) - - ## Features -* **Powerful building blocks** buttons, charts, lists, sliders, images, etc. -* **Advanced graphics** with animations, anti-aliasing, opacity, smooth scrolling -* **Simultaneously use various input devices** touchscreen, mouse, keyboard, encoder, buttons, etc. -* **Simultaneously use multiple displays** i.e. monochrome and color display -* **Multi-language support** with UTF-8 encoding, Bidirectional support, and Arabic text handling -* **Fully customizable** graphical elements -* **Hardware independent** to use with any microcontroller or display -* **Scalable** to operate with little memory (64 kB Flash, 10 kB RAM) -* **OS, External memory and GPU** supported but not required -* **Single frame buffer** operation even with advances graphical effects -* **Written in C** for maximal compatibility (C++ compatible) -* **Micropython Binding** exposes [LVGL API in Micropython](https://blog.lvgl.io/2019-02-20/micropython-bindings) -* **Simulator** to develop on PC without embedded hardware -* **Tutorials, examples, themes** for rapid development -* **Documentation** and API references +* Powerful building blocks: buttons, charts, lists, sliders, images, etc. +* Advanced graphics: animations, anti-aliasing, opacity, smooth scrolling +* Simultaneously use various input devices: touchscreen, mouse, keyboard, encoder, buttons, etc. +* Simultaneously use multiple displays: e.g. monochrome and color display +* Multi-language support with UTF-8 encoding, Bidirectional support, and Arabic text handling +* Fully customizable graphical elements via CSS-like styles +* Hardware independent to use with any microcontroller or display +* Scalable to operate with little memory (64 kB Flash, 10 kB RAM) +* OS, External memory and GPU are supported but not required +* Single frame buffer operation even with advances graphical effects +* Written in C for maximal compatibility (C++ compatible) +* Micropython Binding exposes [LVGL API in Micropython](https://blog.lvgl.io/2019-02-20/micropython-bindings) +* Simulator to develop on PC without embedded hardware +* Tutorials, examples, themes for rapid development +* Documentation and API references ## Supported devices -Basically, every modern controller (which is able to drive a display) is suitable to run LVGL. The minimal requirements are: +Basically, every modern controller (which is able to drive a display) is suitable to run LVGL. The minimal requirements are: - 16, 32 or 64 bit microcontroller or processor - > 16 MHz clock speed is recommended - Flash/ROM: > 64 kB for the very essential components (> 180 kB is recommended) @@ -64,168 +53,29 @@ Basically, every modern controller (which is able to drive a display) is suitab *Note that the memory usage might vary depending on the architecture, compiler and build options.* -Just to mention some **platforms**: -- STM32F1, STM32F3, [STM32F4](https://blog.lvgl.io/2017-07-15/stm32f429_disco_port), [STM32F7](https://github.com/lvgl/lv_port_stm32f746_disco_sw4stm32) +Just to mention some platforms: +- STM32F1, STM32F3, [STM32F4](https://blog.lvgl.io/2017-07-15/stm32f429_disco_port), [STM32F7](https://github.com/lvgl/lv_port_stm32f746_disco_sw4stm32), STM32L4 - Microchip dsPIC33, PIC24, PIC32MX, PIC32MZ -- NXP Kinetis, LPC, iMX +- NXP: Kinetis, LPC, iMX, iMX RT - [Linux frame buffer](https://blog.lvgl.io/2018-01-03/linux_fb) (/dev/fb) - [Raspberry PI](http://www.vk3erw.com/index.php/16-software/63-raspberry-pi-official-7-touchscreen-and-littlevgl) - [Espressif ESP32](https://github.com/lvgl/lv_port_esp32) -- Nordic nrf52 +- [Infineon aurix](https://github.com/lvgl/lv_port_aurix) +- Nordic NRF52 - Quectell M66 -## Quick start in a simulator -The easiest way to get started with LVGL is to run it in a simulator on your PC without any embedded hardware. - -Choose a project with your favourite IDE: - -| Eclipse | CodeBlocks | Visual Studio | PlatformIO | Qt Creator | -|-------------|-------------|---------------|-----------|------------| -| [![Eclipse](https://raw.githubusercontent.com/lvgl/docs/master/v7/misc//eclipse.jpg)](https://github.com/lvgl/lv_sim_eclipse_sdl) | [![CodeBlocks](https://raw.githubusercontent.com/lvgl/docs/master/v7/misc//codeblocks.jpg)](https://github.com/lvgl/lv_sim_codeblocks_win) | [![VisualStudio](https://raw.githubusercontent.com/lvgl/docs/master/v7/misc//visualstudio.jpg)](https://github.com/lvgl/lv_sim_visual_studio_sdl) | [![PlatformIO](https://raw.githubusercontent.com/lvgl/docs/master/v7/misc//platformio.jpg)](https://github.com/lvgl/lv_platformio) | [![QtCreator](https://raw.githubusercontent.com/lvgl/docs/master/v7/misc//qtcreator.jpg)](https://blog.lvgl.io/2019-01-03/qt-creator) | -| Cross-platform
with SDL
(Recommended on
Linux and Mac) | Native Windows | Windows
with SDL | Cross-platform
with SDL | Cross-platform
with SDL | - - -## Add LVGL to your project - -The steps below show how to setup LVGL on an embedded system with a display and a touchpad. -You can use the [Simulators](https://docs.lvgl.io/v7/en/html/get-started/pc-simulator) to get ready to use projects which can be run on your PC. - -1. [Download](https://github.com/lvgl/lvgl/archive/master.zip) or [Clone](https://github.com/lvgl/lvgl) the library -2. Copy the `lvgl` folder into your project -3. Copy `lvgl/lv_conf_template.h` as `lv_conf.h` next to the `lvgl` folder, change the `#if 0` statement near the top of the file to `#if 1` and set at least `LV_HOR_RES_MAX`, `LV_VER_RES_MAX` and `LV_COLOR_DEPTH`. -4. Include `lvgl/lvgl.h` where you need to use LVGL related functions. -5. Call `lv_tick_inc(x)` every `x` milliseconds (should be 1..10) in a Timer or Task. It is required for the internal timing of LVGL. -6. Call `lv_init()` -7. Create a display buffer for LVGL -```c -static lv_disp_buf_t disp_buf; -static lv_color_t buf[LV_HOR_RES_MAX * 10]; /*Declare a buffer for 10 lines*/ -lv_disp_buf_init(&disp_buf, buf, NULL, LV_HOR_RES_MAX * 10); /*Initialize the display buffer*/ -``` -8. Implement and register a function which can copy a pixel array to an area of your display: -```c -lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/ -lv_disp_drv_init(&disp_drv); /*Basic initialization*/ -disp_drv.flush_cb = my_disp_flush; /*Set your driver function*/ -disp_drv.buffer = &disp_buf; /*Assign the buffer to the display*/ -lv_disp_drv_register(&disp_drv); /*Finally register the driver*/ - -void my_disp_flush(lv_disp_t * disp, const lv_area_t * area, lv_color_t * color_p) -{ - int32_t x, y; - for(y = area->y1; y <= area->y2; y++) { - for(x = area->x1; x <= area->x2; x++) { - my_set_pixel(x, y, *color_p); /* Put a pixel to the display.*/ - color_p++; - } - } - - lv_disp_flush_ready(disp); /* Indicate you are ready with the flushing*/ -} - -``` -9. Implement and register a function which can read an input device. E.g. for a touch pad: -```c -lv_indev_drv_init(&indev_drv); /*Descriptor of a input device driver*/ -indev_drv.type = LV_INDEV_TYPE_POINTER; /*Touch pad is a pointer-like device*/ -indev_drv.read_cb = my_touchpad_read; /*Set your driver function*/ -lv_indev_drv_register(&indev_drv); /*Finally register the driver*/ - -bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data) -{ - data->state = my_touchpad_is_pressed() ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL; - if(data->state == LV_INDEV_STATE_PR) touchpad_get_xy(&data->point.x, &data->point.y); - - return false; /*Return `false` because we are not buffering and no more data to read*/ -} -``` -10. Call `lv_task_handler()` periodically every few milliseconds in the main `while(1)` loop, in Timer interrupt or in an Operation system task. -It will redraw the screen if required, handle input devices etc. - -For more detailed desription visit the [Porting](https://docs.lvgl.io/v7/en/html/porting/index.html) section of the documentation. - -## Learn the basics - -In this section you can read the very basics of LVGL. -For a more detailed guide check the [Quick overview](https://docs.lvgl.io/v7/en/html/get-started/quick-overview.html#learn-the-basics) in the documentation. - -### Widgets (Objects) - -The graphical elements like Buttons, Labels, Sliders, Charts etc are called objects or widgets in LVGL. Go to [Widgets](https://docs.lvgl.io/v7/en/html/widgets/index) to see the full list of available types. - -Every object has a parent object. The child object moves with the parent and if you delete the parent the children will be deleted too. Children can be visible only on their parent. - -The *screen* are the "root" parents. To get the current screen call `lv_scr_act()`. - -You can create a new object with `lv__create(parent, obj_to_copy)`. It will return an `lv_obj_t *` variable which should be used as a reference to the object to set its parameters later. -The first parameter is the desired *parent*, the second parameters can be an object to copy (`NULL` if unused). -For example: -```c -lv_obj_t * slider1 = lv_slider_create(lv_scr_act(), NULL); -``` - -To set some basic attribute `lv_obj_set_(obj, )` function can be used. For example: -```c -lv_obj_set_x(btn1, 30); -lv_obj_set_y(btn1, 10); -lv_obj_set_size(btn1, 200, 50); -``` - -The objects have type specific parameters too which can be set by `lv__set_(obj, )` functions. For example: -```c -lv_slider_set_value(slider1, 70, LV_ANIM_ON); -``` - -To see the full API visit the documentation of the object types or the related header file (e.g. `lvgl/src/lv_objx/lv_slider.h`). - - -To create a new screen pass `NULL` as the fisrt paramater of a *create* function: -```c -lv_obj_t * scr2 = lv_obj_create(NULL, NULL); /*Create a screen*/ -lv_scr_load(scr2); /*Load the new screen*/ -``` - -### Styles -Widgets are created with a default appearance but it can be changed by adding new styles to them. A new style can be created like this: -```c -static lv_style_t style1; /*Should be static, global or dynamically allocated*/ -lv_style_init(&style1); -lv_style_set_bg_color(&style1, LV_STATE_DEFAULT, LV_COLOR_RED); /*Default background color*/ -lv_style_set_bg_color(&style1, LV_STATE_PRESSED, LV_COLOR_BLUE); /*Pressed background color*/ -``` - -The wigedt have *parts* which can be referenced via `LV__PART_`. E.g. `LV_BTN_PART_MAIN` or `LV_SLIDER_PART_KNOB`. See the documentation of the widgets to see the exisitng parts. - -To add the style to a button: -```c -lv_obj_add_style(btn1, LV_BTN_PART_MAIN, &style1); -``` - -To remove all styles from a part of an object: -```cc -lv_obj_reset_style_list(obj, LV_OBJ_PART_MAIN); -``` - -Learn more in [Style overview](https://docs.lvgl.io/v7/en/html/overview/style) section. - -### Events -Events are used to inform the user if something has happened with an object. You can assign a callback to an object which will be called if the object is clicked, released, dragged, being deleted etc. It should look like this: - -```c -lv_obj_set_event_cb(btn, btn_event_cb); /*Assign a callback to the button*/ - -... - -void btn_event_cb(lv_obj_t * btn, lv_event_t event) -{ - if(event == LV_EVENT_CLICKED) { - printf("Clicked\n"); - } -} -``` - -Learn more about the events in the [Event overview](https://docs.lvgl.io/v7/en/html/overview/event) section. - +## Get started +his list shows the recommended way of learning the library: +1. Check the [Online demos](https://lvgl.io/demos) to see LVGL in action (3 minutes) +2. Read the [Introduction](https://docs.lvgl.io/latest/en/html/intro/index.html) page of the documentation (5 minutes) +3. Read the [Quick overview](https://docs.lvgl.io/latest/en/html/get-started/quick-overview.html) page of the documentation (15 minutes) +4. Set up a [Simulator](https://docs.lvgl.io/latest/en/html/get-started/pc-simulator.html) (10 minutes) +5. Try out some [Examples](https://github.com/lvgl/lv_examples/) +6. Port LVGL to a board. See the [Porting](https://docs.lvgl.io/latest/en/html/porting/index.html) guide or check the ready to use [Projects](https://github.com/lvgl?q=lv_port_&type=&language=) +7. Read the [Overview](https://docs.lvgl.io/latest/en/html/overview/index.html) page to get a better understanding of the library. (2-3 hours) +8. Check the documentation of the [Widgets](https://docs.lvgl.io/latest/en/html/widgets/index.html) to see their features and usage +9. If you have questions got to the [Forum](http://forum.lvgl.io/) +10. Read the [Contributing](https://docs.lvgl.io/latest/en/html/contributing/index.html) guide to see how you can help to improve LVGL (15 minutes) ## Examples @@ -250,7 +100,7 @@ void btn_event_cb(lv_obj_t * btn, lv_event_t event) ``` ![LVGL button with label example](https://docs.lvgl.io/v7/en/misc/simple_button_example.gif) -### Use LVGL from Micropython +### LVGL from Micropython Learn more about [Micropython](https://docs.lvgl.io/en/html/get-started/micropython). ```python # Create a Button and a Label @@ -264,38 +114,5 @@ label.set_text("Button") lv.scr_load(scr) ``` -## Release policy -LVGL follows the rules of [Semantic versioning](https://semver.org/): -- Major versions for incompatible API changes. E.g. v5.0.0, v6.0.0 -- Minor version for new but backward-compatible functionalities. E.g. v6.1.0, v6.2.0 -- Patch version for backward-compatible bug fixes. E.g. v6.1.1, v6.1.2 - -Branches: -- `master` most recent version, patches are merged directly here. -- `dev` merge new features here until they are merged into `master`. -- `release/vX` there is a branch for every major version to allow adding specific, not forward compatible fixes. - -LVGL has a monthly periodic release cycle. -- **1st Tuesday of the month** -  - Make a major, minor, or patch release from `master` depending on the new features. -  - After that merge only patches into `master` and add new features into the `dev`. -- **3rd Tuesday of the month** -  - Make a patch release from `master`. -  - After that merge the new features from the `dev` to `master` branch. -  - In the rest of the month merge only patches into `master` and new features into `dev` branch. - ## Contributing -To ask questions please use the [Forum](https://forum.lvgl.io). -For development-related things (bug reports, feature suggestions) use [GitHub's Issue tracker](https://github.com/lvgl/lvgl/issues). - -If you are interested in contributing to LVGL you can -- **Help others** in the [Forum](https://forum.lvgl.io). -- **Inspire people** by speaking about your project in [My project](https://forum.lvgl.io/c/my-projects) category in the Forum. -- **Improve and/or translate the documentation.** Go to the [Documentation](https://github.com/lvgl/docs) repository to learn more -- **Write a blog post** about your experiences. See how to do it in the [Blog](https://github.com/lvgl/blog) repository -- **Report and/or fix bugs** in [GitHub's issue tracker](https://github.com/lvgl/lvgl/issues) -- **Help in the developement**. Check the [Open issues](https://github.com/lvgl/lvgl/issues) especially the ones with [Help wanted](https://github.com/lvgl/lvgl/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) label and tell your ideas about a topic or implement a feature. - -Before sending Pull requests, please read the following guides: -- [Contributing guide](https://github.com/lvgl/lvgl/blob/master/docs/CONTRIBUTING.md) -- [Coding style guide](https://github.com/lvgl/lvgl/blob/master/docs/CODING_STYLE.md) +For a detailed description of contribution opportunities visit the [Contributing](https://docs.lvgl.io/latest/en/html/contributing/index.html) section of the documentation. From 5d4873aa95f19a2ab80b75b86dbe6749f8888760 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 18 Jun 2020 16:19:57 +0200 Subject: [PATCH 016/205] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e61714767..ea3f45ee5 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ void btn_event_cb(lv_obj_t * btn, lv_event_t event) } } ``` -![LVGL button with label example](https://docs.lvgl.io/v7/en/misc/simple_button_example.gif) +![LVGL button with label example](https://raw.githubusercontent.com/lvgl/docs/latest/misc/simple_button_example.gif) ### LVGL from Micropython Learn more about [Micropython](https://docs.lvgl.io/en/html/get-started/micropython). From 0f4aeede79e93f3a57c510c4dfb970eddc39d901 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 18 Jun 2020 16:29:18 +0200 Subject: [PATCH 017/205] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ea3f45ee5..e7d193fb2 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,8 @@ his list shows the recommended way of learning the library: ## Examples +For more examples see the [lv_examples](https://github.com/lvgl/lv_examples) repository. + ### Button with label ```c lv_obj_t * btn = lv_btn_create(lv_scr_act(), NULL); /*Add a button the current screen*/ From 24b1a7735a4696f82ed2ee43c216d19b6ce0ce35 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 19 Jun 2020 13:17:45 +0200 Subject: [PATCH 018/205] roller: allow setting different font for the selected text --- CHANGELOG.md | 1 + src/lv_widgets/lv_roller.c | 110 ++++++++++++++++++++++++++++++++----- 2 files changed, 98 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74d3961d0..62d08413d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Available in the `dev` branch - Add `lv_chart_get_x_start_point()` function - Get the current index of the x-axis start point in the data array - Add `lv_chart_get_point_id()` funtion - Get an individual point value in the chart series directly based on index - Add `ext_buf_assigned` bit field to `lv_chart_series_t` structure - it's true if external buffer is assigned to series +- Allow setting different font for the selected text in `lv_roller` ## v7.1.0 (planned on 07.07.2020) *Available in the `master` branch* diff --git a/src/lv_widgets/lv_roller.c b/src/lv_widgets/lv_roller.c index 342d85a42..abd3e22c9 100644 --- a/src/lv_widgets/lv_roller.c +++ b/src/lv_widgets/lv_roller.c @@ -33,6 +33,7 @@ * STATIC PROTOTYPES **********************/ static lv_design_res_t lv_roller_design(lv_obj_t * roller, const lv_area_t * clip_area, lv_design_mode_t mode); +static lv_design_res_t lv_roller_label_design(lv_obj_t * label, const lv_area_t * clip_area, lv_design_mode_t mode); static lv_res_t lv_roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign, void * param); static lv_style_list_t * lv_roller_get_style(lv_obj_t * roller, uint8_t part); static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * param); @@ -51,6 +52,7 @@ static void draw_bg(lv_obj_t * roller, const lv_area_t * clip_area); * STATIC VARIABLES **********************/ static lv_signal_cb_t ancestor_signal; +static lv_design_cb_t ancestor_label_design; static lv_signal_cb_t ancestor_scrl_signal; /********************** @@ -103,7 +105,8 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy) lv_obj_t * label = lv_label_create(roller, NULL); lv_label_set_align(label, LV_LABEL_ALIGN_CENTER); - + if(ancestor_label_design == NULL) ancestor_label_design = lv_obj_get_design_cb(label); + lv_obj_set_design_cb(label, lv_roller_label_design); lv_obj_t * scrl = lv_page_get_scrollable(roller); lv_obj_set_drag(scrl, true); lv_page_set_scrollable_fit2(roller, LV_FIT_PARENT, LV_FIT_NONE); /*Height is specified directly*/ @@ -187,10 +190,8 @@ void lv_roller_set_options(lv_obj_t * roller, const char * options, lv_roller_mo ext->sel_opt_id_ori = ext->sel_opt_id; - - // refr_width(roller); - // refr_height(roller); - refr_position(roller, LV_ANIM_OFF); + refr_height(roller); + refr_width(roller); } /** @@ -408,7 +409,6 @@ const char * lv_roller_get_options(const lv_obj_t * roller) */ static lv_design_res_t lv_roller_design(lv_obj_t * roller, const lv_area_t * clip_area, lv_design_mode_t mode) { - /*Return false if the object is not covers the mask_p area*/ if(mode == LV_DESIGN_COVER_CHK) { return LV_DESIGN_RES_NOT_COVER; } @@ -441,13 +441,13 @@ static lv_design_res_t lv_roller_design(lv_obj_t * roller, const lv_area_t * cli lv_draw_label_dsc_init(&label_dsc); lv_obj_init_draw_label_dsc(roller, LV_ROLLER_PART_SELECTED, &label_dsc); - lv_coord_t font_h = lv_font_get_line_height(label_dsc.font); + lv_coord_t bg_font_h = lv_font_get_line_height(lv_obj_get_style_text_font(roller, LV_ROLLER_PART_BG)); - /*Redraw the text on the selected area with a different color*/ + /*Redraw the text on the selected area*/ lv_area_t rect_area; - rect_area.y1 = roller->coords.y1 + lv_obj_get_height(roller) / 2 - font_h / 2 - label_dsc.line_space / 2; - if((font_h & 0x1) && (label_dsc.line_space & 0x1)) rect_area.y1--; /*Compensate the two rounding error*/ - rect_area.y2 = rect_area.y1 + font_h + label_dsc.line_space - 1; + rect_area.y1 = roller->coords.y1 + lv_obj_get_height(roller) / 2 - bg_font_h / 2 - label_dsc.line_space / 2; + if((bg_font_h & 0x1) && (label_dsc.line_space & 0x1)) rect_area.y1--; /*Compensate the two rounding error*/ + rect_area.y2 = rect_area.y1 + bg_font_h + label_dsc.line_space - 1; rect_area.x1 = roller->coords.x1; rect_area.x2 = roller->coords.x2; lv_area_t mask_sel; @@ -464,7 +464,91 @@ static lv_design_res_t lv_roller_design(lv_obj_t * roller, const lv_area_t * cli label_dsc.flag |= LV_TXT_FLAG_RIGHT; } - lv_draw_label(&label->coords, &mask_sel, &label_dsc, lv_label_get_text(label), NULL); + /*Get the size of the "selected text"*/ + lv_point_t res_p; + _lv_txt_get_size(&res_p, lv_label_get_text(label), label_dsc.font, label_dsc.letter_space, label_dsc.line_space, lv_obj_get_width(roller), LV_TXT_FLAG_EXPAND); + + /*Move the selected label proportionally with the background label*/ + lv_coord_t roller_h = lv_obj_get_height(roller); + int32_t label_y_prop = label->coords.y1 - (roller_h / 2 + roller->coords.y1); /*label offset from the middle line of the roller*/ + label_y_prop = (label_y_prop << 14) / lv_obj_get_height(label); /*Proportional position from the middle line (upscaled)*/ + + /*Apply a correction with different line heights*/ + const lv_font_t * normal_label_font = lv_obj_get_style_text_font(roller, LV_ROLLER_PART_BG); + lv_coord_t corr = (label_dsc.font->line_height - normal_label_font->line_height) / 2; + + /*Apply the proportional position to the selected text*/ + res_p.y -= corr; + int32_t label_sel_y = roller_h / 2 + roller->coords.y1; + label_sel_y += (label_y_prop * res_p.y) >> 14; + label_sel_y -= corr; + + /*Draw the selected text*/ + lv_area_t label_sel_area; + label_sel_area.x1 = label->coords.x1; + label_sel_area.y1 = label_sel_y; + label_sel_area.x2 = label->coords.x2; + label_sel_area.y2 = label_sel_area.y1 + res_p.y; + + label_dsc.flag |= LV_TXT_FLAG_EXPAND; + lv_draw_label(&label_sel_area, &mask_sel, &label_dsc, lv_label_get_text(label), NULL); + } + } + + return LV_DESIGN_RES_OK; +} + + +/** + * Handle the drawing related tasks of the roller's label + * @param roller pointer to an object + * @param clip_area the object will be drawn only in this area + * @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area + * (return 'true' if yes) + * LV_DESIGN_DRAW: draw the object (always return 'true') + * LV_DESIGN_DRAW_POST: drawing after all children are drawn + * @param return an element of `lv_design_res_t` + */ +static lv_design_res_t lv_roller_label_design(lv_obj_t * label, const lv_area_t * clip_area, lv_design_mode_t mode) +{ + if(mode == LV_DESIGN_COVER_CHK) { + return ancestor_label_design(label, clip_area, mode); + } + /*Draw the object*/ + else if(mode == LV_DESIGN_DRAW_MAIN) { + /* Split the drawing of the label into an upper (above the selected area) + * and a lower (below the selected area)*/ + lv_obj_t * roller = lv_obj_get_parent(lv_obj_get_parent(label)); + const lv_font_t * font = lv_obj_get_style_text_font(roller, LV_ROLLER_PART_BG); + lv_style_int_t line_space = lv_obj_get_style_text_line_space(roller, LV_ROLLER_PART_BG); + lv_coord_t font_h = lv_font_get_line_height(font); + + lv_area_t rect_area; + rect_area.y1 = roller->coords.y1 + lv_obj_get_height(roller) / 2 - font_h / 2 - line_space / 2; + if((font_h & 0x1) && (line_space & 0x1)) rect_area.y1--; /*Compensate the two rounding error*/ + rect_area.y2 = rect_area.y1 + font_h + line_space - 1; + lv_area_t roller_coords; + lv_obj_get_coords(roller, &roller_coords); + lv_obj_get_inner_coords(roller, &roller_coords); + + rect_area.x1 = roller_coords.x1; + rect_area.x2 = roller_coords.x2; + + lv_area_t clip2; + clip2.x1 = label->coords.x1; + clip2.y1 = label->coords.y1; + clip2.x2 = label->coords.x2; + clip2.y2 = rect_area.y1; + if(_lv_area_intersect(&clip2, clip_area, &clip2)) { + ancestor_label_design(label, &clip2, mode); + } + + clip2.x1 = label->coords.x1; + clip2.y1 = rect_area.y2; + clip2.x2 = label->coords.x2; + clip2.y2 = label->coords.y2; + if(_lv_area_intersect(&clip2, clip_area, &clip2)) { + ancestor_label_design(label, &clip2, mode); } } @@ -751,7 +835,7 @@ static void refr_position(lv_obj_t * roller, lv_anim_enable_t anim_en) lv_coord_t h = lv_obj_get_height(roller); uint16_t anim_time = lv_roller_get_anim_time(roller); - /* Normally the animation's `end_cb` sets correct position of the roller is infinite. + /* Normally the animation's `end_cb` sets correct position of the roller if infinite. * But without animations do it manually*/ if(anim_en == LV_ANIM_OFF || anim_time == 0) { inf_normalize(roller_scrl); From 4345e05e3251232353b8232e90d2eefbc0215600 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 19 Jun 2020 15:12:17 +0200 Subject: [PATCH 019/205] test Signed-off-by: Gabor Kiss-Vamosi --- lvgl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lvgl.h b/lvgl.h index 5165a598b..5456f5993 100644 --- a/lvgl.h +++ b/lvgl.h @@ -2,7 +2,7 @@ * @file lvgl.h * Include all LittleV GL related headers */ - + #ifndef LVGL_H #define LVGL_H From 8dbd685a908995a951fff82a9e96b6527e0e542d Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Fri, 19 Jun 2020 10:13:53 -0400 Subject: [PATCH 020/205] Fix #1596: typo in `lv_api_map.h` --- src/lv_api_map.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_api_map.h b/src/lv_api_map.h index 9e46e6815..cc3f245e8 100644 --- a/src/lv_api_map.h +++ b/src/lv_api_map.h @@ -153,7 +153,7 @@ static inline void lv_roller_set_fix_width(lv_obj_t * roller, lv_coord_t w) #define lv_scrlbar_mode_t lv_scrollbar_mode_t #define LV_SCRLBAR_MODE_OFF LV_SCROLLBAR_MODE_OFF -#define LV_SCRLBAR_MODE_ON LV_SCRILLBAR_MODE_ON +#define LV_SCRLBAR_MODE_ON LV_SCROLLBAR_MODE_ON #define LV_SCRLBAR_MODE_DRAG LV_SCROLLBAR_MODE_DRAG #define LV_SCRLBAR_MODE_AUTO LV_SCROLLBAR_MODE_AUTO #define LV_SCRLBAR_MODE_HIDE LV_SCROLLBAR_MODE_HIDE From 201d38c5745e58410f4864f52fb2abe095576afe Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sat, 20 Jun 2020 00:00:31 +0200 Subject: [PATCH 021/205] Add theme->apply_cb to replace theme->apply_xcb to make it compatible with the Micropython binding --- CHANGELOG.md | 1 + src/lv_themes/lv_theme.c | 8 +++++++- src/lv_themes/lv_theme.h | 7 ++++--- src/lv_themes/lv_theme_empty.c | 8 +++++--- src/lv_themes/lv_theme_material.c | 9 ++++++--- src/lv_themes/lv_theme_mono.c | 9 ++++++--- src/lv_themes/lv_theme_template.c | 9 ++++++--- 7 files changed, 35 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62d08413d..24b8b0205 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Available in the `dev` branch - Add `lv_chart_get_point_id()` funtion - Get an individual point value in the chart series directly based on index - Add `ext_buf_assigned` bit field to `lv_chart_series_t` structure - it's true if external buffer is assigned to series - Allow setting different font for the selected text in `lv_roller` +- Add `theme->apply_cb` to replace `theme->apply_xcb` to make it compatible with the Micropython binding ## v7.1.0 (planned on 07.07.2020) *Available in the `master` branch* diff --git a/src/lv_themes/lv_theme.c b/src/lv_themes/lv_theme.c index 1d7c03029..f32008c72 100644 --- a/src/lv_themes/lv_theme.c +++ b/src/lv_themes/lv_theme.c @@ -118,7 +118,13 @@ uint32_t lv_theme_get_flags(void) void lv_theme_apply(lv_obj_t * obj, lv_theme_style_t name) { - act_theme->apply_xcb(obj, name); + /*apply_xcb is deprecated, use apply_cb instead*/ + if (act_theme->apply_xcb) { + act_theme->apply_xcb(obj, name); + } + else if(act_theme->apply_cb) { + act_theme->apply_cb(act_theme, obj, name); + } } diff --git a/src/lv_themes/lv_theme.h b/src/lv_themes/lv_theme.h index 7b4f65b3d..4436d0f9e 100644 --- a/src/lv_themes/lv_theme.h +++ b/src/lv_themes/lv_theme.h @@ -141,13 +141,14 @@ typedef enum { #endif _LV_THEME_BUILTIN_LAST, - _LV_THEME_CUSTOM_START = _LV_THEME_BUILTIN_LAST, + LV_THEME_CUSTOM_START = _LV_THEME_BUILTIN_LAST, _LV_THEME_CUSTOM_LAST = 0xFFFF, } lv_theme_style_t; -typedef struct { - void (*apply_xcb)(lv_obj_t *, lv_theme_style_t); +typedef struct _lv_theme_t { + void (*apply_xcb)(lv_obj_t *, lv_theme_style_t); /*Deprecated: use `apply_cb` instead*/ + void (*apply_cb)(struct _lv_theme_t *, lv_obj_t *, lv_theme_style_t); lv_color_t color_primary; lv_color_t color_secondary; const lv_font_t * font_small; diff --git a/src/lv_themes/lv_theme_empty.c b/src/lv_themes/lv_theme_empty.c index 9353bc63d..821bbd510 100644 --- a/src/lv_themes/lv_theme_empty.c +++ b/src/lv_themes/lv_theme_empty.c @@ -31,7 +31,7 @@ typedef struct { /********************** * STATIC PROTOTYPES **********************/ -static void theme_apply(lv_obj_t * obj, lv_theme_style_t name); +static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name); static void style_init_reset(lv_style_t * style); /********************** @@ -89,13 +89,15 @@ lv_theme_t * lv_theme_empty_init(lv_color_t color_primary, lv_color_t color_seco style_init_reset(&styles->opa_cover); lv_style_set_bg_opa(&styles->opa_cover, LV_STATE_DEFAULT, LV_OPA_COVER); - theme.apply_xcb = theme_apply; + theme.apply_xcb = NULL; + theme.apply_cb = theme_apply; return &theme; } -void theme_apply(lv_obj_t * obj, lv_theme_style_t name) +void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) { + LV_UNUSED(th); if(name == LV_THEME_SCR) { lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN); lv_obj_add_style(obj, LV_OBJ_PART_MAIN, &styles->opa_cover); diff --git a/src/lv_themes/lv_theme_material.c b/src/lv_themes/lv_theme_material.c index 33d6f4985..e60ef8b43 100644 --- a/src/lv_themes/lv_theme_material.c +++ b/src/lv_themes/lv_theme_material.c @@ -176,7 +176,7 @@ typedef struct { /********************** * STATIC PROTOTYPES **********************/ -static void theme_apply(lv_obj_t * obj, lv_theme_style_t name); +static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name); static void style_init_reset(lv_style_t * style); /********************** @@ -928,7 +928,8 @@ lv_theme_t * lv_theme_material_init(lv_color_t color_primary, lv_color_t color_s table_init(); win_init(); - theme.apply_xcb = theme_apply; + theme.apply_xcb = NULL; + theme.apply_cb = theme_apply; inited = true; @@ -938,8 +939,10 @@ lv_theme_t * lv_theme_material_init(lv_color_t color_primary, lv_color_t color_s } -static void theme_apply(lv_obj_t * obj, lv_theme_style_t name) +static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) { + LV_UNUSED(th); + lv_style_list_t * list; switch(name) { diff --git a/src/lv_themes/lv_theme_mono.c b/src/lv_themes/lv_theme_mono.c index 1b0924d44..67727f787 100644 --- a/src/lv_themes/lv_theme_mono.c +++ b/src/lv_themes/lv_theme_mono.c @@ -83,7 +83,7 @@ typedef struct { /********************** * STATIC PROTOTYPES **********************/ -static void theme_apply(lv_obj_t * obj, lv_theme_style_t name); +static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name); static void style_init_reset(lv_style_t * style); /********************** @@ -552,14 +552,17 @@ lv_theme_t * lv_theme_mono_init(lv_color_t color_primary, lv_color_t color_secon table_init(); win_init(); - theme.apply_xcb = theme_apply; + theme.apply_xcb = NULL; + theme.apply_cb = theme_apply; return &theme; } -static void theme_apply(lv_obj_t * obj, lv_theme_style_t name) +static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) { + LV_UNUSED(th); + lv_style_list_t * list; switch(name) { diff --git a/src/lv_themes/lv_theme_template.c b/src/lv_themes/lv_theme_template.c index 87c3bbdd0..2c6a8f9b8 100644 --- a/src/lv_themes/lv_theme_template.c +++ b/src/lv_themes/lv_theme_template.c @@ -37,7 +37,7 @@ typedef struct { /********************** * STATIC PROTOTYPES **********************/ -static void theme_apply(lv_obj_t * obj, lv_theme_style_t name); +static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name); /********************** * STATIC VARIABLES @@ -402,14 +402,17 @@ lv_theme_t * lv_theme_template_init(lv_color_t color_primary, lv_color_t color_s table_init(); win_init(); - theme.apply_xcb = theme_apply; + theme.apply_xcb = NULL; + theme.apply_cb = theme_apply; return &theme; } -void theme_apply(lv_obj_t * obj, lv_theme_style_t name) +void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) { + LV_UNUSED(th); + lv_style_list_t * list; switch(name) { From f9512f55cc35371af2cf4779b3d98990d3b44f61 Mon Sep 17 00:00:00 2001 From: Deon Marais Date: Sat, 20 Jun 2020 09:08:59 +0200 Subject: [PATCH 022/205] Add missing lv_font_montserrat_34 if you do not mind me asking, and on matters of fonts why was Roboto changed to Montserrat when V7 was released ? --- src/lv_font/lv_font.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lv_font/lv_font.h b/src/lv_font/lv_font.h index cb90329bf..b319158c1 100644 --- a/src/lv_font/lv_font.h +++ b/src/lv_font/lv_font.h @@ -171,6 +171,10 @@ LV_FONT_DECLARE(lv_font_montserrat_30) LV_FONT_DECLARE(lv_font_montserrat_32) #endif +#if LV_FONT_MONTSERRAT_34 +LV_FONT_DECLARE(lv_font_montserrat_34) +#endif + #if LV_FONT_MONTSERRAT_36 LV_FONT_DECLARE(lv_font_montserrat_36) #endif From 20c46ca640690ec15e7273319cb6254cf6cbd938 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 23 Jun 2020 11:11:45 +0200 Subject: [PATCH 023/205] In lv_init test if the the strings are UTF-8 encoded --- CHANGELOG.md | 1 + src/lv_core/lv_obj.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e749bce9..1a9151416 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Add lv_btnmatrix_set/get_align capability - DMA2D: Remove dependency on ST CubeMX HAL - Added `max_used` propriety to `lv_mem_monitor_t` struct +- In `lv_init` test if the the strings are UTF-8 encoded. ### Bugfixes - None diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 211a14559..109f7eb2f 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -168,6 +168,14 @@ void lv_init(void) _lv_img_decoder_init(); lv_img_cache_set_size(LV_IMG_CACHE_DEF_SIZE); + /*Test if the IDE has UTF-8 encoding*/ + char * txt = "Á"; + + uint8_t * txt_u8 = (uint8_t *) txt; + if(txt_u8[0] != 0xc3 || txt_u8[1] != 0x81 || txt_u8[2] != 0x00) { + LV_LOG_WARN("The strings has no UTF-8 encoding. Some characters won't be displayed.") + } + lv_initialized = true; LV_LOG_INFO("lv_init ready"); } From c0223977d133d1ec41e2a364e41175f859dc97d6 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 23 Jun 2020 11:44:06 +0200 Subject: [PATCH 024/205] roller: fix misaligned option after setting new options --- src/lv_widgets/lv_roller.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lv_widgets/lv_roller.c b/src/lv_widgets/lv_roller.c index 342d85a42..8a366fd79 100644 --- a/src/lv_widgets/lv_roller.c +++ b/src/lv_widgets/lv_roller.c @@ -188,9 +188,9 @@ void lv_roller_set_options(lv_obj_t * roller, const char * options, lv_roller_mo ext->sel_opt_id_ori = ext->sel_opt_id; - // refr_width(roller); - // refr_height(roller); - refr_position(roller, LV_ANIM_OFF); + refr_height(roller); + refr_width(roller); +// refr_position(roller, LV_ANIM_OFF); } /** From 916f5b343a947ffb702adbfdbc5f165160c28554 Mon Sep 17 00:00:00 2001 From: jbamaral Date: Tue, 23 Jun 2020 09:30:33 -0300 Subject: [PATCH 025/205] Improve big endian support (#1599) --- CHANGELOG.md | 1 + src/lv_core/lv_obj.c | 17 ++- src/lv_core/lv_style.c | 205 +++++++++++++++++++++++----------- src/lv_core/lv_style.h | 11 +- src/lv_font/lv_font_fmt_txt.c | 6 +- 5 files changed, 154 insertions(+), 86 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a9151416..e5ff0aaa6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## v7.1.0 (planned on 07.07.2020) *Available in the `master` branch* +- Change some lv_style_t methods to support big endian hardware. ### New features - Add `focus_parent` attribute to `lv_obj` diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 109f7eb2f..2a1874a9e 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -2449,7 +2449,7 @@ lv_style_int_t _lv_obj_get_style_int(const lv_obj_t * obj, uint8_t part, lv_styl lv_style_property_t prop_ori = prop; lv_style_attr_t attr; - attr.full = prop_ori >> 8; + attr = prop_ori >> 8; lv_style_int_t value_act; lv_res_t res = LV_RES_INV; @@ -2463,7 +2463,7 @@ lv_style_int_t _lv_obj_get_style_int(const lv_obj_t * obj, uint8_t part, lv_styl res = _lv_style_list_get_int(dsc, prop, &value_act); if(res == LV_RES_OK) return value_act; - if(attr.bits.inherit == 0) break; + if(LV_STYLE_ATTR_GET_INHERIT(attr) == 0) break; /*If not found, check the `MAIN` style first*/ if(part != LV_OBJ_PART_MAIN) { @@ -2512,7 +2512,7 @@ lv_color_t _lv_obj_get_style_color(const lv_obj_t * obj, uint8_t part, lv_style_ lv_style_property_t prop_ori = prop; lv_style_attr_t attr; - attr.full = prop_ori >> 8; + attr = prop_ori >> 8; lv_color_t value_act; lv_res_t res = LV_RES_INV; @@ -2526,7 +2526,7 @@ lv_color_t _lv_obj_get_style_color(const lv_obj_t * obj, uint8_t part, lv_style_ res = _lv_style_list_get_color(dsc, prop, &value_act); if(res == LV_RES_OK) return value_act; - if(attr.bits.inherit == 0) break; + if(LV_STYLE_ATTR_GET_INHERIT(attr) == 0) break; /*If not found, check the `MAIN` style first*/ if(part != LV_OBJ_PART_MAIN) { @@ -2568,7 +2568,7 @@ lv_opa_t _lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t part, lv_style_prop lv_style_property_t prop_ori = prop; lv_style_attr_t attr; - attr.full = prop_ori >> 8; + attr = prop_ori >> 8; lv_opa_t value_act; lv_res_t res = LV_RES_INV; @@ -2582,7 +2582,7 @@ lv_opa_t _lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t part, lv_style_prop res = _lv_style_list_get_opa(dsc, prop, &value_act); if(res == LV_RES_OK) return value_act; - if(attr.bits.inherit == 0) break; + if(LV_STYLE_ATTR_GET_INHERIT(attr) == 0) break; /*If not found, check the `MAIN` style first*/ if(part != LV_OBJ_PART_MAIN) { @@ -2625,7 +2625,7 @@ const void * _lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_ lv_style_property_t prop_ori = prop; lv_style_attr_t attr; - attr.full = prop_ori >> 8; + attr = prop_ori >> 8; const void * value_act; lv_res_t res = LV_RES_INV; @@ -2639,7 +2639,7 @@ const void * _lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_ res = _lv_style_list_get_ptr(dsc, prop, &value_act); if(res == LV_RES_OK) return value_act; - if(attr.bits.inherit == 0) break; + if(LV_STYLE_ATTR_GET_INHERIT(attr) == 0) break; /*If not found, check the `MAIN` style first*/ if(part != LV_OBJ_PART_MAIN) { @@ -4145,4 +4145,3 @@ static bool obj_valid_child(const lv_obj_t * parent, const lv_obj_t * obj_to_fin return false; } - diff --git a/src/lv_core/lv_style.c b/src/lv_core/lv_style.c index b07954f4d..8d4f10531 100644 --- a/src/lv_core/lv_style.c +++ b/src/lv_core/lv_style.c @@ -36,6 +36,12 @@ **********************/ LV_ATTRIBUTE_FAST_MEM static inline int32_t get_property_index(const lv_style_t * style, lv_style_property_t prop); static lv_style_t * get_alloc_local_style(lv_style_list_t * list); +static inline void style_resize(lv_style_t *style, size_t sz); +static inline lv_style_property_t get_style_prop(const lv_style_t *style, size_t idx); +static inline uint8_t get_style_prop_id(const lv_style_t *style, size_t idx); +static inline uint8_t get_style_prop_attr(const lv_style_t *style, size_t idx); +static inline size_t get_prop_size(uint8_t prop_id); +static inline size_t get_next_prop_index(uint8_t prop_id, size_t id); /********************** * GLOABAL VARIABLES @@ -102,16 +108,12 @@ bool lv_style_remove_prop(lv_style_t * style, lv_style_property_t prop) lv_style_attr_t attr_found; lv_style_attr_t attr_goal; - attr_found.full = *(style->map + id + 1); - attr_goal.full = (prop >> 8) & 0xFFU; + attr_found = get_style_prop_attr(style, id); + attr_goal = (prop >> 8) & 0xFFU; - if(attr_found.bits.state == attr_goal.bits.state) { + if(LV_STYLE_ATTR_GET_STATE(attr_found) == LV_STYLE_ATTR_GET_STATE(attr_goal)) { uint32_t map_size = _lv_style_get_mem_size(style); - uint8_t prop_size = sizeof(lv_style_property_t); - if((prop & 0xF) < LV_STYLE_ID_COLOR) prop_size += sizeof(lv_style_int_t); - else if((prop & 0xF) < LV_STYLE_ID_OPA) prop_size += sizeof(lv_color_t); - else if((prop & 0xF) < LV_STYLE_ID_PTR) prop_size += sizeof(lv_opa_t); - else prop_size += sizeof(const void *); + uint8_t prop_size = get_prop_size(prop); /*Move the props to fill the space of the property to delete*/ uint32_t i; @@ -119,7 +121,7 @@ bool lv_style_remove_prop(lv_style_t * style, lv_style_property_t prop) style->map[i] = style->map[i + prop_size]; } - style->map = lv_mem_realloc(style->map, map_size - prop_size); + style_resize(style, map_size - prop_size); return true; } @@ -335,14 +337,9 @@ uint16_t _lv_style_get_mem_size(const lv_style_t * style) if(style->map == NULL) return 0; size_t i = 0; - while(style->map[i] != _LV_STYLE_CLOSEING_PROP) { - /*Go to the next property*/ - if((style->map[i] & 0xF) < LV_STYLE_ID_COLOR) i += sizeof(lv_style_int_t); - else if((style->map[i] & 0xF) < LV_STYLE_ID_OPA) i += sizeof(lv_color_t); - else if((style->map[i] & 0xF) < LV_STYLE_ID_PTR) i += sizeof(lv_opa_t); - else i += sizeof(const void *); - - i += sizeof(lv_style_property_t); + uint8_t prop_id; + while((prop_id = get_style_prop_id(style, i)) != _LV_STYLE_CLOSEING_PROP) { + i = get_next_prop_index(prop_id, i); } return i + sizeof(lv_style_property_t); @@ -368,10 +365,10 @@ void _lv_style_set_int(lv_style_t * style, lv_style_property_t prop, lv_style_in lv_style_attr_t attr_found; lv_style_attr_t attr_goal; - attr_found.full = *(style->map + id + 1); - attr_goal.full = (prop >> 8) & 0xFFU; + attr_found = get_style_prop_attr(style, id); + attr_goal = (prop >> 8) & 0xFFU; - if(attr_found.bits.state == attr_goal.bits.state) { + if(LV_STYLE_ATTR_GET_STATE(attr_found) == LV_STYLE_ATTR_GET_STATE(attr_goal)) { _lv_memcpy_small(style->map + id + sizeof(lv_style_property_t), &value, sizeof(lv_style_int_t)); return; } @@ -385,7 +382,7 @@ void _lv_style_set_int(lv_style_t * style, lv_style_property_t prop, lv_style_in uint16_t size = _lv_style_get_mem_size(style); if(size == 0) size += end_mark_size; size += sizeof(lv_style_property_t) + sizeof(lv_style_int_t); - style->map = lv_mem_realloc(style->map, size); + style_resize(style, size); LV_ASSERT_MEM(style->map); if(style == NULL) return; @@ -414,10 +411,10 @@ void _lv_style_set_color(lv_style_t * style, lv_style_property_t prop, lv_color_ lv_style_attr_t attr_found; lv_style_attr_t attr_goal; - attr_found.full = *(style->map + id + 1); - attr_goal.full = (prop >> 8) & 0xFFU; + attr_found = get_style_prop_attr(style, id); + attr_goal = (prop >> 8) & 0xFFU; - if(attr_found.bits.state == attr_goal.bits.state) { + if(LV_STYLE_ATTR_GET_STATE(attr_found) == LV_STYLE_ATTR_GET_STATE(attr_goal)) { _lv_memcpy_small(style->map + id + sizeof(lv_style_property_t), &color, sizeof(lv_color_t)); return; } @@ -432,7 +429,7 @@ void _lv_style_set_color(lv_style_t * style, lv_style_property_t prop, lv_color_ if(size == 0) size += end_mark_size; size += sizeof(lv_style_property_t) + sizeof(lv_color_t); - style->map = lv_mem_realloc(style->map, size); + style_resize(style, size); LV_ASSERT_MEM(style->map); if(style == NULL) return; @@ -461,10 +458,10 @@ void _lv_style_set_opa(lv_style_t * style, lv_style_property_t prop, lv_opa_t op lv_style_attr_t attr_found; lv_style_attr_t attr_goal; - attr_found.full = *(style->map + id + 1); - attr_goal.full = (prop >> 8) & 0xFFU; + attr_found = get_style_prop_attr(style, id); + attr_goal = (prop >> 8) & 0xFFU; - if(attr_found.bits.state == attr_goal.bits.state) { + if(LV_STYLE_ATTR_GET_STATE(attr_found) == LV_STYLE_ATTR_GET_STATE(attr_goal)) { _lv_memcpy_small(style->map + id + sizeof(lv_style_property_t), &opa, sizeof(lv_opa_t)); return; } @@ -479,7 +476,7 @@ void _lv_style_set_opa(lv_style_t * style, lv_style_property_t prop, lv_opa_t op if(size == 0) size += end_mark_size; size += sizeof(lv_style_property_t) + sizeof(lv_opa_t); - style->map = lv_mem_realloc(style->map, size); + style_resize(style, size); LV_ASSERT_MEM(style->map); if(style == NULL) return; @@ -508,10 +505,10 @@ void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, const void lv_style_attr_t attr_found; lv_style_attr_t attr_goal; - attr_found.full = *(style->map + id + 1); - attr_goal.full = (prop >> 8) & 0xFFU; + attr_found = get_style_prop_attr(style, id); + attr_goal = (prop >> 8) & 0xFFU; - if(attr_found.bits.state == attr_goal.bits.state) { + if(LV_STYLE_ATTR_GET_STATE(attr_found) == LV_STYLE_ATTR_GET_STATE(attr_goal)) { _lv_memcpy_small(style->map + id + sizeof(lv_style_property_t), &p, sizeof(const void *)); return; } @@ -526,7 +523,7 @@ void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, const void if(size == 0) size += end_mark_size; size += sizeof(lv_style_property_t) + sizeof(const void *); - style->map = lv_mem_realloc(style->map, size); + style_resize(style, size); LV_ASSERT_MEM(style->map); if(style == NULL) return; @@ -560,12 +557,12 @@ int16_t _lv_style_get_int(const lv_style_t * style, lv_style_property_t prop, vo else { _lv_memcpy_small(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_style_int_t)); lv_style_attr_t attr_act; - attr_act.full = style->map[id + 1]; + attr_act = get_style_prop_attr(style, id + 1); lv_style_attr_t attr_goal; - attr_goal.full = (prop >> 8) & 0xFF; + attr_goal = (prop >> 8) & 0xFF; - return attr_act.bits.state & attr_goal.bits.state; + return LV_STYLE_ATTR_GET_STATE(attr_act) & LV_STYLE_ATTR_GET_STATE(attr_goal); } } @@ -597,12 +594,12 @@ int16_t _lv_style_get_opa(const lv_style_t * style, lv_style_property_t prop, vo else { _lv_memcpy_small(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_opa_t)); lv_style_attr_t attr_act; - attr_act.full = style->map[id + 1]; + attr_act = get_style_prop_attr(style, id); lv_style_attr_t attr_goal; - attr_goal.full = (prop >> 8) & 0xFF; + attr_goal = (prop >> 8) & 0xFF; - return attr_act.bits.state & attr_goal.bits.state; + return LV_STYLE_ATTR_GET_STATE(attr_act) & LV_STYLE_ATTR_GET_STATE(attr_goal); } } @@ -631,12 +628,12 @@ int16_t _lv_style_get_color(const lv_style_t * style, lv_style_property_t prop, else { _lv_memcpy_small(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_color_t)); lv_style_attr_t attr_act; - attr_act.full = style->map[id + 1]; + attr_act = get_style_prop_attr(style, id); lv_style_attr_t attr_goal; - attr_goal.full = (prop >> 8) & 0xFF; + attr_goal = (prop >> 8) & 0xFF; - return attr_act.bits.state & attr_goal.bits.state; + return LV_STYLE_ATTR_GET_STATE(attr_act) & LV_STYLE_ATTR_GET_STATE(attr_goal); } } @@ -666,12 +663,12 @@ int16_t _lv_style_get_ptr(const lv_style_t * style, lv_style_property_t prop, vo else { _lv_memcpy_small(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(const void *)); lv_style_attr_t attr_act; - attr_act.full = style->map[id + 1]; + attr_act = get_style_prop_attr(style, id); lv_style_attr_t attr_goal; - attr_goal.full = (prop >> 8) & 0xFF; + attr_goal = (prop >> 8) & 0xFF; - return attr_act.bits.state & attr_goal.bits.state; + return LV_STYLE_ATTR_GET_STATE(attr_act) & LV_STYLE_ATTR_GET_STATE(attr_goal); } } @@ -819,8 +816,8 @@ lv_res_t _lv_style_list_get_int(lv_style_list_t * list, lv_style_property_t prop if(list->style_list == NULL) return LV_RES_INV; lv_style_attr_t attr; - attr.full = prop >> 8; - int16_t weight_goal = attr.full; + attr = prop >> 8; + int16_t weight_goal = attr; int16_t weight = -1; @@ -871,8 +868,8 @@ lv_res_t _lv_style_list_get_color(lv_style_list_t * list, lv_style_property_t pr if(list->style_list == NULL) return LV_RES_INV; lv_style_attr_t attr; - attr.full = prop >> 8; - int16_t weight_goal = attr.full; + attr = prop >> 8; + int16_t weight_goal = attr; int16_t weight = -1; @@ -921,8 +918,8 @@ lv_res_t _lv_style_list_get_opa(lv_style_list_t * list, lv_style_property_t prop if(list->style_list == NULL) return LV_RES_INV; lv_style_attr_t attr; - attr.full = prop >> 8; - int16_t weight_goal = attr.full; + attr = prop >> 8; + int16_t weight_goal = attr; int16_t weight = -1; @@ -971,8 +968,8 @@ lv_res_t _lv_style_list_get_ptr(lv_style_list_t * list, lv_style_property_t prop if(list->style_list == NULL) return LV_RES_INV; lv_style_attr_t attr; - attr.full = prop >> 8; - int16_t weight_goal = attr.full; + attr = prop >> 8; + int16_t weight_goal = attr; int16_t weight = -1; @@ -1061,40 +1058,36 @@ LV_ATTRIBUTE_FAST_MEM static inline int32_t get_property_index(const lv_style_t uint8_t id_to_find = prop & 0xFF; lv_style_attr_t attr; - attr.full = (prop >> 8) & 0xFF; + attr = (prop >> 8) & 0xFF; int16_t weight = -1; int16_t id_guess = -1; size_t i = 0; - while(style->map[i] != _LV_STYLE_CLOSEING_PROP) { - if(style->map[i] == id_to_find) { + + uint8_t prop_id; + while((prop_id = get_style_prop_id(style, i)) != _LV_STYLE_CLOSEING_PROP) { + if(prop_id == id_to_find) { lv_style_attr_t attr_i; - attr_i.full = style->map[i + 1]; + attr_i = get_style_prop_attr(style, i); /*If the state perfectly matches return this property*/ - if(attr_i.bits.state == attr.bits.state) { + if(LV_STYLE_ATTR_GET_STATE(attr_i) == LV_STYLE_ATTR_GET_STATE(attr)) { return i; } /* Be sure the property not specifies other state than the requested. * E.g. For HOVER+PRESS, HOVER only is OK, but HOVER+FOCUS not*/ - else if((attr_i.bits.state & (~attr.bits.state)) == 0) { + else if((LV_STYLE_ATTR_GET_STATE(attr_i) & (~LV_STYLE_ATTR_GET_STATE(attr))) == 0) { /* Use this property if it describes better the requested state than the current candidate. * E.g. for HOVER+FOCUS+PRESS prefer HOVER+FOCUS over FOCUS*/ - if(attr_i.bits.state > weight) { - weight = attr_i.bits.state; + if(LV_STYLE_ATTR_GET_STATE(attr_i) > weight) { + weight = LV_STYLE_ATTR_GET_STATE(attr_i); id_guess = i; } } } - /*Go to the next property*/ - if((style->map[i] & 0xF) < LV_STYLE_ID_COLOR) i += sizeof(lv_style_int_t); - else if((style->map[i] & 0xF) < LV_STYLE_ID_OPA) i += sizeof(lv_color_t); - else if((style->map[i] & 0xF) < LV_STYLE_ID_PTR) i += sizeof(lv_opa_t); - else i += sizeof(const void *); - - i += sizeof(lv_style_property_t); + i = get_next_prop_index(prop_id, i); } return id_guess; @@ -1125,3 +1118,79 @@ static lv_style_t * get_alloc_local_style(lv_style_list_t * list) return local_style; } + +/** + * Resizes a style map. Useful entry point for debugging. + * @param style pointer to the style to be resized. + * @param size new size + */ +static inline void style_resize(lv_style_t *style, size_t sz) +{ + style->map = lv_mem_realloc(style->map, sz); +} + +/** + * Get style property in index. + * @param style pointer to style. + * @param idx index of the style in style->map + * @return property in style->map + idx + */ +static inline lv_style_property_t get_style_prop(const lv_style_t *style, size_t idx) +{ + lv_style_property_t prop; + uint8_t *prop_p = (uint8_t*)∝ + prop_p[0] = style->map[idx]; + prop_p[1] = style->map[idx + 1]; + return prop; +} + +/** + * Get style property id in index. + * @param style pointer to style. + * @param idx index of the style in style->map + * @return id of property in style->map + idx + */ +static inline uint8_t get_style_prop_id(const lv_style_t *style, size_t idx) +{ + return get_style_prop(style, idx) & 0xFF; +} + +/** + * Get style property attributes for index. + * @param style pointer to style. + * @param idx index of the style in style->map + * @return attribute of property in style->map + idx + */ +static inline uint8_t get_style_prop_attr(const lv_style_t *style, size_t idx) +{ + return ((get_style_prop(style, idx) >> 8) & 0xFFU); +} + + +/** + * Get property size. + * @param prop_id property id. + * @param idx index of the style in style->map + * @return attribute of property in style->map + idx + */ +static inline size_t get_prop_size(uint8_t prop_id) +{ + prop_id &= 0xF; + size_t size = sizeof(lv_style_property_t); + if(prop_id < LV_STYLE_ID_COLOR) size += sizeof(lv_style_int_t); + else if(prop_id < LV_STYLE_ID_OPA) size += sizeof(lv_color_t); + else if(prop_id < LV_STYLE_ID_PTR) size += sizeof(lv_opa_t); + else size += sizeof(const void *); + return size; +} + +/** + * Get next property index, given current property and index. + * @param prop_id property id. + * @param idx index of the style in style->map + * @return index of next property in style->map + */ +static inline size_t get_next_prop_index(uint8_t prop_id, size_t idx) +{ + return idx + get_prop_size(prop_id); +} diff --git a/src/lv_core/lv_style.h b/src/lv_core/lv_style.h index c17ee5ff8..aff4759e3 100644 --- a/src/lv_core/lv_style.h +++ b/src/lv_core/lv_style.h @@ -81,13 +81,10 @@ enum { typedef uint8_t lv_text_decor_t; -typedef union { - struct { - uint8_t state : 7; /* To which state the property refers to*/ - uint8_t inherit : 1; /*1: The property can be inherited*/ - } bits; - uint8_t full; -} lv_style_attr_t; +typedef uint8_t lv_style_attr_t; + +#define LV_STYLE_ATTR_GET_INHERIT(f) ((f)&0xA0) +#define LV_STYLE_ATTR_GET_STATE(f) ((f)&0x3F) #define LV_STYLE_ID_VALUE 0x0 /*max 9 pcs*/ #define LV_STYLE_ID_COLOR 0x9 /*max 3 pcs*/ diff --git a/src/lv_font/lv_font_fmt_txt.c b/src/lv_font/lv_font_fmt_txt.c index fe8e55793..731ada0e6 100644 --- a/src/lv_font/lv_font_fmt_txt.c +++ b/src/lv_font/lv_font_fmt_txt.c @@ -214,7 +214,8 @@ static uint32_t get_glyph_dsc_id(const lv_font_t * font, uint32_t letter) glyph_id = fdsc->cmaps[i].glyph_id_start + gid_ofs_8[rcp]; } else if(fdsc->cmaps[i].type == LV_FONT_FMT_TXT_CMAP_SPARSE_TINY) { - uint8_t * p = _lv_utils_bsearch(&rcp, fdsc->cmaps[i].unicode_list, fdsc->cmaps[i].list_length, + uint16_t key = rcp; + uint8_t * p = _lv_utils_bsearch(&key, fdsc->cmaps[i].unicode_list, fdsc->cmaps[i].list_length, sizeof(fdsc->cmaps[i].unicode_list[0]), unicode_list_compare); if(p) { @@ -224,7 +225,8 @@ static uint32_t get_glyph_dsc_id(const lv_font_t * font, uint32_t letter) } } else if(fdsc->cmaps[i].type == LV_FONT_FMT_TXT_CMAP_SPARSE_FULL) { - uint8_t * p = _lv_utils_bsearch(&rcp, fdsc->cmaps[i].unicode_list, fdsc->cmaps[i].list_length, + uint16_t key = rcp; + uint8_t * p = _lv_utils_bsearch(&key, fdsc->cmaps[i].unicode_list, fdsc->cmaps[i].list_length, sizeof(fdsc->cmaps[i].unicode_list[0]), unicode_list_compare); if(p) { From 8864cd87ee30201915fe0672e0ab91106128efa9 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 24 Jun 2020 10:02:45 +0200 Subject: [PATCH 026/205] lv_img: fix invalidation area when angle or zoom changes --- CHANGELOG.md | 3 ++- src/lv_widgets/lv_img.c | 10 ++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5ff0aaa6..21b5dd2e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,10 +13,11 @@ - In `lv_init` test if the the strings are UTF-8 encoded. ### Bugfixes -- None +- `lv_img` fix invalidation area when angle or zoom changes ## v7.0.2 (16.06.2020) +### Bugfixes - `lv_textarea` fix wrong cursor position when clicked after the last character - Change all text related indices from 16-bit to 32-bit integers throughout whole library. #1545 - Fix gestures diff --git a/src/lv_widgets/lv_img.c b/src/lv_widgets/lv_img.c index 08e7c2321..3acb7cab3 100644 --- a/src/lv_widgets/lv_img.c +++ b/src/lv_widgets/lv_img.c @@ -340,10 +340,9 @@ void lv_img_set_angle(lv_obj_t * img, int16_t angle) transf_zoom = (transf_zoom * ext->zoom) >> 8; lv_style_int_t transf_angle = lv_obj_get_style_transform_angle(img, LV_IMG_PART_MAIN); - transf_angle += ext->angle; lv_area_t a; - _lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle, transf_zoom, &ext->pivot); + _lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle + ext->angle, transf_zoom, &ext->pivot); a.x1 += img->coords.x1; a.y1 += img->coords.y1; a.x2 += img->coords.x1; @@ -353,7 +352,7 @@ void lv_img_set_angle(lv_obj_t * img, int16_t angle) ext->angle = angle; lv_obj_refresh_ext_draw_pad(img); - _lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle, transf_zoom, &ext->pivot); + _lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle + ext->angle, transf_zoom, &ext->pivot); a.x1 += img->coords.x1; a.y1 += img->coords.y1; a.x2 += img->coords.x1; @@ -379,13 +378,12 @@ void lv_img_set_zoom(lv_obj_t * img, uint16_t zoom) if(zoom == 0) zoom = 1; lv_style_int_t transf_zoom = lv_obj_get_style_transform_zoom(img, LV_IMG_PART_MAIN); - transf_zoom = (transf_zoom * ext->zoom) >> 8; lv_style_int_t transf_angle = lv_obj_get_style_transform_angle(img, LV_IMG_PART_MAIN); transf_angle += ext->angle; lv_area_t a; - _lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle, transf_zoom, &ext->pivot); + _lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle, (transf_zoom * ext->zoom) >> 8, &ext->pivot); a.x1 += img->coords.x1; a.y1 += img->coords.y1; a.x2 += img->coords.x1; @@ -395,7 +393,7 @@ void lv_img_set_zoom(lv_obj_t * img, uint16_t zoom) ext->zoom = zoom; lv_obj_refresh_ext_draw_pad(img); - _lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle, transf_zoom, &ext->pivot); + _lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle, (transf_zoom * ext->zoom) >> 8, &ext->pivot); a.x1 += img->coords.x1; a.y1 += img->coords.y1; a.x2 += img->coords.x1; From 4c629ec23fe9660956757565c8c1ab2646f86971 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 24 Jun 2020 10:04:30 +0200 Subject: [PATCH 027/205] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21b5dd2e8..a74983ffd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ ### Bugfixes - `lv_img` fix invalidation area when angle or zoom changes +- Update the style handling to support Big endian MCUs ## v7.0.2 (16.06.2020) From 9561aa767d63f8fe5fdbee9d12571569a94038fd Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 24 Jun 2020 10:45:32 +0200 Subject: [PATCH 028/205] style: minor fix on getting style attributes + formatting --- src/lv_core/lv_style.c | 2 +- src/lv_core/lv_style.h | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lv_core/lv_style.c b/src/lv_core/lv_style.c index 8d4f10531..1be4e3dbe 100644 --- a/src/lv_core/lv_style.c +++ b/src/lv_core/lv_style.c @@ -557,7 +557,7 @@ int16_t _lv_style_get_int(const lv_style_t * style, lv_style_property_t prop, vo else { _lv_memcpy_small(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_style_int_t)); lv_style_attr_t attr_act; - attr_act = get_style_prop_attr(style, id + 1); + attr_act = get_style_prop_attr(style, id); lv_style_attr_t attr_goal; attr_goal = (prop >> 8) & 0xFF; diff --git a/src/lv_core/lv_style.h b/src/lv_core/lv_style.h index aff4759e3..5909299b6 100644 --- a/src/lv_core/lv_style.h +++ b/src/lv_core/lv_style.h @@ -83,8 +83,8 @@ typedef uint8_t lv_text_decor_t; typedef uint8_t lv_style_attr_t; -#define LV_STYLE_ATTR_GET_INHERIT(f) ((f)&0xA0) -#define LV_STYLE_ATTR_GET_STATE(f) ((f)&0x3F) +#define LV_STYLE_ATTR_GET_INHERIT(f) ((f)&0x80) +#define LV_STYLE_ATTR_GET_STATE(f) ((f)&0x7F) #define LV_STYLE_ID_VALUE 0x0 /*max 9 pcs*/ #define LV_STYLE_ID_COLOR 0x9 /*max 3 pcs*/ @@ -99,7 +99,7 @@ enum { LV_STYLE_PROP_INIT(LV_STYLE_TRANSFORM_WIDTH, 0x0, LV_STYLE_ID_VALUE + 4, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_TRANSFORM_HEIGHT, 0x0, LV_STYLE_ID_VALUE + 5, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_TRANSFORM_ANGLE, 0x0, LV_STYLE_ID_VALUE + 6, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_TRANSFORM_ZOOM, 0x0, LV_STYLE_ID_VALUE + 7, LV_STYLE_ATTR_NONE), + LV_STYLE_PROP_INIT(LV_STYLE_TRANSFORM_ZOOM, 0x0, LV_STYLE_ID_VALUE + 7, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_OPA_SCALE, 0x0, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_INHERIT), LV_STYLE_PROP_INIT(LV_STYLE_PAD_TOP, 0x1, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE), @@ -134,8 +134,8 @@ enum { LV_STYLE_PROP_INIT(LV_STYLE_OUTLINE_OPA, 0x4, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_WIDTH, 0x5, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_OFS_X, 0x5, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_OFS_Y, 0x5, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE), + LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_OFS_X, 0x5, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE), + LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_OFS_Y, 0x5, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_SPREAD, 0x5, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_BLEND_MODE, 0x5, LV_STYLE_ID_VALUE + 4, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_COLOR, 0x5, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE), @@ -191,12 +191,12 @@ enum { LV_STYLE_PROP_INIT(LV_STYLE_TRANSITION_PROP_6, 0xB, LV_STYLE_ID_VALUE + 7, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_TRANSITION_PATH, 0xB, LV_STYLE_ID_PTR + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SCALE_WIDTH, 0xC, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE), + LV_STYLE_PROP_INIT(LV_STYLE_SCALE_WIDTH, 0xC, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_SCALE_BORDER_WIDTH, 0xC, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_BORDER_WIDTH, 0xC, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_LINE_WIDTH, 0xC, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SCALE_GRAD_COLOR, 0xC, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_COLOR, 0xC, LV_STYLE_ID_COLOR + 1, LV_STYLE_ATTR_NONE), + LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_LINE_WIDTH, 0xC, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE), + LV_STYLE_PROP_INIT(LV_STYLE_SCALE_GRAD_COLOR, 0xC, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE), + LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_COLOR, 0xC, LV_STYLE_ID_COLOR + 1, LV_STYLE_ATTR_NONE), }; typedef uint16_t lv_style_property_t; From be19e91e91649af2552fabd156173d6f10062964 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 24 Jun 2020 11:24:07 +0200 Subject: [PATCH 029/205] fix focusing/defocusing for pages --- src/lv_core/lv_indev.c | 13 +++++++------ src/lv_core/lv_obj.c | 2 -- src/lv_widgets/lv_page.c | 14 ++++++++++---- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/lv_core/lv_indev.c b/src/lv_core/lv_indev.c index cc2c608b6..a491c0996 100644 --- a/src/lv_core/lv_indev.c +++ b/src/lv_core/lv_indev.c @@ -1183,11 +1183,6 @@ static void indev_click_focus(lv_indev_proc_t * proc) } /*The object are not in the same group (in different group or one in not a group)*/ else { - /*Focus to the act. its group*/ - if(g_act) { - lv_group_focus_obj(indev_obj_act); - if(indev_reset_check(proc)) return; - } /*If the prev. obj. is not in a group then defocus it.*/ if(g_prev == NULL && proc->types.pointer.last_pressed) { lv_signal_send(proc->types.pointer.last_pressed, LV_SIGNAL_DEFOCUS, NULL); @@ -1213,12 +1208,18 @@ static void indev_click_focus(lv_indev_proc_t * proc) if(indev_reset_check(proc)) return; } } + } + /*Focus to the act. in its group*/ + if(g_act) { + lv_group_focus_obj(indev_obj_act); + if(indev_reset_check(proc)) return; + } else { lv_signal_send(indev_obj_act, LV_SIGNAL_FOCUS, NULL); if(indev_reset_check(proc)) return; lv_event_send(indev_obj_act, LV_EVENT_FOCUSED, NULL); if(indev_reset_check(proc)) return; - } + } } #else if(proc->types.pointer.last_pressed) { diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 2a1874a9e..8c4276e94 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -3752,7 +3752,6 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param) else if(sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST) { lv_obj_clear_state(obj, LV_STATE_PRESSED); } -#if LV_USE_GROUP else if(sign == LV_SIGNAL_FOCUS) { if(lv_group_get_editing(lv_obj_get_group(obj))) { uint8_t state = LV_STATE_FOCUSED; @@ -3779,7 +3778,6 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param) lv_obj_clear_state(obj, LV_STATE_FOCUSED | LV_STATE_EDITED); } -#endif else if(sign == LV_SIGNAL_CLEANUP) { lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN); } diff --git a/src/lv_widgets/lv_page.c b/src/lv_widgets/lv_page.c index 31a1fef13..f8141c320 100644 --- a/src/lv_widgets/lv_page.c +++ b/src/lv_widgets/lv_page.c @@ -1054,10 +1054,16 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi } } else if(sign == LV_SIGNAL_DEFOCUS) { - res = lv_signal_send(page, LV_SIGNAL_DEFOCUS, NULL); - if(res != LV_RES_OK) return res; - res = lv_event_send(page, LV_EVENT_DEFOCUSED, NULL); - if(res != LV_RES_OK) return res; + bool in_group = false; +#if LV_USE_GROUP + in_group = lv_obj_get_group(page) ? true : false; +#endif + if(in_group == false) { + res = lv_signal_send(page, LV_SIGNAL_DEFOCUS, NULL); + if(res != LV_RES_OK) return res; + res = lv_event_send(page, LV_EVENT_DEFOCUSED, NULL); + if(res != LV_RES_OK) return res; + } } else if(sign == LV_SIGNAL_CLEANUP) { page_ext->scrl = NULL; From 42f79763e156a0e0e341db05cfd25e85817df688 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 24 Jun 2020 11:28:51 +0200 Subject: [PATCH 030/205] fix build error --- src/lv_core/lv_obj.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 8c4276e94..8e935b3b2 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -3753,7 +3753,11 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param) lv_obj_clear_state(obj, LV_STATE_PRESSED); } else if(sign == LV_SIGNAL_FOCUS) { - if(lv_group_get_editing(lv_obj_get_group(obj))) { + bool editing = false; +#if LV_USE_GROUP + editing = lv_group_get_editing(lv_obj_get_group(obj)); +#endif + if(editing) { uint8_t state = LV_STATE_FOCUSED; state |= LV_STATE_EDITED; From 63aba1b3de0fa233b09e80d465665c219d82d0ae Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 24 Jun 2020 11:36:35 +0200 Subject: [PATCH 031/205] lv_textarea fix cursor alignment with empty textarea when the text alignment is center or right --- src/lv_widgets/lv_label.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/lv_widgets/lv_label.c b/src/lv_widgets/lv_label.c index 1a71a37de..da8b6d308 100644 --- a/src/lv_widgets/lv_label.c +++ b/src/lv_widgets/lv_label.c @@ -572,10 +572,21 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint32_t char_id, lv_point_ LV_ASSERT_NULL(pos); const char * txt = lv_label_get_text(label); + lv_label_align_t align = lv_label_get_align(label); if(txt[0] == '\0') { - pos->x = 0; pos->y = 0; + switch(align) { + case LV_LABEL_ALIGN_LEFT: + pos->x = 0; + break; + case LV_LABEL_ALIGN_RIGHT: + pos->x = lv_obj_get_width(label); + break; + case LV_LABEL_ALIGN_CENTER: + pos->x = lv_obj_get_width(label) / 2; + break; + } return; } @@ -597,7 +608,6 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint32_t char_id, lv_point_ if(ext->expand != 0) flag |= LV_TXT_FLAG_EXPAND; if(ext->long_mode == LV_LABEL_LONG_EXPAND) flag |= LV_TXT_FLAG_FIT; - lv_label_align_t align = lv_label_get_align(label); if(align == LV_LABEL_ALIGN_CENTER) flag |= LV_TXT_FLAG_CENTER; if(align == LV_LABEL_ALIGN_RIGHT) flag |= LV_TXT_FLAG_RIGHT; From 2550368d30fba4f7ce1d934468d413741625d484 Mon Sep 17 00:00:00 2001 From: jbamaral Date: Tue, 23 Jun 2020 19:16:36 -0300 Subject: [PATCH 032/205] fix image demos on big endian systems --- CHANGELOG.md | 1 + lv_conf_template.h | 4 ++++ src/lv_draw/lv_img_buf.h | 22 +++++++++++++++++++--- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a74983ffd..783475036 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## v7.1.0 (planned on 07.07.2020) *Available in the `master` branch* - Change some lv_style_t methods to support big endian hardware. +- Add LV_BIG_ENDIAN_SYSTEM flag to lv_conf.h in order to fix displaying images on big endian systems. ### New features - Add `focus_parent` attribute to `lv_obj` diff --git a/lv_conf_template.h b/lv_conf_template.h index de2287cf4..f4cd80800 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -222,6 +222,10 @@ typedef void * lv_img_decoder_user_data_t; /*===================== * Compiler settings *====================*/ + +/* For big endian systems set to 1 */ +#define LV_BIG_ENDIAN_SYSTEM 0 + /* Define a custom attribute to `lv_tick_inc` function */ #define LV_ATTRIBUTE_TICK_INC diff --git a/src/lv_draw/lv_img_buf.h b/src/lv_draw/lv_img_buf.h index a8722cf42..4b6db2b87 100644 --- a/src/lv_draw/lv_img_buf.h +++ b/src/lv_draw/lv_img_buf.h @@ -102,10 +102,26 @@ typedef uint8_t lv_img_cf_t; /** * LVGL image header */ +/* The first 8 bit is very important to distinguish the different source types. + * For more info see `lv_img_get_src_type()` in lv_img.c + * On big endian systems the order is reversed so cf and always_zero must be at + * the end of the struct. + * */ +#if LV_BIG_ENDIAN_SYSTEM +typedef struct { + + uint32_t h : 11; /*Height of the image map*/ + uint32_t w : 11; /*Width of the image map*/ + uint32_t reserved : 2; /*Reserved to be used later*/ + uint32_t always_zero : 3; /*It the upper bits of the first byte. Always zero to look like a + non-printable character*/ + uint32_t cf : 5; /* Color format: See `lv_img_color_format_t`*/ + + +} lv_img_header_t; +#else typedef struct { - /* The first 8 bit is very important to distinguish the different source types. - * For more info see `lv_img_get_src_type()` in lv_img.c */ uint32_t cf : 5; /* Color format: See `lv_img_color_format_t`*/ uint32_t always_zero : 3; /*It the upper bits of the first byte. Always zero to look like a non-printable character*/ @@ -115,7 +131,7 @@ typedef struct { uint32_t w : 11; /*Width of the image map*/ uint32_t h : 11; /*Height of the image map*/ } lv_img_header_t; - +#endif /** Image header it is compatible with * the result from image converter utility*/ From 5f6c7743adc2b3204cadf66f0ccc097c4555efd1 Mon Sep 17 00:00:00 2001 From: jbamaral Date: Wed, 24 Jun 2020 08:38:44 -0300 Subject: [PATCH 033/205] update internal configuration --- src/lv_conf_internal.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index da8f7d8d1..70feabb8d 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -266,6 +266,11 @@ #ifndef LV_USE_GPU_STM32_DMA2D #define LV_USE_GPU_STM32_DMA2D 0 #endif +/*If enabling LV_USE_GPU_STM32_DMA2D, LV_GPU_DMA2D_CMSIS_INCLUDE must be defined to include path of CMSIS header of target processor +e.g. "stm32f769xx.h" or "stm32f429xx.h" */ +#ifndef LV_GPU_DMA2D_CMSIS_INCLUDE +#define LV_GPU_DMA2D_CMSIS_INCLUDE +#endif /* 1: Enable file system (might be required for images */ #ifndef LV_USE_FILESYSTEM @@ -319,6 +324,12 @@ /*===================== * Compiler settings *====================*/ + +/* For big endian systems set to 1 */ +#ifndef LV_BIG_ENDIAN_SYSTEM +#define LV_BIG_ENDIAN_SYSTEM 0 +#endif + /* Define a custom attribute to `lv_tick_inc` function */ #ifndef LV_ATTRIBUTE_TICK_INC #define LV_ATTRIBUTE_TICK_INC @@ -474,7 +485,7 @@ /* The built-in fonts contains the ASCII range and some Symbols with 4 bit-per-pixel. * The symbols are available via `LV_SYMBOL_...` defines - * More info about fonts: https://docs.lvgl.com/#Fonts + * More info about fonts: https://docs.lvgl.io/v7/en/html/overview/font.html * To create a new font go to: https://lvgl.com/ttf-font-to-c-array */ @@ -684,14 +695,14 @@ #define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 3 #endif -/* The control character to use for signaling text recoloring. */ +/* The control character to use for signalling text recoloring. */ #ifndef LV_TXT_COLOR_CMD #define LV_TXT_COLOR_CMD "#" #endif /* Support bidirectional texts. * Allows mixing Left-to-Right and Right-to-Left texts. - * The direction will be processed according to the Unicode Bidirectional Algorithm: + * The direction will be processed according to the Unicode Bidirectioanl Algorithm: * https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/ #ifndef LV_USE_BIDI #define LV_USE_BIDI 0 From 1733508e9a03b1140fa3527dd611b2687ee6f004 Mon Sep 17 00:00:00 2001 From: jbamaral Date: Wed, 24 Jun 2020 10:01:42 -0300 Subject: [PATCH 034/205] move bug logs to their right position in changelog --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 783475036..6bc4dda0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,6 @@ ## v7.1.0 (planned on 07.07.2020) *Available in the `master` branch* -- Change some lv_style_t methods to support big endian hardware. -- Add LV_BIG_ENDIAN_SYSTEM flag to lv_conf.h in order to fix displaying images on big endian systems. ### New features - Add `focus_parent` attribute to `lv_obj` @@ -16,6 +14,8 @@ ### Bugfixes - `lv_img` fix invalidation area when angle or zoom changes - Update the style handling to support Big endian MCUs +- Change some methods to support big endian hardware. +- Add LV_BIG_ENDIAN_SYSTEM flag to lv_conf.h in order to fix displaying images on big endian systems. ## v7.0.2 (16.06.2020) From b77d484a2773d072922acce611c8307740cac14b Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Wed, 24 Jun 2020 12:25:16 -0400 Subject: [PATCH 035/205] Fix #1610: don't assert an expected null pointer --- src/lv_widgets/lv_list.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lv_widgets/lv_list.c b/src/lv_widgets/lv_list.c index afcafecbb..d7b502db1 100644 --- a/src/lv_widgets/lv_list.c +++ b/src/lv_widgets/lv_list.c @@ -462,7 +462,6 @@ lv_obj_t * lv_list_get_next_btn(const lv_obj_t * list, lv_obj_t * prev_btn) */ int32_t lv_list_get_btn_index(const lv_obj_t * list, const lv_obj_t * btn) { - LV_ASSERT_OBJ(list, LV_OBJX_NAME); LV_ASSERT_OBJ(btn, "lv_btn"); int index = 0; @@ -470,6 +469,8 @@ int32_t lv_list_get_btn_index(const lv_obj_t * list, const lv_obj_t * btn) /* no list provided, assuming btn is part of a list */ list = lv_obj_get_parent(lv_obj_get_parent(btn)); } + LV_ASSERT_OBJ(list, LV_OBJX_NAME); + lv_obj_t * e = lv_list_get_next_btn(list, NULL); while(e != NULL) { if(e == btn) { From 859f72eb842a6692df3e62d9888936f82c721078 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 25 Jun 2020 06:19:42 +0200 Subject: [PATCH 036/205] add user_data to themes --- CHANGELOG.md | 1 + src/lv_themes/lv_theme.h | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a74983ffd..56dbb54ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - DMA2D: Remove dependency on ST CubeMX HAL - Added `max_used` propriety to `lv_mem_monitor_t` struct - In `lv_init` test if the the strings are UTF-8 encoded. +- Add `user_data` to themes ### Bugfixes - `lv_img` fix invalidation area when angle or zoom changes diff --git a/src/lv_themes/lv_theme.h b/src/lv_themes/lv_theme.h index 7b4f65b3d..d01b5d160 100644 --- a/src/lv_themes/lv_theme.h +++ b/src/lv_themes/lv_theme.h @@ -155,6 +155,7 @@ typedef struct { const lv_font_t * font_subtitle; const lv_font_t * font_title; uint32_t flags; + lv_theme_user_data_t user_data; } lv_theme_t; /********************** From 52cca1dd9b953d5d4116d825ea0ed49152217801 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 25 Jun 2020 06:38:17 +0200 Subject: [PATCH 037/205] use void * as theme user data for backward compatibility --- src/lv_themes/lv_theme.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_themes/lv_theme.h b/src/lv_themes/lv_theme.h index d01b5d160..35e644c0e 100644 --- a/src/lv_themes/lv_theme.h +++ b/src/lv_themes/lv_theme.h @@ -155,7 +155,7 @@ typedef struct { const lv_font_t * font_subtitle; const lv_font_t * font_title; uint32_t flags; - lv_theme_user_data_t user_data; + void * user_data; } lv_theme_t; /********************** From 8c151a2d43277804aa221f61dc5857031d012bda Mon Sep 17 00:00:00 2001 From: Deon Marais Date: Sat, 20 Jun 2020 09:08:59 +0200 Subject: [PATCH 038/205] Add missing lv_font_montserrat_34 if you do not mind me asking, and on matters of fonts why was Roboto changed to Montserrat when V7 was released ? --- src/lv_font/lv_font.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lv_font/lv_font.h b/src/lv_font/lv_font.h index cb90329bf..b319158c1 100644 --- a/src/lv_font/lv_font.h +++ b/src/lv_font/lv_font.h @@ -171,6 +171,10 @@ LV_FONT_DECLARE(lv_font_montserrat_30) LV_FONT_DECLARE(lv_font_montserrat_32) #endif +#if LV_FONT_MONTSERRAT_34 +LV_FONT_DECLARE(lv_font_montserrat_34) +#endif + #if LV_FONT_MONTSERRAT_36 LV_FONT_DECLARE(lv_font_montserrat_36) #endif From db24bf1d18a9c28384502d3691c51ab740fe7b0c Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 23 Jun 2020 11:11:45 +0200 Subject: [PATCH 039/205] In lv_init test if the the strings are UTF-8 encoded --- CHANGELOG.md | 1 + src/lv_core/lv_obj.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24b8b0205..929b7754f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ Available in the `dev` branch - Add lv_btnmatrix_set/get_align capability - DMA2D: Remove dependency on ST CubeMX HAL - Added `max_used` propriety to `lv_mem_monitor_t` struct +- In `lv_init` test if the the strings are UTF-8 encoded. ### Bugfixes - None diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 211a14559..109f7eb2f 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -168,6 +168,14 @@ void lv_init(void) _lv_img_decoder_init(); lv_img_cache_set_size(LV_IMG_CACHE_DEF_SIZE); + /*Test if the IDE has UTF-8 encoding*/ + char * txt = "Á"; + + uint8_t * txt_u8 = (uint8_t *) txt; + if(txt_u8[0] != 0xc3 || txt_u8[1] != 0x81 || txt_u8[2] != 0x00) { + LV_LOG_WARN("The strings has no UTF-8 encoding. Some characters won't be displayed.") + } + lv_initialized = true; LV_LOG_INFO("lv_init ready"); } From f6a2c635fd71d839636415b616ffeafab55d4489 Mon Sep 17 00:00:00 2001 From: jbamaral Date: Tue, 23 Jun 2020 09:30:33 -0300 Subject: [PATCH 040/205] Improve big endian support (#1599) --- CHANGELOG.md | 1 + src/lv_core/lv_obj.c | 17 ++- src/lv_core/lv_style.c | 205 +++++++++++++++++++++++----------- src/lv_core/lv_style.h | 11 +- src/lv_font/lv_font_fmt_txt.c | 6 +- 5 files changed, 154 insertions(+), 86 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 929b7754f..da8de8cd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ Available in the `dev` branch ## v7.1.0 (planned on 07.07.2020) *Available in the `master` branch* +- Change some lv_style_t methods to support big endian hardware. ### New features - Add `focus_parent` attribute to `lv_obj` diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 109f7eb2f..2a1874a9e 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -2449,7 +2449,7 @@ lv_style_int_t _lv_obj_get_style_int(const lv_obj_t * obj, uint8_t part, lv_styl lv_style_property_t prop_ori = prop; lv_style_attr_t attr; - attr.full = prop_ori >> 8; + attr = prop_ori >> 8; lv_style_int_t value_act; lv_res_t res = LV_RES_INV; @@ -2463,7 +2463,7 @@ lv_style_int_t _lv_obj_get_style_int(const lv_obj_t * obj, uint8_t part, lv_styl res = _lv_style_list_get_int(dsc, prop, &value_act); if(res == LV_RES_OK) return value_act; - if(attr.bits.inherit == 0) break; + if(LV_STYLE_ATTR_GET_INHERIT(attr) == 0) break; /*If not found, check the `MAIN` style first*/ if(part != LV_OBJ_PART_MAIN) { @@ -2512,7 +2512,7 @@ lv_color_t _lv_obj_get_style_color(const lv_obj_t * obj, uint8_t part, lv_style_ lv_style_property_t prop_ori = prop; lv_style_attr_t attr; - attr.full = prop_ori >> 8; + attr = prop_ori >> 8; lv_color_t value_act; lv_res_t res = LV_RES_INV; @@ -2526,7 +2526,7 @@ lv_color_t _lv_obj_get_style_color(const lv_obj_t * obj, uint8_t part, lv_style_ res = _lv_style_list_get_color(dsc, prop, &value_act); if(res == LV_RES_OK) return value_act; - if(attr.bits.inherit == 0) break; + if(LV_STYLE_ATTR_GET_INHERIT(attr) == 0) break; /*If not found, check the `MAIN` style first*/ if(part != LV_OBJ_PART_MAIN) { @@ -2568,7 +2568,7 @@ lv_opa_t _lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t part, lv_style_prop lv_style_property_t prop_ori = prop; lv_style_attr_t attr; - attr.full = prop_ori >> 8; + attr = prop_ori >> 8; lv_opa_t value_act; lv_res_t res = LV_RES_INV; @@ -2582,7 +2582,7 @@ lv_opa_t _lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t part, lv_style_prop res = _lv_style_list_get_opa(dsc, prop, &value_act); if(res == LV_RES_OK) return value_act; - if(attr.bits.inherit == 0) break; + if(LV_STYLE_ATTR_GET_INHERIT(attr) == 0) break; /*If not found, check the `MAIN` style first*/ if(part != LV_OBJ_PART_MAIN) { @@ -2625,7 +2625,7 @@ const void * _lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_ lv_style_property_t prop_ori = prop; lv_style_attr_t attr; - attr.full = prop_ori >> 8; + attr = prop_ori >> 8; const void * value_act; lv_res_t res = LV_RES_INV; @@ -2639,7 +2639,7 @@ const void * _lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_ res = _lv_style_list_get_ptr(dsc, prop, &value_act); if(res == LV_RES_OK) return value_act; - if(attr.bits.inherit == 0) break; + if(LV_STYLE_ATTR_GET_INHERIT(attr) == 0) break; /*If not found, check the `MAIN` style first*/ if(part != LV_OBJ_PART_MAIN) { @@ -4145,4 +4145,3 @@ static bool obj_valid_child(const lv_obj_t * parent, const lv_obj_t * obj_to_fin return false; } - diff --git a/src/lv_core/lv_style.c b/src/lv_core/lv_style.c index b07954f4d..8d4f10531 100644 --- a/src/lv_core/lv_style.c +++ b/src/lv_core/lv_style.c @@ -36,6 +36,12 @@ **********************/ LV_ATTRIBUTE_FAST_MEM static inline int32_t get_property_index(const lv_style_t * style, lv_style_property_t prop); static lv_style_t * get_alloc_local_style(lv_style_list_t * list); +static inline void style_resize(lv_style_t *style, size_t sz); +static inline lv_style_property_t get_style_prop(const lv_style_t *style, size_t idx); +static inline uint8_t get_style_prop_id(const lv_style_t *style, size_t idx); +static inline uint8_t get_style_prop_attr(const lv_style_t *style, size_t idx); +static inline size_t get_prop_size(uint8_t prop_id); +static inline size_t get_next_prop_index(uint8_t prop_id, size_t id); /********************** * GLOABAL VARIABLES @@ -102,16 +108,12 @@ bool lv_style_remove_prop(lv_style_t * style, lv_style_property_t prop) lv_style_attr_t attr_found; lv_style_attr_t attr_goal; - attr_found.full = *(style->map + id + 1); - attr_goal.full = (prop >> 8) & 0xFFU; + attr_found = get_style_prop_attr(style, id); + attr_goal = (prop >> 8) & 0xFFU; - if(attr_found.bits.state == attr_goal.bits.state) { + if(LV_STYLE_ATTR_GET_STATE(attr_found) == LV_STYLE_ATTR_GET_STATE(attr_goal)) { uint32_t map_size = _lv_style_get_mem_size(style); - uint8_t prop_size = sizeof(lv_style_property_t); - if((prop & 0xF) < LV_STYLE_ID_COLOR) prop_size += sizeof(lv_style_int_t); - else if((prop & 0xF) < LV_STYLE_ID_OPA) prop_size += sizeof(lv_color_t); - else if((prop & 0xF) < LV_STYLE_ID_PTR) prop_size += sizeof(lv_opa_t); - else prop_size += sizeof(const void *); + uint8_t prop_size = get_prop_size(prop); /*Move the props to fill the space of the property to delete*/ uint32_t i; @@ -119,7 +121,7 @@ bool lv_style_remove_prop(lv_style_t * style, lv_style_property_t prop) style->map[i] = style->map[i + prop_size]; } - style->map = lv_mem_realloc(style->map, map_size - prop_size); + style_resize(style, map_size - prop_size); return true; } @@ -335,14 +337,9 @@ uint16_t _lv_style_get_mem_size(const lv_style_t * style) if(style->map == NULL) return 0; size_t i = 0; - while(style->map[i] != _LV_STYLE_CLOSEING_PROP) { - /*Go to the next property*/ - if((style->map[i] & 0xF) < LV_STYLE_ID_COLOR) i += sizeof(lv_style_int_t); - else if((style->map[i] & 0xF) < LV_STYLE_ID_OPA) i += sizeof(lv_color_t); - else if((style->map[i] & 0xF) < LV_STYLE_ID_PTR) i += sizeof(lv_opa_t); - else i += sizeof(const void *); - - i += sizeof(lv_style_property_t); + uint8_t prop_id; + while((prop_id = get_style_prop_id(style, i)) != _LV_STYLE_CLOSEING_PROP) { + i = get_next_prop_index(prop_id, i); } return i + sizeof(lv_style_property_t); @@ -368,10 +365,10 @@ void _lv_style_set_int(lv_style_t * style, lv_style_property_t prop, lv_style_in lv_style_attr_t attr_found; lv_style_attr_t attr_goal; - attr_found.full = *(style->map + id + 1); - attr_goal.full = (prop >> 8) & 0xFFU; + attr_found = get_style_prop_attr(style, id); + attr_goal = (prop >> 8) & 0xFFU; - if(attr_found.bits.state == attr_goal.bits.state) { + if(LV_STYLE_ATTR_GET_STATE(attr_found) == LV_STYLE_ATTR_GET_STATE(attr_goal)) { _lv_memcpy_small(style->map + id + sizeof(lv_style_property_t), &value, sizeof(lv_style_int_t)); return; } @@ -385,7 +382,7 @@ void _lv_style_set_int(lv_style_t * style, lv_style_property_t prop, lv_style_in uint16_t size = _lv_style_get_mem_size(style); if(size == 0) size += end_mark_size; size += sizeof(lv_style_property_t) + sizeof(lv_style_int_t); - style->map = lv_mem_realloc(style->map, size); + style_resize(style, size); LV_ASSERT_MEM(style->map); if(style == NULL) return; @@ -414,10 +411,10 @@ void _lv_style_set_color(lv_style_t * style, lv_style_property_t prop, lv_color_ lv_style_attr_t attr_found; lv_style_attr_t attr_goal; - attr_found.full = *(style->map + id + 1); - attr_goal.full = (prop >> 8) & 0xFFU; + attr_found = get_style_prop_attr(style, id); + attr_goal = (prop >> 8) & 0xFFU; - if(attr_found.bits.state == attr_goal.bits.state) { + if(LV_STYLE_ATTR_GET_STATE(attr_found) == LV_STYLE_ATTR_GET_STATE(attr_goal)) { _lv_memcpy_small(style->map + id + sizeof(lv_style_property_t), &color, sizeof(lv_color_t)); return; } @@ -432,7 +429,7 @@ void _lv_style_set_color(lv_style_t * style, lv_style_property_t prop, lv_color_ if(size == 0) size += end_mark_size; size += sizeof(lv_style_property_t) + sizeof(lv_color_t); - style->map = lv_mem_realloc(style->map, size); + style_resize(style, size); LV_ASSERT_MEM(style->map); if(style == NULL) return; @@ -461,10 +458,10 @@ void _lv_style_set_opa(lv_style_t * style, lv_style_property_t prop, lv_opa_t op lv_style_attr_t attr_found; lv_style_attr_t attr_goal; - attr_found.full = *(style->map + id + 1); - attr_goal.full = (prop >> 8) & 0xFFU; + attr_found = get_style_prop_attr(style, id); + attr_goal = (prop >> 8) & 0xFFU; - if(attr_found.bits.state == attr_goal.bits.state) { + if(LV_STYLE_ATTR_GET_STATE(attr_found) == LV_STYLE_ATTR_GET_STATE(attr_goal)) { _lv_memcpy_small(style->map + id + sizeof(lv_style_property_t), &opa, sizeof(lv_opa_t)); return; } @@ -479,7 +476,7 @@ void _lv_style_set_opa(lv_style_t * style, lv_style_property_t prop, lv_opa_t op if(size == 0) size += end_mark_size; size += sizeof(lv_style_property_t) + sizeof(lv_opa_t); - style->map = lv_mem_realloc(style->map, size); + style_resize(style, size); LV_ASSERT_MEM(style->map); if(style == NULL) return; @@ -508,10 +505,10 @@ void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, const void lv_style_attr_t attr_found; lv_style_attr_t attr_goal; - attr_found.full = *(style->map + id + 1); - attr_goal.full = (prop >> 8) & 0xFFU; + attr_found = get_style_prop_attr(style, id); + attr_goal = (prop >> 8) & 0xFFU; - if(attr_found.bits.state == attr_goal.bits.state) { + if(LV_STYLE_ATTR_GET_STATE(attr_found) == LV_STYLE_ATTR_GET_STATE(attr_goal)) { _lv_memcpy_small(style->map + id + sizeof(lv_style_property_t), &p, sizeof(const void *)); return; } @@ -526,7 +523,7 @@ void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, const void if(size == 0) size += end_mark_size; size += sizeof(lv_style_property_t) + sizeof(const void *); - style->map = lv_mem_realloc(style->map, size); + style_resize(style, size); LV_ASSERT_MEM(style->map); if(style == NULL) return; @@ -560,12 +557,12 @@ int16_t _lv_style_get_int(const lv_style_t * style, lv_style_property_t prop, vo else { _lv_memcpy_small(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_style_int_t)); lv_style_attr_t attr_act; - attr_act.full = style->map[id + 1]; + attr_act = get_style_prop_attr(style, id + 1); lv_style_attr_t attr_goal; - attr_goal.full = (prop >> 8) & 0xFF; + attr_goal = (prop >> 8) & 0xFF; - return attr_act.bits.state & attr_goal.bits.state; + return LV_STYLE_ATTR_GET_STATE(attr_act) & LV_STYLE_ATTR_GET_STATE(attr_goal); } } @@ -597,12 +594,12 @@ int16_t _lv_style_get_opa(const lv_style_t * style, lv_style_property_t prop, vo else { _lv_memcpy_small(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_opa_t)); lv_style_attr_t attr_act; - attr_act.full = style->map[id + 1]; + attr_act = get_style_prop_attr(style, id); lv_style_attr_t attr_goal; - attr_goal.full = (prop >> 8) & 0xFF; + attr_goal = (prop >> 8) & 0xFF; - return attr_act.bits.state & attr_goal.bits.state; + return LV_STYLE_ATTR_GET_STATE(attr_act) & LV_STYLE_ATTR_GET_STATE(attr_goal); } } @@ -631,12 +628,12 @@ int16_t _lv_style_get_color(const lv_style_t * style, lv_style_property_t prop, else { _lv_memcpy_small(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_color_t)); lv_style_attr_t attr_act; - attr_act.full = style->map[id + 1]; + attr_act = get_style_prop_attr(style, id); lv_style_attr_t attr_goal; - attr_goal.full = (prop >> 8) & 0xFF; + attr_goal = (prop >> 8) & 0xFF; - return attr_act.bits.state & attr_goal.bits.state; + return LV_STYLE_ATTR_GET_STATE(attr_act) & LV_STYLE_ATTR_GET_STATE(attr_goal); } } @@ -666,12 +663,12 @@ int16_t _lv_style_get_ptr(const lv_style_t * style, lv_style_property_t prop, vo else { _lv_memcpy_small(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(const void *)); lv_style_attr_t attr_act; - attr_act.full = style->map[id + 1]; + attr_act = get_style_prop_attr(style, id); lv_style_attr_t attr_goal; - attr_goal.full = (prop >> 8) & 0xFF; + attr_goal = (prop >> 8) & 0xFF; - return attr_act.bits.state & attr_goal.bits.state; + return LV_STYLE_ATTR_GET_STATE(attr_act) & LV_STYLE_ATTR_GET_STATE(attr_goal); } } @@ -819,8 +816,8 @@ lv_res_t _lv_style_list_get_int(lv_style_list_t * list, lv_style_property_t prop if(list->style_list == NULL) return LV_RES_INV; lv_style_attr_t attr; - attr.full = prop >> 8; - int16_t weight_goal = attr.full; + attr = prop >> 8; + int16_t weight_goal = attr; int16_t weight = -1; @@ -871,8 +868,8 @@ lv_res_t _lv_style_list_get_color(lv_style_list_t * list, lv_style_property_t pr if(list->style_list == NULL) return LV_RES_INV; lv_style_attr_t attr; - attr.full = prop >> 8; - int16_t weight_goal = attr.full; + attr = prop >> 8; + int16_t weight_goal = attr; int16_t weight = -1; @@ -921,8 +918,8 @@ lv_res_t _lv_style_list_get_opa(lv_style_list_t * list, lv_style_property_t prop if(list->style_list == NULL) return LV_RES_INV; lv_style_attr_t attr; - attr.full = prop >> 8; - int16_t weight_goal = attr.full; + attr = prop >> 8; + int16_t weight_goal = attr; int16_t weight = -1; @@ -971,8 +968,8 @@ lv_res_t _lv_style_list_get_ptr(lv_style_list_t * list, lv_style_property_t prop if(list->style_list == NULL) return LV_RES_INV; lv_style_attr_t attr; - attr.full = prop >> 8; - int16_t weight_goal = attr.full; + attr = prop >> 8; + int16_t weight_goal = attr; int16_t weight = -1; @@ -1061,40 +1058,36 @@ LV_ATTRIBUTE_FAST_MEM static inline int32_t get_property_index(const lv_style_t uint8_t id_to_find = prop & 0xFF; lv_style_attr_t attr; - attr.full = (prop >> 8) & 0xFF; + attr = (prop >> 8) & 0xFF; int16_t weight = -1; int16_t id_guess = -1; size_t i = 0; - while(style->map[i] != _LV_STYLE_CLOSEING_PROP) { - if(style->map[i] == id_to_find) { + + uint8_t prop_id; + while((prop_id = get_style_prop_id(style, i)) != _LV_STYLE_CLOSEING_PROP) { + if(prop_id == id_to_find) { lv_style_attr_t attr_i; - attr_i.full = style->map[i + 1]; + attr_i = get_style_prop_attr(style, i); /*If the state perfectly matches return this property*/ - if(attr_i.bits.state == attr.bits.state) { + if(LV_STYLE_ATTR_GET_STATE(attr_i) == LV_STYLE_ATTR_GET_STATE(attr)) { return i; } /* Be sure the property not specifies other state than the requested. * E.g. For HOVER+PRESS, HOVER only is OK, but HOVER+FOCUS not*/ - else if((attr_i.bits.state & (~attr.bits.state)) == 0) { + else if((LV_STYLE_ATTR_GET_STATE(attr_i) & (~LV_STYLE_ATTR_GET_STATE(attr))) == 0) { /* Use this property if it describes better the requested state than the current candidate. * E.g. for HOVER+FOCUS+PRESS prefer HOVER+FOCUS over FOCUS*/ - if(attr_i.bits.state > weight) { - weight = attr_i.bits.state; + if(LV_STYLE_ATTR_GET_STATE(attr_i) > weight) { + weight = LV_STYLE_ATTR_GET_STATE(attr_i); id_guess = i; } } } - /*Go to the next property*/ - if((style->map[i] & 0xF) < LV_STYLE_ID_COLOR) i += sizeof(lv_style_int_t); - else if((style->map[i] & 0xF) < LV_STYLE_ID_OPA) i += sizeof(lv_color_t); - else if((style->map[i] & 0xF) < LV_STYLE_ID_PTR) i += sizeof(lv_opa_t); - else i += sizeof(const void *); - - i += sizeof(lv_style_property_t); + i = get_next_prop_index(prop_id, i); } return id_guess; @@ -1125,3 +1118,79 @@ static lv_style_t * get_alloc_local_style(lv_style_list_t * list) return local_style; } + +/** + * Resizes a style map. Useful entry point for debugging. + * @param style pointer to the style to be resized. + * @param size new size + */ +static inline void style_resize(lv_style_t *style, size_t sz) +{ + style->map = lv_mem_realloc(style->map, sz); +} + +/** + * Get style property in index. + * @param style pointer to style. + * @param idx index of the style in style->map + * @return property in style->map + idx + */ +static inline lv_style_property_t get_style_prop(const lv_style_t *style, size_t idx) +{ + lv_style_property_t prop; + uint8_t *prop_p = (uint8_t*)∝ + prop_p[0] = style->map[idx]; + prop_p[1] = style->map[idx + 1]; + return prop; +} + +/** + * Get style property id in index. + * @param style pointer to style. + * @param idx index of the style in style->map + * @return id of property in style->map + idx + */ +static inline uint8_t get_style_prop_id(const lv_style_t *style, size_t idx) +{ + return get_style_prop(style, idx) & 0xFF; +} + +/** + * Get style property attributes for index. + * @param style pointer to style. + * @param idx index of the style in style->map + * @return attribute of property in style->map + idx + */ +static inline uint8_t get_style_prop_attr(const lv_style_t *style, size_t idx) +{ + return ((get_style_prop(style, idx) >> 8) & 0xFFU); +} + + +/** + * Get property size. + * @param prop_id property id. + * @param idx index of the style in style->map + * @return attribute of property in style->map + idx + */ +static inline size_t get_prop_size(uint8_t prop_id) +{ + prop_id &= 0xF; + size_t size = sizeof(lv_style_property_t); + if(prop_id < LV_STYLE_ID_COLOR) size += sizeof(lv_style_int_t); + else if(prop_id < LV_STYLE_ID_OPA) size += sizeof(lv_color_t); + else if(prop_id < LV_STYLE_ID_PTR) size += sizeof(lv_opa_t); + else size += sizeof(const void *); + return size; +} + +/** + * Get next property index, given current property and index. + * @param prop_id property id. + * @param idx index of the style in style->map + * @return index of next property in style->map + */ +static inline size_t get_next_prop_index(uint8_t prop_id, size_t idx) +{ + return idx + get_prop_size(prop_id); +} diff --git a/src/lv_core/lv_style.h b/src/lv_core/lv_style.h index c17ee5ff8..aff4759e3 100644 --- a/src/lv_core/lv_style.h +++ b/src/lv_core/lv_style.h @@ -81,13 +81,10 @@ enum { typedef uint8_t lv_text_decor_t; -typedef union { - struct { - uint8_t state : 7; /* To which state the property refers to*/ - uint8_t inherit : 1; /*1: The property can be inherited*/ - } bits; - uint8_t full; -} lv_style_attr_t; +typedef uint8_t lv_style_attr_t; + +#define LV_STYLE_ATTR_GET_INHERIT(f) ((f)&0xA0) +#define LV_STYLE_ATTR_GET_STATE(f) ((f)&0x3F) #define LV_STYLE_ID_VALUE 0x0 /*max 9 pcs*/ #define LV_STYLE_ID_COLOR 0x9 /*max 3 pcs*/ diff --git a/src/lv_font/lv_font_fmt_txt.c b/src/lv_font/lv_font_fmt_txt.c index fe8e55793..731ada0e6 100644 --- a/src/lv_font/lv_font_fmt_txt.c +++ b/src/lv_font/lv_font_fmt_txt.c @@ -214,7 +214,8 @@ static uint32_t get_glyph_dsc_id(const lv_font_t * font, uint32_t letter) glyph_id = fdsc->cmaps[i].glyph_id_start + gid_ofs_8[rcp]; } else if(fdsc->cmaps[i].type == LV_FONT_FMT_TXT_CMAP_SPARSE_TINY) { - uint8_t * p = _lv_utils_bsearch(&rcp, fdsc->cmaps[i].unicode_list, fdsc->cmaps[i].list_length, + uint16_t key = rcp; + uint8_t * p = _lv_utils_bsearch(&key, fdsc->cmaps[i].unicode_list, fdsc->cmaps[i].list_length, sizeof(fdsc->cmaps[i].unicode_list[0]), unicode_list_compare); if(p) { @@ -224,7 +225,8 @@ static uint32_t get_glyph_dsc_id(const lv_font_t * font, uint32_t letter) } } else if(fdsc->cmaps[i].type == LV_FONT_FMT_TXT_CMAP_SPARSE_FULL) { - uint8_t * p = _lv_utils_bsearch(&rcp, fdsc->cmaps[i].unicode_list, fdsc->cmaps[i].list_length, + uint16_t key = rcp; + uint8_t * p = _lv_utils_bsearch(&key, fdsc->cmaps[i].unicode_list, fdsc->cmaps[i].list_length, sizeof(fdsc->cmaps[i].unicode_list[0]), unicode_list_compare); if(p) { From 2828582c7abcc93c9ca5b313465eec7c263d4a64 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 24 Jun 2020 10:02:45 +0200 Subject: [PATCH 041/205] lv_img: fix invalidation area when angle or zoom changes --- CHANGELOG.md | 3 ++- src/lv_widgets/lv_img.c | 10 ++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da8de8cd2..88284e936 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,10 +27,11 @@ Available in the `dev` branch - In `lv_init` test if the the strings are UTF-8 encoded. ### Bugfixes -- None +- `lv_img` fix invalidation area when angle or zoom changes ## v7.0.2 (16.06.2020) +### Bugfixes - `lv_textarea` fix wrong cursor position when clicked after the last character - Change all text related indices from 16-bit to 32-bit integers throughout whole library. #1545 - Fix gestures diff --git a/src/lv_widgets/lv_img.c b/src/lv_widgets/lv_img.c index 08e7c2321..3acb7cab3 100644 --- a/src/lv_widgets/lv_img.c +++ b/src/lv_widgets/lv_img.c @@ -340,10 +340,9 @@ void lv_img_set_angle(lv_obj_t * img, int16_t angle) transf_zoom = (transf_zoom * ext->zoom) >> 8; lv_style_int_t transf_angle = lv_obj_get_style_transform_angle(img, LV_IMG_PART_MAIN); - transf_angle += ext->angle; lv_area_t a; - _lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle, transf_zoom, &ext->pivot); + _lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle + ext->angle, transf_zoom, &ext->pivot); a.x1 += img->coords.x1; a.y1 += img->coords.y1; a.x2 += img->coords.x1; @@ -353,7 +352,7 @@ void lv_img_set_angle(lv_obj_t * img, int16_t angle) ext->angle = angle; lv_obj_refresh_ext_draw_pad(img); - _lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle, transf_zoom, &ext->pivot); + _lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle + ext->angle, transf_zoom, &ext->pivot); a.x1 += img->coords.x1; a.y1 += img->coords.y1; a.x2 += img->coords.x1; @@ -379,13 +378,12 @@ void lv_img_set_zoom(lv_obj_t * img, uint16_t zoom) if(zoom == 0) zoom = 1; lv_style_int_t transf_zoom = lv_obj_get_style_transform_zoom(img, LV_IMG_PART_MAIN); - transf_zoom = (transf_zoom * ext->zoom) >> 8; lv_style_int_t transf_angle = lv_obj_get_style_transform_angle(img, LV_IMG_PART_MAIN); transf_angle += ext->angle; lv_area_t a; - _lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle, transf_zoom, &ext->pivot); + _lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle, (transf_zoom * ext->zoom) >> 8, &ext->pivot); a.x1 += img->coords.x1; a.y1 += img->coords.y1; a.x2 += img->coords.x1; @@ -395,7 +393,7 @@ void lv_img_set_zoom(lv_obj_t * img, uint16_t zoom) ext->zoom = zoom; lv_obj_refresh_ext_draw_pad(img); - _lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle, transf_zoom, &ext->pivot); + _lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle, (transf_zoom * ext->zoom) >> 8, &ext->pivot); a.x1 += img->coords.x1; a.y1 += img->coords.y1; a.x2 += img->coords.x1; From e2aa68394ca4b34e1e940686cd7149220334991e Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 24 Jun 2020 10:04:30 +0200 Subject: [PATCH 042/205] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88284e936..178d34ed9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ Available in the `dev` branch ### Bugfixes - `lv_img` fix invalidation area when angle or zoom changes +- Update the style handling to support Big endian MCUs ## v7.0.2 (16.06.2020) From 8f243c01d515ca3b118ef857926c290eb52451d5 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 24 Jun 2020 10:45:32 +0200 Subject: [PATCH 043/205] style: minor fix on getting style attributes + formatting --- src/lv_core/lv_style.c | 2 +- src/lv_core/lv_style.h | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lv_core/lv_style.c b/src/lv_core/lv_style.c index 8d4f10531..1be4e3dbe 100644 --- a/src/lv_core/lv_style.c +++ b/src/lv_core/lv_style.c @@ -557,7 +557,7 @@ int16_t _lv_style_get_int(const lv_style_t * style, lv_style_property_t prop, vo else { _lv_memcpy_small(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_style_int_t)); lv_style_attr_t attr_act; - attr_act = get_style_prop_attr(style, id + 1); + attr_act = get_style_prop_attr(style, id); lv_style_attr_t attr_goal; attr_goal = (prop >> 8) & 0xFF; diff --git a/src/lv_core/lv_style.h b/src/lv_core/lv_style.h index aff4759e3..5909299b6 100644 --- a/src/lv_core/lv_style.h +++ b/src/lv_core/lv_style.h @@ -83,8 +83,8 @@ typedef uint8_t lv_text_decor_t; typedef uint8_t lv_style_attr_t; -#define LV_STYLE_ATTR_GET_INHERIT(f) ((f)&0xA0) -#define LV_STYLE_ATTR_GET_STATE(f) ((f)&0x3F) +#define LV_STYLE_ATTR_GET_INHERIT(f) ((f)&0x80) +#define LV_STYLE_ATTR_GET_STATE(f) ((f)&0x7F) #define LV_STYLE_ID_VALUE 0x0 /*max 9 pcs*/ #define LV_STYLE_ID_COLOR 0x9 /*max 3 pcs*/ @@ -99,7 +99,7 @@ enum { LV_STYLE_PROP_INIT(LV_STYLE_TRANSFORM_WIDTH, 0x0, LV_STYLE_ID_VALUE + 4, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_TRANSFORM_HEIGHT, 0x0, LV_STYLE_ID_VALUE + 5, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_TRANSFORM_ANGLE, 0x0, LV_STYLE_ID_VALUE + 6, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_TRANSFORM_ZOOM, 0x0, LV_STYLE_ID_VALUE + 7, LV_STYLE_ATTR_NONE), + LV_STYLE_PROP_INIT(LV_STYLE_TRANSFORM_ZOOM, 0x0, LV_STYLE_ID_VALUE + 7, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_OPA_SCALE, 0x0, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_INHERIT), LV_STYLE_PROP_INIT(LV_STYLE_PAD_TOP, 0x1, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE), @@ -134,8 +134,8 @@ enum { LV_STYLE_PROP_INIT(LV_STYLE_OUTLINE_OPA, 0x4, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_WIDTH, 0x5, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_OFS_X, 0x5, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_OFS_Y, 0x5, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE), + LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_OFS_X, 0x5, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE), + LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_OFS_Y, 0x5, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_SPREAD, 0x5, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_BLEND_MODE, 0x5, LV_STYLE_ID_VALUE + 4, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_COLOR, 0x5, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE), @@ -191,12 +191,12 @@ enum { LV_STYLE_PROP_INIT(LV_STYLE_TRANSITION_PROP_6, 0xB, LV_STYLE_ID_VALUE + 7, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_TRANSITION_PATH, 0xB, LV_STYLE_ID_PTR + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SCALE_WIDTH, 0xC, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE), + LV_STYLE_PROP_INIT(LV_STYLE_SCALE_WIDTH, 0xC, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_SCALE_BORDER_WIDTH, 0xC, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_BORDER_WIDTH, 0xC, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_LINE_WIDTH, 0xC, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SCALE_GRAD_COLOR, 0xC, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_COLOR, 0xC, LV_STYLE_ID_COLOR + 1, LV_STYLE_ATTR_NONE), + LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_LINE_WIDTH, 0xC, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE), + LV_STYLE_PROP_INIT(LV_STYLE_SCALE_GRAD_COLOR, 0xC, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE), + LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_COLOR, 0xC, LV_STYLE_ID_COLOR + 1, LV_STYLE_ATTR_NONE), }; typedef uint16_t lv_style_property_t; From cf8357e0042a360c3bdddfe6b7cc7c4a661cfa83 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 24 Jun 2020 11:24:07 +0200 Subject: [PATCH 044/205] fix focusing/defocusing for pages --- src/lv_core/lv_indev.c | 13 +++++++------ src/lv_core/lv_obj.c | 2 -- src/lv_widgets/lv_page.c | 14 ++++++++++---- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/lv_core/lv_indev.c b/src/lv_core/lv_indev.c index cc2c608b6..a491c0996 100644 --- a/src/lv_core/lv_indev.c +++ b/src/lv_core/lv_indev.c @@ -1183,11 +1183,6 @@ static void indev_click_focus(lv_indev_proc_t * proc) } /*The object are not in the same group (in different group or one in not a group)*/ else { - /*Focus to the act. its group*/ - if(g_act) { - lv_group_focus_obj(indev_obj_act); - if(indev_reset_check(proc)) return; - } /*If the prev. obj. is not in a group then defocus it.*/ if(g_prev == NULL && proc->types.pointer.last_pressed) { lv_signal_send(proc->types.pointer.last_pressed, LV_SIGNAL_DEFOCUS, NULL); @@ -1213,12 +1208,18 @@ static void indev_click_focus(lv_indev_proc_t * proc) if(indev_reset_check(proc)) return; } } + } + /*Focus to the act. in its group*/ + if(g_act) { + lv_group_focus_obj(indev_obj_act); + if(indev_reset_check(proc)) return; + } else { lv_signal_send(indev_obj_act, LV_SIGNAL_FOCUS, NULL); if(indev_reset_check(proc)) return; lv_event_send(indev_obj_act, LV_EVENT_FOCUSED, NULL); if(indev_reset_check(proc)) return; - } + } } #else if(proc->types.pointer.last_pressed) { diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 2a1874a9e..8c4276e94 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -3752,7 +3752,6 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param) else if(sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST) { lv_obj_clear_state(obj, LV_STATE_PRESSED); } -#if LV_USE_GROUP else if(sign == LV_SIGNAL_FOCUS) { if(lv_group_get_editing(lv_obj_get_group(obj))) { uint8_t state = LV_STATE_FOCUSED; @@ -3779,7 +3778,6 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param) lv_obj_clear_state(obj, LV_STATE_FOCUSED | LV_STATE_EDITED); } -#endif else if(sign == LV_SIGNAL_CLEANUP) { lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN); } diff --git a/src/lv_widgets/lv_page.c b/src/lv_widgets/lv_page.c index 31a1fef13..f8141c320 100644 --- a/src/lv_widgets/lv_page.c +++ b/src/lv_widgets/lv_page.c @@ -1054,10 +1054,16 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi } } else if(sign == LV_SIGNAL_DEFOCUS) { - res = lv_signal_send(page, LV_SIGNAL_DEFOCUS, NULL); - if(res != LV_RES_OK) return res; - res = lv_event_send(page, LV_EVENT_DEFOCUSED, NULL); - if(res != LV_RES_OK) return res; + bool in_group = false; +#if LV_USE_GROUP + in_group = lv_obj_get_group(page) ? true : false; +#endif + if(in_group == false) { + res = lv_signal_send(page, LV_SIGNAL_DEFOCUS, NULL); + if(res != LV_RES_OK) return res; + res = lv_event_send(page, LV_EVENT_DEFOCUSED, NULL); + if(res != LV_RES_OK) return res; + } } else if(sign == LV_SIGNAL_CLEANUP) { page_ext->scrl = NULL; From 1e33359d0ca06a1d65474899c489c371e110cba8 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 24 Jun 2020 11:28:51 +0200 Subject: [PATCH 045/205] fix build error --- src/lv_core/lv_obj.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 8c4276e94..8e935b3b2 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -3753,7 +3753,11 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param) lv_obj_clear_state(obj, LV_STATE_PRESSED); } else if(sign == LV_SIGNAL_FOCUS) { - if(lv_group_get_editing(lv_obj_get_group(obj))) { + bool editing = false; +#if LV_USE_GROUP + editing = lv_group_get_editing(lv_obj_get_group(obj)); +#endif + if(editing) { uint8_t state = LV_STATE_FOCUSED; state |= LV_STATE_EDITED; From c4eec78a02d6836d6cc63139cb55f56bbf93fe50 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 24 Jun 2020 11:36:35 +0200 Subject: [PATCH 046/205] lv_textarea fix cursor alignment with empty textarea when the text alignment is center or right --- src/lv_widgets/lv_label.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/lv_widgets/lv_label.c b/src/lv_widgets/lv_label.c index 1a71a37de..da8b6d308 100644 --- a/src/lv_widgets/lv_label.c +++ b/src/lv_widgets/lv_label.c @@ -572,10 +572,21 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint32_t char_id, lv_point_ LV_ASSERT_NULL(pos); const char * txt = lv_label_get_text(label); + lv_label_align_t align = lv_label_get_align(label); if(txt[0] == '\0') { - pos->x = 0; pos->y = 0; + switch(align) { + case LV_LABEL_ALIGN_LEFT: + pos->x = 0; + break; + case LV_LABEL_ALIGN_RIGHT: + pos->x = lv_obj_get_width(label); + break; + case LV_LABEL_ALIGN_CENTER: + pos->x = lv_obj_get_width(label) / 2; + break; + } return; } @@ -597,7 +608,6 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint32_t char_id, lv_point_ if(ext->expand != 0) flag |= LV_TXT_FLAG_EXPAND; if(ext->long_mode == LV_LABEL_LONG_EXPAND) flag |= LV_TXT_FLAG_FIT; - lv_label_align_t align = lv_label_get_align(label); if(align == LV_LABEL_ALIGN_CENTER) flag |= LV_TXT_FLAG_CENTER; if(align == LV_LABEL_ALIGN_RIGHT) flag |= LV_TXT_FLAG_RIGHT; From cd788da47a6549e1e7191f7b91fd5ab4ea7c76bf Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Wed, 24 Jun 2020 12:25:16 -0400 Subject: [PATCH 047/205] Fix #1610: don't assert an expected null pointer --- src/lv_widgets/lv_list.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lv_widgets/lv_list.c b/src/lv_widgets/lv_list.c index afcafecbb..d7b502db1 100644 --- a/src/lv_widgets/lv_list.c +++ b/src/lv_widgets/lv_list.c @@ -462,7 +462,6 @@ lv_obj_t * lv_list_get_next_btn(const lv_obj_t * list, lv_obj_t * prev_btn) */ int32_t lv_list_get_btn_index(const lv_obj_t * list, const lv_obj_t * btn) { - LV_ASSERT_OBJ(list, LV_OBJX_NAME); LV_ASSERT_OBJ(btn, "lv_btn"); int index = 0; @@ -470,6 +469,8 @@ int32_t lv_list_get_btn_index(const lv_obj_t * list, const lv_obj_t * btn) /* no list provided, assuming btn is part of a list */ list = lv_obj_get_parent(lv_obj_get_parent(btn)); } + LV_ASSERT_OBJ(list, LV_OBJX_NAME); + lv_obj_t * e = lv_list_get_next_btn(list, NULL); while(e != NULL) { if(e == btn) { From 44a96df9fbbb9673a7c32fddc5486512e47bef30 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 25 Jun 2020 06:18:11 +0200 Subject: [PATCH 048/205] initial implementation of screen load animation --- src/lv_core/lv_disp.c | 21 +++++++++++++++++++++ src/lv_core/lv_disp.h | 3 +++ src/lv_core/lv_obj.c | 10 ++++------ src/lv_core/lv_refr.c | 33 ++++++++++++++++++++++++++++++--- src/lv_hal/lv_hal_disp.h | 9 +++++---- 5 files changed, 63 insertions(+), 13 deletions(-) diff --git a/src/lv_core/lv_disp.c b/src/lv_core/lv_disp.c index 37206b35a..722be31ca 100644 --- a/src/lv_core/lv_disp.c +++ b/src/lv_core/lv_disp.c @@ -20,6 +20,7 @@ /********************** * STATIC PROTOTYPES **********************/ +static void scr_load_anim_start(lv_anim_t * a); /********************** * STATIC VARIABLES @@ -115,6 +116,21 @@ void lv_disp_assign_screen(lv_disp_t * disp, lv_obj_t * scr) _lv_ll_chg_list(&old_disp->scr_ll, &disp->scr_ll, scr, true); } +void lv_scr_load_anim(lv_obj_t * scr) +{ + lv_disp_t * d = lv_obj_get_disp(scr); + + lv_anim_t a; + lv_anim_init(&a); + lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t) lv_obj_set_x); + lv_anim_set_start_cb(&a, scr_load_anim_start); + lv_anim_set_time(&a, 2000); + lv_anim_set_delay(&a, 1000); + lv_anim_set_values(&a, lv_disp_get_hor_res(d), 0); + lv_anim_set_var(&a, scr); + lv_anim_start(&a); +} + /** * Get elapsed time since last user activity on a display (e.g. click) * @param disp pointer to an display (NULL to get the overall smallest inactivity) @@ -178,3 +194,8 @@ lv_task_t * _lv_disp_get_refr_task(lv_disp_t * disp) /********************** * STATIC FUNCTIONS **********************/ + +static void scr_load_anim_start(lv_anim_t * a) +{ + lv_disp_load_scr(a->var); +} diff --git a/src/lv_core/lv_disp.h b/src/lv_core/lv_disp.h index 58ce2145f..b09fc1dc6 100644 --- a/src/lv_core/lv_disp.h +++ b/src/lv_core/lv_disp.h @@ -122,6 +122,9 @@ static inline void lv_scr_load(lv_obj_t * scr) lv_disp_load_scr(scr); } + +void lv_scr_load_anim(lv_obj_t * scr); + /********************** * MACROS **********************/ diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 8e935b3b2..e5fc6f1d5 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -684,13 +684,11 @@ void lv_obj_set_pos(lv_obj_t * obj, lv_coord_t x, lv_coord_t y) /*Convert x and y to absolute coordinates*/ lv_obj_t * par = obj->parent; - if(par == NULL) { - LV_LOG_WARN("lv_obj_set_pos: not changing position of screen object"); - return; + if(par) { + x = x + par->coords.x1; + y = y + par->coords.y1; } - x = x + par->coords.x1; - y = y + par->coords.y1; /*Calculate and set the movement*/ lv_point_t diff; @@ -720,7 +718,7 @@ void lv_obj_set_pos(lv_obj_t * obj, lv_coord_t x, lv_coord_t y) obj->signal_cb(obj, LV_SIGNAL_COORD_CHG, &ori); /*Send a signal to the parent too*/ - par->signal_cb(par, LV_SIGNAL_CHILD_CHG, obj); + if(par) par->signal_cb(par, LV_SIGNAL_CHILD_CHG, obj); /*Invalidate the new area*/ lv_obj_invalidate(obj); diff --git a/src/lv_core/lv_refr.c b/src/lv_core/lv_refr.c index d1c5b848d..5ba13e5fa 100644 --- a/src/lv_core/lv_refr.c +++ b/src/lv_core/lv_refr.c @@ -490,7 +490,8 @@ static void lv_refr_area_part(const lv_area_t * area_p) } } - lv_obj_t * top_p; + lv_obj_t * top_act_scr = NULL; + lv_obj_t * top_prev_scr = NULL; /*Get the new mask from the original area and the act. VDB It will be a part of 'area_p'*/ @@ -498,10 +499,36 @@ static void lv_refr_area_part(const lv_area_t * area_p) _lv_area_intersect(&start_mask, area_p, &vdb->area); /*Get the most top object which is not covered by others*/ - top_p = lv_refr_get_top_obj(&start_mask, lv_disp_get_scr_act(disp_refr)); + top_act_scr = lv_refr_get_top_obj(&start_mask, lv_disp_get_scr_act(disp_refr)); + if(disp_refr->prev_scr) { + top_prev_scr = lv_refr_get_top_obj(&start_mask, disp_refr->prev_scr); + } + /*Draw a display background if there is no top object*/ + if(top_act_scr == NULL && top_prev_scr == NULL) { + lv_draw_rect_dsc_t dsc; + lv_draw_rect_dsc_init(&dsc); + dsc.bg_color = LV_COLOR_RED; + + lv_draw_rect(&start_mask, &start_mask, &dsc); + } + /*Refresh the previous screen if any*/ + if(disp_refr->prev_scr) { + /*Get the most top object which is not covered by others*/ + if(top_prev_scr == NULL) { + top_prev_scr = disp_refr->prev_scr; + } + /*Do the refreshing from the top object*/ + lv_refr_obj_and_children(top_prev_scr, &start_mask); + + } + + + if(top_act_scr == NULL) { + top_act_scr = disp_refr->act_scr; + } /*Do the refreshing from the top object*/ - lv_refr_obj_and_children(top_p, &start_mask); + lv_refr_obj_and_children(top_act_scr, &start_mask); /*Also refresh top and sys layer unconditionally*/ lv_refr_obj_and_children(lv_disp_get_layer_top(disp_refr), &start_mask); diff --git a/src/lv_hal/lv_hal_disp.h b/src/lv_hal/lv_hal_disp.h index 97c78c80f..f607390b9 100644 --- a/src/lv_hal/lv_hal_disp.h +++ b/src/lv_hal/lv_hal_disp.h @@ -52,10 +52,10 @@ typedef struct { void * buf_act; uint32_t size; /*In pixel count*/ lv_area_t area; - volatile int - flushing; /*1: flushing is in progress. (It can't be a bitfield because when it's cleared from IRQ Read-Modify-Write issue might occur)*/ - volatile int - flushing_last; /*1: It was the last chunk to flush. (It can't be a bitfield because when it's cleared from IRQ Read-Modify-Write issue might occur)*/ + /*1: flushing is in progress. (It can't be a bit field because when it's cleared from IRQ Read-Modify-Write issue might occur)*/ + volatile int flushing; + /*1: It was the last chunk to flush. (It can't be a bi tfield because when it's cleared from IRQ Read-Modify-Write issue might occur)*/ + volatile int flushing_last; volatile uint32_t last_area : 1; /*1: the last area is being rendered*/ volatile uint32_t last_part : 1; /*1: the last part of the current area is being rendered*/ } lv_disp_buf_t; @@ -147,6 +147,7 @@ typedef struct _disp_t { /** Screens of the display*/ lv_ll_t scr_ll; struct _lv_obj_t * act_scr; /**< Currently active screen on this display */ + struct _lv_obj_t * prev_scr; /**< Previous screen. Used during screen animations */ struct _lv_obj_t * top_layer; /**< @see lv_disp_get_layer_top */ struct _lv_obj_t * sys_layer; /**< @see lv_disp_get_layer_sys */ From 710226c6dbfeffa987b39ed34f378824dda68c83 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 25 Jun 2020 06:19:42 +0200 Subject: [PATCH 049/205] add user_data to themes --- CHANGELOG.md | 1 + src/lv_themes/lv_theme.h | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 178d34ed9..0723803d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ Available in the `dev` branch - DMA2D: Remove dependency on ST CubeMX HAL - Added `max_used` propriety to `lv_mem_monitor_t` struct - In `lv_init` test if the the strings are UTF-8 encoded. +- Add `user_data` to themes ### Bugfixes - `lv_img` fix invalidation area when angle or zoom changes diff --git a/src/lv_themes/lv_theme.h b/src/lv_themes/lv_theme.h index 4436d0f9e..d52bcb9aa 100644 --- a/src/lv_themes/lv_theme.h +++ b/src/lv_themes/lv_theme.h @@ -156,6 +156,7 @@ typedef struct _lv_theme_t { const lv_font_t * font_subtitle; const lv_font_t * font_title; uint32_t flags; + lv_theme_user_data_t user_data; } lv_theme_t; /********************** From f10f94bea3c04dc160e9c3108ec5796408ebcc06 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 25 Jun 2020 06:38:17 +0200 Subject: [PATCH 050/205] use void * as theme user data for backward compatibility --- src/lv_themes/lv_theme.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_themes/lv_theme.h b/src/lv_themes/lv_theme.h index d52bcb9aa..720648be8 100644 --- a/src/lv_themes/lv_theme.h +++ b/src/lv_themes/lv_theme.h @@ -156,7 +156,7 @@ typedef struct _lv_theme_t { const lv_font_t * font_subtitle; const lv_font_t * font_title; uint32_t flags; - lv_theme_user_data_t user_data; + void * user_data; } lv_theme_t; /********************** From eb006b3d39b55adc8a262c5a361bb28aac2fbb1a Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 25 Jun 2020 12:37:46 +0200 Subject: [PATCH 051/205] finialze screen animations --- src/lv_core/lv_disp.c | 223 +++++++++++++++++++++++++++++++++-- src/lv_core/lv_disp.h | 58 ++++++++- src/lv_core/lv_obj.c | 6 +- src/lv_core/lv_refr.c | 25 +++- src/lv_draw/lv_img_decoder.c | 3 + src/lv_hal/lv_hal_disp.c | 9 ++ src/lv_hal/lv_hal_disp.h | 10 +- 7 files changed, 312 insertions(+), 22 deletions(-) diff --git a/src/lv_core/lv_disp.c b/src/lv_core/lv_disp.c index 722be31ca..d3c6321f4 100644 --- a/src/lv_core/lv_disp.c +++ b/src/lv_core/lv_disp.c @@ -8,6 +8,7 @@ *********************/ #include "lv_disp.h" #include "../lv_misc/lv_math.h" +#include "../lv_core/lv_refr.h" /********************* * DEFINES @@ -20,7 +21,12 @@ /********************** * STATIC PROTOTYPES **********************/ + +#if LV_USE_ANIMATION static void scr_load_anim_start(lv_anim_t * a); +static void opa_scale_anim(lv_obj_t * obj, lv_anim_value_t v); +static void scr_anim_ready(lv_anim_t * a); +#endif /********************** * STATIC VARIABLES @@ -44,13 +50,30 @@ lv_obj_t * lv_disp_get_scr_act(lv_disp_t * disp) { if(!disp) disp = lv_disp_get_default(); if(!disp) { - LV_LOG_WARN("lv_scr_act: no display registered to get its act. screen"); + LV_LOG_WARN("no display registered to get its active screen"); return NULL; } return disp->act_scr; } +/** + * Return with a pointer to the previous screen. Only used during screen transitions. + * @param disp pointer to display which previous screen should be get. (NULL to use the default + * screen) + * @return pointer to the previous screen object or NULL if not used now + */ +lv_obj_t * lv_disp_get_scr_prev(lv_disp_t * disp) +{ + if(!disp) disp = lv_disp_get_default(); + if(!disp) { + LV_LOG_WARN("no display registered to get its previous screen"); + return NULL; + } + + return disp->prev_scr; +} + /** * Make a screen active * @param scr pointer to a screen @@ -97,6 +120,7 @@ lv_obj_t * lv_disp_get_layer_sys(lv_disp_t * disp) return disp->sys_layer; } + /** * Assign a screen to a display. * @param disp pointer to a display where to assign the screen @@ -116,21 +140,176 @@ void lv_disp_assign_screen(lv_disp_t * disp, lv_obj_t * scr) _lv_ll_chg_list(&old_disp->scr_ll, &disp->scr_ll, scr, true); } -void lv_scr_load_anim(lv_obj_t * scr) +/** + * Set the background color of a display + * @param disp pointer to a display + * @param color color of the background + */ +void lv_disp_set_bg_color(lv_disp_t * disp, lv_color_t color) { - lv_disp_t * d = lv_obj_get_disp(scr); + if(!disp) disp = lv_disp_get_default(); + if(!disp) { + LV_LOG_WARN("no display registered"); + return; + } + + disp->bg_color = color; + + lv_area_t a; + lv_area_set(&a, 0, 0, lv_disp_get_hor_res(disp) - 1, lv_disp_get_ver_res(disp) - 1); + _lv_inv_area(disp, &a); - lv_anim_t a; - lv_anim_init(&a); - lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t) lv_obj_set_x); - lv_anim_set_start_cb(&a, scr_load_anim_start); - lv_anim_set_time(&a, 2000); - lv_anim_set_delay(&a, 1000); - lv_anim_set_values(&a, lv_disp_get_hor_res(d), 0); - lv_anim_set_var(&a, scr); - lv_anim_start(&a); } +/** + * Set the background image of a display + * @param disp pointer to a display + * @param img_src path to file or pointer to an `lv_img_dsc_t` variable + */ +void lv_disp_set_bg_image(lv_disp_t * disp, const void * img_src) +{ + if(!disp) disp = lv_disp_get_default(); + if(!disp) { + LV_LOG_WARN("no display registered"); + return; + } + + disp->bg_img = img_src; + + lv_area_t a; + lv_area_set(&a, 0, 0, lv_disp_get_hor_res(disp) - 1, lv_disp_get_ver_res(disp) - 1); + _lv_inv_area(disp, &a); +} + + +/** + * Opacity of the background + * @param disp pointer to a display + * @param opa opacity (0..255) + */ +void lv_disp_set_bg_opa(lv_disp_t * disp, lv_opa_t opa) +{ + if(!disp) disp = lv_disp_get_default(); + if(!disp) { + LV_LOG_WARN("no display registered"); + return; + } + + disp->bg_opa = opa; + + lv_area_t a; + lv_area_set(&a, 0, 0, lv_disp_get_hor_res(disp) - 1, lv_disp_get_ver_res(disp) - 1); + _lv_inv_area(disp, &a); +} + +#if LV_USE_ANIMATION + +/** + * Switch screen with animation + * @param scr pointer to the new screen to load + * @param anim_type type of the animation from `lv_scr_load_anim_t`. E.g. `LV_SCR_LOAD_ANIM_MOVE_LEFT` + * @param time time of the animation + * @param delay delay before the transition + * @param auto_del true: automatically delete the old screen + */ +void lv_scr_load_anim(lv_obj_t * new_scr, lv_scr_load_anim_t anim_type, uint32_t time, uint32_t delay, bool auto_del) +{ + lv_disp_t * d = lv_obj_get_disp(new_scr); + + if(d->prev_scr && d->del_prev) { + lv_obj_del(d->prev_scr); + d->prev_scr = NULL; + } + + d->del_prev = auto_del; + + /*Be sure there is no other animation on the screens*/ + lv_anim_del(new_scr, NULL); + lv_anim_del(lv_scr_act(), NULL); + + /*Be sure both screens are in a normal position*/ + lv_obj_set_pos(new_scr, 0, 0); + lv_obj_set_pos(lv_scr_act(), 0, 0); + lv_style_remove_prop(lv_obj_get_local_style(new_scr, LV_OBJ_PART_MAIN), LV_STYLE_OPA_SCALE); + lv_style_remove_prop(lv_obj_get_local_style(lv_scr_act(), LV_OBJ_PART_MAIN), LV_STYLE_OPA_SCALE); + + lv_anim_t a_new; + lv_anim_init(&a_new); + lv_anim_set_var(&a_new, new_scr); + lv_anim_set_start_cb(&a_new, scr_load_anim_start); + lv_anim_set_ready_cb(&a_new, scr_anim_ready); + lv_anim_set_time(&a_new, time); + lv_anim_set_delay(&a_new, delay); + + lv_anim_t a_old; + lv_anim_init(&a_old); + lv_anim_set_var(&a_old, d->act_scr); + lv_anim_set_time(&a_old, time); + lv_anim_set_delay(&a_old, delay); + + switch(anim_type) { + case LV_SCR_LOAD_ANIM_NONE: + /* Create a dummy animation to apply the delay*/ + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x); + lv_anim_set_values(&a_new, 0, 0); + break; + case LV_SCR_LOAD_ANIM_OVER_LEFT: + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x); + lv_anim_set_values(&a_new, lv_disp_get_hor_res(d), 0); + break; + case LV_SCR_LOAD_ANIM_OVER_RIGHT: + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x); + lv_anim_set_values(&a_new, -lv_disp_get_hor_res(d), 0); + break; + case LV_SCR_LOAD_ANIM_OVER_TOP: + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_y); + lv_anim_set_values(&a_new, lv_disp_get_ver_res(d), 0); + break; + case LV_SCR_LOAD_ANIM_OVER_BOTTOM: + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_y); + lv_anim_set_values(&a_new, -lv_disp_get_ver_res(d), 0); + break; + case LV_SCR_LOAD_ANIM_MOVE_LEFT: + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x); + lv_anim_set_values(&a_new, lv_disp_get_hor_res(d), 0); + + lv_anim_set_exec_cb(&a_old, (lv_anim_exec_xcb_t) lv_obj_set_x); + lv_anim_set_values(&a_old, 0, -lv_disp_get_hor_res(d)); + break; + case LV_SCR_LOAD_ANIM_MOVE_RIGHT: + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x); + lv_anim_set_values(&a_new, -lv_disp_get_hor_res(d), 0); + + lv_anim_set_exec_cb(&a_old, (lv_anim_exec_xcb_t) lv_obj_set_x); + lv_anim_set_values(&a_old, 0, lv_disp_get_hor_res(d)); + break; + case LV_SCR_LOAD_ANIM_MOVE_TOP: + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_y); + lv_anim_set_values(&a_new, lv_disp_get_ver_res(d), 0); + + lv_anim_set_exec_cb(&a_old, (lv_anim_exec_xcb_t) lv_obj_set_y); + lv_anim_set_values(&a_old, 0, -lv_disp_get_ver_res(d)); + break; + case LV_SCR_LOAD_ANIM_MOVE_BOTTOM: + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_y); + lv_anim_set_values(&a_new, -lv_disp_get_ver_res(d), 0); + + lv_anim_set_exec_cb(&a_old, (lv_anim_exec_xcb_t) lv_obj_set_y); + lv_anim_set_values(&a_old, 0, lv_disp_get_ver_res(d)); + break; + + case LV_SCR_LOAD_ANIM_FADE_ON: + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) opa_scale_anim); + lv_anim_set_values(&a_new, LV_OPA_TRANSP, LV_OPA_COVER); + break; + } + + lv_anim_start(&a_new); + lv_anim_start(&a_old); +} + +#endif + /** * Get elapsed time since last user activity on a display (e.g. click) * @param disp pointer to an display (NULL to get the overall smallest inactivity) @@ -195,7 +374,27 @@ lv_task_t * _lv_disp_get_refr_task(lv_disp_t * disp) * STATIC FUNCTIONS **********************/ +#if LV_USE_ANIMATION static void scr_load_anim_start(lv_anim_t * a) { + lv_disp_t * d = lv_obj_get_disp(a->var); + d->prev_scr = lv_scr_act(); + lv_disp_load_scr(a->var); } + +static void opa_scale_anim(lv_obj_t * obj, lv_anim_value_t v) +{ + lv_obj_set_style_local_opa_scale(obj, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, v); +} + + +static void scr_anim_ready(lv_anim_t * a) +{ + lv_disp_t * d = lv_obj_get_disp(a->var); + + if(d->prev_scr && d->del_prev) lv_obj_del(d->prev_scr); + d->prev_scr = NULL; + lv_style_remove_prop(lv_obj_get_local_style(a->var, LV_OBJ_PART_MAIN), LV_STYLE_OPA_SCALE); +} +#endif diff --git a/src/lv_core/lv_disp.h b/src/lv_core/lv_disp.h index b09fc1dc6..dba2ddc37 100644 --- a/src/lv_core/lv_disp.h +++ b/src/lv_core/lv_disp.h @@ -24,6 +24,19 @@ extern "C" { * TYPEDEFS **********************/ +typedef enum { + LV_SCR_LOAD_ANIM_NONE, + LV_SCR_LOAD_ANIM_OVER_LEFT, + LV_SCR_LOAD_ANIM_OVER_RIGHT, + LV_SCR_LOAD_ANIM_OVER_TOP, + LV_SCR_LOAD_ANIM_OVER_BOTTOM, + LV_SCR_LOAD_ANIM_MOVE_LEFT, + LV_SCR_LOAD_ANIM_MOVE_RIGHT, + LV_SCR_LOAD_ANIM_MOVE_TOP, + LV_SCR_LOAD_ANIM_MOVE_BOTTOM, + LV_SCR_LOAD_ANIM_FADE_ON, +}lv_scr_load_anim_t; + /********************** * GLOBAL PROTOTYPES **********************/ @@ -36,6 +49,14 @@ extern "C" { */ lv_obj_t * lv_disp_get_scr_act(lv_disp_t * disp); +/** + * Return with a pointer to the previous screen. Only used during screen transitions. + * @param disp pointer to display which previous screen should be get. (NULL to use the default + * screen) + * @return pointer to the previous screen object or NULL if not used now + */ +lv_obj_t * lv_disp_get_scr_prev(lv_disp_t * disp); + /** * Make a screen active * @param scr pointer to a screen @@ -64,6 +85,41 @@ lv_obj_t * lv_disp_get_layer_sys(lv_disp_t * disp); */ void lv_disp_assign_screen(lv_disp_t * disp, lv_obj_t * scr); + +/** + * Set the background color of a display + * @param disp pointer to a display + * @param color color of the background + */ +void lv_disp_set_bg_color(lv_disp_t * disp, lv_color_t color); + +/** + * Set the background image of a display + * @param disp pointer to a display + * @param img_src path to file or pointer to an `lv_img_dsc_t` variable + */ +void lv_disp_set_bg_image(lv_disp_t * disp, const void * img_src); + +/** + * Opacity of the background + * @param disp pointer to a display + * @param opa opacity (0..255) + */ +void lv_disp_set_bg_opa(lv_disp_t * disp, lv_opa_t opa); + +#if LV_USE_ANIMATION + +/** + * Switch screen with animation + * @param scr pointer to the new screen to load + * @param anim_type type of the animation from `lv_scr_load_anim_t`. E.g. `LV_SCR_LOAD_ANIM_MOVE_LEFT` + * @param time time of the animation + * @param delay delay before the transition + * @param auto_del true: automatically delete the old screen + */ +void lv_scr_load_anim(lv_obj_t * scr, lv_scr_load_anim_t anim_type, uint32_t time, uint32_t delay, bool auto_del); + +#endif /** * Get elapsed time since last user activity on a display (e.g. click) * @param disp pointer to an display (NULL to get the overall smallest inactivity) @@ -123,8 +179,6 @@ static inline void lv_scr_load(lv_obj_t * scr) } -void lv_scr_load_anim(lv_obj_t * scr); - /********************** * MACROS **********************/ diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index e5fc6f1d5..dd7df33ca 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -501,10 +501,12 @@ void lv_obj_invalidate_area(const lv_obj_t * obj, const lv_area_t * area) if(lv_obj_get_hidden(obj)) return; - /*Invalidate the object only if it belongs to the 'LV_GC_ROOT(_lv_act_scr)'*/ + /*Invalidate the object only if it belongs to the curent or previous'*/ lv_obj_t * obj_scr = lv_obj_get_screen(obj); lv_disp_t * disp = lv_obj_get_disp(obj_scr); - if(obj_scr == lv_disp_get_scr_act(disp) || obj_scr == lv_disp_get_layer_top(disp) || + if(obj_scr == lv_disp_get_scr_act(disp) || + obj_scr == lv_disp_get_scr_prev(disp) || + obj_scr == lv_disp_get_layer_top(disp) || obj_scr == lv_disp_get_layer_sys(disp)) { /*Truncate the area to the object*/ diff --git a/src/lv_core/lv_refr.c b/src/lv_core/lv_refr.c index 5ba13e5fa..9644a0459 100644 --- a/src/lv_core/lv_refr.c +++ b/src/lv_core/lv_refr.c @@ -506,11 +506,28 @@ static void lv_refr_area_part(const lv_area_t * area_p) /*Draw a display background if there is no top object*/ if(top_act_scr == NULL && top_prev_scr == NULL) { - lv_draw_rect_dsc_t dsc; - lv_draw_rect_dsc_init(&dsc); - dsc.bg_color = LV_COLOR_RED; + if(disp_refr->bg_img) { + lv_draw_img_dsc_t dsc; + lv_draw_img_dsc_init(&dsc); + dsc.opa = disp_refr->bg_opa; + lv_img_header_t header; + lv_res_t res; + res = lv_img_decoder_get_info(disp_refr->bg_img, &header); + if(res == LV_RES_OK) { + lv_area_t a; + lv_area_set(&a, 0, 0, header.w - 1, header.h - 1); + lv_draw_img(&a, &start_mask, disp_refr->bg_img, &dsc); + } else { + LV_LOG_WARN("Can't draw the background image") + } + } else { + lv_draw_rect_dsc_t dsc; + lv_draw_rect_dsc_init(&dsc); + dsc.bg_color = disp_refr->bg_color; + dsc.bg_opa = disp_refr->bg_opa; + lv_draw_rect(&start_mask, &start_mask, &dsc); - lv_draw_rect(&start_mask, &start_mask, &dsc); + } } /*Refresh the previous screen if any*/ if(disp_refr->prev_scr) { diff --git a/src/lv_draw/lv_img_decoder.c b/src/lv_draw/lv_img_decoder.c index 490260870..245ab4711 100644 --- a/src/lv_draw/lv_img_decoder.c +++ b/src/lv_draw/lv_img_decoder.c @@ -89,6 +89,9 @@ void _lv_img_decoder_init(void) lv_res_t lv_img_decoder_get_info(const char * src, lv_img_header_t * header) { header->always_zero = 0; + header->h = 0; + header->w = 0; + header->cf = LV_IMG_CF_UNKNOWN; lv_res_t res = LV_RES_INV; lv_img_decoder_t * d; diff --git a/src/lv_hal/lv_hal_disp.c b/src/lv_hal/lv_hal_disp.c index 09d9648e7..d87afb55f 100644 --- a/src/lv_hal/lv_hal_disp.c +++ b/src/lv_hal/lv_hal_disp.c @@ -144,6 +144,15 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver) disp->inv_p = 0; disp->last_activity_time = 0; + disp->bg_color = LV_COLOR_WHITE; + disp->bg_img = NULL; +#if LV_COLOR_SCREEN_TRANSP + disp->bg_opa = LV_OPA_TRANSP; +#else + disp->bg_opa = LV_OPA_COVER; +#endif + + disp->prev_scr = NULL; disp->act_scr = lv_obj_create(NULL, NULL); /*Create a default screen on the display*/ disp->top_layer = lv_obj_create(NULL, NULL); /*Create top layer on the display*/ disp->sys_layer = lv_obj_create(NULL, NULL); /*Create sys layer on the display*/ diff --git a/src/lv_hal/lv_hal_disp.h b/src/lv_hal/lv_hal_disp.h index f607390b9..a3c627489 100644 --- a/src/lv_hal/lv_hal_disp.h +++ b/src/lv_hal/lv_hal_disp.h @@ -146,11 +146,17 @@ typedef struct _disp_t { /** Screens of the display*/ lv_ll_t scr_ll; - struct _lv_obj_t * act_scr; /**< Currently active screen on this display */ - struct _lv_obj_t * prev_scr; /**< Previous screen. Used during screen animations */ + struct _lv_obj_t * act_scr; /**< Currently active screen on this display */ + struct _lv_obj_t * prev_scr; /**< Previous screen. Used during screen animations */ struct _lv_obj_t * top_layer; /**< @see lv_disp_get_layer_top */ struct _lv_obj_t * sys_layer; /**< @see lv_disp_get_layer_sys */ + uint8_t del_prev :1; /**< 1: Automatically delete the previous screen when the screen load animation is ready */ + + lv_color_t bg_color; /**< Default display color when screens are transparent*/ + const void * bg_img; /**< An image source to display as wallpaper*/ + lv_opa_t bg_opa; /** Date: Thu, 25 Jun 2020 07:32:45 -0400 Subject: [PATCH 052/205] Fix spelling issue --- src/lv_conf_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index 70feabb8d..8b389a355 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -702,7 +702,7 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */ /* Support bidirectional texts. * Allows mixing Left-to-Right and Right-to-Left texts. - * The direction will be processed according to the Unicode Bidirectioanl Algorithm: + * The direction will be processed according to the Unicode Bidirectional Algorithm: * https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/ #ifndef LV_USE_BIDI #define LV_USE_BIDI 0 From ac7527fecfa18c1ebd467b1cf16b3f19a148d5e9 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 26 Jun 2020 09:39:19 +0200 Subject: [PATCH 053/205] minor optimization in lv_obj_init_draw_img_dsc --- src/lv_core/lv_obj.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 8e935b3b2..9259d3325 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -3298,8 +3298,9 @@ void lv_obj_init_draw_img_dsc(lv_obj_t * obj, uint8_t part, lv_draw_img_dsc_t * draw_dsc->pivot.y = lv_area_get_height(&obj->coords) / 2; draw_dsc->recolor_opa = lv_obj_get_style_image_recolor_opa(obj, part); - draw_dsc->recolor = lv_obj_get_style_image_recolor(obj, part); - + if(draw_dsc->recolor_opa > 0) { + draw_dsc->recolor = lv_obj_get_style_image_recolor(obj, part); + } #if LV_USE_BLEND_MODES draw_dsc->blend_mode = lv_obj_get_style_image_blend_mode(obj, part); #endif From 91f64c86627c8d4a2972cb68bcc5f93056039d87 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 26 Jun 2020 14:05:34 +0200 Subject: [PATCH 054/205] Add lv_theme_set_base() to allow easy extension of built-in (or any) themes --- CHANGELOG.md | 5 +- src/lv_core/lv_obj.h | 7 +- src/lv_font/lv_font_fmt_txt.c | 1 - src/lv_themes/lv_theme.c | 338 ++++++++++++++++++++++++++++-- src/lv_themes/lv_theme.h | 18 +- src/lv_themes/lv_theme_material.c | 88 -------- src/lv_themes/lv_theme_mono.c | 91 -------- src/lv_themes/lv_theme_template.c | 94 +-------- 8 files changed, 350 insertions(+), 292 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0723803d5..cc040fccf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,10 +9,11 @@ Available in the `dev` branch - Add `lv_chart_set_ext_array()` function - Set an external array of data points to use for the chart - Add `lv_chart_set_point_id()` function - Set an individual point value in the chart series directly based on index - Add `lv_chart_get_x_start_point()` function - Get the current index of the x-axis start point in the data array -- Add `lv_chart_get_point_id()` funtion - Get an individual point value in the chart series directly based on index +- Add `lv_chart_get_point_id()` function - Get an individual point value in the chart series directly based on index - Add `ext_buf_assigned` bit field to `lv_chart_series_t` structure - it's true if external buffer is assigned to series - Allow setting different font for the selected text in `lv_roller` -- Add `theme->apply_cb` to replace `theme->apply_xcb` to make it compatible with the Micropython binding +- Add `theme->apply_cb` to replace `theme->apply_xcb` to make it compatible with the MicroPython binding +- Add `lv_theme_set_base()` to allow easy extension of built-in (or any) themes. ## v7.1.0 (planned on 07.07.2020) *Available in the `master` branch* diff --git a/src/lv_core/lv_obj.h b/src/lv_core/lv_obj.h index 88b71cb99..a4419b683 100644 --- a/src/lv_core/lv_obj.h +++ b/src/lv_core/lv_obj.h @@ -47,6 +47,9 @@ extern "C" { #define LV_EXT_CLICK_AREA_TINY 1 #define LV_EXT_CLICK_AREA_FULL 2 +#define _LV_OBJ_PART_VIRTUAL_FIRST 0x01 +#define _LV_OBJ_PART_REAL_FIRST 0x40 + /********************** * TYPEDEFS **********************/ @@ -247,8 +250,8 @@ typedef struct _lv_obj_t { enum { LV_OBJ_PART_MAIN, - _LV_OBJ_PART_VIRTUAL_LAST = 0x01, - _LV_OBJ_PART_REAL_LAST = 0x40, + _LV_OBJ_PART_VIRTUAL_LAST = _LV_OBJ_PART_VIRTUAL_FIRST, + _LV_OBJ_PART_REAL_LAST = _LV_OBJ_PART_REAL_FIRST, LV_OBJ_PART_ALL = 0xFF, }; diff --git a/src/lv_font/lv_font_fmt_txt.c b/src/lv_font/lv_font_fmt_txt.c index 731ada0e6..abcb2f01e 100644 --- a/src/lv_font/lv_font_fmt_txt.c +++ b/src/lv_font/lv_font_fmt_txt.c @@ -44,7 +44,6 @@ static inline void bits_write(uint8_t * out, uint32_t bit_pos, uint8_t val, uint static inline void rle_init(const uint8_t * in, uint8_t bpp); static inline uint8_t rle_next(void); - /********************** * STATIC VARIABLES **********************/ diff --git a/src/lv_themes/lv_theme.c b/src/lv_themes/lv_theme.c index f32008c72..276e21d12 100644 --- a/src/lv_themes/lv_theme.c +++ b/src/lv_themes/lv_theme.c @@ -6,8 +6,7 @@ /********************* * INCLUDES *********************/ -#include "lv_theme.h" -#include "../lv_core/lv_obj.h" +#include "../../lvgl.h" /********************* * DEFINES @@ -20,6 +19,8 @@ /********************** * STATIC PROTOTYPES **********************/ +static void apply_theme(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name); +static void clear_styles(lv_obj_t * obj, lv_theme_style_t name); /********************** * STATIC VARIABLES @@ -53,6 +54,34 @@ lv_theme_t * lv_theme_get_act(void) return act_theme; } +/** + * Apply the active theme on an object + * @param obj pointer to an object + * @param name the name of the theme element to apply. E.g. `LV_THEME_BTN` + */ +void lv_theme_apply(lv_obj_t * obj, lv_theme_style_t name) +{ + /* Remove the existing styles from all part of the object. */ + clear_styles(obj, name); + + /*Apply the theme including the base theme(s)*/ + + apply_theme(act_theme, obj, name); +} + + +/** + * Set a base theme for a theme. + * The styles from the base them will be added before the styles of the current theme. + * Arbitrary long chain of themes can be created by setting base themes. + * @param new pointer to theme which base should be set + * @param base pointer to the base theme + */ +void lv_theme_set_base(lv_theme_t * new, lv_theme_t * base) +{ + new->base_theme = base; +} + /** * Get the small font of the theme * @return pointer to the font @@ -116,18 +145,299 @@ uint32_t lv_theme_get_flags(void) return act_theme->flags; } -void lv_theme_apply(lv_obj_t * obj, lv_theme_style_t name) -{ - /*apply_xcb is deprecated, use apply_cb instead*/ - if (act_theme->apply_xcb) { - act_theme->apply_xcb(obj, name); - } - else if(act_theme->apply_cb) { - act_theme->apply_cb(act_theme, obj, name); - } -} - - /********************** * STATIC FUNCTIONS **********************/ + +static void apply_theme(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) +{ + if(th->base_theme) { + apply_theme(th->base_theme, obj, name); + } + + /*apply_xcb is deprecated, use apply_cb instead*/ + if (th->apply_xcb) { + th->apply_xcb(obj, name); + } + else if(th->apply_cb) { + th->apply_cb(act_theme, obj, name); + } +} + +static void clear_styles(lv_obj_t * obj, lv_theme_style_t name) +{ + switch(name) { + case LV_THEME_NONE: + break; + + case LV_THEME_SCR: + lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN); + break; + case LV_THEME_OBJ: + lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN); + break; +#if LV_USE_CONT + case LV_THEME_CONT: + lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN); + break; +#endif + +#if LV_USE_BTN + case LV_THEME_BTN: + lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN); + break; +#endif + +#if LV_USE_BTNMATRIX + case LV_THEME_BTNMATRIX: + lv_obj_clean_style_list(obj, LV_BTNMATRIX_PART_BG); + lv_obj_clean_style_list(obj, LV_BTNMATRIX_PART_BTN); + break; +#endif + +#if LV_USE_KEYBOARD + case LV_THEME_KEYBOARD: + lv_obj_clean_style_list(obj, LV_KEYBOARD_PART_BG); + lv_obj_clean_style_list(obj, LV_KEYBOARD_PART_BTN); + break; +#endif + +#if LV_USE_BAR + case LV_THEME_BAR: + lv_obj_clean_style_list(obj, LV_BAR_PART_BG); + lv_obj_clean_style_list(obj, LV_BAR_PART_INDIC); + break; +#endif + +#if LV_USE_SWITCH + case LV_THEME_SWITCH: + lv_obj_clean_style_list(obj, LV_SWITCH_PART_BG); + lv_obj_clean_style_list(obj, LV_SWITCH_PART_INDIC); + lv_obj_clean_style_list(obj, LV_SWITCH_PART_KNOB); + break; +#endif + +#if LV_USE_CANVAS + case LV_THEME_CANVAS: + lv_obj_clean_style_list(obj, LV_CANVAS_PART_MAIN); + break; +#endif + +#if LV_USE_IMG + case LV_THEME_IMAGE: + lv_obj_clean_style_list(obj, LV_IMG_PART_MAIN); + break; +#endif + +#if LV_USE_IMGBTN + case LV_THEME_IMGBTN: + lv_obj_clean_style_list(obj, LV_IMG_PART_MAIN); + break; +#endif + +#if LV_USE_LABEL + case LV_THEME_LABEL: + lv_obj_clean_style_list(obj, LV_LABEL_PART_MAIN); + break; +#endif + +#if LV_USE_LINE + case LV_THEME_LINE: + lv_obj_clean_style_list(obj, LV_LABEL_PART_MAIN); + break; +#endif + +#if LV_USE_ARC + case LV_THEME_ARC: + lv_obj_clean_style_list(obj, LV_ARC_PART_BG); + lv_obj_clean_style_list(obj, LV_ARC_PART_INDIC); + break; +#endif + +#if LV_USE_SPINNER + case LV_THEME_SPINNER: + lv_obj_clean_style_list(obj, LV_SPINNER_PART_BG); + lv_obj_clean_style_list(obj, LV_SPINNER_PART_INDIC); + break; +#endif + +#if LV_USE_SLIDER + case LV_THEME_SLIDER: + lv_obj_clean_style_list(obj, LV_SLIDER_PART_BG); + lv_obj_clean_style_list(obj, LV_SLIDER_PART_INDIC); + lv_obj_clean_style_list(obj, LV_SLIDER_PART_KNOB); + break; +#endif + +#if LV_USE_CHECKBOX + case LV_THEME_CHECKBOX: + lv_obj_clean_style_list(obj, LV_CHECKBOX_PART_BG); + lv_obj_clean_style_list(obj, LV_CHECKBOX_PART_BULLET); + break; +#endif + +#if LV_USE_MSGBOX + case LV_THEME_MSGBOX: + lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BG); + break; + + case LV_THEME_MSGBOX_BTNS: + lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BTN_BG); + lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BTN); + break; + +#endif +#if LV_USE_LED + case LV_THEME_LED: + lv_obj_clean_style_list(obj, LV_LED_PART_MAIN); + break; +#endif +#if LV_USE_PAGE + case LV_THEME_PAGE: + lv_obj_clean_style_list(obj, LV_PAGE_PART_BG); + lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE); + lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLBAR); + break; +#endif +#if LV_USE_TABVIEW + case LV_THEME_TABVIEW: + lv_obj_clean_style_list(obj, LV_TABVIEW_PART_BG); + lv_obj_clean_style_list(obj, LV_TABVIEW_PART_BG_SCRLLABLE); + lv_obj_clean_style_list(obj, LV_TABVIEW_PART_TAB_BG); + lv_obj_clean_style_list(obj, LV_TABVIEW_PART_INDIC); + lv_obj_clean_style_list(obj, LV_TABVIEW_PART_TAB_BTN); + break; + + case LV_THEME_TABVIEW_PAGE: + lv_obj_clean_style_list(obj, LV_PAGE_PART_BG); + lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE); + break; +#endif + +#if LV_USE_TILEVIEW + case LV_THEME_TILEVIEW: + lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_BG); + lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR); + lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH); + break; +#endif + + +#if LV_USE_ROLLER + case LV_THEME_ROLLER: + lv_obj_clean_style_list(obj, LV_ROLLER_PART_BG); + lv_obj_clean_style_list(obj, LV_ROLLER_PART_SELECTED); + break; +#endif + + +#if LV_USE_OBJMASK + case LV_THEME_OBJMASK: + lv_obj_clean_style_list(obj, LV_OBJMASK_PART_MAIN); + break; +#endif + +#if LV_USE_LIST + case LV_THEME_LIST: + lv_obj_clean_style_list(obj, LV_LIST_PART_BG); + lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLABLE); + lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLBAR); + break; + + case LV_THEME_LIST_BTN: + lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN); + break; +#endif + +#if LV_USE_DROPDOWN + case LV_THEME_DROPDOWN: + lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_MAIN); + lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_LIST); + lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR); + lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SELECTED); + break; +#endif + +#if LV_USE_CHART + case LV_THEME_CHART: + lv_obj_clean_style_list(obj, LV_CHART_PART_BG); + lv_obj_clean_style_list(obj, LV_CHART_PART_SERIES_BG); + lv_obj_clean_style_list(obj, LV_CHART_PART_SERIES); + break; +#endif +#if LV_USE_TABLE + case LV_THEME_TABLE: + lv_obj_clean_style_list(obj, LV_TABLE_PART_BG); + lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL1); + lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL2); + lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL3); + lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL4); + break; +#endif + +#if LV_USE_WIN + case LV_THEME_WIN: + lv_obj_clean_style_list(obj, LV_WIN_PART_BG); + lv_obj_clean_style_list(obj, LV_WIN_PART_SCROLLBAR); + lv_obj_clean_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE); + lv_obj_clean_style_list(obj, LV_WIN_PART_HEADER); + break; + + case LV_THEME_WIN_BTN: + lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN); + break; +#endif + +#if LV_USE_TEXTAREA + case LV_THEME_TEXTAREA: + lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_BG); + lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER); + lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_CURSOR); + lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR); + break; +#endif + + +#if LV_USE_SPINBOX + case LV_THEME_SPINBOX: + lv_obj_clean_style_list(obj, LV_SPINBOX_PART_BG); + lv_obj_clean_style_list(obj, LV_SPINBOX_PART_CURSOR); + break; + + case LV_THEME_SPINBOX_BTN: + lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN); + break; +#endif + +#if LV_USE_CALENDAR + case LV_THEME_CALENDAR: + lv_obj_clean_style_list(obj, LV_CALENDAR_PART_BG); + lv_obj_clean_style_list(obj, LV_CALENDAR_PART_DATE); + lv_obj_clean_style_list(obj, LV_CALENDAR_PART_HEADER); + lv_obj_clean_style_list(obj, LV_CALENDAR_PART_DAY_NAMES); + break; +#endif +#if LV_USE_CPICKER + case LV_THEME_CPICKER: + lv_obj_clean_style_list(obj, LV_CPICKER_PART_MAIN); + lv_obj_clean_style_list(obj, LV_CPICKER_PART_KNOB); + break; +#endif + +#if LV_USE_LINEMETER + case LV_THEME_LINEMETER: + lv_obj_clean_style_list(obj, LV_LINEMETER_PART_MAIN); + break; +#endif +#if LV_USE_GAUGE + case LV_THEME_GAUGE: + lv_obj_clean_style_list(obj, LV_GAUGE_PART_MAIN); + lv_obj_clean_style_list(obj, LV_GAUGE_PART_MAJOR); + lv_obj_clean_style_list(obj, LV_GAUGE_PART_NEEDLE); + break; +#endif + default: + break; + } + +} diff --git a/src/lv_themes/lv_theme.h b/src/lv_themes/lv_theme.h index 720648be8..9941d2c99 100644 --- a/src/lv_themes/lv_theme.h +++ b/src/lv_themes/lv_theme.h @@ -114,7 +114,7 @@ typedef enum { #endif #if LV_USE_SPINBOX LV_THEME_SPINBOX, - LV_THEME_SPINBOX_BTN, /*Button extra for spinbox*/ + LV_THEME_SPINBOX_BTN, /*Control button for the spinbox*/ #endif #if LV_USE_SPINNER LV_THEME_SPINNER, @@ -149,6 +149,7 @@ typedef enum { typedef struct _lv_theme_t { void (*apply_xcb)(lv_obj_t *, lv_theme_style_t); /*Deprecated: use `apply_cb` instead*/ void (*apply_cb)(struct _lv_theme_t *, lv_obj_t *, lv_theme_style_t); + struct _lv_theme_t * base_theme; /**< Apply the current theme's style on top of this theme.*/ lv_color_t color_primary; lv_color_t color_secondary; const lv_font_t * font_small; @@ -176,9 +177,21 @@ void lv_theme_set_act(lv_theme_t * th); */ lv_theme_t * lv_theme_get_act(void); - +/** + * Apply the active theme on an object + * @param obj pointer to an object + * @param name the name of the theme element to apply. E.g. `LV_THEME_BTN` + */ void lv_theme_apply(lv_obj_t * obj, lv_theme_style_t name); +/** + * Set a base theme for a theme. + * The styles from the base them will be added before the styles of the current theme. + * Arbitrary long chain of themes can be created by setting base themes. + * @param new pointer to theme which base should be set + * @param base pointer to the base theme + */ +void lv_theme_set_base(lv_theme_t * new, lv_theme_t * base); /** * Get the small font of the theme @@ -222,7 +235,6 @@ lv_color_t lv_theme_get_color_secondary(void); */ uint32_t lv_theme_get_flags(void); - /********************** * MACROS **********************/ diff --git a/src/lv_themes/lv_theme_material.c b/src/lv_themes/lv_theme_material.c index e60ef8b43..74fd2ab90 100644 --- a/src/lv_themes/lv_theme_material.c +++ b/src/lv_themes/lv_theme_material.c @@ -950,18 +950,15 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) break; case LV_THEME_SCR: - lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN); list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN); _lv_style_list_add_style(list, &styles->scr); break; case LV_THEME_OBJ: - lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN); list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); break; #if LV_USE_CONT case LV_THEME_CONT: - lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN); list = lv_obj_get_style_list(obj, LV_CONT_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); break; @@ -969,7 +966,6 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_BTN case LV_THEME_BTN: - lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN); list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); _lv_style_list_add_style(list, &styles->btn); break; @@ -977,12 +973,10 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_BTNMATRIX case LV_THEME_BTNMATRIX: - lv_obj_clean_style_list(obj, LV_BTNMATRIX_PART_BG); list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->pad_small); - lv_obj_clean_style_list(obj, LV_BTNMATRIX_PART_BTN); list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BTN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->bg_click); @@ -991,12 +985,10 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_KEYBOARD case LV_THEME_KEYBOARD: - lv_obj_clean_style_list(obj, LV_KEYBOARD_PART_BG); list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BG); _lv_style_list_add_style(list, &styles->scr); _lv_style_list_add_style(list, &styles->kb_bg); - lv_obj_clean_style_list(obj, LV_KEYBOARD_PART_BTN); list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BTN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->bg_click); @@ -1005,11 +997,9 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_BAR case LV_THEME_BAR: - lv_obj_clean_style_list(obj, LV_BAR_PART_BG); list = lv_obj_get_style_list(obj, LV_BAR_PART_BG); _lv_style_list_add_style(list, &styles->bar_bg); - lv_obj_clean_style_list(obj, LV_BAR_PART_INDIC); list = lv_obj_get_style_list(obj, LV_BAR_PART_INDIC); _lv_style_list_add_style(list, &styles->bar_indic); break; @@ -1017,15 +1007,12 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_SWITCH case LV_THEME_SWITCH: - lv_obj_clean_style_list(obj, LV_SWITCH_PART_BG); list = lv_obj_get_style_list(obj, LV_SWITCH_PART_BG); _lv_style_list_add_style(list, &styles->bar_bg); - lv_obj_clean_style_list(obj, LV_SWITCH_PART_INDIC); list = lv_obj_get_style_list(obj, LV_SWITCH_PART_INDIC); _lv_style_list_add_style(list, &styles->bar_indic); - lv_obj_clean_style_list(obj, LV_SWITCH_PART_KNOB); list = lv_obj_get_style_list(obj, LV_SWITCH_PART_KNOB); _lv_style_list_add_style(list, &styles->sw_knob); break; @@ -1033,42 +1020,35 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_CANVAS case LV_THEME_CANVAS: - lv_obj_clean_style_list(obj, LV_CANVAS_PART_MAIN); break; #endif #if LV_USE_IMG case LV_THEME_IMAGE: - lv_obj_clean_style_list(obj, LV_IMG_PART_MAIN); break; #endif #if LV_USE_IMGBTN case LV_THEME_IMGBTN: - lv_obj_clean_style_list(obj, LV_IMG_PART_MAIN); break; #endif #if LV_USE_LABEL case LV_THEME_LABEL: - lv_obj_clean_style_list(obj, LV_LABEL_PART_MAIN); break; #endif #if LV_USE_LINE case LV_THEME_LINE: - lv_obj_clean_style_list(obj, LV_LABEL_PART_MAIN); break; #endif #if LV_USE_ARC case LV_THEME_ARC: - lv_obj_clean_style_list(obj, LV_ARC_PART_BG); list = lv_obj_get_style_list(obj, LV_ARC_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->arc_bg); - lv_obj_clean_style_list(obj, LV_ARC_PART_INDIC); list = lv_obj_get_style_list(obj, LV_ARC_PART_INDIC); _lv_style_list_add_style(list, &styles->arc_indic); break; @@ -1076,11 +1056,9 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_SPINNER case LV_THEME_SPINNER: - lv_obj_clean_style_list(obj, LV_SPINNER_PART_BG); list = lv_obj_get_style_list(obj, LV_SPINNER_PART_BG); _lv_style_list_add_style(list, &styles->arc_bg); - lv_obj_clean_style_list(obj, LV_SPINNER_PART_INDIC); list = lv_obj_get_style_list(obj, LV_SPINNER_PART_INDIC); _lv_style_list_add_style(list, &styles->arc_indic); break; @@ -1088,16 +1066,13 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_SLIDER case LV_THEME_SLIDER: - lv_obj_clean_style_list(obj, LV_SLIDER_PART_BG); list = lv_obj_get_style_list(obj, LV_SLIDER_PART_BG); _lv_style_list_add_style(list, &styles->bar_bg); _lv_style_list_add_style(list, &styles->slider_bg); - lv_obj_clean_style_list(obj, LV_SLIDER_PART_INDIC); list = lv_obj_get_style_list(obj, LV_SLIDER_PART_INDIC); _lv_style_list_add_style(list, &styles->bar_indic); - lv_obj_clean_style_list(obj, LV_SLIDER_PART_KNOB); list = lv_obj_get_style_list(obj, LV_SLIDER_PART_KNOB); _lv_style_list_add_style(list, &styles->slider_knob); break; @@ -1105,11 +1080,9 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_CHECKBOX case LV_THEME_CHECKBOX: - lv_obj_clean_style_list(obj, LV_CHECKBOX_PART_BG); list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BG); _lv_style_list_add_style(list, &styles->cb_bg); - lv_obj_clean_style_list(obj, LV_CHECKBOX_PART_BULLET); list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BULLET); _lv_style_list_add_style(list, &styles->btn); _lv_style_list_add_style(list, &styles->cb_bullet); @@ -1118,18 +1091,15 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_MSGBOX case LV_THEME_MSGBOX: - lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BG); list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->mbox_bg); break; case LV_THEME_MSGBOX_BTNS: - lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BTN_BG); list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN_BG); _lv_style_list_add_style(list, &styles->pad_small); - lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BTN); list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN); _lv_style_list_add_style(list, &styles->btn); break; @@ -1137,27 +1107,22 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #endif #if LV_USE_LED case LV_THEME_LED: - lv_obj_clean_style_list(obj, LV_LED_PART_MAIN); list = lv_obj_get_style_list(obj, LV_LED_PART_MAIN); _lv_style_list_add_style(list, &styles->led); break; #endif #if LV_USE_PAGE case LV_THEME_PAGE: - lv_obj_clean_style_list(obj, LV_PAGE_PART_BG); list = lv_obj_get_style_list(obj, LV_PAGE_PART_BG); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE); list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE); _lv_style_list_add_style(list, &styles->pad_inner); - lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLBAR); list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->sb); #if LV_USE_ANIMATION - lv_obj_clean_style_list(obj, LV_PAGE_PART_EDGE_FLASH); list = lv_obj_get_style_list(obj, LV_PAGE_PART_EDGE_FLASH); _lv_style_list_add_style(list, &styles->edge_flash); #endif @@ -1165,29 +1130,20 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #endif #if LV_USE_TABVIEW case LV_THEME_TABVIEW: - lv_obj_clean_style_list(obj, LV_TABVIEW_PART_BG); list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_BG); _lv_style_list_add_style(list, &styles->scr); - lv_obj_clean_style_list(obj, LV_TABVIEW_PART_BG_SCRLLABLE); - - lv_obj_clean_style_list(obj, LV_TABVIEW_PART_TAB_BG); list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BG); _lv_style_list_add_style(list, &styles->tabview_btns_bg); - lv_obj_clean_style_list(obj, LV_TABVIEW_PART_INDIC); list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_INDIC); _lv_style_list_add_style(list, &styles->tabview_indic); - lv_obj_clean_style_list(obj, LV_TABVIEW_PART_TAB_BTN); list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BTN); _lv_style_list_add_style(list, &styles->tabview_btns); break; case LV_THEME_TABVIEW_PAGE: - lv_obj_clean_style_list(obj, LV_PAGE_PART_BG); - - lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE); list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE); _lv_style_list_add_style(list, &styles->tabview_page_scrl); @@ -1196,16 +1152,13 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_TILEVIEW case LV_THEME_TILEVIEW: - lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_BG); list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_BG); _lv_style_list_add_style(list, &styles->scr); - lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR); list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->sb); #if LV_USE_ANIMATION - lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH); list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH); _lv_style_list_add_style(list, &styles->edge_flash); #endif @@ -1215,12 +1168,10 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_ROLLER case LV_THEME_ROLLER: - lv_obj_clean_style_list(obj, LV_ROLLER_PART_BG); list = lv_obj_get_style_list(obj, LV_ROLLER_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->roller_bg); - lv_obj_clean_style_list(obj, LV_ROLLER_PART_SELECTED); list = lv_obj_get_style_list(obj, LV_ROLLER_PART_SELECTED); _lv_style_list_add_style(list, &styles->roller_sel); break; @@ -1229,27 +1180,22 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_OBJMASK case LV_THEME_OBJMASK: - lv_obj_clean_style_list(obj, LV_OBJMASK_PART_MAIN); list = lv_obj_get_style_list(obj, LV_OBJMASK_PART_MAIN); break; #endif #if LV_USE_LIST case LV_THEME_LIST: - lv_obj_clean_style_list(obj, LV_LIST_PART_BG); list = lv_obj_get_style_list(obj, LV_LIST_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->list_bg); - lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLABLE); - lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLBAR); list = lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->sb); break; case LV_THEME_LIST_BTN: - lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN); list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); _lv_style_list_add_style(list, &styles->list_btn); break; @@ -1257,22 +1203,18 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_DROPDOWN case LV_THEME_DROPDOWN: - lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_MAIN); list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->bg_click); _lv_style_list_add_style(list, &styles->pad_small); - lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_LIST); list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_LIST); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->ddlist_page); - lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR); list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->sb); - lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SELECTED); list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SELECTED); _lv_style_list_add_style(list, &styles->ddlist_sel); break; @@ -1280,41 +1222,33 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_CHART case LV_THEME_CHART: - lv_obj_clean_style_list(obj, LV_CHART_PART_BG); list = lv_obj_get_style_list(obj, LV_CHART_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->chart_bg); _lv_style_list_add_style(list, &styles->pad_small); - lv_obj_clean_style_list(obj, LV_CHART_PART_SERIES_BG); list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES_BG); _lv_style_list_add_style(list, &styles->pad_small); _lv_style_list_add_style(list, &styles->chart_series_bg); - lv_obj_clean_style_list(obj, LV_CHART_PART_SERIES); list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES); _lv_style_list_add_style(list, &styles->chart_series); break; #endif #if LV_USE_TABLE case LV_THEME_TABLE: - lv_obj_clean_style_list(obj, LV_TABLE_PART_BG); list = lv_obj_get_style_list(obj, LV_TABLE_PART_BG); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL1); list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL1); _lv_style_list_add_style(list, &styles->table_cell); - lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL2); list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL2); _lv_style_list_add_style(list, &styles->table_cell); - lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL3); list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL3); _lv_style_list_add_style(list, &styles->table_cell); - lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL4); list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL4); _lv_style_list_add_style(list, &styles->table_cell); break; @@ -1322,25 +1256,20 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_WIN case LV_THEME_WIN: - lv_obj_clean_style_list(obj, LV_WIN_PART_BG); list = lv_obj_get_style_list(obj, LV_WIN_PART_BG); _lv_style_list_add_style(list, &styles->scr); - lv_obj_clean_style_list(obj, LV_WIN_PART_SCROLLBAR); list = lv_obj_get_style_list(obj, LV_WIN_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->sb); - lv_obj_clean_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE); list = lv_obj_get_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE); _lv_style_list_add_style(list, &styles->tabview_page_scrl); - lv_obj_clean_style_list(obj, LV_WIN_PART_HEADER); list = lv_obj_get_style_list(obj, LV_WIN_PART_HEADER); _lv_style_list_add_style(list, &styles->tabview_btns_bg); break; case LV_THEME_WIN_BTN: - lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN); list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); _lv_style_list_add_style(list, &styles->tabview_btns); break; @@ -1348,20 +1277,16 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_TEXTAREA case LV_THEME_TEXTAREA: - lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_BG); list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->pad_small); - lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER); list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER); _lv_style_list_add_style(list, &styles->ta_placeholder); - lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_CURSOR); list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_CURSOR); _lv_style_list_add_style(list, &styles->ta_cursor); - lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR); list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->sb); break; @@ -1371,18 +1296,15 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_SPINBOX case LV_THEME_SPINBOX: - lv_obj_clean_style_list(obj, LV_SPINBOX_PART_BG); list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->pad_small); - lv_obj_clean_style_list(obj, LV_SPINBOX_PART_CURSOR); list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_CURSOR); _lv_style_list_add_style(list, &styles->spinbox_cursor); break; case LV_THEME_SPINBOX_BTN: - lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN); list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->bg_click); @@ -1391,30 +1313,24 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_CALENDAR case LV_THEME_CALENDAR: - lv_obj_clean_style_list(obj, LV_CALENDAR_PART_BG); list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_BG); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_CALENDAR_PART_DATE); list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DATE); _lv_style_list_add_style(list, &styles->calendar_date_nums); - lv_obj_clean_style_list(obj, LV_CALENDAR_PART_HEADER); list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_HEADER); _lv_style_list_add_style(list, &styles->calendar_header); - lv_obj_clean_style_list(obj, LV_CALENDAR_PART_DAY_NAMES); list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DAY_NAMES); _lv_style_list_add_style(list, &styles->calendar_daynames); break; #endif #if LV_USE_CPICKER case LV_THEME_CPICKER: - lv_obj_clean_style_list(obj, LV_CPICKER_PART_MAIN); list = lv_obj_get_style_list(obj, LV_CPICKER_PART_MAIN); _lv_style_list_add_style(list, &styles->cpicker_bg); - lv_obj_clean_style_list(obj, LV_CPICKER_PART_KNOB); list = lv_obj_get_style_list(obj, LV_CPICKER_PART_KNOB); _lv_style_list_add_style(list, &styles->cpicker_indic); break; @@ -1422,7 +1338,6 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_LINEMETER case LV_THEME_LINEMETER: - lv_obj_clean_style_list(obj, LV_LINEMETER_PART_MAIN); list = lv_obj_get_style_list(obj, LV_LINEMETER_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->lmeter); @@ -1430,16 +1345,13 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #endif #if LV_USE_GAUGE case LV_THEME_GAUGE: - lv_obj_clean_style_list(obj, LV_GAUGE_PART_MAIN); list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->gauge_main); - lv_obj_clean_style_list(obj, LV_GAUGE_PART_MAJOR); list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAJOR); _lv_style_list_add_style(list, &styles->gauge_strong); - lv_obj_clean_style_list(obj, LV_GAUGE_PART_NEEDLE); list = lv_obj_get_style_list(obj, LV_GAUGE_PART_NEEDLE); _lv_style_list_add_style(list, &styles->gauge_needle); break; diff --git a/src/lv_themes/lv_theme_mono.c b/src/lv_themes/lv_theme_mono.c index 67727f787..466f84064 100644 --- a/src/lv_themes/lv_theme_mono.c +++ b/src/lv_themes/lv_theme_mono.c @@ -570,18 +570,15 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) break; case LV_THEME_SCR: - lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN); list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN); _lv_style_list_add_style(list, &styles->scr); break; case LV_THEME_OBJ: - lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN); list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); break; #if LV_USE_CONT case LV_THEME_CONT: - lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN); list = lv_obj_get_style_list(obj, LV_CONT_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); break; @@ -589,7 +586,6 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_BTN case LV_THEME_BTN: - lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN); list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); @@ -598,11 +594,9 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_BTNMATRIX case LV_THEME_BTNMATRIX: - lv_obj_clean_style_list(obj, LV_BTNMATRIX_PART_BG); list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BG); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_BTNMATRIX_PART_BTN); list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BTN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); @@ -611,12 +605,10 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_KEYBOARD case LV_THEME_KEYBOARD: - lv_obj_clean_style_list(obj, LV_KEYBOARD_PART_BG); list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->pad_small); - lv_obj_clean_style_list(obj, LV_KEYBOARD_PART_BTN); list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BTN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); @@ -625,13 +617,11 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_BAR case LV_THEME_BAR: - lv_obj_clean_style_list(obj, LV_BAR_PART_BG); list = lv_obj_get_style_list(obj, LV_BAR_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->pad_none); _lv_style_list_add_style(list, &styles->round); - lv_obj_clean_style_list(obj, LV_BAR_PART_INDIC); list = lv_obj_get_style_list(obj, LV_BAR_PART_INDIC); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->fg_color); @@ -641,18 +631,15 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_SWITCH case LV_THEME_SWITCH: - lv_obj_clean_style_list(obj, LV_SWITCH_PART_BG); list = lv_obj_get_style_list(obj, LV_SWITCH_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->pad_none); _lv_style_list_add_style(list, &styles->round); - lv_obj_clean_style_list(obj, LV_SWITCH_PART_INDIC); list = lv_obj_get_style_list(obj, LV_SWITCH_PART_INDIC); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->fg_color); - lv_obj_clean_style_list(obj, LV_SWITCH_PART_KNOB); list = lv_obj_get_style_list(obj, LV_SWITCH_PART_KNOB); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->pad_none); @@ -662,46 +649,39 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_CANVAS case LV_THEME_CANVAS: - lv_obj_clean_style_list(obj, LV_CANVAS_PART_MAIN); list = lv_obj_get_style_list(obj, LV_CANVAS_PART_MAIN); break; #endif #if LV_USE_IMG case LV_THEME_IMAGE: - lv_obj_clean_style_list(obj, LV_IMG_PART_MAIN); list = lv_obj_get_style_list(obj, LV_IMG_PART_MAIN); break; #endif #if LV_USE_IMGBTN case LV_THEME_IMGBTN: - lv_obj_clean_style_list(obj, LV_IMG_PART_MAIN); list = lv_obj_get_style_list(obj, LV_IMG_PART_MAIN); break; #endif #if LV_USE_LABEL case LV_THEME_LABEL: - lv_obj_clean_style_list(obj, LV_LABEL_PART_MAIN); list = lv_obj_get_style_list(obj, LV_LABEL_PART_MAIN); break; #endif #if LV_USE_LINE case LV_THEME_LINE: - lv_obj_clean_style_list(obj, LV_LABEL_PART_MAIN); list = lv_obj_get_style_list(obj, LV_LABEL_PART_MAIN); break; #endif #if LV_USE_ARC case LV_THEME_ARC: - lv_obj_clean_style_list(obj, LV_ARC_PART_BG); list = lv_obj_get_style_list(obj, LV_ARC_PART_BG); _lv_style_list_add_style(list, &styles->arc_bg); - lv_obj_clean_style_list(obj, LV_ARC_PART_INDIC); list = lv_obj_get_style_list(obj, LV_ARC_PART_INDIC); _lv_style_list_add_style(list, &styles->arc_indic); break; @@ -709,12 +689,10 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_SPINNER case LV_THEME_SPINNER: - lv_obj_clean_style_list(obj, LV_SPINNER_PART_BG); list = lv_obj_get_style_list(obj, LV_SPINNER_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->tick_line); - lv_obj_clean_style_list(obj, LV_SPINNER_PART_INDIC); list = lv_obj_get_style_list(obj, LV_SPINNER_PART_INDIC); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->fg_color); @@ -724,17 +702,14 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_SLIDER case LV_THEME_SLIDER: - lv_obj_clean_style_list(obj, LV_SLIDER_PART_BG); list = lv_obj_get_style_list(obj, LV_SLIDER_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->pad_none); - lv_obj_clean_style_list(obj, LV_SLIDER_PART_INDIC); list = lv_obj_get_style_list(obj, LV_SLIDER_PART_INDIC); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->fg_color); - lv_obj_clean_style_list(obj, LV_SLIDER_PART_KNOB); list = lv_obj_get_style_list(obj, LV_SLIDER_PART_KNOB); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->round); @@ -744,11 +719,9 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_CHECKBOX case LV_THEME_CHECKBOX: - lv_obj_clean_style_list(obj, LV_CHECKBOX_PART_BG); list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BG); _lv_style_list_add_style(list, &styles->pad_small); - lv_obj_clean_style_list(obj, LV_CHECKBOX_PART_BULLET); list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BULLET); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); @@ -757,17 +730,14 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_MSGBOX case LV_THEME_MSGBOX: - lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BG); list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BG); _lv_style_list_add_style(list, &styles->bg); break; case LV_THEME_MSGBOX_BTNS: - lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BTN_BG); list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN_BG); _lv_style_list_add_style(list, &styles->pad_inner); - lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BTN); list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); @@ -776,7 +746,6 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #endif #if LV_USE_LED case LV_THEME_LED: - lv_obj_clean_style_list(obj, LV_LED_PART_MAIN); list = lv_obj_get_style_list(obj, LV_LED_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->round); @@ -784,45 +753,31 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #endif #if LV_USE_PAGE case LV_THEME_PAGE: - lv_obj_clean_style_list(obj, LV_PAGE_PART_BG); list = lv_obj_get_style_list(obj, LV_PAGE_PART_BG); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE); list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE); _lv_style_list_add_style(list, &styles->pad_inner); - lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLBAR); list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->sb); break; #endif #if LV_USE_TABVIEW case LV_THEME_TABVIEW: - lv_obj_clean_style_list(obj, LV_TABVIEW_PART_BG); list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_BG); _lv_style_list_add_style(list, &styles->scr); - lv_obj_clean_style_list(obj, LV_TABVIEW_PART_BG_SCRLLABLE); - - lv_obj_clean_style_list(obj, LV_TABVIEW_PART_TAB_BG); list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BG); _lv_style_list_add_style(list, &styles->tab_bg); _lv_style_list_add_style(list, &styles->pad_small); - lv_obj_clean_style_list(obj, LV_TABVIEW_PART_INDIC); - list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_INDIC); - - lv_obj_clean_style_list(obj, LV_TABVIEW_PART_TAB_BTN); list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BTN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); break; case LV_THEME_TABVIEW_PAGE: - lv_obj_clean_style_list(obj, LV_PAGE_PART_BG); - - lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE); list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE); _lv_style_list_add_style(list, &styles->pad_normal); @@ -831,15 +786,12 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_TILEVIEW case LV_THEME_TILEVIEW: - lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_BG); list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_BG); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR); list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->sb); - lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH); list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH); _lv_style_list_add_style(list, &styles->bg); break; @@ -848,12 +800,10 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_ROLLER case LV_THEME_ROLLER: - lv_obj_clean_style_list(obj, LV_ROLLER_PART_BG); list = lv_obj_get_style_list(obj, LV_ROLLER_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->big_line_space); - lv_obj_clean_style_list(obj, LV_ROLLER_PART_SELECTED); list = lv_obj_get_style_list(obj, LV_ROLLER_PART_SELECTED); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->fg_color); @@ -864,28 +814,22 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_OBJMASK case LV_THEME_OBJMASK: - lv_obj_clean_style_list(obj, LV_OBJMASK_PART_MAIN); list = lv_obj_get_style_list(obj, LV_OBJMASK_PART_MAIN); break; #endif #if LV_USE_LIST case LV_THEME_LIST: - lv_obj_clean_style_list(obj, LV_LIST_PART_BG); list = lv_obj_get_style_list(obj, LV_LIST_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->pad_none); _lv_style_list_add_style(list, &styles->clip_corner); - lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLABLE); - - lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLBAR); list = lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->sb); break; case LV_THEME_LIST_BTN: - lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN); list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); @@ -896,21 +840,17 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_DROPDOWN case LV_THEME_DROPDOWN: - lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_MAIN); list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); - lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_LIST); list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_LIST); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->big_line_space); - lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR); list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->sb); - lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SELECTED); list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SELECTED); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->fg_color); @@ -920,42 +860,34 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_CHART case LV_THEME_CHART: - lv_obj_clean_style_list(obj, LV_CHART_PART_BG); list = lv_obj_get_style_list(obj, LV_CHART_PART_BG); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_CHART_PART_SERIES_BG); list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->border_none); - lv_obj_clean_style_list(obj, LV_CHART_PART_SERIES); list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES); _lv_style_list_add_style(list, &styles->chart_series); break; #endif #if LV_USE_TABLE case LV_THEME_TABLE: - lv_obj_clean_style_list(obj, LV_TABLE_PART_BG); list = lv_obj_get_style_list(obj, LV_TABLE_PART_BG); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL1); list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL1); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->no_radius); - lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL2); list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL2); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->no_radius); - lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL3); list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL3); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->no_radius); - lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL4); list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL4); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->no_radius); @@ -964,25 +896,20 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_WIN case LV_THEME_WIN: - lv_obj_clean_style_list(obj, LV_WIN_PART_BG); list = lv_obj_get_style_list(obj, LV_WIN_PART_BG); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_WIN_PART_SCROLLBAR); list = lv_obj_get_style_list(obj, LV_WIN_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->sb); - lv_obj_clean_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE); list = lv_obj_get_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_WIN_PART_HEADER); list = lv_obj_get_style_list(obj, LV_WIN_PART_HEADER); _lv_style_list_add_style(list, &styles->bg); break; case LV_THEME_WIN_BTN: - lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN); list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); @@ -991,17 +918,12 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_TEXTAREA case LV_THEME_TEXTAREA: - lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_BG); list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_BG); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER); - - lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_CURSOR); list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_CURSOR); _lv_style_list_add_style(list, &styles->ta_cursor); - lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR); list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->sb); break; @@ -1010,11 +932,9 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_SPINBOX case LV_THEME_SPINBOX: - lv_obj_clean_style_list(obj, LV_SPINBOX_PART_BG); list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_BG); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_SPINBOX_PART_CURSOR); list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_CURSOR); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->fg_color); @@ -1023,7 +943,6 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) break; case LV_THEME_SPINBOX_BTN: - lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN); list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); @@ -1032,11 +951,9 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_CALENDAR case LV_THEME_CALENDAR: - lv_obj_clean_style_list(obj, LV_CALENDAR_PART_BG); list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_BG); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_CALENDAR_PART_DATE); list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DATE); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); @@ -1044,12 +961,10 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) _lv_style_list_add_style(list, &styles->border_none); _lv_style_list_add_style(list, &styles->calendar_date); - lv_obj_clean_style_list(obj, LV_CALENDAR_PART_HEADER); list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_HEADER); _lv_style_list_add_style(list, &styles->pad_normal); _lv_style_list_add_style(list, &styles->border_none); - lv_obj_clean_style_list(obj, LV_CALENDAR_PART_DAY_NAMES); list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DAY_NAMES); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->pad_small); @@ -1057,11 +972,9 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #endif #if LV_USE_CPICKER case LV_THEME_CPICKER: - lv_obj_clean_style_list(obj, LV_CPICKER_PART_MAIN); list = lv_obj_get_style_list(obj, LV_CPICKER_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_CPICKER_PART_KNOB); list = lv_obj_get_style_list(obj, LV_CPICKER_PART_KNOB); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->round); @@ -1070,7 +983,6 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_LINEMETER case LV_THEME_LINEMETER: - lv_obj_clean_style_list(obj, LV_LINEMETER_PART_MAIN); list = lv_obj_get_style_list(obj, LV_LINEMETER_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->round); @@ -1079,16 +991,13 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #endif #if LV_USE_GAUGE case LV_THEME_GAUGE: - lv_obj_clean_style_list(obj, LV_GAUGE_PART_MAIN); list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->round); - lv_obj_clean_style_list(obj, LV_GAUGE_PART_MAJOR); list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAJOR); _lv_style_list_add_style(list, &styles->gauge_major); - lv_obj_clean_style_list(obj, LV_GAUGE_PART_NEEDLE); list = lv_obj_get_style_list(obj, LV_GAUGE_PART_NEEDLE); _lv_style_list_add_style(list, &styles->gauge_needle); break; diff --git a/src/lv_themes/lv_theme_template.c b/src/lv_themes/lv_theme_template.c index 2c6a8f9b8..bd65d7a7b 100644 --- a/src/lv_themes/lv_theme_template.c +++ b/src/lv_themes/lv_theme_template.c @@ -81,7 +81,7 @@ static void basic_init(void) lv_style_set_bg_color(&styles->btn, LV_STATE_PRESSED, lv_color_hex3(0xccc)); lv_style_set_bg_color(&styles->btn, LV_STATE_CHECKED, theme.color_primary); lv_style_set_bg_color(&styles->btn, LV_STATE_CHECKED | LV_STATE_PRESSED, lv_color_darken(theme.color_primary, - LV_OPA_30)); + LV_OPA_30)); lv_style_set_bg_color(&styles->btn, LV_STATE_DISABLED, LV_COLOR_SILVER); lv_style_set_text_color(&styles->btn, LV_STATE_DISABLED, LV_COLOR_GRAY); lv_style_set_image_recolor(&styles->btn, LV_STATE_DISABLED, LV_COLOR_GRAY); @@ -345,8 +345,8 @@ static void win_init(void) * @return a pointer to reference this theme later */ lv_theme_t * lv_theme_template_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags, - const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_subtitle, - const lv_font_t * font_title) + const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_subtitle, + const lv_font_t * font_title) { /* This trick is required only to avoid the garbage collection of @@ -420,19 +420,16 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) break; case LV_THEME_SCR: - lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN); list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->tight); break; case LV_THEME_OBJ: - lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN); list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); break; #if LV_USE_CONT case LV_THEME_CONT: - lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN); list = lv_obj_get_style_list(obj, LV_CONT_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); break; @@ -440,7 +437,6 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_BTN case LV_THEME_BTN: - lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN); list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); @@ -449,11 +445,9 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_BTNMATRIX case LV_THEME_BTNMATRIX: - lv_obj_clean_style_list(obj, LV_BTNMATRIX_PART_BG); list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BG); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_BTNMATRIX_PART_BTN); list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BTN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); @@ -462,11 +456,9 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_KEYBOARD case LV_THEME_KEYBOARD: - lv_obj_clean_style_list(obj, LV_KEYBOARD_PART_BG); list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BG); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_KEYBOARD_PART_BTN); list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BTN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); @@ -475,12 +467,10 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_BAR case LV_THEME_BAR: - lv_obj_clean_style_list(obj, LV_BAR_PART_BG); list = lv_obj_get_style_list(obj, LV_BAR_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->tight); - lv_obj_clean_style_list(obj, LV_BAR_PART_INDIC); list = lv_obj_get_style_list(obj, LV_BAR_PART_INDIC); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->color); @@ -489,18 +479,15 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_SWITCH case LV_THEME_SWITCH: - lv_obj_clean_style_list(obj, LV_SWITCH_PART_BG); list = lv_obj_get_style_list(obj, LV_SWITCH_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->tight); _lv_style_list_add_style(list, &styles->round); - lv_obj_clean_style_list(obj, LV_SWITCH_PART_INDIC); list = lv_obj_get_style_list(obj, LV_SWITCH_PART_INDIC); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->color); - lv_obj_clean_style_list(obj, LV_SWITCH_PART_KNOB); list = lv_obj_get_style_list(obj, LV_SWITCH_PART_KNOB); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->tight); @@ -510,48 +497,41 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_CANVAS case LV_THEME_CANVAS: - lv_obj_clean_style_list(obj, LV_CANVAS_PART_MAIN); list = lv_obj_get_style_list(obj, LV_CANVAS_PART_MAIN); break; #endif #if LV_USE_IMG case LV_THEME_IMAGE: - lv_obj_clean_style_list(obj, LV_IMG_PART_MAIN); list = lv_obj_get_style_list(obj, LV_IMG_PART_MAIN); break; #endif #if LV_USE_IMGBTN case LV_THEME_IMGBTN: - lv_obj_clean_style_list(obj, LV_IMG_PART_MAIN); list = lv_obj_get_style_list(obj, LV_IMG_PART_MAIN); break; #endif #if LV_USE_LABEL case LV_THEME_LABEL: - lv_obj_clean_style_list(obj, LV_LABEL_PART_MAIN); list = lv_obj_get_style_list(obj, LV_LABEL_PART_MAIN); break; #endif #if LV_USE_LINE case LV_THEME_LINE: - lv_obj_clean_style_list(obj, LV_LABEL_PART_MAIN); list = lv_obj_get_style_list(obj, LV_LABEL_PART_MAIN); break; #endif #if LV_USE_ARC case LV_THEME_ARC: - lv_obj_clean_style_list(obj, LV_ARC_PART_BG); list = lv_obj_get_style_list(obj, LV_ARC_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->tick_line); _lv_style_list_add_style(list, &styles->round); - lv_obj_clean_style_list(obj, LV_ARC_PART_INDIC); list = lv_obj_get_style_list(obj, LV_ARC_PART_INDIC); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->color); @@ -561,12 +541,10 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_SPINNER case LV_THEME_SPINNER: - lv_obj_clean_style_list(obj, LV_SPINNER_PART_BG); list = lv_obj_get_style_list(obj, LV_SPINNER_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->tick_line); - lv_obj_clean_style_list(obj, LV_SPINNER_PART_INDIC); list = lv_obj_get_style_list(obj, LV_SPINNER_PART_INDIC); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->color); @@ -576,16 +554,13 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_SLIDER case LV_THEME_SLIDER: - lv_obj_clean_style_list(obj, LV_SLIDER_PART_BG); list = lv_obj_get_style_list(obj, LV_SLIDER_PART_BG); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_SLIDER_PART_INDIC); list = lv_obj_get_style_list(obj, LV_SLIDER_PART_INDIC); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->color); - lv_obj_clean_style_list(obj, LV_SLIDER_PART_KNOB); list = lv_obj_get_style_list(obj, LV_SLIDER_PART_KNOB); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->round); @@ -594,10 +569,8 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_CHECKBOX case LV_THEME_CHECKBOX: - lv_obj_clean_style_list(obj, LV_CHECKBOX_PART_BG); list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BG); - lv_obj_clean_style_list(obj, LV_CHECKBOX_PART_BULLET); list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BULLET); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); @@ -606,17 +579,14 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_MSGBOX case LV_THEME_MSGBOX: - lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BG); list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BG); _lv_style_list_add_style(list, &styles->bg); break; case LV_THEME_MSGBOX_BTNS: - lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BTN_BG); list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN_BG); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BTN); list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); @@ -625,7 +595,6 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #endif #if LV_USE_LED case LV_THEME_LED: - lv_obj_clean_style_list(obj, LV_LED_PART_MAIN); list = lv_obj_get_style_list(obj, LV_LED_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->color); @@ -634,53 +603,43 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #endif #if LV_USE_PAGE case LV_THEME_PAGE: - lv_obj_clean_style_list(obj, LV_PAGE_PART_BG); list = lv_obj_get_style_list(obj, LV_PAGE_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->gray); - lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE); list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLBAR); list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->bg); break; #endif #if LV_USE_TABVIEW case LV_THEME_TABVIEW: - lv_obj_clean_style_list(obj, LV_TABVIEW_PART_BG); list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_BG); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_TABVIEW_PART_BG_SCRLLABLE); list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_BG_SCRLLABLE); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->color); - lv_obj_clean_style_list(obj, LV_TABVIEW_PART_TAB_BG); list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BG); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_TABVIEW_PART_INDIC); list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_INDIC); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->color); - lv_obj_clean_style_list(obj, LV_TABVIEW_PART_TAB_BTN); list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BTN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); break; case LV_THEME_TABVIEW_PAGE: - lv_obj_clean_style_list(obj, LV_PAGE_PART_BG); list = lv_obj_get_style_list(obj, LV_PAGE_PART_BG); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->gray); - lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE); list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE); _lv_style_list_add_style(list, &styles->bg); @@ -689,15 +648,12 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_TILEVIEW case LV_THEME_TILEVIEW: - lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_BG); list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_BG); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR); list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH); list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH); _lv_style_list_add_style(list, &styles->bg); break; @@ -706,11 +662,9 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_ROLLER case LV_THEME_ROLLER: - lv_obj_clean_style_list(obj, LV_ROLLER_PART_BG); list = lv_obj_get_style_list(obj, LV_ROLLER_PART_BG); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_ROLLER_PART_SELECTED); list = lv_obj_get_style_list(obj, LV_ROLLER_PART_SELECTED); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->color); @@ -720,27 +674,22 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_OBJMASK case LV_THEME_OBJMASK: - lv_obj_clean_style_list(obj, LV_OBJMASK_PART_MAIN); list = lv_obj_get_style_list(obj, LV_OBJMASK_PART_MAIN); break; #endif #if LV_USE_LIST case LV_THEME_LIST: - lv_obj_clean_style_list(obj, LV_LIST_PART_BG); list = lv_obj_get_style_list(obj, LV_LIST_PART_BG); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLABLE); list = lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLABLE); - lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLBAR); list = lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->bg); break; case LV_THEME_LIST_BTN: - lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN); list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); @@ -749,20 +698,16 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_DROPDOWN case LV_THEME_DROPDOWN: - lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_MAIN); list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); - lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_LIST); list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_LIST); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR); list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SELECTED); list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SELECTED); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->color); @@ -771,15 +716,12 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_CHART case LV_THEME_CHART: - lv_obj_clean_style_list(obj, LV_CHART_PART_BG); list = lv_obj_get_style_list(obj, LV_CHART_PART_BG); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_CHART_PART_SERIES_BG); list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES_BG); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_CHART_PART_SERIES); list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->tight); @@ -787,23 +729,18 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #endif #if LV_USE_TABLE case LV_THEME_TABLE: - lv_obj_clean_style_list(obj, LV_TABLE_PART_BG); list = lv_obj_get_style_list(obj, LV_TABLE_PART_BG); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL1); list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL1); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL2); list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL2); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL3); list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL3); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL4); list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL4); _lv_style_list_add_style(list, &styles->bg); break; @@ -811,25 +748,20 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_WIN case LV_THEME_WIN: - lv_obj_clean_style_list(obj, LV_WIN_PART_BG); list = lv_obj_get_style_list(obj, LV_WIN_PART_BG); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_WIN_PART_SCROLLBAR); list = lv_obj_get_style_list(obj, LV_WIN_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE); list = lv_obj_get_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_WIN_PART_HEADER); list = lv_obj_get_style_list(obj, LV_WIN_PART_HEADER); _lv_style_list_add_style(list, &styles->bg); break; case LV_THEME_WIN_BTN: - lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN); list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); @@ -838,20 +770,16 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_TEXTAREA case LV_THEME_TEXTAREA: - lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_BG); list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_BG); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER); list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER); _lv_style_list_add_style(list, &styles->gray); - lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_CURSOR); list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_CURSOR); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->tight); - lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR); list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR); _lv_style_list_add_style(list, &styles->bg); break; @@ -860,17 +788,14 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_SPINBOX case LV_THEME_SPINBOX: - lv_obj_clean_style_list(obj, LV_SPINBOX_PART_BG); list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_BG); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_SPINBOX_PART_CURSOR); list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_CURSOR); _lv_style_list_add_style(list, &styles->bg); break; case LV_THEME_SPINBOX_BTN: - lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN); list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); @@ -879,21 +804,17 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_CALENDAR case LV_THEME_CALENDAR: - lv_obj_clean_style_list(obj, LV_CALENDAR_PART_BG); list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_BG); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_CALENDAR_PART_DATE); list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DATE); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); _lv_style_list_add_style(list, &styles->tight); - lv_obj_clean_style_list(obj, LV_CALENDAR_PART_HEADER); list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_HEADER); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_CALENDAR_PART_DAY_NAMES); list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DAY_NAMES); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->tight); @@ -901,11 +822,9 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #endif #if LV_USE_CPICKER case LV_THEME_CPICKER: - lv_obj_clean_style_list(obj, LV_CPICKER_PART_MAIN); list = lv_obj_get_style_list(obj, LV_CPICKER_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); - lv_obj_clean_style_list(obj, LV_CPICKER_PART_KNOB); list = lv_obj_get_style_list(obj, LV_CPICKER_PART_KNOB); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->round); @@ -914,7 +833,6 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #if LV_USE_LINEMETER case LV_THEME_LINEMETER: - lv_obj_clean_style_list(obj, LV_LINEMETER_PART_MAIN); list = lv_obj_get_style_list(obj, LV_LINEMETER_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->round); @@ -922,16 +840,13 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #endif #if LV_USE_GAUGE case LV_THEME_GAUGE: - lv_obj_clean_style_list(obj, LV_GAUGE_PART_MAIN); list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->round); - lv_obj_clean_style_list(obj, LV_GAUGE_PART_MAJOR); list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAJOR); _lv_style_list_add_style(list, &styles->tick_line); - lv_obj_clean_style_list(obj, LV_GAUGE_PART_NEEDLE); list = lv_obj_get_style_list(obj, LV_GAUGE_PART_NEEDLE); _lv_style_list_add_style(list, &styles->bg); break; @@ -940,10 +855,7 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) break; } - lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL); - - } /********************** From 6056bc3b956cf56b9aba9f01f317927398567b5f Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 26 Jun 2020 14:35:30 +0200 Subject: [PATCH 055/205] clraify the tricky loop in lv_tick_get --- src/lv_hal/lv_hal_tick.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/lv_hal/lv_hal_tick.c b/src/lv_hal/lv_hal_tick.c index a62ed7383..afdceb077 100644 --- a/src/lv_hal/lv_hal_tick.c +++ b/src/lv_hal/lv_hal_tick.c @@ -29,7 +29,7 @@ * STATIC VARIABLES **********************/ static uint32_t sys_time = 0; -static volatile uint8_t tick_irq_flag; +static volatile uint32_t tick_irq_flag; /********************** * MACROS @@ -56,12 +56,17 @@ LV_ATTRIBUTE_TICK_INC void lv_tick_inc(uint32_t tick_period) uint32_t lv_tick_get(void) { #if LV_TICK_CUSTOM == 0 + + /* If `lv_tick_inc` is called from an interrupt while `sys_time` is read + * the result might be corrupted. + * This loop detects if `lv_tick_inc` was called while reading `sys_time`. + * If `tick_irq_flag` was cleared in `lv_tick_inc` try to read again + * until `tick_irq_flag` remains `1`. */ uint32_t result; do { tick_irq_flag = 1; result = sys_time; - } while(!tick_irq_flag); /*'lv_tick_inc()' clears this flag which can be in an interrupt. - Continue until make a non interrupted cycle */ + } while(!tick_irq_flag); /*Continue until see a non interrupted cycle */ return result; #else From e678a2c5993c7ec23519da4b5b001d6ba1a1e202 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 26 Jun 2020 20:31:20 +0200 Subject: [PATCH 056/205] chart: add lv_chart_set_series_axis and lv_chart_set_y_range --- CHANGELOG.md | 2 + src/lv_api_map.h | 20 +++++++++- src/lv_conf_internal.h | 3 ++ src/lv_widgets/lv_chart.c | 82 +++++++++++++++++++++++++++++---------- src/lv_widgets/lv_chart.h | 35 +++++++++++++++-- 5 files changed, 116 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc040fccf..c654be0e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ Available in the `dev` branch - Add `lv_chart_get_x_start_point()` function - Get the current index of the x-axis start point in the data array - Add `lv_chart_get_point_id()` function - Get an individual point value in the chart series directly based on index - Add `ext_buf_assigned` bit field to `lv_chart_series_t` structure - it's true if external buffer is assigned to series +- Add `lv_chart_set_series_axis()` to assign series to primary or secondary axis +- Add `lv_chart_set_y_range()` to allow setting range of secondary y axis (based on `lv_chart_set_range` but extended with an axis parameter) - Allow setting different font for the selected text in `lv_roller` - Add `theme->apply_cb` to replace `theme->apply_xcb` to make it compatible with the MicroPython binding - Add `lv_theme_set_base()` to allow easy extension of built-in (or any) themes. diff --git a/src/lv_api_map.h b/src/lv_api_map.h index cc3f245e8..926e9ec47 100644 --- a/src/lv_api_map.h +++ b/src/lv_api_map.h @@ -176,17 +176,33 @@ static inline lv_obj_t * lv_page_get_scrl(lv_obj_t * page) } #endif + +#endif /*LV_USE_API_EXTENSION_V6*/ + + + + +/*--------------------- + * V7.0 COMPATIBILITY + *--------------------*/ +#if LV_USE_API_EXTENSION_V7 #if LV_USE_WIN static inline lv_obj_t * lv_win_add_btn(lv_obj_t * win, const void * img_src) { - return lv_win_add_btn_right(win, img_src); + return lv_win_add_btn_right(win, img_src); } #endif -#endif /*LV_USE_API_EXTENSION_V6*/ +#if LV_USE_CHART +static inline void lv_chart_set_range(lv_obj_t * chart, lv_coord_t ymin, lv_coord_t ymax) +{ + lv_chart_set_y_range(chart, LV_CHART_AXIS_PRIMARY_Y, ymin, ymax); +} +#endif +#endif /*LV_USE_API_EXTENSION_V6*/ /********************** * MACROS **********************/ diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index 6c653bf61..f722c0615 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -289,6 +289,9 @@ #ifndef LV_USE_API_EXTENSION_V6 #define LV_USE_API_EXTENSION_V6 1 #endif +#ifndef LV_USE_API_EXTENSION_V7 +#define LV_USE_API_EXTENSION_V7 1 +#endif /*======================== * Image decoder and cache diff --git a/src/lv_widgets/lv_chart.c b/src/lv_widgets/lv_chart.c index 3c8dac17e..96b09e402 100644 --- a/src/lv_widgets/lv_chart.c +++ b/src/lv_widgets/lv_chart.c @@ -27,8 +27,6 @@ #define LV_CHART_PNUM_DEF 10 #define LV_CHART_AXIS_MAJOR_TICK_LEN_COE 1 / 15 #define LV_CHART_AXIS_MINOR_TICK_LEN_COE 2 / 3 -#define LV_CHART_AXIS_PRIMARY_Y 1 -#define LV_CHART_AXIS_SECONDARY_Y 0 #define LV_CHART_LABEL_ITERATOR_FORWARD 1 #define LV_CHART_LABEL_ITERATOR_REVERSE 0 @@ -101,8 +99,12 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy) _lv_ll_init(&ext->series_ll, sizeof(lv_chart_series_t)); - ext->ymin = LV_CHART_YMIN_DEF; - ext->ymax = LV_CHART_YMAX_DEF; + uint8_t i; + for(i = 0; i < _LV_CHART_AXIS_LAST; i++) { + ext->ymin[i] = LV_CHART_YMIN_DEF; + ext->ymax[i] = LV_CHART_YMAX_DEF; + } + ext->hdiv_cnt = LV_CHART_HDIV_DEF; ext->vdiv_cnt = LV_CHART_VDIV_DEF; ext->point_cnt = LV_CHART_PNUM_DEF; @@ -118,7 +120,6 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy) ext->secondary_y_axis.major_tick_len = LV_CHART_TICK_LENGTH_AUTO; ext->secondary_y_axis.minor_tick_len = LV_CHART_TICK_LENGTH_AUTO; - lv_style_list_init(&ext->style_series_bg); lv_style_list_init(&ext->style_series); @@ -133,7 +134,6 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy) lv_obj_set_size(chart, LV_DPI * 3, LV_DPI * 2); lv_theme_apply(chart, LV_THEME_CHART); - } else { lv_chart_ext_t * ext_copy = lv_obj_get_ext_attr(copy); @@ -142,11 +142,11 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy) lv_style_list_copy(&ext->style_series_bg, &ext_copy->style_series_bg); ext->type = ext_copy->type; - ext->ymin = ext_copy->ymin; - ext->ymax = ext_copy->ymax; ext->hdiv_cnt = ext_copy->hdiv_cnt; ext->vdiv_cnt = ext_copy->vdiv_cnt; ext->point_cnt = ext_copy->point_cnt; + _lv_memcpy_small(ext->ymin, ext_copy->ymin, sizeof(ext->ymin)); + _lv_memcpy_small(ext->ymax, ext_copy->ymax, sizeof(ext->ymax)); _lv_memcpy(&ext->x_axis, &ext_copy->x_axis, sizeof(lv_chart_axis_cfg_t)); _lv_memcpy(&ext->y_axis, &ext_copy->y_axis, sizeof(lv_chart_axis_cfg_t)); _lv_memcpy(&ext->secondary_y_axis, &ext_copy->secondary_y_axis, sizeof(lv_chart_axis_cfg_t)); @@ -192,6 +192,7 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color) ser->start_point = 0; ser->ext_buf_assigned = false; + ser->y_axis = LV_CHART_AXIS_PRIMARY_Y; uint16_t i; lv_coord_t * p_tmp = ser->points; @@ -249,20 +250,26 @@ void lv_chart_set_div_line_count(lv_obj_t * chart, uint8_t hdiv, uint8_t vdiv) } /** - * Set the minimal and maximal y values + * Set the minimal and maximal y values on an axis * @param chart pointer to a graph background object + * @param axis `LV_CHART_AXIS_PRIMARY_Y` or `LV_CHART_AXIS_SECONDARY_Y` * @param ymin y minimum value * @param ymax y maximum value */ -void lv_chart_set_range(lv_obj_t * chart, lv_coord_t ymin, lv_coord_t ymax) +void lv_chart_set_y_range(lv_obj_t * chart, lv_chart_axis_t axis, lv_coord_t ymin, lv_coord_t ymax) { LV_ASSERT_OBJ(chart, LV_OBJX_NAME); - lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); - if(ext->ymin == ymin && ext->ymax == ymax) return; + if(axis >= _LV_CHART_AXIS_LAST) { + LV_LOG_WARN("Invalid axis: %d", axis); + return; + } - ext->ymin = ymin; - ext->ymax = ymax; + lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); + if(ext->ymin[axis] == ymin && ext->ymax[axis] == ymax) return; + + ext->ymin[axis] = ymin; + ext->ymax[axis] = ymax; lv_chart_refresh(chart); } @@ -600,6 +607,28 @@ void lv_chart_set_point_id(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t ser->points[id] = value; } +/** + * Set the Y axis of a series + * @param chart pointer to a chart object + * @param ser pointer to series + * @param axis `LV_CHART_AXIS_PRIMARY_Y` or `LV_CHART_AXIS_SECONDARY_Y` + */ +void lv_chart_set_series_axis(lv_obj_t * chart, lv_chart_series_t * ser, lv_chart_axis_t axis) +{ + LV_ASSERT_OBJ(chart, LV_OBJX_NAME); + LV_ASSERT_NULL(ser); + + if(axis >= _LV_CHART_AXIS_LAST) { + LV_LOG_WARN("Invalid axis: %d", axis); + return; + } + + if( ser->y_axis == axis) return; + + ser->y_axis = axis; + lv_chart_refresh(chart); +} + /*===================== * Getter functions *====================*/ @@ -660,6 +689,19 @@ lv_coord_t lv_chart_get_point_id(lv_obj_t * chart, lv_chart_series_t * ser, uint } +/** + * Get the Y axis of a series + * @param chart pointer to a chart object + * @param ser pointer to series + * @return `LV_CHART_AXIS_PRIMARY_Y` or `LV_CHART_AXIS_SECONDARY_Y` + */ +lv_chart_axis_t lv_chart_get_series_axis(lv_obj_t * chart, lv_chart_series_t * ser) +{ + LV_ASSERT_NULL(ser); + LV_UNUSED(chart); + + return ser->y_axis; +} /*===================== * Other functions *====================*/ @@ -929,8 +971,8 @@ static void draw_series_line(lv_obj_t * chart, const lv_area_t * series_area, co lv_coord_t p_act = start_point; lv_coord_t p_prev = start_point; - int32_t y_tmp = (int32_t)((int32_t)ser->points[p_prev] - ext->ymin) * h; - y_tmp = y_tmp / (ext->ymax - ext->ymin); + int32_t y_tmp = (int32_t)((int32_t)ser->points[p_prev] - ext->ymin[ser->y_axis]) * h; + y_tmp = y_tmp / (ext->ymax[ser->y_axis] - ext->ymin[ser->y_axis]); p2.y = h - y_tmp + y_ofs; for(i = 0; i < ext->point_cnt; i++) { @@ -941,8 +983,8 @@ static void draw_series_line(lv_obj_t * chart, const lv_area_t * series_area, co p_act = (start_point + i) % ext->point_cnt; - y_tmp = (int32_t)((int32_t)ser->points[p_act] - ext->ymin) * h; - y_tmp = y_tmp / (ext->ymax - ext->ymin); + y_tmp = (int32_t)((int32_t)ser->points[p_act] - ext->ymin[ser->y_axis]) * h; + y_tmp = y_tmp / (ext->ymax[ser->y_axis] - ext->ymin[ser->y_axis]); p2.y = h - y_tmp + y_ofs; /*Don't draw the first point. A second point is also required to draw the line*/ @@ -1065,8 +1107,8 @@ static void draw_series_column(lv_obj_t * chart, const lv_area_t * series_area, col_dsc.bg_color = ser->color; lv_coord_t p_act = (start_point + i) % ext->point_cnt; - y_tmp = (int32_t)((int32_t)ser->points[p_act] - ext->ymin) * h; - y_tmp = y_tmp / (ext->ymax - ext->ymin); + y_tmp = (int32_t)((int32_t)ser->points[p_act] - ext->ymin[ser->y_axis]) * h; + y_tmp = y_tmp / (ext->ymax[ser->y_axis] - ext->ymin[ser->y_axis]); col_a.y1 = h - y_tmp + series_area->y1; if(ser->points[p_act] != LV_CHART_POINT_DEF) { diff --git a/src/lv_widgets/lv_chart.h b/src/lv_widgets/lv_chart.h index 87dc201b3..06bbe84a2 100644 --- a/src/lv_widgets/lv_chart.h +++ b/src/lv_widgets/lv_chart.h @@ -52,11 +52,20 @@ enum { }; typedef uint8_t lv_chart_update_mode_t; + +enum { + LV_CHART_AXIS_PRIMARY_Y, + LV_CHART_AXIS_SECONDARY_Y, + _LV_CHART_AXIS_LAST, +}; +typedef uint8_t lv_chart_axis_t; + typedef struct { lv_coord_t * points; lv_color_t color; uint16_t start_point; uint8_t ext_buf_assigned : 1; + lv_chart_axis_t y_axis : 1; } lv_chart_series_t; /** Data of axis */ @@ -80,8 +89,8 @@ typedef struct { /*No inherited ext*/ /*Ext. of ancestor*/ /*New data for this type */ lv_ll_t series_ll; /*Linked list for the data line pointers (stores lv_chart_series_t)*/ - lv_coord_t ymin; /*y min value (used to scale the data)*/ - lv_coord_t ymax; /*y max value (used to scale the data)*/ + lv_coord_t ymin[_LV_CHART_AXIS_LAST]; /*y min values for both axis (used to scale the data)*/ + lv_coord_t ymax[_LV_CHART_AXIS_LAST]; /*y max values for both axis (used to scale the data)*/ 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*/ @@ -137,6 +146,7 @@ void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * serie); * Setter functions *====================*/ + /** * Set the number of horizontal and vertical division lines * @param chart pointer to a graph background object @@ -146,12 +156,13 @@ void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * serie); void lv_chart_set_div_line_count(lv_obj_t * chart, uint8_t hdiv, uint8_t vdiv); /** - * Set the minimal and maximal y values + * Set the minimal and maximal y values on an axis * @param chart pointer to a graph background object + * @param axis `LV_CHART_AXIS_PRIMARY_Y` or `LV_CHART_AXIS_SECONDARY_Y` * @param ymin y minimum value * @param ymax y maximum value */ -void lv_chart_set_range(lv_obj_t * chart, lv_coord_t ymin, lv_coord_t ymax); +void lv_chart_set_y_range(lv_obj_t * chart, lv_chart_axis_t axis, lv_coord_t ymin, lv_coord_t ymax); /** * Set a new type for a chart @@ -287,6 +298,14 @@ void lv_chart_set_ext_array(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_ */ void lv_chart_set_point_id(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t value, uint16_t id); +/** + * Set the Y axis of a series + * @param chart pointer to a chart object + * @param ser pointer to series + * @param axis `LV_CHART_AXIS_PRIMARY_Y` or `LV_CHART_AXIS_SECONDARY_Y` + */ +void lv_chart_set_series_axis(lv_obj_t * chart, lv_chart_series_t * ser, lv_chart_axis_t axis); + /*===================== * Getter functions *====================*/ @@ -321,6 +340,14 @@ uint16_t lv_chart_get_x_start_point(lv_chart_series_t * ser); */ lv_coord_t lv_chart_get_point_id(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id); +/** + * Get the Y axis of a series + * @param chart pointer to a chart object + * @param ser pointer to series + * @return `LV_CHART_AXIS_PRIMARY_Y` or `LV_CHART_AXIS_SECONDARY_Y` + */ +lv_chart_axis_t lv_chart_get_series_axis(lv_obj_t * chart, lv_chart_series_t * ser); + /*===================== * Other functions *====================*/ From 97f999ed9fa81a6ff38b91efbcc55559cf5075aa Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 26 Jun 2020 20:52:21 +0200 Subject: [PATCH 057/205] add lv_obj_align_x() and lv_obj_align_y() functions --- CHANGELOG.md | 1 + src/lv_core/lv_obj.c | 74 +++++++++++++++++++++++++++++++-------- src/lv_core/lv_obj.h | 18 ++++++++++ src/lv_widgets/lv_chart.h | 1 + 4 files changed, 80 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c654be0e4..7a110f1b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ Available in the `dev` branch - Allow setting different font for the selected text in `lv_roller` - Add `theme->apply_cb` to replace `theme->apply_xcb` to make it compatible with the MicroPython binding - Add `lv_theme_set_base()` to allow easy extension of built-in (or any) themes. +- Add `lv_obj_align_x()` and `lv_obj_align_y()` functions ## v7.1.0 (planned on 07.07.2020) *Available in the `master` branch* diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index dd7df33ca..55cef5424 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -85,6 +85,7 @@ static void refresh_children_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coor static void report_style_mod_core(void * style_p, lv_obj_t * obj); static void refresh_children_style(lv_obj_t * obj); static void base_dir_refr_children(lv_obj_t * obj); +static void obj_align_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set, lv_coord_t x_ofs, lv_coord_t y_ofs); #if LV_USE_ANIMATION static lv_style_trans_t * trans_create(lv_obj_t * obj, lv_style_property_t prop, uint8_t part, lv_state_t prev_state, lv_state_t new_state); @@ -883,7 +884,6 @@ void lv_obj_set_height_margin(lv_obj_t * obj, lv_coord_t h) lv_obj_set_height(obj, h - mtop - mbottom); } - /** * Align an object to an other object. * @param obj pointer to an object to align @@ -900,19 +900,7 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co LV_ASSERT_OBJ(base, LV_OBJX_NAME); - lv_point_t new_pos; - _lv_area_align(&base->coords, &obj->coords, align, &new_pos); - - /*Bring together the coordination system of base and obj*/ - lv_obj_t * par = lv_obj_get_parent(obj); - lv_coord_t par_abs_x = par->coords.x1; - lv_coord_t par_abs_y = par->coords.y1; - new_pos.x += x_ofs; - new_pos.y += y_ofs; - new_pos.x -= par_abs_x; - new_pos.y -= par_abs_y; - - lv_obj_set_pos(obj, new_pos.x, new_pos.y); + obj_align_core(obj, base, align, true, true, x_ofs, y_ofs); #if LV_USE_OBJ_REALIGN /*Save the last align parameters to use them in `lv_obj_realign`*/ @@ -924,6 +912,42 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co #endif } +/** + * Align an object to an other object horizontally. + * @param obj pointer to an object to align + * @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it. + * @param align type of alignment (see 'lv_align_t' enum) + * @param x_ofs x coordinate offset after alignment + */ +void lv_obj_align_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs) +{ + LV_ASSERT_OBJ(obj, LV_OBJX_NAME); + + if(base == NULL) base = lv_obj_get_parent(obj); + + LV_ASSERT_OBJ(base, LV_OBJX_NAME); + + obj_align_core(obj, base, align, true, false, x_ofs, 0); +} + +/** + * Align an object to an other object vertically. + * @param obj pointer to an object to align + * @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it. + * @param align type of alignment (see 'lv_align_t' enum) + * @param y_ofs y coordinate offset after alignment + */ +void lv_obj_align_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t y_ofs) +{ + LV_ASSERT_OBJ(obj, LV_OBJX_NAME); + + if(base == NULL) base = lv_obj_get_parent(obj); + + LV_ASSERT_OBJ(base, LV_OBJX_NAME); + + obj_align_core(obj, base, align, true, false, 0, y_ofs); +} + /** * Align an object's middle point to an other object. * @param obj pointer to an object to align @@ -3871,6 +3895,27 @@ static void base_dir_refr_children(lv_obj_t * obj) } } +static void obj_align_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set, lv_coord_t x_ofs, lv_coord_t y_ofs) +{ + lv_point_t new_pos; + _lv_area_align(&base->coords, &obj->coords, align, &new_pos); + + /*Bring together the coordination system of base and obj*/ + lv_obj_t * par = lv_obj_get_parent(obj); + lv_coord_t par_abs_x = par->coords.x1; + lv_coord_t par_abs_y = par->coords.y1; + new_pos.x += x_ofs; + new_pos.y += y_ofs; + new_pos.x -= par_abs_x; + new_pos.y -= par_abs_y; + + if(x_set && y_set) lv_obj_set_pos(obj, new_pos.x, new_pos.y); + else if(x_set) lv_obj_set_x(obj, new_pos.x); + else if(y_set) lv_obj_set_y(obj, new_pos.y); +} + + + #if LV_USE_ANIMATION /** @@ -4147,3 +4192,4 @@ static bool obj_valid_child(const lv_obj_t * parent, const lv_obj_t * obj_to_fin return false; } + diff --git a/src/lv_core/lv_obj.h b/src/lv_core/lv_obj.h index a4419b683..c470e7af5 100644 --- a/src/lv_core/lv_obj.h +++ b/src/lv_core/lv_obj.h @@ -468,6 +468,24 @@ void lv_obj_set_height_margin(lv_obj_t * obj, lv_coord_t h); */ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs); +/** + * Align an object to an other object horizontally. + * @param obj pointer to an object to align + * @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it. + * @param align type of alignment (see 'lv_align_t' enum) + * @param x_ofs x coordinate offset after alignment + */ +void lv_obj_align_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs); + +/** + * Align an object to an other object vertically. + * @param obj pointer to an object to align + * @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it. + * @param align type of alignment (see 'lv_align_t' enum) + * @param y_ofs y coordinate offset after alignment + */ +void lv_obj_align_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t y_ofs); + /** * Align an object to an other object. * @param obj pointer to an object to align diff --git a/src/lv_widgets/lv_chart.h b/src/lv_widgets/lv_chart.h index 06bbe84a2..c7f68284c 100644 --- a/src/lv_widgets/lv_chart.h +++ b/src/lv_widgets/lv_chart.h @@ -42,6 +42,7 @@ enum { LV_CHART_TYPE_NONE = 0x00, /**< Don't draw the series*/ LV_CHART_TYPE_LINE = 0x01, /**< Connect the points with lines*/ LV_CHART_TYPE_COLUMN = 0x02, /**< Draw columns*/ + LV_CHART_TYPE_SCATTER = 0x03, /**< X/Y chart, points and/or lines*/ }; typedef uint8_t lv_chart_type_t; From 8b3f9f19f691718a71e976000231dc6a9dabb5df Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 26 Jun 2020 20:59:57 +0200 Subject: [PATCH 058/205] add lv_obj_align_origo_x() and lv_obj_align_origo_y() functions --- CHANGELOG.md | 3 +- src/lv_core/lv_obj.c | 255 ++++++++++++++++++++++--------------------- src/lv_core/lv_obj.h | 19 ++++ 3 files changed, 153 insertions(+), 124 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a110f1b9..50e885d22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,8 +15,9 @@ Available in the `dev` branch - Add `lv_chart_set_y_range()` to allow setting range of secondary y axis (based on `lv_chart_set_range` but extended with an axis parameter) - Allow setting different font for the selected text in `lv_roller` - Add `theme->apply_cb` to replace `theme->apply_xcb` to make it compatible with the MicroPython binding -- Add `lv_theme_set_base()` to allow easy extension of built-in (or any) themes. +- Add `lv_theme_set_base()` to allow easy extension of built-in (or any) themes - Add `lv_obj_align_x()` and `lv_obj_align_y()` functions +- Add `lv_obj_align_origo_x()` and `lv_obj_align_origo_y()` functions ## v7.1.0 (planned on 07.07.2020) *Available in the `master` branch* diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 55cef5424..481033d60 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -86,6 +86,7 @@ static void report_style_mod_core(void * style_p, lv_obj_t * obj); static void refresh_children_style(lv_obj_t * obj); static void base_dir_refr_children(lv_obj_t * obj); static void obj_align_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set, lv_coord_t x_ofs, lv_coord_t y_ofs); +static void obj_align_origo_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set, lv_coord_t x_ofs, lv_coord_t y_ofs); #if LV_USE_ANIMATION static lv_style_trans_t * trans_create(lv_obj_t * obj, lv_style_property_t prop, uint8_t part, lv_state_t prev_state, lv_state_t new_state); @@ -960,12 +961,6 @@ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, { LV_ASSERT_OBJ(obj, LV_OBJX_NAME); - lv_coord_t new_x = lv_obj_get_x(obj); - lv_coord_t new_y = lv_obj_get_y(obj); - - lv_coord_t obj_w_half = lv_obj_get_width(obj) / 2; - lv_coord_t obj_h_half = lv_obj_get_height(obj) / 2; - if(base == NULL) { base = lv_obj_get_parent(obj); } @@ -973,123 +968,7 @@ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, LV_ASSERT_OBJ(base, LV_OBJX_NAME); - switch(align) { - case LV_ALIGN_CENTER: - new_x = lv_obj_get_width(base) / 2 - obj_w_half; - new_y = lv_obj_get_height(base) / 2 - obj_h_half; - break; - - case LV_ALIGN_IN_TOP_LEFT: - new_x = -obj_w_half; - new_y = -obj_h_half; - break; - case LV_ALIGN_IN_TOP_MID: - new_x = lv_obj_get_width(base) / 2 - obj_w_half; - new_y = -obj_h_half; - break; - - case LV_ALIGN_IN_TOP_RIGHT: - new_x = lv_obj_get_width(base) - obj_w_half; - new_y = -obj_h_half; - break; - - case LV_ALIGN_IN_BOTTOM_LEFT: - new_x = -obj_w_half; - new_y = lv_obj_get_height(base) - obj_h_half; - break; - case LV_ALIGN_IN_BOTTOM_MID: - new_x = lv_obj_get_width(base) / 2 - obj_w_half; - new_y = lv_obj_get_height(base) - obj_h_half; - break; - - case LV_ALIGN_IN_BOTTOM_RIGHT: - new_x = lv_obj_get_width(base) - obj_w_half; - new_y = lv_obj_get_height(base) - obj_h_half; - break; - - case LV_ALIGN_IN_LEFT_MID: - new_x = -obj_w_half; - new_y = lv_obj_get_height(base) / 2 - obj_h_half; - break; - - case LV_ALIGN_IN_RIGHT_MID: - new_x = lv_obj_get_width(base) - obj_w_half; - new_y = lv_obj_get_height(base) / 2 - obj_h_half; - break; - - case LV_ALIGN_OUT_TOP_LEFT: - new_x = -obj_w_half; - new_y = -obj_h_half; - break; - - case LV_ALIGN_OUT_TOP_MID: - new_x = lv_obj_get_width(base) / 2 - obj_w_half; - new_y = -obj_h_half; - break; - - case LV_ALIGN_OUT_TOP_RIGHT: - new_x = lv_obj_get_width(base) - obj_w_half; - new_y = -obj_h_half; - break; - - case LV_ALIGN_OUT_BOTTOM_LEFT: - new_x = -obj_w_half; - new_y = lv_obj_get_height(base) - obj_h_half; - break; - - case LV_ALIGN_OUT_BOTTOM_MID: - new_x = lv_obj_get_width(base) / 2 - obj_w_half; - new_y = lv_obj_get_height(base) - obj_h_half; - break; - - case LV_ALIGN_OUT_BOTTOM_RIGHT: - new_x = lv_obj_get_width(base) - obj_w_half; - new_y = lv_obj_get_height(base) - obj_h_half; - break; - - case LV_ALIGN_OUT_LEFT_TOP: - new_x = -obj_w_half; - new_y = -obj_h_half; - break; - - case LV_ALIGN_OUT_LEFT_MID: - new_x = -obj_w_half; - new_y = lv_obj_get_height(base) / 2 - obj_h_half; - break; - - case LV_ALIGN_OUT_LEFT_BOTTOM: - new_x = -obj_w_half; - new_y = lv_obj_get_height(base) - obj_h_half; - break; - - case LV_ALIGN_OUT_RIGHT_TOP: - new_x = lv_obj_get_width(base) - obj_w_half; - new_y = -obj_h_half; - break; - - case LV_ALIGN_OUT_RIGHT_MID: - new_x = lv_obj_get_width(base) - obj_w_half; - new_y = lv_obj_get_height(base) / 2 - obj_h_half; - break; - - case LV_ALIGN_OUT_RIGHT_BOTTOM: - new_x = lv_obj_get_width(base) - obj_w_half; - new_y = lv_obj_get_height(base) - obj_h_half; - break; - } - - /*Bring together the coordination system of base and obj*/ - lv_obj_t * par = lv_obj_get_parent(obj); - lv_coord_t base_abs_x = base->coords.x1; - lv_coord_t base_abs_y = base->coords.y1; - lv_coord_t par_abs_x = par->coords.x1; - lv_coord_t par_abs_y = par->coords.y1; - new_x += x_ofs + base_abs_x; - new_y += y_ofs + base_abs_y; - new_x -= par_abs_x; - new_y -= par_abs_y; - - lv_obj_set_pos(obj, new_x, new_y); + obj_align_core(obj, base, align, true, true, x_ofs, y_ofs); #if LV_USE_OBJ_REALIGN /*Save the last align parameters to use them in `lv_obj_realign`*/ @@ -3914,6 +3793,136 @@ static void obj_align_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t ali else if(y_set) lv_obj_set_y(obj, new_pos.y); } +static void obj_align_origo_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set, lv_coord_t x_ofs, lv_coord_t y_ofs) +{ + lv_coord_t new_x = lv_obj_get_x(obj); + lv_coord_t new_y = lv_obj_get_y(obj); + + lv_coord_t obj_w_half = lv_obj_get_width(obj) / 2; + lv_coord_t obj_h_half = lv_obj_get_height(obj) / 2; + + + switch(align) { + case LV_ALIGN_CENTER: + new_x = lv_obj_get_width(base) / 2 - obj_w_half; + new_y = lv_obj_get_height(base) / 2 - obj_h_half; + break; + + case LV_ALIGN_IN_TOP_LEFT: + new_x = -obj_w_half; + new_y = -obj_h_half; + break; + case LV_ALIGN_IN_TOP_MID: + new_x = lv_obj_get_width(base) / 2 - obj_w_half; + new_y = -obj_h_half; + break; + + case LV_ALIGN_IN_TOP_RIGHT: + new_x = lv_obj_get_width(base) - obj_w_half; + new_y = -obj_h_half; + break; + + case LV_ALIGN_IN_BOTTOM_LEFT: + new_x = -obj_w_half; + new_y = lv_obj_get_height(base) - obj_h_half; + break; + case LV_ALIGN_IN_BOTTOM_MID: + new_x = lv_obj_get_width(base) / 2 - obj_w_half; + new_y = lv_obj_get_height(base) - obj_h_half; + break; + + case LV_ALIGN_IN_BOTTOM_RIGHT: + new_x = lv_obj_get_width(base) - obj_w_half; + new_y = lv_obj_get_height(base) - obj_h_half; + break; + + case LV_ALIGN_IN_LEFT_MID: + new_x = -obj_w_half; + new_y = lv_obj_get_height(base) / 2 - obj_h_half; + break; + + case LV_ALIGN_IN_RIGHT_MID: + new_x = lv_obj_get_width(base) - obj_w_half; + new_y = lv_obj_get_height(base) / 2 - obj_h_half; + break; + + case LV_ALIGN_OUT_TOP_LEFT: + new_x = -obj_w_half; + new_y = -obj_h_half; + break; + + case LV_ALIGN_OUT_TOP_MID: + new_x = lv_obj_get_width(base) / 2 - obj_w_half; + new_y = -obj_h_half; + break; + + case LV_ALIGN_OUT_TOP_RIGHT: + new_x = lv_obj_get_width(base) - obj_w_half; + new_y = -obj_h_half; + break; + + case LV_ALIGN_OUT_BOTTOM_LEFT: + new_x = -obj_w_half; + new_y = lv_obj_get_height(base) - obj_h_half; + break; + + case LV_ALIGN_OUT_BOTTOM_MID: + new_x = lv_obj_get_width(base) / 2 - obj_w_half; + new_y = lv_obj_get_height(base) - obj_h_half; + break; + + case LV_ALIGN_OUT_BOTTOM_RIGHT: + new_x = lv_obj_get_width(base) - obj_w_half; + new_y = lv_obj_get_height(base) - obj_h_half; + break; + + case LV_ALIGN_OUT_LEFT_TOP: + new_x = -obj_w_half; + new_y = -obj_h_half; + break; + + case LV_ALIGN_OUT_LEFT_MID: + new_x = -obj_w_half; + new_y = lv_obj_get_height(base) / 2 - obj_h_half; + break; + + case LV_ALIGN_OUT_LEFT_BOTTOM: + new_x = -obj_w_half; + new_y = lv_obj_get_height(base) - obj_h_half; + break; + + case LV_ALIGN_OUT_RIGHT_TOP: + new_x = lv_obj_get_width(base) - obj_w_half; + new_y = -obj_h_half; + break; + + case LV_ALIGN_OUT_RIGHT_MID: + new_x = lv_obj_get_width(base) - obj_w_half; + new_y = lv_obj_get_height(base) / 2 - obj_h_half; + break; + + case LV_ALIGN_OUT_RIGHT_BOTTOM: + new_x = lv_obj_get_width(base) - obj_w_half; + new_y = lv_obj_get_height(base) - obj_h_half; + break; + } + + /*Bring together the coordination system of base and obj*/ + lv_obj_t * par = lv_obj_get_parent(obj); + lv_coord_t base_abs_x = base->coords.x1; + lv_coord_t base_abs_y = base->coords.y1; + lv_coord_t par_abs_x = par->coords.x1; + lv_coord_t par_abs_y = par->coords.y1; + new_x += x_ofs + base_abs_x; + new_y += y_ofs + base_abs_y; + new_x -= par_abs_x; + new_y -= par_abs_y; + if(x_set && y_set) lv_obj_set_pos(obj, new_x, new_y); + else if(x_set) lv_obj_set_x(obj, new_x); + else if(y_set) lv_obj_set_y(obj, new_y); + +} + #if LV_USE_ANIMATION diff --git a/src/lv_core/lv_obj.h b/src/lv_core/lv_obj.h index c470e7af5..ad438c399 100644 --- a/src/lv_core/lv_obj.h +++ b/src/lv_core/lv_obj.h @@ -496,6 +496,25 @@ void lv_obj_align_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_ */ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs); + +/** + * Align an object's middle point to an other object horizontally. + * @param obj pointer to an object to align + * @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it. + * @param align type of alignment (see 'lv_align_t' enum) + * @param x_ofs x coordinate offset after alignment + */ +void lv_obj_align_origo_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs); + +/** + * Align an object's middle point to an other object vertically. + * @param obj pointer to an object to align + * @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it. + * @param align type of alignment (see 'lv_align_t' enum) + * @param y_ofs y coordinate offset after alignment + */ +void lv_obj_align_origo_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t y_ofs); + /** * Realign the object based on the last `lv_obj_align` parameters. * @param obj pointer to an object From 76625adec2a26a8cf2a28af437b12ea9d5dd2391 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 26 Jun 2020 21:02:06 +0200 Subject: [PATCH 059/205] fix typo in lv_obj_align_origo_x/y --- src/lv_core/lv_obj.c | 45 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 481033d60..582485422 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -968,7 +968,7 @@ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, LV_ASSERT_OBJ(base, LV_OBJX_NAME); - obj_align_core(obj, base, align, true, true, x_ofs, y_ofs); + obj_align_origo_core(obj, base, align, true, true, x_ofs, y_ofs); #if LV_USE_OBJ_REALIGN /*Save the last align parameters to use them in `lv_obj_realign`*/ @@ -980,6 +980,49 @@ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, #endif } +/** + * Align an object's middle point to an other object horizontally. + * @param obj pointer to an object to align + * @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it. + * @param align type of alignment (see 'lv_align_t' enum) + * @param x_ofs x coordinate offset after alignment + */ +void lv_obj_align_origo_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs) +{ + LV_ASSERT_OBJ(obj, LV_OBJX_NAME); + + if(base == NULL) { + base = lv_obj_get_parent(obj); + } + + LV_ASSERT_OBJ(base, LV_OBJX_NAME); + + + obj_align_origo_core(obj, base, align, true, false, x_ofs, 0); +} + + +/** + * Align an object's middle point to an other object vertically. + * @param obj pointer to an object to align + * @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it. + * @param align type of alignment (see 'lv_align_t' enum) + * @param y_ofs y coordinate offset after alignment + */ +void lv_obj_align_origo_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t y_ofs) +{ + LV_ASSERT_OBJ(obj, LV_OBJX_NAME); + + if(base == NULL) { + base = lv_obj_get_parent(obj); + } + + LV_ASSERT_OBJ(base, LV_OBJX_NAME); + + + obj_align_origo_core(obj, base, align, true, false, 0, y_ofs); +} + /** * Realign the object based on the last `lv_obj_align` parameters. * @param obj pointer to an object From aad9f4f0c1a785b370bce873fa76f702398edb5d Mon Sep 17 00:00:00 2001 From: Amir Gonnen Date: Sat, 27 Jun 2020 01:04:46 +0300 Subject: [PATCH 060/205] Add lv_dpx inline function (#1612) Identical to LV_DPX (no code additions) --- src/lv_core/lv_disp.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lv_core/lv_disp.h b/src/lv_core/lv_disp.h index dba2ddc37..d29978c5c 100644 --- a/src/lv_core/lv_disp.h +++ b/src/lv_core/lv_disp.h @@ -211,6 +211,11 @@ static inline void lv_scr_load(lv_obj_t * scr) */ #define LV_DPX(n) LV_MATH_MAX((( lv_disp_get_dpi(NULL) * (n) + 80) / 160), 1) /*+80 for rounding*/ +static inline lv_coord_t lv_dpx(lv_coord_t n) +{ + return LV_DPX(n); +} + #ifdef __cplusplus } /* extern "C" */ #endif From 6971d603d2da561afd49c7d02665ecf8d4280497 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sat, 27 Jun 2020 06:53:19 +0200 Subject: [PATCH 061/205] add lv_theme_copy --- src/lv_themes/lv_theme.c | 30 +++++++++++++++++++++++++++--- src/lv_themes/lv_theme.h | 19 ++++++++++++++++--- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/src/lv_themes/lv_theme.c b/src/lv_themes/lv_theme.c index 276e21d12..365fe3aa4 100644 --- a/src/lv_themes/lv_theme.c +++ b/src/lv_themes/lv_theme.c @@ -69,6 +69,30 @@ void lv_theme_apply(lv_obj_t * obj, lv_theme_style_t name) apply_theme(act_theme, obj, name); } +/** + * Copy a theme to an other or initialize a theme + * @param theme pointer to a theme to initialize + * @param copy pointer to a theme to copy + * or `NULL` to initialize `theme` to empty + */ +void lv_theme_copy(lv_theme_t * theme, const lv_theme_t * copy) +{ + _lv_memset_00(theme, sizeof(lv_theme_t)); + + if(copy) { + theme->font_small = copy->font_small; + theme->font_normal = copy->font_normal; + theme->font_subtitle = copy->font_subtitle; + theme->font_title = copy->font_title; + theme->color_primary = copy->color_primary; + theme->color_secondary = copy->color_secondary; + theme->flags = copy->flags; + theme->base = copy->base; + theme->apply_cb = copy->apply_cb; + theme->apply_xcb = copy->apply_xcb; + } + +} /** * Set a base theme for a theme. @@ -79,7 +103,7 @@ void lv_theme_apply(lv_obj_t * obj, lv_theme_style_t name) */ void lv_theme_set_base(lv_theme_t * new, lv_theme_t * base) { - new->base_theme = base; + new->base = base; } /** @@ -151,8 +175,8 @@ uint32_t lv_theme_get_flags(void) static void apply_theme(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) { - if(th->base_theme) { - apply_theme(th->base_theme, obj, name); + if(th->base) { + apply_theme(th->base, obj, name); } /*apply_xcb is deprecated, use apply_cb instead*/ diff --git a/src/lv_themes/lv_theme.h b/src/lv_themes/lv_theme.h index 9941d2c99..0a24f5e7d 100644 --- a/src/lv_themes/lv_theme.h +++ b/src/lv_themes/lv_theme.h @@ -146,10 +146,15 @@ typedef enum { } lv_theme_style_t; +struct _lv_theme_t; + +typedef void (*lv_theme_apply_cb_t)(struct _lv_theme_t *, lv_obj_t *, lv_theme_style_t); +typedef void (*lv_theme_apply_xcb_t)(lv_obj_t *, lv_theme_style_t); /*Deprecated: use `apply_cb` instead*/ + typedef struct _lv_theme_t { - void (*apply_xcb)(lv_obj_t *, lv_theme_style_t); /*Deprecated: use `apply_cb` instead*/ - void (*apply_cb)(struct _lv_theme_t *, lv_obj_t *, lv_theme_style_t); - struct _lv_theme_t * base_theme; /**< Apply the current theme's style on top of this theme.*/ + lv_theme_apply_cb_t apply_cb; + lv_theme_apply_xcb_t apply_xcb; /*Deprecated: use `apply_cb` instead*/ + struct _lv_theme_t * base; /**< Apply the current theme's style on top of this theme.*/ lv_color_t color_primary; lv_color_t color_secondary; const lv_font_t * font_small; @@ -184,6 +189,14 @@ lv_theme_t * lv_theme_get_act(void); */ void lv_theme_apply(lv_obj_t * obj, lv_theme_style_t name); +/** + * Copy a theme to an other or initialize a theme + * @param theme pointer to a theme to initialize + * @param copy pointer to a theme to copy + * or `NULL` to initialize `theme` to empty + */ +void lv_theme_copy(lv_theme_t * theme, const lv_theme_t * copy); + /** * Set a base theme for a theme. * The styles from the base them will be added before the styles of the current theme. From e06201f042c141d97b06e6b031ab4d6cb5c4e03f Mon Sep 17 00:00:00 2001 From: 3096 Date: Fri, 26 Jun 2020 22:27:52 -0700 Subject: [PATCH 062/205] material theme: fix lv_win uninitialed styles --- src/lv_themes/lv_theme_material.c | 62 +++++++++++++++++-------------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/src/lv_themes/lv_theme_material.c b/src/lv_themes/lv_theme_material.c index 33d6f4985..c1cd0c0bf 100644 --- a/src/lv_themes/lv_theme_material.c +++ b/src/lv_themes/lv_theme_material.c @@ -792,6 +792,39 @@ static void roller_init(void) static void tabview_init(void) { #if LV_USE_TABVIEW != 0 +#endif +} + +static void tileview_init(void) +{ +#if LV_USE_TILEVIEW != 0 +#endif +} + +static void table_init(void) +{ +#if LV_USE_TABLE != 0 + style_init_reset(&styles->table_cell); + lv_style_set_border_color(&styles->table_cell, LV_STATE_DEFAULT, COLOR_BG_BORDER); + lv_style_set_border_width(&styles->table_cell, LV_STATE_DEFAULT, 1); + lv_style_set_border_side(&styles->table_cell, LV_STATE_DEFAULT, LV_BORDER_SIDE_TOP | LV_BORDER_SIDE_BOTTOM); + lv_style_set_pad_left(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF); + lv_style_set_pad_right(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF); + lv_style_set_pad_top(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF); + lv_style_set_pad_bottom(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF); + +#endif +} + +static void win_init(void) +{ +#if LV_USE_WIN != 0 +#endif +} + +static void tabview_win_shared_init(void) +{ +#if LV_USE_TABVIEW || LV_USE_WIN style_init_reset(&styles->tabview_btns_bg); lv_style_set_bg_opa(&styles->tabview_btns_bg, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_bg_color(&styles->tabview_btns_bg, LV_STATE_DEFAULT, COLOR_BG); @@ -831,34 +864,6 @@ static void tabview_init(void) #endif } -static void tileview_init(void) -{ -#if LV_USE_TILEVIEW != 0 -#endif -} - -static void table_init(void) -{ -#if LV_USE_TABLE != 0 - style_init_reset(&styles->table_cell); - lv_style_set_border_color(&styles->table_cell, LV_STATE_DEFAULT, COLOR_BG_BORDER); - lv_style_set_border_width(&styles->table_cell, LV_STATE_DEFAULT, 1); - lv_style_set_border_side(&styles->table_cell, LV_STATE_DEFAULT, LV_BORDER_SIDE_TOP | LV_BORDER_SIDE_BOTTOM); - lv_style_set_pad_left(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF); - lv_style_set_pad_right(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF); - lv_style_set_pad_top(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF); - lv_style_set_pad_bottom(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF); - -#endif -} - -static void win_init(void) -{ -#if LV_USE_WIN != 0 - -#endif -} - /********************** * GLOBAL FUNCTIONS @@ -927,6 +932,7 @@ lv_theme_t * lv_theme_material_init(lv_color_t color_primary, lv_color_t color_s tileview_init(); table_init(); win_init(); + tabview_win_shared_init(); theme.apply_xcb = theme_apply; From 40daa7195dc86655dcf6b830cfabfc2d8d793d84 Mon Sep 17 00:00:00 2001 From: Amir Gonnen Date: Sun, 28 Jun 2020 00:46:22 +0300 Subject: [PATCH 063/205] lv_theme: add lv_theme_set_apply_cb (#1616) --- src/lv_themes/lv_theme.c | 11 +++++++++++ src/lv_themes/lv_theme.h | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/src/lv_themes/lv_theme.c b/src/lv_themes/lv_theme.c index 365fe3aa4..d990912db 100644 --- a/src/lv_themes/lv_theme.c +++ b/src/lv_themes/lv_theme.c @@ -106,6 +106,17 @@ void lv_theme_set_base(lv_theme_t * new, lv_theme_t * base) new->base = base; } +/** + * Set a callback for a theme. + * The callback is used to add styles to different objects + * @param theme pointer to theme which callback should be set + * @param cb pointer to the callback + */ +void lv_theme_set_apply_cb(lv_theme_t * theme, lv_theme_apply_cb_t apply_cb) +{ + theme->apply_cb = apply_cb; +} + /** * Get the small font of the theme * @return pointer to the font diff --git a/src/lv_themes/lv_theme.h b/src/lv_themes/lv_theme.h index 0a24f5e7d..788766726 100644 --- a/src/lv_themes/lv_theme.h +++ b/src/lv_themes/lv_theme.h @@ -206,6 +206,14 @@ void lv_theme_copy(lv_theme_t * theme, const lv_theme_t * copy); */ void lv_theme_set_base(lv_theme_t * new, lv_theme_t * base); +/** + * Set an apply callback for a theme. + * The apply callback is used to add styles to different objects + * @param theme pointer to theme which callback should be set + * @param apply_cb pointer to the callback + */ +void lv_theme_set_apply_cb(lv_theme_t * theme, lv_theme_apply_cb_t apply_cb); + /** * Get the small font of the theme * @return pointer to the font From d055944ebb80e45a1d4f3940654cba5343f4cdce Mon Sep 17 00:00:00 2001 From: liangyongxiang Date: Sun, 28 Jun 2020 12:13:39 +0800 Subject: [PATCH 064/205] Add conditional macro LV_USE_GROUP to more GROUP related singles: - LV_SIGNAL_CONTROL - LV_SIGNAL_GET_EDITABLE --- src/lv_widgets/lv_btn.c | 2 ++ src/lv_widgets/lv_btnmatrix.c | 4 ++++ src/lv_widgets/lv_calendar.c | 2 ++ src/lv_widgets/lv_checkbox.c | 2 ++ src/lv_widgets/lv_cpicker.c | 2 ++ src/lv_widgets/lv_dropdown.c | 4 ++++ src/lv_widgets/lv_list.c | 2 ++ src/lv_widgets/lv_msgbox.c | 9 +++++++-- src/lv_widgets/lv_page.c | 4 ++++ src/lv_widgets/lv_roller.c | 5 +++++ src/lv_widgets/lv_slider.c | 4 ++++ src/lv_widgets/lv_spinbox.c | 4 ++++ src/lv_widgets/lv_switch.c | 4 ++++ src/lv_widgets/lv_tabview.c | 9 +++++++-- src/lv_widgets/lv_textarea.c | 4 ++++ src/lv_widgets/lv_win.c | 2 ++ 16 files changed, 59 insertions(+), 4 deletions(-) diff --git a/src/lv_widgets/lv_btn.c b/src/lv_widgets/lv_btn.c index e69aae20b..fa327bd6e 100644 --- a/src/lv_widgets/lv_btn.c +++ b/src/lv_widgets/lv_btn.c @@ -289,6 +289,7 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param) } } else if(sign == LV_SIGNAL_CONTROL) { +#if LV_USE_GROUP char c = *((char *)param); if(c == LV_KEY_RIGHT || c == LV_KEY_UP) { if(lv_btn_get_checkable(btn)) { @@ -309,6 +310,7 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param) if(res != LV_RES_OK) return res; } } +#endif } return res; diff --git a/src/lv_widgets/lv_btnmatrix.c b/src/lv_widgets/lv_btnmatrix.c index 0f2718699..d40880ce1 100644 --- a/src/lv_widgets/lv_btnmatrix.c +++ b/src/lv_widgets/lv_btnmatrix.c @@ -992,6 +992,7 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * pa ext->btn_id_act = LV_BTNMATRIX_BTN_NONE; } else if(sign == LV_SIGNAL_CONTROL) { +#if LV_USE_GROUP char c = *((char *)param); if(c == LV_KEY_RIGHT) { if(ext->btn_id_focused == LV_BTNMATRIX_BTN_NONE) @@ -1059,10 +1060,13 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * pa ext->btn_id_act = ext->btn_id_focused; lv_obj_invalidate(btnm); } +#endif } else if(sign == LV_SIGNAL_GET_EDITABLE) { +#if LV_USE_GROUP bool * editable = (bool *)param; *editable = true; +#endif } return res; } diff --git a/src/lv_widgets/lv_calendar.c b/src/lv_widgets/lv_calendar.c index d1b205bb4..fd1f93182 100644 --- a/src/lv_widgets/lv_calendar.c +++ b/src/lv_widgets/lv_calendar.c @@ -515,6 +515,7 @@ static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void * lv_obj_invalidate(calendar); } else if(sign == LV_SIGNAL_CONTROL) { +#if LV_USE_GROUP uint8_t c = *((uint8_t *)param); lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar); if(c == LV_KEY_RIGHT || c == LV_KEY_UP) { @@ -537,6 +538,7 @@ static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void * } lv_obj_invalidate(calendar); } +#endif } return res; diff --git a/src/lv_widgets/lv_checkbox.c b/src/lv_widgets/lv_checkbox.c index 7196678e2..3f8ac3dc7 100644 --- a/src/lv_widgets/lv_checkbox.c +++ b/src/lv_widgets/lv_checkbox.c @@ -193,11 +193,13 @@ static lv_res_t lv_checkbox_signal(lv_obj_t * cb, lv_signal_t sign, void * param lv_obj_set_state(ext->bullet, lv_obj_get_state(cb, LV_CHECKBOX_PART_BG)); } else if(sign == LV_SIGNAL_CONTROL) { +#if LV_USE_GROUP char c = *((char *)param); if(c == LV_KEY_RIGHT || c == LV_KEY_DOWN || c == LV_KEY_LEFT || c == LV_KEY_UP) { /*Follow the backgrounds state with the bullet*/ lv_obj_set_state(ext->bullet, lv_obj_get_state(cb, LV_CHECKBOX_PART_BG)); } +#endif } return res; diff --git a/src/lv_widgets/lv_cpicker.c b/src/lv_widgets/lv_cpicker.c index 1b8025c5b..d80c9a56c 100644 --- a/src/lv_widgets/lv_cpicker.c +++ b/src/lv_widgets/lv_cpicker.c @@ -701,6 +701,7 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p lv_obj_invalidate(cpicker); } else if(sign == LV_SIGNAL_CONTROL) { +#if LV_USE_GROUP uint32_t c = *((uint32_t *)param); /*uint32_t because can be UTF-8*/ if(c == LV_KEY_RIGHT || c == LV_KEY_UP) { @@ -745,6 +746,7 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p if(res != LV_RES_OK) return res; } } +#endif } else if(sign == LV_SIGNAL_PRESSED) { ext->last_change_time = lv_tick_get(); diff --git a/src/lv_widgets/lv_dropdown.c b/src/lv_widgets/lv_dropdown.c index 0f16ef8e0..c7bbd8746 100644 --- a/src/lv_widgets/lv_dropdown.c +++ b/src/lv_widgets/lv_dropdown.c @@ -968,6 +968,7 @@ static lv_res_t lv_dropdown_signal(lv_obj_t * ddlist, lv_signal_t sign, void * p if(ext->page) lv_obj_refresh_style(ext->page, LV_STYLE_PROP_ALL); } else if(sign == LV_SIGNAL_CONTROL) { +#if LV_USE_GROUP char c = *((char *)param); if(c == LV_KEY_RIGHT || c == LV_KEY_DOWN) { if(ext->page == NULL) { @@ -992,10 +993,13 @@ static lv_res_t lv_dropdown_signal(lv_obj_t * ddlist, lv_signal_t sign, void * p ext->sel_opt_id = ext->sel_opt_id_orig; lv_dropdown_close(ddlist); } +#endif } else if(sign == LV_SIGNAL_GET_EDITABLE) { +#if LV_USE_GROUP bool * editable = (bool *)param; *editable = true; +#endif } return res; diff --git a/src/lv_widgets/lv_list.c b/src/lv_widgets/lv_list.c index d7b502db1..9df0d621d 100644 --- a/src/lv_widgets/lv_list.c +++ b/src/lv_widgets/lv_list.c @@ -730,8 +730,10 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param) #endif } else if(sign == LV_SIGNAL_GET_EDITABLE) { +#if LV_USE_GROUP bool * editable = (bool *)param; *editable = true; +#endif } else if(sign == LV_SIGNAL_CONTROL) { diff --git a/src/lv_widgets/lv_msgbox.c b/src/lv_widgets/lv_msgbox.c index f971f93d8..60f4cdc9c 100644 --- a/src/lv_widgets/lv_msgbox.c +++ b/src/lv_widgets/lv_msgbox.c @@ -412,6 +412,7 @@ static lv_res_t lv_msgbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param { lv_res_t res; +#if LV_USE_GROUP /*Translate LV_KEY_UP/DOWN to LV_KEY_LEFT/RIGHT */ char c_trans = 0; if(sign == LV_SIGNAL_CONTROL) { @@ -421,6 +422,7 @@ static lv_res_t lv_msgbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param param = &c_trans; } +#endif if(sign == LV_SIGNAL_GET_STYLE) { lv_get_style_info_t * info = param; @@ -460,8 +462,11 @@ static lv_res_t lv_msgbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param if(btn_id != LV_BTNMATRIX_BTN_NONE) lv_event_send(mbox, LV_EVENT_VALUE_CHANGED, &btn_id); } } - else if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS || sign == LV_SIGNAL_CONTROL || - sign == LV_SIGNAL_GET_EDITABLE) { + else if( +#if LV_USE_GROUP + sign == LV_SIGNAL_CONTROL || sign == LV_SIGNAL_GET_EDITABLE || +#endif + sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS) { if(ext->btnm) { ext->btnm->signal_cb(ext->btnm, sign, param); } diff --git a/src/lv_widgets/lv_page.c b/src/lv_widgets/lv_page.c index f8141c320..89c6c0f0e 100644 --- a/src/lv_widgets/lv_page.c +++ b/src/lv_widgets/lv_page.c @@ -859,6 +859,7 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param) refr_ext_draw_pad(page); } else if(sign == LV_SIGNAL_CONTROL) { +#if LV_USE_GROUP uint32_t c = *((uint32_t *)param); if(c == LV_KEY_DOWN) { @@ -883,10 +884,13 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param) else lv_page_scroll_hor(page, lv_obj_get_width(page) / 4); } +#endif } else if(sign == LV_SIGNAL_GET_EDITABLE) { +#if LV_USE_GROUP bool * editable = (bool *)param; *editable = true; +#endif } return res; diff --git a/src/lv_widgets/lv_roller.c b/src/lv_widgets/lv_roller.c index 8a366fd79..23fe90837 100644 --- a/src/lv_widgets/lv_roller.c +++ b/src/lv_widgets/lv_roller.c @@ -490,13 +490,16 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par /* Include the ancient signal function */ if(sign != LV_SIGNAL_CONTROL) { /*Don't let the page to scroll on keys*/ +#if LV_USE_GROUP res = ancestor_signal(roller, sign, param); if(res != LV_RES_OK) return res; +#endif } if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME); lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller); + LV_UNUSED(ext); if(sign == LV_SIGNAL_STYLE_CHG) { lv_obj_t * label = get_label(roller); @@ -556,6 +559,7 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par #endif } else if(sign == LV_SIGNAL_CONTROL) { +#if LV_USE_GROUP char c = *((char *)param); if(c == LV_KEY_RIGHT || c == LV_KEY_DOWN) { if(ext->sel_opt_id + 1 < ext->option_cnt) { @@ -572,6 +576,7 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par ext->sel_opt_id_ori = ori_id; } } +#endif } else if(sign == LV_SIGNAL_CLEANUP) { lv_obj_clean_style_list(roller, LV_ROLLER_PART_SELECTED); diff --git a/src/lv_widgets/lv_slider.c b/src/lv_widgets/lv_slider.c index b516c03f1..d7efb7469 100644 --- a/src/lv_widgets/lv_slider.c +++ b/src/lv_widgets/lv_slider.c @@ -407,6 +407,7 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par } else if(sign == LV_SIGNAL_CONTROL) { +#if LV_USE_GROUP char c = *((char *)param); if(c == LV_KEY_RIGHT || c == LV_KEY_UP) { @@ -419,13 +420,16 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par res = lv_event_send(slider, LV_EVENT_VALUE_CHANGED, NULL); if(res != LV_RES_OK) return res; } +#endif } else if(sign == LV_SIGNAL_CLEANUP) { lv_obj_clean_style_list(slider, LV_SLIDER_PART_KNOB); } else if(sign == LV_SIGNAL_GET_EDITABLE) { +#if LV_USE_GROUP bool * editable = (bool *)param; *editable = true; +#endif } return res; diff --git a/src/lv_widgets/lv_spinbox.c b/src/lv_widgets/lv_spinbox.c index c3098dc5e..669c72d38 100644 --- a/src/lv_widgets/lv_spinbox.c +++ b/src/lv_widgets/lv_spinbox.c @@ -390,8 +390,10 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * p /* Include the ancient signal function */ if(sign != LV_SIGNAL_CONTROL) { +#if LV_USE_GROUP res = ancestor_signal(spinbox, sign, param); if(res != LV_RES_OK) return res; +#endif } if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME); @@ -464,6 +466,7 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * p } } else if(sign == LV_SIGNAL_CONTROL) { +#if LV_USE_GROUP lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act()); uint32_t c = *((uint32_t *)param); /*uint32_t because can be UTF-8*/ @@ -488,6 +491,7 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * p else { lv_textarea_add_char(spinbox, c); } +#endif } return res; diff --git a/src/lv_widgets/lv_switch.c b/src/lv_widgets/lv_switch.c index f3b6aa549..dfc1aa964 100644 --- a/src/lv_widgets/lv_switch.c +++ b/src/lv_widgets/lv_switch.c @@ -296,12 +296,14 @@ static lv_res_t lv_switch_signal(lv_obj_t * sw, lv_signal_t sign, void * param) } else if(sign == LV_SIGNAL_CONTROL) { +#if LV_USE_GROUP char c = *((char *)param); if(c == LV_KEY_RIGHT || c == LV_KEY_UP) lv_switch_on(sw, LV_ANIM_ON); else if(c == LV_KEY_LEFT || c == LV_KEY_DOWN) lv_switch_off(sw, LV_ANIM_ON); res = lv_event_send(sw, LV_EVENT_VALUE_CHANGED, NULL); if(res != LV_RES_OK) return res; +#endif } else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) { lv_style_int_t knob_left = lv_obj_get_style_pad_left(sw, LV_SWITCH_PART_KNOB); @@ -320,8 +322,10 @@ static lv_res_t lv_switch_signal(lv_obj_t * sw, lv_signal_t sign, void * param) sw->ext_draw_pad = LV_MATH_MAX(sw->ext_draw_pad, knob_size); } else if(sign == LV_SIGNAL_GET_EDITABLE) { +#if LV_USE_GROUP bool * editable = (bool *)param; *editable = false; /*The ancestor slider is editable the switch is not*/ +#endif } return res; diff --git a/src/lv_widgets/lv_tabview.c b/src/lv_widgets/lv_tabview.c index 2b2475eb2..9e51d59dc 100644 --- a/src/lv_widgets/lv_tabview.c +++ b/src/lv_widgets/lv_tabview.c @@ -645,12 +645,17 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p #endif } else if(sign == LV_SIGNAL_GET_EDITABLE) { +#if LV_USE_GROUP bool * editable = (bool *)param; *editable = true; +#endif } - if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS || sign == LV_SIGNAL_CONTROL || sign == LV_SIGNAL_PRESSED || - sign == LV_SIGNAL_RELEASED) { + if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS || +#if LV_USE_GROUP + sign == LV_SIGNAL_CONTROL || +#endif + sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_RELEASED) { /* The button matrix is not in a group (the tab view is in it) but it should handle the * group signals. So propagate the related signals to the button matrix manually*/ diff --git a/src/lv_widgets/lv_textarea.c b/src/lv_widgets/lv_textarea.c index e95cb5cdd..c8bfc65da 100644 --- a/src/lv_widgets/lv_textarea.c +++ b/src/lv_widgets/lv_textarea.c @@ -1466,6 +1466,7 @@ static lv_res_t lv_textarea_signal(lv_obj_t * ta, lv_signal_t sign, void * param } } else if(sign == LV_SIGNAL_CONTROL) { +#if LV_USE_GROUP uint32_t c = *((uint32_t *)param); /*uint32_t because can be UTF-8*/ if(c == LV_KEY_RIGHT) lv_textarea_cursor_right(ta); @@ -1486,10 +1487,13 @@ static lv_res_t lv_textarea_signal(lv_obj_t * ta, lv_signal_t sign, void * param else { lv_textarea_add_char(ta, c); } +#endif } else if(sign == LV_SIGNAL_GET_EDITABLE) { +#if LV_USE_GROUP bool * editable = (bool *)param; *editable = true; +#endif } else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_PRESSING || sign == LV_SIGNAL_PRESS_LOST || sign == LV_SIGNAL_RELEASED) { diff --git a/src/lv_widgets/lv_win.c b/src/lv_widgets/lv_win.c index fa5147053..6b825c168 100644 --- a/src/lv_widgets/lv_win.c +++ b/src/lv_widgets/lv_win.c @@ -645,8 +645,10 @@ static lv_res_t lv_win_signal(lv_obj_t * win, lv_signal_t sign, void * param) ext->title_txt = NULL; } else if(sign == LV_SIGNAL_CONTROL) { +#if LV_USE_GROUP /*Forward all the control signals to the page*/ ext->page->signal_cb(ext->page, sign, param); +#endif } return res; From ddbeb212b7be7aac7d71a0323c9d756d88a8418c Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 28 Jun 2020 13:29:01 +0200 Subject: [PATCH 065/205] Add support to compressed fonts without pre-filter to gain some speed by sacrificing some memory --- CHANGELOG.md | 1 + src/lv_font/lv_font_fmt_txt.c | 34 +++++++++++++++++++++++++--------- src/lv_font/lv_font_fmt_txt.h | 1 + 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15ec85db2..7b747ea9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ Available in the `dev` branch - Add `lv_theme_set_base()` to allow easy extension of built-in (or any) themes - Add `lv_obj_align_x()` and `lv_obj_align_y()` functions - Add `lv_obj_align_origo_x()` and `lv_obj_align_origo_y()` functions +- Support compressed fonts without pre-filter to gain some speed by sacrificing some memory ## v7.1.0 (planned on 07.07.2020) *Available in the `master` branch* diff --git a/src/lv_font/lv_font_fmt_txt.c b/src/lv_font/lv_font_fmt_txt.c index abcb2f01e..403fe26ee 100644 --- a/src/lv_font/lv_font_fmt_txt.c +++ b/src/lv_font/lv_font_fmt_txt.c @@ -37,7 +37,7 @@ static int32_t unicode_list_compare(const void * ref, const void * element); static int32_t kern_pair_8_compare(const void * ref, const void * element); static int32_t kern_pair_16_compare(const void * ref, const void * element); -static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord_t h, uint8_t bpp); +static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord_t h, uint8_t bpp, bool prefilter); static inline void decompress_line(uint8_t * out, lv_coord_t w); static inline uint8_t get_bits(const uint8_t * in, uint32_t bit_pos, uint8_t len); static inline void bits_write(uint8_t * out, uint32_t bit_pos, uint8_t val, uint8_t len); @@ -114,7 +114,8 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic if(decompr_buf == NULL) return NULL; } - decompress(&fdsc->glyph_bitmap[gdsc->bitmap_index], decompr_buf, gdsc->box_w, gdsc->box_h, (uint8_t)fdsc->bpp); + bool prefilter = fdsc->bitmap_format == LV_FONT_FMT_TXT_COMPRESSED ? true : false; + decompress(&fdsc->glyph_bitmap[gdsc->bitmap_index], decompr_buf, gdsc->box_w, gdsc->box_h, (uint8_t)fdsc->bpp, prefilter); return decompr_buf; } @@ -333,8 +334,9 @@ static int32_t kern_pair_16_compare(const void * ref, const void * element) * @param out buffer to store the result * @param px_num number of pixels in the glyph (width * height) * @param bpp bit per pixel (bpp = 3 will be converted to bpp = 4) + * @param prefilter true: the lines are XORed */ -static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord_t h, uint8_t bpp) +static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord_t h, uint8_t bpp, bool prefilter) { uint32_t wrp = 0; uint8_t wr_size = bpp; @@ -343,7 +345,12 @@ static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord rle_init(in, bpp); uint8_t * line_buf1 = _lv_mem_buf_get(w); - uint8_t * line_buf2 = _lv_mem_buf_get(w); + + uint8_t * line_buf2 = NULL; + + if(prefilter) { + line_buf2= _lv_mem_buf_get(w); + } decompress_line(line_buf1, w); @@ -356,12 +363,21 @@ static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord } for(y = 1; y < h; y++) { - decompress_line(line_buf2, w); + if(prefilter) { + decompress_line(line_buf2, w); - for(x = 0; x < w; x++) { - line_buf1[x] = line_buf2[x] ^ line_buf1[x]; - bits_write(out, wrp, line_buf1[x], bpp); - wrp += wr_size; + for(x = 0; x < w; x++) { + line_buf1[x] = line_buf2[x] ^ line_buf1[x]; + bits_write(out, wrp, line_buf1[x], bpp); + wrp += wr_size; + } + } else { + decompress_line(line_buf1, w); + + for(x = 0; x < w; x++) { + bits_write(out, wrp, line_buf1[x], bpp); + wrp += wr_size; + } } } diff --git a/src/lv_font/lv_font_fmt_txt.h b/src/lv_font/lv_font_fmt_txt.h index 657bcfa30..549c7f5e6 100644 --- a/src/lv_font/lv_font_fmt_txt.h +++ b/src/lv_font/lv_font_fmt_txt.h @@ -150,6 +150,7 @@ typedef struct { typedef enum { LV_FONT_FMT_TXT_PLAIN = 0, LV_FONT_FMT_TXT_COMPRESSED = 1, + LV_FONT_FMT_TXT_COMPRESSED_NO_PREFILTER= 1, } lv_font_fmt_txt_bitmap_format_t; From 92027cc06f4dae161d4916eceb0e4b8c434a1b3c Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 28 Jun 2020 13:32:40 +0200 Subject: [PATCH 066/205] lv_hal_tick: revert using uint32_t as tick_irq_flag uint8_t surely can be written in 1 instruction even on 16 bit MCUs --- src/lv_hal/lv_hal_tick.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_hal/lv_hal_tick.c b/src/lv_hal/lv_hal_tick.c index afdceb077..3a1a5128a 100644 --- a/src/lv_hal/lv_hal_tick.c +++ b/src/lv_hal/lv_hal_tick.c @@ -29,7 +29,7 @@ * STATIC VARIABLES **********************/ static uint32_t sys_time = 0; -static volatile uint32_t tick_irq_flag; +static volatile uint8_t tick_irq_flag; /********************** * MACROS From 421f1b2c0122c7354e9b47708984b3ee23ac77d0 Mon Sep 17 00:00:00 2001 From: Themba Dube Date: Sun, 28 Jun 2020 09:16:25 -0400 Subject: [PATCH 067/205] lv_gpu: fix #1617 by renaming internal macros This avoids conflicts with STM32Cube. --- src/lv_gpu/lv_gpu_stm32_dma2d.c | 12 ++++++------ src/lv_gpu/lv_gpu_stm32_dma2d.h | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/lv_gpu/lv_gpu_stm32_dma2d.c b/src/lv_gpu/lv_gpu_stm32_dma2d.c index 086f27753..9810587dd 100644 --- a/src/lv_gpu/lv_gpu_stm32_dma2d.c +++ b/src/lv_gpu/lv_gpu_stm32_dma2d.c @@ -27,9 +27,9 @@ #endif #if LV_COLOR_DEPTH == 16 - #define DMA2D_COLOR_FORMAT DMA2D_RGB565 + #define LV_DMA2D_COLOR_FORMAT LV_DMA2D_RGB565 #elif LV_COLOR_DEPTH == 32 - #define DMA2D_COLOR_FORMAT DMA2D_ARGB8888 + #define LV_DMA2D_COLOR_FORMAT LV_DMA2D_ARGB8888 #else /*Can't use GPU with other formats*/ #endif @@ -68,7 +68,7 @@ void lv_gpu_stm32_dma2d_init(void) volatile uint32_t temp = RCC->AHB1ENR; /* set output colour mode */ - DMA2D->OPFCCR = DMA2D_COLOR_FORMAT; + DMA2D->OPFCCR = LV_DMA2D_COLOR_FORMAT; } /** @@ -160,7 +160,7 @@ void lv_gpu_stm32_dma2d_copy(lv_color_t * buf, lv_coord_t buf_w, const lv_color_ DMA2D->CR = 0; /* copy output colour mode, this register controls both input and output colour format */ - DMA2D->FGPFCCR = DMA2D_COLOR_FORMAT; + DMA2D->FGPFCCR = LV_DMA2D_COLOR_FORMAT; DMA2D->FGMAR = (uint32_t)map; DMA2D->FGOR = map_w - copy_w; DMA2D->OMAR = (uint32_t)buf; @@ -189,11 +189,11 @@ void lv_gpu_stm32_dma2d_blend(lv_color_t * buf, lv_coord_t buf_w, const lv_color invalidate_cache(); DMA2D->CR = 0x20000; - DMA2D->BGPFCCR = DMA2D_COLOR_FORMAT; + DMA2D->BGPFCCR = LV_DMA2D_COLOR_FORMAT; DMA2D->BGMAR = (uint32_t)buf; DMA2D->BGOR = buf_w - copy_w; - DMA2D->FGPFCCR = (uint32_t)DMA2D_COLOR_FORMAT + DMA2D->FGPFCCR = (uint32_t)LV_DMA2D_COLOR_FORMAT /* alpha mode 2, replace with foreground * alpha value */ | (2 << DMA2D_FGPFCCR_AM_Pos) /* alpha value */ diff --git a/src/lv_gpu/lv_gpu_stm32_dma2d.h b/src/lv_gpu/lv_gpu_stm32_dma2d.h index d3da2a846..9f244a603 100644 --- a/src/lv_gpu/lv_gpu_stm32_dma2d.h +++ b/src/lv_gpu/lv_gpu_stm32_dma2d.h @@ -20,11 +20,11 @@ extern "C" { * DEFINES *********************/ -#define DMA2D_ARGB8888 0 -#define DMA2D_RGB888 1 -#define DMA2D_RGB565 2 -#define DMA2D_ARGB1555 3 -#define DMA2D_ARGB4444 4 +#define LV_DMA2D_ARGB8888 0 +#define LV_DMA2D_RGB888 1 +#define LV_DMA2D_RGB565 2 +#define LV_DMA2D_ARGB1555 3 +#define LV_DMA2D_ARGB4444 4 /********************** * TYPEDEFS From d0db0bab5cb5d21c785af4145ea602c5bb7e0795 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 28 Jun 2020 20:10:05 +0200 Subject: [PATCH 068/205] add Arduino library files --- library.properties | 10 ++++++++++ src/lvgl.h | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 library.properties create mode 100644 src/lvgl.h diff --git a/library.properties b/library.properties new file mode 100644 index 000000000..9c8c48826 --- /dev/null +++ b/library.properties @@ -0,0 +1,10 @@ +name=lvgl +version=7.0.2 +author=kisvegabor +maintainer=Pavel Brychta +sentence=Full-featured Graphics Library for Embedded Systems +paragraph=Powerful and easy-to-use embedded GUI with many widgets, advanced visual effects (opacity, antialiasing, animations) and low memory requirements (16K RAM, 64K Flash). +category=Display +url=https://lvgl.io +architectures=* +includes=lvgl.h diff --git a/src/lvgl.h b/src/lvgl.h new file mode 100644 index 000000000..77dca2bec --- /dev/null +++ b/src/lvgl.h @@ -0,0 +1,39 @@ +/** + * @file lvgl.h + * This file exists only to be compatible with Arduino's library structure + */ + +#ifndef LVGL_SRC_H +#define LVGL_SRC_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************* + * INCLUDES + *********************/ + +#include "../lvgl.h" + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * GLOBAL PROTOTYPES + **********************/ + +/********************** + * MACROS + **********************/ + +#ifdef __cplusplus +} +#endif + +#endif /*LVGL_SRC_H*/ From 069e24bdb294f27cc45c50497b05b5377d9f16d7 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 28 Jun 2020 20:37:32 +0200 Subject: [PATCH 069/205] add examples folder with arduio examples and move porting folder there --- .../arduino/ESP32_TFT_eSPI/ESP32_TFT_eSPI.ino | 119 ++++++++++++++++++ examples/arduino/ESP32_TFT_eSPI/README.md | 44 +++++++ examples/arduino/README.md | 37 ++++++ .../porting}/lv_port_disp_template.c | 0 .../porting}/lv_port_disp_template.h | 0 .../porting}/lv_port_fs_template.c | 0 .../porting}/lv_port_fs_template.h | 0 .../porting}/lv_port_indev_template.c | 0 .../porting}/lv_port_indev_template.h | 0 library.properties | 10 -- lv_conf_template.h | 4 +- src/lv_conf_internal.h | 4 +- 12 files changed, 204 insertions(+), 14 deletions(-) create mode 100644 examples/arduino/ESP32_TFT_eSPI/ESP32_TFT_eSPI.ino create mode 100644 examples/arduino/ESP32_TFT_eSPI/README.md create mode 100644 examples/arduino/README.md rename {porting => examples/porting}/lv_port_disp_template.c (100%) rename {porting => examples/porting}/lv_port_disp_template.h (100%) rename {porting => examples/porting}/lv_port_fs_template.c (100%) rename {porting => examples/porting}/lv_port_fs_template.h (100%) rename {porting => examples/porting}/lv_port_indev_template.c (100%) rename {porting => examples/porting}/lv_port_indev_template.h (100%) delete mode 100644 library.properties diff --git a/examples/arduino/ESP32_TFT_eSPI/ESP32_TFT_eSPI.ino b/examples/arduino/ESP32_TFT_eSPI/ESP32_TFT_eSPI.ino new file mode 100644 index 000000000..4e777c19e --- /dev/null +++ b/examples/arduino/ESP32_TFT_eSPI/ESP32_TFT_eSPI.ino @@ -0,0 +1,119 @@ +#include +#include + +TFT_eSPI tft = TFT_eSPI(); /* TFT instance */ +static lv_disp_buf_t disp_buf; +static lv_color_t buf[LV_HOR_RES_MAX * 10]; + +#if USE_LV_LOG != 0 +/* Serial debugging */ +void my_print(lv_log_level_t level, const char * file, uint32_t line, const char * dsc) +{ + + Serial.printf("%s@%d->%s\r\n", file, line, dsc); + Serial.flush(); +} +#endif + +/* Display flushing */ +void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p) +{ + uint32_t w = (area->x2 - area->x1 + 1); + uint32_t h = (area->y2 - area->y1 + 1); + + tft.startWrite(); + tft.setAddrWindow(area->x1, area->y1, w, h); + tft.pushColors(&color_p->full, w * h, true); + tft.endWrite(); + + lv_disp_flush_ready(disp); +} + +/*Read the touchpad*/ +bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data) +{ + uint16_t touchX, touchY; + + bool touched = tft.getTouch(&touchX, &touchY, 600); + + if(!touched) + { + data->state = LV_INDEV_STATE_REL; + return false; + } + else + { + data->state = LV_INDEV_STATE_PR; + } + + if(touchX>screenWidth || touchY > screenHeight) + { + Serial.println("Y or y outside of expected parameters.."); + Serial.print("y:"); + Serial.print(touchX); + Serial.print(" x:"); + Serial.print(touchY); + } + else + { + /*Set the coordinates*/ + data->point.x = touchX; + data->point.y = touchY; + + Serial.print("Data x"); + Serial.println(touchX); + + Serial.print("Data y"); + Serial.println(touchY); + + } + + return false; /*Return `false` because we are not buffering and no more data to read*/ +} + +void setup() +{ + Serial.begin(115200); /* prepare for possible serial debug */ + + lv_init(); + +#if USE_LV_LOG != 0 + lv_log_register_print_cb(my_print); /* register print function for debugging */ +#endif + + tft.begin(); /* TFT init */ + tft.setRotation(1); /* Landscape orientation */ + + uint16_t calData[5] = { 275, 3620, 264, 3532, 1 }; + tft.setTouch(calData); + + lv_disp_buf_init(&disp_buf, buf, NULL, LV_HOR_RES_MAX * 10); + + /*Initialize the display*/ + lv_disp_drv_t disp_drv; + lv_disp_drv_init(&disp_drv); + disp_drv.hor_res = 320; + disp_drv.ver_res = 240; + disp_drv.flush_cb = my_disp_flush; + disp_drv.buffer = &disp_buf; + lv_disp_drv_register(&disp_drv); + + /*Initialize the (dummy) input device driver*/ + lv_indev_drv_t indev_drv; + lv_indev_drv_init(&indev_drv); + indev_drv.type = LV_INDEV_TYPE_POINTER; + indev_drv.read_cb = my_touchpad_read; + lv_indev_drv_register(&indev_drv); + + /* Try an example from the lv_examples repository + * https://github.com/lvgl/lv_examples*/ + lv_ex_btn_1(); +} + + +void loop() +{ + + lv_task_handler(); /* let the GUI do its work */ + delay(5); +} diff --git a/examples/arduino/ESP32_TFT_eSPI/README.md b/examples/arduino/ESP32_TFT_eSPI/README.md new file mode 100644 index 000000000..10f583d42 --- /dev/null +++ b/examples/arduino/ESP32_TFT_eSPI/README.md @@ -0,0 +1,44 @@ +# Example for lv_arduino using a slider + +This example has the screen set to 320x480 (ILI9488), change this by altering the following lines in the main ino file: + +```C +int screenWidth = 480; +int screenHeight = 320; +``` + +## Backlight + +Change pin 32 to your preferred backlight pin using a PNP transistor (2N3906) or remove the following code and connect directly to +ve: + +```C + ledcSetup(10, 5000/*freq*/, 10 /*resolution*/); + ledcAttachPin(32, 10); + analogReadResolution(10); + ledcWrite(10,768); +``` + +## Theme selection + +Change the following to change the theme: + +```C + lv_theme_t * th = lv_theme_night_init(210, NULL); //Set a HUE value and a Font for the Night Theme + lv_theme_set_current(th); +``` + +## Calibration + +This is using the bodmer tft_espi driver for touch. To correctly set the calibration load the calibration sketch and replace the following with your values: + +```C +uint16_t calData[5] = { 275, 3620, 264, 3532, 1 }; +``` + +## Screen rotation + +Check the following if you need to alter your screen rotation: + +```C + tft.setRotation(3); +``` diff --git a/examples/arduino/README.md b/examples/arduino/README.md new file mode 100644 index 000000000..b6a764c9e --- /dev/null +++ b/examples/arduino/README.md @@ -0,0 +1,37 @@ +# LVGL Arduino examples + +LVGL can be installed via Arduino IDE Library Manager or as an .ZIP library. +It will install [lv_exmaples](https://github.com/lvgl/lv_examples) which contains a lot of examples and demos to try LVGL. + +## Example + +There are simple examples which use the [TFT_eSPI](https://github.com/Bodmer/TFT_eSPI) library as a TFT driver to simplify testing. +To get all this to work you have to setup TFT_eSPI to work with your TFT display type via editing the `User_Setup.h` file in TFT_eSPI library folder, or by selecting your own configurtion in the `User_Setup_Select.h` file in TFT_eSPI library folder. + +LVGL library has its own configuration file called `lv_conf.h`. When LVGL is installed to followings needs to be done to configure it: +1. Go to directory of the installed Arduno libraries +2. Go to `lvgl` and copy `lv_conf_template.h` as `lvgl.h` next to the `lvgl` folder. +3. Open `lv_conf.h` and change the first `#if 0` to `#if 1` +4. Set the resolution of your display in `LV_HOR_RES_MAX` and `LV_VER_RES_MAX` +5. Set the color depth of you display in `LV_COLOR_DEPTH` +6. Set `LV_TICK_CUSTOM 1` + +## Debugging + +In case of trouble there are debug informations inside LVGL. In the `ESP32_TFT_eSPI` example there is `my_print` method, which allow to send this debug informations to the serial interface. To enable this feature you have to edit `lv_conf.h` file and enable logging in section `log settings`: + +```c +/*Log settings*/ +#define USE_LV_LOG 1 /*Enable/disable the log module*/ +#if LV_USE_LOG +/* How important log should be added: + * LV_LOG_LEVEL_TRACE A lot of logs to give detailed information + * LV_LOG_LEVEL_INFO Log important events + * LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem + * LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail + * LV_LOG_LEVEL_NONE Do not log anything + */ +# define LV_LOG_LEVEL LV_LOG_LEVEL_WARN +``` + +After enabling log module and setting LV_LOG_LEVEL accordingly the output log is sent to the `Serial` port @ 115200 Bd. diff --git a/porting/lv_port_disp_template.c b/examples/porting/lv_port_disp_template.c similarity index 100% rename from porting/lv_port_disp_template.c rename to examples/porting/lv_port_disp_template.c diff --git a/porting/lv_port_disp_template.h b/examples/porting/lv_port_disp_template.h similarity index 100% rename from porting/lv_port_disp_template.h rename to examples/porting/lv_port_disp_template.h diff --git a/porting/lv_port_fs_template.c b/examples/porting/lv_port_fs_template.c similarity index 100% rename from porting/lv_port_fs_template.c rename to examples/porting/lv_port_fs_template.c diff --git a/porting/lv_port_fs_template.h b/examples/porting/lv_port_fs_template.h similarity index 100% rename from porting/lv_port_fs_template.h rename to examples/porting/lv_port_fs_template.h diff --git a/porting/lv_port_indev_template.c b/examples/porting/lv_port_indev_template.c similarity index 100% rename from porting/lv_port_indev_template.c rename to examples/porting/lv_port_indev_template.c diff --git a/porting/lv_port_indev_template.h b/examples/porting/lv_port_indev_template.h similarity index 100% rename from porting/lv_port_indev_template.h rename to examples/porting/lv_port_indev_template.h diff --git a/library.properties b/library.properties deleted file mode 100644 index 9c8c48826..000000000 --- a/library.properties +++ /dev/null @@ -1,10 +0,0 @@ -name=lvgl -version=7.0.2 -author=kisvegabor -maintainer=Pavel Brychta -sentence=Full-featured Graphics Library for Embedded Systems -paragraph=Powerful and easy-to-use embedded GUI with many widgets, advanced visual effects (opacity, antialiasing, animations) and low memory requirements (16K RAM, 64K Flash). -category=Display -url=https://lvgl.io -architectures=* -includes=lvgl.h diff --git a/lv_conf_template.h b/lv_conf_template.h index f4cd80800..945761c86 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -268,8 +268,8 @@ typedef void * lv_img_decoder_user_data_t; * It removes the need to manually update the tick with `lv_tick_inc`) */ #define LV_TICK_CUSTOM 0 #if LV_TICK_CUSTOM == 1 -#define LV_TICK_CUSTOM_INCLUDE "something.h" /*Header for the sys time function*/ -#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current systime in ms*/ +#define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/ +#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/ #endif /*LV_TICK_CUSTOM*/ typedef void * lv_disp_drv_user_data_t; /*Type of user data in the display driver*/ diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index 8b389a355..d6c9163b6 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -391,10 +391,10 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */ #endif #if LV_TICK_CUSTOM == 1 #ifndef LV_TICK_CUSTOM_INCLUDE -#define LV_TICK_CUSTOM_INCLUDE "something.h" /*Header for the sys time function*/ +#define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the sys time function*/ #endif #ifndef LV_TICK_CUSTOM_SYS_TIME_EXPR -#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current systime in ms*/ +#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current sys time in ms*/ #endif #endif /*LV_TICK_CUSTOM*/ From bae04005d33627547efb4c6964656aa2eebf4225 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 29 Jun 2020 20:46:49 +0200 Subject: [PATCH 070/205] update old function name in comment --- src/lv_widgets/lv_textarea.c | 2 +- src/lv_widgets/lv_textarea.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lv_widgets/lv_textarea.c b/src/lv_widgets/lv_textarea.c index c8bfc65da..bfdc5af26 100644 --- a/src/lv_widgets/lv_textarea.c +++ b/src/lv_widgets/lv_textarea.c @@ -221,7 +221,7 @@ lv_obj_t * lv_textarea_create(lv_obj_t * par, const lv_obj_t * copy) /** * Insert a character to the current cursor position. - * To add a wide char, e.g. 'Á' use `lv_txt_encoded_conv_wc('Á')` + * To add a wide char, e.g. 'Á' use `_lv_txt_encoded_conv_wc('Á')` * @param ta pointer to a text area object * @param c a character (e.g. 'a') */ diff --git a/src/lv_widgets/lv_textarea.h b/src/lv_widgets/lv_textarea.h index 9f07749fe..49cfc9b7d 100644 --- a/src/lv_widgets/lv_textarea.h +++ b/src/lv_widgets/lv_textarea.h @@ -106,7 +106,7 @@ lv_obj_t * lv_textarea_create(lv_obj_t * par, const lv_obj_t * copy); /** * Insert a character to the current cursor position. - * To add a wide char, e.g. 'Á' use `lv_txt_encoded_conv_wc('Á')` + * To add a wide char, e.g. 'Á' use `_lv_txt_encoded_conv_wc('Á')` * @param ta pointer to a text area object * @param c a character (e.g. 'a') */ From 6d1da27b3cd07b29fa13af2c78074f7f075fd13b Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 30 Jun 2020 09:43:58 +0200 Subject: [PATCH 071/205] Create merge-to-dev.yml --- .github/workflows/merge-to-dev.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/merge-to-dev.yml diff --git a/.github/workflows/merge-to-dev.yml b/.github/workflows/merge-to-dev.yml new file mode 100644 index 000000000..997bb5d2e --- /dev/null +++ b/.github/workflows/merge-to-dev.yml @@ -0,0 +1,17 @@ +name: Merge master branch to dev +on: + push: + branches: + - 'master' +jobs: + merge-branch: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Merge to dev branch + uses: devmasx/merge-branch@v1.1.0 + with: + type: now + target_branch: 'dev' + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} From 86f74e3da2908fac67deb7d774aeac59d5899b67 Mon Sep 17 00:00:00 2001 From: xiaogangly <67666754+xiaogangly@users.noreply.github.com> Date: Wed, 1 Jul 2020 15:26:37 +0800 Subject: [PATCH 072/205] Fix a memory leak bug in function "lv_objmask_remove_mask" . There is a little memory leak When you call function "lv_objmask_remove_mask" to remove a specified mask. It's need free the memory of list's node. --- src/lv_widgets/lv_objmask.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lv_widgets/lv_objmask.c b/src/lv_widgets/lv_objmask.c index e78b1227d..2c817fb17 100644 --- a/src/lv_widgets/lv_objmask.c +++ b/src/lv_widgets/lv_objmask.c @@ -171,6 +171,7 @@ void lv_objmask_remove_mask(lv_obj_t * objmask, lv_objmask_mask_t * mask) else { lv_mem_free(mask->param); _lv_ll_remove(&ext->mask_ll, mask); + lv_mem_free(mask); } lv_obj_invalidate(objmask); From 6b246b2fed308a83d09a425d726cc1a698ba7f0c Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 1 Jul 2020 10:53:23 +0200 Subject: [PATCH 073/205] fix default theme colors --- lv_conf_template.h | 4 ++-- src/lv_conf_internal.h | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lv_conf_template.h b/lv_conf_template.h index 945761c86..828413eab 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -428,8 +428,8 @@ typedef void * lv_font_user_data_t; #define LV_THEME_DEFAULT_INCLUDE /*Include a header for the init. function*/ #define LV_THEME_DEFAULT_INIT lv_theme_material_init -#define LV_THEME_DEFAULT_COLOR_PRIMARY LV_COLOR_RED -#define LV_THEME_DEFAULT_COLOR_SECONDARY LV_COLOR_BLUE +#define LV_THEME_DEFAULT_COLOR_PRIMARY lv_color_hex(0x01a2b1) +#define LV_THEME_DEFAULT_COLOR_SECONDARY lv_color_hex(0x44d1b6) #define LV_THEME_DEFAULT_FLAG LV_THEME_MATERIAL_FLAG_LIGHT #define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_16 #define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_16 diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index d6c9163b6..ef86888a8 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -391,10 +391,10 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */ #endif #if LV_TICK_CUSTOM == 1 #ifndef LV_TICK_CUSTOM_INCLUDE -#define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the sys time function*/ +#define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/ #endif #ifndef LV_TICK_CUSTOM_SYS_TIME_EXPR -#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current sys time in ms*/ +#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/ #endif #endif /*LV_TICK_CUSTOM*/ @@ -638,10 +638,10 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */ #define LV_THEME_DEFAULT_INIT lv_theme_material_init #endif #ifndef LV_THEME_DEFAULT_COLOR_PRIMARY -#define LV_THEME_DEFAULT_COLOR_PRIMARY LV_COLOR_RED +#define LV_THEME_DEFAULT_COLOR_PRIMARY lv_color_hex(0x01a2b1) #endif #ifndef LV_THEME_DEFAULT_COLOR_SECONDARY -#define LV_THEME_DEFAULT_COLOR_SECONDARY LV_COLOR_BLUE +#define LV_THEME_DEFAULT_COLOR_SECONDARY lv_color_hex(0x44d1b6) #endif #ifndef LV_THEME_DEFAULT_FLAG #define LV_THEME_DEFAULT_FLAG LV_THEME_MATERIAL_FLAG_LIGHT @@ -702,7 +702,7 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */ /* Support bidirectional texts. * Allows mixing Left-to-Right and Right-to-Left texts. - * The direction will be processed according to the Unicode Bidirectional Algorithm: + * The direction will be processed according to the Unicode Bidirectioanl Algorithm: * https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/ #ifndef LV_USE_BIDI #define LV_USE_BIDI 0 From 06603a9c8456d91724bf78e0f05befa35b2204b3 Mon Sep 17 00:00:00 2001 From: pete-pjb Date: Wed, 1 Jul 2020 12:13:46 +0100 Subject: [PATCH 074/205] New functions for Check Box and a minor bug fix Remove use of c++ keyword 'new' from function parameter in lv_theme_set_base() function. Add function lv_checkbox_set_state(lv_obj_t * cb, lv_btn_state_t state). Add function lv_checkbox_get_state(const lv_obj_t * cb) Update Change log. --- CHANGELOG.md | 373 ++++++++++++++++++----------------- src/lv_themes/lv_theme.c | 6 +- src/lv_themes/lv_theme.h | 4 +- src/lv_widgets/lv_checkbox.h | 18 ++ 4 files changed, 211 insertions(+), 190 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15ec85db2..fd481633e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,185 +1,188 @@ -# Changelog - -## v7.2.0 (planned on 04.08.2020) -Available in the `dev` branch - -### New features -- Add `LV_CALENDAR_WEEK_STARTS_MONDAY` -- Add `lv_chart_set_x_start_point()` function - Set the index of the x-axis start point in the data array -- Add `lv_chart_set_ext_array()` function - Set an external array of data points to use for the chart -- Add `lv_chart_set_point_id()` function - Set an individual point value in the chart series directly based on index -- Add `lv_chart_get_x_start_point()` function - Get the current index of the x-axis start point in the data array -- Add `lv_chart_get_point_id()` function - Get an individual point value in the chart series directly based on index -- Add `ext_buf_assigned` bit field to `lv_chart_series_t` structure - it's true if external buffer is assigned to series -- Add `lv_chart_set_series_axis()` to assign series to primary or secondary axis -- Add `lv_chart_set_y_range()` to allow setting range of secondary y axis (based on `lv_chart_set_range` but extended with an axis parameter) -- Allow setting different font for the selected text in `lv_roller` -- Add `theme->apply_cb` to replace `theme->apply_xcb` to make it compatible with the MicroPython binding -- Add `lv_theme_set_base()` to allow easy extension of built-in (or any) themes -- Add `lv_obj_align_x()` and `lv_obj_align_y()` functions -- Add `lv_obj_align_origo_x()` and `lv_obj_align_origo_y()` functions - -## v7.1.0 (planned on 07.07.2020) -*Available in the `master` branch* - -### New features -- Add `focus_parent` attribute to `lv_obj` -- Allow using buttons in encoder input device -- Add lv_btnmatrix_set/get_align capability -- DMA2D: Remove dependency on ST CubeMX HAL -- Added `max_used` propriety to `lv_mem_monitor_t` struct -- In `lv_init` test if the the strings are UTF-8 encoded. -- Add `user_data` to themes -- Add LV_BIG_ENDIAN_SYSTEM flag to lv_conf.h in order to fix displaying images on big endian systems. - -### Bugfixes -- `lv_img` fix invalidation area when angle or zoom changes -- Update the style handling to support Big endian MCUs -- Change some methods to support big endian hardware. - -## v7.0.2 (16.06.2020) - -### Bugfixes -- `lv_textarea` fix wrong cursor position when clicked after the last character -- Change all text related indices from 16-bit to 32-bit integers throughout whole library. #1545 -- Fix gestures -- Do not call `set_px_cb` for transparent pixel -- Fix list button focus in material theme -- Fix crash when the a text area is cleared with the backspace of a keyboard -- Add version number to `lv_conf_template.h` -- Add log in true double buffering mode with `set_px_cb` -- `lv_dropdown`: fix missing `LV_EVENT_VALUE_CHANGED` event when used with encoder -- `lv_tileview`: fix if not the {0;0} tile is created first -- `lv_debug`: restructure to allow asserting in from `lv_misc` too -- add assert if `_lv_mem_buf_get()` fails -- `lv_textarea`: fix character delete in password mode -- Update `LV_OPA_MIN` and `LV_OPA_MAX` to widen the opacity processed range -- `lv_btnm` fix sending events for hidden buttons -- `lv_gaguge` make `lv_gauge_set_angle_offset` offset the labels and needles too -- Fix typo in the API `scrllable` -> `scrollable` -- `tabview` by default allow auto expanding the page only to right and bottom (#1573) -- fix crash when drawing gradient to the same color -- chart: fix memory leak - -## v7.0.1 (01.06.2020) - -### Bugfixes -- Make the Microptyhon working by adding the required variables as GC_ROOT -- Prefix some internal API functions with `_` to reduce the API of LVGL -- Fix built-in SimSun CJK font -- Fix UTF-8 encoding when `LV_USE_ARABIC_PERSIAN_CHARS` is enabled -- Fix DMA2D usage when 32 bit images directly blended -- Fix lv_roller in infinite mode when used with encoder -- Add `lv_theme_get_color_secondary()` -- Add `LV_COLOR_MIX_ROUND_OFS` to adjust color mixing to make it compatible with the GPU -- Improve DMA2D blending -- Remove memcpy from `lv_ll` (caused issues with some optimization settings) -- `lv_chart` fix X tick drawing -- Fix vertical dashed line drawing -- Some additonal minor fixes and formattings - -## v7.0.0 (18.05.2020) - -### Documentation -The docs for v7 is available at https://docs.littlevgl.com/v7/en/html/index.html - -### Legal changes - -The name of the project is changed to LVGL and the new website is on https://lvgl.io - -LVGL remains free under the same conditions (MIT license) and a company is created to manage LVGL and offer services. - - -### New drawing system -Complete rework of LVGL's draw engine to use "masks" for more advanced and higher quality graphical effects. -A possible use-case of this system is to remove the overflowing content from the rounded edges. -It also allows drawing perfectly anti-aliased circles, lines, and arcs. -Internally, the drawings happen by defining masks (such as rounded rectangle, line, angle). -When something is drawn the currently active masks can make some pixels transparent. -For example, rectangle borders are drawn by using 2 rectangle masks: one mask removes the inner part and another the outer part. - -The API in this regard remained the same but some new functions were added: -- `lv_img_set_zoom`: set image object's zoom factor -- `lv_img_set_angle`: set image object's angle without using canvas -- `lv_img_set_pivot`: set the pivot point of rotation - - -The new drawing engine brought new drawing features too. They are highlighted in the "style" section. - -### New style system -The old style system is replaced with a new more flexible and lightweighted one. -It uses an approach similar to CSS: support cascading styles, inheriting properties and local style properties per object. -As part of these updates, a lot of objects were reworked and the APIs have been changed. - -- more shadows options: *offset* and *spread* -- gradient stop position to shift the gradient area and horizontal gradient -- `LV_BLEND_MODE_NORMAL/ADDITIVE/SUBTRACTIVE` blending modes -- *clip corner*: crop the content on the rounded corners -- *text underline* and *strikethrough* -- dashed vertical and horizontal lines (*dash gap*, *dash_width*) -- *outline*: a border-like part drawn out of the background. Can have spacing to the background. -- *pattern*: display and image in the middle of the background or repeat it -- *value* display a text which is stored in the style. It can be used e.g. as a lighweighted text on buttons too. -- *margin*: similar to *padding* but used to keep space outside of the object - -Read the [Style](https://docs.littlevgl.com/v7/en/html/overview/style.html) section of the documentation to learn how the new styles system works. - -### GPU integration -To better utilize GPUs, from this version GPU usage can be integrated into LVGL. In `lv_conf.h` any supported GPUs can be enabled with a single configuration option. - -Right now, only ST's DMA2D (Chrom-ART) is integrated. More will in the upcoming releases. - -### Renames -The following object types are renamed: -- sw -> switch -- ta -> textarea -- cb -> checkbox -- lmeter -> linemeter -- mbox -> msgbox -- ddlist -> dropdown -- btnm -> btnmatrix -- kb -> keyboard -- preload -> spinner -- lv_objx folder -> lv_widgets -- LV_FIT_FILL -> LV_FIT_PARENT -- LV_FIT_FLOOD -> LV_FLOOD_MAX -- LV_LAYOUT_COL_L/M/R -> LV_LAYOUT_COLUMN_LEFT/MID/RIGHT -- LV_LAYOUT_ROW_T/M/B -> LV_LAYOUT_ROW_TOP/MID/BOTTOM - -### Reworked and improved object -- `dropdown`: Completely reworked. Now creates a separate list when opened and can be dropped to down/up/left/right. -- `label`: `body_draw` is removed, instead, if its style has a visible background/border/shadow etc it will be drawn. Padding really makes the object larger (not just virtually as before) -- `arc`: can draw bacground too. -- `btn`: doesn't store styles for each state because it's done naturally in the new style system. -- `calendar`: highlight the pressed datum. The used styles are changed: use `LV_CALENDAR_PART_DATE` normal for normal dates, checked for highlighted, focused for today, pressed for the being pressed. (checked+pressed, focused+pressed also work) -- `chart`: only has `LINE` and `COLUMN` types because with new styles all the others can be described. LV_CHART_PART_SERIES sets the style of the series. bg_opa > 0 draws an area in LINE mode. `LV_CHART_PART_SERIES_BG` also added to set a different style for the series area. Padding in `LV_CHART_PART_BG` makes the series area smaller, and it ensures space for axis labels/numbers. -- `linemeter`, `gauge`: can have background if the related style properties are set. Padding makes the scale/lines smaller. scale_border_width and scale_end_border_width allow to draw an arc on the outer part of the scale lines. -- `gauge`: `lv_gauge_set_needle_img` allows use image as needle -- `canvas`: allow drawing to true color alpha and alpha only canvas, add `lv_canvas_blur_hor/ver` and rename `lv_canvas_rotate` to `lv_canvas_transform` -- `textarea`: If available in the font use bullet (`U+2022`) character in text area password - -### New object types -- `lv_objmask`: masks can be added to it. The children will be masked accordingly. - -### Others -- Change the built-in fonts to [Montserrat](https://fonts.google.com/specimen/Montserrat) and add built-in fonts from 12 px to 48 px for every 2nd size. -- Add example CJK and Arabic/Persian/Hebrew built-in font -- Add ° and "bullet" to the built-in fonts -- Add Arabic/Persian script support: change the character according to its position in the text. -- Add `playback_time` to animations. -- Add `repeat_count` to animations instead of the current "repeat forever". -- Replace `LV_LAYOUT_PRETTY` with `LV_LAYOUT_PRETTY_TOP/MID/BOTTOM` - -### Demos -- [lv_examples](https://github.com/littlevgl/lv_examples) was reworked and new examples and demos were added - -### New release policy -- Maintain this Changelog for every release -- Save old major version in new branches. E.g. `release/v6` -- Merge new features and fixes directly into `master` and release a patch or minor releases every 2 weeks. - -### Migrating from v6 to v7 -- First and foremost, create a new `lv_conf.h` based on `lv_conf_templ.h`. -- To try the new version it suggested using a simulator project and see the examples. -- If you have a running project, the most difficult part of the migration is updating to the new style system. Unfortunately, there is no better way than manually updating to the new format. -- The other parts are mainly minor renames and refactoring as described above. +# Changelog + +## v7.2.0 (planned on 04.08.2020) +Available in the `dev` branch + +### New features +- Add `LV_CALENDAR_WEEK_STARTS_MONDAY` +- Add `lv_chart_set_x_start_point()` function - Set the index of the x-axis start point in the data array +- Add `lv_chart_set_ext_array()` function - Set an external array of data points to use for the chart +- Add `lv_chart_set_point_id()` function - Set an individual point value in the chart series directly based on index +- Add `lv_chart_get_x_start_point()` function - Get the current index of the x-axis start point in the data array +- Add `lv_chart_get_point_id()` function - Get an individual point value in the chart series directly based on index +- Add `ext_buf_assigned` bit field to `lv_chart_series_t` structure - it's true if external buffer is assigned to series +- Add `lv_chart_set_series_axis()` to assign series to primary or secondary axis +- Add `lv_chart_set_y_range()` to allow setting range of secondary y axis (based on `lv_chart_set_range` but extended with an axis parameter) +- Allow setting different font for the selected text in `lv_roller` +- Add `theme->apply_cb` to replace `theme->apply_xcb` to make it compatible with the MicroPython binding +- Add `lv_theme_set_base()` to allow easy extension of built-in (or any) themes +- Add `lv_obj_align_x()` and `lv_obj_align_y()` functions +- Add `lv_obj_align_origo_x()` and `lv_obj_align_origo_y()` functions + +## v7.1.0 (planned on 07.07.2020) +*Available in the `master` branch* + +### New features +- Add `focus_parent` attribute to `lv_obj` +- Allow using buttons in encoder input device +- Add lv_btnmatrix_set/get_align capability +- DMA2D: Remove dependency on ST CubeMX HAL +- Added `max_used` propriety to `lv_mem_monitor_t` struct +- In `lv_init` test if the the strings are UTF-8 encoded. +- Add `user_data` to themes +- Add LV_BIG_ENDIAN_SYSTEM flag to lv_conf.h in order to fix displaying images on big endian systems. +- Add inline function lv_checkbox_get_state(const lv_obj_t * cb) to extend the checkbox functionality. +- Add inline function lv_checkbox_set_state(const lv_obj_t * cb, lv_btn_state_t state ) to extend the checkbox functionality. + +### Bugfixes +- `lv_img` fix invalidation area when angle or zoom changes +- Update the style handling to support Big endian MCUs +- Change some methods to support big endian hardware. +- remove use of c++ keyword 'new' in parameter of function lv_theme_set_base(). + +## v7.0.2 (16.06.2020) + +### Bugfixes +- `lv_textarea` fix wrong cursor position when clicked after the last character +- Change all text related indices from 16-bit to 32-bit integers throughout whole library. #1545 +- Fix gestures +- Do not call `set_px_cb` for transparent pixel +- Fix list button focus in material theme +- Fix crash when the a text area is cleared with the backspace of a keyboard +- Add version number to `lv_conf_template.h` +- Add log in true double buffering mode with `set_px_cb` +- `lv_dropdown`: fix missing `LV_EVENT_VALUE_CHANGED` event when used with encoder +- `lv_tileview`: fix if not the {0;0} tile is created first +- `lv_debug`: restructure to allow asserting in from `lv_misc` too +- add assert if `_lv_mem_buf_get()` fails +- `lv_textarea`: fix character delete in password mode +- Update `LV_OPA_MIN` and `LV_OPA_MAX` to widen the opacity processed range +- `lv_btnm` fix sending events for hidden buttons +- `lv_gaguge` make `lv_gauge_set_angle_offset` offset the labels and needles too +- Fix typo in the API `scrllable` -> `scrollable` +- `tabview` by default allow auto expanding the page only to right and bottom (#1573) +- fix crash when drawing gradient to the same color +- chart: fix memory leak + +## v7.0.1 (01.06.2020) + +### Bugfixes +- Make the Microptyhon working by adding the required variables as GC_ROOT +- Prefix some internal API functions with `_` to reduce the API of LVGL +- Fix built-in SimSun CJK font +- Fix UTF-8 encoding when `LV_USE_ARABIC_PERSIAN_CHARS` is enabled +- Fix DMA2D usage when 32 bit images directly blended +- Fix lv_roller in infinite mode when used with encoder +- Add `lv_theme_get_color_secondary()` +- Add `LV_COLOR_MIX_ROUND_OFS` to adjust color mixing to make it compatible with the GPU +- Improve DMA2D blending +- Remove memcpy from `lv_ll` (caused issues with some optimization settings) +- `lv_chart` fix X tick drawing +- Fix vertical dashed line drawing +- Some additonal minor fixes and formattings + +## v7.0.0 (18.05.2020) + +### Documentation +The docs for v7 is available at https://docs.littlevgl.com/v7/en/html/index.html + +### Legal changes + +The name of the project is changed to LVGL and the new website is on https://lvgl.io + +LVGL remains free under the same conditions (MIT license) and a company is created to manage LVGL and offer services. + + +### New drawing system +Complete rework of LVGL's draw engine to use "masks" for more advanced and higher quality graphical effects. +A possible use-case of this system is to remove the overflowing content from the rounded edges. +It also allows drawing perfectly anti-aliased circles, lines, and arcs. +Internally, the drawings happen by defining masks (such as rounded rectangle, line, angle). +When something is drawn the currently active masks can make some pixels transparent. +For example, rectangle borders are drawn by using 2 rectangle masks: one mask removes the inner part and another the outer part. + +The API in this regard remained the same but some new functions were added: +- `lv_img_set_zoom`: set image object's zoom factor +- `lv_img_set_angle`: set image object's angle without using canvas +- `lv_img_set_pivot`: set the pivot point of rotation + + +The new drawing engine brought new drawing features too. They are highlighted in the "style" section. + +### New style system +The old style system is replaced with a new more flexible and lightweighted one. +It uses an approach similar to CSS: support cascading styles, inheriting properties and local style properties per object. +As part of these updates, a lot of objects were reworked and the APIs have been changed. + +- more shadows options: *offset* and *spread* +- gradient stop position to shift the gradient area and horizontal gradient +- `LV_BLEND_MODE_NORMAL/ADDITIVE/SUBTRACTIVE` blending modes +- *clip corner*: crop the content on the rounded corners +- *text underline* and *strikethrough* +- dashed vertical and horizontal lines (*dash gap*, *dash_width*) +- *outline*: a border-like part drawn out of the background. Can have spacing to the background. +- *pattern*: display and image in the middle of the background or repeat it +- *value* display a text which is stored in the style. It can be used e.g. as a lighweighted text on buttons too. +- *margin*: similar to *padding* but used to keep space outside of the object + +Read the [Style](https://docs.littlevgl.com/v7/en/html/overview/style.html) section of the documentation to learn how the new styles system works. + +### GPU integration +To better utilize GPUs, from this version GPU usage can be integrated into LVGL. In `lv_conf.h` any supported GPUs can be enabled with a single configuration option. + +Right now, only ST's DMA2D (Chrom-ART) is integrated. More will in the upcoming releases. + +### Renames +The following object types are renamed: +- sw -> switch +- ta -> textarea +- cb -> checkbox +- lmeter -> linemeter +- mbox -> msgbox +- ddlist -> dropdown +- btnm -> btnmatrix +- kb -> keyboard +- preload -> spinner +- lv_objx folder -> lv_widgets +- LV_FIT_FILL -> LV_FIT_PARENT +- LV_FIT_FLOOD -> LV_FLOOD_MAX +- LV_LAYOUT_COL_L/M/R -> LV_LAYOUT_COLUMN_LEFT/MID/RIGHT +- LV_LAYOUT_ROW_T/M/B -> LV_LAYOUT_ROW_TOP/MID/BOTTOM + +### Reworked and improved object +- `dropdown`: Completely reworked. Now creates a separate list when opened and can be dropped to down/up/left/right. +- `label`: `body_draw` is removed, instead, if its style has a visible background/border/shadow etc it will be drawn. Padding really makes the object larger (not just virtually as before) +- `arc`: can draw bacground too. +- `btn`: doesn't store styles for each state because it's done naturally in the new style system. +- `calendar`: highlight the pressed datum. The used styles are changed: use `LV_CALENDAR_PART_DATE` normal for normal dates, checked for highlighted, focused for today, pressed for the being pressed. (checked+pressed, focused+pressed also work) +- `chart`: only has `LINE` and `COLUMN` types because with new styles all the others can be described. LV_CHART_PART_SERIES sets the style of the series. bg_opa > 0 draws an area in LINE mode. `LV_CHART_PART_SERIES_BG` also added to set a different style for the series area. Padding in `LV_CHART_PART_BG` makes the series area smaller, and it ensures space for axis labels/numbers. +- `linemeter`, `gauge`: can have background if the related style properties are set. Padding makes the scale/lines smaller. scale_border_width and scale_end_border_width allow to draw an arc on the outer part of the scale lines. +- `gauge`: `lv_gauge_set_needle_img` allows use image as needle +- `canvas`: allow drawing to true color alpha and alpha only canvas, add `lv_canvas_blur_hor/ver` and rename `lv_canvas_rotate` to `lv_canvas_transform` +- `textarea`: If available in the font use bullet (`U+2022`) character in text area password + +### New object types +- `lv_objmask`: masks can be added to it. The children will be masked accordingly. + +### Others +- Change the built-in fonts to [Montserrat](https://fonts.google.com/specimen/Montserrat) and add built-in fonts from 12 px to 48 px for every 2nd size. +- Add example CJK and Arabic/Persian/Hebrew built-in font +- Add ° and "bullet" to the built-in fonts +- Add Arabic/Persian script support: change the character according to its position in the text. +- Add `playback_time` to animations. +- Add `repeat_count` to animations instead of the current "repeat forever". +- Replace `LV_LAYOUT_PRETTY` with `LV_LAYOUT_PRETTY_TOP/MID/BOTTOM` + +### Demos +- [lv_examples](https://github.com/littlevgl/lv_examples) was reworked and new examples and demos were added + +### New release policy +- Maintain this Changelog for every release +- Save old major version in new branches. E.g. `release/v6` +- Merge new features and fixes directly into `master` and release a patch or minor releases every 2 weeks. + +### Migrating from v6 to v7 +- First and foremost, create a new `lv_conf.h` based on `lv_conf_templ.h`. +- To try the new version it suggested using a simulator project and see the examples. +- If you have a running project, the most difficult part of the migration is updating to the new style system. Unfortunately, there is no better way than manually updating to the new format. +- The other parts are mainly minor renames and refactoring as described above. diff --git a/src/lv_themes/lv_theme.c b/src/lv_themes/lv_theme.c index d990912db..eddeebd83 100644 --- a/src/lv_themes/lv_theme.c +++ b/src/lv_themes/lv_theme.c @@ -98,12 +98,12 @@ void lv_theme_copy(lv_theme_t * theme, const lv_theme_t * copy) * Set a base theme for a theme. * The styles from the base them will be added before the styles of the current theme. * Arbitrary long chain of themes can be created by setting base themes. - * @param new pointer to theme which base should be set + * @param new_theme pointer to theme which base should be set * @param base pointer to the base theme */ -void lv_theme_set_base(lv_theme_t * new, lv_theme_t * base) +void lv_theme_set_base(lv_theme_t * new_theme, lv_theme_t * base) { - new->base = base; + new_theme->base = base; } /** diff --git a/src/lv_themes/lv_theme.h b/src/lv_themes/lv_theme.h index 788766726..8297b0b53 100644 --- a/src/lv_themes/lv_theme.h +++ b/src/lv_themes/lv_theme.h @@ -201,10 +201,10 @@ void lv_theme_copy(lv_theme_t * theme, const lv_theme_t * copy); * Set a base theme for a theme. * The styles from the base them will be added before the styles of the current theme. * Arbitrary long chain of themes can be created by setting base themes. - * @param new pointer to theme which base should be set + * @param new_theme pointer to theme which base should be set * @param base pointer to the base theme */ -void lv_theme_set_base(lv_theme_t * new, lv_theme_t * base); +void lv_theme_set_base(lv_theme_t * new_theme, lv_theme_t * base); /** * Set an apply callback for a theme. diff --git a/src/lv_widgets/lv_checkbox.h b/src/lv_widgets/lv_checkbox.h index 7a1536692..cb083733f 100644 --- a/src/lv_widgets/lv_checkbox.h +++ b/src/lv_widgets/lv_checkbox.h @@ -106,6 +106,15 @@ static inline void lv_checkbox_set_disabled(lv_obj_t * cb) lv_btn_set_state(cb, LV_BTN_STATE_DISABLED); } +/** + * Set the state of a check box + * @param cb pointer to a check box object + * @param state the new state of the check box (from lv_btn_state_t enum) + */ +static inline void lv_checkbox_set_state(lv_obj_t * cb, lv_btn_state_t state) +{ + lv_btn_set_state(cb, state); +} /*===================== * Getter functions *====================*/ @@ -137,6 +146,15 @@ static inline bool lv_checkbox_is_inactive(const lv_obj_t * cb) return lv_btn_get_state(cb) == LV_BTN_STATE_DISABLED ? true : false; } +/** + * Get the current state of a check box + * @param cb pointer to a check box object + * @return the state of the check box (from lv_btn_state_t enum) + */ +static inline lv_btn_state_t lv_checkbox_get_state(const lv_obj_t * cb) +{ + return lv_btn_get_state(cb); +} /********************** * MACROS From ac26442ca6eb42f025ef516aec92c88196112522 Mon Sep 17 00:00:00 2001 From: jbamaral Date: Wed, 1 Jul 2020 10:08:45 -0300 Subject: [PATCH 075/205] Fix lv_textarea_add_char on big endian (#1620) --- CHANGELOG.md | 1 + src/lv_misc/lv_txt.c | 3 ++- src/lv_widgets/lv_textarea.c | 18 +++++++++++++----- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3e542b3d..f31d2b820 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - Update the style handling to support Big endian MCUs - Change some methods to support big endian hardware. - Add LV_BIG_ENDIAN_SYSTEM flag to lv_conf.h in order to fix displaying images on big endian systems. +- Fix inserting chars in text area in big endian hardware. ## v7.0.2 (16.06.2020) diff --git a/src/lv_misc/lv_txt.c b/src/lv_misc/lv_txt.c index c76c486e7..a29a3c158 100644 --- a/src/lv_misc/lv_txt.c +++ b/src/lv_misc/lv_txt.c @@ -534,6 +534,7 @@ static uint32_t lv_txt_unicode_to_utf8(uint32_t letter_uni) */ static uint32_t lv_txt_utf8_conv_wc(uint32_t c) { +#if LV_BIG_ENDIAN_SYSTEM == 0 /*Swap the bytes (UTF-8 is big endian, but the MCUs are little endian)*/ if((c & 0x80) != 0) { uint32_t swapped; @@ -547,7 +548,7 @@ static uint32_t lv_txt_utf8_conv_wc(uint32_t c) } c = swapped; } - +#endif return c; } diff --git a/src/lv_widgets/lv_textarea.c b/src/lv_widgets/lv_textarea.c index bfdc5af26..182ac55da 100644 --- a/src/lv_widgets/lv_textarea.c +++ b/src/lv_widgets/lv_textarea.c @@ -231,9 +231,17 @@ void lv_textarea_add_char(lv_obj_t * ta, uint32_t c) lv_textarea_ext_t * ext = lv_obj_get_ext_attr(ta); - uint32_t letter_buf[2]; - letter_buf[0] = c; - letter_buf[1] = '\0'; + const char *letter_buf; + + uint32_t u32_buf[2]; + u32_buf[0] = c; + u32_buf[1] = 0; + + letter_buf = (char*)&u32_buf; + +#if LV_BIG_ENDIAN_SYSTEM + if (c != 0) while (*letter_buf == 0) ++letter_buf; +#endif ta_insert_replace = NULL; lv_event_send(ta, LV_EVENT_INSERT, letter_buf); @@ -241,7 +249,7 @@ void lv_textarea_add_char(lv_obj_t * ta, uint32_t c) if(ta_insert_replace[0] == '\0') return; /*Drop this text*/ /*Add the replaced text directly it's different from the original*/ - if(strcmp(ta_insert_replace, (char *)letter_buf)) { + if(strcmp(ta_insert_replace, letter_buf)) { lv_textarea_add_text(ta, ta_insert_replace); return; } @@ -272,7 +280,7 @@ void lv_textarea_add_char(lv_obj_t * ta, uint32_t c) if(txt[0] == '\0') lv_obj_invalidate(ta); } - lv_label_ins_text(ext->label, ext->cursor.pos, (const char *)letter_buf); /*Insert the character*/ + lv_label_ins_text(ext->label, ext->cursor.pos, letter_buf); /*Insert the character*/ lv_textarea_clear_selection(ta); /*Clear selection*/ if(ext->pwd_mode != 0) { From 1051e3f5a4dfc7ed14f1a64b6920a60180646478 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 1 Jul 2020 15:15:03 +0200 Subject: [PATCH 076/205] roller: fix copy. Closes #1628 --- src/lv_widgets/lv_roller.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lv_widgets/lv_roller.c b/src/lv_widgets/lv_roller.c index 23fe90837..07c89e6c2 100644 --- a/src/lv_widgets/lv_roller.c +++ b/src/lv_widgets/lv_roller.c @@ -120,11 +120,16 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy) } /*Copy an existing roller*/ else { + lv_label_create(roller, get_label(copy)); + lv_roller_ext_t * copy_ext = lv_obj_get_ext_attr(copy); lv_roller_set_options(roller, lv_roller_get_options(copy), copy_ext->mode); ext->auto_fit = copy_ext->auto_fit; lv_obj_t * scrl = lv_page_get_scrollable(roller); lv_obj_set_signal_cb(scrl, lv_roller_scrl_signal); + + lv_style_list_copy(&ext->style_sel, ©_ext->style_sel); + lv_obj_refresh_style(roller, LV_STYLE_PROP_ALL); } LV_LOG_INFO("roller created"); From 4b2c3e560b1c3b9705858ce6889ddd17d06b1e47 Mon Sep 17 00:00:00 2001 From: Petri HARRI Date: Wed, 1 Jul 2020 17:14:14 +0300 Subject: [PATCH 077/205] lv_slider: add knob-only feature and fix bug with symmetrical slider (#1578) --- src/lv_widgets/lv_slider.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/lv_widgets/lv_slider.c b/src/lv_widgets/lv_slider.c index d7efb7469..b9ce83cf3 100644 --- a/src/lv_widgets/lv_slider.c +++ b/src/lv_widgets/lv_slider.c @@ -260,15 +260,30 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par if(res != LV_RES_OK) return res; if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME); + lv_slider_type_t type = lv_slider_get_type(slider); lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider); + + /* Advanced hit testing: react only on dragging the knob(s) */ + if (sign == LV_SIGNAL_HIT_TEST) { + lv_hit_test_info_t *info = param; + + /* Ordinary slider: was the knob area hit? */ + info->result = _lv_area_is_point_on(&ext->right_knob_area, info->point, 0); + + /* There's still a change we have a hit, if we have another knob */ + if ((info->result == false) && (type == LV_SLIDER_TYPE_RANGE)) { + info->result = _lv_area_is_point_on(&ext->left_knob_area, info->point, 0); + } + } + lv_point_t p; if(sign == LV_SIGNAL_PRESSED) { ext->dragging = true; - if(lv_slider_get_type(slider) == LV_SLIDER_TYPE_NORMAL) { + if(type == LV_SLIDER_TYPE_NORMAL || type == LV_SLIDER_TYPE_SYMMETRICAL) { ext->value_to_set = &ext->bar.cur_value; } - else if(lv_slider_get_type(slider) == LV_SLIDER_TYPE_RANGE) { + else if(type == LV_SLIDER_TYPE_RANGE) { lv_indev_get_point(param, &p); bool hor = lv_obj_get_width(slider) >= lv_obj_get_height(slider); lv_bidi_dir_t base_dir = lv_obj_get_base_dir(slider); From fd186eeb1522ff32ad957914bbdaa77acae5d45a Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 3 Jul 2020 14:24:13 +0200 Subject: [PATCH 078/205] roller: fix copy --- src/lv_widgets/lv_roller.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lv_widgets/lv_roller.c b/src/lv_widgets/lv_roller.c index 07c89e6c2..066d3c29a 100644 --- a/src/lv_widgets/lv_roller.c +++ b/src/lv_widgets/lv_roller.c @@ -123,7 +123,10 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy) lv_label_create(roller, get_label(copy)); lv_roller_ext_t * copy_ext = lv_obj_get_ext_attr(copy); - lv_roller_set_options(roller, lv_roller_get_options(copy), copy_ext->mode); + ext->mode = copy_ext->mode; + ext->option_cnt = copy_ext->option_cnt; + ext->sel_opt_id = copy_ext->sel_opt_id; + ext->sel_opt_id_ori = copy_ext->sel_opt_id; ext->auto_fit = copy_ext->auto_fit; lv_obj_t * scrl = lv_page_get_scrollable(roller); lv_obj_set_signal_cb(scrl, lv_roller_scrl_signal); @@ -185,7 +188,7 @@ void lv_roller_set_options(lv_obj_t * roller, const char * options, lv_roller_mo lv_label_set_text(label, opt_extra); _lv_mem_buf_release(opt_extra); - ext->sel_opt_id = ((LV_ROLLER_INF_PAGES / 2) + 1) * ext->option_cnt; + ext->sel_opt_id = ((LV_ROLLER_INF_PAGES / 2) + 0) * ext->option_cnt; ext->option_cnt = ext->option_cnt * LV_ROLLER_INF_PAGES; } @@ -908,11 +911,12 @@ static void inf_normalize(void * scrl) if(ext->mode == LV_ROLLER_MODE_INIFINITE) { uint16_t real_id_cnt = ext->option_cnt / LV_ROLLER_INF_PAGES; - ext->sel_opt_id = ext->sel_opt_id % real_id_cnt; - ext->sel_opt_id += (LV_ROLLER_INF_PAGES / 2) * real_id_cnt; /*Select the middle page*/ + ext->sel_opt_id_ori = ext->sel_opt_id % real_id_cnt; + ext->sel_opt_id_ori += (LV_ROLLER_INF_PAGES / 2) * real_id_cnt; /*Select the middle page*/ + /*Move to the new id*/ const lv_font_t * font = lv_obj_get_style_text_font(roller, LV_ROLLER_PART_BG); lv_style_int_t line_space = lv_obj_get_style_text_line_space(roller, LV_ROLLER_PART_BG); From e9d3001dbff21ce1658d76b91033392fe5884fad Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 3 Jul 2020 14:48:54 +0200 Subject: [PATCH 079/205] img: improve hit test for transformed images --- CHANGELOG.md | 1 + src/lv_widgets/lv_img.c | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f31d2b820..9b02dddc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ - `tabview` by default allow auto expanding the page only to right and bottom (#1573) - fix crash when drawing gradient to the same color - chart: fix memory leak +- `img`: improve hit test for transformed images ## v7.0.1 (01.06.2020) diff --git a/src/lv_widgets/lv_img.c b/src/lv_widgets/lv_img.c index 3acb7cab3..6c6f65791 100644 --- a/src/lv_widgets/lv_img.c +++ b/src/lv_widgets/lv_img.c @@ -793,21 +793,24 @@ static lv_res_t lv_img_signal(lv_obj_t * img, lv_signal_t sign, void * param) } else if(sign == LV_SIGNAL_HIT_TEST) { lv_hit_test_info_t * info = param; - if(ext->zoom != 256 && ext->angle == 0) { - lv_coord_t origin_width = lv_area_get_width(&img->coords); - lv_coord_t origin_height = lv_area_get_height(&img->coords); - lv_coord_t scaled_width = (origin_width * ext->zoom + 255) / 256; - lv_coord_t scaled_height = (origin_height * ext->zoom + 255) / 256; + lv_style_int_t zoom = lv_obj_get_style_transform_zoom(img, LV_IMG_PART_MAIN); + zoom = (zoom * ext->zoom) >> 8; - lv_coord_t width_offset = (origin_width - scaled_width) / 2; - lv_coord_t height_offset = (origin_height - scaled_height) / 2; + lv_style_int_t angle = lv_obj_get_style_transform_angle(img, LV_IMG_PART_MAIN); + angle += ext->angle; + + /* If the object is exactly image sized (not cropped, not mosaic) and transformed + * perform hit test on it's transformed area */ + if(ext->w == lv_obj_get_width(img) && ext->h == lv_obj_get_height(img) && + (zoom != LV_IMG_ZOOM_NONE || angle != 0 || ext->pivot.x != ext->w / 2 || ext->pivot.y != ext->h / 2)) { lv_area_t coords; - lv_area_copy(&coords, &img->coords); - coords.x1 += width_offset; - coords.x2 -= width_offset; - coords.y1 += height_offset; - coords.y2 -= height_offset; + _lv_img_buf_get_transformed_area(&coords, ext->w, ext->h, angle, zoom, &ext->pivot); + coords.x1 += img->coords.x1; + coords.y1 += img->coords.y1; + coords.x2 += img->coords.x1; + coords.y2 += img->coords.y1; + info->result = _lv_area_is_point_on(&coords, info->point, 0); } else From e6fe8436f4104df3f6fe41377cc5e1ddebd0a5ce Mon Sep 17 00:00:00 2001 From: guoweilkd <35251456+guoweilkd@users.noreply.github.com> Date: Sat, 4 Jul 2020 19:30:07 +0800 Subject: [PATCH 080/205] Fix #1634: bug in `lv_tileview_scrl_signal` (#1636) --- src/lv_widgets/lv_tileview.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_widgets/lv_tileview.c b/src/lv_widgets/lv_tileview.c index 9755b9756..9d1fec097 100644 --- a/src/lv_widgets/lv_tileview.c +++ b/src/lv_widgets/lv_tileview.c @@ -376,7 +376,7 @@ static lv_res_t lv_tileview_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void if(!ext->drag_right_en && indev->proc.types.pointer.vect.x < 0 && x < -(ext->act_id.x * w)) { lv_page_start_edge_flash(tileview, LV_PAGE_EDGE_RIGHT); - lv_obj_set_x(scrl, -ext->act_id.x * w + top); + lv_obj_set_x(scrl, -ext->act_id.x * w + left); } /*Apply the drag constraints*/ From 9e56f750a7f424d0cd52ce5ba3d4ccfa82a97866 Mon Sep 17 00:00:00 2001 From: Amir Gonnen Date: Sun, 5 Jul 2020 02:50:14 +0300 Subject: [PATCH 081/205] Prevent compiler warning in lv_draw_rect.c (#1637) --- src/lv_draw/lv_draw_rect.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lv_draw/lv_draw_rect.c b/src/lv_draw/lv_draw_rect.c index d813ca3be..161b8e433 100644 --- a/src/lv_draw/lv_draw_rect.c +++ b/src/lv_draw/lv_draw_rect.c @@ -1111,7 +1111,7 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_draw_corner_buf(const lv_area_t * coord _lv_mem_buf_release(mask_line); if(sw == 1) { - uint32_t i; + int32_t i; lv_opa_t * res_buf = (lv_opa_t *)sh_buf; for(i = 0; i < size * size; i++) { res_buf[i] = (sh_buf[i] >> SHADOW_UPSACALE_SHIFT); @@ -1140,7 +1140,7 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_draw_corner_buf(const lv_area_t * coord shadow_blur_corner(size, sw, sh_buf); } - uint32_t x; + int32_t x; lv_opa_t * res_buf = (lv_opa_t *)sh_buf; for(x = 0; x < size * size; x++) { res_buf[x] = sh_buf[x]; From d8585d2ea3c11ae08964e0ab3ba395b1124b55b2 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 7 Jul 2020 09:32:21 +0200 Subject: [PATCH 082/205] update release.py --- scripts/release.py | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/scripts/release.py b/scripts/release.py index 1f97e885b..61b04745f 100644 --- a/scripts/release.py +++ b/scripts/release.py @@ -11,18 +11,10 @@ def title(t): def cmd(c): print("\n" + c) - os.system(c) - - -def increment(s): - """ look for the last sequence of number(s) in a string and increment """ - m = lastNum.search(s) - if m: - next = str(int(m.group(1))+1) - start, end = m.span(1) - s = s[:max(end-len(next), start)] + next + s[end:] - return s, str(next) - + r = os.system(c) + if r: + print("Exit due to previous error") + exit(r) def lvgl_clone(): title("lvgl: Clone") @@ -179,14 +171,16 @@ def drivers_merge_to_release_branch(v): def docs_clone(): title("docs: Clone") cmd("git clone --recursive https://github.com/lvgl/docs.git") - os.chdir("./docs/v7") - cmd("git co master") + os.chdir("./docs") def docs_get_api(): title("docs: Get API files") + cmd("git co latest") cmd("rm -rf xml"); cmd("cp -r ../../lvgl/docs/api_doc/xml ."); + cmd("git add xml"); + cmd('git commit -m "update API"') def docs_update_version(v): title("docs: Update version number") @@ -212,6 +206,8 @@ def docs_update_version(v): f.write(outbuf) f.close() + cmd("git add conf.py") + cmd('git ci -m "update conf.py to ' + v '"') def docs_update_trans(): title("docs: Update translations") @@ -219,17 +215,8 @@ def docs_update_trans(): def docs_build(): title("docs: Build") - cmd("./build.py clean") - - -def docs_commit_push(v): - title("docs: Commit release") - - cmd('git add .') - cmd('git ci -am "Release ' + v + '"') - cmd('git tag -a ' + v + ' -m "Release ' + v +'"') - cmd('git push origin master') - cmd('git push origin ' + v) + cmd("git checkout master") + cmd("./update.py latest") def clean_up(): title("Clean up repos") @@ -258,6 +245,5 @@ docs_get_api() docs_update_version(ver_str) #docs_update_trans() # Zanata is not working now docs_build() -docs_commit_push(ver_str) clean_up() From 43f5e4d2e0bfe140b37297ac165d40d398052e77 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 7 Jul 2020 09:36:59 +0200 Subject: [PATCH 083/205] Run code formatter --- src/lv_api_map.h | 2 +- src/lv_core/lv_indev.c | 186 ++++++++++++++++---------------- src/lv_core/lv_obj.c | 34 +++--- src/lv_core/lv_obj_style_dec.h | 9 +- src/lv_core/lv_style.c | 20 ++-- src/lv_draw/lv_draw_blend.c | 2 +- src/lv_draw/lv_img_buf.h | 2 +- src/lv_font/lv_font.h | 2 +- src/lv_gpu/lv_gpu_stm32_dma2d.c | 8 +- src/lv_misc/lv_mem.c | 23 ++-- src/lv_widgets/lv_btnmatrix.c | 20 ++-- src/lv_widgets/lv_btnmatrix.h | 10 +- src/lv_widgets/lv_label.c | 18 ++-- src/lv_widgets/lv_list.c | 2 +- src/lv_widgets/lv_roller.c | 6 +- src/lv_widgets/lv_slider.c | 6 +- src/lv_widgets/lv_textarea.c | 8 +- src/lv_widgets/lv_win.c | 30 +++--- 18 files changed, 200 insertions(+), 188 deletions(-) diff --git a/src/lv_api_map.h b/src/lv_api_map.h index cc3f245e8..dd2eb129a 100644 --- a/src/lv_api_map.h +++ b/src/lv_api_map.h @@ -180,7 +180,7 @@ static inline lv_obj_t * lv_page_get_scrl(lv_obj_t * page) static inline lv_obj_t * lv_win_add_btn(lv_obj_t * win, const void * img_src) { - return lv_win_add_btn_right(win, img_src); + return lv_win_add_btn_right(win, img_src); } #endif diff --git a/src/lv_core/lv_indev.c b/src/lv_core/lv_indev.c index a491c0996..98461f5ed 100644 --- a/src/lv_core/lv_indev.c +++ b/src/lv_core/lv_indev.c @@ -609,7 +609,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data) /*Process the steps they are valid only with released button*/ if(data->state != LV_INDEV_STATE_REL) { - data->enc_diff = 0; + data->enc_diff = 0; } /*Refresh the focused object. It might change due to lv_group_focus_prev/next*/ @@ -619,71 +619,74 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data) /*Button press happened*/ if(data->state == LV_INDEV_STATE_PR && last_state == LV_INDEV_STATE_REL) { - i->proc.pr_timestamp = lv_tick_get(); + i->proc.pr_timestamp = lv_tick_get(); - if (data->key == LV_KEY_ENTER) { - bool editable = false; - indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_GET_EDITABLE, &editable); + if(data->key == LV_KEY_ENTER) { + bool editable = false; + indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_GET_EDITABLE, &editable); - if(lv_group_get_editing(g) == true || editable == false) { - indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_PRESSED, NULL); - if(indev_reset_check(&i->proc)) return; + if(lv_group_get_editing(g) == true || editable == false) { + indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_PRESSED, NULL); + if(indev_reset_check(&i->proc)) return; - lv_event_send(indev_obj_act, LV_EVENT_PRESSED, NULL); - if(indev_reset_check(&i->proc)) return; - } - } else if(data->key == LV_KEY_LEFT) { - /*emulate encoder left*/ - data->enc_diff--; - } else if(data->key == LV_KEY_RIGHT) { - /*emulate encoder right*/ - data->enc_diff++; - } else if(data->key == LV_KEY_ESC) { + lv_event_send(indev_obj_act, LV_EVENT_PRESSED, NULL); + if(indev_reset_check(&i->proc)) return; + } + } + else if(data->key == LV_KEY_LEFT) { + /*emulate encoder left*/ + data->enc_diff--; + } + else if(data->key == LV_KEY_RIGHT) { + /*emulate encoder right*/ + data->enc_diff++; + } + else if(data->key == LV_KEY_ESC) { /*Send the ESC as a normal KEY*/ lv_group_send_data(g, LV_KEY_ESC); lv_event_send(indev_obj_act, LV_EVENT_CANCEL, NULL); if(indev_reset_check(&i->proc)) return; } - /*Just send other keys to the object (e.g. 'A' or `LV_GROUP_KEY_RIGHT`)*/ + /*Just send other keys to the object (e.g. 'A' or `LV_GROUP_KEY_RIGHT`)*/ else { lv_group_send_data(g, data->key); } } /*Pressing*/ else if(data->state == LV_INDEV_STATE_PR && last_state == LV_INDEV_STATE_PR) { - /* Long press*/ + /* Long press*/ if(i->proc.long_pr_sent == 0 && lv_tick_elaps(i->proc.pr_timestamp) > i->driver.long_press_time) { - i->proc.long_pr_sent = 1; - i->proc.longpr_rep_timestamp = lv_tick_get(); + i->proc.long_pr_sent = 1; + i->proc.longpr_rep_timestamp = lv_tick_get(); - if (data->key == LV_KEY_ENTER) { - bool editable = false; - indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_GET_EDITABLE, &editable); + if(data->key == LV_KEY_ENTER) { + bool editable = false; + indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_GET_EDITABLE, &editable); - /*On enter long press toggle edit mode.*/ - if(editable) { - /*Don't leave edit mode if there is only one object (nowhere to navigate)*/ - if(_lv_ll_is_empty(&g->obj_ll) == false) { - lv_group_set_editing(g, lv_group_get_editing(g) ? false : true); /*Toggle edit mode on long press*/ - } - } - /*If not editable then just send a long press signal*/ - else { - indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_LONG_PRESS, NULL); - if(indev_reset_check(&i->proc)) return; - lv_event_send(indev_obj_act, LV_EVENT_LONG_PRESSED, NULL); - if(indev_reset_check(&i->proc)) return; - } - } + /*On enter long press toggle edit mode.*/ + if(editable) { + /*Don't leave edit mode if there is only one object (nowhere to navigate)*/ + if(_lv_ll_is_empty(&g->obj_ll) == false) { + lv_group_set_editing(g, lv_group_get_editing(g) ? false : true); /*Toggle edit mode on long press*/ + } + } + /*If not editable then just send a long press signal*/ + else { + indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_LONG_PRESS, NULL); + if(indev_reset_check(&i->proc)) return; + lv_event_send(indev_obj_act, LV_EVENT_LONG_PRESSED, NULL); + if(indev_reset_check(&i->proc)) return; + } + } - i->proc.long_pr_sent = 1; + i->proc.long_pr_sent = 1; } /*Long press repeated time has elapsed?*/ - else if(i->proc.long_pr_sent != 0 && lv_tick_elaps(i->proc.longpr_rep_timestamp) > i->driver.long_press_rep_time) { + else if(i->proc.long_pr_sent != 0 && lv_tick_elaps(i->proc.longpr_rep_timestamp) > i->driver.long_press_rep_time) { - i->proc.longpr_rep_timestamp = lv_tick_get(); + i->proc.longpr_rep_timestamp = lv_tick_get(); if(data->key == LV_KEY_ENTER) { indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_LONG_PRESS_REP, NULL); @@ -692,12 +695,14 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data) if(indev_reset_check(&i->proc)) return; } else if(data->key == LV_KEY_LEFT) { - /*emulate encoder left*/ - data->enc_diff--; - } else if(data->key == LV_KEY_RIGHT) { - /*emulate encoder right*/ - data->enc_diff++; - } else { + /*emulate encoder left*/ + data->enc_diff--; + } + else if(data->key == LV_KEY_RIGHT) { + /*emulate encoder right*/ + data->enc_diff++; + } + else { lv_group_send_data(g, data->key); if(indev_reset_check(&i->proc)) return; } @@ -708,49 +713,49 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data) /*Release happened*/ else if(data->state == LV_INDEV_STATE_REL && last_state == LV_INDEV_STATE_PR) { - if (data->key == LV_KEY_ENTER) { - bool editable = false; - indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_GET_EDITABLE, &editable); + if(data->key == LV_KEY_ENTER) { + bool editable = false; + indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_GET_EDITABLE, &editable); - /*The button was released on a non-editable object. Just send enter*/ - if(editable == false) { - indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_RELEASED, NULL); - if(indev_reset_check(&i->proc)) return; + /*The button was released on a non-editable object. Just send enter*/ + if(editable == false) { + indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_RELEASED, NULL); + if(indev_reset_check(&i->proc)) return; - if(i->proc.long_pr_sent == 0) lv_event_send(indev_obj_act, LV_EVENT_SHORT_CLICKED, NULL); - if(indev_reset_check(&i->proc)) return; + if(i->proc.long_pr_sent == 0) lv_event_send(indev_obj_act, LV_EVENT_SHORT_CLICKED, NULL); + if(indev_reset_check(&i->proc)) return; - lv_event_send(indev_obj_act, LV_EVENT_CLICKED, NULL); - if(indev_reset_check(&i->proc)) return; + lv_event_send(indev_obj_act, LV_EVENT_CLICKED, NULL); + if(indev_reset_check(&i->proc)) return; - lv_event_send(indev_obj_act, LV_EVENT_RELEASED, NULL); - if(indev_reset_check(&i->proc)) return; - } - /*An object is being edited and the button is released. */ - else if(g->editing) { - /*Ignore long pressed enter release because it comes from mode switch*/ - if(!i->proc.long_pr_sent || _lv_ll_is_empty(&g->obj_ll)) { - indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_RELEASED, NULL); - if(indev_reset_check(&i->proc)) return; + lv_event_send(indev_obj_act, LV_EVENT_RELEASED, NULL); + if(indev_reset_check(&i->proc)) return; + } + /*An object is being edited and the button is released. */ + else if(g->editing) { + /*Ignore long pressed enter release because it comes from mode switch*/ + if(!i->proc.long_pr_sent || _lv_ll_is_empty(&g->obj_ll)) { + indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_RELEASED, NULL); + if(indev_reset_check(&i->proc)) return; - lv_event_send(indev_obj_act, LV_EVENT_SHORT_CLICKED, NULL); - if(indev_reset_check(&i->proc)) return; + lv_event_send(indev_obj_act, LV_EVENT_SHORT_CLICKED, NULL); + if(indev_reset_check(&i->proc)) return; - lv_event_send(indev_obj_act, LV_EVENT_CLICKED, NULL); - if(indev_reset_check(&i->proc)) return; + lv_event_send(indev_obj_act, LV_EVENT_CLICKED, NULL); + if(indev_reset_check(&i->proc)) return; - lv_event_send(indev_obj_act, LV_EVENT_RELEASED, NULL); - if(indev_reset_check(&i->proc)) return; + lv_event_send(indev_obj_act, LV_EVENT_RELEASED, NULL); + if(indev_reset_check(&i->proc)) return; - lv_group_send_data(g, LV_KEY_ENTER); - } - } - /*If the focused object is editable and now in navigate mode then on enter switch edit - mode*/ - else if(editable && !g->editing && !i->proc.long_pr_sent) { - lv_group_set_editing(g, true); /*Set edit mode*/ - } - } + lv_group_send_data(g, LV_KEY_ENTER); + } + } + /*If the focused object is editable and now in navigate mode then on enter switch edit + mode*/ + else if(editable && !g->editing && !i->proc.long_pr_sent) { + lv_group_set_editing(g, true); /*Set edit mode*/ + } + } i->proc.pr_timestamp = 0; i->proc.long_pr_sent = 0; @@ -758,7 +763,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data) indev_obj_act = NULL; /*if encoder steps or simulated steps via left/right keys*/ - if (data->enc_diff != 0) { + if(data->enc_diff != 0) { /*In edit mode send LEFT/RIGHT keys*/ if(lv_group_get_editing(g)) { int32_t s; @@ -1211,15 +1216,16 @@ static void indev_click_focus(lv_indev_proc_t * proc) } /*Focus to the act. in its group*/ - if(g_act) { - lv_group_focus_obj(indev_obj_act); - if(indev_reset_check(proc)) return; - } else { + if(g_act) { + lv_group_focus_obj(indev_obj_act); + if(indev_reset_check(proc)) return; + } + else { lv_signal_send(indev_obj_act, LV_SIGNAL_FOCUS, NULL); if(indev_reset_check(proc)) return; lv_event_send(indev_obj_act, LV_EVENT_FOCUSED, NULL); if(indev_reset_check(proc)) return; - } + } } #else if(proc->types.pointer.last_pressed) { diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 9259d3325..059d3d78b 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -39,7 +39,7 @@ #include LV_THEME_DEFAULT_INCLUDE #if LV_USE_GPU_STM32_DMA2D -#include "../lv_gpu/lv_gpu_stm32_dma2d.h" + #include "../lv_gpu/lv_gpu_stm32_dma2d.h" #endif /********************* @@ -1570,21 +1570,21 @@ void lv_obj_set_gesture_parent(lv_obj_t * obj, bool en) */ void lv_obj_set_focus_parent(lv_obj_t * obj, bool en) { - if (lv_obj_is_focused(obj)) { - if (en) { - obj->focus_parent = 1; - lv_obj_clear_state(obj, LV_STATE_FOCUSED | LV_STATE_EDITED); - lv_obj_set_state(lv_obj_get_focused_obj(obj), LV_STATE_FOCUSED); - } - else { - lv_obj_clear_state(lv_obj_get_focused_obj(obj), LV_STATE_FOCUSED | LV_STATE_EDITED); - lv_obj_set_state(obj, LV_STATE_FOCUSED); - obj->focus_parent = 0; - } + if(lv_obj_is_focused(obj)) { + if(en) { + obj->focus_parent = 1; + lv_obj_clear_state(obj, LV_STATE_FOCUSED | LV_STATE_EDITED); + lv_obj_set_state(lv_obj_get_focused_obj(obj), LV_STATE_FOCUSED); + } + else { + lv_obj_clear_state(lv_obj_get_focused_obj(obj), LV_STATE_FOCUSED | LV_STATE_EDITED); + lv_obj_set_state(obj, LV_STATE_FOCUSED); + obj->focus_parent = 0; + } + } + else { + obj->focus_parent = (en == true ? 1 : 0); } - else { - obj->focus_parent = (en == true ? 1 : 0); - } } /** @@ -3704,10 +3704,10 @@ lv_obj_t * lv_obj_get_focused_obj(const lv_obj_t * obj) if(obj == NULL) return NULL; const lv_obj_t * focus_obj = obj; while(lv_obj_get_focus_parent(focus_obj) != false && focus_obj != NULL) { - focus_obj = lv_obj_get_parent(focus_obj); + focus_obj = lv_obj_get_parent(focus_obj); } - return (lv_obj_t*)focus_obj; + return (lv_obj_t *)focus_obj; } /** diff --git a/src/lv_core/lv_obj_style_dec.h b/src/lv_core/lv_obj_style_dec.h index e1b65f720..47751597e 100644 --- a/src/lv_core/lv_obj_style_dec.h +++ b/src/lv_core/lv_obj_style_dec.h @@ -246,7 +246,8 @@ static inline void lv_style_set_pad_ver(lv_style_t * style, lv_state_t state, lv } -static inline void lv_obj_set_style_local_margin_all(lv_obj_t * obj, uint8_t part, lv_state_t state, lv_style_int_t value) +static inline void lv_obj_set_style_local_margin_all(lv_obj_t * obj, uint8_t part, lv_state_t state, + lv_style_int_t value) { lv_obj_set_style_local_margin_top(obj, part, state, value); lv_obj_set_style_local_margin_bottom(obj, part, state, value); @@ -264,7 +265,8 @@ static inline void lv_style_set_margin_all(lv_style_t * style, lv_state_t state, } -static inline void lv_obj_set_style_local_margin_hor(lv_obj_t * obj, uint8_t part, lv_state_t state, lv_style_int_t value) +static inline void lv_obj_set_style_local_margin_hor(lv_obj_t * obj, uint8_t part, lv_state_t state, + lv_style_int_t value) { lv_obj_set_style_local_margin_left(obj, part, state, value); lv_obj_set_style_local_margin_right(obj, part, state, value); @@ -278,7 +280,8 @@ static inline void lv_style_set_margin_hor(lv_style_t * style, lv_state_t state, } -static inline void lv_obj_set_style_local_margin_ver(lv_obj_t * obj, uint8_t part, lv_state_t state, lv_style_int_t value) +static inline void lv_obj_set_style_local_margin_ver(lv_obj_t * obj, uint8_t part, lv_state_t state, + lv_style_int_t value) { lv_obj_set_style_local_margin_top(obj, part, state, value); lv_obj_set_style_local_margin_bottom(obj, part, state, value); diff --git a/src/lv_core/lv_style.c b/src/lv_core/lv_style.c index 1be4e3dbe..ce3665e0d 100644 --- a/src/lv_core/lv_style.c +++ b/src/lv_core/lv_style.c @@ -36,10 +36,10 @@ **********************/ LV_ATTRIBUTE_FAST_MEM static inline int32_t get_property_index(const lv_style_t * style, lv_style_property_t prop); static lv_style_t * get_alloc_local_style(lv_style_list_t * list); -static inline void style_resize(lv_style_t *style, size_t sz); -static inline lv_style_property_t get_style_prop(const lv_style_t *style, size_t idx); -static inline uint8_t get_style_prop_id(const lv_style_t *style, size_t idx); -static inline uint8_t get_style_prop_attr(const lv_style_t *style, size_t idx); +static inline void style_resize(lv_style_t * style, size_t sz); +static inline lv_style_property_t get_style_prop(const lv_style_t * style, size_t idx); +static inline uint8_t get_style_prop_id(const lv_style_t * style, size_t idx); +static inline uint8_t get_style_prop_attr(const lv_style_t * style, size_t idx); static inline size_t get_prop_size(uint8_t prop_id); static inline size_t get_next_prop_index(uint8_t prop_id, size_t id); @@ -1065,7 +1065,7 @@ LV_ATTRIBUTE_FAST_MEM static inline int32_t get_property_index(const lv_style_t size_t i = 0; - uint8_t prop_id; + uint8_t prop_id; while((prop_id = get_style_prop_id(style, i)) != _LV_STYLE_CLOSEING_PROP) { if(prop_id == id_to_find) { lv_style_attr_t attr_i; @@ -1124,7 +1124,7 @@ static lv_style_t * get_alloc_local_style(lv_style_list_t * list) * @param style pointer to the style to be resized. * @param size new size */ -static inline void style_resize(lv_style_t *style, size_t sz) +static inline void style_resize(lv_style_t * style, size_t sz) { style->map = lv_mem_realloc(style->map, sz); } @@ -1135,10 +1135,10 @@ static inline void style_resize(lv_style_t *style, size_t sz) * @param idx index of the style in style->map * @return property in style->map + idx */ -static inline lv_style_property_t get_style_prop(const lv_style_t *style, size_t idx) +static inline lv_style_property_t get_style_prop(const lv_style_t * style, size_t idx) { lv_style_property_t prop; - uint8_t *prop_p = (uint8_t*)∝ + uint8_t * prop_p = (uint8_t *)∝ prop_p[0] = style->map[idx]; prop_p[1] = style->map[idx + 1]; return prop; @@ -1150,7 +1150,7 @@ static inline lv_style_property_t get_style_prop(const lv_style_t *style, size_t * @param idx index of the style in style->map * @return id of property in style->map + idx */ -static inline uint8_t get_style_prop_id(const lv_style_t *style, size_t idx) +static inline uint8_t get_style_prop_id(const lv_style_t * style, size_t idx) { return get_style_prop(style, idx) & 0xFF; } @@ -1161,7 +1161,7 @@ static inline uint8_t get_style_prop_id(const lv_style_t *style, size_t idx) * @param idx index of the style in style->map * @return attribute of property in style->map + idx */ -static inline uint8_t get_style_prop_attr(const lv_style_t *style, size_t idx) +static inline uint8_t get_style_prop_attr(const lv_style_t * style, size_t idx) { return ((get_style_prop(style, idx) >> 8) & 0xFFU); } diff --git a/src/lv_draw/lv_draw_blend.c b/src/lv_draw/lv_draw_blend.c index 3b94c3c78..375bee819 100644 --- a/src/lv_draw/lv_draw_blend.c +++ b/src/lv_draw/lv_draw_blend.c @@ -61,7 +61,7 @@ static inline lv_color_t color_blend_true_color_subtractive(lv_color_t fg, lv_co **********************/ #if LV_USE_GPU || LV_USE_GPU_STM32_DMA2D -LV_ATTRIBUTE_DMA static lv_color_t blend_buf[LV_HOR_RES_MAX]; + LV_ATTRIBUTE_DMA static lv_color_t blend_buf[LV_HOR_RES_MAX]; #endif /********************** diff --git a/src/lv_draw/lv_img_buf.h b/src/lv_draw/lv_img_buf.h index 4b6db2b87..204f3c1d8 100644 --- a/src/lv_draw/lv_img_buf.h +++ b/src/lv_draw/lv_img_buf.h @@ -103,7 +103,7 @@ typedef uint8_t lv_img_cf_t; * LVGL image header */ /* The first 8 bit is very important to distinguish the different source types. - * For more info see `lv_img_get_src_type()` in lv_img.c + * For more info see `lv_img_get_src_type()` in lv_img.c * On big endian systems the order is reversed so cf and always_zero must be at * the end of the struct. * */ diff --git a/src/lv_font/lv_font.h b/src/lv_font/lv_font.h index b319158c1..041211acd 100644 --- a/src/lv_font/lv_font.h +++ b/src/lv_font/lv_font.h @@ -174,7 +174,7 @@ LV_FONT_DECLARE(lv_font_montserrat_32) #if LV_FONT_MONTSERRAT_34 LV_FONT_DECLARE(lv_font_montserrat_34) #endif - + #if LV_FONT_MONTSERRAT_36 LV_FONT_DECLARE(lv_font_montserrat_36) #endif diff --git a/src/lv_gpu/lv_gpu_stm32_dma2d.c b/src/lv_gpu/lv_gpu_stm32_dma2d.c index 9810587dd..d5c8e40dc 100644 --- a/src/lv_gpu/lv_gpu_stm32_dma2d.c +++ b/src/lv_gpu/lv_gpu_stm32_dma2d.c @@ -194,10 +194,10 @@ void lv_gpu_stm32_dma2d_blend(lv_color_t * buf, lv_coord_t buf_w, const lv_color DMA2D->BGOR = buf_w - copy_w; DMA2D->FGPFCCR = (uint32_t)LV_DMA2D_COLOR_FORMAT - /* alpha mode 2, replace with foreground * alpha value */ - | (2 << DMA2D_FGPFCCR_AM_Pos) - /* alpha value */ - | (opa << DMA2D_FGPFCCR_ALPHA_Pos); + /* alpha mode 2, replace with foreground * alpha value */ + | (2 << DMA2D_FGPFCCR_AM_Pos) + /* alpha value */ + | (opa << DMA2D_FGPFCCR_ALPHA_Pos); DMA2D->FGMAR = (uint32_t)map; DMA2D->FGOR = map_w - copy_w; diff --git a/src/lv_misc/lv_mem.c b/src/lv_misc/lv_mem.c index 331771d7e..8775f39da 100644 --- a/src/lv_misc/lv_mem.c +++ b/src/lv_misc/lv_mem.c @@ -87,7 +87,7 @@ typedef struct { static uint32_t zero_mem; /*Give the address of this variable if 0 byte should be allocated*/ #if LV_MEM_CUSTOM == 0 -static uint32_t mem_max_size; /*Tracks the maximum total size of memory ever used from the internal heap*/ + static uint32_t mem_max_size; /*Tracks the maximum total size of memory ever used from the internal heap*/ #endif static uint8_t mem_buf1_32[MEM_BUF_SMALL_SIZE]; @@ -125,7 +125,7 @@ void _lv_mem_init(void) #else work_mem = (uint8_t *)LV_MEM_ADR; #endif - + lv_mem_ent_t * full = (lv_mem_ent_t *)work_mem; full->header.s.used = 0; /*The total mem size id reduced by the first header and the close patterns */ @@ -205,16 +205,17 @@ void * lv_mem_alloc(size_t size) #endif if(alloc == NULL) { - LV_LOG_WARN("Couldn't allocate memory"); - }else{ - #if LV_MEM_CUSTOM == 0 - /* just a safety check, should always be true */ - if ((uintptr_t) alloc > (uintptr_t) work_mem) { - if ((((uintptr_t) alloc - (uintptr_t) work_mem) + size) > mem_max_size) { - mem_max_size = ((uintptr_t) alloc - (uintptr_t) work_mem) + size; + LV_LOG_WARN("Couldn't allocate memory"); + } + else { +#if LV_MEM_CUSTOM == 0 + /* just a safety check, should always be true */ + if((uintptr_t) alloc > (uintptr_t) work_mem) { + if((((uintptr_t) alloc - (uintptr_t) work_mem) + size) > mem_max_size) { + mem_max_size = ((uintptr_t) alloc - (uintptr_t) work_mem) + size; + } } - } - #endif +#endif } return alloc; diff --git a/src/lv_widgets/lv_btnmatrix.c b/src/lv_widgets/lv_btnmatrix.c index d40880ce1..5501fcfa6 100644 --- a/src/lv_widgets/lv_btnmatrix.c +++ b/src/lv_widgets/lv_btnmatrix.c @@ -427,12 +427,12 @@ void lv_btnmatrix_set_one_check(lv_obj_t * btnm, bool one_chk) * @param btnm pointer to a btnmatrix object * @param align LV_LABEL_ALIGN_LEFT, LV_LABEL_ALIGN_RIGHT or LV_LABEL_ALIGN_CENTER */ -void lv_btnmatrix_set_align(lv_obj_t* btnm, lv_label_align_t align) +void lv_btnmatrix_set_align(lv_obj_t * btnm, lv_label_align_t align) { LV_ASSERT_OBJ(btnm, LV_OBJX_NAME); - lv_btnmatrix_ext_t* ext = lv_obj_get_ext_attr(btnm); - if (ext->align == align) return; + lv_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm); + if(ext->align == align) return; ext->align = align; @@ -585,18 +585,18 @@ bool lv_btnmatrix_get_one_check(const lv_obj_t * btnm) * @param btnm pointer to a btnmatrix object * @return LV_LABEL_ALIGN_LEFT, LV_LABEL_ALIGN_RIGHT or LV_LABEL_ALIGN_CENTER */ -lv_label_align_t lv_btnmatrix_get_align(const lv_obj_t* btnm) +lv_label_align_t lv_btnmatrix_get_align(const lv_obj_t * btnm) { LV_ASSERT_OBJ(btnm, LV_OBJX_NAME); - lv_btnmatrix_ext_t* ext = lv_obj_get_ext_attr(btnm); + lv_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm); lv_label_align_t align = ext->align; - if (align == LV_LABEL_ALIGN_AUTO) { + if(align == LV_LABEL_ALIGN_AUTO) { #if LV_USE_BIDI lv_bidi_dir_t base_dir = lv_obj_get_base_dir(btnm); - if (base_dir == LV_BIDI_DIR_RTL) align = LV_LABEL_ALIGN_RIGHT; + if(base_dir == LV_BIDI_DIR_RTL) align = LV_LABEL_ALIGN_RIGHT; else align = LV_LABEL_ALIGN_LEFT; #else align = LV_LABEL_ALIGN_LEFT; @@ -641,10 +641,10 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl uint16_t btn_i = 0; uint16_t txt_i = 0; lv_txt_flag_t txt_flag = LV_TXT_FLAG_NONE; - if (ext->recolor) txt_flag |= LV_TXT_FLAG_RECOLOR; + if(ext->recolor) txt_flag |= LV_TXT_FLAG_RECOLOR; lv_label_align_t align = lv_btnmatrix_get_align(btnm); - if (align == LV_LABEL_ALIGN_CENTER) txt_flag |= LV_TXT_FLAG_CENTER; - if (align == LV_LABEL_ALIGN_RIGHT) txt_flag |= LV_TXT_FLAG_RIGHT; + if(align == LV_LABEL_ALIGN_CENTER) txt_flag |= LV_TXT_FLAG_CENTER; + if(align == LV_LABEL_ALIGN_RIGHT) txt_flag |= LV_TXT_FLAG_RIGHT; lv_draw_rect_dsc_t draw_rect_rel_dsc; lv_draw_label_dsc_t draw_label_rel_dsc; diff --git a/src/lv_widgets/lv_btnmatrix.h b/src/lv_widgets/lv_btnmatrix.h index f9d9b06a0..c30a959f0 100644 --- a/src/lv_widgets/lv_btnmatrix.h +++ b/src/lv_widgets/lv_btnmatrix.h @@ -170,13 +170,13 @@ void lv_btnmatrix_set_btn_width(lv_obj_t * btnm, uint16_t btn_id, uint8_t width) * @param one_chk Whether "one check" mode is enabled */ void lv_btnmatrix_set_one_check(lv_obj_t * btnm, bool one_chk); - + /** * Set the align of the map text (left, right or center) * @param btnm pointer to a btnmatrix object * @param align LV_LABEL_ALIGN_LEFT, LV_LABEL_ALIGN_RIGHT or LV_LABEL_ALIGN_CENTER */ -void lv_btnmatrix_set_align(lv_obj_t* btnm, lv_label_align_t align); +void lv_btnmatrix_set_align(lv_obj_t * btnm, lv_label_align_t align); /*===================== * Getter functions @@ -244,14 +244,14 @@ bool lv_btnmatrix_get_btn_ctrl(lv_obj_t * btnm, uint16_t btn_id, lv_btnmatrix_ct * @return whether "one toggle" mode is enabled */ bool lv_btnmatrix_get_one_check(const lv_obj_t * btnm); - + /** * Get the align attribute * @param btnm pointer to a btnmatrix object * @return LV_LABEL_ALIGN_LEFT, LV_LABEL_ALIGN_RIGHT or LV_LABEL_ALIGN_CENTER */ -lv_label_align_t lv_btnmatrix_get_align(const lv_obj_t* btnm); - +lv_label_align_t lv_btnmatrix_get_align(const lv_obj_t * btnm); + /********************** * MACROS **********************/ diff --git a/src/lv_widgets/lv_label.c b/src/lv_widgets/lv_label.c index da8b6d308..1113a6b10 100644 --- a/src/lv_widgets/lv_label.c +++ b/src/lv_widgets/lv_label.c @@ -577,15 +577,15 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint32_t char_id, lv_point_ if(txt[0] == '\0') { pos->y = 0; switch(align) { - case LV_LABEL_ALIGN_LEFT: - pos->x = 0; - break; - case LV_LABEL_ALIGN_RIGHT: - pos->x = lv_obj_get_width(label); - break; - case LV_LABEL_ALIGN_CENTER: - pos->x = lv_obj_get_width(label) / 2; - break; + case LV_LABEL_ALIGN_LEFT: + pos->x = 0; + break; + case LV_LABEL_ALIGN_RIGHT: + pos->x = lv_obj_get_width(label); + break; + case LV_LABEL_ALIGN_CENTER: + pos->x = lv_obj_get_width(label) / 2; + break; } return; } diff --git a/src/lv_widgets/lv_list.c b/src/lv_widgets/lv_list.c index 9df0d621d..76ba666ff 100644 --- a/src/lv_widgets/lv_list.c +++ b/src/lv_widgets/lv_list.c @@ -470,7 +470,7 @@ int32_t lv_list_get_btn_index(const lv_obj_t * list, const lv_obj_t * btn) list = lv_obj_get_parent(lv_obj_get_parent(btn)); } LV_ASSERT_OBJ(list, LV_OBJX_NAME); - + lv_obj_t * e = lv_list_get_next_btn(list, NULL); while(e != NULL) { if(e == btn) { diff --git a/src/lv_widgets/lv_roller.c b/src/lv_widgets/lv_roller.c index 066d3c29a..41874af52 100644 --- a/src/lv_widgets/lv_roller.c +++ b/src/lv_widgets/lv_roller.c @@ -196,9 +196,9 @@ void lv_roller_set_options(lv_obj_t * roller, const char * options, lv_roller_mo ext->sel_opt_id_ori = ext->sel_opt_id; - refr_height(roller); - refr_width(roller); -// refr_position(roller, LV_ANIM_OFF); + refr_height(roller); + refr_width(roller); + // refr_position(roller, LV_ANIM_OFF); } /** diff --git a/src/lv_widgets/lv_slider.c b/src/lv_widgets/lv_slider.c index b9ce83cf3..bb83f9298 100644 --- a/src/lv_widgets/lv_slider.c +++ b/src/lv_widgets/lv_slider.c @@ -264,14 +264,14 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider); /* Advanced hit testing: react only on dragging the knob(s) */ - if (sign == LV_SIGNAL_HIT_TEST) { - lv_hit_test_info_t *info = param; + if(sign == LV_SIGNAL_HIT_TEST) { + lv_hit_test_info_t * info = param; /* Ordinary slider: was the knob area hit? */ info->result = _lv_area_is_point_on(&ext->right_knob_area, info->point, 0); /* There's still a change we have a hit, if we have another knob */ - if ((info->result == false) && (type == LV_SLIDER_TYPE_RANGE)) { + if((info->result == false) && (type == LV_SLIDER_TYPE_RANGE)) { info->result = _lv_area_is_point_on(&ext->left_knob_area, info->point, 0); } } diff --git a/src/lv_widgets/lv_textarea.c b/src/lv_widgets/lv_textarea.c index 182ac55da..9cf859f82 100644 --- a/src/lv_widgets/lv_textarea.c +++ b/src/lv_widgets/lv_textarea.c @@ -231,16 +231,16 @@ void lv_textarea_add_char(lv_obj_t * ta, uint32_t c) lv_textarea_ext_t * ext = lv_obj_get_ext_attr(ta); - const char *letter_buf; + const char * letter_buf; uint32_t u32_buf[2]; u32_buf[0] = c; u32_buf[1] = 0; - - letter_buf = (char*)&u32_buf; + + letter_buf = (char *)&u32_buf; #if LV_BIG_ENDIAN_SYSTEM - if (c != 0) while (*letter_buf == 0) ++letter_buf; + if(c != 0) while(*letter_buf == 0) ++letter_buf; #endif ta_insert_replace = NULL; diff --git a/src/lv_widgets/lv_win.c b/src/lv_widgets/lv_win.c index 6b825c168..20fbb7426 100644 --- a/src/lv_widgets/lv_win.c +++ b/src/lv_widgets/lv_win.c @@ -34,8 +34,8 @@ typedef struct { } lv_win_btn_ext_t; enum { - LV_WIN_BTN_ALIGN_RIGHT = 0, /**< Align button to right of the header */ - LV_WIN_BTN_ALIGN_LEFT /**< Align button to left of the header */ + LV_WIN_BTN_ALIGN_RIGHT = 0, /**< Align button to right of the header */ + LV_WIN_BTN_ALIGN_LEFT /**< Align button to left of the header */ }; typedef uint8_t lv_win_btn_align_t; @@ -559,7 +559,7 @@ static lv_design_res_t lv_win_header_design(lv_obj_t * header, const lv_area_t * lv_coord_t left_btn_offset = 0; btn = lv_obj_get_child_back(ext->header, NULL); while(btn != NULL) { - if (LV_WIN_BTN_ALIGN_LEFT == lv_win_btn_get_alignment(btn)) { + if(LV_WIN_BTN_ALIGN_LEFT == lv_win_btn_get_alignment(btn)) { left_btn_offset += btn_w + header_inner; } @@ -716,26 +716,28 @@ static void lv_win_realign(lv_obj_t * win) lv_obj_set_size(btn, btn_w, btn_h); uint8_t btn_alignment = lv_win_btn_get_alignment(btn); - if (LV_WIN_BTN_ALIGN_RIGHT == btn_alignment) { - if (is_header_right_side_empty) { + if(LV_WIN_BTN_ALIGN_RIGHT == btn_alignment) { + if(is_header_right_side_empty) { /* Align the button to the right of the header */ lv_obj_align(btn, ext->header, LV_ALIGN_IN_RIGHT_MID, -header_right, 0); is_header_right_side_empty = false; - } else { + } + else { /* Align the button to the left of the previous button */ - lv_obj_align(btn, btn_prev_at_right, LV_ALIGN_OUT_LEFT_MID, -header_inner, 0); + lv_obj_align(btn, btn_prev_at_right, LV_ALIGN_OUT_LEFT_MID, -header_inner, 0); } btn_prev_at_right = btn; } - else if (LV_WIN_BTN_ALIGN_LEFT == btn_alignment) { - if (is_header_left_side_empty) { + else if(LV_WIN_BTN_ALIGN_LEFT == btn_alignment) { + if(is_header_left_side_empty) { /* Align the button to the right of the header */ lv_obj_align(btn, ext->header, LV_ALIGN_IN_LEFT_MID, header_left, 0); is_header_left_side_empty = false; - } else { + } + else { /* Align the button to the right of the previous button */ lv_obj_align(btn, btn_prev_at_left, LV_ALIGN_OUT_RIGHT_MID, header_inner, 0); } @@ -754,11 +756,11 @@ static void lv_win_realign(lv_obj_t * win) static lv_obj_t * lv_win_btn_create(lv_obj_t * par, const void * img_src) { - LV_LOG_TRACE("win btn create started"); + LV_LOG_TRACE("win btn create started"); - lv_obj_t * win_btn; + lv_obj_t * win_btn; - win_btn = lv_btn_create(par, NULL); + win_btn = lv_btn_create(par, NULL); LV_ASSERT_MEM(win_btn); if(win_btn == NULL) return NULL; @@ -785,7 +787,7 @@ static lv_obj_t * lv_win_btn_create(lv_obj_t * par, const void * img_src) LV_LOG_INFO("win btn created"); - return win_btn; + return win_btn; } static void lv_win_btn_set_alignment(lv_obj_t * win_btn, const uint8_t alignment) From e30efb716fe2ae0eb385ea9efa1f3b742b180cb5 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 7 Jul 2020 09:37:00 +0200 Subject: [PATCH 084/205] Release v7.1.0 --- library.json | 2 +- lv_conf_template.h | 2 +- lvgl.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library.json b/library.json index 233aa99d5..faa8db1f7 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "lvgl", - "version": "v7.0.2", + "version": "v7.1.0", "keywords": "graphics, gui, embedded, littlevgl", "description": "Graphics library to create embedded GUI with easy-to-use graphical elements, beautiful visual effects and low memory footprint. It offers anti-aliasing, opacity, and animations using only one frame buffer.", "repository": diff --git a/lv_conf_template.h b/lv_conf_template.h index 828413eab..4db0f7bb0 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -1,6 +1,6 @@ /** * @file lv_conf.h - * Configuration file for LVGL v7.0.2 + * Configuration file for LVGL v7.1.0 */ /* diff --git a/lvgl.h b/lvgl.h index 5165a598b..6146d7120 100644 --- a/lvgl.h +++ b/lvgl.h @@ -79,7 +79,7 @@ extern "C" { #define LVGL_VERSION_MAJOR 7 #define LVGL_VERSION_MINOR 1 #define LVGL_VERSION_PATCH 0 -#define LVGL_VERSION_INFO "dev" +#define LVGL_VERSION_INFO "" /********************** * TYPEDEFS From a117b3cead6523a955c3991ff0e8f30a86b3cb8b Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 7 Jul 2020 10:00:38 +0200 Subject: [PATCH 085/205] update relaese script --- scripts/release.py | 310 ++++++++++++++++++++++----------------------- 1 file changed, 153 insertions(+), 157 deletions(-) mode change 100644 => 100755 scripts/release.py diff --git a/scripts/release.py b/scripts/release.py old mode 100644 new mode 100755 index 61b04745f..568bfeab2 --- a/scripts/release.py +++ b/scripts/release.py @@ -1,227 +1,224 @@ +#!/usr/bin/env python + import re import os lastNum = re.compile(r'(?:[^\d]*(\d+)[^\d]*)+') def title(t): - print("\n---------------------------------") - print(t) - print("---------------------------------") + print("\n---------------------------------") + print(t) + print("---------------------------------") def cmd(c): - print("\n" + c) - r = os.system(c) + print("\n" + c) + r = os.system(c) if r: - print("Exit due to previous error") - exit(r) + print("### Error: " + str(r)) def lvgl_clone(): - title("lvgl: Clone") - cmd("git clone https://github.com/lvgl/lvgl.git") - os.chdir("./lvgl") - cmd("git co master") + title("lvgl: Clone") + cmd("git clone https://github.com/lvgl/lvgl.git") + os.chdir("./lvgl") + cmd("git co master") def lvgl_format(): title("lvgl: Run code formatter") os.chdir("./scripts") cmd("./code-format.sh") - cmd("git ci -am 'Run code formatter'") + os.system("git ci -am 'Run code formatter'") os.chdir("..") def lvgl_update_version(): - title("lvgl: Update version number") + title("lvgl: Update version number") - f = open("./lvgl.h", "r") - - outbuf = "" - major_ver = -1 - minor_ver = -1 - patch_ver = -1 - - for i in f.read().splitlines(): - r = re.search(r'^#define LVGL_VERSION_MAJOR ', i) - if r: - m = lastNum.search(i) - if m: major_ver = m.group(1) + f = open("./lvgl.h", "r") + + outbuf = "" + major_ver = -1 + minor_ver = -1 + patch_ver = -1 + + for i in f.read().splitlines(): + r = re.search(r'^#define LVGL_VERSION_MAJOR ', i) + if r: + m = lastNum.search(i) + if m: major_ver = m.group(1) - r = re.search(r'^#define LVGL_VERSION_MINOR ', i) - if r: - m = lastNum.search(i) - if m: minor_ver = m.group(1) - - r = re.search(r'^#define LVGL_VERSION_PATCH ', i) - if r: - m = lastNum.search(i) - if m: patch_ver = m.group(1) - - - r = re.search(r'^#define LVGL_VERSION_INFO ', i) - if r: - i = "#define LVGL_VERSION_INFO \"\"" - - outbuf += i + '\n' - - f.close() + r = re.search(r'^#define LVGL_VERSION_MINOR ', i) + if r: + m = lastNum.search(i) + if m: minor_ver = m.group(1) + + r = re.search(r'^#define LVGL_VERSION_PATCH ', i) + if r: + m = lastNum.search(i) + if m: patch_ver = m.group(1) + + + r = re.search(r'^#define LVGL_VERSION_INFO ', i) + if r: + i = "#define LVGL_VERSION_INFO \"\"" + + outbuf += i + '\n' + + f.close() - f = open("./lvgl.h", "w") - - f.write(outbuf) - f.close() + f = open("./lvgl.h", "w") + + f.write(outbuf) + f.close() - s = "v" + str(major_ver) + "." + str(minor_ver) + "." + str(patch_ver) - print("New version:" + s) - return s + s = "v" + str(major_ver) + "." + str(minor_ver) + "." + str(patch_ver) + print("New version:" + s) + return s def lvgl_update_library_json(v): - title("lvgl: Update version number in library.json") + title("lvgl: Update version number in library.json") - f = open("./library.json", "r") - - outbuf = "" - - for i in f.read().splitlines(): - r = re.search(r'"version": ', i) - if r: - i = ' "version": "' + v + '",' - - outbuf += i + '\n' - - f.close() + f = open("./library.json", "r") + + outbuf = "" + + for i in f.read().splitlines(): + r = re.search(r'"version": ', i) + if r: + i = ' "version": "' + v + '",' + + outbuf += i + '\n' + + f.close() - f = open("./library.json", "w") - - f.write(outbuf) - f.close() + f = open("./library.json", "w") + + f.write(outbuf) + f.close() def lvgl_update_lv_conf_templ(ver_str): - title("lvgl: Update version number in lv_conf_template.h") - cmd("sed -i -r 's/v[0-9]+\.[0-9]+\.[0-9]+/"+ ver_str +"/' lv_conf_template.h ") + title("lvgl: Update version number in lv_conf_template.h") + cmd("sed -i -r 's/v[0-9]+\.[0-9]+\.[0-9]+/"+ ver_str +"/' lv_conf_template.h ") def lvgl_commit_push(v): - title("lvgl: commit and push release") + title("lvgl: commit and push release") - cmd('git ci -am "Release ' + v + '"') - cmd('git tag -a ' + v + ' -m "Release ' + v +'"') - cmd('git push origin master') - cmd('git push origin ' + v) + os.system('git ci -am "Release ' + v + '"') + cmd('git tag -a ' + v + ' -m "Release ' + v +'"') + cmd('git push origin master') + cmd('git push origin ' + v) def lvgl_merge_to_release_branch(v): - title("lvgl: merge to release branch") - cmd('git co release/v7') - cmd('git merge master') - cmd('git push origin release/v7') - os.chdir("../") - - + title("lvgl: merge to release branch") + cmd('git co release/v7') + cmd('git merge master') + cmd('git push origin release/v7') + os.chdir("../") + + def lvgl_update_api_docs(): - title("lvgl: Update API with Doxygen") + title("lvgl: Update API with Doxygen") - cmd("cd scripts; doxygen"); + cmd("cd scripts; doxygen"); def examples_clone(): - title("examples: Clone") - cmd("git clone https://github.com/lvgl/lv_examples.git") - os.chdir("./lv_examples") - cmd("git co master") + title("examples: Clone") + cmd("git clone https://github.com/lvgl/lv_examples.git") + os.chdir("./lv_examples") + cmd("git co master") def examples_commit_push(v): - title("examples: commit and push release") + title("examples: commit and push release") - cmd('git ci -am "Release ' + v + '"') - cmd('git tag -a ' + v + ' -m "Release ' + v +'"') - cmd('git push origin master') - cmd('git push origin ' + v) + os.system('git ci -am "Release ' + v + '"') + cmd('git tag -a ' + v + ' -m "Release ' + v +'"') + cmd('git push origin master') + cmd('git push origin ' + v) def examples_merge_to_release_branch(v): - title("examples: merge to release branch") - cmd('git co release/v7') - cmd('git merge master') - cmd('git push origin release/v7') - os.chdir("../") - - + title("examples: merge to release branch") + cmd('git co release/v7') + cmd('git merge master') + cmd('git push origin release/v7') + os.chdir("../") + + def drivers_clone(): - title("drivers: Clone") - cmd("git clone https://github.com/lvgl/lv_drivers.git") - os.chdir("./lv_drivers") - cmd("git co master") + title("drivers: Clone") + cmd("git clone https://github.com/lvgl/lv_drivers.git") + os.chdir("./lv_drivers") + cmd("git co master") def drivers_commit_push(v): - title("drivers: commit and push release") + title("drivers: commit and push release") - cmd('git ci -am "Release ' + v + '"') - cmd('git tag -a ' + v + ' -m "Release ' + v +'"') - cmd('git push origin master') - cmd('git push origin ' + v) + os.system('git ci -am "Release ' + v + '"') + cmd('git tag -a ' + v + ' -m "Release ' + v +'"') + cmd('git push origin master') + cmd('git push origin ' + v) def drivers_merge_to_release_branch(v): - title("drivers: merge to release branch") - cmd('git co release/v7') - cmd('git merge master') - cmd('git push origin release/v7') - os.chdir("../") + title("drivers: merge to release branch") + cmd('git co release/v7') + cmd('git merge master') + cmd('git push origin release/v7') + os.chdir("../") def docs_clone(): - title("docs: Clone") - cmd("git clone --recursive https://github.com/lvgl/docs.git") - os.chdir("./docs") + title("docs: Clone") + #cmd("git clone --recursive https://github.com/lvgl/docs.git") + os.chdir("./docs") def docs_get_api(): - title("docs: Get API files") - - cmd("git co latest") - cmd("rm -rf xml"); - cmd("cp -r ../../lvgl/docs/api_doc/xml ."); - cmd("git add xml"); - cmd('git commit -m "update API"') + title("docs: Get API files") + + cmd("git co latest --") + cmd("rm -rf xml"); + cmd("cp -r ../lvgl/docs/api_doc/xml ."); + cmd("git add xml"); + cmd('git commit -m "update API"') def docs_update_version(v): - title("docs: Update version number") + title("docs: Update version number") - f = open("./conf.py", "r") - - outbuf = "" - - for i in f.read().splitlines(): - r = re.search(r'^version = ', i) - if r: - i = "version = '" + v + "'" + f = open("./conf.py", "r") + + outbuf = "" + + for i in f.read().splitlines(): + r = re.search(r'^version = ', i) + if r: + i = "version = '" + v + "'" - r = re.search(r'^release = ', i) - if r: - i = "version = '" + v + "'" - - outbuf += i + '\n' - - f.close() + r = re.search(r'^release = ', i) + if r: + i = "version = '" + v + "'" + + outbuf += i + '\n' + + f.close() - f = open("./conf.py", "w") - - f.write(outbuf) - f.close() - cmd("git add conf.py") - cmd('git ci -m "update conf.py to ' + v '"') - -def docs_update_trans(): - title("docs: Update translations") - cmd("cd en && ./trans_push.py && ./trans_pull.py") + f = open("./conf.py", "w") + + f.write(outbuf) + f.close() + cmd("git add conf.py") + cmd('git ci -m "update conf.py to ' + v + '"') def docs_build(): - title("docs: Build") - cmd("git checkout master") - cmd("./update.py latest") - + title("docs: Build") + cmd("git checkout master") + cmd("./update.py latest") + def clean_up(): - title("Clean up repos") - os.chdir("../..") - cmd("rm -rf lvgl docs lv_examples lv_drivers") + title("Clean up repos") + os.chdir("../") + cmd("rm -rf lvgl docs lv_examples lv_drivers") lvgl_clone() lvgl_format() @@ -243,7 +240,6 @@ drivers_merge_to_release_branch(ver_str) docs_clone() docs_get_api() docs_update_version(ver_str) -#docs_update_trans() # Zanata is not working now docs_build() clean_up() From 7e9cf858d69d581967d57edf3acd3da1ae01e7ef Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 7 Jul 2020 10:03:52 +0200 Subject: [PATCH 086/205] update version number --- lvgl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lvgl.h b/lvgl.h index 178811bc1..6e1c15e33 100644 --- a/lvgl.h +++ b/lvgl.h @@ -77,9 +77,9 @@ extern "C" { *********************/ /*Current version of LVGL*/ #define LVGL_VERSION_MAJOR 7 -#define LVGL_VERSION_MINOR 1 +#define LVGL_VERSION_MINOR 2 #define LVGL_VERSION_PATCH 0 -#define LVGL_VERSION_INFO "" +#define LVGL_VERSION_INFO "dev" /********************** * TYPEDEFS From 039080fc261176dc958a62cb8e8a1e162116f444 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 7 Jul 2020 10:05:29 +0200 Subject: [PATCH 087/205] update changlog --- CHANGELOG.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94a25ce52..91a25df37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,11 @@ # Changelog -## v7.2.0 (planned on 04.08.2020) +## v7.3.0 (planned on 04.08.2020) Available in the `dev` branch +## v7.2.0 (planned on 21.07.2020) +*Available in the `master` branch* + ### New features - Add `LV_CALENDAR_WEEK_STARTS_MONDAY` - Add `lv_chart_set_x_start_point()` function - Set the index of the x-axis start point in the data array @@ -19,8 +22,7 @@ Available in the `dev` branch - Add `lv_obj_align_x()` and `lv_obj_align_y()` functions - Add `lv_obj_align_origo_x()` and `lv_obj_align_origo_y()` functions -## v7.1.0 (planned on 07.07.2020) -*Available in the `master` branch* +## v7.1.0 (07.07.2020) ### New features - Add `focus_parent` attribute to `lv_obj` From 38e68eeb7abe65dd26704f1167bffc9ec5e8cfa9 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 7 Jul 2020 10:06:49 +0200 Subject: [PATCH 088/205] update version number --- lvgl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lvgl.h b/lvgl.h index 6e1c15e33..f90729d7b 100644 --- a/lvgl.h +++ b/lvgl.h @@ -77,7 +77,7 @@ extern "C" { *********************/ /*Current version of LVGL*/ #define LVGL_VERSION_MAJOR 7 -#define LVGL_VERSION_MINOR 2 +#define LVGL_VERSION_MINOR 3 #define LVGL_VERSION_PATCH 0 #define LVGL_VERSION_INFO "dev" From b2d78dcca7b9d0567f992993a7a271236c3d6075 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 7 Jul 2020 11:29:20 +0200 Subject: [PATCH 089/205] Create auto-comment.yml --- .github/.github/auto-comment.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/.github/auto-comment.yml diff --git a/.github/.github/auto-comment.yml b/.github/.github/auto-comment.yml new file mode 100644 index 000000000..6683944f7 --- /dev/null +++ b/.github/.github/auto-comment.yml @@ -0,0 +1,11 @@ +# Comment to a new issue. +pullRequestOpened: > + Thank you for raising your pull request. + + To ensure that all licensing criteria is met all repositories of the LVGL project apply a process called DCO (Developer's Certificate of Origin).  +  + The text of DCO can be read here: https://developercertificate.org/ +  + By contributing to any repositories of the LVGL project you state that your contribution corresponds with the DCO. + + From faf56680f81adbdf37322fef56caf0f8458f3237 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 7 Jul 2020 11:29:41 +0200 Subject: [PATCH 090/205] Delete auto-comment.yml --- .github/.github/auto-comment.yml | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 .github/.github/auto-comment.yml diff --git a/.github/.github/auto-comment.yml b/.github/.github/auto-comment.yml deleted file mode 100644 index 6683944f7..000000000 --- a/.github/.github/auto-comment.yml +++ /dev/null @@ -1,11 +0,0 @@ -# Comment to a new issue. -pullRequestOpened: > - Thank you for raising your pull request. - - To ensure that all licensing criteria is met all repositories of the LVGL project apply a process called DCO (Developer's Certificate of Origin).  -  - The text of DCO can be read here: https://developercertificate.org/ -  - By contributing to any repositories of the LVGL project you state that your contribution corresponds with the DCO. - - From c97a0684cf99c3fd60b77133cca0a08a1460d8b6 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 7 Jul 2020 11:30:35 +0200 Subject: [PATCH 091/205] Create auto-comment.yml --- .github/auto-comment.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .github/auto-comment.yml diff --git a/.github/auto-comment.yml b/.github/auto-comment.yml new file mode 100644 index 000000000..f718c7913 --- /dev/null +++ b/.github/auto-comment.yml @@ -0,0 +1,9 @@ +# Comment to a new issue. +pullRequestOpened: > + Thank you for raising your pull request. + + To ensure that all licensing criteria is met all repositories of the LVGL project apply a process called DCO (Developer's Certificate of Origin). + + The text of DCO can be read here: https://developercertificate.org/ + + By contributing to any repositories of the LVGL project you state that your contribution corresponds with the DCO. From c599a59f056f79d72e34f2925b9ddd4f1cac568f Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 7 Jul 2020 11:31:00 +0200 Subject: [PATCH 092/205] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e7d193fb2..9ee6eb709 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

LVGL - Light and Versatile Graphics Library

- +

From a6793b2695919798dc7ccf5bf492523ae0da249f Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 7 Jul 2020 12:44:42 +0200 Subject: [PATCH 093/205] Update auto-comment.yml --- .github/auto-comment.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/auto-comment.yml b/.github/auto-comment.yml index f718c7913..e28adfc22 100644 --- a/.github/auto-comment.yml +++ b/.github/auto-comment.yml @@ -1,5 +1,5 @@ # Comment to a new issue. -pullRequestOpened: > +pullRequestOpened: | Thank you for raising your pull request. To ensure that all licensing criteria is met all repositories of the LVGL project apply a process called DCO (Developer's Certificate of Origin). @@ -7,3 +7,5 @@ pullRequestOpened: > The text of DCO can be read here: https://developercertificate.org/ By contributing to any repositories of the LVGL project you state that your contribution corresponds with the DCO. + + No further action is required if your contribution fulfills the DCO. If you are not sure about it feel free to ask us in a comemnt. From 234e74202ca08166406c55269b61087ce980563b Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 7 Jul 2020 12:58:03 +0200 Subject: [PATCH 094/205] image decoder open bug described in #1638 --- src/lv_draw/lv_img_decoder.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/lv_draw/lv_img_decoder.c b/src/lv_draw/lv_img_decoder.c index 245ab4711..0c2f67d72 100644 --- a/src/lv_draw/lv_img_decoder.c +++ b/src/lv_draw/lv_img_decoder.c @@ -153,10 +153,6 @@ lv_res_t lv_img_decoder_open(lv_img_decoder_dsc_t * dsc, const void * src, lv_co if(res == LV_RES_OK) break; } - if(res == LV_RES_INV) { - _lv_memset_00(dsc, sizeof(lv_img_decoder_dsc_t)); - } - return res; } From aff7a22ac59e592f8f116ec476729620497c16dd Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 7 Jul 2020 13:03:30 +0200 Subject: [PATCH 095/205] Update auto-comment.yml --- .github/auto-comment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/auto-comment.yml b/.github/auto-comment.yml index e28adfc22..7596dc8b7 100644 --- a/.github/auto-comment.yml +++ b/.github/auto-comment.yml @@ -8,4 +8,4 @@ pullRequestOpened: | By contributing to any repositories of the LVGL project you state that your contribution corresponds with the DCO. - No further action is required if your contribution fulfills the DCO. If you are not sure about it feel free to ask us in a comemnt. + No further action is required if your contribution fulfills the DCO. If you are not sure about it feel free to ask us in a comment. From 2cecd01b30d32c6af1e45198ad4de6ba5fac0ad5 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 7 Jul 2020 13:07:02 +0200 Subject: [PATCH 096/205] Update auto-comment.yml --- .github/auto-comment.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/auto-comment.yml b/.github/auto-comment.yml index 7596dc8b7..dc35b2355 100644 --- a/.github/auto-comment.yml +++ b/.github/auto-comment.yml @@ -5,6 +5,7 @@ pullRequestOpened: | To ensure that all licensing criteria is met all repositories of the LVGL project apply a process called DCO (Developer's Certificate of Origin). The text of DCO can be read here: https://developercertificate.org/ + For a more detailed description see the [Documentation](https://docs.lvgl.io/latest/en/html/contributing/index.html#dco) site. By contributing to any repositories of the LVGL project you state that your contribution corresponds with the DCO. From 343b70b19c600d2ed4b4b1eb26b40ff7eea42611 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 7 Jul 2020 13:09:26 +0200 Subject: [PATCH 097/205] Update auto-comment.yml --- .github/auto-comment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/auto-comment.yml b/.github/auto-comment.yml index dc35b2355..8ff0cf1e6 100644 --- a/.github/auto-comment.yml +++ b/.github/auto-comment.yml @@ -5,7 +5,7 @@ pullRequestOpened: | To ensure that all licensing criteria is met all repositories of the LVGL project apply a process called DCO (Developer's Certificate of Origin). The text of DCO can be read here: https://developercertificate.org/ - For a more detailed description see the [Documentation](https://docs.lvgl.io/latest/en/html/contributing/index.html#dco) site. + For a more detailed description see the [Documentation](https://docs.lvgl.io/latest/en/html/contributing/index.html#developer-certification-of-origin-dco) site. By contributing to any repositories of the LVGL project you state that your contribution corresponds with the DCO. From 646cb71a9d17e0c394c3e23c13bc53e07cd9a0ce Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 7 Jul 2020 20:40:33 +0200 Subject: [PATCH 098/205] Update library.json --- library.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.json b/library.json index faa8db1f7..3e83c49d8 100644 --- a/library.json +++ b/library.json @@ -1,7 +1,7 @@ { "name": "lvgl", "version": "v7.1.0", - "keywords": "graphics, gui, embedded, littlevgl", + "keywords": "graphics, gui, embedded, tft, lvgl", "description": "Graphics library to create embedded GUI with easy-to-use graphical elements, beautiful visual effects and low memory footprint. It offers anti-aliasing, opacity, and animations using only one frame buffer.", "repository": { From 019042297d4a99711bf51a01b7ecd8bf07e46a60 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 8 Jul 2020 06:26:56 +0200 Subject: [PATCH 099/205] Update library.json --- library.json | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/library.json b/library.json index 3e83c49d8..ed34d7fff 100644 --- a/library.json +++ b/library.json @@ -1,14 +1,17 @@ { - "name": "lvgl", - "version": "v7.1.0", - "keywords": "graphics, gui, embedded, tft, lvgl", - "description": "Graphics library to create embedded GUI with easy-to-use graphical elements, beautiful visual effects and low memory footprint. It offers anti-aliasing, opacity, and animations using only one frame buffer.", - "repository": - { - "type": "git", - "url": "https://github.com/lvgl/lvgl.git" - }, - "build": { - "includeDir": "." - } + "name": "lvgl", + "version": "v7.1.0", + "keywords": "graphics, gui, embedded, tft, lvgl", + "description": "Graphics library to create embedded GUI with easy-to-use graphical elements, beautiful visual effects and low memory footprint. It offers anti-aliasing, opacity, and animations using only one frame buffer.", + "repository": { + "type": "git", + "url": "https://github.com/lvgl/lvgl.git" + }, + "build": { + "includeDir": "." + }, + "license": "MIT", + "homepage": "https://lvgl.io", + "frameworks": "*", + "platforms": "*" } From 843555a4b18e17797395e26760eaa70c32da4bcd Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 8 Jul 2020 09:28:35 +0200 Subject: [PATCH 100/205] Add lv_task_get_next --- src/lv_misc/lv_task.c | 11 +++++++++++ src/lv_misc/lv_task.h | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/src/lv_misc/lv_task.c b/src/lv_misc/lv_task.c index 1779a1272..c051d9faa 100644 --- a/src/lv_misc/lv_task.c +++ b/src/lv_misc/lv_task.c @@ -378,6 +378,17 @@ uint8_t lv_task_get_idle(void) return idle_last; } +/** + * Iterate through the tasks + * @param task NULL to start iteration or the previous return value to get the next task + * @return the next task or NULL if there is no more task + */ +lv_task_t * lv_task_get_next(lv_task_t * task) +{ + if(task == NULL) return _lv_ll_get_head(&LV_GC_ROOT(_lv_task_ll)); + else return _lv_ll_get_next(&LV_GC_ROOT(_lv_task_ll), task); +} + /********************** * STATIC FUNCTIONS **********************/ diff --git a/src/lv_misc/lv_task.h b/src/lv_misc/lv_task.h index bfd428369..d3dfc4adb 100644 --- a/src/lv_misc/lv_task.h +++ b/src/lv_misc/lv_task.h @@ -165,6 +165,13 @@ void lv_task_enable(bool en); */ uint8_t lv_task_get_idle(void); +/** + * Iterate through the tasks + * @param task NULL to start iteration or the previous return value to get the next task + * @return the next task or NULL if there is no more task + */ +lv_task_t * lv_task_get_next(lv_task_t * task); + /********************** * MACROS **********************/ From 15b7ea6614fa4ba383ed298e8b0886e4ed585eb0 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 8 Jul 2020 09:29:36 +0200 Subject: [PATCH 101/205] Add lv_event_send_refresh, lv_event_send_refresh_recursive, lv_event_queue_refresh_recursive Used to easily send LV_EVENT_REFRESH to objects --- CHANGELOG.md | 4 +++ src/lv_core/lv_obj.c | 71 ++++++++++++++++++++++++++++++++++++++++++++ src/lv_core/lv_obj.h | 22 ++++++++++++++ 3 files changed, 97 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 91a25df37..04ec86cb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ ## v7.3.0 (planned on 04.08.2020) Available in the `dev` branch +### New features +- Add `lv_task_get_next` +- Add `lv_event_send_refresh`, `lv_event_send_refresh_recursive`, `lv_event_queue_refresh_recursive` to easily send `LV_EVENT_REFRESH` to object + ## v7.2.0 (planned on 21.07.2020) *Available in the `master` branch* diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 024216ce3..c11917d8d 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -98,6 +98,7 @@ static void opa_scale_anim(lv_obj_t * obj, lv_anim_value_t v); static void fade_in_anim_ready(lv_anim_t * a); #endif static void lv_event_mark_deleted(lv_obj_t * obj); +static void refresh_event_task_cb(lv_task_t * t); static bool obj_valid_child(const lv_obj_t * parent, const lv_obj_t * obj_to_find); static void lv_obj_del_async_cb(void * obj); static void obj_del_core(lv_obj_t * obj); @@ -1751,6 +1752,71 @@ lv_res_t lv_event_send(lv_obj_t * obj, lv_event_t event, const void * data) return res; } +/** + * Send LV_EVENT_REFRESH event to an object + * @param obj point to an obejct. (Can NOT be NULL) + * @return LV_RES_OK: success, LV_RES_INV: to object become invalid (e.g. deleted) due to this event. + */ +lv_res_t lv_event_send_refresh(lv_obj_t * obj) +{ + return lv_event_send(obj, LV_EVENT_REFRESH, NULL); +} + +/** + * Send LV_EVENT_REFRESH event to an object all of its children. + * @param obj pointer to an object or NULL to refresh all objects of all displays + */ +void lv_event_send_refresh_recursive(lv_obj_t * obj) +{ + if(obj == NULL) { + /*If no obj specified refresh all screen of all displays */ + lv_disp_t * d = lv_disp_get_next(NULL); + while(d) { + lv_obj_t * scr = _lv_ll_get_head(&d->scr_ll); + while(scr) { + lv_event_send_refresh_recursive(scr); + scr = _lv_ll_get_next(&d->scr_ll, scr); + } + lv_event_send_refresh_recursive(d->top_layer); + lv_event_send_refresh_recursive(d->sys_layer); + + d = lv_disp_get_next(d); + } + } else { + + lv_res_t res = lv_event_send_refresh(obj); + if(res != LV_RES_OK) return; /*If invalid returned do not check the children*/ + + lv_obj_t * child = lv_obj_get_child(obj, NULL); + while(child) { + lv_event_send_refresh_recursive(child); + + child = lv_obj_get_child(obj, child); + } + } +} + +/** + * Queue the sending of LV_EVENT_REFRESH event to an object all of its children. + * The events won't be sent immediately but after `LV_DISP_DEF_REFR_PERIOD` delay. + * It is useful to refresh object only on a reasonable rate if this function is called very often. + * @param obj pointer to an object or NULL to refresh all objects of all displays + */ +void lv_event_queue_refresh_recursive(lv_obj_t * obj) +{ + lv_task_t * t = lv_task_get_next(NULL); + while(t) { + /* REturn if a refresh is already queued for this object*/ + if(t->task_cb == refresh_event_task_cb && t->user_data == obj) return; + t = lv_task_get_next(t); + } + + /*No queued task for this object so create one now*/ + t = lv_task_create(refresh_event_task_cb, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, obj); + lv_task_set_repeat_count(t, 1); +} + + /** * Call an event function with an object, event, and data. * @param event_xcb an event callback function. If `NULL` `LV_RES_OK` will return without any actions. @@ -4231,6 +4297,11 @@ static void lv_event_mark_deleted(lv_obj_t * obj) } } +static void refresh_event_task_cb(lv_task_t * t) +{ + lv_event_send_refresh_recursive(t->user_data); +} + static bool obj_valid_child(const lv_obj_t * parent, const lv_obj_t * obj_to_find) { /*Check all children of `parent`*/ diff --git a/src/lv_core/lv_obj.h b/src/lv_core/lv_obj.h index ad438c399..e6113e0d5 100644 --- a/src/lv_core/lv_obj.h +++ b/src/lv_core/lv_obj.h @@ -823,6 +823,28 @@ void lv_obj_set_event_cb(lv_obj_t * obj, lv_event_cb_t event_cb); */ lv_res_t lv_event_send(lv_obj_t * obj, lv_event_t event, const void * data); + +/** + * Send LV_EVENT_REFRESH event to an object + * @param obj point to an obejct. (Can NOT be NULL) + * @return LV_RES_OK: success, LV_RES_INV: to object become invalid (e.g. deleted) due to this event. + */ +lv_res_t lv_event_send_refresh(lv_obj_t * obj); + +/** + * Send LV_EVENT_REFRESH event to an object all of its children + * @param obj pointer to an object or NULL to refresh all objects of all displays + */ +void lv_event_send_refresh_recursive(lv_obj_t * obj); + +/** + * Queue the sending of LV_EVENT_REFRESH event to an object all of its children. + * The events won't be sent immediately but after `LV_DISP_DEF_REFR_PERIOD` delay. + * It is useful to refresh object only on a reasonable rate if this function is called very often. + * @param obj pointer to an object or NULL to refresh all objects of all displays + */ +void lv_event_queue_refresh_recursive(lv_obj_t * obj); + /** * Call an event function with an object, event, and data. * @param event_xcb an event callback function. If `NULL` `LV_RES_OK` will return without any actions. From ec64820272c90d4901eeda4b343d7424c38e8271 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 7 Jul 2020 17:30:43 +0200 Subject: [PATCH 102/205] tileview: fix navigation when not screen sized --- CHANGELOG.md | 3 +++ src/lv_widgets/lv_tileview.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 91a25df37..0a4986d5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,9 @@ Available in the `dev` branch - Add `lv_obj_align_x()` and `lv_obj_align_y()` functions - Add `lv_obj_align_origo_x()` and `lv_obj_align_origo_y()` functions +### Bugfixes +- `tileview` fix navigation when not screen sized + ## v7.1.0 (07.07.2020) ### New features diff --git a/src/lv_widgets/lv_tileview.c b/src/lv_widgets/lv_tileview.c index 9d1fec097..0ea0f8133 100644 --- a/src/lv_widgets/lv_tileview.c +++ b/src/lv_widgets/lv_tileview.c @@ -403,8 +403,8 @@ static void drag_end_handler(lv_obj_t * tileview) lv_obj_t * scrl = lv_page_get_scrollable(tileview); lv_point_t p; - p.x = -(scrl->coords.x1 - lv_obj_get_width(tileview) / 2); - p.y = -(scrl->coords.y1 - lv_obj_get_height(tileview) / 2); + p.x = -(lv_obj_get_x(scrl) - lv_obj_get_width(tileview) / 2); + p.y = -(lv_obj_get_y(scrl) - lv_obj_get_height(tileview) / 2); lv_drag_dir_t drag_dir = indev->proc.types.pointer.drag_dir; /*From the drag vector (drag throw) predict the end position*/ From cbc88285d3e1eb4a51520dab348d92fd6b9a5db7 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 8 Jul 2020 08:42:32 +0200 Subject: [PATCH 103/205] change default fot to 14 px for better compatibility with small displays Related to #1602 --- lv_conf_template.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lv_conf_template.h b/lv_conf_template.h index 9564f2769..7461dd9d7 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -348,8 +348,8 @@ typedef void * lv_indev_drv_user_data_t; /*Type of user data in the i /* Montserrat fonts with bpp = 4 * https://fonts.google.com/specimen/Montserrat */ #define LV_FONT_MONTSERRAT_12 0 -#define LV_FONT_MONTSERRAT_14 0 -#define LV_FONT_MONTSERRAT_16 1 +#define LV_FONT_MONTSERRAT_14 1 +#define LV_FONT_MONTSERRAT_16 0 #define LV_FONT_MONTSERRAT_18 0 #define LV_FONT_MONTSERRAT_20 0 #define LV_FONT_MONTSERRAT_22 0 @@ -431,10 +431,10 @@ typedef void * lv_font_user_data_t; #define LV_THEME_DEFAULT_COLOR_PRIMARY lv_color_hex(0x01a2b1) #define LV_THEME_DEFAULT_COLOR_SECONDARY lv_color_hex(0x44d1b6) #define LV_THEME_DEFAULT_FLAG LV_THEME_MATERIAL_FLAG_LIGHT -#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_16 -#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_16 -#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_16 -#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_16 +#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_14 +#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_14 +#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_14 +#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_14 /*================= * Text settings From b769463d398ae9cab11c576c3f788cf816fc6df5 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 8 Jul 2020 09:31:49 +0200 Subject: [PATCH 104/205] update CHANGELONG and lv_conf_internal.h --- CHANGELOG.md | 1 + src/lv_conf_internal.h | 15 ++++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a4986d5f..e1a1ae061 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ Available in the `dev` branch ### Bugfixes - `tileview` fix navigation when not screen sized +- Use 14px font by default to for better compatibility with smaller displays ## v7.1.0 (07.07.2020) diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index b162f3c9e..52eb79990 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -294,9 +294,6 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */ #ifndef LV_USE_API_EXTENSION_V6 #define LV_USE_API_EXTENSION_V6 1 #endif -#ifndef LV_USE_API_EXTENSION_V7 -#define LV_USE_API_EXTENSION_V7 1 -#endif /*======================== * Image decoder and cache @@ -498,10 +495,10 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */ #define LV_FONT_MONTSERRAT_12 0 #endif #ifndef LV_FONT_MONTSERRAT_14 -#define LV_FONT_MONTSERRAT_14 0 +#define LV_FONT_MONTSERRAT_14 1 #endif #ifndef LV_FONT_MONTSERRAT_16 -#define LV_FONT_MONTSERRAT_16 1 +#define LV_FONT_MONTSERRAT_16 0 #endif #ifndef LV_FONT_MONTSERRAT_18 #define LV_FONT_MONTSERRAT_18 0 @@ -650,16 +647,16 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */ #define LV_THEME_DEFAULT_FLAG LV_THEME_MATERIAL_FLAG_LIGHT #endif #ifndef LV_THEME_DEFAULT_FONT_SMALL -#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_16 +#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_14 #endif #ifndef LV_THEME_DEFAULT_FONT_NORMAL -#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_16 +#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_14 #endif #ifndef LV_THEME_DEFAULT_FONT_SUBTITLE -#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_16 +#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_14 #endif #ifndef LV_THEME_DEFAULT_FONT_TITLE -#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_16 +#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_14 #endif /*================= From 1a3b6d4cb3f4288ef1a7786798d7466b24cd29b8 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 8 Jul 2020 09:35:25 +0200 Subject: [PATCH 105/205] update lv_conf_internal.h --- lv_conf_template.h | 1 + src/lv_conf_internal.h | 3 +++ 2 files changed, 4 insertions(+) diff --git a/lv_conf_template.h b/lv_conf_template.h index 7461dd9d7..36a55ee15 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -197,6 +197,7 @@ typedef void * lv_fs_drv_user_data_t; /*1: Use the functions and types from the older API if possible */ #define LV_USE_API_EXTENSION_V6 1 +#define LV_USE_API_EXTENSION_V7 1 /*======================== * Image decoder and cache diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index 52eb79990..135e8c374 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -294,6 +294,9 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */ #ifndef LV_USE_API_EXTENSION_V6 #define LV_USE_API_EXTENSION_V6 1 #endif +#ifndef LV_USE_API_EXTENSION_V7 +#define LV_USE_API_EXTENSION_V7 1 +#endif /*======================== * Image decoder and cache From a5de71933b60bf4971260dc762d23953b8f9289a Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 8 Jul 2020 10:31:36 +0200 Subject: [PATCH 106/205] fix typoe in comments --- src/lv_core/lv_obj.c | 4 ++-- src/lv_core/lv_obj.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index c11917d8d..e30520a0d 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -1763,7 +1763,7 @@ lv_res_t lv_event_send_refresh(lv_obj_t * obj) } /** - * Send LV_EVENT_REFRESH event to an object all of its children. + * Send LV_EVENT_REFRESH event to an object and all of its children. * @param obj pointer to an object or NULL to refresh all objects of all displays */ void lv_event_send_refresh_recursive(lv_obj_t * obj) @@ -1797,7 +1797,7 @@ void lv_event_send_refresh_recursive(lv_obj_t * obj) } /** - * Queue the sending of LV_EVENT_REFRESH event to an object all of its children. + * Queue the sending of LV_EVENT_REFRESH event to an object and all of its children. * The events won't be sent immediately but after `LV_DISP_DEF_REFR_PERIOD` delay. * It is useful to refresh object only on a reasonable rate if this function is called very often. * @param obj pointer to an object or NULL to refresh all objects of all displays diff --git a/src/lv_core/lv_obj.h b/src/lv_core/lv_obj.h index e6113e0d5..0f985ff83 100644 --- a/src/lv_core/lv_obj.h +++ b/src/lv_core/lv_obj.h @@ -832,13 +832,13 @@ lv_res_t lv_event_send(lv_obj_t * obj, lv_event_t event, const void * data); lv_res_t lv_event_send_refresh(lv_obj_t * obj); /** - * Send LV_EVENT_REFRESH event to an object all of its children + * Send LV_EVENT_REFRESH event to an object and all of its children * @param obj pointer to an object or NULL to refresh all objects of all displays */ void lv_event_send_refresh_recursive(lv_obj_t * obj); /** - * Queue the sending of LV_EVENT_REFRESH event to an object all of its children. + * Queue the sending of LV_EVENT_REFRESH event to an object and all of its children. * The events won't be sent immediately but after `LV_DISP_DEF_REFR_PERIOD` delay. * It is useful to refresh object only on a reasonable rate if this function is called very often. * @param obj pointer to an object or NULL to refresh all objects of all displays From 106e023c8096a7310a165d3254b09cd4460b1b39 Mon Sep 17 00:00:00 2001 From: DaPa Date: Wed, 8 Jul 2020 14:36:13 +0300 Subject: [PATCH 107/205] Fix lv_page_get_height_grid comment --- src/lv_widgets/lv_page.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_widgets/lv_page.c b/src/lv_widgets/lv_page.c index 89c6c0f0e..726e404d8 100644 --- a/src/lv_widgets/lv_page.c +++ b/src/lv_widgets/lv_page.c @@ -402,7 +402,7 @@ lv_coord_t lv_page_get_width_grid(lv_obj_t * page, uint8_t div, uint8_t span) } /** - * Divide the height of the object and get the width of a given number of columns. + * Divide the height of the object and get the height of a given number of rows. * Take into account the paddings of the background and scrollable too. * @param obj pointer to an object * @param div indicates how many rows are assumed. From e3f6a3327df29fdcae58352b1586ec9e8f2cbc6b Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 8 Jul 2020 14:59:02 +0200 Subject: [PATCH 108/205] Update library.json --- library.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.json b/library.json index ed34d7fff..6422a345e 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "lvgl", - "version": "v7.1.0", + "version": "7.1.0", "keywords": "graphics, gui, embedded, tft, lvgl", "description": "Graphics library to create embedded GUI with easy-to-use graphical elements, beautiful visual effects and low memory footprint. It offers anti-aliasing, opacity, and animations using only one frame buffer.", "repository": { From c07ef75ac5ef4748bfd69cd0e2acb300d19c1d8e Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 8 Jul 2020 15:02:40 +0200 Subject: [PATCH 109/205] update release script --- scripts/release.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/release.py b/scripts/release.py index 568bfeab2..c817baf8c 100755 --- a/scripts/release.py +++ b/scripts/release.py @@ -80,13 +80,13 @@ def lvgl_update_library_json(v): title("lvgl: Update version number in library.json") f = open("./library.json", "r") - + vn = v[1:] outbuf = "" for i in f.read().splitlines(): r = re.search(r'"version": ', i) if r: - i = ' "version": "' + v + '",' + i = ' "version": "' + vn + '",' outbuf += i + '\n' From 09250d0a92e8f2fd5745b5cbcd6c03675f550524 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 9 Jul 2020 14:13:21 +0200 Subject: [PATCH 110/205] Delete queued refresh queries --- src/lv_core/lv_obj.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index e30520a0d..2b414addb 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -3535,6 +3535,16 @@ static void obj_del_core(lv_obj_t * obj) /*Let the user free the resources used in `LV_EVENT_DELETE`*/ lv_event_send(obj, LV_EVENT_DELETE, NULL); + /*Delete queued refresh queries*/ + lv_task_t * t = lv_task_get_next(NULL); + while(t) { + if(t->user_data == obj && t->task_cb == refresh_event_task_cb) { + lv_task_del(t); + break; + } + t = lv_task_get_next(t); + } + /*Delete from the group*/ #if LV_USE_GROUP lv_group_t * group = lv_obj_get_group(obj); From 416ef9e251d39dba291b86eab9ad7c1a22ff2e8d Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 9 Jul 2020 14:41:24 +0200 Subject: [PATCH 111/205] fix chart series area invalidation --- src/lv_widgets/lv_chart.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lv_widgets/lv_chart.c b/src/lv_widgets/lv_chart.c index 96b09e402..3129a1a77 100644 --- a/src/lv_widgets/lv_chart.c +++ b/src/lv_widgets/lv_chart.c @@ -1505,6 +1505,9 @@ static void invalidate_lines(lv_obj_t * chart, uint16_t i) lv_area_t coords; lv_area_copy(&coords, &series_area); + coords.y1 -= line_width + point_radius; + coords.y2 += line_width + point_radius; + if(i < ext->point_cnt - 1) { coords.x1 = ((w * i) / (ext->point_cnt - 1)) + x_ofs - line_width - point_radius; coords.x2 = ((w * (i + 1)) / (ext->point_cnt - 1)) + x_ofs + line_width + point_radius; From 96bc39782180465f0bf4f26613c28d26af4cae18 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 10 Jul 2020 14:57:03 +0200 Subject: [PATCH 112/205] linemeter: fix conversation of current value to "level" Related to #1648 --- CHANGELOG.md | 1 + src/lv_widgets/lv_linemeter.c | 14 ++++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1a1ae061..c5a8a8c2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ Available in the `dev` branch ### Bugfixes - `tileview` fix navigation when not screen sized - Use 14px font by default to for better compatibility with smaller displays +- `linemeter` fix conversation of current value to "level" ## v7.1.0 (07.07.2020) diff --git a/src/lv_widgets/lv_linemeter.c b/src/lv_widgets/lv_linemeter.c index f29d848c3..1b561e5a6 100644 --- a/src/lv_widgets/lv_linemeter.c +++ b/src/lv_widgets/lv_linemeter.c @@ -126,9 +126,9 @@ void lv_linemeter_set_value(lv_obj_t * lmeter, int32_t value) ext->cur_value = ext->cur_value < ext->min_value ? ext->min_value : ext->cur_value; int16_t level_old = - (int32_t)((int32_t)(old_value - ext->min_value) * ext->line_cnt) / (ext->max_value - ext->min_value); + (int32_t)((int32_t)(old_value - ext->min_value) * (ext->line_cnt - 1)) / (ext->max_value - ext->min_value); int16_t level_new = - (int32_t)((int32_t)(ext->cur_value - ext->min_value) * ext->line_cnt) / (ext->max_value - ext->min_value); + (int32_t)((int32_t)(ext->cur_value - ext->min_value) * (ext->line_cnt - 1)) / (ext->max_value - ext->min_value); if(level_new == level_old) { return; @@ -393,7 +393,7 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin lv_coord_t y_ofs = lmeter->coords.y1 + r_out + top; int16_t angle_ofs = ext->angle_ofs + 90 + (360 - ext->scale_angle) / 2; int16_t level = - (int32_t)((int32_t)(ext->cur_value - ext->min_value) * ext->line_cnt) / (ext->max_value - ext->min_value); + (int32_t)((int32_t)(ext->cur_value - ext->min_value) * (ext->line_cnt - 1)) / (ext->max_value - ext->min_value); uint8_t i; lv_color_t main_color = lv_obj_get_style_line_color(lmeter, part); @@ -519,7 +519,8 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin p1.x = x_out_extra; p1.y = y_out_extra; - if(i >= level) { + /* Set the color of the lines */ + if(i > level) { line_dsc.color = end_color; line_dsc.width = end_line_width; } @@ -543,7 +544,7 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin lv_style_int_t end_border_width = lv_obj_get_style_scale_end_border_width(lmeter, part); if(border_width || end_border_width) { - int16_t end_angle = (level * ext->scale_angle) / (ext->line_cnt - 1) + angle_ofs - 1; + int16_t end_angle = ((level + 1) * ext->scale_angle) / (ext->line_cnt - 1) + angle_ofs; lv_draw_line_dsc_t arc_dsc; lv_draw_line_dsc_init(&arc_dsc); lv_obj_init_draw_line_dsc(lmeter, part, &arc_dsc); @@ -559,8 +560,6 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin arc_dsc.color = end_color; lv_draw_arc(x_ofs, y_ofs, r_out, end_angle, (angle_ofs + ext->scale_angle) % 360, clip_area, &arc_dsc); } - - } } @@ -570,7 +569,6 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin /********************** * STATIC FUNCTIONS **********************/ -#include /** * Handle the drawing related tasks of the line meters From 43a77d86990cd94f5ffe87d4b33350a4ff037d09 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 10 Jul 2020 15:03:54 +0200 Subject: [PATCH 113/205] linemeter: fix arc drawing if the value is close to max value --- src/lv_widgets/lv_linemeter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_widgets/lv_linemeter.c b/src/lv_widgets/lv_linemeter.c index 1b561e5a6..c8e7ae724 100644 --- a/src/lv_widgets/lv_linemeter.c +++ b/src/lv_widgets/lv_linemeter.c @@ -539,7 +539,7 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin lv_draw_mask_remove_id(mask_out_id); #endif - if(part == LV_LINEMETER_PART_MAIN) { + if(part == LV_LINEMETER_PART_MAIN && level + 1 < ext->line_cnt - 1) { lv_style_int_t border_width = lv_obj_get_style_scale_border_width(lmeter, part); lv_style_int_t end_border_width = lv_obj_get_style_scale_end_border_width(lmeter, part); From 6cb79914a85a2922e500c69aaa512f60195c50a4 Mon Sep 17 00:00:00 2001 From: Michael Katzenberger Date: Sun, 12 Jul 2020 11:46:12 +0200 Subject: [PATCH 114/205] widget tableview: add function lv_tabview_set_tab_name() to change a tab name --- src/lv_widgets/lv_tabview.c | 30 ++++++++++++++++++++++++++++++ src/lv_widgets/lv_tabview.h | 8 ++++++++ 2 files changed, 38 insertions(+) diff --git a/src/lv_widgets/lv_tabview.c b/src/lv_widgets/lv_tabview.c index 9e51d59dc..313a4bcfc 100644 --- a/src/lv_widgets/lv_tabview.c +++ b/src/lv_widgets/lv_tabview.c @@ -448,6 +448,36 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t an lv_btnmatrix_set_btn_ctrl(ext->btns, ext->tab_cur, LV_BTNMATRIX_CTRL_CHECK_STATE); } +/** + * Set the name of a tab. + * @param tabview pointer to Tab view object + * @param id index of a tab to load + * @param name new tab name + */ +void lv_tabview_set_tab_name(lv_obj_t *tabview, uint16_t id, char *name) +{ + LV_ASSERT_OBJ(tabview, LV_OBJX_NAME); + + // get tabview's ext pointer which contains the tab name pointer list + lv_tabview_ext_t *ext = lv_obj_get_ext_attr(tabview); + + // check for valid tab index + if (ext->tab_cnt > id) + { + // reallocate memory for new tab name (use reallocate due to mostly the size didn't change much) + char *str = lv_mem_realloc((void *)ext->tab_name_ptr[id], strlen(name) + 1); + LV_ASSERT_MEM(str); + + // store new tab name at allocated memory + strcpy(str, name); + // update pointer + ext->tab_name_ptr[id] = str; + + // force redrawing of the tab headers + lv_obj_invalidate(ext->btns); + } +} + /** * Set the animation time of tab view when a new tab is loaded * @param tabview pointer to Tab view object diff --git a/src/lv_widgets/lv_tabview.h b/src/lv_widgets/lv_tabview.h index 50530ee85..668c8b44b 100644 --- a/src/lv_widgets/lv_tabview.h +++ b/src/lv_widgets/lv_tabview.h @@ -119,6 +119,14 @@ void lv_tabview_clean_tab(lv_obj_t * tab); */ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t anim); +/** + * Set the name of a tab. + * @param tabview pointer to Tab view object + * @param id index of a tab to load + * @param name new tab name + */ +void lv_tabview_set_tab_name(lv_obj_t * tabview, uint16_t id, char * name); + /** * Set the animation time of tab view when a new tab is loaded * @param tabview pointer to Tab view object From ba7a86de748401b684125875cffc3e3890beb969 Mon Sep 17 00:00:00 2001 From: Michael Katzenberger Date: Sun, 12 Jul 2020 14:22:09 +0200 Subject: [PATCH 115/205] implement review findings: use C-style comments --- src/lv_widgets/lv_tabview.c | 14 +++++++------- src/lv_widgets/lv_tabview.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lv_widgets/lv_tabview.c b/src/lv_widgets/lv_tabview.c index 313a4bcfc..f68d69a36 100644 --- a/src/lv_widgets/lv_tabview.c +++ b/src/lv_widgets/lv_tabview.c @@ -451,29 +451,29 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t an /** * Set the name of a tab. * @param tabview pointer to Tab view object - * @param id index of a tab to load + * @param id index of the tab the name should be set * @param name new tab name */ void lv_tabview_set_tab_name(lv_obj_t *tabview, uint16_t id, char *name) { LV_ASSERT_OBJ(tabview, LV_OBJX_NAME); - // get tabview's ext pointer which contains the tab name pointer list + /* get tabview's ext pointer which contains the tab name pointer list */ lv_tabview_ext_t *ext = lv_obj_get_ext_attr(tabview); - // check for valid tab index + /* check for valid tab index */ if (ext->tab_cnt > id) { - // reallocate memory for new tab name (use reallocate due to mostly the size didn't change much) + /* reallocate memory for new tab name (use reallocate due to mostly the size didn't change much) */ char *str = lv_mem_realloc((void *)ext->tab_name_ptr[id], strlen(name) + 1); LV_ASSERT_MEM(str); - // store new tab name at allocated memory + /* store new tab name at allocated memory */ strcpy(str, name); - // update pointer + /* update pointer */ ext->tab_name_ptr[id] = str; - // force redrawing of the tab headers + /* force redrawing of the tab headers */ lv_obj_invalidate(ext->btns); } } diff --git a/src/lv_widgets/lv_tabview.h b/src/lv_widgets/lv_tabview.h index 668c8b44b..eca985e62 100644 --- a/src/lv_widgets/lv_tabview.h +++ b/src/lv_widgets/lv_tabview.h @@ -122,7 +122,7 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t an /** * Set the name of a tab. * @param tabview pointer to Tab view object - * @param id index of a tab to load + * @param id index of the tab the name should be set * @param name new tab name */ void lv_tabview_set_tab_name(lv_obj_t * tabview, uint16_t id, char * name); From e1a09551ceb34db2126864ec999cb0e15ed68abc Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 13 Jul 2020 09:43:18 +0200 Subject: [PATCH 116/205] fix drawing on right border --- CHANGELOG.md | 1 + src/lv_draw/lv_draw_rect.c | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5a8a8c2c..5f0b54057 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ Available in the `dev` branch - `tileview` fix navigation when not screen sized - Use 14px font by default to for better compatibility with smaller displays - `linemeter` fix conversation of current value to "level" +- fix drawing on right border ## v7.1.0 (07.07.2020) diff --git a/src/lv_draw/lv_draw_rect.c b/src/lv_draw/lv_draw_rect.c index 161b8e433..38e3de6fc 100644 --- a/src/lv_draw/lv_draw_rect.c +++ b/src/lv_draw/lv_draw_rect.c @@ -545,8 +545,12 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv fill_area.y1 = disp_area->y1 + draw_area.y1; fill_area.y2 = fill_area.y1; + uint32_t buf_ofs = 0; if(dsc->border_side == LV_BORDER_SIDE_LEFT) fill_area.x2 = coords->x1 + corner_size; - else if(dsc->border_side == LV_BORDER_SIDE_RIGHT) fill_area.x1 = coords->x2 - corner_size; + else if(dsc->border_side == LV_BORDER_SIDE_RIGHT) { + fill_area.x1 = coords->x2 - corner_size; + buf_ofs = fill_area.x1 - coords->x1; + } volatile bool top_only = false; volatile bool bottom_only = false; @@ -565,7 +569,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv (bottom_only && fill_area.y1 >= coords->y2 - corner_size)) { _lv_memset_ff(mask_buf, draw_area_w); mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); - _lv_blend_fill(clip, &fill_area, color, mask_buf, mask_res, opa, blend_mode); + _lv_blend_fill(clip, &fill_area, color, mask_buf + buf_ofs, mask_res, opa, blend_mode); } fill_area.y1++; fill_area.y2++; From baeda1998fdecea9ce611816f058b5fe165ab451 Mon Sep 17 00:00:00 2001 From: pete-pjb Date: Mon, 13 Jul 2020 14:26:04 +0100 Subject: [PATCH 117/205] Fix chart linked list free before use bug. --- src/lv_widgets/lv_chart.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/lv_widgets/lv_chart.c b/src/lv_widgets/lv_chart.c index 3129a1a77..44060d9f2 100644 --- a/src/lv_widgets/lv_chart.c +++ b/src/lv_widgets/lv_chart.c @@ -783,13 +783,15 @@ static lv_res_t lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param if(sign == LV_SIGNAL_CLEANUP) { lv_chart_series_t * ser; - _LV_LL_READ(ext->series_ll, ser) { + while( ext->series_ll.head != NULL ) { + ser =_lv_ll_get_head(&ext->series_ll); - if(!ser->ext_buf_assigned) lv_mem_free(ser->points); + if(!ser->ext_buf_assigned) lv_mem_free(ser->points); - lv_mem_free(ser); - } - _lv_ll_clear(&ext->series_ll); + _lv_ll_remove(&ext->series_ll, ser); + lv_mem_free(ser); + } + _lv_ll_clear(&ext->series_ll); lv_obj_clean_style_list(chart, LV_CHART_PART_SERIES); lv_obj_clean_style_list(chart, LV_CHART_PART_SERIES_BG); From 18072b3dd4026077a926a7ec2d319f38cbbd4860 Mon Sep 17 00:00:00 2001 From: Michael Katzenberger Date: Mon, 13 Jul 2020 19:56:06 +0200 Subject: [PATCH 118/205] update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5a8a8c2c..e04547c51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ Available in the `dev` branch - Add `lv_theme_set_base()` to allow easy extension of built-in (or any) themes - Add `lv_obj_align_x()` and `lv_obj_align_y()` functions - Add `lv_obj_align_origo_x()` and `lv_obj_align_origo_y()` functions +- Add `lv_tabview_set_tab_name()` function - used to change a tab's name ### Bugfixes - `tileview` fix navigation when not screen sized From 7e38ac68e3e2a84fabbb70b5462ba2b78b01284f Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 13 Jul 2020 19:59:53 +0200 Subject: [PATCH 119/205] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4df40c6a5..adddee5f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Available in the `dev` branch ### New features - Add `lv_task_get_next` - Add `lv_event_send_refresh`, `lv_event_send_refresh_recursive`, `lv_event_queue_refresh_recursive` to easily send `LV_EVENT_REFRESH` to object +- Add `lv_tabview_set_tab_name()` function - used to change a tab's name ## v7.2.0 (planned on 21.07.2020) *Available in the `master` branch* @@ -25,7 +26,6 @@ Available in the `dev` branch - Add `lv_theme_set_base()` to allow easy extension of built-in (or any) themes - Add `lv_obj_align_x()` and `lv_obj_align_y()` functions - Add `lv_obj_align_origo_x()` and `lv_obj_align_origo_y()` functions -- Add `lv_tabview_set_tab_name()` function - used to change a tab's name ### Bugfixes - `tileview` fix navigation when not screen sized From d8e10c41cf08a7b4bd04b10ec7a57ee2d99b6221 Mon Sep 17 00:00:00 2001 From: Johannes Linde Date: Tue, 14 Jul 2020 12:04:53 +0200 Subject: [PATCH 120/205] Handle ESC/Cancel event in list --- src/lv_widgets/lv_list.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lv_widgets/lv_list.c b/src/lv_widgets/lv_list.c index 76ba666ff..dfd2b32af 100644 --- a/src/lv_widgets/lv_list.c +++ b/src/lv_widgets/lv_list.c @@ -767,6 +767,11 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param) if(btn) lv_list_focus_btn(list, btn); } } + else if(c == LV_KEY_ESC) { + lv_list_ext_t * ext = lv_obj_get_ext_attr(list); + /* Handle ESC/Cancel event */ + res = lv_event_send(ext->act_sel_btn, LV_EVENT_CANCEL, NULL); + } #endif } return res; From b1213dcc5908cad1ce861c1f146724a73653708f Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 14 Jul 2020 15:25:56 +0200 Subject: [PATCH 121/205] remove lv_event_queue_refresh_recursive keep only the synchronous functions for refresh for easier maintanance --- CHANGELOG.md | 2 +- src/lv_core/lv_obj.c | 36 ------------------------------------ src/lv_core/lv_obj.h | 8 -------- 3 files changed, 1 insertion(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index adddee5f0..7d81cb749 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ Available in the `dev` branch ### New features - Add `lv_task_get_next` -- Add `lv_event_send_refresh`, `lv_event_send_refresh_recursive`, `lv_event_queue_refresh_recursive` to easily send `LV_EVENT_REFRESH` to object +- Add `lv_event_send_refresh`, `lv_event_send_refresh_recursive` to easily send `LV_EVENT_REFRESH` to object - Add `lv_tabview_set_tab_name()` function - used to change a tab's name ## v7.2.0 (planned on 21.07.2020) diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 2b414addb..1ff68317c 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -98,7 +98,6 @@ static void opa_scale_anim(lv_obj_t * obj, lv_anim_value_t v); static void fade_in_anim_ready(lv_anim_t * a); #endif static void lv_event_mark_deleted(lv_obj_t * obj); -static void refresh_event_task_cb(lv_task_t * t); static bool obj_valid_child(const lv_obj_t * parent, const lv_obj_t * obj_to_find); static void lv_obj_del_async_cb(void * obj); static void obj_del_core(lv_obj_t * obj); @@ -1796,26 +1795,6 @@ void lv_event_send_refresh_recursive(lv_obj_t * obj) } } -/** - * Queue the sending of LV_EVENT_REFRESH event to an object and all of its children. - * The events won't be sent immediately but after `LV_DISP_DEF_REFR_PERIOD` delay. - * It is useful to refresh object only on a reasonable rate if this function is called very often. - * @param obj pointer to an object or NULL to refresh all objects of all displays - */ -void lv_event_queue_refresh_recursive(lv_obj_t * obj) -{ - lv_task_t * t = lv_task_get_next(NULL); - while(t) { - /* REturn if a refresh is already queued for this object*/ - if(t->task_cb == refresh_event_task_cb && t->user_data == obj) return; - t = lv_task_get_next(t); - } - - /*No queued task for this object so create one now*/ - t = lv_task_create(refresh_event_task_cb, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, obj); - lv_task_set_repeat_count(t, 1); -} - /** * Call an event function with an object, event, and data. @@ -3535,16 +3514,6 @@ static void obj_del_core(lv_obj_t * obj) /*Let the user free the resources used in `LV_EVENT_DELETE`*/ lv_event_send(obj, LV_EVENT_DELETE, NULL); - /*Delete queued refresh queries*/ - lv_task_t * t = lv_task_get_next(NULL); - while(t) { - if(t->user_data == obj && t->task_cb == refresh_event_task_cb) { - lv_task_del(t); - break; - } - t = lv_task_get_next(t); - } - /*Delete from the group*/ #if LV_USE_GROUP lv_group_t * group = lv_obj_get_group(obj); @@ -4307,11 +4276,6 @@ static void lv_event_mark_deleted(lv_obj_t * obj) } } -static void refresh_event_task_cb(lv_task_t * t) -{ - lv_event_send_refresh_recursive(t->user_data); -} - static bool obj_valid_child(const lv_obj_t * parent, const lv_obj_t * obj_to_find) { /*Check all children of `parent`*/ diff --git a/src/lv_core/lv_obj.h b/src/lv_core/lv_obj.h index 0f985ff83..9815d3b9b 100644 --- a/src/lv_core/lv_obj.h +++ b/src/lv_core/lv_obj.h @@ -837,14 +837,6 @@ lv_res_t lv_event_send_refresh(lv_obj_t * obj); */ void lv_event_send_refresh_recursive(lv_obj_t * obj); -/** - * Queue the sending of LV_EVENT_REFRESH event to an object and all of its children. - * The events won't be sent immediately but after `LV_DISP_DEF_REFR_PERIOD` delay. - * It is useful to refresh object only on a reasonable rate if this function is called very often. - * @param obj pointer to an object or NULL to refresh all objects of all displays - */ -void lv_event_queue_refresh_recursive(lv_obj_t * obj); - /** * Call an event function with an object, event, and data. * @param event_xcb an event callback function. If `NULL` `LV_RES_OK` will return without any actions. From a66afca68ed854c984464d73fd98e139532fb701 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 14 Jul 2020 17:06:33 +0200 Subject: [PATCH 122/205] Update README.md --- README.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 9ee6eb709..b13edbd8b 100644 --- a/README.md +++ b/README.md @@ -46,35 +46,34 @@ Basically, every modern controller (which is able to drive a display) is suitabl - RAM: - Static RAM usage: ~2 kB depending on the used features and objects types - Stack: > 2kB (> 8 kB is recommended) - - Dynamic data (heap): > 2 KB (> 16 kB is recommended if using several objects). - Set by `LV_MEM_SIZE` in *lv_conf.h*. + - Dynamic data (heap): > 2 KB (> 16 kB is recommended if using several objects) - Display buffer: > *"Horizontal resolution"* pixels (> 10 × *"Horizontal resolution"* is recommended) - C99 or newer compiler *Note that the memory usage might vary depending on the architecture, compiler and build options.* Just to mention some platforms: -- STM32F1, STM32F3, [STM32F4](https://blog.lvgl.io/2017-07-15/stm32f429_disco_port), [STM32F7](https://github.com/lvgl/lv_port_stm32f746_disco_sw4stm32), STM32L4 +- STM32F1, STM32F3, STM32F4, STM32F7, STM32L4, STM32L5, STM32H7 - Microchip dsPIC33, PIC24, PIC32MX, PIC32MZ - NXP: Kinetis, LPC, iMX, iMX RT - [Linux frame buffer](https://blog.lvgl.io/2018-01-03/linux_fb) (/dev/fb) - [Raspberry PI](http://www.vk3erw.com/index.php/16-software/63-raspberry-pi-official-7-touchscreen-and-littlevgl) - [Espressif ESP32](https://github.com/lvgl/lv_port_esp32) -- [Infineon aurix](https://github.com/lvgl/lv_port_aurix) -- Nordic NRF52 -- Quectell M66 +- [Infineon Aurix](https://github.com/lvgl/lv_port_aurix) +- Nordic NRF52 Bluetooth modules +- Quectell modems ## Get started -his list shows the recommended way of learning the library: +This list shows the recommended way of learning the library: 1. Check the [Online demos](https://lvgl.io/demos) to see LVGL in action (3 minutes) 2. Read the [Introduction](https://docs.lvgl.io/latest/en/html/intro/index.html) page of the documentation (5 minutes) -3. Read the [Quick overview](https://docs.lvgl.io/latest/en/html/get-started/quick-overview.html) page of the documentation (15 minutes) +3. Get familiar with the basics on the [Quick overview](https://docs.lvgl.io/latest/en/html/get-started/quick-overview.html) page (15 minutes) 4. Set up a [Simulator](https://docs.lvgl.io/latest/en/html/get-started/pc-simulator.html) (10 minutes) 5. Try out some [Examples](https://github.com/lvgl/lv_examples/) 6. Port LVGL to a board. See the [Porting](https://docs.lvgl.io/latest/en/html/porting/index.html) guide or check the ready to use [Projects](https://github.com/lvgl?q=lv_port_&type=&language=) 7. Read the [Overview](https://docs.lvgl.io/latest/en/html/overview/index.html) page to get a better understanding of the library. (2-3 hours) 8. Check the documentation of the [Widgets](https://docs.lvgl.io/latest/en/html/widgets/index.html) to see their features and usage -9. If you have questions got to the [Forum](http://forum.lvgl.io/) +9. If you have questions go to the [Forum](http://forum.lvgl.io/) 10. Read the [Contributing](https://docs.lvgl.io/latest/en/html/contributing/index.html) guide to see how you can help to improve LVGL (15 minutes) ## Examples @@ -117,4 +116,6 @@ lv.scr_load(scr) ``` ## Contributing +LVGL is an open project and contribution is very welcome. There are many ways to contribute from simply speaking about your project, through writing examples, improving the documentation, fixing bugs to hosing your own project under in LVGL. + For a detailed description of contribution opportunities visit the [Contributing](https://docs.lvgl.io/latest/en/html/contributing/index.html) section of the documentation. From ac5f1998e4391b91d476e70d5bb5fd9dde62b04f Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 14 Jul 2020 17:15:30 +0200 Subject: [PATCH 123/205] Update README.md --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index b13edbd8b..1fd3a229d 100644 --- a/README.md +++ b/README.md @@ -16,27 +16,27 @@ LVGL provides everything you need to create embedded GUI with easy-to-use graphi Website · Online demo · Docs · -Forum · +Forum --- ## Features -* Powerful building blocks: buttons, charts, lists, sliders, images, etc. +* Powerful [building blocks](https://docs.lvgl.io/latest/en/html/widgets/index.html): buttons, charts, lists, sliders, images, etc. * Advanced graphics: animations, anti-aliasing, opacity, smooth scrolling -* Simultaneously use various input devices: touchscreen, mouse, keyboard, encoder, buttons, etc. -* Simultaneously use multiple displays: e.g. monochrome and color display -* Multi-language support with UTF-8 encoding, Bidirectional support, and Arabic text handling -* Fully customizable graphical elements via CSS-like styles +* Use [various input devices](https://docs.lvgl.io/latest/en/html/overview/indev.html): touchscreen, mouse, keyboard, encoder, buttons, etc. +* Use [multiple displays](https://docs.lvgl.io/latest/en/html/overview/display.html): e.g. monochrome and color display * Hardware independent to use with any microcontroller or display * Scalable to operate with little memory (64 kB Flash, 10 kB RAM) +* Multi-language support with UTF-8 handling, Bidirectional and Arabic script support +* Fully customizable graphical elements via [CSS-like styles](https://docs.lvgl.io/latest/en/html/overview/style.html) * OS, External memory and GPU are supported but not required -* Single frame buffer operation even with advances graphical effects +* Smooth rendering even with a [single frame buffer](https://docs.lvgl.io/latest/en/html/porting/display.html) * Written in C for maximal compatibility (C++ compatible) * Micropython Binding exposes [LVGL API in Micropython](https://blog.lvgl.io/2019-02-20/micropython-bindings) -* Simulator to develop on PC without embedded hardware -* Tutorials, examples, themes for rapid development -* Documentation and API references +* [Simulator](https://docs.lvgl.io/latest/en/html/get-started/pc-simulator.html) to develop on PC without embedded hardware +* [Examples](lv_examples) and tutorials for rapid development +* [Documentation](http://docs.lvgl.io/) and API references ## Supported devices Basically, every modern controller (which is able to drive a display) is suitable to run LVGL. The minimal requirements are: From 798f3177f2eb2c0d1a9fc822bb09675d50a42e1c Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 14 Jul 2020 17:36:41 +0200 Subject: [PATCH 124/205] Update README.md --- README.md | 63 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 1fd3a229d..83548b218 100644 --- a/README.md +++ b/README.md @@ -38,17 +38,60 @@ LVGL provides everything you need to create embedded GUI with easy-to-use graphi * [Examples](lv_examples) and tutorials for rapid development * [Documentation](http://docs.lvgl.io/) and API references -## Supported devices +## Requirements Basically, every modern controller (which is able to drive a display) is suitable to run LVGL. The minimal requirements are: -- 16, 32 or 64 bit microcontroller or processor -- > 16 MHz clock speed is recommended -- Flash/ROM: > 64 kB for the very essential components (> 180 kB is recommended) -- RAM: - - Static RAM usage: ~2 kB depending on the used features and objects types - - Stack: > 2kB (> 8 kB is recommended) - - Dynamic data (heap): > 2 KB (> 16 kB is recommended if using several objects) - - Display buffer: > *"Horizontal resolution"* pixels (> 10 × *"Horizontal resolution"* is recommended) -- C99 or newer compiler + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Name MinimalRecommended
Architecture16, 32 or 64 bit microcontroller or processor
Clock > 16 MHz > 48 MHz
Flash/ROM > 64 kB > 180 MHz
Static RAM > 2 kB > 4 kB
Stack > 2 kB > 8 kB
Heap > 2 kB > 16 kB
Display buffer > 1 × hor. res. pixels > 10 × hor. res. pixels
Compiler C99 or newer
*Note that the memory usage might vary depending on the architecture, compiler and build options.* From 1d5300e02f118da873d2c60fe58ba98730f183c3 Mon Sep 17 00:00:00 2001 From: Diego Herranz Date: Wed, 15 Jul 2020 07:55:27 +0100 Subject: [PATCH 125/205] Fix README typos --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 83548b218..dfbd2a1ce 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Basically, every modern controller (which is able to drive a display) is suitabl Flash/ROM > 64 kB - > 180 MHz + > 180 kB @@ -100,11 +100,11 @@ Just to mention some platforms: - Microchip dsPIC33, PIC24, PIC32MX, PIC32MZ - NXP: Kinetis, LPC, iMX, iMX RT - [Linux frame buffer](https://blog.lvgl.io/2018-01-03/linux_fb) (/dev/fb) -- [Raspberry PI](http://www.vk3erw.com/index.php/16-software/63-raspberry-pi-official-7-touchscreen-and-littlevgl) +- [Raspberry Pi](http://www.vk3erw.com/index.php/16-software/63-raspberry-pi-official-7-touchscreen-and-littlevgl) - [Espressif ESP32](https://github.com/lvgl/lv_port_esp32) - [Infineon Aurix](https://github.com/lvgl/lv_port_aurix) - Nordic NRF52 Bluetooth modules -- Quectell modems +- Quectel modems ## Get started This list shows the recommended way of learning the library: @@ -114,7 +114,7 @@ This list shows the recommended way of learning the library: 4. Set up a [Simulator](https://docs.lvgl.io/latest/en/html/get-started/pc-simulator.html) (10 minutes) 5. Try out some [Examples](https://github.com/lvgl/lv_examples/) 6. Port LVGL to a board. See the [Porting](https://docs.lvgl.io/latest/en/html/porting/index.html) guide or check the ready to use [Projects](https://github.com/lvgl?q=lv_port_&type=&language=) -7. Read the [Overview](https://docs.lvgl.io/latest/en/html/overview/index.html) page to get a better understanding of the library. (2-3 hours) +7. Read the [Overview](https://docs.lvgl.io/latest/en/html/overview/index.html) page to get a better understanding of the library (2-3 hours) 8. Check the documentation of the [Widgets](https://docs.lvgl.io/latest/en/html/widgets/index.html) to see their features and usage 9. If you have questions go to the [Forum](http://forum.lvgl.io/) 10. Read the [Contributing](https://docs.lvgl.io/latest/en/html/contributing/index.html) guide to see how you can help to improve LVGL (15 minutes) From dd56e9a0133ebdf6b2f5dff109789dbf7431fab0 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 16 Jul 2020 13:08:18 +0200 Subject: [PATCH 126/205] set the cursor object non clickable by default Fixes: #1664 --- CHANGELOG.md | 3 ++- src/lv_core/lv_indev.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f0b54057..93d518ec9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,8 @@ Available in the `dev` branch - `tileview` fix navigation when not screen sized - Use 14px font by default to for better compatibility with smaller displays - `linemeter` fix conversation of current value to "level" -- fix drawing on right border +- Fix drawing on right border +- Set the cursor image non clickable by default ## v7.1.0 (07.07.2020) diff --git a/src/lv_core/lv_indev.c b/src/lv_core/lv_indev.c index 98461f5ed..3b1d2b25c 100644 --- a/src/lv_core/lv_indev.c +++ b/src/lv_core/lv_indev.c @@ -213,6 +213,7 @@ void lv_indev_set_cursor(lv_indev_t * indev, lv_obj_t * cur_obj) indev->cursor = cur_obj; lv_obj_set_parent(indev->cursor, lv_disp_get_layer_sys(indev->driver.disp)); lv_obj_set_pos(indev->cursor, indev->proc.types.pointer.act_point.x, indev->proc.types.pointer.act_point.y); + lv_obj_set_click(indev->cursor, false); } #if LV_USE_GROUP From a4774ccc7255546ad6fcba4b11293c597e1de9b1 Mon Sep 17 00:00:00 2001 From: Themba Dube Date: Thu, 16 Jul 2020 18:55:25 -0400 Subject: [PATCH 127/205] Add LV_USE_FONT_COMPRESSED to control support for compressed fonts --- src/lv_font/lv_font_fmt_txt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lv_font/lv_font_fmt_txt.c b/src/lv_font/lv_font_fmt_txt.c index 403fe26ee..d155cf0f1 100644 --- a/src/lv_font/lv_font_fmt_txt.c +++ b/src/lv_font/lv_font_fmt_txt.c @@ -88,6 +88,7 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic } /*Handle compressed bitmap*/ else { +#if LV_USE_FONT_COMPRESSED uint32_t gsize = gdsc->box_w * gdsc->box_h; if(gsize == 0) return NULL; @@ -117,6 +118,9 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic bool prefilter = fdsc->bitmap_format == LV_FONT_FMT_TXT_COMPRESSED ? true : false; decompress(&fdsc->glyph_bitmap[gdsc->bitmap_index], decompr_buf, gdsc->box_w, gdsc->box_h, (uint8_t)fdsc->bpp, prefilter); return decompr_buf; +#else /* !LV_USE_FONT_COMPRESSED */ + return NULL; +#endif } /*If not returned earlier then the letter is not found in this font*/ From da9a5f58d0980e1d6dc37c8176a4bc1ec14fcb9c Mon Sep 17 00:00:00 2001 From: Themba Dube Date: Thu, 16 Jul 2020 18:55:35 -0400 Subject: [PATCH 128/205] Don't include blending code if LV_USE_BLEND_MODES is disabled --- src/lv_draw/lv_draw_blend.c | 14 ++++++++++++-- src/lv_draw/lv_draw_blend.h | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/lv_draw/lv_draw_blend.c b/src/lv_draw/lv_draw_blend.c index 375bee819..a7d9e0d1d 100644 --- a/src/lv_draw/lv_draw_blend.c +++ b/src/lv_draw/lv_draw_blend.c @@ -36,9 +36,11 @@ LV_ATTRIBUTE_FAST_MEM static void fill_normal(const lv_area_t * disp_area, lv_co lv_color_t color, lv_opa_t opa, const lv_opa_t * mask, lv_draw_mask_res_t mask_res); +#if LV_USE_BLEND_MODES static void fill_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area, lv_color_t color, lv_opa_t opa, const lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_blend_mode_t mode); +#endif static void map_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area, const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa, @@ -49,12 +51,14 @@ LV_ATTRIBUTE_FAST_MEM static void map_normal(const lv_area_t * disp_area, lv_col const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa, const lv_opa_t * mask, lv_draw_mask_res_t mask_res); +#if LV_USE_BLEND_MODES static void map_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area, const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa, const lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_blend_mode_t mode); static inline lv_color_t color_blend_true_color_additive(lv_color_t fg, lv_color_t bg, lv_opa_t opa); static inline lv_color_t color_blend_true_color_subtractive(lv_color_t fg, lv_color_t bg, lv_opa_t opa); +#endif /********************** * STATIC VARIABLES @@ -167,9 +171,11 @@ LV_ATTRIBUTE_FAST_MEM void _lv_blend_fill(const lv_area_t * clip_area, const lv_ else if(mode == LV_BLEND_MODE_NORMAL) { fill_normal(disp_area, disp_buf, &draw_area, color, opa, mask, mask_res); } +#if LV_USE_BLEND_MODES else { fill_blended(disp_area, disp_buf, &draw_area, color, opa, mask, mask_res, mode); } +#endif } /** @@ -230,9 +236,11 @@ LV_ATTRIBUTE_FAST_MEM void _lv_blend_map(const lv_area_t * clip_area, const lv_a else if(mode == LV_BLEND_MODE_NORMAL) { map_normal(disp_area, disp_buf, &draw_area, map_area, map_buf, opa, mask, mask_res); } +#if LV_USE_BLEND_MODES else { map_blended(disp_area, disp_buf, &draw_area, map_area, map_buf, opa, mask, mask_res, mode); } +#endif } @@ -515,7 +523,7 @@ LV_ATTRIBUTE_FAST_MEM static void fill_normal(const lv_area_t * disp_area, lv_co } } - +#if LV_USE_BLEND_MODES /** * Fill an area with a color but apply blending algorithms * @param disp_area the current display area (destination area) @@ -606,6 +614,7 @@ static void fill_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, co } } } +#endif static void map_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area, const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa, @@ -845,7 +854,7 @@ LV_ATTRIBUTE_FAST_MEM static void map_normal(const lv_area_t * disp_area, lv_col } } } - +#if LV_USE_BLEND_MODES static void map_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area, const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa, const lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_blend_mode_t mode) @@ -996,3 +1005,4 @@ static inline lv_color_t color_blend_true_color_subtractive(lv_color_t fg, lv_co return lv_color_mix(fg, bg, opa); } +#endif diff --git a/src/lv_draw/lv_draw_blend.h b/src/lv_draw/lv_draw_blend.h index 2d5e349d7..a5f57ed88 100644 --- a/src/lv_draw/lv_draw_blend.h +++ b/src/lv_draw/lv_draw_blend.h @@ -26,8 +26,10 @@ extern "C" { **********************/ enum { LV_BLEND_MODE_NORMAL, +#if LV_USE_BLEND_MODES LV_BLEND_MODE_ADDITIVE, LV_BLEND_MODE_SUBTRACTIVE, +#endif }; typedef uint8_t lv_blend_mode_t; From b26b4435a5d844d1e0e64d2ae697bdd3236dc169 Mon Sep 17 00:00:00 2001 From: Themba Dube Date: Thu, 16 Jul 2020 18:56:58 -0400 Subject: [PATCH 129/205] Add LV_USE_FONT_COMPRESSED to lv_conf_template.h --- lv_conf_template.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lv_conf_template.h b/lv_conf_template.h index 36a55ee15..22333849d 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -391,6 +391,11 @@ typedef void * lv_indev_drv_user_data_t; /*Type of user data in the i * but with > 10,000 characters if you see issues probably you need to enable it.*/ #define LV_FONT_FMT_TXT_LARGE 0 +/* Enables/disables support for compressed fonts. If it's disabled, compressed + * glyphs cannot be processed by the library and won't be rendered. + */ +#define LV_USE_FONT_COMPRESSED 1 + /* Set the pixel order of the display. * Important only if "subpx fonts" are used. * With "normal" font it doesn't matter. From ae94302f4d75332883d6e59d5045f46b41fad08f Mon Sep 17 00:00:00 2001 From: mentha Date: Fri, 17 Jul 2020 16:09:24 +0800 Subject: [PATCH 130/205] Fix lv_canvas_set_buffer doc Lines in canvas buffers are byte aligned so buffers might request larger size and contain unused bits. The previous documented calc method would often result in a buffer size smaller than what was expected by LVGL, leading to memory corruption and program crash. --- src/lv_widgets/lv_canvas.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_widgets/lv_canvas.h b/src/lv_widgets/lv_canvas.h index 7d60855df..ce4cca2f7 100644 --- a/src/lv_widgets/lv_canvas.h +++ b/src/lv_widgets/lv_canvas.h @@ -60,7 +60,7 @@ lv_obj_t * lv_canvas_create(lv_obj_t * par, const lv_obj_t * copy); /** * Set a buffer for the canvas. * @param buf a buffer where the content of the canvas will be. - * The required size is (lv_img_color_format_get_px_size(cf) * w * h) / 8) + * The required size is (lv_img_color_format_get_px_size(cf) * w) / 8 * h) * It can be allocated with `lv_mem_alloc()` or * it can be statically allocated array (e.g. static lv_color_t buf[100*50]) or * it can be an address in RAM or external SRAM From c0a7cf76b9b1f43763dcf3f5466e7dabef8daaa4 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 17 Jul 2020 11:41:49 +0200 Subject: [PATCH 131/205] minor fixes with LV_COLOR_DEPTH == 1 --- src/lv_draw/lv_draw_img.c | 3 +-- src/lv_draw/lv_draw_rect.c | 1 - src/lv_misc/lv_color.h | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/lv_draw/lv_draw_img.c b/src/lv_draw/lv_draw_img.c index 1c6dcee93..b447d615e 100644 --- a/src/lv_draw/lv_draw_img.c +++ b/src/lv_draw/lv_draw_img.c @@ -407,7 +407,6 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const return; } #endif - /*Build the image and a mask line-by-line*/ uint32_t mask_buf_size = lv_area_get_size(&draw_area) > LV_HOR_RES_MAX ? LV_HOR_RES_MAX : lv_area_get_size(&draw_area); lv_color_t * map2 = _lv_mem_buf_get(mask_buf_size * sizeof(lv_color_t)); lv_opa_t * mask_buf = _lv_mem_buf_get(mask_buf_size); @@ -420,7 +419,7 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const lv_opa_t px_opa = map_px[LV_IMG_PX_SIZE_ALPHA_BYTE - 1]; mask_buf[px_i] = px_opa; if(px_opa) { -#if LV_COLOR_DEPTH == 8 +#if LV_COLOR_DEPTH == 8 || LV_COLOR_DEPTH == 1 map2[px_i].full = map_px[0]; #elif LV_COLOR_DEPTH == 16 map2[px_i].full = map_px[0] + (map_px[1] << 8); diff --git a/src/lv_draw/lv_draw_rect.c b/src/lv_draw/lv_draw_rect.c index 38e3de6fc..47ed3dc70 100644 --- a/src/lv_draw/lv_draw_rect.c +++ b/src/lv_draw/lv_draw_rect.c @@ -1559,4 +1559,3 @@ static void draw_value(const lv_area_t * coords, const lv_area_t * clip, lv_draw lv_draw_label(&value_area, clip, &label_dsc, dsc->value_str, NULL); } - diff --git a/src/lv_misc/lv_color.h b/src/lv_misc/lv_color.h index 168f48bb5..1b557788c 100644 --- a/src/lv_misc/lv_color.h +++ b/src/lv_misc/lv_color.h @@ -390,7 +390,7 @@ static inline uint32_t lv_color_to32(lv_color_t color) { #if LV_COLOR_DEPTH == 1 if(color.full == 0) - return 0; + return 0xFF000000; else return 0xFFFFFFFF; #elif LV_COLOR_DEPTH == 8 From 2d984da893943c4ef07c1110c60369e465b79e25 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 17 Jul 2020 14:08:42 +0200 Subject: [PATCH 132/205] improve mono theme when used with keyboard or encoder --- CHANGELOG.md | 1 + src/lv_themes/lv_theme_mono.c | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93d518ec9..cd015f1b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ Available in the `dev` branch - `linemeter` fix conversation of current value to "level" - Fix drawing on right border - Set the cursor image non clickable by default +- Improve mono theme when used with keyboard or encoder ## v7.1.0 (07.07.2020) diff --git a/src/lv_themes/lv_theme_mono.c b/src/lv_themes/lv_theme_mono.c index 466f84064..ba5357088 100644 --- a/src/lv_themes/lv_theme_mono.c +++ b/src/lv_themes/lv_theme_mono.c @@ -38,6 +38,7 @@ typedef struct { lv_style_t pad_normal; lv_style_t pad_small; lv_style_t pad_inner; + lv_style_t txt_underline; #if LV_USE_ARC lv_style_t arc_bg, arc_indic; @@ -122,6 +123,8 @@ static void basic_init(void) lv_style_set_bg_opa(&styles->bg, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_bg_color(&styles->bg, LV_STATE_DEFAULT, BG_COLOR); lv_style_set_border_width(&styles->bg, LV_STATE_DEFAULT, BORDER_WIDTH); + lv_style_set_border_width(&styles->bg, LV_STATE_FOCUSED, BORDER_WIDTH * 2); + lv_style_set_border_width(&styles->bg, LV_STATE_FOCUSED | LV_STATE_EDITED, BORDER_WIDTH * 3); lv_style_set_border_color(&styles->bg, LV_STATE_DEFAULT, FG_COLOR); lv_style_set_line_width(&styles->bg, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 100, 1)); lv_style_set_scale_end_line_width(&styles->bg, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 100, 1)); @@ -139,10 +142,11 @@ static void basic_init(void) style_init_reset(&styles->clip_corner); lv_style_set_clip_corner(&styles->clip_corner, LV_STATE_DEFAULT, true); - style_init_reset(&styles->btn); lv_style_set_radius(&styles->btn, LV_STATE_DEFAULT, RADIUS); lv_style_set_border_width(&styles->btn, LV_STATE_DEFAULT, BORDER_WIDTH); + lv_style_set_border_width(&styles->btn, LV_STATE_FOCUSED, BORDER_WIDTH + 1); + lv_style_set_border_width(&styles->btn, LV_STATE_FOCUSED | LV_STATE_EDITED, BORDER_WIDTH + 2); lv_style_set_border_color(&styles->btn, LV_STATE_DEFAULT, FG_COLOR); lv_style_set_bg_color(&styles->btn, LV_STATE_DEFAULT, BG_COLOR); lv_style_set_bg_color(&styles->btn, LV_STATE_PRESSED, FG_COLOR); @@ -204,6 +208,9 @@ static void basic_init(void) style_init_reset(&styles->pad_inner); lv_style_set_pad_inner(&styles->pad_inner, LV_STATE_DEFAULT, LV_DPI / 15); + + style_init_reset(&styles->txt_underline); + lv_style_set_text_decor(&styles->txt_underline, LV_STATE_FOCUSED, LV_TEXT_DECOR_UNDERLINE); } static void arc_init(void) @@ -589,6 +596,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); + _lv_style_list_add_style(list, &styles->txt_underline); break; #endif @@ -600,6 +608,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BTN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); + _lv_style_list_add_style(list, &styles->txt_underline); break; #endif @@ -714,6 +723,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->round); _lv_style_list_add_style(list, &styles->pad_small); + _lv_style_list_add_style(list, &styles->fg_color); break; #endif @@ -725,6 +735,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BULLET); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); + _lv_style_list_add_style(list, &styles->pad_small); break; #endif @@ -741,6 +752,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); + _lv_style_list_add_style(list, &styles->txt_underline); break; #endif @@ -775,6 +787,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BTN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); + _lv_style_list_add_style(list, &styles->txt_underline); break; case LV_THEME_TABVIEW_PAGE: @@ -834,6 +847,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); _lv_style_list_add_style(list, &styles->list_btn); + _lv_style_list_add_style(list, &styles->txt_underline); break; #endif @@ -940,12 +954,14 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) _lv_style_list_add_style(list, &styles->fg_color); _lv_style_list_add_style(list, &styles->pad_none); _lv_style_list_add_style(list, &styles->no_radius); + _lv_style_list_add_style(list, &styles->txt_underline); break; case LV_THEME_SPINBOX_BTN: list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); + _lv_style_list_add_style(list, &styles->txt_underline); break; #endif From 75875e244d0c8f888cc9ec3bbce8fe9e02a97d36 Mon Sep 17 00:00:00 2001 From: Adam Han Date: Fri, 17 Jul 2020 15:51:09 +0100 Subject: [PATCH 133/205] fixes #1671 lv_cont_layout_grid() fails to calculate available space in a row this issue results in space waste in right side of container the size of wasted space in each row is pad_left plus pad_inner --- src/lv_widgets/lv_cont.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_widgets/lv_cont.c b/src/lv_widgets/lv_cont.c index 6aa4d0305..ffb716832 100644 --- a/src/lv_widgets/lv_cont.c +++ b/src/lv_widgets/lv_cont.c @@ -628,7 +628,7 @@ static void lv_cont_layout_grid(lv_obj_t * cont) _LV_LL_READ_BACK(cont->child_ll, child) { if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue; lv_coord_t obj_w = lv_obj_get_width(child); - if(act_x + inner + obj_w > w_fit) { + if(act_x + obj_w > w_fit + left) { act_x = left; act_y += y_ofs; } From 960bca78070e2d53f6e90319b36c83a4b57a0eca Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 21 Jul 2020 13:29:36 +0200 Subject: [PATCH 134/205] Run code formatter --- src/lv_core/lv_disp.c | 106 +++++++++++++------------- src/lv_core/lv_disp.h | 4 +- src/lv_core/lv_obj.c | 12 ++- src/lv_core/lv_refr.c | 10 ++- src/lv_font/lv_font_fmt_txt.c | 8 +- src/lv_font/lv_font_fmt_txt.h | 2 +- src/lv_hal/lv_hal_disp.h | 3 +- src/lv_themes/lv_theme.c | 2 +- src/lv_themes/lv_theme_template.c | 6 +- src/lv_widgets/lv_calendar.c | 6 +- src/lv_widgets/lv_chart.c | 122 +++++++++++++++--------------- src/lv_widgets/lv_chart.h | 26 +++---- src/lv_widgets/lv_checkbox.h | 4 +- src/lv_widgets/lv_roller.c | 9 ++- 14 files changed, 166 insertions(+), 154 deletions(-) diff --git a/src/lv_core/lv_disp.c b/src/lv_core/lv_disp.c index d3c6321f4..6cf6283ef 100644 --- a/src/lv_core/lv_disp.c +++ b/src/lv_core/lv_disp.c @@ -23,9 +23,9 @@ **********************/ #if LV_USE_ANIMATION -static void scr_load_anim_start(lv_anim_t * a); -static void opa_scale_anim(lv_obj_t * obj, lv_anim_value_t v); -static void scr_anim_ready(lv_anim_t * a); + static void scr_load_anim_start(lv_anim_t * a); + static void opa_scale_anim(lv_obj_t * obj, lv_anim_value_t v); + static void scr_anim_ready(lv_anim_t * a); #endif /********************** @@ -166,7 +166,7 @@ void lv_disp_set_bg_color(lv_disp_t * disp, lv_color_t color) * @param disp pointer to a display * @param img_src path to file or pointer to an `lv_img_dsc_t` variable */ -void lv_disp_set_bg_image(lv_disp_t * disp, const void * img_src) +void lv_disp_set_bg_image(lv_disp_t * disp, const void * img_src) { if(!disp) disp = lv_disp_get_default(); if(!disp) { @@ -248,60 +248,60 @@ void lv_scr_load_anim(lv_obj_t * new_scr, lv_scr_load_anim_t anim_type, uint32_t lv_anim_set_delay(&a_old, delay); switch(anim_type) { - case LV_SCR_LOAD_ANIM_NONE: - /* Create a dummy animation to apply the delay*/ - lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x); - lv_anim_set_values(&a_new, 0, 0); - break; - case LV_SCR_LOAD_ANIM_OVER_LEFT: - lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x); - lv_anim_set_values(&a_new, lv_disp_get_hor_res(d), 0); - break; - case LV_SCR_LOAD_ANIM_OVER_RIGHT: - lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x); - lv_anim_set_values(&a_new, -lv_disp_get_hor_res(d), 0); - break; - case LV_SCR_LOAD_ANIM_OVER_TOP: - lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_y); - lv_anim_set_values(&a_new, lv_disp_get_ver_res(d), 0); - break; - case LV_SCR_LOAD_ANIM_OVER_BOTTOM: - lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_y); - lv_anim_set_values(&a_new, -lv_disp_get_ver_res(d), 0); - break; - case LV_SCR_LOAD_ANIM_MOVE_LEFT: - lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x); - lv_anim_set_values(&a_new, lv_disp_get_hor_res(d), 0); + case LV_SCR_LOAD_ANIM_NONE: + /* Create a dummy animation to apply the delay*/ + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x); + lv_anim_set_values(&a_new, 0, 0); + break; + case LV_SCR_LOAD_ANIM_OVER_LEFT: + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x); + lv_anim_set_values(&a_new, lv_disp_get_hor_res(d), 0); + break; + case LV_SCR_LOAD_ANIM_OVER_RIGHT: + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x); + lv_anim_set_values(&a_new, -lv_disp_get_hor_res(d), 0); + break; + case LV_SCR_LOAD_ANIM_OVER_TOP: + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_y); + lv_anim_set_values(&a_new, lv_disp_get_ver_res(d), 0); + break; + case LV_SCR_LOAD_ANIM_OVER_BOTTOM: + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_y); + lv_anim_set_values(&a_new, -lv_disp_get_ver_res(d), 0); + break; + case LV_SCR_LOAD_ANIM_MOVE_LEFT: + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x); + lv_anim_set_values(&a_new, lv_disp_get_hor_res(d), 0); - lv_anim_set_exec_cb(&a_old, (lv_anim_exec_xcb_t) lv_obj_set_x); - lv_anim_set_values(&a_old, 0, -lv_disp_get_hor_res(d)); - break; - case LV_SCR_LOAD_ANIM_MOVE_RIGHT: - lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x); - lv_anim_set_values(&a_new, -lv_disp_get_hor_res(d), 0); + lv_anim_set_exec_cb(&a_old, (lv_anim_exec_xcb_t) lv_obj_set_x); + lv_anim_set_values(&a_old, 0, -lv_disp_get_hor_res(d)); + break; + case LV_SCR_LOAD_ANIM_MOVE_RIGHT: + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x); + lv_anim_set_values(&a_new, -lv_disp_get_hor_res(d), 0); - lv_anim_set_exec_cb(&a_old, (lv_anim_exec_xcb_t) lv_obj_set_x); - lv_anim_set_values(&a_old, 0, lv_disp_get_hor_res(d)); - break; - case LV_SCR_LOAD_ANIM_MOVE_TOP: - lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_y); - lv_anim_set_values(&a_new, lv_disp_get_ver_res(d), 0); + lv_anim_set_exec_cb(&a_old, (lv_anim_exec_xcb_t) lv_obj_set_x); + lv_anim_set_values(&a_old, 0, lv_disp_get_hor_res(d)); + break; + case LV_SCR_LOAD_ANIM_MOVE_TOP: + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_y); + lv_anim_set_values(&a_new, lv_disp_get_ver_res(d), 0); - lv_anim_set_exec_cb(&a_old, (lv_anim_exec_xcb_t) lv_obj_set_y); - lv_anim_set_values(&a_old, 0, -lv_disp_get_ver_res(d)); - break; - case LV_SCR_LOAD_ANIM_MOVE_BOTTOM: - lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_y); - lv_anim_set_values(&a_new, -lv_disp_get_ver_res(d), 0); + lv_anim_set_exec_cb(&a_old, (lv_anim_exec_xcb_t) lv_obj_set_y); + lv_anim_set_values(&a_old, 0, -lv_disp_get_ver_res(d)); + break; + case LV_SCR_LOAD_ANIM_MOVE_BOTTOM: + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_y); + lv_anim_set_values(&a_new, -lv_disp_get_ver_res(d), 0); - lv_anim_set_exec_cb(&a_old, (lv_anim_exec_xcb_t) lv_obj_set_y); - lv_anim_set_values(&a_old, 0, lv_disp_get_ver_res(d)); - break; + lv_anim_set_exec_cb(&a_old, (lv_anim_exec_xcb_t) lv_obj_set_y); + lv_anim_set_values(&a_old, 0, lv_disp_get_ver_res(d)); + break; - case LV_SCR_LOAD_ANIM_FADE_ON: - lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) opa_scale_anim); - lv_anim_set_values(&a_new, LV_OPA_TRANSP, LV_OPA_COVER); - break; + case LV_SCR_LOAD_ANIM_FADE_ON: + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) opa_scale_anim); + lv_anim_set_values(&a_new, LV_OPA_TRANSP, LV_OPA_COVER); + break; } lv_anim_start(&a_new); diff --git a/src/lv_core/lv_disp.h b/src/lv_core/lv_disp.h index d29978c5c..a0757accf 100644 --- a/src/lv_core/lv_disp.h +++ b/src/lv_core/lv_disp.h @@ -35,7 +35,7 @@ typedef enum { LV_SCR_LOAD_ANIM_MOVE_TOP, LV_SCR_LOAD_ANIM_MOVE_BOTTOM, LV_SCR_LOAD_ANIM_FADE_ON, -}lv_scr_load_anim_t; +} lv_scr_load_anim_t; /********************** * GLOBAL PROTOTYPES @@ -98,7 +98,7 @@ void lv_disp_set_bg_color(lv_disp_t * disp, lv_color_t color); * @param disp pointer to a display * @param img_src path to file or pointer to an `lv_img_dsc_t` variable */ -void lv_disp_set_bg_image(lv_disp_t * disp, const void * img_src); +void lv_disp_set_bg_image(lv_disp_t * disp, const void * img_src); /** * Opacity of the background diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 024216ce3..c5ef773d7 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -85,8 +85,10 @@ static void refresh_children_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coor static void report_style_mod_core(void * style_p, lv_obj_t * obj); static void refresh_children_style(lv_obj_t * obj); static void base_dir_refr_children(lv_obj_t * obj); -static void obj_align_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set, lv_coord_t x_ofs, lv_coord_t y_ofs); -static void obj_align_origo_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set, lv_coord_t x_ofs, lv_coord_t y_ofs); +static void obj_align_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set, + lv_coord_t x_ofs, lv_coord_t y_ofs); +static void obj_align_origo_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set, + lv_coord_t x_ofs, lv_coord_t y_ofs); #if LV_USE_ANIMATION static lv_style_trans_t * trans_create(lv_obj_t * obj, lv_style_property_t prop, uint8_t part, lv_state_t prev_state, lv_state_t new_state); @@ -3818,7 +3820,8 @@ static void base_dir_refr_children(lv_obj_t * obj) } } -static void obj_align_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set, lv_coord_t x_ofs, lv_coord_t y_ofs) +static void obj_align_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set, + lv_coord_t x_ofs, lv_coord_t y_ofs) { lv_point_t new_pos; _lv_area_align(&base->coords, &obj->coords, align, &new_pos); @@ -3837,7 +3840,8 @@ static void obj_align_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t ali else if(y_set) lv_obj_set_y(obj, new_pos.y); } -static void obj_align_origo_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set, lv_coord_t x_ofs, lv_coord_t y_ofs) +static void obj_align_origo_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set, + lv_coord_t x_ofs, lv_coord_t y_ofs) { lv_coord_t new_x = lv_obj_get_x(obj); lv_coord_t new_y = lv_obj_get_y(obj); diff --git a/src/lv_core/lv_refr.c b/src/lv_core/lv_refr.c index 9644a0459..0765fba27 100644 --- a/src/lv_core/lv_refr.c +++ b/src/lv_core/lv_refr.c @@ -517,10 +517,12 @@ static void lv_refr_area_part(const lv_area_t * area_p) lv_area_t a; lv_area_set(&a, 0, 0, header.w - 1, header.h - 1); lv_draw_img(&a, &start_mask, disp_refr->bg_img, &dsc); - } else { + } + else { LV_LOG_WARN("Can't draw the background image") } - } else { + } + else { lv_draw_rect_dsc_t dsc; lv_draw_rect_dsc_init(&dsc); dsc.bg_color = disp_refr->bg_color; @@ -542,8 +544,8 @@ static void lv_refr_area_part(const lv_area_t * area_p) if(top_act_scr == NULL) { - top_act_scr = disp_refr->act_scr; - } + top_act_scr = disp_refr->act_scr; + } /*Do the refreshing from the top object*/ lv_refr_obj_and_children(top_act_scr, &start_mask); diff --git a/src/lv_font/lv_font_fmt_txt.c b/src/lv_font/lv_font_fmt_txt.c index 403fe26ee..a2c72d740 100644 --- a/src/lv_font/lv_font_fmt_txt.c +++ b/src/lv_font/lv_font_fmt_txt.c @@ -115,7 +115,8 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic } bool prefilter = fdsc->bitmap_format == LV_FONT_FMT_TXT_COMPRESSED ? true : false; - decompress(&fdsc->glyph_bitmap[gdsc->bitmap_index], decompr_buf, gdsc->box_w, gdsc->box_h, (uint8_t)fdsc->bpp, prefilter); + decompress(&fdsc->glyph_bitmap[gdsc->bitmap_index], decompr_buf, gdsc->box_w, gdsc->box_h, (uint8_t)fdsc->bpp, + prefilter); return decompr_buf; } @@ -349,7 +350,7 @@ static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord uint8_t * line_buf2 = NULL; if(prefilter) { - line_buf2= _lv_mem_buf_get(w); + line_buf2 = _lv_mem_buf_get(w); } decompress_line(line_buf1, w); @@ -371,7 +372,8 @@ static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord bits_write(out, wrp, line_buf1[x], bpp); wrp += wr_size; } - } else { + } + else { decompress_line(line_buf1, w); for(x = 0; x < w; x++) { diff --git a/src/lv_font/lv_font_fmt_txt.h b/src/lv_font/lv_font_fmt_txt.h index 549c7f5e6..863b19269 100644 --- a/src/lv_font/lv_font_fmt_txt.h +++ b/src/lv_font/lv_font_fmt_txt.h @@ -150,7 +150,7 @@ typedef struct { typedef enum { LV_FONT_FMT_TXT_PLAIN = 0, LV_FONT_FMT_TXT_COMPRESSED = 1, - LV_FONT_FMT_TXT_COMPRESSED_NO_PREFILTER= 1, + LV_FONT_FMT_TXT_COMPRESSED_NO_PREFILTER = 1, } lv_font_fmt_txt_bitmap_format_t; diff --git a/src/lv_hal/lv_hal_disp.h b/src/lv_hal/lv_hal_disp.h index a3c627489..e99830b19 100644 --- a/src/lv_hal/lv_hal_disp.h +++ b/src/lv_hal/lv_hal_disp.h @@ -151,7 +151,8 @@ typedef struct _disp_t { struct _lv_obj_t * top_layer; /**< @see lv_disp_get_layer_top */ struct _lv_obj_t * sys_layer; /**< @see lv_disp_get_layer_sys */ - uint8_t del_prev :1; /**< 1: Automatically delete the previous screen when the screen load animation is ready */ +uint8_t del_prev : + 1; /**< 1: Automatically delete the previous screen when the screen load animation is ready */ lv_color_t bg_color; /**< Default display color when screens are transparent*/ const void * bg_img; /**< An image source to display as wallpaper*/ diff --git a/src/lv_themes/lv_theme.c b/src/lv_themes/lv_theme.c index eddeebd83..a13527f38 100644 --- a/src/lv_themes/lv_theme.c +++ b/src/lv_themes/lv_theme.c @@ -191,7 +191,7 @@ static void apply_theme(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) } /*apply_xcb is deprecated, use apply_cb instead*/ - if (th->apply_xcb) { + if(th->apply_xcb) { th->apply_xcb(obj, name); } else if(th->apply_cb) { diff --git a/src/lv_themes/lv_theme_template.c b/src/lv_themes/lv_theme_template.c index bd65d7a7b..2a22fad4e 100644 --- a/src/lv_themes/lv_theme_template.c +++ b/src/lv_themes/lv_theme_template.c @@ -81,7 +81,7 @@ static void basic_init(void) lv_style_set_bg_color(&styles->btn, LV_STATE_PRESSED, lv_color_hex3(0xccc)); lv_style_set_bg_color(&styles->btn, LV_STATE_CHECKED, theme.color_primary); lv_style_set_bg_color(&styles->btn, LV_STATE_CHECKED | LV_STATE_PRESSED, lv_color_darken(theme.color_primary, - LV_OPA_30)); + LV_OPA_30)); lv_style_set_bg_color(&styles->btn, LV_STATE_DISABLED, LV_COLOR_SILVER); lv_style_set_text_color(&styles->btn, LV_STATE_DISABLED, LV_COLOR_GRAY); lv_style_set_image_recolor(&styles->btn, LV_STATE_DISABLED, LV_COLOR_GRAY); @@ -345,8 +345,8 @@ static void win_init(void) * @return a pointer to reference this theme later */ lv_theme_t * lv_theme_template_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags, - const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_subtitle, - const lv_font_t * font_title) + const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_subtitle, + const lv_font_t * font_title) { /* This trick is required only to avoid the garbage collection of diff --git a/src/lv_widgets/lv_calendar.c b/src/lv_widgets/lv_calendar.c index 54fc831e2..9936b624b 100644 --- a/src/lv_widgets/lv_calendar.c +++ b/src/lv_widgets/lv_calendar.c @@ -1070,11 +1070,11 @@ static uint8_t get_day_of_week(uint32_t year, uint32_t month, uint32_t day) uint32_t a = month < 3 ? 1 : 0; uint32_t b = year - a; - #if LV_CALENDAR_WEEK_STARTS_MONDAY +#if LV_CALENDAR_WEEK_STARTS_MONDAY uint32_t day_of_week = (day + (31 * (month - 2 + 12 * a) / 12) + b + (b / 4) - (b / 100) + (b / 400) - 1) % 7; - #else +#else uint32_t day_of_week = (day + (31 * (month - 2 + 12 * a) / 12) + b + (b / 4) - (b / 100) + (b / 400)) % 7; - #endif +#endif return day_of_week; } diff --git a/src/lv_widgets/lv_chart.c b/src/lv_widgets/lv_chart.c index 44060d9f2..d7308cf88 100644 --- a/src/lv_widgets/lv_chart.c +++ b/src/lv_widgets/lv_chart.c @@ -311,44 +311,44 @@ void lv_chart_set_point_count(lv_obj_t * chart, uint16_t point_cnt) if(point_cnt < 1) point_cnt = 1; _LV_LL_READ_BACK(ext->series_ll, ser) { - if( !ser->ext_buf_assigned ) { - if(ser->start_point != 0) { - lv_coord_t * new_points = lv_mem_alloc(sizeof(lv_coord_t) * point_cnt); - LV_ASSERT_MEM(new_points); - if(new_points == NULL) return; + if(!ser->ext_buf_assigned) { + if(ser->start_point != 0) { + lv_coord_t * new_points = lv_mem_alloc(sizeof(lv_coord_t) * point_cnt); + LV_ASSERT_MEM(new_points); + if(new_points == NULL) return; - if(point_cnt >= point_cnt_old) { - for(i = 0; i < point_cnt_old; i++) { - new_points[i] = - ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/ - } - for(i = point_cnt_old; i < point_cnt; i++) { - new_points[i] = def; /*Fill up the rest with default value*/ - } - } - else { - for(i = 0; i < point_cnt; i++) { - new_points[i] = - ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/ - } - } + if(point_cnt >= point_cnt_old) { + for(i = 0; i < point_cnt_old; i++) { + new_points[i] = + ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/ + } + for(i = point_cnt_old; i < point_cnt; i++) { + new_points[i] = def; /*Fill up the rest with default value*/ + } + } + else { + for(i = 0; i < point_cnt; i++) { + new_points[i] = + ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/ + } + } - /*Switch over pointer from old to new*/ - lv_mem_free(ser->points); - ser->points = new_points; - } - else { - ser->points = lv_mem_realloc(ser->points, sizeof(lv_coord_t) * point_cnt); - LV_ASSERT_MEM(ser->points); - if(ser->points == NULL) return; - /*Initialize the new points*/ - if(point_cnt > point_cnt_old) { - for(i = point_cnt_old - 1; i < point_cnt; i++) { - ser->points[i] = def; - } - } - } - } + /*Switch over pointer from old to new*/ + lv_mem_free(ser->points); + ser->points = new_points; + } + else { + ser->points = lv_mem_realloc(ser->points, sizeof(lv_coord_t) * point_cnt); + LV_ASSERT_MEM(ser->points); + if(ser->points == NULL) return; + /*Initialize the new points*/ + if(point_cnt > point_cnt_old) { + for(i = point_cnt_old - 1; i < point_cnt; i++) { + ser->points[i] = def; + } + } + } + } ser->start_point = 0; } @@ -552,8 +552,8 @@ void lv_chart_set_secondary_y_tick_texts(lv_obj_t * chart, const char * list_of_ /** * Set the index of the x-axis start point in the data array * @param chart pointer to a chart object - * @param ser pointer to a data series on 'chart' - * @param id the index of the x point in the data array + * @param ser pointer to a data series on 'chart' + * @param id the index of the x point in the data array */ void lv_chart_set_x_start_point(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id) { @@ -563,7 +563,7 @@ void lv_chart_set_x_start_point(lv_obj_t * chart, lv_chart_series_t * ser, uint1 if(chart == NULL || ser == NULL) return; lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); if(ext == NULL) return; - if( id >= ext->point_cnt ) return; + if(id >= ext->point_cnt) return; ser->start_point = id; } @@ -571,9 +571,9 @@ void lv_chart_set_x_start_point(lv_obj_t * chart, lv_chart_series_t * ser, uint1 * Set an external array of data points to use for the chart * NOTE: It is the users responsibility to make sure the point_cnt matches the external array size. * @param chart pointer to a chart object - * @param ser pointer to a data series on 'chart' - * @param array external array of points for chart - * @param point_cnt number of external points in the array + * @param ser pointer to a data series on 'chart' + * @param array external array of points for chart + * @param point_cnt number of external points in the array */ void lv_chart_set_ext_array(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t array[], uint16_t point_cnt) { @@ -582,7 +582,7 @@ void lv_chart_set_ext_array(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_ if(chart == NULL || ser == NULL) return; lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); - if( !ser->ext_buf_assigned && ser->points ) lv_mem_free(ser->points); + if(!ser->ext_buf_assigned && ser->points) lv_mem_free(ser->points); ser->ext_buf_assigned = true; ser->points = array; ext->point_cnt = point_cnt; @@ -591,9 +591,9 @@ void lv_chart_set_ext_array(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_ /** * Set an individual point y value in the chart series directly based on index * @param chart pointer to a chart object - * @param ser pointer to a data series on 'chart' - * @param value value to assign to array point - * @param id the index of the x point in the array + * @param ser pointer to a data series on 'chart' + * @param value value to assign to array point + * @param id the index of the x point in the array */ void lv_chart_set_point_id(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t value, uint16_t id) { @@ -603,7 +603,7 @@ void lv_chart_set_point_id(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t if(chart == NULL || ser == NULL) return; lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); if(ext == NULL) return; - if( id >= ext->point_cnt ) return; + if(id >= ext->point_cnt) return; ser->points[id] = value; } @@ -623,7 +623,7 @@ void lv_chart_set_series_axis(lv_obj_t * chart, lv_chart_series_t * ser, lv_char return; } - if( ser->y_axis == axis) return; + if(ser->y_axis == axis) return; ser->y_axis = axis; lv_chart_refresh(chart); @@ -661,8 +661,8 @@ uint16_t lv_chart_get_point_count(const lv_obj_t * chart) /** * Get the current index of the x-axis start point in the data array - * @param ser pointer to a data series on 'chart' - * @return the index of the current x start point in the data array + * @param ser pointer to a data series on 'chart' + * @return the index of the current x start point in the data array */ uint16_t lv_chart_get_x_start_point(lv_chart_series_t * ser) { @@ -674,9 +674,9 @@ uint16_t lv_chart_get_x_start_point(lv_chart_series_t * ser) /** * Get an individual point y value in the chart series directly based on index * @param chart pointer to a chart object - * @param ser pointer to a data series on 'chart' - * @param id the index of the x point in the array - * @return value of array point at index id + * @param ser pointer to a data series on 'chart' + * @param id the index of the x point in the array + * @return value of array point at index id */ lv_coord_t lv_chart_get_point_id(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id) { @@ -684,7 +684,7 @@ lv_coord_t lv_chart_get_point_id(lv_obj_t * chart, lv_chart_series_t * ser, uint LV_ASSERT_NULL(ser); lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); - if( id >= ext->point_cnt ) id = 0; + if(id >= ext->point_cnt) id = 0; return(ser->points[id]); } @@ -783,15 +783,15 @@ static lv_res_t lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param if(sign == LV_SIGNAL_CLEANUP) { lv_chart_series_t * ser; - while( ext->series_ll.head != NULL ) { - ser =_lv_ll_get_head(&ext->series_ll); + while(ext->series_ll.head != NULL) { + ser = _lv_ll_get_head(&ext->series_ll); - if(!ser->ext_buf_assigned) lv_mem_free(ser->points); + if(!ser->ext_buf_assigned) lv_mem_free(ser->points); - _lv_ll_remove(&ext->series_ll, ser); - lv_mem_free(ser); - } - _lv_ll_clear(&ext->series_ll); + _lv_ll_remove(&ext->series_ll, ser); + lv_mem_free(ser); + } + _lv_ll_clear(&ext->series_ll); lv_obj_clean_style_list(chart, LV_CHART_PART_SERIES); lv_obj_clean_style_list(chart, LV_CHART_PART_SERIES_BG); diff --git a/src/lv_widgets/lv_chart.h b/src/lv_widgets/lv_chart.h index c7f68284c..e35c696c7 100644 --- a/src/lv_widgets/lv_chart.h +++ b/src/lv_widgets/lv_chart.h @@ -276,8 +276,8 @@ void lv_chart_set_y_tick_texts(lv_obj_t * chart, const char * list_of_values, ui /** * Set the index of the x-axis start point in the data array * @param chart pointer to a chart object - * @param ser pointer to a data series on 'chart' - * @param id the index of the x point in the data array + * @param ser pointer to a data series on 'chart' + * @param id the index of the x point in the data array */ void lv_chart_set_x_start_point(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id); @@ -285,17 +285,17 @@ void lv_chart_set_x_start_point(lv_obj_t * chart, lv_chart_series_t * ser, uint1 * Set an external array of data points to use for the chart * NOTE: It is the users responsibility to make sure the point_cnt matches the external array size. * @param chart pointer to a chart object - * @param ser pointer to a data series on 'chart' - * @param array external array of points for chart + * @param ser pointer to a data series on 'chart' + * @param array external array of points for chart */ -void lv_chart_set_ext_array(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t array[], uint16_t point_cnt ); +void lv_chart_set_ext_array(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t array[], uint16_t point_cnt); /** * Set an individual point value in the chart series directly based on index * @param chart pointer to a chart object - * @param ser pointer to a data series on 'chart' - * @param value value to assign to array point - * @param id the index of the x point in the array + * @param ser pointer to a data series on 'chart' + * @param value value to assign to array point + * @param id the index of the x point in the array */ void lv_chart_set_point_id(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t value, uint16_t id); @@ -327,17 +327,17 @@ uint16_t lv_chart_get_point_count(const lv_obj_t * chart); /** * get the current index of the x-axis start point in the data array - * @param ser pointer to a data series on 'chart' - * @return the index of the current x start point in the data array + * @param ser pointer to a data series on 'chart' + * @return the index of the current x start point in the data array */ uint16_t lv_chart_get_x_start_point(lv_chart_series_t * ser); /** * Get an individual point value in the chart series directly based on index * @param chart pointer to a chart object - * @param ser pointer to a data series on 'chart' - * @param id the index of the x point in the array - * @return value of array point at index id + * @param ser pointer to a data series on 'chart' + * @param id the index of the x point in the array + * @return value of array point at index id */ lv_coord_t lv_chart_get_point_id(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id); diff --git a/src/lv_widgets/lv_checkbox.h b/src/lv_widgets/lv_checkbox.h index cb083733f..96bb0f1e2 100644 --- a/src/lv_widgets/lv_checkbox.h +++ b/src/lv_widgets/lv_checkbox.h @@ -113,7 +113,7 @@ static inline void lv_checkbox_set_disabled(lv_obj_t * cb) */ static inline void lv_checkbox_set_state(lv_obj_t * cb, lv_btn_state_t state) { - lv_btn_set_state(cb, state); + lv_btn_set_state(cb, state); } /*===================== * Getter functions @@ -153,7 +153,7 @@ static inline bool lv_checkbox_is_inactive(const lv_obj_t * cb) */ static inline lv_btn_state_t lv_checkbox_get_state(const lv_obj_t * cb) { - return lv_btn_get_state(cb); + return lv_btn_get_state(cb); } /********************** diff --git a/src/lv_widgets/lv_roller.c b/src/lv_widgets/lv_roller.c index 46f81221a..7c67fcb68 100644 --- a/src/lv_widgets/lv_roller.c +++ b/src/lv_widgets/lv_roller.c @@ -474,12 +474,15 @@ static lv_design_res_t lv_roller_design(lv_obj_t * roller, const lv_area_t * cli /*Get the size of the "selected text"*/ lv_point_t res_p; - _lv_txt_get_size(&res_p, lv_label_get_text(label), label_dsc.font, label_dsc.letter_space, label_dsc.line_space, lv_obj_get_width(roller), LV_TXT_FLAG_EXPAND); + _lv_txt_get_size(&res_p, lv_label_get_text(label), label_dsc.font, label_dsc.letter_space, label_dsc.line_space, + lv_obj_get_width(roller), LV_TXT_FLAG_EXPAND); /*Move the selected label proportionally with the background label*/ lv_coord_t roller_h = lv_obj_get_height(roller); - int32_t label_y_prop = label->coords.y1 - (roller_h / 2 + roller->coords.y1); /*label offset from the middle line of the roller*/ - label_y_prop = (label_y_prop << 14) / lv_obj_get_height(label); /*Proportional position from the middle line (upscaled)*/ + int32_t label_y_prop = label->coords.y1 - (roller_h / 2 + + roller->coords.y1); /*label offset from the middle line of the roller*/ + label_y_prop = (label_y_prop << 14) / lv_obj_get_height( + label); /*Proportional position from the middle line (upscaled)*/ /*Apply a correction with different line heights*/ const lv_font_t * normal_label_font = lv_obj_get_style_text_font(roller, LV_ROLLER_PART_BG); From 57079452b0da9b9072fa88da8354e020cc6b6e6b Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 21 Jul 2020 13:29:37 +0200 Subject: [PATCH 135/205] Release v7.2.0 --- library.json | 2 +- lv_conf_template.h | 2 +- lvgl.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library.json b/library.json index 6422a345e..a2c5dd2b9 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "lvgl", - "version": "7.1.0", + "version": "7.2.0", "keywords": "graphics, gui, embedded, tft, lvgl", "description": "Graphics library to create embedded GUI with easy-to-use graphical elements, beautiful visual effects and low memory footprint. It offers anti-aliasing, opacity, and animations using only one frame buffer.", "repository": { diff --git a/lv_conf_template.h b/lv_conf_template.h index 36a55ee15..c720a097b 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -1,6 +1,6 @@ /** * @file lv_conf.h - * Configuration file for LVGL v7.1.0 + * Configuration file for LVGL v7.2.0 */ /* diff --git a/lvgl.h b/lvgl.h index 6e1c15e33..76ac2855d 100644 --- a/lvgl.h +++ b/lvgl.h @@ -79,7 +79,7 @@ extern "C" { #define LVGL_VERSION_MAJOR 7 #define LVGL_VERSION_MINOR 2 #define LVGL_VERSION_PATCH 0 -#define LVGL_VERSION_INFO "dev" +#define LVGL_VERSION_INFO "" /********************** * TYPEDEFS From c36a96914b707906bbc9e4b68b99c7a5ff9915df Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 21 Jul 2020 13:38:04 +0200 Subject: [PATCH 136/205] fix release script --- scripts/release.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release.py b/scripts/release.py index c817baf8c..e64c13bdc 100755 --- a/scripts/release.py +++ b/scripts/release.py @@ -171,7 +171,7 @@ def drivers_merge_to_release_branch(v): def docs_clone(): title("docs: Clone") - #cmd("git clone --recursive https://github.com/lvgl/docs.git") + cmd("git clone --recursive https://github.com/lvgl/docs.git") os.chdir("./docs") def docs_get_api(): From 35b3a1f2a4413366fecb2ee7fc85fb7f40409fd9 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 21 Jul 2020 13:42:02 +0200 Subject: [PATCH 137/205] merge dev --- CHANGELOG.md | 8 +++++--- lvgl.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 581b4355a..e607b8987 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,15 +1,17 @@ # Changelog +## v7.4.0 (planned on 18.08.2020) +*Available in the `dev` branch* + ## v7.3.0 (planned on 04.08.2020) -Available in the `dev` branch +*Available in the `master` branch* ### New features - Add `lv_task_get_next` - Add `lv_event_send_refresh`, `lv_event_send_refresh_recursive` to easily send `LV_EVENT_REFRESH` to object - Add `lv_tabview_set_tab_name()` function - used to change a tab's name -## v7.2.0 (planned on 21.07.2020) -*Available in the `master` branch* +## v7.2.0 (21.07.2020) ### New features - Add `LV_CALENDAR_WEEK_STARTS_MONDAY` diff --git a/lvgl.h b/lvgl.h index 94a53df2c..f90729d7b 100644 --- a/lvgl.h +++ b/lvgl.h @@ -79,7 +79,7 @@ extern "C" { #define LVGL_VERSION_MAJOR 7 #define LVGL_VERSION_MINOR 3 #define LVGL_VERSION_PATCH 0 -#define LVGL_VERSION_INFO "" +#define LVGL_VERSION_INFO "dev" /********************** * TYPEDEFS From cc0ea22903b31047e3a6368216498245bf41809b Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 21 Jul 2020 13:43:05 +0200 Subject: [PATCH 138/205] increment version number to v7.4-dev --- lvgl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lvgl.h b/lvgl.h index 94a53df2c..ae383e640 100644 --- a/lvgl.h +++ b/lvgl.h @@ -77,9 +77,9 @@ extern "C" { *********************/ /*Current version of LVGL*/ #define LVGL_VERSION_MAJOR 7 -#define LVGL_VERSION_MINOR 3 +#define LVGL_VERSION_MINOR 4 #define LVGL_VERSION_PATCH 0 -#define LVGL_VERSION_INFO "" +#define LVGL_VERSION_INFO "dev" /********************** * TYPEDEFS From eb725a3a686e796a951de8317f000d3617e9f156 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 21 Jul 2020 16:06:09 +0200 Subject: [PATCH 139/205] add LV_USE_FONT_SUBPX option and draw_full_border() to avoid duplication in outline and border drawing --- CHANGELOG.md | 2 + lv_conf_template.h | 4 + src/lv_conf_internal.h | 13 + src/lv_draw/lv_draw_label.c | 4 + src/lv_draw/lv_draw_rect.c | 578 +++++++++++++++--------------------- 5 files changed, 267 insertions(+), 334 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e607b8987..44375b440 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ## v7.4.0 (planned on 18.08.2020) *Available in the `dev` branch* +- Reduce code size by adding: `LV_USE_FONT_COMPRESSED` and `LV_FONT_USE_SUBPX` and applying some optimization + ## v7.3.0 (planned on 04.08.2020) *Available in the `master` branch* diff --git a/lv_conf_template.h b/lv_conf_template.h index e42d722c5..fcbe9175b 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -396,11 +396,15 @@ typedef void * lv_indev_drv_user_data_t; /*Type of user data in the i */ #define LV_USE_FONT_COMPRESSED 1 +/* Enable subpixel rendering */ +#define LV_USE_FONT_SUBPX 1 +#if LV_USE_FONT_SUBPX /* Set the pixel order of the display. * Important only if "subpx fonts" are used. * With "normal" font it doesn't matter. */ #define LV_FONT_SUBPX_BGR 0 +#endif /*Declare the type of the user data of fonts (can be e.g. `void *`, `int`, `struct`)*/ typedef void * lv_font_user_data_t; diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index 135e8c374..7f86b0eae 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -589,6 +589,18 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */ #define LV_FONT_FMT_TXT_LARGE 0 #endif +/* Enables/disables support for compressed fonts. If it's disabled, compressed + * glyphs cannot be processed by the library and won't be rendered. + */ +#ifndef LV_USE_FONT_COMPRESSED +#define LV_USE_FONT_COMPRESSED 1 +#endif + +/* Enable subpixel rendering */ +#ifndef LV_USE_FONT_SUBPX +#define LV_USE_FONT_SUBPX 1 +#endif +#if LV_USE_FONT_SUBPX /* Set the pixel order of the display. * Important only if "subpx fonts" are used. * With "normal" font it doesn't matter. @@ -596,6 +608,7 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */ #ifndef LV_FONT_SUBPX_BGR #define LV_FONT_SUBPX_BGR 0 #endif +#endif /*Declare the type of the user data of fonts (can be e.g. `void *`, `int`, `struct`)*/ diff --git a/src/lv_draw/lv_draw_label.c b/src/lv_draw/lv_draw_label.c index 136b4d0d7..ac1b21086 100644 --- a/src/lv_draw/lv_draw_label.c +++ b/src/lv_draw/lv_draw_label.c @@ -607,6 +607,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_letter_normal(lv_coord_t pos_x, lv_coord_ 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_USE_FONT_SUBPX const uint8_t * bpp_opa_table; uint32_t bitmask_init; uint32_t bitmask; @@ -806,6 +807,9 @@ 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 } diff --git a/src/lv_draw/lv_draw_rect.c b/src/lv_draw/lv_draw_rect.c index 47ed3dc70..41a7fab26 100644 --- a/src/lv_draw/lv_draw_rect.c +++ b/src/lv_draw/lv_draw_rect.c @@ -41,6 +41,7 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_blur_corner(lv_coord_t size, lv_coord_t #endif static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc); static void draw_value(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc); +static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * area_outer, const lv_area_t * clip, lv_coord_t radius, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode); /********************** * STATIC VARIABLES @@ -370,41 +371,6 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv if(dsc->border_width == 0) return; if(dsc->border_side == LV_BORDER_SIDE_NONE) return; - lv_opa_t opa = dsc->border_opa; - - if(opa > LV_OPA_MAX) opa = LV_OPA_COVER; - - lv_disp_t * disp = _lv_refr_get_disp_refreshing(); - lv_disp_buf_t * vdb = lv_disp_get_buf(disp); - - /* Get clipped fill area which is the real draw area. - * It is always the same or inside `fill_area` */ - lv_area_t draw_area; - bool is_common; - is_common = _lv_area_intersect(&draw_area, coords, clip); - if(is_common == false) return; - - const lv_area_t * disp_area = &vdb->area; - - /* Now `draw_area` has absolute coordinates. - * Make it relative to `disp_area` to simplify draw to `disp_buf`*/ - draw_area.x1 -= disp_area->x1; - draw_area.y1 -= disp_area->y1; - draw_area.x2 -= disp_area->x1; - draw_area.y2 -= disp_area->y1; - - int32_t draw_area_w = lv_area_get_width(&draw_area); - - /*Create a mask if there is a radius*/ - lv_opa_t * mask_buf = _lv_mem_buf_get(draw_area_w); - - uint8_t other_mask_cnt = lv_draw_mask_get_cnt(); - bool simple_mode = true; - if(other_mask_cnt) simple_mode = false; - else if(dsc->border_side != LV_BORDER_SIDE_FULL) simple_mode = false; - - int16_t mask_rout_id = LV_MASK_ID_INV; - int32_t coords_w = lv_area_get_width(coords); int32_t coords_h = lv_area_get_height(coords); @@ -413,133 +379,73 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv int32_t short_side = LV_MATH_MIN(coords_w, coords_h); if(rout > short_side >> 1) rout = short_side >> 1; - /*Get the outer area*/ - lv_draw_mask_radius_param_t mask_rout_param; - if(rout > 0) { - lv_draw_mask_radius_init(&mask_rout_param, coords, rout, false); - mask_rout_id = lv_draw_mask_add(&mask_rout_param, NULL); - } - - /*Get the inner radius*/ - int32_t rin = rout - dsc->border_width; - if(rin < 0) rin = 0; - /*Get the inner area*/ - lv_area_t area_small; - lv_area_copy(&area_small, coords); - area_small.x1 += ((dsc->border_side & LV_BORDER_SIDE_LEFT) ? dsc->border_width : - (dsc->border_width + rout)); - area_small.x2 -= ((dsc->border_side & LV_BORDER_SIDE_RIGHT) ? dsc->border_width : - (dsc->border_width + rout)); - area_small.y1 += ((dsc->border_side & LV_BORDER_SIDE_TOP) ? dsc->border_width : - (dsc->border_width + rout)); - area_small.y2 -= ((dsc->border_side & LV_BORDER_SIDE_BOTTOM) ? dsc->border_width : - (dsc->border_width + rout)); + lv_area_t area_inner; + lv_area_copy(&area_inner, coords); + area_inner.x1 += ((dsc->border_side & LV_BORDER_SIDE_LEFT) ? dsc->border_width : - (dsc->border_width + rout)); + area_inner.x2 -= ((dsc->border_side & LV_BORDER_SIDE_RIGHT) ? dsc->border_width : - (dsc->border_width + rout)); + area_inner.y1 += ((dsc->border_side & LV_BORDER_SIDE_TOP) ? dsc->border_width : - (dsc->border_width + rout)); + area_inner.y2 -= ((dsc->border_side & LV_BORDER_SIDE_BOTTOM) ? dsc->border_width : - (dsc->border_width + rout)); - /*Create inner the mask*/ - lv_draw_mask_radius_param_t mask_rin_param; - lv_draw_mask_radius_init(&mask_rin_param, &area_small, rout - dsc->border_width, true); - int16_t mask_rin_id = lv_draw_mask_add(&mask_rin_param, NULL); - - int32_t corner_size = LV_MATH_MAX(rout, dsc->border_width - 1); - - int32_t h; - lv_draw_mask_res_t mask_res; - lv_area_t fill_area; - - lv_color_t color = dsc->border_color; - lv_blend_mode_t blend_mode = dsc->border_blend_mode; - - /*Apply some optimization if there is no other mask*/ - if(simple_mode) { - /*Draw the upper corner area*/ - int32_t upper_corner_end = coords->y1 - disp_area->y1 + corner_size; - upper_corner_end = LV_MATH_MIN(upper_corner_end, draw_area.y2); - fill_area.x1 = coords->x1; - fill_area.x2 = coords->x2; - fill_area.y1 = disp_area->y1 + draw_area.y1; - fill_area.y2 = fill_area.y1; - for(h = draw_area.y1; h <= upper_corner_end; h++) { - _lv_memset_ff(mask_buf, draw_area_w); - mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); - - lv_area_t fill_area2; - fill_area2.y1 = fill_area.y1; - fill_area2.y2 = fill_area.y2; - - fill_area2.x1 = coords->x1; - fill_area2.x2 = coords->x1 + rout - 1; - - _lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode); - - /*Draw the top horizontal line*/ - if(fill_area2.y2 < coords->y1 + dsc->border_width) { - fill_area2.x1 = coords->x1 + rout; - fill_area2.x2 = coords->x2 - rout; - - _lv_blend_fill(clip, &fill_area2, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode); - } - - fill_area2.x1 = coords->x2 - rout + 1; - fill_area2.x2 = coords->x2; - - int32_t mask_ofs = (coords->x2 - rout + 1) - (vdb->area.x1 + draw_area.x1); - if(mask_ofs < 0) mask_ofs = 0; - _lv_blend_fill(clip, &fill_area2, color, mask_buf + mask_ofs, mask_res, opa, blend_mode); - - fill_area.y1++; - fill_area.y2++; - } - - /*Draw the lower corner area */ - int32_t lower_corner_end = coords->y2 - disp_area->y1 - corner_size; - lower_corner_end = LV_MATH_MAX(lower_corner_end, draw_area.y1); - if(lower_corner_end <= upper_corner_end) lower_corner_end = upper_corner_end + 1; - fill_area.y1 = disp_area->y1 + lower_corner_end; - fill_area.y2 = fill_area.y1; - for(h = lower_corner_end; h <= draw_area.y2; h++) { - _lv_memset_ff(mask_buf, draw_area_w); - mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); - - lv_area_t fill_area2; - fill_area2.x1 = coords->x1; - fill_area2.x2 = coords->x1 + rout - 1; - fill_area2.y1 = fill_area.y1; - fill_area2.y2 = fill_area.y2; - - _lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode); - - /*Draw the bottom horizontal line*/ - if(fill_area2.y2 > coords->y2 - dsc->border_width) { - fill_area2.x1 = coords->x1 + rout; - fill_area2.x2 = coords->x2 - rout; - - _lv_blend_fill(clip, &fill_area2, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode); - } - fill_area2.x1 = coords->x2 - rout + 1; - fill_area2.x2 = coords->x2; - - int32_t mask_ofs = (coords->x2 - rout + 1) - (vdb->area.x1 + draw_area.x1); - if(mask_ofs < 0) mask_ofs = 0; - _lv_blend_fill(clip, &fill_area2, color, mask_buf + mask_ofs, mask_res, opa, blend_mode); - - - fill_area.y1++; - fill_area.y2++; - } - - /*Draw the left vertical border part*/ - fill_area.y1 = coords->y1 + corner_size + 1; - fill_area.y2 = coords->y2 - corner_size - 1; - - fill_area.x1 = coords->x1; - fill_area.x2 = coords->x1 + dsc->border_width - 1; - _lv_blend_fill(clip, &fill_area, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode); - - /*Draw the right vertical border*/ - fill_area.x1 = coords->x2 - dsc->border_width + 1; - fill_area.x2 = coords->x2; - - _lv_blend_fill(clip, &fill_area, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode); + if(dsc->border_side == LV_BORDER_SIDE_FULL) { + draw_full_border(&area_inner, coords, clip, dsc->radius, dsc->border_color, dsc->border_opa, dsc->border_blend_mode); } - /*Process line by line if there is other mask too*/ else { + lv_opa_t opa = dsc->border_opa; + if(opa > LV_OPA_MAX) opa = LV_OPA_COVER; + + lv_disp_t * disp = _lv_refr_get_disp_refreshing(); + lv_disp_buf_t * vdb = lv_disp_get_buf(disp); + + /* Get clipped fill area which is the real draw area. + * It is always the same or inside `fill_area` */ + lv_area_t draw_area; + bool is_common; + is_common = _lv_area_intersect(&draw_area, coords, clip); + if(is_common == false) return; + + const lv_area_t * disp_area = &vdb->area; + + /* Now `draw_area` has absolute coordinates. + * Make it relative to `disp_area` to simplify draw to `disp_buf`*/ + draw_area.x1 -= disp_area->x1; + draw_area.y1 -= disp_area->y1; + draw_area.x2 -= disp_area->x1; + draw_area.y2 -= disp_area->y1; + + int32_t draw_area_w = lv_area_get_width(&draw_area); + + /*Create a mask if there is a radius*/ + lv_opa_t * mask_buf = _lv_mem_buf_get(draw_area_w); + + uint8_t other_mask_cnt = lv_draw_mask_get_cnt(); + bool simple_mode = true; + if(other_mask_cnt) simple_mode = false; + + /*Create mask for the outer area*/ + int16_t mask_rout_id = LV_MASK_ID_INV; + lv_draw_mask_radius_param_t mask_rout_param; + if(rout > 0) { + lv_draw_mask_radius_init(&mask_rout_param, coords, rout, false); + mask_rout_id = lv_draw_mask_add(&mask_rout_param, NULL); + } + + /*Create mask for the inner mask*/ + int32_t rin = rout - dsc->border_width; + if(rin < 0) rin = 0; + lv_draw_mask_radius_param_t mask_rin_param; + lv_draw_mask_radius_init(&mask_rin_param, &area_inner, rout - dsc->border_width, true); + int16_t mask_rin_id = lv_draw_mask_add(&mask_rin_param, NULL); + + int32_t corner_size = LV_MATH_MAX(rout, dsc->border_width - 1); + + int32_t h; + lv_draw_mask_res_t mask_res; + lv_area_t fill_area; + + lv_color_t color = dsc->border_color; + lv_blend_mode_t blend_mode = dsc->border_blend_mode; + fill_area.x1 = coords->x1; fill_area.x2 = coords->x2; fill_area.y1 = disp_area->y1 + draw_area.y1; @@ -565,8 +471,8 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv for(h = draw_area.y1; h <= draw_area.y2; h++) { if(normal || - (top_only && fill_area.y1 <= coords->y1 + corner_size) || - (bottom_only && fill_area.y1 >= coords->y2 - corner_size)) { + (top_only && fill_area.y1 <= coords->y1 + corner_size) || + (bottom_only && fill_area.y1 >= coords->y2 - corner_size)) { _lv_memset_ff(mask_buf, draw_area_w); mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); _lv_blend_fill(clip, &fill_area, color, mask_buf + buf_ofs, mask_res, opa, blend_mode); @@ -575,10 +481,10 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv fill_area.y2++; } + lv_draw_mask_remove_id(mask_rin_id); + lv_draw_mask_remove_id(mask_rout_id); + _lv_mem_buf_release(mask_buf); } - lv_draw_mask_remove_id(mask_rin_id); - lv_draw_mask_remove_id(mask_rout_id); - _lv_mem_buf_release(mask_buf); } LV_ATTRIBUTE_FAST_MEM static inline lv_color_t grad_get(lv_draw_rect_dsc_t * dsc, lv_coord_t s, lv_coord_t i) @@ -1235,10 +1141,6 @@ static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_dr if(opa > LV_OPA_MAX) opa = LV_OPA_COVER; - uint8_t other_mask_cnt = lv_draw_mask_get_cnt(); - bool simple_mode = true; - if(other_mask_cnt) simple_mode = false; - /*Get the inner radius*/ lv_area_t area_inner; lv_area_copy(&area_inner, coords); @@ -1247,16 +1149,6 @@ static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_dr area_inner.x2 += dsc->outline_pad; area_inner.y2 += dsc->outline_pad; - int32_t inner_w = lv_area_get_width(&area_inner); - int32_t inner_h = lv_area_get_height(&area_inner); - - int32_t rin = dsc->radius; - int32_t short_side = LV_MATH_MIN(inner_w, inner_h); - if(rin > short_side >> 1) rin = short_side >> 1; - - /*Get the outer area*/ - int32_t rout = rin + dsc->outline_width; - lv_area_t area_outer; lv_area_copy(&area_outer, &area_inner); @@ -1265,163 +1157,7 @@ static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_dr area_outer.y1 -= dsc->outline_width; area_outer.y2 += dsc->outline_width; - int32_t coords_out_w = lv_area_get_width(&area_outer); - int32_t coords_out_h = lv_area_get_height(&area_outer); - short_side = LV_MATH_MIN(coords_out_w, coords_out_h); - if(rout > short_side >> 1) rout = short_side >> 1; - - lv_disp_t * disp = _lv_refr_get_disp_refreshing(); - lv_disp_buf_t * vdb = lv_disp_get_buf(disp); - - /* Get clipped fill area which is the real draw area. - * It is always the same or inside `fill_area` */ - lv_area_t draw_area; - bool is_common; - is_common = _lv_area_intersect(&draw_area, &area_outer, clip); - if(is_common == false) return; - - const lv_area_t * disp_area = &vdb->area; - - /* Now `draw_area` has absolute coordinates. - * Make it relative to `disp_area` to simplify draw to `disp_buf`*/ - draw_area.x1 -= disp_area->x1; - draw_area.y1 -= disp_area->y1; - draw_area.x2 -= disp_area->x1; - draw_area.y2 -= disp_area->y1; - - int32_t draw_area_w = lv_area_get_width(&draw_area); - - /*Create inner the mask*/ - lv_draw_mask_radius_param_t mask_rin_param; - lv_draw_mask_radius_init(&mask_rin_param, &area_inner, rin, true); - int16_t mask_rin_id = lv_draw_mask_add(&mask_rin_param, NULL); - - lv_draw_mask_radius_param_t mask_rout_param; - lv_draw_mask_radius_init(&mask_rout_param, &area_outer, rout, false); - int16_t mask_rout_id = lv_draw_mask_add(&mask_rout_param, NULL); - - lv_opa_t * mask_buf = _lv_mem_buf_get(draw_area_w); - - int32_t corner_size = LV_MATH_MAX(rout, dsc->outline_width - 1); - - int32_t h; - lv_draw_mask_res_t mask_res; - lv_area_t fill_area; - - lv_color_t color = dsc->outline_color; - lv_blend_mode_t blend_mode = dsc->outline_blend_mode; - - /*Apply some optimization if there is no other mask*/ - if(simple_mode) { - /*Draw the upper corner area*/ - int32_t upper_corner_end = area_outer.y1 - disp_area->y1 + corner_size; - - fill_area.x1 = area_outer.x1; - fill_area.x2 = area_outer.x2; - fill_area.y1 = disp_area->y1 + draw_area.y1; - fill_area.y2 = fill_area.y1; - for(h = draw_area.y1; h <= upper_corner_end; h++) { - _lv_memset_ff(mask_buf, draw_area_w); - mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); - - lv_area_t fill_area2; - fill_area2.y1 = fill_area.y1; - fill_area2.y2 = fill_area.y2; - - fill_area2.x1 = area_outer.x1; - fill_area2.x2 = area_outer.x1 + rout - 1; - - _lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode); - - /*Draw the top horizontal line*/ - if(fill_area2.y2 < area_outer.y1 + dsc->outline_width) { - fill_area2.x1 = area_outer.x1 + rout; - fill_area2.x2 = area_outer.x2 - rout; - - _lv_blend_fill(clip, &fill_area2, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode); - } - - fill_area2.x1 = area_outer.x2 - rout + 1; - fill_area2.x2 = area_outer.x2; - - int32_t mask_ofs = (area_outer.x2 - rout + 1) - (vdb->area.x1 + draw_area.x1); - if(mask_ofs < 0) mask_ofs = 0; - _lv_blend_fill(clip, &fill_area2, color, mask_buf + mask_ofs, mask_res, opa, blend_mode); - - fill_area.y1++; - fill_area.y2++; - } - - /*Draw the lower corner area */ - int32_t lower_corner_end = area_outer.y2 - disp_area->y1 - corner_size; - if(lower_corner_end <= upper_corner_end) lower_corner_end = upper_corner_end + 1; - fill_area.y1 = disp_area->y1 + lower_corner_end; - fill_area.y2 = fill_area.y1; - for(h = lower_corner_end; h <= draw_area.y2; h++) { - _lv_memset_ff(mask_buf, draw_area_w); - mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); - - lv_area_t fill_area2; - fill_area2.x1 = area_outer.x1; - fill_area2.x2 = area_outer.x1 + rout - 1; - fill_area2.y1 = fill_area.y1; - fill_area2.y2 = fill_area.y2; - - _lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode); - - /*Draw the bottom horizontal line*/ - if(fill_area2.y2 > area_outer.y2 - dsc->outline_width) { - fill_area2.x1 = area_outer.x1 + rout; - fill_area2.x2 = area_outer.x2 - rout; - - _lv_blend_fill(clip, &fill_area2, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode); - } - fill_area2.x1 = area_outer.x2 - rout + 1; - fill_area2.x2 = area_outer.x2; - - int32_t mask_ofs = (area_outer.x2 - rout + 1) - (vdb->area.x1 + draw_area.x1); - if(mask_ofs < 0) mask_ofs = 0; - _lv_blend_fill(clip, &fill_area2, color, mask_buf + mask_ofs, mask_res, opa, blend_mode); - - - fill_area.y1++; - fill_area.y2++; - } - - /*Draw the left vertical part*/ - fill_area.y1 = area_outer.y1 + corner_size + 1; - fill_area.y2 = area_outer.y2 - corner_size - 1; - - fill_area.x1 = area_outer.x1; - fill_area.x2 = area_outer.x1 + dsc->outline_width - 1; - _lv_blend_fill(clip, &fill_area, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode); - - /*Draw the right vertical border*/ - fill_area.x1 = area_outer.x2 - dsc->outline_width + 1; - fill_area.x2 = area_outer.x2; - - _lv_blend_fill(clip, &fill_area, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode); - } - /*Process line by line if there is other mask too*/ - else { - fill_area.x1 = area_outer.x1; - fill_area.x2 = area_outer.x2; - fill_area.y1 = disp_area->y1 + draw_area.y1; - fill_area.y2 = fill_area.y1; - - for(h = draw_area.y1; h <= draw_area.y2; h++) { - _lv_memset_ff(mask_buf, draw_area_w); - mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); - - _lv_blend_fill(clip, &fill_area, color, mask_buf, mask_res, opa, blend_mode); - fill_area.y1++; - fill_area.y2++; - - } - } - lv_draw_mask_remove_id(mask_rin_id); - lv_draw_mask_remove_id(mask_rout_id); - _lv_mem_buf_release(mask_buf); + draw_full_border(&area_inner, &area_outer, clip, dsc->radius, dsc->outline_color, dsc->outline_opa, dsc->outline_blend_mode); } static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc) @@ -1559,3 +1295,177 @@ static void draw_value(const lv_area_t * coords, const lv_area_t * clip, lv_draw lv_draw_label(&value_area, clip, &label_dsc, dsc->value_str, NULL); } + +static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * area_outer, const lv_area_t * clip, lv_coord_t radius, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode) +{ + uint8_t other_mask_cnt = lv_draw_mask_get_cnt(); + bool simple_mode = true; + if(other_mask_cnt) simple_mode = false; + + int32_t inner_w = lv_area_get_width(area_inner); + int32_t inner_h = lv_area_get_height(area_inner); + lv_coord_t border_width = area_outer->x2 - area_inner->x2; + int32_t rin = radius; + + int32_t short_side = LV_MATH_MIN(inner_w, inner_h); + if(rin > short_side >> 1) rin = short_side >> 1; + + /*Get the outer area*/ + int32_t rout = rin + border_width; + + int32_t coords_out_w = lv_area_get_width(area_outer); + int32_t coords_out_h = lv_area_get_height(area_outer); + short_side = LV_MATH_MIN(coords_out_w, coords_out_h); + if(rout > short_side >> 1) rout = short_side >> 1; + + lv_disp_t * disp = _lv_refr_get_disp_refreshing(); + lv_disp_buf_t * vdb = lv_disp_get_buf(disp); + + /* Get clipped fill area which is the real draw area. + * It is always the same or inside `fill_area` */ + lv_area_t draw_area; + bool is_common; + is_common = _lv_area_intersect(&draw_area, area_outer, clip); + if(is_common == false) return; + + const lv_area_t * disp_area = &vdb->area; + + /* Now `draw_area` has absolute coordinates. + * Make it relative to `disp_area` to simplify draw to `disp_buf`*/ + draw_area.x1 -= disp_area->x1; + draw_area.y1 -= disp_area->y1; + draw_area.x2 -= disp_area->x1; + draw_area.y2 -= disp_area->y1; + + int32_t draw_area_w = lv_area_get_width(&draw_area); + + /*Create inner the mask*/ + lv_draw_mask_radius_param_t mask_rin_param; + lv_draw_mask_radius_init(&mask_rin_param, area_inner, rin, true); + int16_t mask_rin_id = lv_draw_mask_add(&mask_rin_param, NULL); + + lv_draw_mask_radius_param_t mask_rout_param; + lv_draw_mask_radius_init(&mask_rout_param, area_outer, rout, false); + int16_t mask_rout_id = lv_draw_mask_add(&mask_rout_param, NULL); + + lv_opa_t * mask_buf = _lv_mem_buf_get(draw_area_w); + + int32_t corner_size = LV_MATH_MAX(rout, border_width - 1); + + int32_t h; + lv_draw_mask_res_t mask_res; + lv_area_t fill_area; + + /*Apply some optimization if there is no other mask*/ + if(simple_mode) { + /*Draw the upper corner area*/ + int32_t upper_corner_end = area_outer->y1 - disp_area->y1 + corner_size; + + fill_area.x1 = area_outer->x1; + fill_area.x2 = area_outer->x2; + fill_area.y1 = disp_area->y1 + draw_area.y1; + fill_area.y2 = fill_area.y1; + for(h = draw_area.y1; h <= upper_corner_end; h++) { + _lv_memset_ff(mask_buf, draw_area_w); + mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); + + lv_area_t fill_area2; + fill_area2.y1 = fill_area.y1; + fill_area2.y2 = fill_area.y2; + + fill_area2.x1 = area_outer->x1; + fill_area2.x2 = area_outer->x1 + rout - 1; + + _lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode); + + /*Draw the top horizontal line*/ + if(fill_area2.y2 < area_outer->y1 + border_width) { + fill_area2.x1 = area_outer->x1 + rout; + fill_area2.x2 = area_outer->x2 - rout; + + _lv_blend_fill(clip, &fill_area2, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode); + } + + fill_area2.x1 = area_outer->x2 - rout + 1; + fill_area2.x2 = area_outer->x2; + + int32_t mask_ofs = (area_outer->x2 - rout + 1) - (vdb->area.x1 + draw_area.x1); + if(mask_ofs < 0) mask_ofs = 0; + _lv_blend_fill(clip, &fill_area2, color, mask_buf + mask_ofs, mask_res, opa, blend_mode); + + fill_area.y1++; + fill_area.y2++; + } + + /*Draw the lower corner area */ + int32_t lower_corner_end = area_outer->y2 - disp_area->y1 - corner_size; + if(lower_corner_end <= upper_corner_end) lower_corner_end = upper_corner_end + 1; + fill_area.y1 = disp_area->y1 + lower_corner_end; + fill_area.y2 = fill_area.y1; + for(h = lower_corner_end; h <= draw_area.y2; h++) { + _lv_memset_ff(mask_buf, draw_area_w); + mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); + + lv_area_t fill_area2; + fill_area2.x1 = area_outer->x1; + fill_area2.x2 = area_outer->x1 + rout - 1; + fill_area2.y1 = fill_area.y1; + fill_area2.y2 = fill_area.y2; + + _lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode); + + /*Draw the bottom horizontal line*/ + if(fill_area2.y2 > area_outer->y2 - border_width) { + fill_area2.x1 = area_outer->x1 + rout; + fill_area2.x2 = area_outer->x2 - rout; + + _lv_blend_fill(clip, &fill_area2, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode); + } + fill_area2.x1 = area_outer->x2 - rout + 1; + fill_area2.x2 = area_outer->x2; + + int32_t mask_ofs = (area_outer->x2 - rout + 1) - (vdb->area.x1 + draw_area.x1); + if(mask_ofs < 0) mask_ofs = 0; + _lv_blend_fill(clip, &fill_area2, color, mask_buf + mask_ofs, mask_res, opa, blend_mode); + + + fill_area.y1++; + fill_area.y2++; + } + + /*Draw the left vertical part*/ + fill_area.y1 = area_outer->y1 + corner_size + 1; + fill_area.y2 = area_outer->y2 - corner_size - 1; + + fill_area.x1 = area_outer->x1; + fill_area.x2 = area_outer->x1 + border_width - 1; + _lv_blend_fill(clip, &fill_area, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode); + + /*Draw the right vertical border*/ + fill_area.x1 = area_outer->x2 - border_width + 1; + fill_area.x2 = area_outer->x2; + + _lv_blend_fill(clip, &fill_area, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode); + } + /*Process line by line if there is other mask too*/ + else { + fill_area.x1 = area_outer->x1; + fill_area.x2 = area_outer->x2; + fill_area.y1 = disp_area->y1 + draw_area.y1; + fill_area.y2 = fill_area.y1; + + for(h = draw_area.y1; h <= draw_area.y2; h++) { + _lv_memset_ff(mask_buf, draw_area_w); + mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); + + _lv_blend_fill(clip, &fill_area, color, mask_buf, mask_res, opa, blend_mode); + fill_area.y1++; + fill_area.y2++; + + } + } + lv_draw_mask_remove_id(mask_rin_id); + lv_draw_mask_remove_id(mask_rout_id); + _lv_mem_buf_release(mask_buf); +} + From 557342cc088424c48894e4acffccf40801663ddf Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 21 Jul 2020 16:39:04 +0200 Subject: [PATCH 140/205] Do not print for missing glyph if its height OR width is zero Fixes: #1674 --- CHANGELOG.md | 3 +++ src/lv_draw/lv_draw_label.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e607b8987..508c7c8c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ - Add `lv_event_send_refresh`, `lv_event_send_refresh_recursive` to easily send `LV_EVENT_REFRESH` to object - Add `lv_tabview_set_tab_name()` function - used to change a tab's name +### Bugfixes +- Do not print for missing glyph if its height OR width is zero. + ## v7.2.0 (21.07.2020) ### New features diff --git a/src/lv_draw/lv_draw_label.c b/src/lv_draw/lv_draw_label.c index 136b4d0d7..9c5626dfe 100644 --- a/src/lv_draw/lv_draw_label.c +++ b/src/lv_draw/lv_draw_label.c @@ -420,7 +420,7 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_letter(const lv_point_t * pos_p, const } /* Don't draw anything if the character is empty. E.g. space */ - if((g.box_h == 0) && (g.box_w == 0)) return; + if((g.box_h == 0) || (g.box_w == 0)) return; int32_t pos_x = pos_p->x + g.ofs_x; int32_t pos_y = pos_p->y + (font_p->line_height - font_p->base_line) - g.box_h - g.ofs_y; From 806f3a9bbf7442f3466a4350e21ccaabfe8b0b1d Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Tue, 21 Jul 2020 11:16:26 -0400 Subject: [PATCH 141/205] textarea: don't call LV_EVENT_INSERT too far before insertion --- src/lv_widgets/lv_textarea.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lv_widgets/lv_textarea.c b/src/lv_widgets/lv_textarea.c index 9cf859f82..3b7ed4db4 100644 --- a/src/lv_widgets/lv_textarea.c +++ b/src/lv_widgets/lv_textarea.c @@ -244,7 +244,7 @@ void lv_textarea_add_char(lv_obj_t * ta, uint32_t c) #endif ta_insert_replace = NULL; - lv_event_send(ta, LV_EVENT_INSERT, letter_buf); + if(ta_insert_replace) { if(ta_insert_replace[0] == '\0') return; /*Drop this text*/ @@ -267,6 +267,8 @@ void lv_textarea_add_char(lv_obj_t * ta, uint32_t c) "accepted list)"); return; } + + lv_event_send(ta, LV_EVENT_INSERT, letter_buf); /*If a new line was added it shouldn't show edge flash effect*/ bool edge_flash_en = lv_textarea_get_edge_flash(ta); @@ -334,7 +336,6 @@ void lv_textarea_add_text(lv_obj_t * ta, const char * txt) lv_textarea_ext_t * ext = lv_obj_get_ext_attr(ta); ta_insert_replace = NULL; - lv_event_send(ta, LV_EVENT_INSERT, txt); if(ta_insert_replace) { if(ta_insert_replace[0] == '\0') return; /*Drop this text*/ @@ -356,7 +357,8 @@ void lv_textarea_add_text(lv_obj_t * ta, const char * txt) } return; } - + + lv_event_send(ta, LV_EVENT_INSERT, txt); /*If a new line was added it shouldn't show edge flash effect*/ bool edge_flash_en = lv_textarea_get_edge_flash(ta); lv_textarea_set_edge_flash(ta, false); From 3c3fe46447e4d1453872789f2dc1adca41bca443 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 22 Jul 2020 16:18:49 +0200 Subject: [PATCH 142/205] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 508c7c8c9..189466b47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ - Add `lv_tabview_set_tab_name()` function - used to change a tab's name ### Bugfixes -- Do not print for missing glyph if its height OR width is zero. +- Do not print warning for missing glyph if its height OR width is zero. ## v7.2.0 (21.07.2020) From 4df27fc5b27d1e1e74701093fedfa3f8ac88f720 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 22 Jul 2020 16:25:42 +0200 Subject: [PATCH 143/205] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 189466b47..85230b9a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ ## v7.2.0 (21.07.2020) ### New features +- Add screen transitions with `lv_scr_load_anim()` +- Add display background color, wallpaper and opacity. Shown when the screen is transparent. Can be used with `lv_disp_set_bg_opa/color/image()`. - Add `LV_CALENDAR_WEEK_STARTS_MONDAY` - Add `lv_chart_set_x_start_point()` function - Set the index of the x-axis start point in the data array - Add `lv_chart_set_ext_array()` function - Set an external array of data points to use for the chart From fb3e6ec1f49212f35ede09889ff613893e36f663 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 22 Jul 2020 16:28:03 +0200 Subject: [PATCH 144/205] textarea: add insert handler functions --- src/lv_widgets/lv_textarea.c | 59 +++++++++++++++--------------------- 1 file changed, 25 insertions(+), 34 deletions(-) diff --git a/src/lv_widgets/lv_textarea.c b/src/lv_widgets/lv_textarea.c index 3b7ed4db4..f41169661 100644 --- a/src/lv_widgets/lv_textarea.c +++ b/src/lv_widgets/lv_textarea.c @@ -60,6 +60,7 @@ static void pwd_char_hider(lv_obj_t * ta); static bool char_is_accepted(lv_obj_t * ta, uint32_t c); static void refr_cursor_area(lv_obj_t * ta); static void update_cursor_position_on_click(lv_obj_t * ta, lv_signal_t sign, lv_indev_t * click_source); +static lv_res_t insert_handler(lv_obj_t * ta, const char * txt); /********************** * STATIC VARIABLES @@ -243,18 +244,9 @@ void lv_textarea_add_char(lv_obj_t * ta, uint32_t c) if(c != 0) while(*letter_buf == 0) ++letter_buf; #endif - ta_insert_replace = NULL; + lv_res_t res = insert_handler(ta, letter_buf); + if(res != LV_RES_OK) return; - if(ta_insert_replace) { - if(ta_insert_replace[0] == '\0') return; /*Drop this text*/ - - /*Add the replaced text directly it's different from the original*/ - if(strcmp(ta_insert_replace, letter_buf)) { - lv_textarea_add_text(ta, ta_insert_replace); - return; - } - } - if(ext->one_line && (c == '\n' || c == '\r')) { LV_LOG_INFO("Text area: line break ignored in one-line mode"); return; @@ -268,7 +260,6 @@ void lv_textarea_add_char(lv_obj_t * ta, uint32_t c) return; } - lv_event_send(ta, LV_EVENT_INSERT, letter_buf); /*If a new line was added it shouldn't show edge flash effect*/ bool edge_flash_en = lv_textarea_get_edge_flash(ta); @@ -335,17 +326,6 @@ void lv_textarea_add_text(lv_obj_t * ta, const char * txt) lv_textarea_ext_t * ext = lv_obj_get_ext_attr(ta); - ta_insert_replace = NULL; - if(ta_insert_replace) { - if(ta_insert_replace[0] == '\0') return; /*Drop this text*/ - - /*Add the replaced text directly it's different from the original*/ - if(strcmp(ta_insert_replace, txt)) { - lv_textarea_add_text(ta, ta_insert_replace); - return; - } - } - if(ext->pwd_mode != 0) pwd_char_hider(ta); /*Make sure all the current text contains only '*'*/ /*Add the character one-by-one if not all characters are accepted or there is character limit.*/ @@ -358,7 +338,9 @@ void lv_textarea_add_text(lv_obj_t * ta, const char * txt) return; } - lv_event_send(ta, LV_EVENT_INSERT, txt); + lv_res_t res = insert_handler(ta, txt); + if(res != LV_RES_OK) return; + /*If a new line was added it shouldn't show edge flash effect*/ bool edge_flash_en = lv_textarea_get_edge_flash(ta); lv_textarea_set_edge_flash(ta, false); @@ -421,18 +403,10 @@ void lv_textarea_del_char(lv_obj_t * ta) if(cur_pos == 0) return; - ta_insert_replace = NULL; char del_buf[2] = {LV_KEY_DEL, '\0'}; - lv_event_send(ta, LV_EVENT_INSERT, del_buf); - if(ta_insert_replace) { - if(ta_insert_replace[0] == '\0') return; /*Drop this text*/ - /*Add the replaced text directly it's different from the original*/ - if(strcmp(ta_insert_replace, del_buf)) { - lv_textarea_add_text(ta, ta_insert_replace); - return; - } - } + lv_res_t res = insert_handler(ta, del_buf); + if(res != LV_RES_OK) return; char * label_txt = lv_label_get_text(ext->label); @@ -1917,4 +1891,21 @@ static void update_cursor_position_on_click(lv_obj_t * ta, lv_signal_t sign, lv_ #endif } +static lv_res_t insert_handler(lv_obj_t * ta, const char * txt) +{ + ta_insert_replace = NULL; + lv_event_send(ta, LV_EVENT_INSERT, txt); + if(ta_insert_replace) { + if(ta_insert_replace[0] == '\0') return LV_RES_INV; /*Drop this text*/ + + /*Add the replaced text directly it's different from the original*/ + if(strcmp(ta_insert_replace, txt)) { + lv_textarea_add_text(ta, ta_insert_replace); + return LV_RES_INV; + } + } + + return LV_RES_OK; +} + #endif From 00e93a5d30c92f711c684781c6eba68923d19cdf Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 22 Jul 2020 18:23:56 +0200 Subject: [PATCH 145/205] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85230b9a2..f4e05e163 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ ### Bugfixes - Do not print warning for missing glyph if its height OR width is zero. +- Prevent duplicated sending of `LV_EVENT_INSERT` from text area ## v7.2.0 (21.07.2020) From 28495b9eb942c973e6f93b2b3799ab16de7664e9 Mon Sep 17 00:00:00 2001 From: pete-pjb Date: Thu, 23 Jul 2020 14:15:34 +0100 Subject: [PATCH 146/205] Tidy up the edges of the colour picker widget. --- src/lv_widgets/lv_cpicker.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/lv_widgets/lv_cpicker.c b/src/lv_widgets/lv_cpicker.c index d80c9a56c..9ddc3b199 100644 --- a/src/lv_widgets/lv_cpicker.c +++ b/src/lv_widgets/lv_cpicker.c @@ -491,11 +491,14 @@ static void draw_disc_grad(lv_obj_t * cpicker, const lv_area_t * mask) line_dsc.color = angle_to_mode_color(cpicker, i); lv_point_t p[2]; - p[0].x = cx + (r * _lv_trigo_sin(i) >> LV_TRIGO_SHIFT); - p[0].y = cy + (r * _lv_trigo_sin(i + 90) >> LV_TRIGO_SHIFT); - p[1].x = cx + ((r - cir_w_extra) * _lv_trigo_sin(i) >> LV_TRIGO_SHIFT); - p[1].y = cy + ((r - cir_w_extra) * _lv_trigo_sin(i + 90) >> LV_TRIGO_SHIFT); + p[0].x = cx + ((r-2) * _lv_trigo_sin(i) >> LV_TRIGO_SHIFT); + p[0].y = cy + ((r-2) * _lv_trigo_sin(i + 90) >> LV_TRIGO_SHIFT); + p[1].x = cx + ((r-2 - cir_w_extra) * _lv_trigo_sin(i) >> LV_TRIGO_SHIFT); + p[1].y = cy + ((r-2 - cir_w_extra) * _lv_trigo_sin(i + 90) >> LV_TRIGO_SHIFT); + /* We use the r-2 value here to keep the lines inside the bounds of the circle as the integer based arithmetic + * is not a 100% using the trigonometric functions + */ lv_draw_line(&p[0], &p[1], mask, &line_dsc); } @@ -524,6 +527,13 @@ static void draw_disc_grad(lv_obj_t * cpicker, const lv_area_t * mask) area_mid.y2 -= inner; lv_draw_rect(&area_mid, mask, &bg_dsc); + + /*Tidy outside of colour picker, the way the outer ring has to be drawn it cannot mask well so this draws a clean edge around it */ + lv_draw_line_dsc_t tidy_dsc; + lv_draw_line_dsc_init(&tidy_dsc); + tidy_dsc.width = 3; + tidy_dsc.color = lv_obj_get_style_bg_color(cpicker, LV_CPICKER_PART_MAIN); + lv_draw_arc(cx, cy, r, 0, 360, mask, &tidy_dsc); } static void draw_rect_grad(lv_obj_t * cpicker, const lv_area_t * mask) From d125472e81fec67096dc7d017f215bb25cb57932 Mon Sep 17 00:00:00 2001 From: pete-pjb Date: Thu, 23 Jul 2020 14:24:28 +0100 Subject: [PATCH 147/205] Update change log. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4e05e163..7b9c0cebc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ ### Bugfixes - Do not print warning for missing glyph if its height OR width is zero. - Prevent duplicated sending of `LV_EVENT_INSERT` from text area +- Tidy outer edges of cpicker widget. ## v7.2.0 (21.07.2020) From 89adfbc816eebfbb582e1b73236a835e3b5778e4 Mon Sep 17 00:00:00 2001 From: pete-pjb Date: Fri, 24 Jul 2020 10:15:29 +0100 Subject: [PATCH 148/205] Fix ragged edge of Colour Picker. --- src/lv_widgets/lv_cpicker.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/lv_widgets/lv_cpicker.c b/src/lv_widgets/lv_cpicker.c index 9ddc3b199..128f4e480 100644 --- a/src/lv_widgets/lv_cpicker.c +++ b/src/lv_widgets/lv_cpicker.c @@ -483,6 +483,17 @@ static void draw_disc_grad(lv_obj_t * cpicker, const lv_area_t * mask) uint16_t i; lv_coord_t cir_w = lv_obj_get_style_scale_width(cpicker, LV_CPICKER_PART_MAIN); + /* Mask outer ring of widget to tidy up ragged edges of lines while drawing outer ring */ + lv_area_t mask_area_out; + lv_area_copy( &mask_area_out, &cpicker->coords); + mask_area_out.x1 += 3; + mask_area_out.x2 -= 3; + mask_area_out.y1 += 3; + mask_area_out.y2 -= 3; + lv_draw_mask_radius_param_t mask_out_param; + lv_draw_mask_radius_init(&mask_out_param, &mask_area_out, LV_RADIUS_CIRCLE, false); + int16_t mask_out_id = lv_draw_mask_add(&mask_out_param, 0); + /* The inner line ends will be masked out. * So make lines a little bit longer because the masking makes a more even result */ lv_coord_t cir_w_extra = cir_w + line_dsc.width; @@ -491,17 +502,15 @@ static void draw_disc_grad(lv_obj_t * cpicker, const lv_area_t * mask) line_dsc.color = angle_to_mode_color(cpicker, i); lv_point_t p[2]; - p[0].x = cx + ((r-2) * _lv_trigo_sin(i) >> LV_TRIGO_SHIFT); - p[0].y = cy + ((r-2) * _lv_trigo_sin(i + 90) >> LV_TRIGO_SHIFT); - p[1].x = cx + ((r-2 - cir_w_extra) * _lv_trigo_sin(i) >> LV_TRIGO_SHIFT); - p[1].y = cy + ((r-2 - cir_w_extra) * _lv_trigo_sin(i + 90) >> LV_TRIGO_SHIFT); + p[0].x = cx + (r * _lv_trigo_sin(i) >> LV_TRIGO_SHIFT); + p[0].y = cy + (r * _lv_trigo_sin(i + 90) >> LV_TRIGO_SHIFT); + p[1].x = cx + ((r - cir_w_extra) * _lv_trigo_sin(i) >> LV_TRIGO_SHIFT); + p[1].y = cy + ((r - cir_w_extra) * _lv_trigo_sin(i + 90) >> LV_TRIGO_SHIFT); - /* We use the r-2 value here to keep the lines inside the bounds of the circle as the integer based arithmetic - * is not a 100% using the trigonometric functions - */ lv_draw_line(&p[0], &p[1], mask, &line_dsc); } - + /* Now remove mask to continue with inner part */ + lv_draw_mask_remove_id(mask_out_id); /*Mask out the inner area*/ lv_draw_rect_dsc_t bg_dsc; @@ -527,13 +536,6 @@ static void draw_disc_grad(lv_obj_t * cpicker, const lv_area_t * mask) area_mid.y2 -= inner; lv_draw_rect(&area_mid, mask, &bg_dsc); - - /*Tidy outside of colour picker, the way the outer ring has to be drawn it cannot mask well so this draws a clean edge around it */ - lv_draw_line_dsc_t tidy_dsc; - lv_draw_line_dsc_init(&tidy_dsc); - tidy_dsc.width = 3; - tidy_dsc.color = lv_obj_get_style_bg_color(cpicker, LV_CPICKER_PART_MAIN); - lv_draw_arc(cx, cy, r, 0, 360, mask, &tidy_dsc); } static void draw_rect_grad(lv_obj_t * cpicker, const lv_area_t * mask) From da5c9dd424c7059ab9486e4d0c0be396c414fee1 Mon Sep 17 00:00:00 2001 From: pete-pjb Date: Fri, 24 Jul 2020 13:50:35 +0100 Subject: [PATCH 149/205] Add define and comment to explain magic number used in previous fix. --- src/lv_widgets/lv_cpicker.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/lv_widgets/lv_cpicker.c b/src/lv_widgets/lv_cpicker.c index 128f4e480..db682092a 100644 --- a/src/lv_widgets/lv_cpicker.c +++ b/src/lv_widgets/lv_cpicker.c @@ -48,6 +48,13 @@ #define TRI_OFFSET 2 +/* The OUTER_MASK_WIDTH define is required to assist with the placing of a mask over the outer ring of the widget as when the + * multicoloured radial lines are calculated for the outer ring of the widget their lengths are jittering because of the + * integer based arithmetic. From tests the maximum delta was found to be 2 so the current value is set to 3 to achieve + * appropriate masking. + */ +#define OUTER_MASK_WIDTH 3 + /********************** * TYPEDEFS **********************/ @@ -486,10 +493,10 @@ static void draw_disc_grad(lv_obj_t * cpicker, const lv_area_t * mask) /* Mask outer ring of widget to tidy up ragged edges of lines while drawing outer ring */ lv_area_t mask_area_out; lv_area_copy( &mask_area_out, &cpicker->coords); - mask_area_out.x1 += 3; - mask_area_out.x2 -= 3; - mask_area_out.y1 += 3; - mask_area_out.y2 -= 3; + mask_area_out.x1 += OUTER_MASK_WIDTH; + mask_area_out.x2 -= OUTER_MASK_WIDTH; + mask_area_out.y1 += OUTER_MASK_WIDTH; + mask_area_out.y2 -= OUTER_MASK_WIDTH; lv_draw_mask_radius_param_t mask_out_param; lv_draw_mask_radius_init(&mask_out_param, &mask_area_out, LV_RADIUS_CIRCLE, false); int16_t mask_out_id = lv_draw_mask_add(&mask_out_param, 0); From f30dc5d186e63adbe758dca5e245f3e3e106f010 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 24 Jul 2020 16:16:18 +0200 Subject: [PATCH 150/205] remove duplicated lines from lv_tabview_add_tab --- CHANGELOG.md | 1 + src/lv_widgets/lv_tabview.c | 14 -------------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4e05e163..e135b72ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ ### Bugfixes - Do not print warning for missing glyph if its height OR width is zero. - Prevent duplicated sending of `LV_EVENT_INSERT` from text area +- Remove duplicated lines from `lv_tabview_add_tab` ## v7.2.0 (21.07.2020) diff --git a/src/lv_widgets/lv_tabview.c b/src/lv_widgets/lv_tabview.c index f68d69a36..475a3f427 100644 --- a/src/lv_widgets/lv_tabview.c +++ b/src/lv_widgets/lv_tabview.c @@ -230,20 +230,6 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name) ext->tab_cnt++; - switch(ext->btns_pos) { - case LV_TABVIEW_TAB_POS_TOP: - case LV_TABVIEW_TAB_POS_BOTTOM: - ext->tab_name_ptr = lv_mem_realloc((void *)ext->tab_name_ptr, sizeof(char *) * (ext->tab_cnt + 1)); - break; - case LV_TABVIEW_TAB_POS_LEFT: - case LV_TABVIEW_TAB_POS_RIGHT: - ext->tab_name_ptr = lv_mem_realloc((void *)ext->tab_name_ptr, sizeof(char *) * (ext->tab_cnt * 2)); - break; - } - - LV_ASSERT_MEM(ext->tab_name_ptr); - if(ext->tab_name_ptr == NULL) return NULL; - /* FIXME: It is not possible yet to switch tab button position from/to top/bottom from/to left/right at runtime. * Method: clean extra \n when switch from LV_TABVIEW_BTNS_POS_LEFT or LV_TABVIEW_BTNS_POS_RIGHT * to LV_TABVIEW_BTNS_POS_TOP or LV_TABVIEW_BTNS_POS_BOTTOM. From 28a668ce09ea71aacbbdc1df8302fbf15cd859e0 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 24 Jul 2020 21:49:44 +0200 Subject: [PATCH 151/205] Create ROADMAP.md --- docs/ROADMAP.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 docs/ROADMAP.md diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md new file mode 100644 index 000000000..6863ca221 --- /dev/null +++ b/docs/ROADMAP.md @@ -0,0 +1,26 @@ +# Roadmap + +This is a summary for thenew fatures of the major releases and a collection of ideas. + +This list indicates only the current intention and can be changed. + +## v8 +Planned to September/October 2020 +- New scrolling: + - See [feat/new-scroll]((https://github.com/lvgl/lvgl/tree/feat/new-scroll) branch and [#1614](https://github.com/lvgl/lvgl/issues/1614)) issue. + - Remove `lv_page` and support scrolling on `lv_obj` + - Support "elastic" scrolling when scrolled in + - Support scroll chaining among any objects types (not only `lv_pages`s) + - Remove `lv_drag`. Similar effect can be achieved by setting the position in `LV_EVENT_PRESSING` + - Add snapping? + - Already working +- New layouts: + - See [#1615](https://github.com/lvgl/lvgl/issues/1615) issue + - [CSS Flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/)-like layout support + - Besides setting width/height in `px` add support to `partent percentage` and `screen percentage`. + - Work in progress +- Simplified File system interface ([feat/new_fs_api](https://github.com/lvgl/lvgl/tree/feat/new-fs-api) branch) to make porting easier + - Work in progress + +## Ideas +- ... From 834b498aec372ba51baadc8260c990e83f6fc6a1 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 24 Jul 2020 21:51:08 +0200 Subject: [PATCH 152/205] Update ROADMAP.md --- docs/ROADMAP.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 6863ca221..66aae962d 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -21,6 +21,8 @@ Planned to September/October 2020 - Work in progress - Simplified File system interface ([feat/new_fs_api](https://github.com/lvgl/lvgl/tree/feat/new-fs-api) branch) to make porting easier - Work in progress +- Add new label alignment modes + - See [#1656](https://github.com/lvgl/lvgl/issues/1656) ## Ideas - ... From ed10c1da672d2865ec37fb6229f9bc646086d983 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 26 Jul 2020 21:13:39 +0200 Subject: [PATCH 153/205] Add LV_THEME_MATERIAL_FLAG_NO_TRANSITION and LV_THEME_MATERIAL_FLAG_NO_FOCUS flags --- CHANGELOG.md | 1 + lv_conf_template.h | 5 ++++- src/lv_themes/lv_theme_material.c | 13 +++++++------ src/lv_themes/lv_theme_material.h | 1 + 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 887fe35df..093c4f312 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Add `lv_task_get_next` - Add `lv_event_send_refresh`, `lv_event_send_refresh_recursive` to easily send `LV_EVENT_REFRESH` to object - Add `lv_tabview_set_tab_name()` function - used to change a tab's name +- Add `LV_THEME_MATERIAL_FLAG_NO_TRANSITION` and `LV_THEME_MATERIAL_FLAG_NO_FOCUS` flags ### Bugfixes - Do not print warning for missing glyph if its height OR width is zero. diff --git a/lv_conf_template.h b/lv_conf_template.h index c720a097b..6fb26a349 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -417,7 +417,10 @@ typedef void * lv_font_user_data_t; /* A fast and impressive theme. * Flags: * LV_THEME_MATERIAL_FLAG_LIGHT: light theme - * LV_THEME_MATERIAL_FLAG_DARK: dark theme*/ + * LV_THEME_MATERIAL_FLAG_DARK: dark theme + * LV_THEME_MATERIAL_FLAG_NO_TRANSITION: disable transitions (state change animations) + * LV_THEME_MATERIAL_FLAG_NO_FOCUS: disable indication of focused state) + * */ #define LV_USE_THEME_MATERIAL 1 /* Mono-color theme for monochrome displays. diff --git a/src/lv_themes/lv_theme_material.c b/src/lv_themes/lv_theme_material.c index 1aa9fe580..19ee14a78 100644 --- a/src/lv_themes/lv_theme_material.c +++ b/src/lv_themes/lv_theme_material.c @@ -64,8 +64,9 @@ #define COLOR_BG_SEC_TEXT (IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex(0xa5a8ad)) #define COLOR_BG_SEC_TEXT_DIS (IS_LIGHT ? lv_color_hex(0xaaaaaa) : lv_color_hex(0xa5a8ad)) -#define TRANSITION_TIME 150 +#define TRANSITION_TIME (theme.flags | LV_THEME_MATERIAL_FLAG_NO_TRANSITION ? 0 : 150) #define BORDER_WIDTH LV_DPX(2) +#define OUTLINE_WIDTH (theme.flags | LV_THEME_MATERIAL_FLAG_NO_FOCUS ? 0 : LV_DPX(2)) #define IS_LIGHT (theme.flags & LV_THEME_MATERIAL_FLAG_LIGHT) #define PAD_DEF (lv_disp_get_size_category(NULL) <= LV_DISP_SIZE_MEDIUM ? LV_DPX(15) : (LV_DPX(30))) @@ -210,7 +211,7 @@ static void basic_init(void) lv_style_set_bg_opa(&styles->bg, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_bg_color(&styles->bg, LV_STATE_DEFAULT, COLOR_BG); lv_style_set_border_color(&styles->bg, LV_STATE_DEFAULT, COLOR_BG_BORDER); - lv_style_set_border_color(&styles->bg, LV_STATE_FOCUSED, theme.color_primary); + if((theme.flags | LV_THEME_MATERIAL_FLAG_NO_FOCUS) == 0)lv_style_set_border_color(&styles->bg, LV_STATE_FOCUSED, theme.color_primary); lv_style_set_border_color(&styles->bg, LV_STATE_EDITED, theme.color_secondary); lv_style_set_border_width(&styles->bg, LV_STATE_DEFAULT, BORDER_WIDTH); lv_style_set_border_post(&styles->bg, LV_STATE_DEFAULT, true); @@ -298,7 +299,7 @@ static void basic_init(void) lv_style_set_pad_top(&styles->btn, LV_STATE_DEFAULT, LV_DPX(15)); lv_style_set_pad_bottom(&styles->btn, LV_STATE_DEFAULT, LV_DPX(15)); lv_style_set_pad_inner(&styles->btn, LV_STATE_DEFAULT, LV_DPX(20)); - lv_style_set_outline_width(&styles->btn, LV_STATE_DEFAULT, 3); + lv_style_set_outline_width(&styles->btn, LV_STATE_DEFAULT, OUTLINE_WIDTH); lv_style_set_outline_opa(&styles->btn, LV_STATE_DEFAULT, LV_OPA_0); lv_style_set_outline_opa(&styles->btn, LV_STATE_FOCUSED, LV_OPA_50); lv_style_set_outline_color(&styles->btn, LV_STATE_DEFAULT, theme.color_primary); @@ -357,7 +358,7 @@ static void bar_init(void) lv_style_set_outline_color(&styles->bar_bg, LV_STATE_EDITED, theme.color_secondary); lv_style_set_outline_opa(&styles->bar_bg, LV_STATE_DEFAULT, LV_OPA_TRANSP); lv_style_set_outline_opa(&styles->bar_bg, LV_STATE_FOCUSED, LV_OPA_50); - lv_style_set_outline_width(&styles->bar_bg, LV_STATE_DEFAULT, 3); + lv_style_set_outline_width(&styles->bar_bg, LV_STATE_DEFAULT, OUTLINE_WIDTH); lv_style_set_transition_time(&styles->bar_bg, LV_STATE_DEFAULT, TRANSITION_TIME); lv_style_set_transition_prop_6(&styles->bar_bg, LV_STATE_DEFAULT, LV_STYLE_OUTLINE_OPA); @@ -608,7 +609,7 @@ static void checkbox_init(void) lv_style_set_outline_color(&styles->cb_bg, LV_STATE_DEFAULT, theme.color_primary); lv_style_set_outline_opa(&styles->cb_bg, LV_STATE_DEFAULT, LV_OPA_TRANSP); lv_style_set_outline_opa(&styles->cb_bg, LV_STATE_FOCUSED, LV_OPA_50); - lv_style_set_outline_width(&styles->cb_bg, LV_STATE_DEFAULT, LV_DPX(3)); + lv_style_set_outline_width(&styles->cb_bg, LV_STATE_DEFAULT, OUTLINE_WIDTH); lv_style_set_outline_pad(&styles->cb_bg, LV_STATE_DEFAULT, LV_DPX(10)); lv_style_set_transition_time(&styles->cb_bg, LV_STATE_DEFAULT, TRANSITION_TIME); lv_style_set_transition_prop_6(&styles->cb_bg, LV_STATE_DEFAULT, LV_STYLE_OUTLINE_OPA); @@ -738,7 +739,7 @@ static void list_init(void) lv_style_set_border_width(&styles->list_btn, LV_STATE_DEFAULT, 1); lv_style_set_outline_color(&styles->list_btn, LV_STATE_FOCUSED, theme.color_secondary); - lv_style_set_outline_width(&styles->list_btn, LV_STATE_FOCUSED, BORDER_WIDTH); + lv_style_set_outline_width(&styles->list_btn, LV_STATE_FOCUSED, OUTLINE_WIDTH); lv_style_set_outline_pad(&styles->list_btn, LV_STATE_FOCUSED, -BORDER_WIDTH); lv_style_set_pad_left(&styles->list_btn, LV_STATE_DEFAULT, PAD_DEF); diff --git a/src/lv_themes/lv_theme_material.h b/src/lv_themes/lv_theme_material.h index ed0ab6162..5ee7283cc 100644 --- a/src/lv_themes/lv_theme_material.h +++ b/src/lv_themes/lv_theme_material.h @@ -24,6 +24,7 @@ typedef enum { LV_THEME_MATERIAL_FLAG_DARK = 0x01, LV_THEME_MATERIAL_FLAG_LIGHT = 0x02, LV_THEME_MATERIAL_FLAG_NO_TRANSITION = 0x10, + LV_THEME_MATERIAL_FLAG_NO_FOCUS = 0x20, } lv_theme_material_flag_t; /********************** From c173f28a3f0b2347650023491f630e7042991b9e Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 27 Jul 2020 12:47:07 +0200 Subject: [PATCH 154/205] add underline properties to the fonts --- src/lv_draw/lv_draw_label.c | 6 +++--- src/lv_font/lv_font.h | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lv_draw/lv_draw_label.c b/src/lv_draw/lv_draw_label.c index 136b4d0d7..577890980 100644 --- a/src/lv_draw/lv_draw_label.c +++ b/src/lv_draw/lv_draw_label.c @@ -213,12 +213,12 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area sel_start = sel_end; sel_end = tmp; } - lv_draw_line_dsc_t line_dsc; + dsc->decor = LV_TEXT_DECOR_UNDERLINE; if((dsc->decor & LV_TEXT_DECOR_UNDERLINE) || (dsc->decor & LV_TEXT_DECOR_STRIKETHROUGH)) { lv_draw_line_dsc_init(&line_dsc); line_dsc.color = dsc->color; - line_dsc.width = (dsc->font->line_height + 5) / 10; /*+5 for rounding*/ + line_dsc.width = font->underline_thickness; line_dsc.opa = dsc->opa; line_dsc.blend_mode = dsc->blend_mode; } @@ -342,7 +342,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area lv_point_t p1; lv_point_t p2; p1.x = pos_x_start; - p1.y = pos.y + dsc->font->line_height - dsc->font->base_line + line_dsc.width / 2 + 1; + p1.y = pos.y + dsc->font->line_height - dsc->font->base_line - font->underline_position; p2.x = pos.x; p2.y = p1.y; lv_draw_line(&p1, &p2, mask, &line_dsc); diff --git a/src/lv_font/lv_font.h b/src/lv_font/lv_font.h index 041211acd..b3ecb881c 100644 --- a/src/lv_font/lv_font.h +++ b/src/lv_font/lv_font.h @@ -71,6 +71,10 @@ typedef struct _lv_font_struct { lv_coord_t line_height; /**< The real line height where any text fits*/ lv_coord_t base_line; /**< Base line measured from the top of the line_height*/ uint8_t subpx : 2; /**< An element of `lv_font_subpx_t`*/ + + int8_t underline_position; /**< Distance between the top of the underline and base line (< 0 means below the base line)*/ + int8_t underline_thickness; /**< Thickness of the underline*/ + void * dsc; /**< Store implementation specific or run_time data or caching here*/ #if LV_USE_USER_DATA lv_font_user_data_t user_data; /**< Custom user data for font. */ From 2172ec93a2ccec08c776bcff1cbeefe22fbe5a4b Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 27 Jul 2020 14:16:06 +0200 Subject: [PATCH 155/205] material theme minor fix Fixes #1689 --- src/lv_themes/lv_theme_material.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lv_themes/lv_theme_material.c b/src/lv_themes/lv_theme_material.c index 19ee14a78..893798917 100644 --- a/src/lv_themes/lv_theme_material.c +++ b/src/lv_themes/lv_theme_material.c @@ -64,9 +64,9 @@ #define COLOR_BG_SEC_TEXT (IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex(0xa5a8ad)) #define COLOR_BG_SEC_TEXT_DIS (IS_LIGHT ? lv_color_hex(0xaaaaaa) : lv_color_hex(0xa5a8ad)) -#define TRANSITION_TIME (theme.flags | LV_THEME_MATERIAL_FLAG_NO_TRANSITION ? 0 : 150) +#define TRANSITION_TIME ((theme.flags & LV_THEME_MATERIAL_FLAG_NO_TRANSITION) ? 0 : 150) #define BORDER_WIDTH LV_DPX(2) -#define OUTLINE_WIDTH (theme.flags | LV_THEME_MATERIAL_FLAG_NO_FOCUS ? 0 : LV_DPX(2)) +#define OUTLINE_WIDTH ((theme.flags & LV_THEME_MATERIAL_FLAG_NO_FOCUS) ? 0 : LV_DPX(2)) #define IS_LIGHT (theme.flags & LV_THEME_MATERIAL_FLAG_LIGHT) #define PAD_DEF (lv_disp_get_size_category(NULL) <= LV_DISP_SIZE_MEDIUM ? LV_DPX(15) : (LV_DPX(30))) @@ -211,7 +211,7 @@ static void basic_init(void) lv_style_set_bg_opa(&styles->bg, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_bg_color(&styles->bg, LV_STATE_DEFAULT, COLOR_BG); lv_style_set_border_color(&styles->bg, LV_STATE_DEFAULT, COLOR_BG_BORDER); - if((theme.flags | LV_THEME_MATERIAL_FLAG_NO_FOCUS) == 0)lv_style_set_border_color(&styles->bg, LV_STATE_FOCUSED, theme.color_primary); + if((theme.flags & LV_THEME_MATERIAL_FLAG_NO_FOCUS) == 0)lv_style_set_border_color(&styles->bg, LV_STATE_FOCUSED, theme.color_primary); lv_style_set_border_color(&styles->bg, LV_STATE_EDITED, theme.color_secondary); lv_style_set_border_width(&styles->bg, LV_STATE_DEFAULT, BORDER_WIDTH); lv_style_set_border_post(&styles->bg, LV_STATE_DEFAULT, true); From 8cc951202ca6ea8761be9e07e6256f81d8ee17a9 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 27 Jul 2020 14:17:58 +0200 Subject: [PATCH 156/205] Rename FUNDING.yml to _FUNDING.yml --- .github/{FUNDING.yml => _FUNDING.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{FUNDING.yml => _FUNDING.yml} (100%) diff --git a/.github/FUNDING.yml b/.github/_FUNDING.yml similarity index 100% rename from .github/FUNDING.yml rename to .github/_FUNDING.yml From fd411e200fb5e21846b0fa0b599a8331d60a8f86 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 27 Jul 2020 14:29:41 +0200 Subject: [PATCH 157/205] Update and rename _FUNDING.yml to FUNDING.yml --- .github/FUNDING.yml | 1 + .github/_FUNDING.yml | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 .github/FUNDING.yml delete mode 100644 .github/_FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 000000000..1491dff47 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +custom: [https://www.paypal.com/paypalme/my/profile"] diff --git a/.github/_FUNDING.yml b/.github/_FUNDING.yml deleted file mode 100644 index 9c6d3af73..000000000 --- a/.github/_FUNDING.yml +++ /dev/null @@ -1 +0,0 @@ -custom: ["https://littlevgl.com/donate"] From ca9dfb706375f0a4360808e439c4349bdede484f Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 27 Jul 2020 14:30:22 +0200 Subject: [PATCH 158/205] Update FUNDING.yml --- .github/FUNDING.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 1491dff47..1b34d7088 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1 +1 @@ -custom: [https://www.paypal.com/paypalme/my/profile"] +custom: ["https://www.paypal.com/paypalme/my/profile"] From 06d7a6d006d222bef17749c9998b7cd114ee8da4 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 27 Jul 2020 15:57:22 +0200 Subject: [PATCH 159/205] btnmatrix: hadle combined states of buttons (e.g. chacked + disabled) --- CHANGELOG.md | 2 ++ src/lv_widgets/lv_btnmatrix.c | 37 ++++++++++++++++------------------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 093c4f312..50b1d0821 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ - Prevent duplicated sending of `LV_EVENT_INSERT` from text area - Tidy outer edges of cpicker widget. - Remove duplicated lines from `lv_tabview_add_tab` +- "btnmatrix: hadle combined states of buttons (e.g. chacked + disabled)" + ## v7.2.0 (21.07.2020) diff --git a/src/lv_widgets/lv_btnmatrix.c b/src/lv_widgets/lv_btnmatrix.c index 5501fcfa6..1f2cd6675 100644 --- a/src/lv_widgets/lv_btnmatrix.c +++ b/src/lv_widgets/lv_btnmatrix.c @@ -658,7 +658,6 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl lv_draw_rect_dsc_t draw_rect_tmp_dsc; lv_draw_label_dsc_t draw_label_tmp_dsc; - /*The state changes without re-caching the styles, disable the use of cache*/ lv_state_t state_ori = btnm->state; btnm->state = LV_STATE_DEFAULT; lv_draw_rect_dsc_init(&draw_rect_rel_dsc); @@ -695,9 +694,19 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl /*Choose the style*/ lv_draw_rect_dsc_t * draw_rect_dsc_act; lv_draw_label_dsc_t * draw_label_dsc_act; - bool tgl_state = button_get_tgl_state(ext->ctrl_bits[btn_i]); + lv_state_t btn_state = LV_STATE_DEFAULT; + if(button_get_tgl_state(ext->ctrl_bits[btn_i])) btn_state |= LV_STATE_CHECKED; + if(button_is_inactive(ext->ctrl_bits[btn_i])) btn_state |= LV_STATE_DISABLED; + if(btn_i == ext->btn_id_pr) btn_state |= LV_STATE_PRESSED; + if(btn_i == ext->btn_id_focused) { + btn_state |= LV_STATE_FOCUSED; + if(state_ori & LV_STATE_EDITED) btn_state |= LV_STATE_EDITED; + } - if(tgl_state) { + if(btn_state == LV_STATE_DEFAULT) { + draw_rect_dsc_act = &draw_rect_rel_dsc; + draw_label_dsc_act = &draw_label_rel_dsc; + } else if(btn_state == LV_STATE_CHECKED) { if(!chk_inited) { btnm->state = LV_STATE_CHECKED; lv_draw_rect_dsc_init(&draw_rect_chk_dsc); @@ -708,9 +717,9 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl btnm->state = state_ori; chk_inited = true; } - } - - if(button_is_inactive(ext->ctrl_bits[btn_i])) { + draw_rect_dsc_act = &draw_rect_chk_dsc; + draw_label_dsc_act = &draw_label_chk_dsc; + } else if(btn_state == LV_STATE_CHECKED) { if(!disabled_inited) { btnm->state = LV_STATE_DISABLED; lv_draw_rect_dsc_init(&draw_rect_ina_dsc); @@ -724,21 +733,9 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl draw_rect_dsc_act = &draw_rect_ina_dsc; draw_label_dsc_act = &draw_label_ina_dsc; } - /*Simple released or checked buttons button*/ - else if(btn_i != ext->btn_id_pr && btn_i != ext->btn_id_focused) { - draw_rect_dsc_act = tgl_state ? &draw_rect_chk_dsc : &draw_rect_rel_dsc; - draw_label_dsc_act = tgl_state ? &draw_label_chk_dsc : &draw_label_rel_dsc; - } - /*Focused and/or pressed + checked or released button*/ + /*In other cases get the styles directly without caching them*/ else { - btnm->state = LV_STATE_DEFAULT; - if(tgl_state) btnm->state = LV_STATE_CHECKED; - if(ext->btn_id_pr == btn_i) btnm->state |= LV_STATE_PRESSED; - if(ext->btn_id_focused == btn_i) { - btnm->state |= LV_STATE_FOCUSED; - if(state_ori & LV_STATE_EDITED) btnm->state |= LV_STATE_EDITED; - } - + btnm->state = btn_state; lv_draw_rect_dsc_init(&draw_rect_tmp_dsc); lv_draw_label_dsc_init(&draw_label_tmp_dsc); lv_obj_init_draw_rect_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_rect_tmp_dsc); From fd695c9ad3f37ca7654d2e9385a61ac6a954ad1d Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 27 Jul 2020 17:46:06 +0200 Subject: [PATCH 160/205] textarea: fix typo in lv_textarea_set_sscrollbar_mode Fixes #1691 --- CHANGELOG.md | 3 ++- src/lv_widgets/lv_textarea.c | 2 +- src/lv_widgets/lv_textarea.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50b1d0821..a8e2f10e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,8 @@ - Prevent duplicated sending of `LV_EVENT_INSERT` from text area - Tidy outer edges of cpicker widget. - Remove duplicated lines from `lv_tabview_add_tab` -- "btnmatrix: hadle combined states of buttons (e.g. chacked + disabled)" +- btnmatrix: hadle combined states of buttons (e.g. chacked + disabled) +- textarea: fix typo in lv_textarea_set_sscrollbar_mode ## v7.2.0 (21.07.2020) diff --git a/src/lv_widgets/lv_textarea.c b/src/lv_widgets/lv_textarea.c index f41169661..c82870bf1 100644 --- a/src/lv_widgets/lv_textarea.c +++ b/src/lv_widgets/lv_textarea.c @@ -149,7 +149,7 @@ lv_obj_t * lv_textarea_create(lv_obj_t * par, const lv_obj_t * copy) lv_label_set_text(ext->label, "Text area"); lv_obj_set_click(ext->label, false); lv_obj_set_size(ta, LV_TEXTAREA_DEF_WIDTH, LV_TEXTAREA_DEF_HEIGHT); - lv_textarea_set_sscrollbar_mode(ta, LV_SCROLLBAR_MODE_DRAG); + lv_textarea_set_scrollbar_mode(ta, LV_SCROLLBAR_MODE_DRAG); lv_obj_reset_style_list(ta, LV_PAGE_PART_SCROLLABLE); lv_theme_apply(ta, LV_THEME_TEXTAREA); diff --git a/src/lv_widgets/lv_textarea.h b/src/lv_widgets/lv_textarea.h index 49cfc9b7d..dbca0db45 100644 --- a/src/lv_widgets/lv_textarea.h +++ b/src/lv_widgets/lv_textarea.h @@ -224,7 +224,7 @@ void lv_textarea_set_insert_replace(lv_obj_t * ta, const char * txt); * @param ta pointer to a text area object * @param sb_mode the new mode from 'lv_scrollbar_mode_t' enum */ -static inline void lv_textarea_set_sscrollbar_mode(lv_obj_t * ta, lv_scrollbar_mode_t mode) +static inline void lv_textarea_set_scrollbar_mode(lv_obj_t * ta, lv_scrollbar_mode_t mode) { lv_page_set_scrollbar_mode(ta, mode); } From 80a4c6ff14ebdd2f37da6cdd8c69ad213f35b885 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 27 Jul 2020 17:58:10 +0200 Subject: [PATCH 161/205] update CHANGELOG --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d37b4213..7b50a0335 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,6 @@ ## v7.4.0 (planned on 18.08.2020) *Available in the `dev` branch* -- Reduce code size by adding: `LV_USE_FONT_COMPRESSED` and `LV_FONT_USE_SUBPX` and applying some optimization - ## v7.3.0 (planned on 04.08.2020) *Available in the `master` branch* @@ -13,6 +11,8 @@ - Add `lv_event_send_refresh`, `lv_event_send_refresh_recursive` to easily send `LV_EVENT_REFRESH` to object - Add `lv_tabview_set_tab_name()` function - used to change a tab's name - Add `LV_THEME_MATERIAL_FLAG_NO_TRANSITION` and `LV_THEME_MATERIAL_FLAG_NO_FOCUS` flags +- Reduce code size by adding: `LV_USE_FONT_COMPRESSED` and `LV_FONT_USE_SUBPX` and applying some optimization + ### Bugfixes - Do not print warning for missing glyph if its height OR width is zero. From cac6f92964f3cdb960612b21a7e7996af2a9e8ee Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 27 Jul 2020 20:19:02 +0200 Subject: [PATCH 162/205] fix warning --- src/lv_draw/lv_draw_rect.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/lv_draw/lv_draw_rect.c b/src/lv_draw/lv_draw_rect.c index 41a7fab26..f624d99e8 100644 --- a/src/lv_draw/lv_draw_rect.c +++ b/src/lv_draw/lv_draw_rect.c @@ -418,10 +418,6 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv /*Create a mask if there is a radius*/ lv_opa_t * mask_buf = _lv_mem_buf_get(draw_area_w); - uint8_t other_mask_cnt = lv_draw_mask_get_cnt(); - bool simple_mode = true; - if(other_mask_cnt) simple_mode = false; - /*Create mask for the outer area*/ int16_t mask_rout_id = LV_MASK_ID_INV; lv_draw_mask_radius_param_t mask_rout_param; From 0f69469eeeecf41921f870051bc3af311114fa13 Mon Sep 17 00:00:00 2001 From: Seth Itow <11025699+sethitow@users.noreply.github.com> Date: Tue, 28 Jul 2020 03:18:42 -0700 Subject: [PATCH 163/205] README.md: Update link to Micropython documentation (#1693) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dfbd2a1ce..12bb29d44 100644 --- a/README.md +++ b/README.md @@ -145,7 +145,7 @@ void btn_event_cb(lv_obj_t * btn, lv_event_t event) ![LVGL button with label example](https://raw.githubusercontent.com/lvgl/docs/latest/misc/simple_button_example.gif) ### LVGL from Micropython -Learn more about [Micropython](https://docs.lvgl.io/en/html/get-started/micropython). +Learn more about [Micropython](https://docs.lvgl.io/latest/en/html/get-started/micropython.html). ```python # Create a Button and a Label scr = lv.obj() From b0e3f11da13ffb3e705fbc8c911cc3c4e00ddc62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sven=20Krau=C3=9F?= Date: Tue, 28 Jul 2020 17:08:21 +0200 Subject: [PATCH 164/205] Make lv_draw_line_dsc_t parameters constant --- src/lv_draw/lv_draw_line.c | 14 +++++++------- src/lv_draw/lv_draw_line.h | 2 +- src/lv_widgets/lv_canvas.c | 2 +- src/lv_widgets/lv_canvas.h | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lv_draw/lv_draw_line.c b/src/lv_draw/lv_draw_line.c index 2a22ec509..0c84b2c49 100644 --- a/src/lv_draw/lv_draw_line.c +++ b/src/lv_draw/lv_draw_line.c @@ -26,13 +26,13 @@ **********************/ LV_ATTRIBUTE_FAST_MEM static void draw_line_skew(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip, - lv_draw_line_dsc_t * dsc); + const lv_draw_line_dsc_t * dsc); LV_ATTRIBUTE_FAST_MEM static void draw_line_hor(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip, - lv_draw_line_dsc_t * dsc); + const lv_draw_line_dsc_t * dsc); LV_ATTRIBUTE_FAST_MEM static void draw_line_ver(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip, - lv_draw_line_dsc_t * dsc); + const lv_draw_line_dsc_t * dsc); /********************** * STATIC VARIABLES @@ -63,7 +63,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc) * @param opa_scale scale down all opacities by the factor */ LV_ATTRIBUTE_FAST_MEM void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip, - lv_draw_line_dsc_t * dsc) + const lv_draw_line_dsc_t * dsc) { if(dsc->width == 0) return; if(dsc->opa <= LV_OPA_MIN) return; @@ -120,7 +120,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_line(const lv_point_t * point1, const lv_poin LV_ATTRIBUTE_FAST_MEM static void draw_line_hor(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip, - lv_draw_line_dsc_t * dsc) + const lv_draw_line_dsc_t * dsc) { lv_opa_t opa = dsc->opa; @@ -221,7 +221,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_hor(const lv_point_t * point1, const LV_ATTRIBUTE_FAST_MEM static void draw_line_ver(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip, - lv_draw_line_dsc_t * dsc) + const lv_draw_line_dsc_t * dsc) { lv_opa_t opa = dsc->opa; @@ -316,7 +316,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_ver(const lv_point_t * point1, const LV_ATTRIBUTE_FAST_MEM static void draw_line_skew(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip, - lv_draw_line_dsc_t * dsc) + const lv_draw_line_dsc_t * dsc) { /*Keep the great y in p1*/ lv_point_t p1; diff --git a/src/lv_draw/lv_draw_line.h b/src/lv_draw/lv_draw_line.h index abc2e9819..83abe6818 100644 --- a/src/lv_draw/lv_draw_line.h +++ b/src/lv_draw/lv_draw_line.h @@ -48,7 +48,7 @@ typedef struct { * @param opa_scale scale down all opacities by the factor */ LV_ATTRIBUTE_FAST_MEM void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * mask, - lv_draw_line_dsc_t * dsc); + const lv_draw_line_dsc_t * dsc); LV_ATTRIBUTE_FAST_MEM void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc); diff --git a/src/lv_widgets/lv_canvas.c b/src/lv_widgets/lv_canvas.c index 70571b903..d16d40a22 100644 --- a/src/lv_widgets/lv_canvas.c +++ b/src/lv_widgets/lv_canvas.c @@ -909,7 +909,7 @@ void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const voi * @param style style of the line (`line` properties are used) */ void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t points[], uint32_t point_cnt, - lv_draw_line_dsc_t * line_draw_dsc) + const lv_draw_line_dsc_t * line_draw_dsc) { LV_ASSERT_OBJ(canvas, LV_OBJX_NAME); diff --git a/src/lv_widgets/lv_canvas.h b/src/lv_widgets/lv_canvas.h index ce4cca2f7..14958c1d8 100644 --- a/src/lv_widgets/lv_canvas.h +++ b/src/lv_widgets/lv_canvas.h @@ -215,7 +215,7 @@ void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const voi * @param style style of the line (`line` properties are used) */ void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t points[], uint32_t point_cnt, - lv_draw_line_dsc_t * line_draw_dsc); + const lv_draw_line_dsc_t * line_draw_dsc); /** * Draw a polygon on the canvas From 1072b71ea09c6e901f2f64153595f8784f356f54 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 30 Jul 2020 11:11:07 +0200 Subject: [PATCH 165/205] gauge: fix image needle drawing --- CHANGELOG.md | 1 + src/lv_widgets/lv_gauge.c | 17 ++++++++--------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b50a0335..456d2bfb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ - Remove duplicated lines from `lv_tabview_add_tab` - btnmatrix: hadle combined states of buttons (e.g. chacked + disabled) - textarea: fix typo in lv_textarea_set_sscrollbar_mode +- gauge: fix image needle drawing ## v7.2.0 (21.07.2020) diff --git a/src/lv_widgets/lv_gauge.c b/src/lv_widgets/lv_gauge.c index ad7cb32e1..df2d5c0ea 100644 --- a/src/lv_widgets/lv_gauge.c +++ b/src/lv_widgets/lv_gauge.c @@ -589,15 +589,6 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * clip_area) lv_draw_line_dsc_init(&line_dsc); lv_obj_init_draw_line_dsc(gauge, LV_GAUGE_PART_NEEDLE, &line_dsc); - lv_draw_img_dsc_t img_dsc; - if(ext->needle_img == NULL) { - lv_draw_img_dsc_init(&img_dsc); - lv_obj_init_draw_img_dsc(gauge, LV_GAUGE_PART_MAIN, &img_dsc); - img_dsc.recolor_opa = LV_OPA_COVER; - img_dsc.pivot.x = ext->needle_img_pivot.x; - img_dsc.pivot.y = ext->needle_img_pivot.y; - } - p_mid.x = x_ofs; p_mid.y = y_ofs; for(i = 0; i < ext->needle_count; i++) { @@ -625,10 +616,18 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * clip_area) a.y1 = gauge->coords.y1 + lv_area_get_height(&gauge->coords) / 2 - ext->needle_img_pivot.y; a.x2 = a.x1 + info.w - 1; a.y2 = a.y1 + info.h - 1; + lv_draw_img_dsc_t img_dsc; + lv_draw_img_dsc_init(&img_dsc); + lv_obj_init_draw_img_dsc(gauge, LV_GAUGE_PART_MAIN, &img_dsc); + img_dsc.recolor_opa = LV_OPA_COVER; + img_dsc.pivot.x = ext->needle_img_pivot.x; + img_dsc.pivot.y = ext->needle_img_pivot.y; if(ext->needle_colors != NULL) img_dsc.recolor = ext->needle_colors[i]; + needle_angle = (needle_angle * 10); + if(needle_angle > 3600) needle_angle -= 3600; img_dsc.angle = needle_angle; lv_draw_img(&a, clip_area, ext->needle_img, &img_dsc); } From 373af97472fe2f15c4becfae350962c02ce63566 Mon Sep 17 00:00:00 2001 From: Droup Date: Fri, 31 Jul 2020 14:32:17 +0200 Subject: [PATCH 166/205] page: Use padding when focus an child item Signed-off-by: Droup --- src/lv_widgets/lv_page.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lv_widgets/lv_page.c b/src/lv_widgets/lv_page.c index 726e404d8..7efe2aab3 100644 --- a/src/lv_widgets/lv_page.c +++ b/src/lv_widgets/lv_page.c @@ -495,14 +495,14 @@ void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, lv_anim_enable_t anim_ lv_coord_t scrlable_y = lv_obj_get_y(ext->scrl); lv_coord_t page_h = lv_obj_get_height(page); - lv_coord_t top_err = -(scrlable_y + obj_y); - lv_coord_t bot_err = scrlable_y + obj_y + obj_h - page_h; - lv_style_int_t bg_top = lv_obj_get_style_pad_top(page, LV_PAGE_PART_BG); lv_style_int_t bg_bottom = lv_obj_get_style_pad_bottom(page, LV_PAGE_PART_BG); lv_style_int_t scrl_top = lv_obj_get_style_pad_top(ext->scrl, LV_CONT_PART_MAIN); lv_style_int_t scrl_bottom = lv_obj_get_style_pad_bottom(ext->scrl, LV_CONT_PART_MAIN); + lv_coord_t top_err = -(scrlable_y + (obj_y - scrl_top - bg_top) - scrl_top); + lv_coord_t bot_err = scrlable_y + (obj_y + scrl_bottom + bg_bottom) + scrl_bottom + obj_h - page_h; + /*Out of the page on the top*/ if((obj_h <= page_h && top_err > 0) || (obj_h > page_h && top_err < bot_err)) { /*Calculate a new position and let some space above*/ @@ -524,14 +524,14 @@ void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, lv_anim_enable_t anim_ lv_coord_t scrlable_x = lv_obj_get_x(ext->scrl); lv_coord_t page_w = lv_obj_get_width(page); - lv_coord_t left_err = -(scrlable_x + obj_x); - lv_coord_t right_err = scrlable_x + obj_x + obj_w - page_w; - lv_style_int_t bg_left = lv_obj_get_style_pad_left(page, LV_PAGE_PART_BG); lv_style_int_t bg_right = lv_obj_get_style_pad_right(page, LV_PAGE_PART_BG); lv_style_int_t scrl_left = lv_obj_get_style_pad_top(ext->scrl, LV_CONT_PART_MAIN); lv_style_int_t scrl_right = lv_obj_get_style_pad_bottom(ext->scrl, LV_CONT_PART_MAIN); + lv_coord_t left_err = -(scrlable_x + (obj_x - scrl_left - bg_left) - scrl_left); + lv_coord_t right_err = scrlable_x + (obj_x + scrl_right + bg_right) + scrl_right + obj_w - page_w; + /*Out of the page on the left*/ if((obj_w <= page_w && left_err > 0) || (obj_w > page_w && left_err < right_err)) { /*Calculate a new position and let some space on the side*/ From b7d7bf7dd53017ebf7fa73bea191cc117630ff42 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 31 Jul 2020 22:13:46 +0200 Subject: [PATCH 167/205] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 12bb29d44..eeb9f47f2 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ Basically, every modern controller (which is able to drive a display) is suitabl Heap > 2 kB - > 16 kB + > 8 kB From 2b60f4496f6bd174907be0742c49df9cbbf3e3df Mon Sep 17 00:00:00 2001 From: DefinPlusPlus Date: Sat, 1 Aug 2020 20:36:07 +0300 Subject: [PATCH 168/205] Fixed infinite loop during calculation size of lv_list (#1700) --- src/lv_widgets/lv_list.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_widgets/lv_list.c b/src/lv_widgets/lv_list.c index dfd2b32af..acb165a81 100644 --- a/src/lv_widgets/lv_list.c +++ b/src/lv_widgets/lv_list.c @@ -495,7 +495,7 @@ uint16_t lv_list_get_size(const lv_obj_t * list) lv_obj_t * btn = lv_list_get_next_btn(list, NULL); while(btn) { size++; - btn = lv_list_get_next_btn(list, NULL); + btn = lv_list_get_next_btn(list, btn); } return size; } From 28213adfa62f70fa3a25b10baf305b99bbc14436 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 2 Aug 2020 12:04:10 +0200 Subject: [PATCH 169/205] -fix using freed memory in _lv_style_list_remove_style Fixes: #1694 --- src/lv_core/lv_style.c | 4 +++- src/lv_core/lv_style.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lv_core/lv_style.c b/src/lv_core/lv_style.c index ce3665e0d..df1debc4d 100644 --- a/src/lv_core/lv_style.c +++ b/src/lv_core/lv_style.c @@ -257,7 +257,7 @@ void _lv_style_list_remove_style(lv_style_list_t * list, lv_style_t * style) return; } - lv_style_t ** new_classes = lv_mem_realloc(list->style_list, sizeof(lv_style_t *) * (list->style_cnt - 1)); + lv_style_t ** new_classes = lv_mem_alloc(sizeof(lv_style_t *) * (list->style_cnt - 1)); LV_ASSERT_MEM(new_classes); if(new_classes == NULL) { LV_LOG_WARN("lv_style_list_remove_style: couldn't reallocate class list"); @@ -271,6 +271,8 @@ void _lv_style_list_remove_style(lv_style_list_t * list, lv_style_t * style) } + lv_mem_free(list->style_list); + list->style_cnt--; list->style_list = new_classes; } diff --git a/src/lv_core/lv_style.h b/src/lv_core/lv_style.h index 5909299b6..d244936b2 100644 --- a/src/lv_core/lv_style.h +++ b/src/lv_core/lv_style.h @@ -570,7 +570,7 @@ bool lv_debug_check_style_list(const lv_style_list_t * list); * lv_style_init(&my_style); * lv_style_copy(&my_style, &style_to_copy); */ -#define LV_STYLE_CREATE(name, copy_p) static lv_style_t name; lv_style_init(&name); lv_style_copy(&name, copy); +#define LV_STYLE_CREATE(name, copy_p) static lv_style_t name; lv_style_init(&name); lv_style_copy(&name, copy_p); From c85295b5ea9e44a5da67b12b8a7a9db179580360 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 2 Aug 2020 12:04:48 +0200 Subject: [PATCH 170/205] update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 456d2bfb1..4afdd3327 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ - btnmatrix: hadle combined states of buttons (e.g. chacked + disabled) - textarea: fix typo in lv_textarea_set_sscrollbar_mode - gauge: fix image needle drawing +- fix using freed memory in _lv_style_list_remove_style ## v7.2.0 (21.07.2020) From 1c3bbc9f6c76a498de7daa06099b2726b819c725 Mon Sep 17 00:00:00 2001 From: Droup Date: Mon, 3 Aug 2020 10:38:18 +0200 Subject: [PATCH 171/205] Fix focus move Signed-off-by: Droup --- src/lv_widgets/lv_page.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lv_widgets/lv_page.c b/src/lv_widgets/lv_page.c index 7efe2aab3..7be8f456f 100644 --- a/src/lv_widgets/lv_page.c +++ b/src/lv_widgets/lv_page.c @@ -500,8 +500,8 @@ void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, lv_anim_enable_t anim_ lv_style_int_t scrl_top = lv_obj_get_style_pad_top(ext->scrl, LV_CONT_PART_MAIN); lv_style_int_t scrl_bottom = lv_obj_get_style_pad_bottom(ext->scrl, LV_CONT_PART_MAIN); - lv_coord_t top_err = -(scrlable_y + (obj_y - scrl_top - bg_top) - scrl_top); - lv_coord_t bot_err = scrlable_y + (obj_y + scrl_bottom + bg_bottom) + scrl_bottom + obj_h - page_h; + lv_coord_t top_err = -((scrlable_y + obj_y) - bg_top); + lv_coord_t bot_err = scrlable_y + obj_y + obj_h - (page_h - bg_bottom); /*Out of the page on the top*/ if((obj_h <= page_h && top_err > 0) || (obj_h > page_h && top_err < bot_err)) { @@ -529,8 +529,8 @@ void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, lv_anim_enable_t anim_ lv_style_int_t scrl_left = lv_obj_get_style_pad_top(ext->scrl, LV_CONT_PART_MAIN); lv_style_int_t scrl_right = lv_obj_get_style_pad_bottom(ext->scrl, LV_CONT_PART_MAIN); - lv_coord_t left_err = -(scrlable_x + (obj_x - scrl_left - bg_left) - scrl_left); - lv_coord_t right_err = scrlable_x + (obj_x + scrl_right + bg_right) + scrl_right + obj_w - page_w; + lv_coord_t left_err = -((scrlable_x + obj_x) - bg_left); + lv_coord_t right_err = scrlable_x + obj_x + obj_w - (page_w - bg_right); /*Out of the page on the left*/ if((obj_w <= page_w && left_err > 0) || (obj_w > page_w && left_err < right_err)) { From a0e6f7f0225da39e498b21d6be3b8599cbbd4a5b Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 3 Aug 2020 13:37:11 +0200 Subject: [PATCH 172/205] Update ROADMAP.md --- docs/ROADMAP.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 66aae962d..04341ee39 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -25,4 +25,10 @@ Planned to September/October 2020 - See [#1656](https://github.com/lvgl/lvgl/issues/1656) ## Ideas -- ... +- Unit testing (gtest?). See [#1658](https://github.com/lvgl/lvgl/issues/1658) +- Benchmarking (gem5?). See [#1660](https://github.com/lvgl/lvgl/issues/1660) +- CPP binding. See [Forum](https://forum.lvgl.io/t/is-it-possible-to-officially-support-optional-cpp-api/2736) +- Optmize font decompression +- Switch to RGBA colors in styles +- Need coverage report for tests +- Need static analize (via coverity.io or somehing else). From 85d375b1283bf0a59411d3a3a729c69352a10dcf Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 3 Aug 2020 13:39:51 +0200 Subject: [PATCH 173/205] Update ROADMAP.md --- docs/ROADMAP.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 04341ee39..a30893f76 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -7,7 +7,7 @@ This list indicates only the current intention and can be changed. ## v8 Planned to September/October 2020 - New scrolling: - - See [feat/new-scroll]((https://github.com/lvgl/lvgl/tree/feat/new-scroll) branch and [#1614](https://github.com/lvgl/lvgl/issues/1614)) issue. + - See [feat/new-scroll](https://github.com/lvgl/lvgl/tree/feat/new-scroll) branch and [#1614](https://github.com/lvgl/lvgl/issues/1614)) issue. - Remove `lv_page` and support scrolling on `lv_obj` - Support "elastic" scrolling when scrolled in - Support scroll chaining among any objects types (not only `lv_pages`s) From b58f9c602179877222130221646ff7d3f40f445f Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 4 Aug 2020 09:19:25 +0200 Subject: [PATCH 174/205] Add LV_USE_OUTLINE/PATTERN/VALUE_STR and LV_MEMCPY_MEMSET_STD --- CHANGELOG.md | 3 +- lv_conf_template.h | 15 ++++++++- src/lv_conf_internal.h | 28 ++++++++++++++-- src/lv_core/lv_obj.c | 8 ++++- src/lv_draw/lv_draw_rect.c | 33 ++++++++++++++++--- src/lv_misc/lv_mem.c | 5 ++- src/lv_misc/lv_mem.h | 66 ++++++++++++++++++++++++++++++++++++-- 7 files changed, 143 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4afdd3327..7960f5497 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,8 @@ - Add `lv_event_send_refresh`, `lv_event_send_refresh_recursive` to easily send `LV_EVENT_REFRESH` to object - Add `lv_tabview_set_tab_name()` function - used to change a tab's name - Add `LV_THEME_MATERIAL_FLAG_NO_TRANSITION` and `LV_THEME_MATERIAL_FLAG_NO_FOCUS` flags -- Reduce code size by adding: `LV_USE_FONT_COMPRESSED` and `LV_FONT_USE_SUBPX` and applying some optimization +- Reduce code size by adding: `LV_USE_FONT_COMPRESSED`, `LV_FONT_USE_SUBPX`, `LV_USE_OUTLINE`, `LV_USE_PATTERN`, `LV_USE_VALUE_STR` and applying some optimization +- Add `LV_MEMCPY_MEMSET_STD` to use standard `memcpy` and `memset` ### Bugfixes diff --git a/lv_conf_template.h b/lv_conf_template.h index aab9f497f..d8b5f8870 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -97,6 +97,10 @@ typedef int16_t lv_coord_t; # define LV_MEM_CUSTOM_FREE free /*Wrapper to free*/ #endif /*LV_MEM_CUSTOM*/ +/* Use the standard memcpy and memset instead of LVGL's own functions. + * The standard functions might or might not be faster depending on their implementation. */ +#define LV_MEMCPY_MEMSET_STD 0 + /* Garbage Collector settings * Used if lvgl is binded to higher level language and the memory is managed by that language */ #define LV_ENABLE_GC 0 @@ -150,7 +154,7 @@ typedef void * lv_anim_user_data_t; #endif -/* 1: Enable shadow drawing*/ +/* 1: Enable shadow drawing on rectangles*/ #define LV_USE_SHADOW 1 #if LV_USE_SHADOW /* Allow buffering some shadow calculation @@ -160,6 +164,15 @@ typedef void * lv_anim_user_data_t; #define LV_SHADOW_CACHE_SIZE 0 #endif +/*1: enable outline drawing on rectangles*/ +#define LV_USE_OUTLINE 1 + +/*1: enable pattern drawing on rectangles*/ +#define LV_USE_PATTERN 1 + +/*1: enable value string drawing on rectangles*/ +#define LV_USE_VALUE_STR 1 + /* 1: Use other blend modes than normal (`LV_BLEND_MODE_...`)*/ #define LV_USE_BLEND_MODES 1 diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index 7f86b0eae..d43134241 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -147,6 +147,12 @@ #endif #endif /*LV_MEM_CUSTOM*/ +/* Use the standard memcpy and memset instead of LVGL's own functions. + * The standard functions might or might not be faster depending on their implementation. */ +#ifndef LV_MEMCPY_MEMSET_STD +#define LV_MEMCPY_MEMSET_STD 0 +#endif + /* Garbage Collector settings * Used if lvgl is binded to higher level language and the memory is managed by that language */ #ifndef LV_ENABLE_GC @@ -223,7 +229,7 @@ #endif -/* 1: Enable shadow drawing*/ +/* 1: Enable shadow drawing on rectangles*/ #ifndef LV_USE_SHADOW #define LV_USE_SHADOW 1 #endif @@ -237,6 +243,21 @@ #endif #endif +/*1: enable outline drawing on rectangles*/ +#ifndef LV_USE_OUTLINE +#define LV_USE_OUTLINE 1 +#endif + +/*1: enable pattern drawing on rectangles*/ +#ifndef LV_USE_PATTERN +#define LV_USE_PATTERN 1 +#endif + +/*1: enable value string drawing on rectangles*/ +#ifndef LV_USE_VALUE_STR +#define LV_USE_VALUE_STR 1 +#endif + /* 1: Use other blend modes than normal (`LV_BLEND_MODE_...`)*/ #ifndef LV_USE_BLEND_MODES #define LV_USE_BLEND_MODES 1 @@ -633,7 +654,10 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */ /* A fast and impressive theme. * Flags: * LV_THEME_MATERIAL_FLAG_LIGHT: light theme - * LV_THEME_MATERIAL_FLAG_DARK: dark theme*/ + * LV_THEME_MATERIAL_FLAG_DARK: dark theme + * LV_THEME_MATERIAL_FLAG_NO_TRANSITION: disable transitions (state change animations) + * LV_THEME_MATERIAL_FLAG_NO_FOCUS: disable indication of focused state) + * */ #ifndef LV_USE_THEME_MATERIAL #define LV_USE_THEME_MATERIAL 1 #endif diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 8eedc3da0..3a5d05e46 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -3157,7 +3157,7 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t } } - +#if LV_USE_OUTLINE if(draw_dsc->outline_opa != LV_OPA_TRANSP) { draw_dsc->outline_width = lv_obj_get_style_outline_width(obj, part); if(draw_dsc->outline_width) { @@ -3171,7 +3171,9 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t #endif } } +#endif +#if LV_USE_PATTERN if(draw_dsc->pattern_opa != LV_OPA_TRANSP) { draw_dsc->pattern_image = lv_obj_get_style_pattern_image(obj, part); if(draw_dsc->pattern_image) { @@ -3192,6 +3194,8 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t } } } +#endif + #if LV_USE_SHADOW if(draw_dsc->shadow_opa > LV_OPA_MIN) { draw_dsc->shadow_width = lv_obj_get_style_shadow_width(obj, part); @@ -3210,6 +3214,7 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t } #endif +#if LV_USE_VALUE_STR if(draw_dsc->value_opa > LV_OPA_MIN) { draw_dsc->value_str = lv_obj_get_style_value_str(obj, part); if(draw_dsc->value_str) { @@ -3228,6 +3233,7 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t } } } +#endif #if LV_USE_OPA_SCALE if(opa_scale < LV_OPA_MAX) { diff --git a/src/lv_draw/lv_draw_rect.c b/src/lv_draw/lv_draw_rect.c index f624d99e8..b83963966 100644 --- a/src/lv_draw/lv_draw_rect.c +++ b/src/lv_draw/lv_draw_rect.c @@ -30,8 +30,10 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc); LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc); + +#if LV_USE_OUTLINE static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc); -LV_ATTRIBUTE_FAST_MEM static inline lv_color_t grad_get(lv_draw_rect_dsc_t * dsc, lv_coord_t s, lv_coord_t i); +#endif #if LV_USE_SHADOW LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc); @@ -39,9 +41,16 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_draw_corner_buf(const lv_area_t * coord lv_coord_t r); LV_ATTRIBUTE_FAST_MEM static void shadow_blur_corner(lv_coord_t size, lv_coord_t sw, uint16_t * sh_ups_buf); #endif + +#if LV_USE_PATTERN static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc); -static void draw_value(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc); +#endif + +#if LV_USE_VALUE_STR +static void draw_value_str(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc); +#endif static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * area_outer, const lv_area_t * clip, lv_coord_t radius, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode); +LV_ATTRIBUTE_FAST_MEM static inline lv_color_t grad_get(lv_draw_rect_dsc_t * dsc, lv_coord_t s, lv_coord_t i); /********************** * STATIC VARIABLES @@ -96,10 +105,19 @@ void lv_draw_rect(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect #endif draw_bg(coords, clip, dsc); + +#if LV_USE_PATTERN draw_pattern(coords, clip, dsc); +#endif draw_border(coords, clip, dsc); - draw_value(coords, clip, dsc); + +#if LV_USE_VALUE_STR + draw_value_str(coords, clip, dsc); +#endif + +#if LV_USE_OUTLINE draw_outline(coords, clip, dsc); +#endif LV_ASSERT_MEM_INTEGRITY(); } @@ -1128,6 +1146,7 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_blur_corner(lv_coord_t size, lv_coord_t #endif +#if LV_USE_OUTLINE static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc) { if(dsc->outline_opa <= LV_OPA_MIN) return; @@ -1155,7 +1174,10 @@ static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_dr draw_full_border(&area_inner, &area_outer, clip, dsc->radius, dsc->outline_color, dsc->outline_opa, dsc->outline_blend_mode); } +#endif + +#if LV_USE_PATTERN static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc) { if(dsc->pattern_image == NULL) return; @@ -1256,9 +1278,11 @@ static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, lv_dr lv_draw_mask_remove_id(radius_mask_id); } } +#endif -static void draw_value(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc) +#if LV_USE_VALUE_STR +static void draw_value_str(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc) { if(dsc->value_str == NULL) return; if(dsc->value_opa <= LV_OPA_MIN) return; @@ -1291,6 +1315,7 @@ static void draw_value(const lv_area_t * coords, const lv_area_t * clip, lv_draw lv_draw_label(&value_area, clip, &label_dsc, dsc->value_str, NULL); } +#endif static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * area_outer, const lv_area_t * clip, lv_coord_t radius, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode) { diff --git a/src/lv_misc/lv_mem.c b/src/lv_misc/lv_mem.c index 8775f39da..7fa3146f8 100644 --- a/src/lv_misc/lv_mem.c +++ b/src/lv_misc/lv_mem.c @@ -586,6 +586,7 @@ void _lv_mem_buf_free_all(void) } } +#if LV_MEMCPY_MEMSET_STD == 0 /** * Same as `memcpy` but optimized for 4 byte operation. * @param dst pointer to the destination buffer @@ -652,7 +653,6 @@ LV_ATTRIBUTE_FAST_MEM void * _lv_memcpy(void * dst, const void * src, size_t len /** * Same as `memset` but optimized for 4 byte operation. - * `dst` should be word aligned else normal `memcpy` will be used * @param dst pointer to the destination buffer * @param v value to set [0..255] * @param len number of byte to set @@ -707,7 +707,6 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset(void * dst, uint8_t v, size_t len) /** * Same as `memset(dst, 0x00, len)` but optimized for 4 byte operation. - * `dst` should be word aligned else normal `memcpy` will be used * @param dst pointer to the destination buffer * @param len number of byte to set */ @@ -757,7 +756,6 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset_00(void * dst, size_t len) /** * Same as `memset(dst, 0xFF, len)` but optimized for 4 byte operation. - * `dst` should be word aligned else normal `memcpy` will be used * @param dst pointer to the destination buffer * @param len number of byte to set */ @@ -805,6 +803,7 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset_ff(void * dst, size_t len) } } +#endif /*LV_MEMCPY_MEMSET_STD*/ /********************** * STATIC FUNCTIONS diff --git a/src/lv_misc/lv_mem.h b/src/lv_misc/lv_mem.h index 91774133a..f3ca9c6f2 100644 --- a/src/lv_misc/lv_mem.h +++ b/src/lv_misc/lv_mem.h @@ -20,6 +20,10 @@ extern "C" { #include "lv_log.h" #include "lv_types.h" +#if LV_MEMCPY_MEMSET_STD +#include +#endif + /********************* * DEFINES *********************/ @@ -137,6 +141,62 @@ void _lv_mem_buf_free_all(void); //! @cond Doxygen_Suppress +#if LV_MEMCPY_MEMSET_STD + +/** + * Wrapper for the standard memcpy + * @param dst pointer to the destination buffer + * @param src pointer to the source buffer + * @param len number of byte to copy + */ +static inline void * _lv_memcpy(void * dst, const void * src, size_t len) +{ + return memcpy(dst, src, len); +} + +/** + * Wrapper for the standard memcpy + * @param dst pointer to the destination buffer + * @param src pointer to the source buffer + * @param len number of byte to copy + */ +static inline void * _lv_memcpy_small(void * dst, const void * src, size_t len) +{ + return memcpy(dst, src, len); +} + +/** + * Wrapper for the standard memset + * @param dst pointer to the destination buffer + * @param v value to set [0..255] + * @param len number of byte to set + */ +static inline void _lv_memset(void * dst, uint8_t v, size_t len) +{ + memset(dst, v, len); +} + +/** + * Wrapper for the standard memset with fixed 0x00 value + * @param dst pointer to the destination buffer + * @param len number of byte to set + */ +static inline void _lv_memset_00(void * dst, size_t len) +{ + memset(dst, 0x00, len); +} + +/** + * Wrapper for the standard memset with fixed 0xFF value + * @param dst pointer to the destination buffer + * @param len number of byte to set + */ +static inline void _lv_memset_ff(void * dst, size_t len) +{ + memset(dst, 0xFF, len); +} + +#else /** * Same as `memcpy` but optimized for 4 byte operation. * @param dst pointer to the destination buffer @@ -168,7 +228,6 @@ LV_ATTRIBUTE_FAST_MEM static inline void * _lv_memcpy_small(void * dst, const vo /** * Same as `memset` but optimized for 4 byte operation. - * `dst` should be word aligned else normal `memcpy` will be used * @param dst pointer to the destination buffer * @param v value to set [0..255] * @param len number of byte to set @@ -177,7 +236,6 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset(void * dst, uint8_t v, size_t len); /** * Same as `memset(dst, 0x00, len)` but optimized for 4 byte operation. - * `dst` should be word aligned else normal `memcpy` will be used * @param dst pointer to the destination buffer * @param len number of byte to set */ @@ -185,7 +243,6 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset_00(void * dst, size_t len); /** * Same as `memset(dst, 0xFF, len)` but optimized for 4 byte operation. - * `dst` should be word aligned else normal `memcpy` will be used * @param dst pointer to the destination buffer * @param len number of byte to set */ @@ -193,6 +250,9 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset_ff(void * dst, size_t len); //! @endcond +#endif + + /********************** * MACROS **********************/ From 0ec409f83ecfc27af725bf9dbc0e19a5e6f3dac1 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 4 Aug 2020 09:28:16 +0200 Subject: [PATCH 175/205] fix version nnumber --- lvgl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lvgl.h b/lvgl.h index ae383e640..f90729d7b 100644 --- a/lvgl.h +++ b/lvgl.h @@ -77,7 +77,7 @@ extern "C" { *********************/ /*Current version of LVGL*/ #define LVGL_VERSION_MAJOR 7 -#define LVGL_VERSION_MINOR 4 +#define LVGL_VERSION_MINOR 3 #define LVGL_VERSION_PATCH 0 #define LVGL_VERSION_INFO "dev" From ec7397e4a0267b2d0dbe662b213bf37bff70b243 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 4 Aug 2020 09:49:57 +0200 Subject: [PATCH 176/205] update release.py --- scripts/release.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/release.py b/scripts/release.py index e64c13bdc..d9917c5ab 100755 --- a/scripts/release.py +++ b/scripts/release.py @@ -210,10 +210,18 @@ def docs_update_version(v): cmd("git add conf.py") cmd('git ci -m "update conf.py to ' + v + '"') + +def docs_merge_to_release_branch(v): + title("docs: merge to release branch") + cmd('git co release/v7 --') + cmd('git clean -fd .') + cmd('git merge latest') + cmd('git push origin release/v7') + def docs_build(): title("docs: Build") cmd("git checkout master") - cmd("./update.py latest") + cmd("./update.py latest release/v7") def clean_up(): title("Clean up repos") @@ -240,6 +248,7 @@ drivers_merge_to_release_branch(ver_str) docs_clone() docs_get_api() docs_update_version(ver_str) +docs_merge_to_release_branch(v): docs_build() clean_up() From ad422250db859fa859c1d2393e454a967a77a65c Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 4 Aug 2020 09:57:29 +0200 Subject: [PATCH 177/205] update release.py --- scripts/release.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/release.py b/scripts/release.py index d9917c5ab..dc3ceb2b6 100755 --- a/scripts/release.py +++ b/scripts/release.py @@ -215,6 +215,7 @@ def docs_merge_to_release_branch(v): title("docs: merge to release branch") cmd('git co release/v7 --') cmd('git clean -fd .') + cmd('rm -f LVGL.pdf') #To avoide possible merge conflict cmd('git merge latest') cmd('git push origin release/v7') From 48f8d83bdc97067253adefd2137e96f1473fca8b Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 4 Aug 2020 10:06:57 +0200 Subject: [PATCH 178/205] update release.py --- scripts/release.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release.py b/scripts/release.py index dc3ceb2b6..7987d412c 100755 --- a/scripts/release.py +++ b/scripts/release.py @@ -249,7 +249,7 @@ drivers_merge_to_release_branch(ver_str) docs_clone() docs_get_api() docs_update_version(ver_str) -docs_merge_to_release_branch(v): +docs_merge_to_release_branch(v) docs_build() clean_up() From 7b0a0ef4a7b0c45c3a397c6e1ecbd87a2efbc028 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 4 Aug 2020 10:07:29 +0200 Subject: [PATCH 179/205] Run code formatter --- src/lv_core/lv_obj.c | 3 ++- src/lv_draw/lv_draw_rect.c | 19 ++++++++++-------- src/lv_themes/lv_theme_material.c | 3 ++- src/lv_widgets/lv_btnmatrix.c | 6 ++++-- src/lv_widgets/lv_cpicker.c | 2 +- src/lv_widgets/lv_tabview.c | 33 +++++++++++++++---------------- src/lv_widgets/lv_textarea.c | 6 +++--- 7 files changed, 39 insertions(+), 33 deletions(-) diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 3a5d05e46..a3051e529 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -1783,7 +1783,8 @@ void lv_event_send_refresh_recursive(lv_obj_t * obj) d = lv_disp_get_next(d); } - } else { + } + else { lv_res_t res = lv_event_send_refresh(obj); if(res != LV_RES_OK) return; /*If invalid returned do not check the children*/ diff --git a/src/lv_draw/lv_draw_rect.c b/src/lv_draw/lv_draw_rect.c index b83963966..d2d31d148 100644 --- a/src/lv_draw/lv_draw_rect.c +++ b/src/lv_draw/lv_draw_rect.c @@ -32,7 +32,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv lv_draw_rect_dsc_t * dsc); #if LV_USE_OUTLINE -static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc); + static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc); #endif #if LV_USE_SHADOW LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, @@ -43,13 +43,14 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_blur_corner(lv_coord_t size, lv_coord_t #endif #if LV_USE_PATTERN -static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc); + static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc); #endif #if LV_USE_VALUE_STR -static void draw_value_str(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc); + static void draw_value_str(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc); #endif -static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * area_outer, const lv_area_t * clip, lv_coord_t radius, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode); +static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * area_outer, const lv_area_t * clip, + lv_coord_t radius, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode); LV_ATTRIBUTE_FAST_MEM static inline lv_color_t grad_get(lv_draw_rect_dsc_t * dsc, lv_coord_t s, lv_coord_t i); /********************** @@ -485,8 +486,8 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv for(h = draw_area.y1; h <= draw_area.y2; h++) { if(normal || - (top_only && fill_area.y1 <= coords->y1 + corner_size) || - (bottom_only && fill_area.y1 >= coords->y2 - corner_size)) { + (top_only && fill_area.y1 <= coords->y1 + corner_size) || + (bottom_only && fill_area.y1 >= coords->y2 - corner_size)) { _lv_memset_ff(mask_buf, draw_area_w); mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); _lv_blend_fill(clip, &fill_area, color, mask_buf + buf_ofs, mask_res, opa, blend_mode); @@ -1172,7 +1173,8 @@ static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_dr area_outer.y1 -= dsc->outline_width; area_outer.y2 += dsc->outline_width; - draw_full_border(&area_inner, &area_outer, clip, dsc->radius, dsc->outline_color, dsc->outline_opa, dsc->outline_blend_mode); + draw_full_border(&area_inner, &area_outer, clip, dsc->radius, dsc->outline_color, dsc->outline_opa, + dsc->outline_blend_mode); } #endif @@ -1317,7 +1319,8 @@ static void draw_value_str(const lv_area_t * coords, const lv_area_t * clip, lv_ } #endif -static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * area_outer, const lv_area_t * clip, lv_coord_t radius, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode) +static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * area_outer, const lv_area_t * clip, + lv_coord_t radius, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode) { uint8_t other_mask_cnt = lv_draw_mask_get_cnt(); bool simple_mode = true; diff --git a/src/lv_themes/lv_theme_material.c b/src/lv_themes/lv_theme_material.c index 893798917..661db996d 100644 --- a/src/lv_themes/lv_theme_material.c +++ b/src/lv_themes/lv_theme_material.c @@ -211,7 +211,8 @@ static void basic_init(void) lv_style_set_bg_opa(&styles->bg, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_bg_color(&styles->bg, LV_STATE_DEFAULT, COLOR_BG); lv_style_set_border_color(&styles->bg, LV_STATE_DEFAULT, COLOR_BG_BORDER); - if((theme.flags & LV_THEME_MATERIAL_FLAG_NO_FOCUS) == 0)lv_style_set_border_color(&styles->bg, LV_STATE_FOCUSED, theme.color_primary); + if((theme.flags & LV_THEME_MATERIAL_FLAG_NO_FOCUS) == 0)lv_style_set_border_color(&styles->bg, LV_STATE_FOCUSED, + theme.color_primary); lv_style_set_border_color(&styles->bg, LV_STATE_EDITED, theme.color_secondary); lv_style_set_border_width(&styles->bg, LV_STATE_DEFAULT, BORDER_WIDTH); lv_style_set_border_post(&styles->bg, LV_STATE_DEFAULT, true); diff --git a/src/lv_widgets/lv_btnmatrix.c b/src/lv_widgets/lv_btnmatrix.c index 1f2cd6675..842d6421b 100644 --- a/src/lv_widgets/lv_btnmatrix.c +++ b/src/lv_widgets/lv_btnmatrix.c @@ -706,7 +706,8 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl if(btn_state == LV_STATE_DEFAULT) { draw_rect_dsc_act = &draw_rect_rel_dsc; draw_label_dsc_act = &draw_label_rel_dsc; - } else if(btn_state == LV_STATE_CHECKED) { + } + else if(btn_state == LV_STATE_CHECKED) { if(!chk_inited) { btnm->state = LV_STATE_CHECKED; lv_draw_rect_dsc_init(&draw_rect_chk_dsc); @@ -719,7 +720,8 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl } draw_rect_dsc_act = &draw_rect_chk_dsc; draw_label_dsc_act = &draw_label_chk_dsc; - } else if(btn_state == LV_STATE_CHECKED) { + } + else if(btn_state == LV_STATE_CHECKED) { if(!disabled_inited) { btnm->state = LV_STATE_DISABLED; lv_draw_rect_dsc_init(&draw_rect_ina_dsc); diff --git a/src/lv_widgets/lv_cpicker.c b/src/lv_widgets/lv_cpicker.c index db682092a..552b171e4 100644 --- a/src/lv_widgets/lv_cpicker.c +++ b/src/lv_widgets/lv_cpicker.c @@ -492,7 +492,7 @@ static void draw_disc_grad(lv_obj_t * cpicker, const lv_area_t * mask) /* Mask outer ring of widget to tidy up ragged edges of lines while drawing outer ring */ lv_area_t mask_area_out; - lv_area_copy( &mask_area_out, &cpicker->coords); + lv_area_copy(&mask_area_out, &cpicker->coords); mask_area_out.x1 += OUTER_MASK_WIDTH; mask_area_out.x2 -= OUTER_MASK_WIDTH; mask_area_out.y1 += OUTER_MASK_WIDTH; diff --git a/src/lv_widgets/lv_tabview.c b/src/lv_widgets/lv_tabview.c index 475a3f427..0e35e3798 100644 --- a/src/lv_widgets/lv_tabview.c +++ b/src/lv_widgets/lv_tabview.c @@ -440,28 +440,27 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t an * @param id index of the tab the name should be set * @param name new tab name */ -void lv_tabview_set_tab_name(lv_obj_t *tabview, uint16_t id, char *name) +void lv_tabview_set_tab_name(lv_obj_t * tabview, uint16_t id, char * name) { - LV_ASSERT_OBJ(tabview, LV_OBJX_NAME); + LV_ASSERT_OBJ(tabview, LV_OBJX_NAME); - /* get tabview's ext pointer which contains the tab name pointer list */ - lv_tabview_ext_t *ext = lv_obj_get_ext_attr(tabview); + /* get tabview's ext pointer which contains the tab name pointer list */ + lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview); - /* check for valid tab index */ - if (ext->tab_cnt > id) - { - /* reallocate memory for new tab name (use reallocate due to mostly the size didn't change much) */ - char *str = lv_mem_realloc((void *)ext->tab_name_ptr[id], strlen(name) + 1); - LV_ASSERT_MEM(str); + /* check for valid tab index */ + if(ext->tab_cnt > id) { + /* reallocate memory for new tab name (use reallocate due to mostly the size didn't change much) */ + char * str = lv_mem_realloc((void *)ext->tab_name_ptr[id], strlen(name) + 1); + LV_ASSERT_MEM(str); - /* store new tab name at allocated memory */ - strcpy(str, name); - /* update pointer */ - ext->tab_name_ptr[id] = str; + /* store new tab name at allocated memory */ + strcpy(str, name); + /* update pointer */ + ext->tab_name_ptr[id] = str; - /* force redrawing of the tab headers */ - lv_obj_invalidate(ext->btns); - } + /* force redrawing of the tab headers */ + lv_obj_invalidate(ext->btns); + } } /** diff --git a/src/lv_widgets/lv_textarea.c b/src/lv_widgets/lv_textarea.c index c82870bf1..da622df65 100644 --- a/src/lv_widgets/lv_textarea.c +++ b/src/lv_widgets/lv_textarea.c @@ -246,7 +246,7 @@ void lv_textarea_add_char(lv_obj_t * ta, uint32_t c) lv_res_t res = insert_handler(ta, letter_buf); if(res != LV_RES_OK) return; - + if(ext->one_line && (c == '\n' || c == '\r')) { LV_LOG_INFO("Text area: line break ignored in one-line mode"); return; @@ -259,7 +259,7 @@ void lv_textarea_add_char(lv_obj_t * ta, uint32_t c) "accepted list)"); return; } - + /*If a new line was added it shouldn't show edge flash effect*/ bool edge_flash_en = lv_textarea_get_edge_flash(ta); @@ -337,7 +337,7 @@ void lv_textarea_add_text(lv_obj_t * ta, const char * txt) } return; } - + lv_res_t res = insert_handler(ta, txt); if(res != LV_RES_OK) return; From eb76519d254ef6a55077e973c42ada2cd3e6666a Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 4 Aug 2020 10:07:30 +0200 Subject: [PATCH 180/205] Release v7.3.0 --- library.json | 2 +- lv_conf_template.h | 2 +- lvgl.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library.json b/library.json index a2c5dd2b9..6cb9ab8b3 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "lvgl", - "version": "7.2.0", + "version": "7.3.0", "keywords": "graphics, gui, embedded, tft, lvgl", "description": "Graphics library to create embedded GUI with easy-to-use graphical elements, beautiful visual effects and low memory footprint. It offers anti-aliasing, opacity, and animations using only one frame buffer.", "repository": { diff --git a/lv_conf_template.h b/lv_conf_template.h index d8b5f8870..4032f5ab0 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -1,6 +1,6 @@ /** * @file lv_conf.h - * Configuration file for LVGL v7.2.0 + * Configuration file for LVGL v7.3.0 */ /* diff --git a/lvgl.h b/lvgl.h index f90729d7b..94a53df2c 100644 --- a/lvgl.h +++ b/lvgl.h @@ -79,7 +79,7 @@ extern "C" { #define LVGL_VERSION_MAJOR 7 #define LVGL_VERSION_MINOR 3 #define LVGL_VERSION_PATCH 0 -#define LVGL_VERSION_INFO "dev" +#define LVGL_VERSION_INFO "" /********************** * TYPEDEFS From e3a07ed58cc53bbe6e259dd16a5976aaade5cab9 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 4 Aug 2020 10:09:33 +0200 Subject: [PATCH 181/205] update release.py --- scripts/release.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release.py b/scripts/release.py index 7987d412c..0b5946584 100755 --- a/scripts/release.py +++ b/scripts/release.py @@ -249,7 +249,7 @@ drivers_merge_to_release_branch(ver_str) docs_clone() docs_get_api() docs_update_version(ver_str) -docs_merge_to_release_branch(v) +docs_merge_to_release_branch(ver_str) docs_build() clean_up() From 7e3739576f41c07e9f376bf136bcd10a1ee0993d Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 4 Aug 2020 17:07:54 +0200 Subject: [PATCH 182/205] add back library.proeprties --- library.properties | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 library.properties diff --git a/library.properties b/library.properties new file mode 100644 index 000000000..9c8c48826 --- /dev/null +++ b/library.properties @@ -0,0 +1,10 @@ +name=lvgl +version=7.0.2 +author=kisvegabor +maintainer=Pavel Brychta +sentence=Full-featured Graphics Library for Embedded Systems +paragraph=Powerful and easy-to-use embedded GUI with many widgets, advanced visual effects (opacity, antialiasing, animations) and low memory requirements (16K RAM, 64K Flash). +category=Display +url=https://lvgl.io +architectures=* +includes=lvgl.h From f36f8fe2539bd1a58f07d019a721a4dace05fc09 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 4 Aug 2020 17:11:19 +0200 Subject: [PATCH 183/205] Update library.properties --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 9c8c48826..1e1fad80a 100644 --- a/library.properties +++ b/library.properties @@ -1,7 +1,7 @@ name=lvgl version=7.0.2 author=kisvegabor -maintainer=Pavel Brychta +maintainer=kisvegabor,embeddedt,pete-pjb sentence=Full-featured Graphics Library for Embedded Systems paragraph=Powerful and easy-to-use embedded GUI with many widgets, advanced visual effects (opacity, antialiasing, animations) and low memory requirements (16K RAM, 64K Flash). category=Display From 5810baa0212b59dd9d0472a7878cde73436b1df3 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 4 Aug 2020 17:11:51 +0200 Subject: [PATCH 184/205] Update library.properties --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 1e1fad80a..712c77392 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=lvgl -version=7.0.2 +version=7.3.0 author=kisvegabor maintainer=kisvegabor,embeddedt,pete-pjb sentence=Full-featured Graphics Library for Embedded Systems From a0f338eb6fa131e1a4957f8f81a103e31c5d5e99 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 4 Aug 2020 17:33:39 +0200 Subject: [PATCH 185/205] update changlelog --- CHANGELOG.md | 6 ++++-- lvgl.h | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7960f5497..0ae4be1f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,13 @@ # Changelog -## v7.4.0 (planned on 18.08.2020) +## v7.4.0 (planned on 01.09.2020) *Available in the `dev` branch* -## v7.3.0 (planned on 04.08.2020) +## v7.3.1 (planned on 18.08.2020) *Available in the `master` branch* +## v7.3.0 (04.08.2020) + ### New features - Add `lv_task_get_next` - Add `lv_event_send_refresh`, `lv_event_send_refresh_recursive` to easily send `LV_EVENT_REFRESH` to object diff --git a/lvgl.h b/lvgl.h index 94a53df2c..bc3c00c70 100644 --- a/lvgl.h +++ b/lvgl.h @@ -78,8 +78,8 @@ extern "C" { /*Current version of LVGL*/ #define LVGL_VERSION_MAJOR 7 #define LVGL_VERSION_MINOR 3 -#define LVGL_VERSION_PATCH 0 -#define LVGL_VERSION_INFO "" +#define LVGL_VERSION_PATCH 1 +#define LVGL_VERSION_INFO "dev" /********************** * TYPEDEFS From 7caa2bf9ada2861e41a5dfa5d827fdd2de2d9541 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 4 Aug 2020 17:36:27 +0200 Subject: [PATCH 186/205] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eeb9f47f2..ae7335c8a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

LVGL - Light and Versatile Graphics Library

- +

From acb46aaed14ce607040771c2d9805140a5f482e4 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 4 Aug 2020 17:37:07 +0200 Subject: [PATCH 187/205] Update README.md --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index ae7335c8a..af3a4cde5 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,4 @@

LVGL - Light and Versatile Graphics Library

-

- - -

From b4955f0b6ead8c8a2b78ddb8c7773efed884d1d0 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 4 Aug 2020 18:43:34 +0200 Subject: [PATCH 188/205] Fix drawing value string twice Fixes #1704 --- CHANGELOG.md | 4 +++- src/lv_core/lv_obj.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ae4be1f3..a3a111429 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,9 @@ *Available in the `dev` branch* ## v7.3.1 (planned on 18.08.2020) -*Available in the `master` branch* + +### Bugfix +- Fix drawing value string twice ## v7.3.0 (04.08.2020) diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index a3051e529..7ba1c6173 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -3676,6 +3676,7 @@ static lv_design_res_t lv_obj_design(lv_obj_t * obj, const lv_area_t * clip_area draw_dsc.bg_opa = LV_OPA_TRANSP; draw_dsc.pattern_opa = LV_OPA_TRANSP; draw_dsc.shadow_opa = LV_OPA_TRANSP; + draw_dsc.value_opa = LV_OPA_TRANSP; lv_obj_init_draw_rect_dsc(obj, LV_OBJ_PART_MAIN, &draw_dsc); lv_coord_t w = lv_obj_get_style_transform_width(obj, LV_OBJ_PART_MAIN); From bd4db19aee5a1f5f50066838ab1aa2b9c4a0de69 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 4 Aug 2020 18:52:37 +0200 Subject: [PATCH 189/205] rename lv_chart_clear_serie to lv_chart_clear_series and lv_obj_align_origo to lv_obj_align_mid --- CHANGELOG.md | 3 ++- src/lv_api_map.h | 22 ++++++++++++++++++++++ src/lv_core/lv_obj.c | 24 ++++++++++++------------ src/lv_core/lv_obj.h | 8 ++++---- src/lv_widgets/lv_chart.c | 12 ++++++------ src/lv_widgets/lv_chart.h | 4 ++-- 6 files changed, 48 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3a111429..b0748227c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,9 @@ ## v7.3.1 (planned on 18.08.2020) -### Bugfix +### Bugfixes - Fix drawing value string twice +- Rename `lv_chart_clear_serie` to `lv_chart_clear_series` and `lv_obj_align_origo` to `lv_obj_align_mid` ## v7.3.0 (04.08.2020) diff --git a/src/lv_api_map.h b/src/lv_api_map.h index 926e9ec47..d8e904e8a 100644 --- a/src/lv_api_map.h +++ b/src/lv_api_map.h @@ -200,8 +200,30 @@ static inline void lv_chart_set_range(lv_obj_t * chart, lv_coord_t ymin, lv_coor { lv_chart_set_y_range(chart, LV_CHART_AXIS_PRIMARY_Y, ymin, ymax); } + + +static inline void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * series) +{ + lv_chart_clear_series(chart, series); +} + #endif +static inline void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs) +{ + lv_obj_align_mid(obj, base, align, x_ofs, y_ofs); +} + +static inline void lv_obj_align_origo_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs) +{ + lv_obj_align_mid_y(obj, base, align, x_ofs); +} + +static inline void lv_obj_align_origo_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t y_ofs) +{ + lv_obj_align_mid_y(obj, base, align, y_ofs); +} + #endif /*LV_USE_API_EXTENSION_V6*/ /********************** * MACROS diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 7ba1c6173..e8b50b0e1 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -87,7 +87,7 @@ static void refresh_children_style(lv_obj_t * obj); static void base_dir_refr_children(lv_obj_t * obj); static void obj_align_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set, lv_coord_t x_ofs, lv_coord_t y_ofs); -static void obj_align_origo_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set, +static void obj_align_mid_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set, lv_coord_t x_ofs, lv_coord_t y_ofs); #if LV_USE_ANIMATION static lv_style_trans_t * trans_create(lv_obj_t * obj, lv_style_property_t prop, uint8_t part, lv_state_t prev_state, @@ -911,7 +911,7 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co obj->realign.xofs = x_ofs; obj->realign.yofs = y_ofs; obj->realign.base = base; - obj->realign.origo_align = 0; + obj->realign.mid_align = 0; #endif } @@ -959,7 +959,7 @@ void lv_obj_align_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_ * @param x_ofs x coordinate offset after alignment * @param y_ofs y coordinate offset after alignment */ -void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs) +void lv_obj_align_mid(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs) { LV_ASSERT_OBJ(obj, LV_OBJX_NAME); @@ -970,7 +970,7 @@ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, LV_ASSERT_OBJ(base, LV_OBJX_NAME); - obj_align_origo_core(obj, base, align, true, true, x_ofs, y_ofs); + obj_align_mid_core(obj, base, align, true, true, x_ofs, y_ofs); #if LV_USE_OBJ_REALIGN /*Save the last align parameters to use them in `lv_obj_realign`*/ @@ -978,7 +978,7 @@ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, obj->realign.xofs = x_ofs; obj->realign.yofs = y_ofs; obj->realign.base = base; - obj->realign.origo_align = 1; + obj->realign.mid_align = 1; #endif } @@ -989,7 +989,7 @@ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, * @param align type of alignment (see 'lv_align_t' enum) * @param x_ofs x coordinate offset after alignment */ -void lv_obj_align_origo_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs) +void lv_obj_align_mid_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs) { LV_ASSERT_OBJ(obj, LV_OBJX_NAME); @@ -1000,7 +1000,7 @@ void lv_obj_align_origo_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t alig LV_ASSERT_OBJ(base, LV_OBJX_NAME); - obj_align_origo_core(obj, base, align, true, false, x_ofs, 0); + obj_align_mid_core(obj, base, align, true, false, x_ofs, 0); } @@ -1011,7 +1011,7 @@ void lv_obj_align_origo_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t alig * @param align type of alignment (see 'lv_align_t' enum) * @param y_ofs y coordinate offset after alignment */ -void lv_obj_align_origo_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t y_ofs) +void lv_obj_align_mid_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t y_ofs) { LV_ASSERT_OBJ(obj, LV_OBJX_NAME); @@ -1022,7 +1022,7 @@ void lv_obj_align_origo_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t alig LV_ASSERT_OBJ(base, LV_OBJX_NAME); - obj_align_origo_core(obj, base, align, true, false, 0, y_ofs); + obj_align_mid_core(obj, base, align, true, false, 0, y_ofs); } /** @@ -1034,8 +1034,8 @@ void lv_obj_realign(lv_obj_t * obj) LV_ASSERT_OBJ(obj, LV_OBJX_NAME); #if LV_USE_OBJ_REALIGN - if(obj->realign.origo_align) - lv_obj_align_origo(obj, obj->realign.base, obj->realign.align, obj->realign.xofs, obj->realign.yofs); + if(obj->realign.mid_align) + lv_obj_align_mid(obj, obj->realign.base, obj->realign.align, obj->realign.xofs, obj->realign.yofs); else lv_obj_align(obj, obj->realign.base, obj->realign.align, obj->realign.xofs, obj->realign.yofs); #else @@ -3893,7 +3893,7 @@ static void obj_align_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t ali else if(y_set) lv_obj_set_y(obj, new_pos.y); } -static void obj_align_origo_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set, +static void obj_align_mid_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set, lv_coord_t x_ofs, lv_coord_t y_ofs) { lv_coord_t new_x = lv_obj_get_x(obj); diff --git a/src/lv_core/lv_obj.h b/src/lv_core/lv_obj.h index 9815d3b9b..5d10eb3bc 100644 --- a/src/lv_core/lv_obj.h +++ b/src/lv_core/lv_obj.h @@ -162,7 +162,7 @@ typedef struct { lv_coord_t yofs; lv_align_t align; uint8_t auto_realign : 1; - uint8_t origo_align : 1; /**< 1: the origo (center of the object) was aligned with + uint8_t mid_align : 1; /**< 1: the origo (center of the object) was aligned with `lv_obj_align_origo`*/ } lv_realign_t; #endif @@ -494,7 +494,7 @@ void lv_obj_align_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_ * @param x_ofs x coordinate offset after alignment * @param y_ofs y coordinate offset after alignment */ -void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs); +void lv_obj_align_mid(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs); /** @@ -504,7 +504,7 @@ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, * @param align type of alignment (see 'lv_align_t' enum) * @param x_ofs x coordinate offset after alignment */ -void lv_obj_align_origo_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs); +void lv_obj_align_mid_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs); /** * Align an object's middle point to an other object vertically. @@ -513,7 +513,7 @@ void lv_obj_align_origo_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t alig * @param align type of alignment (see 'lv_align_t' enum) * @param y_ofs y coordinate offset after alignment */ -void lv_obj_align_origo_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t y_ofs); +void lv_obj_align_mid_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t y_ofs); /** * Realign the object based on the last `lv_obj_align` parameters. diff --git a/src/lv_widgets/lv_chart.c b/src/lv_widgets/lv_chart.c index d7308cf88..c77ecd858 100644 --- a/src/lv_widgets/lv_chart.c +++ b/src/lv_widgets/lv_chart.c @@ -207,23 +207,23 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color) /** * Clear the point of a series * @param chart pointer to a chart object - * @param serie pointer to the chart's series to clear + * @param series pointer to the chart's series to clear */ -void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * serie) +void lv_chart_clear_series(lv_obj_t * chart, lv_chart_series_t * series) { LV_ASSERT_OBJ(chart, LV_OBJX_NAME); - LV_ASSERT_NULL(serie); + LV_ASSERT_NULL(series); - if(chart == NULL || serie == NULL) return; + if(chart == NULL || series == NULL) return; lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); if(ext == NULL) return; uint32_t i; for(i = 0; i < ext->point_cnt; i++) { - serie->points[i] = LV_CHART_POINT_DEF; + series->points[i] = LV_CHART_POINT_DEF; } - serie->start_point = 0; + series->start_point = 0; } /*===================== diff --git a/src/lv_widgets/lv_chart.h b/src/lv_widgets/lv_chart.h index e35c696c7..6f3deed8d 100644 --- a/src/lv_widgets/lv_chart.h +++ b/src/lv_widgets/lv_chart.h @@ -139,9 +139,9 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color); /** * Clear the point of a series * @param chart pointer to a chart object - * @param serie pointer to the chart's series to clear + * @param series pointer to the chart's series to clear */ -void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * serie); +void lv_chart_clear_series(lv_obj_t * chart, lv_chart_series_t * series); /*===================== * Setter functions From 1f0a4918f21e8ae44f6825ed26eb4a4c8c84a6f7 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 5 Aug 2020 10:04:16 +0200 Subject: [PATCH 190/205] Update ROADMAP.md --- docs/ROADMAP.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index a30893f76..5affba5f7 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -31,4 +31,5 @@ Planned to September/October 2020 - Optmize font decompression - Switch to RGBA colors in styles - Need coverage report for tests -- Need static analize (via coverity.io or somehing else). +- Need static analize (via coverity.io or somehing else) +- Support dot_begin and dot_middle long modes for labels From 28f74bd91d2ca6597f74152ea9f095d51c78e076 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sven=20Krau=C3=9F?= Date: Wed, 5 Aug 2020 10:53:03 +0200 Subject: [PATCH 191/205] Make several descriptor parameters const, update parameter docs. Making the descriptor const allows to use static initialized variables. --- src/lv_draw/lv_draw_arc.c | 17 +++++++++-------- src/lv_draw/lv_draw_arc.h | 6 +++--- src/lv_draw/lv_draw_img.c | 24 ++++++++---------------- src/lv_draw/lv_draw_img.h | 8 ++------ src/lv_draw/lv_draw_label.c | 6 ++++-- src/lv_draw/lv_draw_label.h | 3 ++- src/lv_draw/lv_draw_line.c | 5 ++--- src/lv_draw/lv_draw_line.h | 7 +++---- src/lv_draw/lv_draw_rect.c | 34 ++++++++++++++++++---------------- src/lv_draw/lv_draw_rect.h | 4 ++-- src/lv_draw/lv_draw_triangle.c | 4 ++-- src/lv_draw/lv_draw_triangle.h | 4 ++-- src/lv_draw/lv_img_buf.c | 2 +- src/lv_draw/lv_img_buf.h | 2 +- src/lv_widgets/lv_canvas.c | 21 +++++++++++---------- src/lv_widgets/lv_canvas.h | 24 ++++++++++++++---------- 16 files changed, 84 insertions(+), 87 deletions(-) diff --git a/src/lv_draw/lv_draw_arc.c b/src/lv_draw/lv_draw_arc.c index 27f6f1667..bcf94d000 100644 --- a/src/lv_draw/lv_draw_arc.c +++ b/src/lv_draw/lv_draw_arc.c @@ -65,17 +65,18 @@ static void get_rounded_area(int16_t angle, lv_coord_t radius, uint8_t tickness, * @param mask the arc will be drawn only in this mask * @param start_angle the start angle of the arc (0 deg on the bottom, 90 deg on the right) * @param end_angle the end angle of the arc - * @param style style of the arc (`body.thickness`, `body.main_color`, `body.opa` is used) - * @param opa_scale scale down all opacities by the factor + * @param clip_area the arc will be drawn only in this area + * @param dsc pointer to an initialized `lv_draw_line_dsc_t` variable */ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uint16_t start_angle, uint16_t end_angle, - const lv_area_t * clip_area, lv_draw_line_dsc_t * dsc) + const lv_area_t * clip_area, const lv_draw_line_dsc_t * dsc) { if(dsc->opa <= LV_OPA_MIN) return; if(dsc->width == 0) return; if(start_angle == end_angle) return; - if(dsc->width > radius) dsc->width = radius; + lv_style_int_t width = dsc->width; + if(width > radius) width = radius; lv_draw_rect_dsc_t cir_dsc; lv_draw_rect_dsc_init(&cir_dsc); @@ -83,7 +84,7 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin cir_dsc.bg_opa = LV_OPA_TRANSP; cir_dsc.border_opa = dsc->opa; cir_dsc.border_color = dsc->color; - cir_dsc.border_width = dsc->width; + cir_dsc.border_width = width; cir_dsc.border_blend_mode = dsc->blend_mode; lv_area_t area; @@ -123,7 +124,7 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin q_dsc.end_angle = end_angle; q_dsc.start_quarter = (start_angle / 90) & 0x3; q_dsc.end_quarter = (end_angle / 90) & 0x3; - q_dsc.width = dsc->width; + q_dsc.width = width; q_dsc.draw_dsc = &cir_dsc; q_dsc.draw_area = &area; q_dsc.clip_area = clip_area; @@ -146,7 +147,7 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin lv_area_t round_area; if(dsc->round_start) { - get_rounded_area(start_angle, radius, dsc->width, &round_area); + get_rounded_area(start_angle, radius, width, &round_area); round_area.x1 += center_x; round_area.x2 += center_x; round_area.y1 += center_y; @@ -156,7 +157,7 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin } if(dsc->round_end) { - get_rounded_area(end_angle, radius, dsc->width, &round_area); + get_rounded_area(end_angle, radius, width, &round_area); round_area.x1 += center_x; round_area.x2 += center_x; round_area.y1 += center_y; diff --git a/src/lv_draw/lv_draw_arc.h b/src/lv_draw/lv_draw_arc.h index 7e1352eb9..a4b182410 100644 --- a/src/lv_draw/lv_draw_arc.h +++ b/src/lv_draw/lv_draw_arc.h @@ -35,11 +35,11 @@ extern "C" { * @param mask the arc will be drawn only in this mask * @param start_angle the start angle of the arc (0 deg on the bottom, 90 deg on the right) * @param end_angle the end angle of the arc - * @param style style of the arc (`body.thickness`, `body.main_color`, `body.opa` is used) - * @param opa_scale scale down all opacities by the factor + * @param clip_area the arc will be drawn only in this area + * @param dsc pointer to an initialized `lv_draw_line_dsc_t` variable */ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uint16_t start_angle, uint16_t end_angle, - const lv_area_t * clip_area, lv_draw_line_dsc_t * dsc); + const lv_area_t * clip_area, const lv_draw_line_dsc_t * dsc); /********************** * MACROS diff --git a/src/lv_draw/lv_draw_img.c b/src/lv_draw/lv_draw_img.c index b447d615e..47615724a 100644 --- a/src/lv_draw/lv_draw_img.c +++ b/src/lv_draw/lv_draw_img.c @@ -29,11 +29,11 @@ **********************/ LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * clip_area, const void * src, - lv_draw_img_dsc_t * draw_dsc); + const lv_draw_img_dsc_t * draw_dsc); LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area, const uint8_t * map_p, - lv_draw_img_dsc_t * draw_dsc, + const lv_draw_img_dsc_t * draw_dsc, bool chroma_key, bool alpha_byte); static void show_error(const lv_area_t * coords, const lv_area_t * clip_area, const char * msg); @@ -65,13 +65,9 @@ void lv_draw_img_dsc_init(lv_draw_img_dsc_t * dsc) * @param coords the coordinates of the image * @param mask the image will be drawn only in this area * @param src pointer to a lv_color_t array which contains the pixels of the image - * @param style style of the image - * @param angle rotation angle of the image - * @param center rotation center of the image - * @param antialias anti-alias transformations (rotate, zoom) or not - * @param opa_scale scale down all opacities by the factor + * @param dsc pointer to an initialized `lv_draw_img_dsc_t` variable */ -void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * src, lv_draw_img_dsc_t * dsc) +void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * src, const lv_draw_img_dsc_t * dsc) { if(src == NULL) { LV_LOG_WARN("Image draw: src is NULL"); @@ -232,7 +228,7 @@ lv_img_src_t lv_img_src_get_type(const void * src) LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * clip_area, const void * src, - lv_draw_img_dsc_t * draw_dsc) + const lv_draw_img_dsc_t * draw_dsc) { if(draw_dsc->opa <= LV_OPA_MIN) return LV_RES_OK; @@ -327,18 +323,14 @@ LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords, * @param cords_p coordinates the color map * @param mask_p the map will drawn only on this area (truncated to VDB area) * @param map_p pointer to a lv_color_t array - * @param opa opacity of the map + * @param draw_dsc pointer to an initialized `lv_draw_img_dsc_t` variable * @param chroma_keyed true: enable transparency of LV_IMG_LV_COLOR_TRANSP color pixels * @param alpha_byte true: extra alpha byte is inserted for every pixel - * @param style style of the image - * @param angle angle in degree - * @param pivot center of rotation - * @param zoom zoom factor - * @param antialias anti-alias transformations (rotate, zoom) or not */ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area, const uint8_t * map_p, - lv_draw_img_dsc_t * draw_dsc, bool chroma_key, bool alpha_byte) + const lv_draw_img_dsc_t * draw_dsc, + bool chroma_key, bool alpha_byte) { /* Use the clip area as draw area*/ lv_area_t draw_area; diff --git a/src/lv_draw/lv_draw_img.h b/src/lv_draw/lv_draw_img.h index 735777684..e4531d725 100644 --- a/src/lv_draw/lv_draw_img.h +++ b/src/lv_draw/lv_draw_img.h @@ -53,13 +53,9 @@ void lv_draw_img_dsc_init(lv_draw_img_dsc_t * dsc); * @param coords the coordinates of the image * @param mask the image will be drawn only in this area * @param src pointer to a lv_color_t array which contains the pixels of the image - * @param style style of the image - * @param angle rotation angle of the image - * @param center rotation center of the image - * @param antialias anti-alias transformations (rotate, zoom) or not - * @param opa_scale scale down all opacities by the factor + * @param dsc pointer to an initialized `lv_draw_img_dsc_t` variable */ -void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * src, lv_draw_img_dsc_t * dsc); +void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * src, const lv_draw_img_dsc_t * dsc); /** * Get the type of an image source diff --git a/src/lv_draw/lv_draw_label.c b/src/lv_draw/lv_draw_label.c index 136b4d0d7..4bdcb65f4 100644 --- a/src/lv_draw/lv_draw_label.c +++ b/src/lv_draw/lv_draw_label.c @@ -111,8 +111,10 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc) * @param hint pointer to a `lv_draw_label_hint_t` variable. * It is managed by the drawer to speed up the drawing of very long texts (thousands of lines). */ -LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_label_dsc_t * dsc, - const char * txt, lv_draw_label_hint_t * hint) +LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, + const lv_draw_label_dsc_t * dsc, + const char * txt, + lv_draw_label_hint_t * hint) { if(dsc->opa <= LV_OPA_MIN) return; diff --git a/src/lv_draw/lv_draw_label.h b/src/lv_draw/lv_draw_label.h index a81aeae74..b28381002 100644 --- a/src/lv_draw/lv_draw_label.h +++ b/src/lv_draw/lv_draw_label.h @@ -77,7 +77,8 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc); * @param hint pointer to a `lv_draw_label_hint_t` variable. * It is managed by the drawer to speed up the drawing of very long texts (thousands of lines). */ -LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_label_dsc_t * dsc, +LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, + const lv_draw_label_dsc_t * dsc, const char * txt, lv_draw_label_hint_t * hint); //! @endcond diff --git a/src/lv_draw/lv_draw_line.c b/src/lv_draw/lv_draw_line.c index 0c84b2c49..38e29cdfb 100644 --- a/src/lv_draw/lv_draw_line.c +++ b/src/lv_draw/lv_draw_line.c @@ -58,9 +58,8 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc) * Draw a line * @param point1 first point of the line * @param point2 second point of the line - * @param mask the line will be drawn only on this area - * @param style pointer to a line's style - * @param opa_scale scale down all opacities by the factor + * @param clip the line will be drawn only in this area + * @param dsc pointer to an initialized `lv_draw_line_dsc_t` variable */ LV_ATTRIBUTE_FAST_MEM void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip, const lv_draw_line_dsc_t * dsc) diff --git a/src/lv_draw/lv_draw_line.h b/src/lv_draw/lv_draw_line.h index 83abe6818..eb4bbaf58 100644 --- a/src/lv_draw/lv_draw_line.h +++ b/src/lv_draw/lv_draw_line.h @@ -43,11 +43,10 @@ typedef struct { * Draw a line * @param point1 first point of the line * @param point2 second point of the line - * @param mask the line will be drawn only on this area - * @param style pointer to a line's style - * @param opa_scale scale down all opacities by the factor + * @param clip the line will be drawn only in this area + * @param dsc pointer to an initialized `lv_draw_line_dsc_t` variable */ -LV_ATTRIBUTE_FAST_MEM void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * mask, +LV_ATTRIBUTE_FAST_MEM void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip, const lv_draw_line_dsc_t * dsc); LV_ATTRIBUTE_FAST_MEM void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc); diff --git a/src/lv_draw/lv_draw_rect.c b/src/lv_draw/lv_draw_rect.c index 47ed3dc70..34b033428 100644 --- a/src/lv_draw/lv_draw_rect.c +++ b/src/lv_draw/lv_draw_rect.c @@ -27,20 +27,21 @@ /********************** * STATIC PROTOTYPES **********************/ -LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc); +LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, + const lv_draw_rect_dsc_t * dsc); LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv_area_t * clip, - lv_draw_rect_dsc_t * dsc); -static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc); -LV_ATTRIBUTE_FAST_MEM static inline lv_color_t grad_get(lv_draw_rect_dsc_t * dsc, lv_coord_t s, lv_coord_t i); + const lv_draw_rect_dsc_t * dsc); +static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc); +LV_ATTRIBUTE_FAST_MEM static inline lv_color_t grad_get(const lv_draw_rect_dsc_t * dsc, lv_coord_t s, lv_coord_t i); #if LV_USE_SHADOW LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, - lv_draw_rect_dsc_t * dsc); + const lv_draw_rect_dsc_t * dsc); LV_ATTRIBUTE_FAST_MEM static void shadow_draw_corner_buf(const lv_area_t * coords, uint16_t * sh_buf, lv_coord_t s, lv_coord_t r); LV_ATTRIBUTE_FAST_MEM static void shadow_blur_corner(lv_coord_t size, lv_coord_t sw, uint16_t * sh_ups_buf); #endif -static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc); -static void draw_value(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc); +static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc); +static void draw_value(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc); /********************** * STATIC VARIABLES @@ -85,9 +86,9 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc) * Draw a rectangle * @param coords the coordinates of the rectangle * @param mask the rectangle will be drawn only in this mask - * @param style pointer to a style + * @param dsc pointer to an initialized `lv_draw_rect_dsc_t` variable */ -void lv_draw_rect(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc) +void lv_draw_rect(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc) { if(lv_area_get_height(coords) < 1 || lv_area_get_width(coords) < 1) return; #if LV_USE_SHADOW @@ -142,7 +143,8 @@ void lv_draw_px(const lv_point_t * point, const lv_area_t * clip_area, const lv_ * STATIC FUNCTIONS **********************/ -LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc) +LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, + const lv_draw_rect_dsc_t * dsc) { if(dsc->bg_opa <= LV_OPA_MIN) return; @@ -364,7 +366,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_are } LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv_area_t * clip, - lv_draw_rect_dsc_t * dsc) + const lv_draw_rect_dsc_t * dsc) { if(dsc->border_opa <= LV_OPA_MIN) return; if(dsc->border_width == 0) return; @@ -581,7 +583,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv _lv_mem_buf_release(mask_buf); } -LV_ATTRIBUTE_FAST_MEM static inline lv_color_t grad_get(lv_draw_rect_dsc_t * dsc, lv_coord_t s, lv_coord_t i) +LV_ATTRIBUTE_FAST_MEM static inline lv_color_t grad_get(const lv_draw_rect_dsc_t * dsc, lv_coord_t s, lv_coord_t i) { int32_t min = (dsc->bg_main_color_stop * s) >> 8; if(i <= min) return dsc->bg_color; @@ -598,7 +600,7 @@ LV_ATTRIBUTE_FAST_MEM static inline lv_color_t grad_get(lv_draw_rect_dsc_t * dsc #if LV_USE_SHADOW LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, - lv_draw_rect_dsc_t * dsc) + const lv_draw_rect_dsc_t * dsc) { /*Check whether the shadow is visible*/ if(dsc->shadow_width == 0) return; @@ -1226,7 +1228,7 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_blur_corner(lv_coord_t size, lv_coord_t #endif -static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc) +static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc) { if(dsc->outline_opa <= LV_OPA_MIN) return; if(dsc->outline_width == 0) return; @@ -1424,7 +1426,7 @@ static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_dr _lv_mem_buf_release(mask_buf); } -static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc) +static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc) { if(dsc->pattern_image == NULL) return; if(dsc->pattern_opa <= LV_OPA_MIN) return; @@ -1526,7 +1528,7 @@ static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, lv_dr } -static void draw_value(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc) +static void draw_value(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc) { if(dsc->value_str == NULL) return; if(dsc->value_opa <= LV_OPA_MIN) return; diff --git a/src/lv_draw/lv_draw_rect.h b/src/lv_draw/lv_draw_rect.h index 3b6dc5bf3..17f4a7248 100644 --- a/src/lv_draw/lv_draw_rect.h +++ b/src/lv_draw/lv_draw_rect.h @@ -92,9 +92,9 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc); * Draw a rectangle * @param coords the coordinates of the rectangle * @param mask the rectangle will be drawn only in this mask - * @param style pointer to a style + * @param dsc pointer to an initialized `lv_draw_rect_dsc_t` variable */ -void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, lv_draw_rect_dsc_t * dsc); +void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_draw_rect_dsc_t * dsc); /** * Draw a pixel diff --git a/src/lv_draw/lv_draw_triangle.c b/src/lv_draw/lv_draw_triangle.c index 72a4a7fe2..08bcf6af2 100644 --- a/src/lv_draw/lv_draw_triangle.c +++ b/src/lv_draw/lv_draw_triangle.c @@ -40,7 +40,7 @@ * @param clip_area the triangle will be drawn only in this area * @param draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable */ -void lv_draw_triangle(const lv_point_t points[], const lv_area_t * clip_area, lv_draw_rect_dsc_t * draw_dsc) +void lv_draw_triangle(const lv_point_t points[], const lv_area_t * clip_area, const lv_draw_rect_dsc_t * draw_dsc) { lv_draw_polygon(points, 3, clip_area, draw_dsc); } @@ -53,7 +53,7 @@ void lv_draw_triangle(const lv_point_t points[], const lv_area_t * clip_area, lv * @param draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable */ void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_area_t * clip_area, - lv_draw_rect_dsc_t * draw_dsc) + const lv_draw_rect_dsc_t * draw_dsc) { if(point_cnt < 3) return; if(points == NULL) return; diff --git a/src/lv_draw/lv_draw_triangle.h b/src/lv_draw/lv_draw_triangle.h index 242ce30f9..64a7b1c81 100644 --- a/src/lv_draw/lv_draw_triangle.h +++ b/src/lv_draw/lv_draw_triangle.h @@ -33,7 +33,7 @@ extern "C" { * @param clip_area the triangle will be drawn only in this area * @param draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable */ -void lv_draw_triangle(const lv_point_t points[], const lv_area_t * clip, lv_draw_rect_dsc_t * draw_dsc); +void lv_draw_triangle(const lv_point_t points[], const lv_area_t * clip, const lv_draw_rect_dsc_t * draw_dsc); /** * Draw a polygon. Only convex polygons are supported. @@ -43,7 +43,7 @@ void lv_draw_triangle(const lv_point_t points[], const lv_area_t * clip, lv_draw * @param draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable */ void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_area_t * mask, - lv_draw_rect_dsc_t * draw_dsc); + const lv_draw_rect_dsc_t * draw_dsc); /********************** * MACROS diff --git a/src/lv_draw/lv_img_buf.c b/src/lv_draw/lv_img_buf.c index 8838c32ab..741ad0439 100644 --- a/src/lv_draw/lv_img_buf.c +++ b/src/lv_draw/lv_img_buf.c @@ -468,7 +468,7 @@ void _lv_img_buf_transform_init(lv_img_transform_dsc_t * dsc) * @param pivot x,y pivot coordinates of rotation */ void _lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t h, int16_t angle, uint16_t zoom, - lv_point_t * pivot) + const lv_point_t * pivot) { #if LV_USE_IMG_TRANSFORM if(angle == 0 && zoom == LV_IMG_ZOOM_NONE) { diff --git a/src/lv_draw/lv_img_buf.h b/src/lv_draw/lv_img_buf.h index 204f3c1d8..afde70c55 100644 --- a/src/lv_draw/lv_img_buf.h +++ b/src/lv_draw/lv_img_buf.h @@ -380,7 +380,7 @@ static inline bool _lv_img_buf_transform(lv_img_transform_dsc_t * dsc, lv_coord_ * @param pivot x,y pivot coordinates of rotation */ void _lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t h, int16_t angle, uint16_t zoom, - lv_point_t * pivot); + const lv_point_t * pivot); /********************** * MACROS diff --git a/src/lv_widgets/lv_canvas.c b/src/lv_widgets/lv_canvas.c index d16d40a22..14fb5e023 100644 --- a/src/lv_widgets/lv_canvas.c +++ b/src/lv_widgets/lv_canvas.c @@ -657,6 +657,7 @@ void lv_canvas_blur_ver(lv_obj_t * canvas, const lv_area_t * area, uint16_t r) * Fill the canvas with color * @param canvas pointer to a canvas * @param color the background color + * @param opa the desired opacity */ void lv_canvas_fill_bg(lv_obj_t * canvas, lv_color_t color, lv_opa_t opa) { @@ -694,10 +695,10 @@ void lv_canvas_fill_bg(lv_obj_t * canvas, lv_color_t color, lv_opa_t opa) * @param y top coordinate of the rectangle * @param w width of the rectangle * @param h height of the rectangle - * @param style style of the rectangle (`body` properties are used except `padding`) + * @param rect_dsc descriptor of the rectangle */ void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, - lv_draw_rect_dsc_t * rect_dsc) + const lv_draw_rect_dsc_t * rect_dsc) { LV_ASSERT_OBJ(canvas, LV_OBJX_NAME); @@ -763,7 +764,7 @@ void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord * @param x left coordinate of the text * @param y top coordinate of the text * @param max_w max width of the text. The text will be wrapped to fit into this size - * @param style style of the text (`text` properties are used) + * @param label_draw_dsc pointer to a valid label descriptor `lv_draw_label_dsc_t` * @param txt text to display * @param align align of the text (`LV_LABEL_ALIGN_LEFT/RIGHT/CENTER`) */ @@ -841,10 +842,10 @@ void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord * Draw an image on the canvas * @param canvas pointer to a canvas object * @param src image source. Can be a pointer an `lv_img_dsc_t` variable or a path an image. - * @param style style of the image (`image` properties are used) + * @param img_draw_dsc pointer to a valid label descriptor `lv_draw_img_dsc_t` */ void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const void * src, - lv_draw_img_dsc_t * img_draw_dsc) + const lv_draw_img_dsc_t * img_draw_dsc) { LV_ASSERT_OBJ(canvas, LV_OBJX_NAME); @@ -906,7 +907,7 @@ void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const voi * @param canvas pointer to a canvas object * @param points point of the line * @param point_cnt number of points - * @param style style of the line (`line` properties are used) + * @param line_draw_dsc pointer to an initialized `lv_draw_line_dsc_t` variable */ void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t points[], uint32_t point_cnt, const lv_draw_line_dsc_t * line_draw_dsc) @@ -969,10 +970,10 @@ void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t points[], uint32_t * @param canvas pointer to a canvas object * @param points point of the polygon * @param point_cnt number of points - * @param style style of the polygon (`body.main_color` and `body.opa` is used) + * @param poly_draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable */ void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t points[], uint32_t point_cnt, - lv_draw_rect_dsc_t * poly_draw_dsc) + const lv_draw_rect_dsc_t * poly_draw_dsc) { LV_ASSERT_OBJ(canvas, LV_OBJX_NAME); @@ -1033,10 +1034,10 @@ void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t points[], uint32 * @param r radius of the arc * @param start_angle start angle in degrees * @param end_angle end angle in degrees - * @param style style of the polygon (`body.main_color` and `body.opa` is used) + * @param arc_draw_dsc pointer to an initialized `lv_draw_line_dsc_t` variable */ void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t r, int32_t start_angle, - int32_t end_angle, lv_draw_line_dsc_t * arc_draw_dsc) + int32_t end_angle, const lv_draw_line_dsc_t * arc_draw_dsc) { LV_ASSERT_OBJ(canvas, LV_OBJX_NAME); diff --git a/src/lv_widgets/lv_canvas.h b/src/lv_widgets/lv_canvas.h index 14958c1d8..de1a26bf4 100644 --- a/src/lv_widgets/lv_canvas.h +++ b/src/lv_widgets/lv_canvas.h @@ -153,6 +153,7 @@ void lv_canvas_transform(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle, u /** * Apply horizontal blur on the canvas * @param canvas pointer to a canvas object + * @param area the area to blur. If `NULL` the whole canvas will be blurred. * @param r radius of the blur */ void lv_canvas_blur_hor(lv_obj_t * canvas, const lv_area_t * area, uint16_t r); @@ -169,6 +170,7 @@ void lv_canvas_blur_ver(lv_obj_t * canvas, const lv_area_t * area, uint16_t r); * Fill the canvas with color * @param canvas pointer to a canvas * @param color the background color + * @param opa the desired opacity */ void lv_canvas_fill_bg(lv_obj_t * canvas, lv_color_t color, lv_opa_t opa); @@ -179,10 +181,10 @@ void lv_canvas_fill_bg(lv_obj_t * canvas, lv_color_t color, lv_opa_t opa); * @param y top coordinate of the rectangle * @param w width of the rectangle * @param h height of the rectangle - * @param style style of the rectangle (`body` properties are used except `padding`) + * @param rect_dsc descriptor of the rectangle */ void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, - lv_draw_rect_dsc_t * rect_dsc); + const lv_draw_rect_dsc_t * rect_dsc); /** * Draw a text on the canvas. @@ -190,7 +192,7 @@ void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord * @param x left coordinate of the text * @param y top coordinate of the text * @param max_w max width of the text. The text will be wrapped to fit into this size - * @param style style of the text (`text` properties are used) + * @param label_draw_dsc pointer to a valid label descriptor `lv_draw_label_dsc_t` * @param txt text to display * @param align align of the text (`LV_LABEL_ALIGN_LEFT/RIGHT/CENTER`) */ @@ -201,18 +203,20 @@ void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord /** * Draw an image on the canvas * @param canvas pointer to a canvas object + * @param x left coordinate of the image + * @param y top coordinate of the image * @param src image source. Can be a pointer an `lv_img_dsc_t` variable or a path an image. - * @param style style of the image (`image` properties are used) + * @param img_draw_dsc pointer to a valid label descriptor `lv_draw_img_dsc_t` */ void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const void * src, - lv_draw_img_dsc_t * img_draw_dsc); + const lv_draw_img_dsc_t * img_draw_dsc); /** * Draw a line on the canvas * @param canvas pointer to a canvas object * @param points point of the line * @param point_cnt number of points - * @param style style of the line (`line` properties are used) + * @param line_draw_dsc pointer to an initialized `lv_draw_line_dsc_t` variable */ void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t points[], uint32_t point_cnt, const lv_draw_line_dsc_t * line_draw_dsc); @@ -222,10 +226,10 @@ void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t points[], uint32_t * @param canvas pointer to a canvas object * @param points point of the polygon * @param point_cnt number of points - * @param style style of the polygon (`body.main_color` and `body.opa` is used) + * @param poly_draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable */ void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t points[], uint32_t point_cnt, - lv_draw_rect_dsc_t * poly_draw_dsc); + const lv_draw_rect_dsc_t * poly_draw_dsc); /** * Draw an arc on the canvas @@ -235,10 +239,10 @@ void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t points[], uint32 * @param r radius of the arc * @param start_angle start angle in degrees * @param end_angle end angle in degrees - * @param style style of the polygon (`body.main_color` and `body.opa` is used) + * @param arc_draw_dsc pointer to an initialized `lv_draw_line_dsc_t` variable */ void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t r, int32_t start_angle, - int32_t end_angle, lv_draw_line_dsc_t * arc_draw_dsc); + int32_t end_angle, const lv_draw_line_dsc_t * arc_draw_dsc); /********************** * MACROS From 7827d948d8d26863b71a372b97bbd2077512700a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sven=20Krau=C3=9F?= Date: Wed, 5 Aug 2020 11:18:56 +0200 Subject: [PATCH 192/205] Fix evaluation of return value --- src/lv_draw/lv_img_decoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_draw/lv_img_decoder.c b/src/lv_draw/lv_img_decoder.c index 0c2f67d72..57e99e297 100644 --- a/src/lv_draw/lv_img_decoder.c +++ b/src/lv_draw/lv_img_decoder.c @@ -559,7 +559,7 @@ static lv_res_t lv_img_decoder_built_in_line_true_color(lv_img_decoder_dsc_t * d } uint32_t btr = len * (px_size >> 3); uint32_t br = 0; - lv_fs_read(user_data->f, buf, btr, &br); + res = lv_fs_read(user_data->f, buf, btr, &br); if(res != LV_FS_RES_OK || btr != br) { LV_LOG_WARN("Built-in image decoder read failed"); return LV_RES_INV; From 21985e9a146b246acad9b3b0030cc03f798ef7ff Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 6 Aug 2020 11:40:30 +0200 Subject: [PATCH 193/205] Update FUNDING.yml --- .github/FUNDING.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 1b34d7088..0c08541e1 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1 +1 @@ -custom: ["https://www.paypal.com/paypalme/my/profile"] +custom: ["https://paypal.me/littlevgl?locale.x=en_US"] From 7af20516a51dd8a1ab76e039a084a110941cb240 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 5 Aug 2020 11:06:48 +0200 Subject: [PATCH 194/205] add linemeter's mirror feature again the drawing part was somehow removed --- CHANGELOG.md | 1 + src/lv_widgets/lv_linemeter.c | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0748227c..62fc6fec0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ ### Bugfixes - Fix drawing value string twice - Rename `lv_chart_clear_serie` to `lv_chart_clear_series` and `lv_obj_align_origo` to `lv_obj_align_mid` +- Add linemeter's mirror feature again ## v7.3.0 (04.08.2020) diff --git a/src/lv_widgets/lv_linemeter.c b/src/lv_widgets/lv_linemeter.c index c8e7ae724..d8043f876 100644 --- a/src/lv_widgets/lv_linemeter.c +++ b/src/lv_widgets/lv_linemeter.c @@ -392,15 +392,15 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin lv_coord_t x_ofs = lmeter->coords.x1 + r_out + left; lv_coord_t y_ofs = lmeter->coords.y1 + r_out + top; int16_t angle_ofs = ext->angle_ofs + 90 + (360 - ext->scale_angle) / 2; - int16_t level = - (int32_t)((int32_t)(ext->cur_value - ext->min_value) * (ext->line_cnt - 1)) / (ext->max_value - ext->min_value); + int16_t level = ext->mirrored ? + (int32_t)((int32_t)(ext->max_value - ext->cur_value) * (ext->line_cnt - 1)) / (ext->max_value - ext->min_value) : + (int32_t)((int32_t)(ext->cur_value - ext->min_value) * (ext->line_cnt - 1)) / (ext->max_value - ext->min_value); uint8_t i; lv_color_t main_color = lv_obj_get_style_line_color(lmeter, part); lv_color_t grad_color = lv_obj_get_style_scale_grad_color(lmeter, part); lv_color_t end_color = lv_obj_get_style_scale_end_color(lmeter, part); - lv_draw_line_dsc_t line_dsc; lv_draw_line_dsc_init(&line_dsc); lv_obj_init_draw_line_dsc(lmeter, part, &line_dsc); @@ -520,11 +520,11 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin p1.y = y_out_extra; /* Set the color of the lines */ - if(i > level) { + uint16_t index = ext->mirrored ? ext->line_cnt - i : i; + if((!ext->mirrored && i >= level) || (ext->mirrored && i <= level)) { line_dsc.color = end_color; line_dsc.width = end_line_width; - } - else { + } else { line_dsc.color = lv_color_mix(grad_color, main_color, (255 * i) / ext->line_cnt); } From cda21694c48f163b99a5abe9c1047ee9a11d428d Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 6 Aug 2020 14:48:23 +0200 Subject: [PATCH 195/205] Fix text decor (udnerline strikethrough) with older versions of font converter --- CHANGELOG.md | 1 + src/lv_draw/lv_draw_label.c | 3 +-- src/lv_themes/lv_theme_empty.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62fc6fec0..2a92f840d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Fix drawing value string twice - Rename `lv_chart_clear_serie` to `lv_chart_clear_series` and `lv_obj_align_origo` to `lv_obj_align_mid` - Add linemeter's mirror feature again +- Fix text decor (udnerline strikethrough) with older versions of font converter ## v7.3.0 (04.08.2020) diff --git a/src/lv_draw/lv_draw_label.c b/src/lv_draw/lv_draw_label.c index 3f5ac09da..4e2c7f922 100644 --- a/src/lv_draw/lv_draw_label.c +++ b/src/lv_draw/lv_draw_label.c @@ -214,11 +214,10 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area sel_end = tmp; } lv_draw_line_dsc_t line_dsc; - dsc->decor = LV_TEXT_DECOR_UNDERLINE; if((dsc->decor & LV_TEXT_DECOR_UNDERLINE) || (dsc->decor & LV_TEXT_DECOR_STRIKETHROUGH)) { lv_draw_line_dsc_init(&line_dsc); line_dsc.color = dsc->color; - line_dsc.width = font->underline_thickness; + line_dsc.width = font->underline_thickness ? font->underline_thickness : LV_MATH_MAX(font->line_height / 10, 1); line_dsc.opa = dsc->opa; line_dsc.blend_mode = dsc->blend_mode; } diff --git a/src/lv_themes/lv_theme_empty.c b/src/lv_themes/lv_theme_empty.c index 821bbd510..6900ef23c 100644 --- a/src/lv_themes/lv_theme_empty.c +++ b/src/lv_themes/lv_theme_empty.c @@ -95,7 +95,7 @@ lv_theme_t * lv_theme_empty_init(lv_color_t color_primary, lv_color_t color_seco } -void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) +static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) { LV_UNUSED(th); if(name == LV_THEME_SCR) { From 5d981f56adc0505cf992a6327431912c68a13dc4 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 6 Aug 2020 14:54:51 +0200 Subject: [PATCH 196/205] remove unused variable --- src/lv_widgets/lv_linemeter.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lv_widgets/lv_linemeter.c b/src/lv_widgets/lv_linemeter.c index d8043f876..0de65871c 100644 --- a/src/lv_widgets/lv_linemeter.c +++ b/src/lv_widgets/lv_linemeter.c @@ -520,7 +520,6 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin p1.y = y_out_extra; /* Set the color of the lines */ - uint16_t index = ext->mirrored ? ext->line_cnt - i : i; if((!ext->mirrored && i >= level) || (ext->mirrored && i <= level)) { line_dsc.color = end_color; line_dsc.width = end_line_width; From 81caeaa7253fdf76c1e1930a21bad4443428c2ba Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Fri, 7 Aug 2020 07:31:31 -0400 Subject: [PATCH 197/205] Fix `lv_obj_set_height_fit` --- src/lv_core/lv_obj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index e8b50b0e1..c20904733 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -856,7 +856,7 @@ void lv_obj_set_height_fit(lv_obj_t * obj, lv_coord_t h) lv_style_int_t ptop = lv_obj_get_style_pad_top(obj, LV_OBJ_PART_MAIN); lv_style_int_t pbottom = lv_obj_get_style_pad_bottom(obj, LV_OBJ_PART_MAIN); - lv_obj_set_width(obj, h - ptop - pbottom); + lv_obj_set_height(obj, h - ptop - pbottom); } /** From 90be42c4931039a63821b7bd0e9e6a65bc563f44 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sat, 8 Aug 2020 16:21:51 +0200 Subject: [PATCH 198/205] Fix setting local style property multiple times Realted to https://forum.lvgl.io/t/how-to-change-button-object-color-on-demand/2922/2 --- CHANGELOG.md | 1 + src/lv_core/lv_style.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a92f840d..28a0c4fac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Rename `lv_chart_clear_serie` to `lv_chart_clear_series` and `lv_obj_align_origo` to `lv_obj_align_mid` - Add linemeter's mirror feature again - Fix text decor (udnerline strikethrough) with older versions of font converter +- Fix setting local style property multiple times ## v7.3.0 (04.08.2020) diff --git a/src/lv_core/lv_style.c b/src/lv_core/lv_style.c index df1debc4d..887c4733b 100644 --- a/src/lv_core/lv_style.c +++ b/src/lv_core/lv_style.c @@ -1104,7 +1104,7 @@ static lv_style_t * get_alloc_local_style(lv_style_list_t * list) { LV_ASSERT_STYLE_LIST(list); - if(list->has_local) return lv_style_list_get_style(list, 0); + if(list->has_local) return lv_style_list_get_style(list, list->has_trans ? 1 : 0); lv_style_t * local_style = lv_mem_alloc(sizeof(lv_style_t)); LV_ASSERT_MEM(local_style); From b6c18ed1717059734a868dcd1123c6527ddf7758 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 9 Aug 2020 12:41:25 +0200 Subject: [PATCH 199/205] Update ROADMAP.md --- docs/ROADMAP.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 5affba5f7..9b5914e58 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -23,6 +23,10 @@ Planned to September/October 2020 - Work in progress - Add new label alignment modes - See [#1656](https://github.com/lvgl/lvgl/issues/1656) +- Remove the align parameter from `lv_canvas_draw_text` + +## v9 +- Simplify `group`s. Discussion is [here](https://forum.lvgl.io/t/lv-group-tabindex/2927/3). ## Ideas - Unit testing (gtest?). See [#1658](https://github.com/lvgl/lvgl/issues/1658) From bd8ac58b6b9bbf005165e650aa317d6f8e108160 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 10 Aug 2020 06:17:03 +0200 Subject: [PATCH 200/205] add missing background drawing and radius handling to image button --- CHANGELOG.md | 1 + src/lv_widgets/lv_img.c | 28 ++++++++++++--- src/lv_widgets/lv_imgbtn.c | 70 +++++++++++++++++++++++++++++++++++++- 3 files changed, 93 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28a0c4fac..87e94bb18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - Add linemeter's mirror feature again - Fix text decor (udnerline strikethrough) with older versions of font converter - Fix setting local style property multiple times +- Add missing background drawing and radius handling to image button ## v7.3.0 (04.08.2020) diff --git a/src/lv_widgets/lv_img.c b/src/lv_widgets/lv_img.c index 6c6f65791..66ada123c 100644 --- a/src/lv_widgets/lv_img.c +++ b/src/lv_widgets/lv_img.c @@ -620,8 +620,6 @@ static lv_design_res_t lv_img_design(lv_obj_t * img, const lv_area_t * clip_area int32_t zoom_final = lv_obj_get_style_transform_zoom(img, LV_IMG_PART_MAIN); zoom_final = (zoom_final * ext->zoom) >> 8; - if(zoom_final == 0) return LV_DESIGN_RES_OK; - int32_t angle_final = lv_obj_get_style_transform_angle(img, LV_IMG_PART_MAIN); angle_final += ext->angle; @@ -639,6 +637,8 @@ static lv_design_res_t lv_img_design(lv_obj_t * img, const lv_area_t * clip_area lv_draw_rect(&bg_coords, clip_area, &bg_dsc); + if(zoom_final == 0) return LV_DESIGN_RES_OK; + if(lv_obj_get_style_clip_corner(img, LV_OBJ_PART_MAIN)) { lv_draw_mask_radius_param_t * mp = _lv_mem_buf_get(sizeof(lv_draw_mask_radius_param_t)); @@ -705,15 +705,33 @@ static lv_design_res_t lv_img_design(lv_obj_t * img, const lv_area_t * clip_area _lv_mem_buf_release(param); } - lv_draw_rect_dsc_t draw_dsc; - lv_draw_rect_dsc_init(&draw_dsc); - /*If the border is drawn later disable loading other properties*/ if(lv_obj_get_style_border_post(img, LV_OBJ_PART_MAIN)) { + lv_draw_rect_dsc_t draw_dsc; + lv_draw_rect_dsc_init(&draw_dsc); draw_dsc.bg_opa = LV_OPA_TRANSP; draw_dsc.pattern_opa = LV_OPA_TRANSP; draw_dsc.shadow_opa = LV_OPA_TRANSP; lv_obj_init_draw_rect_dsc(img, LV_OBJ_PART_MAIN, &draw_dsc); + + int32_t zoom_final = lv_obj_get_style_transform_zoom(img, LV_IMG_PART_MAIN); + zoom_final = (zoom_final * ext->zoom) >> 8; + + int32_t angle_final = lv_obj_get_style_transform_angle(img, LV_IMG_PART_MAIN); + angle_final += ext->angle; + + lv_area_t bg_coords; + _lv_img_buf_get_transformed_area(&bg_coords, lv_area_get_width(&img->coords), lv_area_get_height(&img->coords), + angle_final, zoom_final, &ext->pivot); + bg_coords.x1 += img->coords.x1; + bg_coords.y1 += img->coords.y1; + bg_coords.x2 += img->coords.x1; + bg_coords.y2 += img->coords.y1; + bg_coords.x1 -= lv_obj_get_style_pad_left(img, LV_IMG_PART_MAIN); + bg_coords.x2 += lv_obj_get_style_pad_right(img, LV_IMG_PART_MAIN); + bg_coords.y1 -= lv_obj_get_style_pad_top(img, LV_IMG_PART_MAIN); + bg_coords.y2 += lv_obj_get_style_pad_bottom(img, LV_IMG_PART_MAIN); + lv_draw_rect(&img->coords, clip_area, &draw_dsc); } } diff --git a/src/lv_widgets/lv_imgbtn.c b/src/lv_widgets/lv_imgbtn.c index 1c37d92a9..5cdc8e15a 100644 --- a/src/lv_widgets/lv_imgbtn.c +++ b/src/lv_widgets/lv_imgbtn.c @@ -273,7 +273,38 @@ static lv_design_res_t lv_imgbtn_design(lv_obj_t * imgbtn, const lv_area_t * cli } /*Draw the object*/ else if(mode == LV_DESIGN_DRAW_MAIN) { - ancestor_design(imgbtn, clip_area, mode); + lv_area_t img_coords; + + lv_obj_get_coords(imgbtn, &img_coords); + + lv_draw_rect_dsc_t bg_dsc; + lv_draw_rect_dsc_init(&bg_dsc); + lv_obj_init_draw_rect_dsc(imgbtn, LV_IMGBTN_PART_MAIN, &bg_dsc); + + /*If the border is drawn later disable loading its properties*/ + if(lv_obj_get_style_border_post(imgbtn, LV_OBJ_PART_MAIN)) { + bg_dsc.border_opa = LV_OPA_TRANSP; + } + + lv_area_t bg_coords; + lv_area_copy(&bg_coords, &img_coords); + bg_coords.x1 -= lv_obj_get_style_pad_left(imgbtn, LV_IMGBTN_PART_MAIN); + bg_coords.x2 += lv_obj_get_style_pad_right(imgbtn, LV_IMGBTN_PART_MAIN); + bg_coords.y1 -= lv_obj_get_style_pad_top(imgbtn, LV_IMGBTN_PART_MAIN); + bg_coords.y2 += lv_obj_get_style_pad_bottom(imgbtn, LV_IMGBTN_PART_MAIN); + + lv_draw_rect(&bg_coords, clip_area, &bg_dsc); + + if(lv_obj_get_style_clip_corner(imgbtn, LV_OBJ_PART_MAIN)) { + lv_draw_mask_radius_param_t * mp = _lv_mem_buf_get(sizeof(lv_draw_mask_radius_param_t)); + + lv_coord_t r = lv_obj_get_style_radius(imgbtn, LV_OBJ_PART_MAIN); + + lv_draw_mask_radius_init(mp, &bg_coords, r, false); + /*Add the mask and use `img+8` as custom id. Don't use `obj` directly because it might be used by the user*/ + lv_draw_mask_add(mp, imgbtn + 8); + } + /*Just draw an image*/ lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn); lv_btn_state_t state = lv_imgbtn_get_state(imgbtn); @@ -374,6 +405,31 @@ static lv_design_res_t lv_imgbtn_design(lv_obj_t * imgbtn, const lv_area_t * cli } /*Post draw when the children are drawn*/ else if(mode == LV_DESIGN_DRAW_POST) { + if(lv_obj_get_style_clip_corner(imgbtn, LV_OBJ_PART_MAIN)) { + lv_draw_mask_radius_param_t * param = lv_draw_mask_remove_custom(imgbtn + 8); + _lv_mem_buf_release(param); + } + + lv_draw_rect_dsc_t draw_dsc; + lv_draw_rect_dsc_init(&draw_dsc); + + /*If the border is drawn later disable loading other properties*/ + if(lv_obj_get_style_border_post(imgbtn, LV_OBJ_PART_MAIN)) { + draw_dsc.bg_opa = LV_OPA_TRANSP; + draw_dsc.pattern_opa = LV_OPA_TRANSP; + draw_dsc.shadow_opa = LV_OPA_TRANSP; + lv_obj_init_draw_rect_dsc(imgbtn, LV_OBJ_PART_MAIN, &draw_dsc); + + + lv_area_t bg_coords; + lv_area_copy(&bg_coords, &imgbtn->coords); + bg_coords.x1 -= lv_obj_get_style_pad_left(imgbtn, LV_IMGBTN_PART_MAIN); + bg_coords.x2 += lv_obj_get_style_pad_right(imgbtn, LV_IMGBTN_PART_MAIN); + bg_coords.y1 -= lv_obj_get_style_pad_top(imgbtn, LV_IMGBTN_PART_MAIN); + bg_coords.y2 += lv_obj_get_style_pad_bottom(imgbtn, LV_IMGBTN_PART_MAIN); + + lv_draw_rect(&bg_coords, clip_area, &draw_dsc); + } } return LV_DESIGN_RES_OK; @@ -400,6 +456,18 @@ static lv_res_t lv_imgbtn_signal(lv_obj_t * imgbtn, lv_signal_t sign, void * par * changed as well Set the new image for the new state.*/ refr_img(imgbtn); } + else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) { + /*Handle the padding of the background*/ + lv_style_int_t left = lv_obj_get_style_pad_left(imgbtn, LV_IMGBTN_PART_MAIN); + lv_style_int_t right = lv_obj_get_style_pad_right(imgbtn, LV_IMGBTN_PART_MAIN); + lv_style_int_t top = lv_obj_get_style_pad_top(imgbtn, LV_IMGBTN_PART_MAIN); + lv_style_int_t bottom = lv_obj_get_style_pad_bottom(imgbtn, LV_IMGBTN_PART_MAIN); + + imgbtn->ext_draw_pad = LV_MATH_MAX(imgbtn->ext_draw_pad, left); + imgbtn->ext_draw_pad = LV_MATH_MAX(imgbtn->ext_draw_pad, right); + imgbtn->ext_draw_pad = LV_MATH_MAX(imgbtn->ext_draw_pad, top); + imgbtn->ext_draw_pad = LV_MATH_MAX(imgbtn->ext_draw_pad, bottom); + } else if(sign == LV_SIGNAL_CLEANUP) { /*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/ } From 6fd7bcf17222214d0da7392e2d68657a9cfa0a6b Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 10 Aug 2020 11:36:43 +0200 Subject: [PATCH 201/205] allow adding extra label to list buttons --- CHANGELOG.md | 1 + src/lv_widgets/lv_list.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87e94bb18..874bce62d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - Fix text decor (udnerline strikethrough) with older versions of font converter - Fix setting local style property multiple times - Add missing background drawing and radius handling to image button +- Allow adding extra label to list buttons ## v7.3.0 (04.08.2020) diff --git a/src/lv_widgets/lv_list.c b/src/lv_widgets/lv_list.c index acb165a81..ecda79c9b 100644 --- a/src/lv_widgets/lv_list.c +++ b/src/lv_widgets/lv_list.c @@ -365,11 +365,11 @@ lv_obj_t * lv_list_get_btn_label(const lv_obj_t * btn) { LV_ASSERT_OBJ(btn, "lv_btn"); - lv_obj_t * label = lv_obj_get_child(btn, NULL); + lv_obj_t * label = lv_obj_get_child_back(btn, NULL); if(label == NULL) return NULL; while(lv_list_is_list_label(label) == false) { - label = lv_obj_get_child(btn, label); + label = lv_obj_get_child_back(btn, label); if(label == NULL) break; } @@ -386,11 +386,11 @@ lv_obj_t * lv_list_get_btn_img(const lv_obj_t * btn) LV_ASSERT_OBJ(btn, "lv_btn"); #if LV_USE_IMG != 0 - lv_obj_t * img = lv_obj_get_child(btn, NULL); + lv_obj_t * img = lv_obj_get_child_back(btn, NULL); if(img == NULL) return NULL; while(lv_list_is_list_img(img) == false) { - img = lv_obj_get_child(btn, img); + img = lv_obj_get_child_back(btn, img); if(img == NULL) break; } From d2e1094159ecea84ea2662af65f3df0894670ca1 Mon Sep 17 00:00:00 2001 From: Sergei Kolotovchenkov Date: Mon, 10 Aug 2020 21:13:26 +0300 Subject: [PATCH 202/205] Fix Visual Studio 2019 compile errors (#1711) Fixed msvc 2019 compiler error C4576 when using the LVGL inside C++ code --- src/lv_misc/lv_color.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/lv_misc/lv_color.h b/src/lv_misc/lv_color.h index 1b557788c..8268668e6 100644 --- a/src/lv_misc/lv_color.h +++ b/src/lv_misc/lv_color.h @@ -596,19 +596,26 @@ static inline uint8_t lv_color_brightness(lv_color_t color) return (uint8_t)(bright >> 3); } +#ifdef __cplusplus +/* Fix of msvc 2019 compiler error C4576 inside C++ code */ +#define _LV_COLOR_MAKE_TYPE_HELPER lv_color_t +#else +#define _LV_COLOR_MAKE_TYPE_HELPER (lv_color_t) +#endif + /* The most simple macro to create a color from R,G and B values */ #if LV_COLOR_DEPTH == 1 -#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){.full = (uint8_t)((b8 >> 7) | (g8 >> 7) | (r8 >> 7))}) +#define LV_COLOR_MAKE(r8, g8, b8) (_LV_COLOR_MAKE_TYPE_HELPER{.full = (uint8_t)((b8 >> 7) | (g8 >> 7) | (r8 >> 7))}) #elif LV_COLOR_DEPTH == 8 -#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{(uint8_t)((b8 >> 6) & 0x3U), (uint8_t)((g8 >> 5) & 0x7U), (uint8_t)((r8 >> 5) & 0x7U)}}) +#define LV_COLOR_MAKE(r8, g8, b8) (_LV_COLOR_MAKE_TYPE_HELPER{{(uint8_t)((b8 >> 6) & 0x3U), (uint8_t)((g8 >> 5) & 0x7U), (uint8_t)((r8 >> 5) & 0x7U)}}) #elif LV_COLOR_DEPTH == 16 #if LV_COLOR_16_SWAP == 0 -#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{(uint16_t)((b8 >> 3) & 0x1FU), (uint16_t)((g8 >> 2) & 0x3FU), (uint16_t)((r8 >> 3) & 0x1FU)}}) +#define LV_COLOR_MAKE(r8, g8, b8) (_LV_COLOR_MAKE_TYPE_HELPER{{(uint16_t)((b8 >> 3) & 0x1FU), (uint16_t)((g8 >> 2) & 0x3FU), (uint16_t)((r8 >> 3) & 0x1FU)}}) #else -#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{(uint16_t)((g8 >> 5) & 0x7U), (uint16_t)((r8 >> 3) & 0x1FU), (uint16_t)((b8 >> 3) & 0x1FU), (uint16_t)((g8 >> 2) & 0x7U)}}) +#define LV_COLOR_MAKE(r8, g8, b8) (_LV_COLOR_MAKE_TYPE_HELPER{{(uint16_t)((g8 >> 5) & 0x7U), (uint16_t)((r8 >> 3) & 0x1FU), (uint16_t)((b8 >> 3) & 0x1FU), (uint16_t)((g8 >> 2) & 0x7U)}}) #endif #elif LV_COLOR_DEPTH == 32 -#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{b8, g8, r8, 0xff}}) /*Fix 0xff alpha*/ +#define LV_COLOR_MAKE(r8, g8, b8) (_LV_COLOR_MAKE_TYPE_HELPER{{b8, g8, r8, 0xff}}) /*Fix 0xff alpha*/ #endif static inline lv_color_t lv_color_make(uint8_t r, uint8_t g, uint8_t b) From f066f0b8d8d9d47aabab7b81880632dd4dd58bb7 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 11 Aug 2020 10:09:31 +0200 Subject: [PATCH 203/205] fix overflow in large image transformations --- CHANGELOG.md | 1 + src/lv_draw/lv_img_buf.c | 24 ++++++++++++++++-------- src/lv_draw/lv_img_buf.h | 10 ++++++---- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 874bce62d..8e4b928be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - Fix setting local style property multiple times - Add missing background drawing and radius handling to image button - Allow adding extra label to list buttons +- Fix overflow in large image transformations ## v7.3.0 (04.08.2020) diff --git a/src/lv_draw/lv_img_buf.c b/src/lv_draw/lv_img_buf.c index 741ad0439..5ddf40577 100644 --- a/src/lv_draw/lv_img_buf.c +++ b/src/lv_draw/lv_img_buf.c @@ -435,6 +435,10 @@ void _lv_img_buf_transform_init(lv_img_transform_dsc_t * dsc) dsc->tmp.sinma = (s1 * (10 - angle_rem) + s2 * angle_rem) / 10; dsc->tmp.cosma = (c1 * (10 - angle_rem) + c2 * angle_rem) / 10; + /*Use smaller value to avoid overflow*/ + dsc->tmp.sinma = dsc->tmp.sinma >> (LV_TRIGO_SHIFT - _LV_TRANSFORM_TRIGO_SHIFT); + dsc->tmp.cosma = dsc->tmp.cosma >> (LV_TRIGO_SHIFT - _LV_TRANSFORM_TRIGO_SHIFT); + dsc->tmp.chroma_keyed = lv_img_cf_is_chroma_keyed(dsc->cfg.cf) ? 1 : 0; dsc->tmp.has_alpha = lv_img_cf_has_alpha(dsc->cfg.cf) ? 1 : 0; if(dsc->cfg.cf == LV_IMG_CF_TRUE_COLOR || dsc->cfg.cf == LV_IMG_CF_TRUE_COLOR_ALPHA || @@ -493,6 +497,10 @@ void _lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t int32_t sinma = (s1 * (10 - angle_rem) + s2 * angle_rem) / 10; int32_t cosma = (c1 * (10 - angle_rem) + c2 * angle_rem) / 10; + /*Use smaller value to avoid overflow*/ + sinma = sinma >> (LV_TRIGO_SHIFT - _LV_TRANSFORM_TRIGO_SHIFT); + cosma = cosma >> (LV_TRIGO_SHIFT - _LV_TRANSFORM_TRIGO_SHIFT); + lv_point_t lt; lv_point_t rt; lv_point_t lb; @@ -509,23 +517,23 @@ void _lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t xt = a.x1; yt = a.y1; - lt.x = ((cosma * xt - sinma * yt) >> LV_TRIGO_SHIFT) + pivot->x; - lt.y = ((sinma * xt + cosma * yt) >> LV_TRIGO_SHIFT) + pivot->y; + lt.x = ((cosma * xt - sinma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->x; + lt.y = ((sinma * xt + cosma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->y; xt = a.x2; yt = a.y1; - rt.x = ((cosma * xt - sinma * yt) >> LV_TRIGO_SHIFT) + pivot->x; - rt.y = ((sinma * xt + cosma * yt) >> LV_TRIGO_SHIFT) + pivot->y; + rt.x = ((cosma * xt - sinma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->x; + rt.y = ((sinma * xt + cosma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->y; xt = a.x1; yt = a.y2; - lb.x = ((cosma * xt - sinma * yt) >> LV_TRIGO_SHIFT) + pivot->x; - lb.y = ((sinma * xt + cosma * yt) >> LV_TRIGO_SHIFT) + pivot->y; + lb.x = ((cosma * xt - sinma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->x; + lb.y = ((sinma * xt + cosma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->y; xt = a.x2; yt = a.y2; - rb.x = ((cosma * xt - sinma * yt) >> LV_TRIGO_SHIFT) + pivot->x; - rb.y = ((sinma * xt + cosma * yt) >> LV_TRIGO_SHIFT) + pivot->y; + rb.x = ((cosma * xt - sinma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->x; + rb.y = ((sinma * xt + cosma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->y; res->x1 = LV_MATH_MIN4(lb.x, lt.x, rb.x, rt.x); res->x2 = LV_MATH_MAX4(lb.x, lt.x, rb.x, rt.x); diff --git a/src/lv_draw/lv_img_buf.h b/src/lv_draw/lv_img_buf.h index afde70c55..d0d3991fc 100644 --- a/src/lv_draw/lv_img_buf.h +++ b/src/lv_draw/lv_img_buf.h @@ -48,6 +48,8 @@ extern "C" { #define LV_IMG_ZOOM_NONE 256 +#define _LV_TRANSFORM_TRIGO_SHIFT 10 + /********************** * TYPEDEFS **********************/ @@ -301,8 +303,8 @@ static inline bool _lv_img_buf_transform(lv_img_transform_dsc_t * dsc, lv_coord_ int32_t ys; if(dsc->cfg.zoom == LV_IMG_ZOOM_NONE) { /*Get the source pixel from the upscaled image*/ - xs = ((dsc->tmp.cosma * xt - dsc->tmp.sinma * yt) >> (LV_TRIGO_SHIFT - 8)) + dsc->tmp.pivot_x_256; - ys = ((dsc->tmp.sinma * xt + dsc->tmp.cosma * yt) >> (LV_TRIGO_SHIFT - 8)) + dsc->tmp.pivot_y_256; + xs = ((dsc->tmp.cosma * xt - dsc->tmp.sinma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT - 8)) + dsc->tmp.pivot_x_256; + ys = ((dsc->tmp.sinma * xt + dsc->tmp.cosma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT - 8)) + dsc->tmp.pivot_y_256; } else if(dsc->cfg.angle == 0) { xt *= dsc->tmp.zoom_inv; @@ -313,8 +315,8 @@ static inline bool _lv_img_buf_transform(lv_img_transform_dsc_t * dsc, lv_coord_ else { xt *= dsc->tmp.zoom_inv; yt *= dsc->tmp.zoom_inv; - xs = ((dsc->tmp.cosma * xt - dsc->tmp.sinma * yt) >> (LV_TRIGO_SHIFT)) + dsc->tmp.pivot_x_256; - ys = ((dsc->tmp.sinma * xt + dsc->tmp.cosma * yt) >> (LV_TRIGO_SHIFT)) + dsc->tmp.pivot_y_256; + xs = ((dsc->tmp.cosma * xt - dsc->tmp.sinma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT)) + dsc->tmp.pivot_x_256; + ys = ((dsc->tmp.sinma * xt + dsc->tmp.cosma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT)) + dsc->tmp.pivot_y_256; } /*Get the integer part of the source pixel*/ From 28807b6a77b96ffcb144bc433f932a2f0b67a36e Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 11 Aug 2020 10:34:04 +0200 Subject: [PATCH 204/205] lv_img_design: fix cover check if angle != 0 --- src/lv_widgets/lv_img.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_widgets/lv_img.c b/src/lv_widgets/lv_img.c index 66ada123c..aaeb59d5c 100644 --- a/src/lv_widgets/lv_img.c +++ b/src/lv_widgets/lv_img.c @@ -578,7 +578,7 @@ static lv_design_res_t lv_img_design(lv_obj_t * img, const lv_area_t * clip_area int32_t angle_final = lv_obj_get_style_transform_angle(img, LV_IMG_PART_MAIN); angle_final += ext->angle; - if(angle_final == 0) return LV_DESIGN_RES_NOT_COVER; + if(angle_final != 0) return LV_DESIGN_RES_NOT_COVER; int32_t zoom_final = lv_obj_get_style_transform_zoom(img, LV_IMG_PART_MAIN); zoom_final = (zoom_final * ext->zoom) >> 8; From 2068ab3211ab4df04f283f39c7b6a4b58c64ee20 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 11 Aug 2020 10:38:16 +0200 Subject: [PATCH 205/205] bar, switch, slider: fix drawing background's 'value_str' twice --- src/lv_widgets/lv_bar.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lv_widgets/lv_bar.c b/src/lv_widgets/lv_bar.c index f76a2e13f..c30da9f01 100644 --- a/src/lv_widgets/lv_bar.c +++ b/src/lv_widgets/lv_bar.c @@ -395,7 +395,9 @@ static lv_design_res_t lv_bar_design(lv_obj_t * bar, const lv_area_t * clip_area lv_draw_rect_dsc_init(&draw_dsc); draw_dsc.bg_opa = LV_OPA_TRANSP; draw_dsc.pattern_opa = LV_OPA_TRANSP; + draw_dsc.outline_opa = LV_OPA_TRANSP; draw_dsc.shadow_opa = LV_OPA_TRANSP; + draw_dsc.value_opa = LV_OPA_TRANSP; lv_obj_init_draw_rect_dsc(bar, LV_OBJ_PART_MAIN, &draw_dsc); lv_draw_rect(&bar->coords, clip_area, &draw_dsc); @@ -414,6 +416,8 @@ static void draw_bg(lv_obj_t * bar, const lv_area_t * clip_area) draw_dsc.border_opa = LV_OPA_TRANSP; } + /*value will be drawn later*/ + draw_dsc.value_opa = LV_OPA_TRANSP; lv_obj_init_draw_rect_dsc(bar, LV_BAR_PART_BG, &draw_dsc); lv_draw_rect(&bar->coords, clip_area, &draw_dsc);