From 1a3d61e074213fa3387e483fe37f414049c8cac2 Mon Sep 17 00:00:00 2001 From: Paul Peavyhouse Date: Sat, 28 Sep 2019 01:41:26 -0700 Subject: [PATCH 01/64] Consolidate separate h, s, & v vars in to single lv_color_hsv_t var --- src/lv_objx/lv_cpicker.c | 197 +++++++++++++++++---------------------- src/lv_objx/lv_cpicker.h | 28 ++++-- 2 files changed, 105 insertions(+), 120 deletions(-) diff --git a/src/lv_objx/lv_cpicker.c b/src/lv_objx/lv_cpicker.c index 6615397c7..c16fe61a5 100644 --- a/src/lv_objx/lv_cpicker.c +++ b/src/lv_objx/lv_cpicker.c @@ -9,6 +9,7 @@ #include "lv_cpicker.h" #if LV_USE_CPICKER != 0 +#include "../lv_core/lv_debug.h" #include "../lv_draw/lv_draw_arc.h" #include "../lv_themes/lv_theme.h" #include "../lv_core/lv_indev.h" @@ -34,6 +35,10 @@ #define LV_CPICKER_DEF_VALUE 100 #endif +#ifndef LV_CPICKER_DEF_HSV +#define LV_CPICKER_DEF_HSV ((lv_color_hsv_t){LV_CPICKER_DEF_HUE, LV_CPICKER_DEF_SATURATION, LV_CPICKER_DEF_VALUE}) +#endif + #ifndef LV_CPICKER_DEF_INDICATOR_TYPE #define LV_CPICKER_DEF_INDICATOR_TYPE LV_CPICKER_INDICATOR_CIRCLE #endif @@ -92,7 +97,7 @@ lv_obj_t * lv_cpicker_create(lv_obj_t * par, const lv_obj_t * copy) LV_LOG_TRACE("color_picker create started"); lv_obj_t * new_cpicker = lv_obj_create(par, copy); - lv_mem_assert(new_cpicker); + LV_ASSERT_MEM(new_cpicker); if(new_cpicker == NULL) return NULL; if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_cpicker); @@ -100,14 +105,12 @@ lv_obj_t * lv_cpicker_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the extended data*/ lv_cpicker_ext_t * ext = lv_obj_allocate_ext_attr(new_cpicker, sizeof(lv_cpicker_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_MEM(ext); if(ext == NULL) return NULL; /*Initialize the allocated 'ext' */ - ext->hue = LV_CPICKER_DEF_HUE; - ext->prev_hue = ext->hue; - ext->saturation = LV_CPICKER_DEF_SATURATION; - ext->value = LV_CPICKER_DEF_VALUE; + ext->hsv = LV_CPICKER_DEF_HSV; + ext->prev_hsv = ext->hsv; ext->indicator.style = &lv_style_plain; ext->indicator.type = LV_CPICKER_DEF_INDICATOR_TYPE; ext->color_mode = LV_CPICKER_COLOR_MODE_HUE; @@ -201,7 +204,7 @@ void lv_cpicker_set_hue(lv_obj_t * cpicker, uint16_t hue) { lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); - ext->hue = hue % 360; + ext->hsv.h = hue % 360; lv_obj_invalidate(cpicker); } @@ -215,7 +218,7 @@ void lv_cpicker_set_saturation(lv_obj_t * cpicker, uint8_t saturation) { lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); - ext->saturation = saturation % 100; + ext->hsv.s = saturation % 100; lv_obj_invalidate(cpicker); } @@ -229,7 +232,21 @@ void lv_cpicker_set_value(lv_obj_t * cpicker, uint8_t val) { lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); - ext->value = val % 100; + ext->hsv.v = val % 100; + + lv_obj_invalidate(cpicker); +} + +/** + * Set the current hsv of a colorpicker. + * @param cpicker pointer to colorpicker object + * @param color current selected hsv + */ +void lv_cpicker_set_hsv(lv_obj_t * cpicker, lv_color_hsv_t hsv) +{ + lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); + + ext->hsv = hsv; lv_obj_invalidate(cpicker); } @@ -241,12 +258,7 @@ void lv_cpicker_set_value(lv_obj_t * cpicker, uint8_t val) */ void lv_cpicker_set_color(lv_obj_t * cpicker, lv_color_t color) { - lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); - - lv_color_hsv_t hsv = lv_color_rgb_to_hsv(color.ch.red, color.ch.green, color.ch.blue); - ext->hue = hsv.h; - - lv_obj_invalidate(cpicker); + lv_cpicker_set_hsv(cpicker, lv_color_rgb_to_hsv(color.ch.red, color.ch.green, color.ch.blue)); } /** @@ -325,7 +337,7 @@ lv_style_t * lv_cpicker_get_style(const lv_obj_t * cpicker, lv_cpicker_style_t t } /** - * Get the current hue of a colorpicker. + * Get the current selected hue of a colorpicker. * @param cpicker pointer to colorpicker object * @return hue current selected hue */ @@ -333,11 +345,11 @@ uint16_t lv_cpicker_get_hue(lv_obj_t * cpicker) { lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); - return ext->hue; + return ext->hsv.h; } /** - * Get the current saturation of a colorpicker. + * Get the current selected saturation of a colorpicker. * @param cpicker pointer to colorpicker object * @return current selected saturation */ @@ -345,11 +357,11 @@ uint8_t lv_cpicker_get_saturation(lv_obj_t * cpicker) { lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); - return ext->saturation; + return ext->hsv.s; } /** - * Get the current hue of a colorpicker. + * Get the current selected hue of a colorpicker. * @param cpicker pointer to colorpicker object * @return current selected value */ @@ -357,7 +369,19 @@ uint8_t lv_cpicker_get_value(lv_obj_t * cpicker) { lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); - return ext->value; + return ext->hsv.v; +} + +/** + * Get the current selected hsv of a colorpicker. + * @param cpicker pointer to colorpicker object + * @return current selected hsv + */ +lv_color_hsv_t lv_cpicker_get_hsv(lv_obj_t * cpicker) +{ + lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); + + return ext->hsv; } /** @@ -369,7 +393,7 @@ lv_color_t lv_cpicker_get_color(lv_obj_t * cpicker) { lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); - return lv_color_hsv_to_rgb(ext->hue, ext->saturation, ext->value); + return lv_color_hsv_to_rgb(ext->hsv.h, ext->hsv.s, ext->hsv.v); } /*===================== @@ -452,13 +476,13 @@ static lv_color_t angle_to_mode_color(lv_cpicker_ext_t * ext, uint16_t angle) { default: case LV_CPICKER_COLOR_MODE_HUE: - color = lv_color_hsv_to_rgb(angle % 360, ext->saturation, ext->value); + color = lv_color_hsv_to_rgb(angle % 360, ext->hsv.s, ext->hsv.v); break; case LV_CPICKER_COLOR_MODE_SATURATION: - color = lv_color_hsv_to_rgb(ext->hue, (angle % 360) / 360.0 * 100.0, ext->value); + color = lv_color_hsv_to_rgb(ext->hsv.h, (angle % 360) / 360.0 * 100.0, ext->hsv.v); break; case LV_CPICKER_COLOR_MODE_VALUE: - color = lv_color_hsv_to_rgb(ext->hue, ext->saturation, (angle % 360) / 360.0 * 100.0); + color = lv_color_hsv_to_rgb(ext->hsv.h, ext->hsv.s, (angle % 360) / 360.0 * 100.0); break; } return color; @@ -471,13 +495,13 @@ static uint16_t mode_color_to_angle(lv_cpicker_ext_t * ext) { default: case LV_CPICKER_COLOR_MODE_HUE: - angle = ext->hue; + angle = ext->hsv.h; break; case LV_CPICKER_COLOR_MODE_SATURATION: - angle = ext->saturation / 100.0 * 360.0; + angle = ext->hsv.s / 100.0 * 360.0; break; case LV_CPICKER_COLOR_MODE_VALUE: - angle = ext->value / 100.0 * 360.0; + angle = ext->hsv.v / 100.0 * 360.0; break; } return angle; @@ -490,13 +514,13 @@ static lv_coord_t lv_cpicker_get_indicator_coord(lv_style_t * style, lv_cpicker_ { default: case LV_CPICKER_COLOR_MODE_HUE: - ind_pos += ext->hue / 360.0 * ext->rect_gradient_w; + ind_pos += ext->hsv.h / 360.0 * ext->rect_gradient_w; break; case LV_CPICKER_COLOR_MODE_SATURATION: - ind_pos += ext->saturation / 100.0 * ext->rect_gradient_w; + ind_pos += ext->hsv.s / 100.0 * ext->rect_gradient_w; break; case LV_CPICKER_COLOR_MODE_VALUE: - ind_pos += ext->value / 100.0 * ext->rect_gradient_w; + ind_pos += ext->hsv.v / 100.0 * ext->rect_gradient_w; break; } return ind_pos; @@ -610,7 +634,7 @@ static void lv_cpicker_draw_disc_indicator(lv_area_t * mask, lv_style_t * style, lv_draw_rect(¢er_area, mask, &styleCenterBackground, opa_scale); /*draw the center color indicator*/ - style->body.main_color = lv_color_hsv_to_rgb(ext->hue, ext->saturation, ext->value); + style->body.main_color = lv_color_hsv_to_rgb(ext->hsv.h, ext->hsv.s, ext->hsv.v); style->body.grad_color = style->body.main_color; style->body.radius = LV_RADIUS_CIRCLE; lv_draw_rect(¢er_ind_area, mask, style, opa_scale); @@ -1181,13 +1205,13 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p switch(ext->color_mode) { case LV_CPICKER_COLOR_MODE_HUE: - ext->hue = (ext->hue + 1) % 360; + ext->hsv.h = (ext->hsv.h + 1) % 360; break; case LV_CPICKER_COLOR_MODE_SATURATION: - ext->saturation = (ext->saturation + 1) % 100; + ext->hsv.s = (ext->hsv.s + 1) % 100; break; case LV_CPICKER_COLOR_MODE_VALUE: - ext->value = (ext->value + 1) % 100; + ext->hsv.v = (ext->hsv.v + 1) % 100; break; } @@ -1201,13 +1225,13 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p switch(ext->color_mode) { case LV_CPICKER_COLOR_MODE_HUE: - ext->hue = ext->hue > 0?(ext->hue - 1):360; + ext->hsv.h = ext->hsv.h > 0?(ext->hsv.h - 1):360; break; case LV_CPICKER_COLOR_MODE_SATURATION: - ext->saturation = ext->saturation > 0?(ext->saturation - 1):100; + ext->hsv.s = ext->hsv.s > 0?(ext->hsv.s - 1):100; break; case LV_CPICKER_COLOR_MODE_VALUE: - ext->value = ext->value > 0?(ext->value - 1):100; + ext->hsv.v = ext->hsv.v > 0?(ext->hsv.v - 1):100; break; } @@ -1221,13 +1245,13 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p switch(ext->color_mode) { case LV_CPICKER_COLOR_MODE_HUE: - ext->hue = (ext->hue + 1) % 360; + ext->hsv.h = (ext->hsv.h + 1) % 360; break; case LV_CPICKER_COLOR_MODE_SATURATION: - ext->saturation = (ext->saturation + 1) % 100; + ext->hsv.s = (ext->hsv.s + 1) % 100; break; case LV_CPICKER_COLOR_MODE_VALUE: - ext->value = (ext->value + 1) % 100; + ext->hsv.v = (ext->hsv.v + 1) % 100; break; } @@ -1241,13 +1265,13 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p switch(ext->color_mode) { case LV_CPICKER_COLOR_MODE_HUE: - ext->hue = ext->hue > 0?(ext->hue - 1):360; + ext->hsv.h = ext->hsv.h > 0?(ext->hsv.h - 1):360; break; case LV_CPICKER_COLOR_MODE_SATURATION: - ext->saturation = ext->saturation > 0?(ext->saturation - 1):100; + ext->hsv.s = ext->hsv.s > 0?(ext->hsv.s - 1):100; break; case LV_CPICKER_COLOR_MODE_VALUE: - ext->value = ext->value > 0?(ext->value - 1):100; + ext->hsv.v = ext->hsv.v > 0?(ext->hsv.v - 1):100; break; } @@ -1279,40 +1303,6 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p return res; } -static void lv_cpicker_prev_hsv_save(lv_cpicker_ext_t * ext) -{ - switch(ext->color_mode) - { - case LV_CPICKER_COLOR_MODE_HUE: - ext->prev_hue = ext->hue; - break; - case LV_CPICKER_COLOR_MODE_SATURATION: - ext->prev_saturation = ext->saturation; - break; - case LV_CPICKER_COLOR_MODE_VALUE: - ext->prev_value = ext->value; - break; - } -} - -static void lv_cpicker_prev_hsv_restore(lv_obj_t * cpicker, - lv_cpicker_ext_t * ext) -{ - switch(ext->color_mode) - { - case LV_CPICKER_COLOR_MODE_HUE: - ext->prev_hue = ext->hue; - break; - case LV_CPICKER_COLOR_MODE_SATURATION: - ext->prev_saturation = ext->saturation; - break; - case LV_CPICKER_COLOR_MODE_VALUE: - ext->prev_value = ext->value; - break; - } - lv_cpicker_invalidate(cpicker, false); -} - static void lv_cpicker_reset_hsv_if_double_clicked(lv_obj_t * cpicker, lv_cpicker_ext_t * ext) { @@ -1321,18 +1311,16 @@ static void lv_cpicker_reset_hsv_if_double_clicked(lv_obj_t * cpicker, switch(ext->color_mode) { case LV_CPICKER_COLOR_MODE_HUE: - ext->hue = LV_CPICKER_DEF_HUE; - ext->prev_hue = ext->hue; + ext->hsv.h = LV_CPICKER_DEF_HSV.h; break; case LV_CPICKER_COLOR_MODE_SATURATION: - ext->saturation = LV_CPICKER_DEF_SATURATION; - ext->prev_saturation = ext->saturation; + ext->hsv.s = LV_CPICKER_DEF_HSV.s; break; case LV_CPICKER_COLOR_MODE_VALUE: - ext->value = LV_CPICKER_DEF_VALUE; - ext->prev_value = ext->value; + ext->hsv.v = LV_CPICKER_DEF_HSV.v; break; } + ext->prev_hsv = ext->hsv; lv_cpicker_invalidate(cpicker, false); } ext->last_click = lv_tick_get(); @@ -1341,21 +1329,8 @@ static void lv_cpicker_reset_hsv_if_double_clicked(lv_obj_t * cpicker, static void lv_cpicker_set_next_color_mode(lv_obj_t * cpicker, lv_cpicker_ext_t * ext) { - switch(ext->color_mode) - { - case LV_CPICKER_COLOR_MODE_HUE: - ext->prev_hue = ext->hue; - break; - case LV_CPICKER_COLOR_MODE_SATURATION: - ext->prev_saturation = ext->saturation; - break; - case LV_CPICKER_COLOR_MODE_VALUE: - ext->prev_value = ext->value; - break; - } - + ext->prev_hsv = ext->hsv; ext->color_mode = (ext->color_mode + 1) % 3; - lv_cpicker_invalidate(cpicker, true); } @@ -1371,32 +1346,30 @@ static lv_res_t lv_cpicker_set_hsv_percent(lv_obj_t * cpicker, { case LV_CPICKER_COLOR_MODE_HUE: hsv = percent * 360.0; - changed = hsv != ext->hue; + changed = hsv != ext->hsv.h; if (changed) { - ext->hue = hsv; - ext->prev_hue = ext->hue; + ext->hsv.h = hsv; } break; case LV_CPICKER_COLOR_MODE_SATURATION: hsv = percent * 100.0; - changed = hsv != ext->saturation; + changed = hsv != ext->hsv.s; if (changed) { - ext->saturation = hsv; - ext->prev_saturation = ext->saturation; + ext->hsv.s = hsv; } break; case LV_CPICKER_COLOR_MODE_VALUE: hsv = percent * 100.0; - changed = hsv != ext->value; + changed = hsv != ext->hsv.v; if (changed) { - ext->value = hsv; - ext->prev_value = ext->value; + ext->hsv.v = hsv; } break; } + ext->prev_hsv = ext->hsv; if (changed) { @@ -1417,7 +1390,7 @@ static lv_res_t lv_cpicker_disc_signal(lv_obj_t * cpicker, lv_signal_t sign, voi if(sign == LV_SIGNAL_PRESSED) { - lv_cpicker_prev_hsv_save(ext); + ext->prev_hsv = ext->hsv; lv_indev_t * indev = param; @@ -1444,7 +1417,8 @@ static lv_res_t lv_cpicker_disc_signal(lv_obj_t * cpicker, lv_signal_t sign, voi } else if(sign == LV_SIGNAL_PRESS_LOST) { - lv_cpicker_prev_hsv_restore(cpicker, ext); + ext->prev_hsv = ext->hsv; + lv_cpicker_invalidate(cpicker, false); } else if(sign == LV_SIGNAL_RELEASED) { @@ -1485,7 +1459,7 @@ static lv_res_t lv_cpicker_rect_signal(lv_obj_t * cpicker, lv_signal_t sign, voi if(sign == LV_SIGNAL_PRESSED) { - lv_cpicker_prev_hsv_save(ext); + ext->prev_hsv = ext->hsv; lv_indev_t * indev = param; @@ -1510,7 +1484,8 @@ static lv_res_t lv_cpicker_rect_signal(lv_obj_t * cpicker, lv_signal_t sign, voi } else if(sign == LV_SIGNAL_PRESS_LOST) { - lv_cpicker_prev_hsv_restore(cpicker, ext); + ext->prev_hsv = ext->hsv; + lv_cpicker_invalidate(cpicker, false); } else if(sign == LV_SIGNAL_RELEASED) { diff --git a/src/lv_objx/lv_cpicker.h b/src/lv_objx/lv_cpicker.h index 406322579..987800e85 100644 --- a/src/lv_objx/lv_cpicker.h +++ b/src/lv_objx/lv_cpicker.h @@ -32,17 +32,13 @@ extern "C" { **********************/ /*Data of colorpicker*/ typedef struct { - uint16_t hue; - uint8_t saturation; - uint8_t value; + lv_color_hsv_t hsv; struct { lv_style_t * style; uint8_t type; } indicator; - uint16_t prev_hue; - uint8_t prev_saturation; - uint8_t prev_value; + lv_color_hsv_t prev_hsv; uint16_t prev_pos; uint8_t color_mode:2; uint8_t color_mode_fixed:1; @@ -141,6 +137,13 @@ void lv_cpicker_set_saturation(lv_obj_t * cpicker, uint8_t saturation); */ void lv_cpicker_set_value(lv_obj_t * cpicker, uint8_t val); +/** + * Set the current hsv of a colorpicker. + * @param cpicker pointer to colorpicker object + * @param hsv current selected hsv + */ +void lv_cpicker_set_hsv(lv_obj_t * cpicker, lv_color_hsv_t hsv); + /** * Set the current color of a colorpicker. * @param cpicker pointer to colorpicker object @@ -184,14 +187,14 @@ bool lv_cpicker_get_color_mode_fixed(lv_obj_t * cpicker); * Get style of a colorpicker. * @param cpicker pointer to colorpicker object * @param type which style should be get - * @return style pointer to the style + * @return pointer to the style */ lv_style_t * lv_cpicker_get_style(const lv_obj_t * cpicker, lv_cpicker_style_t type); /** * Get the current hue of a colorpicker. * @param cpicker pointer to colorpicker object - * @return hue current selected hue + * @return current selected hue */ uint16_t lv_cpicker_get_hue(lv_obj_t * cpicker); @@ -209,10 +212,17 @@ uint8_t lv_cpicker_get_saturation(lv_obj_t * cpicker); */ uint8_t lv_cpicker_get_value(lv_obj_t * cpicker); +/** + * Get the current selected hsv of a colorpicker. + * @param cpicker pointer to colorpicker object + * @return current selected hsv + */ +lv_color_hsv_t lv_cpicker_get_hsv(lv_obj_t * cpicker); + /** * Get the current selected color of a colorpicker. * @param cpicker pointer to colorpicker object - * @return color current selected color + * @return current selected color */ lv_color_t lv_cpicker_get_color(lv_obj_t * cpicker); From ab2114e4e773daa57147f33c7cb64871f8ebc68f Mon Sep 17 00:00:00 2001 From: Paul Peavyhouse Date: Sat, 28 Sep 2019 01:54:10 -0700 Subject: [PATCH 02/64] Eventing LV_EVENT_VALUE_CHANGED when double-clicked --- src/lv_objx/lv_cpicker.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/lv_objx/lv_cpicker.c b/src/lv_objx/lv_cpicker.c index c16fe61a5..9aebc2157 100644 --- a/src/lv_objx/lv_cpicker.c +++ b/src/lv_objx/lv_cpicker.c @@ -1303,9 +1303,11 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p return res; } -static void lv_cpicker_reset_hsv_if_double_clicked(lv_obj_t * cpicker, - lv_cpicker_ext_t * ext) +static lv_res_t lv_cpicker_reset_hsv_if_double_clicked(lv_obj_t * cpicker, + lv_cpicker_ext_t * ext) { + lv_res_t res; + if(lv_tick_elaps(ext->last_click) < 400) { switch(ext->color_mode) @@ -1322,8 +1324,12 @@ static void lv_cpicker_reset_hsv_if_double_clicked(lv_obj_t * cpicker, } ext->prev_hsv = ext->hsv; lv_cpicker_invalidate(cpicker, false); + + res = lv_event_send(cpicker, LV_EVENT_VALUE_CHANGED, NULL); } ext->last_click = lv_tick_get(); + + return res; } static void lv_cpicker_set_next_color_mode(lv_obj_t * cpicker, @@ -1398,7 +1404,8 @@ static lv_res_t lv_cpicker_disc_signal(lv_obj_t * cpicker, lv_signal_t sign, voi lv_coord_t yp = indev->proc.types.pointer.act_point.y - y; if((xp*xp + yp*yp) < (r_in*r_in)) { - lv_cpicker_reset_hsv_if_double_clicked(cpicker, ext); + res = lv_cpicker_reset_hsv_if_double_clicked(cpicker, ext); + if(res != LV_RES_OK) return res; } } else if(sign == LV_SIGNAL_PRESSING) @@ -1465,7 +1472,8 @@ static lv_res_t lv_cpicker_rect_signal(lv_obj_t * cpicker, lv_signal_t sign, voi if(lv_area_is_point_on(&(ext->rect_preview_area), &indev->proc.types.pointer.act_point)) { - lv_cpicker_reset_hsv_if_double_clicked(cpicker, ext); + res = lv_cpicker_reset_hsv_if_double_clicked(cpicker, ext); + if(res != LV_RES_OK) return res; } } else if(sign == LV_SIGNAL_PRESSING) From 3a5293fa3222a90fd2e7d5c19744c6a43c040110 Mon Sep 17 00:00:00 2001 From: Paul Peavyhouse Date: Sun, 29 Sep 2019 20:56:05 -0700 Subject: [PATCH 03/64] Tiny consolidation of identical LV_SIGNAL_PRESS_LOST code --- src/lv_objx/lv_cpicker.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/lv_objx/lv_cpicker.c b/src/lv_objx/lv_cpicker.c index 9aebc2157..1c3e701a2 100644 --- a/src/lv_objx/lv_cpicker.c +++ b/src/lv_objx/lv_cpicker.c @@ -1280,6 +1280,9 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p res = lv_event_send(cpicker, LV_EVENT_VALUE_CHANGED, NULL); if(res != LV_RES_OK) return res; } + } else if(sign == LV_SIGNAL_PRESS_LOST) { + ext->prev_hsv = ext->hsv; + lv_cpicker_invalidate(cpicker, false); } else { lv_style_t * style = lv_cpicker_get_style(cpicker, LV_CPICKER_STYLE_MAIN); @@ -1422,11 +1425,6 @@ static lv_res_t lv_cpicker_disc_signal(lv_obj_t * cpicker, lv_signal_t sign, voi if(res != LV_RES_OK) return res; } } - else if(sign == LV_SIGNAL_PRESS_LOST) - { - ext->prev_hsv = ext->hsv; - lv_cpicker_invalidate(cpicker, false); - } else if(sign == LV_SIGNAL_RELEASED) { lv_indev_t * indev = param; @@ -1490,11 +1488,6 @@ static lv_res_t lv_cpicker_rect_signal(lv_obj_t * cpicker, lv_signal_t sign, voi if(res != LV_RES_OK) return res; } } - else if(sign == LV_SIGNAL_PRESS_LOST) - { - ext->prev_hsv = ext->hsv; - lv_cpicker_invalidate(cpicker, false); - } else if(sign == LV_SIGNAL_RELEASED) { lv_indev_t * indev = param; From bf9ed06bac67baf97127102362be5e62d2348f6a Mon Sep 17 00:00:00 2001 From: Paul Peavyhouse Date: Sun, 29 Sep 2019 21:00:00 -0700 Subject: [PATCH 04/64] Consolidating identical LV_KEY_RIGHT/UP and LV_KEY_LEFT/DOWN code --- src/lv_objx/lv_cpicker.c | 44 ++-------------------------------------- 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/src/lv_objx/lv_cpicker.c b/src/lv_objx/lv_cpicker.c index 1c3e701a2..fcdd0d626 100644 --- a/src/lv_objx/lv_cpicker.c +++ b/src/lv_objx/lv_cpicker.c @@ -1200,7 +1200,7 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p if(sign == LV_SIGNAL_CONTROL) { uint32_t c = *((uint32_t *)param); /*uint32_t because can be UTF-8*/ - if(c == LV_KEY_RIGHT) + if(c == LV_KEY_RIGHT || c == LV_KEY_UP) { switch(ext->color_mode) { @@ -1220,47 +1220,7 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p res = lv_event_send(cpicker, LV_EVENT_VALUE_CHANGED, NULL); if(res != LV_RES_OK) return res; } - else if(c == LV_KEY_LEFT) - { - switch(ext->color_mode) - { - case LV_CPICKER_COLOR_MODE_HUE: - ext->hsv.h = ext->hsv.h > 0?(ext->hsv.h - 1):360; - break; - case LV_CPICKER_COLOR_MODE_SATURATION: - ext->hsv.s = ext->hsv.s > 0?(ext->hsv.s - 1):100; - break; - case LV_CPICKER_COLOR_MODE_VALUE: - ext->hsv.v = ext->hsv.v > 0?(ext->hsv.v - 1):100; - break; - } - - lv_cpicker_invalidate(cpicker, false); - - res = lv_event_send(cpicker, LV_EVENT_VALUE_CHANGED, NULL); - if(res != LV_RES_OK) return res; - } - else if(c == LV_KEY_UP) - { - switch(ext->color_mode) - { - case LV_CPICKER_COLOR_MODE_HUE: - ext->hsv.h = (ext->hsv.h + 1) % 360; - break; - case LV_CPICKER_COLOR_MODE_SATURATION: - ext->hsv.s = (ext->hsv.s + 1) % 100; - break; - case LV_CPICKER_COLOR_MODE_VALUE: - ext->hsv.v = (ext->hsv.v + 1) % 100; - break; - } - - lv_cpicker_invalidate(cpicker, false); - - res = lv_event_send(cpicker, LV_EVENT_VALUE_CHANGED, NULL); - if(res != LV_RES_OK) return res; - } - else if(c == LV_KEY_DOWN) + else if(c == LV_KEY_LEFT || c == LV_KEY_DOWN) { switch(ext->color_mode) { From 1339d92ccd65e5d32230768e20f7f9c8b02d067c Mon Sep 17 00:00:00 2001 From: Paul Peavyhouse Date: Sun, 29 Sep 2019 21:02:12 -0700 Subject: [PATCH 05/64] Code formatting --- src/lv_objx/lv_cpicker.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/lv_objx/lv_cpicker.c b/src/lv_objx/lv_cpicker.c index fcdd0d626..4abbff739 100644 --- a/src/lv_objx/lv_cpicker.c +++ b/src/lv_objx/lv_cpicker.c @@ -1186,19 +1186,26 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p lv_res_t res = ancestor_signal(cpicker, sign, param); if(res != LV_RES_OK) return res; - if(sign == LV_SIGNAL_CLEANUP) { + if(sign == LV_SIGNAL_CLEANUP) + { /*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/ - } else if(sign == LV_SIGNAL_GET_TYPE) { + } + else if(sign == LV_SIGNAL_GET_TYPE) + { lv_obj_type_t * buf = param; uint8_t i; - for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/ + for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) /*Find the last set data*/ + { if(buf->type[i] == NULL) break; } buf->type[i] = "lv_cpicker"; - } else { + } + else + { lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); - if(sign == LV_SIGNAL_CONTROL) { + if(sign == LV_SIGNAL_CONTROL) + { uint32_t c = *((uint32_t *)param); /*uint32_t because can be UTF-8*/ if(c == LV_KEY_RIGHT || c == LV_KEY_UP) { @@ -1240,10 +1247,14 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p res = lv_event_send(cpicker, LV_EVENT_VALUE_CHANGED, NULL); if(res != LV_RES_OK) return res; } - } else if(sign == LV_SIGNAL_PRESS_LOST) { + } + else if(sign == LV_SIGNAL_PRESS_LOST) + { ext->prev_hsv = ext->hsv; lv_cpicker_invalidate(cpicker, false); - } else { + } + else + { lv_style_t * style = lv_cpicker_get_style(cpicker, LV_CPICKER_STYLE_MAIN); if(ext->type == LV_CPICKER_TYPE_DISC) From 93d2d422b804baeb10322ce749e40c24fc482d94 Mon Sep 17 00:00:00 2001 From: Paul Peavyhouse Date: Sun, 29 Sep 2019 21:11:53 -0700 Subject: [PATCH 06/64] Not emitting LV_EVENT_VALUE_CHANGED if double-click doesn't change value --- src/lv_objx/lv_cpicker.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/lv_objx/lv_cpicker.c b/src/lv_objx/lv_cpicker.c index 4abbff739..ad138d126 100644 --- a/src/lv_objx/lv_cpicker.c +++ b/src/lv_objx/lv_cpicker.c @@ -1280,29 +1280,46 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p static lv_res_t lv_cpicker_reset_hsv_if_double_clicked(lv_obj_t * cpicker, lv_cpicker_ext_t * ext) { - lv_res_t res; + bool changed = false; if(lv_tick_elaps(ext->last_click) < 400) { switch(ext->color_mode) { case LV_CPICKER_COLOR_MODE_HUE: - ext->hsv.h = LV_CPICKER_DEF_HSV.h; + changed = ext->hsv.h != LV_CPICKER_DEF_HSV.h; + if (changed) + { + ext->hsv.h = LV_CPICKER_DEF_HSV.h; + } break; case LV_CPICKER_COLOR_MODE_SATURATION: - ext->hsv.s = LV_CPICKER_DEF_HSV.s; + changed = ext->hsv.s != LV_CPICKER_DEF_HSV.s; + if (changed) + { + ext->hsv.s = LV_CPICKER_DEF_HSV.s; + } break; case LV_CPICKER_COLOR_MODE_VALUE: - ext->hsv.v = LV_CPICKER_DEF_HSV.v; + changed = ext->hsv.v != LV_CPICKER_DEF_HSV.v; + if (changed) + { + ext->hsv.v = LV_CPICKER_DEF_HSV.v; + } break; } ext->prev_hsv = ext->hsv; - lv_cpicker_invalidate(cpicker, false); - - res = lv_event_send(cpicker, LV_EVENT_VALUE_CHANGED, NULL); } ext->last_click = lv_tick_get(); + lv_res_t res = LV_RES_OK; + if (changed) + { + lv_cpicker_invalidate(cpicker, false); + + res = lv_event_send(cpicker, LV_EVENT_VALUE_CHANGED, NULL); + if(res != LV_RES_OK) return res; + } return res; } From 974e4a245eec65dba335d673f181187c9c2747a3 Mon Sep 17 00:00:00 2001 From: Paul Peavyhouse Date: Mon, 30 Sep 2019 15:43:02 -0700 Subject: [PATCH 07/64] Consolidating Disc and Rect lv_cpicker_signal --- src/lv_objx/lv_cpicker.c | 357 ++++++++++++++++++--------------------- 1 file changed, 167 insertions(+), 190 deletions(-) diff --git a/src/lv_objx/lv_cpicker.c b/src/lv_objx/lv_cpicker.c index ad138d126..7250f7689 100644 --- a/src/lv_objx/lv_cpicker.c +++ b/src/lv_objx/lv_cpicker.c @@ -1167,11 +1167,22 @@ static void lv_cpicker_rect_design(lv_obj_t * cpicker, static void lv_cpicker_invalidate(lv_obj_t * cpicker, bool all); -static lv_res_t lv_cpicker_disc_signal(lv_obj_t * cpicker, lv_signal_t sign, void * param, - lv_style_t * style, lv_cpicker_ext_t * ext, - lv_coord_t r_out, lv_coord_t r_in, lv_coord_t x, lv_coord_t y); -static lv_res_t lv_cpicker_rect_signal(lv_obj_t * cpicker, lv_signal_t sign, void * param, - lv_style_t * style, lv_cpicker_ext_t * ext); +static bool lv_cpicker_preview_hit_test(lv_obj_t * cpicker, lv_signal_t sign, lv_indev_t * indev, + lv_cpicker_ext_t * ext); + +static bool lv_cpicker_gradient_hit_test(lv_obj_t * cpicker, lv_signal_t sign, lv_indev_t * indev, + lv_cpicker_ext_t * ext, + float * percent); + +static lv_res_t lv_cpicker_reset_hsv_if_double_clicked(lv_obj_t * cpicker, + lv_cpicker_ext_t * ext); + +static lv_res_t lv_cpicker_set_hsv_percent(lv_obj_t * cpicker, + lv_cpicker_ext_t * ext, + float percent); + +static void lv_cpicker_set_next_color_mode(lv_obj_t * cpicker, + lv_cpicker_ext_t * ext); /** * Signal function of the color_picker @@ -1200,76 +1211,106 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p } buf->type[i] = "lv_cpicker"; } - else + else if(sign == LV_SIGNAL_CONTROL) { lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); - if(sign == LV_SIGNAL_CONTROL) + uint32_t c = *((uint32_t *)param); /*uint32_t because can be UTF-8*/ + if(c == LV_KEY_RIGHT || c == LV_KEY_UP) { - uint32_t c = *((uint32_t *)param); /*uint32_t because can be UTF-8*/ - if(c == LV_KEY_RIGHT || c == LV_KEY_UP) + switch(ext->color_mode) { - switch(ext->color_mode) - { - case LV_CPICKER_COLOR_MODE_HUE: - ext->hsv.h = (ext->hsv.h + 1) % 360; - break; - case LV_CPICKER_COLOR_MODE_SATURATION: - ext->hsv.s = (ext->hsv.s + 1) % 100; - break; - case LV_CPICKER_COLOR_MODE_VALUE: - ext->hsv.v = (ext->hsv.v + 1) % 100; - break; - } - - lv_cpicker_invalidate(cpicker, false); - - res = lv_event_send(cpicker, LV_EVENT_VALUE_CHANGED, NULL); - if(res != LV_RES_OK) return res; + case LV_CPICKER_COLOR_MODE_HUE: + ext->hsv.h = (ext->hsv.h + 1) % 360; + break; + case LV_CPICKER_COLOR_MODE_SATURATION: + ext->hsv.s = (ext->hsv.s + 1) % 100; + break; + case LV_CPICKER_COLOR_MODE_VALUE: + ext->hsv.v = (ext->hsv.v + 1) % 100; + break; } - else if(c == LV_KEY_LEFT || c == LV_KEY_DOWN) - { - switch(ext->color_mode) - { - case LV_CPICKER_COLOR_MODE_HUE: - ext->hsv.h = ext->hsv.h > 0?(ext->hsv.h - 1):360; - break; - case LV_CPICKER_COLOR_MODE_SATURATION: - ext->hsv.s = ext->hsv.s > 0?(ext->hsv.s - 1):100; - break; - case LV_CPICKER_COLOR_MODE_VALUE: - ext->hsv.v = ext->hsv.v > 0?(ext->hsv.v - 1):100; - break; - } - lv_cpicker_invalidate(cpicker, false); - - res = lv_event_send(cpicker, LV_EVENT_VALUE_CHANGED, NULL); - if(res != LV_RES_OK) return res; - } - } - else if(sign == LV_SIGNAL_PRESS_LOST) - { - ext->prev_hsv = ext->hsv; lv_cpicker_invalidate(cpicker, false); - } - else - { - lv_style_t * style = lv_cpicker_get_style(cpicker, LV_CPICKER_STYLE_MAIN); - if(ext->type == LV_CPICKER_TYPE_DISC) + res = lv_event_send(cpicker, LV_EVENT_VALUE_CHANGED, NULL); + if(res != LV_RES_OK) return res; + } + else if(c == LV_KEY_LEFT || c == LV_KEY_DOWN) + { + switch(ext->color_mode) { - lv_coord_t r_out = (LV_MATH_MIN(lv_obj_get_width(cpicker), lv_obj_get_height(cpicker))) / 2; - lv_coord_t r_in = r_out - style->line.width - style->body.padding.inner; - lv_coord_t x = cpicker->coords.x1 + lv_obj_get_width(cpicker) / 2; - lv_coord_t y = cpicker->coords.y1 + lv_obj_get_height(cpicker) / 2; - res = lv_cpicker_disc_signal(cpicker, sign, param, style, ext, r_out, r_in, x, y); - if(res != LV_RES_OK) return res; + case LV_CPICKER_COLOR_MODE_HUE: + ext->hsv.h = ext->hsv.h > 0?(ext->hsv.h - 1):360; + break; + case LV_CPICKER_COLOR_MODE_SATURATION: + ext->hsv.s = ext->hsv.s > 0?(ext->hsv.s - 1):100; + break; + case LV_CPICKER_COLOR_MODE_VALUE: + ext->hsv.v = ext->hsv.v > 0?(ext->hsv.v - 1):100; + break; } - else if(ext->type == LV_CPICKER_TYPE_RECT) + + lv_cpicker_invalidate(cpicker, false); + + res = lv_event_send(cpicker, LV_EVENT_VALUE_CHANGED, NULL); + if(res != LV_RES_OK) return res; + } + } + else if(sign == LV_SIGNAL_PRESSED) + { + lv_indev_t * indev = param; + lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); + + ext->prev_hsv = ext->hsv; + + if(lv_cpicker_preview_hit_test(cpicker, sign, indev, ext)) + { + res = lv_cpicker_reset_hsv_if_double_clicked(cpicker, ext); + if(res != LV_RES_OK) return res; + } + } + else if(sign == LV_SIGNAL_PRESSING) + { + lv_indev_t * indev = param; + lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); + + float percent; + if(lv_cpicker_gradient_hit_test(cpicker, sign, indev, ext, &percent)) + { + res = lv_cpicker_set_hsv_percent(cpicker, ext, percent); + if(res != LV_RES_OK) return res; + } + } + else if(sign == LV_SIGNAL_PRESS_LOST) + { + lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); + + ext->prev_hsv = ext->hsv; + lv_cpicker_invalidate(cpicker, false); + } + else if(sign == LV_SIGNAL_RELEASED) + { + lv_indev_t * indev = param; + lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); + + float percent; + if(lv_cpicker_gradient_hit_test(cpicker, sign, indev, ext, &percent)) + { + res = lv_cpicker_set_hsv_percent(cpicker, ext, percent); + if(res != LV_RES_OK) return res; + } + } + else if(sign == LV_SIGNAL_LONG_PRESS) + { + lv_indev_t * indev = param; + lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); + + if(!ext->color_mode_fixed) + { + if(lv_cpicker_preview_hit_test(cpicker, sign, indev, ext)) { - res = lv_cpicker_rect_signal(cpicker, sign, param, style, ext); - if(res != LV_RES_OK) return res; + lv_cpicker_set_next_color_mode(cpicker, ext); } } } @@ -1277,6 +1318,69 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p return res; } +static bool lv_cpicker_preview_hit_test(lv_obj_t * cpicker, lv_signal_t sign, lv_indev_t * indev, + lv_cpicker_ext_t * ext) +{ + bool hit = false; + if(ext->type == LV_CPICKER_TYPE_DISC) + { + lv_coord_t w = lv_obj_get_width(cpicker); + lv_coord_t h = lv_obj_get_height(cpicker); + lv_style_t * style = lv_cpicker_get_style(cpicker, LV_CPICKER_STYLE_MAIN); + lv_coord_t r_out = (LV_MATH_MIN(w, h)) / 2; + lv_coord_t r_in = r_out - style->line.width - style->body.padding.inner; + lv_point_t center; + center.x = cpicker->coords.x1 + w / 2; + center.y = cpicker->coords.y1 + h / 2; + lv_coord_t xp = indev->proc.types.pointer.act_point.x - center.x; + lv_coord_t yp = indev->proc.types.pointer.act_point.y - center.y; + + hit = (xp*xp + yp*yp) < (r_in*r_in); + } + else if(ext->type == LV_CPICKER_TYPE_RECT) + { + hit = lv_area_is_point_on(&(ext->rect_preview_area), &indev->proc.types.pointer.act_point); + } + return hit; +} + +static bool lv_cpicker_gradient_hit_test(lv_obj_t * cpicker, lv_signal_t sign, lv_indev_t * indev, + lv_cpicker_ext_t * ext, + float * percent) +{ + bool hit; + if(ext->type == LV_CPICKER_TYPE_DISC) + { + lv_coord_t w = lv_obj_get_width(cpicker); + lv_coord_t h = lv_obj_get_height(cpicker); + lv_style_t * style = lv_cpicker_get_style(cpicker, LV_CPICKER_STYLE_MAIN); + lv_coord_t r_out = (LV_MATH_MIN(w, h)) / 2; + lv_coord_t r_in = r_out - style->line.width - style->body.padding.inner; + lv_point_t center; + center.x = cpicker->coords.x1 + w / 2; + center.y = cpicker->coords.y1 + h / 2; + lv_coord_t xp = indev->proc.types.pointer.act_point.x - center.x; + lv_coord_t yp = indev->proc.types.pointer.act_point.y - center.y; + + hit = (xp*xp + yp*yp) < (r_out*r_out) && (xp*xp + yp*yp) >= (r_in*r_in); + if (hit) + { + *percent = lv_atan2(xp, yp) / 360.0; + } + } + else if(ext->type == LV_CPICKER_TYPE_RECT) + { + hit = lv_area_is_point_on(&(ext->rect_gradient_area), &indev->proc.types.pointer.act_point); + if (hit) + { + uint16_t width = ext->rect_gradient_area.x2 - ext->rect_gradient_area.x1; + uint16_t distance = indev->proc.types.pointer.act_point.x - ext->rect_gradient_area.x1; + *percent = distance / (float) width; + } + } + return hit; +} + static lv_res_t lv_cpicker_reset_hsv_if_double_clicked(lv_obj_t * cpicker, lv_cpicker_ext_t * ext) { @@ -1379,133 +1483,6 @@ static lv_res_t lv_cpicker_set_hsv_percent(lv_obj_t * cpicker, return res; } -static lv_res_t lv_cpicker_disc_signal(lv_obj_t * cpicker, lv_signal_t sign, void * param, - lv_style_t * style, lv_cpicker_ext_t * ext, - lv_coord_t r_out, lv_coord_t r_in, lv_coord_t x, lv_coord_t y) -{ - lv_res_t res; - - if(sign == LV_SIGNAL_PRESSED) - { - ext->prev_hsv = ext->hsv; - - lv_indev_t * indev = param; - - lv_coord_t xp = indev->proc.types.pointer.act_point.x - x; - lv_coord_t yp = indev->proc.types.pointer.act_point.y - y; - if((xp*xp + yp*yp) < (r_in*r_in)) - { - res = lv_cpicker_reset_hsv_if_double_clicked(cpicker, ext); - if(res != LV_RES_OK) return res; - } - } - else if(sign == LV_SIGNAL_PRESSING) - { - lv_indev_t * indev = param; - - lv_coord_t xp = indev->proc.types.pointer.act_point.x - x; - lv_coord_t yp = indev->proc.types.pointer.act_point.y - y; - if((xp*xp + yp*yp) < (r_out*r_out) && (xp*xp + yp*yp) >= (r_in*r_in)) - { - float percent = lv_atan2(xp, yp) / 360.0; - - res = lv_cpicker_set_hsv_percent(cpicker, ext, percent); - if(res != LV_RES_OK) return res; - } - } - else if(sign == LV_SIGNAL_RELEASED) - { - lv_indev_t * indev = param; - - lv_coord_t xp = indev->proc.types.pointer.act_point.x - x; - lv_coord_t yp = indev->proc.types.pointer.act_point.y - y; - if((xp*xp + yp*yp) < (r_out*r_out) && (xp*xp + yp*yp) >= (r_in*r_in)) - { - float percent = lv_atan2(xp, yp) / 360.0; - - res = lv_cpicker_set_hsv_percent(cpicker, ext, percent); - if(res != LV_RES_OK) return res; - } - } - else if(sign == LV_SIGNAL_LONG_PRESS) - { - if(!ext->color_mode_fixed) - { - lv_indev_t * indev = param; - - lv_coord_t xp = indev->proc.types.pointer.act_point.x - x; - lv_coord_t yp = indev->proc.types.pointer.act_point.y - y; - if((xp*xp + yp*yp) < (r_in*r_in)) - { - lv_cpicker_set_next_color_mode(cpicker, ext); - } - } - } - - return res; -} - -static lv_res_t lv_cpicker_rect_signal(lv_obj_t * cpicker, lv_signal_t sign, void * param, - lv_style_t * style, lv_cpicker_ext_t * ext) -{ - lv_res_t res; - - if(sign == LV_SIGNAL_PRESSED) - { - ext->prev_hsv = ext->hsv; - - lv_indev_t * indev = param; - - if(lv_area_is_point_on(&(ext->rect_preview_area), &indev->proc.types.pointer.act_point)) - { - res = lv_cpicker_reset_hsv_if_double_clicked(cpicker, ext); - if(res != LV_RES_OK) return res; - } - } - else if(sign == LV_SIGNAL_PRESSING) - { - lv_indev_t * indev = param; - - if(lv_area_is_point_on(&(ext->rect_gradient_area), &indev->proc.types.pointer.act_point)) - { - uint16_t width = ext->rect_gradient_area.x2 - ext->rect_gradient_area.x1; - uint16_t distance = indev->proc.types.pointer.act_point.x - ext->rect_gradient_area.x1; - float percent = distance / (float) width; - - res = lv_cpicker_set_hsv_percent(cpicker, ext, percent); - if(res != LV_RES_OK) return res; - } - } - else if(sign == LV_SIGNAL_RELEASED) - { - lv_indev_t * indev = param; - - if(lv_area_is_point_on(&(ext->rect_gradient_area), &indev->proc.types.pointer.act_point)) - { - uint16_t width = ext->rect_gradient_area.x2 - ext->rect_gradient_area.x1; - uint16_t distance = indev->proc.types.pointer.act_point.x - ext->rect_gradient_area.x1; - float percent = distance / (float) width; - - res = lv_cpicker_set_hsv_percent(cpicker, ext, percent); - if(res != LV_RES_OK) return res; - } - } - else if(sign == LV_SIGNAL_LONG_PRESS) - { - if(!ext->color_mode_fixed) - { - lv_indev_t * indev = param; - - if(lv_area_is_point_on(&(ext->rect_preview_area), &indev->proc.types.pointer.act_point)) - { - lv_cpicker_set_next_color_mode(cpicker, ext); - } - } - } - - return res; -} - static void lv_cpicker_invalidate_disc(lv_disp_t * disp, lv_style_t * style, lv_cpicker_ext_t * ext, From af7b2857eeefc4f7ff039d5d80548051c039e559 Mon Sep 17 00:00:00 2001 From: Paul Peavyhouse Date: Mon, 30 Sep 2019 15:51:18 -0700 Subject: [PATCH 08/64] Moving a method --- src/lv_objx/lv_cpicker.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lv_objx/lv_cpicker.c b/src/lv_objx/lv_cpicker.c index 7250f7689..a99ea6ac4 100644 --- a/src/lv_objx/lv_cpicker.c +++ b/src/lv_objx/lv_cpicker.c @@ -1427,14 +1427,6 @@ static lv_res_t lv_cpicker_reset_hsv_if_double_clicked(lv_obj_t * cpicker, return res; } -static void lv_cpicker_set_next_color_mode(lv_obj_t * cpicker, - lv_cpicker_ext_t * ext) -{ - ext->prev_hsv = ext->hsv; - ext->color_mode = (ext->color_mode + 1) % 3; - lv_cpicker_invalidate(cpicker, true); -} - static lv_res_t lv_cpicker_set_hsv_percent(lv_obj_t * cpicker, lv_cpicker_ext_t * ext, float percent) @@ -1483,6 +1475,14 @@ static lv_res_t lv_cpicker_set_hsv_percent(lv_obj_t * cpicker, return res; } +static void lv_cpicker_set_next_color_mode(lv_obj_t * cpicker, + lv_cpicker_ext_t * ext) +{ + ext->prev_hsv = ext->hsv; + ext->color_mode = (ext->color_mode + 1) % 3; + lv_cpicker_invalidate(cpicker, true); +} + static void lv_cpicker_invalidate_disc(lv_disp_t * disp, lv_style_t * style, lv_cpicker_ext_t * ext, From 994057b578e4de6df752bed4acae02695c398a0e Mon Sep 17 00:00:00 2001 From: Paul Peavyhouse Date: Wed, 2 Oct 2019 15:25:25 -0700 Subject: [PATCH 09/64] Removing extra indentation --- src/lv_objx/lv_cpicker.c | 242 +++++++++++++++++++-------------------- 1 file changed, 121 insertions(+), 121 deletions(-) diff --git a/src/lv_objx/lv_cpicker.c b/src/lv_objx/lv_cpicker.c index 467c62ee2..3d367e9b5 100644 --- a/src/lv_objx/lv_cpicker.c +++ b/src/lv_objx/lv_cpicker.c @@ -544,142 +544,142 @@ static bool lv_cpicker_design(lv_obj_t * cpicker, const lv_area_t * mask, lv_des static void draw_disc_grad(lv_obj_t * cpicker, const lv_area_t * mask, lv_opa_t opa_scale) { - lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); - int16_t start_angle = 0; /*Default*/ - int16_t end_angle = 360 - LV_CPICKER_DEF_QF; /*Default*/ + lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); + int16_t start_angle = 0; /*Default*/ + int16_t end_angle = 360 - LV_CPICKER_DEF_QF; /*Default*/ - lv_coord_t w = lv_obj_get_width(cpicker); - lv_coord_t h = lv_obj_get_height(cpicker); - lv_coord_t cx = cpicker->coords.x1 + w / 2; - lv_coord_t cy = cpicker->coords.y1 + h / 2; - lv_coord_t r = w / 2; + lv_coord_t w = lv_obj_get_width(cpicker); + lv_coord_t h = lv_obj_get_height(cpicker); + lv_coord_t cx = cpicker->coords.x1 + w / 2; + lv_coord_t cy = cpicker->coords.y1 + h / 2; + lv_coord_t r = w / 2; - /*if the mask does not include the center of the object - * redrawing all the wheel is not necessary; - * only a given angular range - */ - lv_point_t center = {cx, cy}; - if(!lv_area_is_point_on(mask, ¢er)) - { - /*get angle from center of object to each corners of the area*/ - int16_t dr, ur, ul, dl; - dr = lv_atan2(mask->x2 - cx, mask->y2 - cy); - ur = lv_atan2(mask->x2 - cx, mask->y1 - cy); - ul = lv_atan2(mask->x1 - cx, mask->y1 - cy); - dl = lv_atan2(mask->x1 - cx, mask->y2 - cy); + /*if the mask does not include the center of the object + * redrawing all the wheel is not necessary; + * only a given angular range + */ + lv_point_t center = {cx, cy}; + if(!lv_area_is_point_on(mask, ¢er)) + { + /*get angle from center of object to each corners of the area*/ + int16_t dr, ur, ul, dl; + dr = lv_atan2(mask->x2 - cx, mask->y2 - cy); + ur = lv_atan2(mask->x2 - cx, mask->y1 - cy); + ul = lv_atan2(mask->x1 - cx, mask->y1 - cy); + dl = lv_atan2(mask->x1 - cx, mask->y2 - cy); - /*check area position from object axis*/ - bool left = (mask->x2 < cx && mask->x1 < cx) ? true : false; - bool onYaxis = (mask->x2 > cx && mask->x1 < cx) ? true : false; - bool right = (mask->x2 > cx && mask->x1 > cx) ? true : false; - bool top = (mask->y2 < cy && mask->y1 < cy) ? true : false; - bool onXaxis = (mask->y2 > cy && mask->y1 < cy) ? true : false; - bool bottom = (mask->y2 > cy && mask->y1 > cy) ? true : false; + /*check area position from object axis*/ + bool left = (mask->x2 < cx && mask->x1 < cx) ? true : false; + bool onYaxis = (mask->x2 > cx && mask->x1 < cx) ? true : false; + bool right = (mask->x2 > cx && mask->x1 > cx) ? true : false; + bool top = (mask->y2 < cy && mask->y1 < cy) ? true : false; + bool onXaxis = (mask->y2 > cy && mask->y1 < cy) ? true : false; + bool bottom = (mask->y2 > cy && mask->y1 > cy) ? true : false; - /*store angular range*/ - if(right && bottom) { - start_angle = dl; - end_angle = ur; - } - else if(right && onXaxis) { - start_angle = dl; - end_angle = ul; - } - else if(right && top) { - start_angle = dr; - end_angle = ul; - } - else if(onYaxis && top) { - start_angle = dr; - end_angle = dl; - } - else if(left && top) { - start_angle = ur; - end_angle = dl; - } - else if(left && onXaxis) { - start_angle = ur; - end_angle = dr; - } - else if(left && bottom) { - start_angle = ul; - end_angle = dr; - } - else if(onYaxis && bottom) { - start_angle = ul; - end_angle = ur; - } - - /*rollover angle*/ - if(start_angle > end_angle) end_angle += 360; - - /*round to QF factor*/ - start_angle = (start_angle/LV_CPICKER_DEF_QF) * LV_CPICKER_DEF_QF; - end_angle = (end_angle / LV_CPICKER_DEF_QF) * LV_CPICKER_DEF_QF; - - /*shift angle if necessary before adding offset*/ - if((start_angle - LV_CPICKER_DEF_QF) < 0) - { - start_angle += 360; - end_angle += 360; - } - - /*ensure overlapping by adding offset*/ - start_angle -= LV_CPICKER_DEF_QF; - end_angle += LV_CPICKER_DEF_QF; + /*store angular range*/ + if(right && bottom) { + start_angle = dl; + end_angle = ur; + } + else if(right && onXaxis) { + start_angle = dl; + end_angle = ul; + } + else if(right && top) { + start_angle = dr; + end_angle = ul; + } + else if(onYaxis && top) { + start_angle = dr; + end_angle = dl; + } + else if(left && top) { + start_angle = ur; + end_angle = dl; + } + else if(left && onXaxis) { + start_angle = ur; + end_angle = dr; + } + else if(left && bottom) { + start_angle = ul; + end_angle = dr; + } + else if(onYaxis && bottom) { + start_angle = ul; + end_angle = ur; } - lv_point_t triangle_points[3]; - lv_style_t style; - lv_style_copy(&style, &lv_style_plain); - for(uint16_t i = start_angle; i <= end_angle; i+= LV_CPICKER_DEF_QF) + /*rollover angle*/ + if(start_angle > end_angle) end_angle += 360; + + /*round to QF factor*/ + start_angle = (start_angle/LV_CPICKER_DEF_QF) * LV_CPICKER_DEF_QF; + end_angle = (end_angle / LV_CPICKER_DEF_QF) * LV_CPICKER_DEF_QF; + + /*shift angle if necessary before adding offset*/ + if((start_angle - LV_CPICKER_DEF_QF) < 0) { - style.body.main_color = angle_to_mode_color(cpicker, i); - style.body.grad_color = style.body.main_color; - - triangle_points[0].x = cx; - triangle_points[0].y = cy; - - triangle_points[1].x = cx + (r * lv_trigo_sin(i) >> LV_TRIGO_SHIFT); - triangle_points[1].y = cy + (r * lv_trigo_sin(i + 90) >> LV_TRIGO_SHIFT); - - if(i == end_angle || i == (360 - LV_CPICKER_DEF_QF)) { - /*the last triangle is drawn without additional overlapping pixels*/ - triangle_points[2].x = cx + (r * lv_trigo_sin(i + LV_CPICKER_DEF_QF) >> LV_TRIGO_SHIFT); - triangle_points[2].y = cy + (r * lv_trigo_sin(i + LV_CPICKER_DEF_QF + 90) >> LV_TRIGO_SHIFT); - } - else { - triangle_points[2].x = cx + (r * lv_trigo_sin(i + LV_CPICKER_DEF_QF + TRI_OFFSET) >> LV_TRIGO_SHIFT); - triangle_points[2].y = cy + (r * lv_trigo_sin(i + LV_CPICKER_DEF_QF + TRI_OFFSET + 90) >> LV_TRIGO_SHIFT); - } - - lv_draw_triangle(triangle_points, mask, &style, LV_OPA_COVER); + start_angle += 360; + end_angle += 360; } - /*Mask out the center area*/ - const lv_style_t * style_main = lv_cpicker_get_style(cpicker, LV_CPICKER_STYLE_MAIN); - lv_style_copy(&style, style_main); - style.body.radius = LV_RADIUS_CIRCLE; - lv_area_t area_mid; - lv_area_copy(&area_mid, &cpicker->coords); + /*ensure overlapping by adding offset*/ + start_angle -= LV_CPICKER_DEF_QF; + end_angle += LV_CPICKER_DEF_QF; + } + + lv_point_t triangle_points[3]; + lv_style_t style; + lv_style_copy(&style, &lv_style_plain); + for(uint16_t i = start_angle; i <= end_angle; i+= LV_CPICKER_DEF_QF) + { + style.body.main_color = angle_to_mode_color(cpicker, i); + style.body.grad_color = style.body.main_color; + + triangle_points[0].x = cx; + triangle_points[0].y = cy; + + triangle_points[1].x = cx + (r * lv_trigo_sin(i) >> LV_TRIGO_SHIFT); + triangle_points[1].y = cy + (r * lv_trigo_sin(i + 90) >> LV_TRIGO_SHIFT); + + if(i == end_angle || i == (360 - LV_CPICKER_DEF_QF)) { + /*the last triangle is drawn without additional overlapping pixels*/ + triangle_points[2].x = cx + (r * lv_trigo_sin(i + LV_CPICKER_DEF_QF) >> LV_TRIGO_SHIFT); + triangle_points[2].y = cy + (r * lv_trigo_sin(i + LV_CPICKER_DEF_QF + 90) >> LV_TRIGO_SHIFT); + } + else { + triangle_points[2].x = cx + (r * lv_trigo_sin(i + LV_CPICKER_DEF_QF + TRI_OFFSET) >> LV_TRIGO_SHIFT); + triangle_points[2].y = cy + (r * lv_trigo_sin(i + LV_CPICKER_DEF_QF + TRI_OFFSET + 90) >> LV_TRIGO_SHIFT); + } + + lv_draw_triangle(triangle_points, mask, &style, LV_OPA_COVER); + } + + /*Mask out the center area*/ + const lv_style_t * style_main = lv_cpicker_get_style(cpicker, LV_CPICKER_STYLE_MAIN); + lv_style_copy(&style, style_main); + style.body.radius = LV_RADIUS_CIRCLE; + lv_area_t area_mid; + lv_area_copy(&area_mid, &cpicker->coords); + area_mid.x1 += style_main->line.width; + area_mid.y1 += style_main->line.width; + area_mid.x2 -= style_main->line.width; + area_mid.y2 -= style_main->line.width; + + lv_draw_rect(&area_mid, mask, &style, opa_scale); + + if(ext->preview) { + lv_color_t color = lv_cpicker_get_color(cpicker); + style.body.main_color = color; + style.body.grad_color = color; area_mid.x1 += style_main->line.width; area_mid.y1 += style_main->line.width; area_mid.x2 -= style_main->line.width; area_mid.y2 -= style_main->line.width; lv_draw_rect(&area_mid, mask, &style, opa_scale); - - if(ext->preview) { - lv_color_t color = lv_cpicker_get_color(cpicker); - style.body.main_color = color; - style.body.grad_color = color; - area_mid.x1 += style_main->line.width; - area_mid.y1 += style_main->line.width; - area_mid.x2 -= style_main->line.width; - area_mid.y2 -= style_main->line.width; - - lv_draw_rect(&area_mid, mask, &style, opa_scale); - } + } } static void draw_rect_grad(lv_obj_t * cpicker, const lv_area_t * mask, lv_opa_t opa_scale) From b49edd91a2eb7462a384902de4413f7a9c9bf6d5 Mon Sep 17 00:00:00 2001 From: Paul Peavyhouse Date: Wed, 2 Oct 2019 16:21:44 -0700 Subject: [PATCH 10/64] All color setters use lv_cpicker_set_hsv and return bool for change --- src/lv_objx/lv_cpicker.c | 126 +++++++++++++++++++-------------------- src/lv_objx/lv_cpicker.h | 21 ++++--- 2 files changed, 74 insertions(+), 73 deletions(-) diff --git a/src/lv_objx/lv_cpicker.c b/src/lv_objx/lv_cpicker.c index 3d367e9b5..937b1b4c3 100644 --- a/src/lv_objx/lv_cpicker.c +++ b/src/lv_objx/lv_cpicker.c @@ -200,88 +200,79 @@ void lv_cpicker_set_style(lv_obj_t * cpicker, lv_cpicker_style_t type, lv_style_ * Set the current hue of a colorpicker. * @param cpicker pointer to colorpicker object * @param hue current selected hue [0..360] + * @return true if changed, otherwise false */ -void lv_cpicker_set_hue(lv_obj_t * cpicker, uint16_t hue) +bool lv_cpicker_set_hue(lv_obj_t * cpicker, uint16_t hue) { - LV_ASSERT_OBJ(cpicker, LV_OBJX_NAME); - - lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); - - ext->hsv.h = hue % 360; - - if(ext->color_mode == LV_CPICKER_COLOR_MODE_HUE) refr_indic_pos(cpicker); - - if(ext->preview && ext->type == LV_CPICKER_TYPE_DISC) { - lv_obj_invalidate(cpicker); - } + lv_color_hsv_t hsv = lv_cpicker_get_hsv(cpicker); + hsv.h = hue; + return lv_cpicker_set_hsv(cpicker, hsv); } /** * Set the current saturation of a colorpicker. * @param cpicker pointer to colorpicker object * @param saturation current selected saturation [0..100] + * @return true if changed, otherwise false */ -void lv_cpicker_set_saturation(lv_obj_t * cpicker, uint8_t saturation) +bool lv_cpicker_set_saturation(lv_obj_t * cpicker, uint8_t saturation) { - LV_ASSERT_OBJ(cpicker, LV_OBJX_NAME); - - lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); - - ext->hsv.s = saturation > 100 ? 100 : saturation; - - if(ext->color_mode == LV_CPICKER_COLOR_MODE_SATURATION) refr_indic_pos(cpicker); - - if(ext->preview && ext->type == LV_CPICKER_TYPE_DISC) { - lv_obj_invalidate(cpicker); - } + lv_color_hsv_t hsv = lv_cpicker_get_hsv(cpicker); + hsv.s = saturation; + return lv_cpicker_set_hsv(cpicker, hsv); } /** * Set the current value of a colorpicker. * @param cpicker pointer to colorpicker object * @param val current selected value [0..100] + * @return true if changed, otherwise false */ -void lv_cpicker_set_value(lv_obj_t * cpicker, uint8_t val) +bool lv_cpicker_set_value(lv_obj_t * cpicker, uint8_t val) { - LV_ASSERT_OBJ(cpicker, LV_OBJX_NAME); - - lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); - - ext->hsv.v = val > 100 ? 100 : val; - - if(ext->color_mode == LV_CPICKER_COLOR_MODE_VALUE) refr_indic_pos(cpicker); - - if(ext->preview && ext->type == LV_CPICKER_TYPE_DISC) { - lv_obj_invalidate(cpicker); - } + lv_color_hsv_t hsv = lv_cpicker_get_hsv(cpicker); + hsv.v = val; + return lv_cpicker_set_hsv(cpicker, hsv); } /** * Set the current hsv of a colorpicker. * @param cpicker pointer to colorpicker object * @param color current selected hsv + * @return true if changed, otherwise false */ -void lv_cpicker_set_hsv(lv_obj_t * cpicker, lv_color_hsv_t hsv) +bool lv_cpicker_set_hsv(lv_obj_t * cpicker, lv_color_hsv_t hsv) { LV_ASSERT_OBJ(cpicker, LV_OBJX_NAME); + if (hsv.h > 360) hsv.h %= 360; + if (hsv.s > 100) hsv.s = 100; + if (hsv.v > 100) hsv.v = 100; + lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); + if (ext->hsv.h == hsv.h && ext->hsv.s == hsv.s && ext->hsv.v == hsv.v) return false; + ext->hsv = hsv; + refr_indic_pos(cpicker); - lv_obj_invalidate(cpicker); + + if (ext->preview && ext->type == LV_CPICKER_TYPE_DISC) { + lv_obj_invalidate(cpicker); + } + + return true; } /** * Set the current color of a colorpicker. * @param cpicker pointer to colorpicker object * @param color current selected color + * @return true if changed, otherwise false */ -void lv_cpicker_set_color(lv_obj_t * cpicker, lv_color_t color) +bool lv_cpicker_set_color(lv_obj_t * cpicker, lv_color_t color) { - LV_ASSERT_OBJ(cpicker, LV_OBJX_NAME); - - lv_cpicker_set_hsv(cpicker, lv_color_rgb_to_hsv(color.ch.red, color.ch.green, color.ch.blue)); + return lv_cpicker_set_hsv(cpicker, lv_color_rgb_to_hsv(color.ch.red, color.ch.green, color.ch.blue)); } /** @@ -834,10 +825,10 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p break; } - lv_cpicker_set_hsv(cpicker, hsv_cur); - - res = lv_event_send(cpicker, LV_EVENT_VALUE_CHANGED, NULL); - if(res != LV_RES_OK) return res; + if (lv_cpicker_set_hsv(cpicker, hsv_cur)) { + res = lv_event_send(cpicker, LV_EVENT_VALUE_CHANGED, NULL); + if(res != LV_RES_OK) return res; + } } else if(c == LV_KEY_LEFT || c == LV_KEY_DOWN) { lv_color_hsv_t hsv_cur; @@ -855,10 +846,10 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p break; } - lv_cpicker_set_hsv(cpicker, hsv_cur); - - res = lv_event_send(cpicker, LV_EVENT_VALUE_CHANGED, NULL); - if(res != LV_RES_OK) return res; + if (lv_cpicker_set_hsv(cpicker, hsv_cur)) { + res = lv_event_send(cpicker, LV_EVENT_VALUE_CHANGED, NULL); + if(res != LV_RES_OK) return res; + } } } else if(sign == LV_SIGNAL_PRESSED) { @@ -927,24 +918,25 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p angle = lv_atan2(p.x, p.y) % 360; } + lv_color_hsv_t hsv_cur; + hsv_cur = ext->hsv; + switch(ext->color_mode) { case LV_CPICKER_COLOR_MODE_HUE: - if(ext->hsv.h != angle) lv_cpicker_set_hue(cpicker, angle); + hsv_cur.h = angle; break; case LV_CPICKER_COLOR_MODE_SATURATION: - angle = (angle * 100) / 360; - if(ext->hsv.s != angle) lv_cpicker_set_saturation(cpicker, angle); + hsv_cur.s = (angle * 100) / 360; break; case LV_CPICKER_COLOR_MODE_VALUE: - angle = (angle * 100) / 360; - if(ext->hsv.v != angle) lv_cpicker_set_value(cpicker, angle); + hsv_cur.v = (angle * 100) / 360; break; } - refr_indic_pos(cpicker); - - res = lv_event_send(cpicker, LV_EVENT_VALUE_CHANGED, NULL); - if(res != LV_RES_OK) return res; + if (lv_cpicker_set_hsv(cpicker, hsv_cur)) { + res = lv_event_send(cpicker, LV_EVENT_VALUE_CHANGED, NULL); + if(res != LV_RES_OK) return res; + } } return res; @@ -1028,21 +1020,25 @@ static lv_res_t double_click_reset(lv_obj_t * cpicker) lv_indev_t * indev = lv_indev_get_act(); /*Double clicked? Use long press time as double click time out*/ if(lv_tick_elaps(ext->last_click_time) < indev->driver.long_press_time) { + lv_color_hsv_t hsv_cur; + hsv_cur = ext->hsv; + switch(ext->color_mode) { case LV_CPICKER_COLOR_MODE_HUE: - lv_cpicker_set_hue(cpicker, LV_CPICKER_DEF_HUE); + hsv_cur.h = LV_CPICKER_DEF_HUE; break; case LV_CPICKER_COLOR_MODE_SATURATION: - lv_cpicker_set_saturation(cpicker, LV_CPICKER_DEF_SATURATION); + hsv_cur.s = LV_CPICKER_DEF_SATURATION; break; case LV_CPICKER_COLOR_MODE_VALUE: - lv_cpicker_set_value(cpicker, LV_CPICKER_DEF_VALUE); + hsv_cur.v = LV_CPICKER_DEF_VALUE; break; } - lv_res_t res; - res = lv_event_send(cpicker, LV_EVENT_VALUE_CHANGED, NULL); - if(res != LV_RES_OK) return res; + if (lv_cpicker_set_hsv(cpicker, hsv_cur)) { + lv_res_t res = lv_event_send(cpicker, LV_EVENT_VALUE_CHANGED, NULL); + if(res != LV_RES_OK) return res; + } } ext->last_click_time = lv_tick_get(); diff --git a/src/lv_objx/lv_cpicker.h b/src/lv_objx/lv_cpicker.h index 7bce0fec8..8ca26dacd 100644 --- a/src/lv_objx/lv_cpicker.h +++ b/src/lv_objx/lv_cpicker.h @@ -106,37 +106,42 @@ void lv_cpicker_set_style(lv_obj_t * cpicker, lv_cpicker_style_t type, lv_style_ /** * Set the current hue of a colorpicker. * @param cpicker pointer to colorpicker object - * @param hue current selected hue + * @param hue current selected hue [0..360] + * @return true if changed, otherwise false */ -void lv_cpicker_set_hue(lv_obj_t * cpicker, uint16_t hue); +bool lv_cpicker_set_hue(lv_obj_t * cpicker, uint16_t hue); /** * Set the current saturation of a colorpicker. * @param cpicker pointer to colorpicker object - * @param saturation current selected saturation + * @param saturation current selected saturation [0..100] + * @return true if changed, otherwise false */ -void lv_cpicker_set_saturation(lv_obj_t * cpicker, uint8_t saturation); +bool lv_cpicker_set_saturation(lv_obj_t * cpicker, uint8_t saturation); /** * Set the current value of a colorpicker. * @param cpicker pointer to colorpicker object - * @param val current selected value + * @param val current selected value [0..100] + * @return true if changed, otherwise false */ -void lv_cpicker_set_value(lv_obj_t * cpicker, uint8_t val); +bool lv_cpicker_set_value(lv_obj_t * cpicker, uint8_t val); /** * Set the current hsv of a colorpicker. * @param cpicker pointer to colorpicker object * @param hsv current selected hsv + * @return true if changed, otherwise false */ -void lv_cpicker_set_hsv(lv_obj_t * cpicker, lv_color_hsv_t hsv); +bool lv_cpicker_set_hsv(lv_obj_t * cpicker, lv_color_hsv_t hsv); /** * Set the current color of a colorpicker. * @param cpicker pointer to colorpicker object * @param color current selected color + * @return true if changed, otherwise false */ -void lv_cpicker_set_color(lv_obj_t * cpicker, lv_color_t color); +bool lv_cpicker_set_color(lv_obj_t * cpicker, lv_color_t color); /** * Set the current color mode. From c74e6a6207b9f4c02410cf25e592c224f90f477f Mon Sep 17 00:00:00 2001 From: Paul Peavyhouse Date: Wed, 2 Oct 2019 21:14:28 -0700 Subject: [PATCH 11/64] Shrinking the gap between outer ring and inner preview a little --- src/lv_misc/lv_area.c | 13 +++++++++++++ src/lv_misc/lv_area.h | 7 +++++++ src/lv_objx/lv_cpicker.c | 10 ++-------- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/lv_misc/lv_area.c b/src/lv_misc/lv_area.c index 025e1733e..de649c5b0 100644 --- a/src/lv_misc/lv_area.c +++ b/src/lv_misc/lv_area.c @@ -192,6 +192,19 @@ bool lv_area_is_in(const lv_area_t * ain_p, const lv_area_t * aholder_p) return is_in; } +/** + * Increment or decrement an area's size by a single amount + * @param a_p pointer to an area to grow + * @param amount amount to increment the area, or negative to decrement + */ +void lv_area_increment(lv_area_t * a_p, const lv_coord_t amount) +{ + a_p->x1 -= amount; + a_p->y1 -= amount; + a_p->x2 += amount; + a_p->y2 += amount; +} + /********************** * STATIC FUNCTIONS **********************/ diff --git a/src/lv_misc/lv_area.h b/src/lv_misc/lv_area.h index 30b62cbec..3f8e8446a 100644 --- a/src/lv_misc/lv_area.h +++ b/src/lv_misc/lv_area.h @@ -165,6 +165,13 @@ bool lv_area_is_on(const lv_area_t * a1_p, const lv_area_t * a2_p); */ bool lv_area_is_in(const lv_area_t * ain_p, const lv_area_t * aholder_p); +/** + * Increment or decrement an area's size by a single amount + * @param a_p pointer to an area to grow + * @param amount amount to increment the area, or negative to decrement + */ +void lv_area_increment(lv_area_t * a_p, const lv_coord_t amount); + /********************** * MACROS **********************/ diff --git a/src/lv_objx/lv_cpicker.c b/src/lv_objx/lv_cpicker.c index 937b1b4c3..d4c259148 100644 --- a/src/lv_objx/lv_cpicker.c +++ b/src/lv_objx/lv_cpicker.c @@ -653,10 +653,7 @@ static void draw_disc_grad(lv_obj_t * cpicker, const lv_area_t * mask, lv_opa_t style.body.radius = LV_RADIUS_CIRCLE; lv_area_t area_mid; lv_area_copy(&area_mid, &cpicker->coords); - area_mid.x1 += style_main->line.width; - area_mid.y1 += style_main->line.width; - area_mid.x2 -= style_main->line.width; - area_mid.y2 -= style_main->line.width; + lv_area_increment(&area_mid, -style_main->line.width); lv_draw_rect(&area_mid, mask, &style, opa_scale); @@ -664,10 +661,7 @@ static void draw_disc_grad(lv_obj_t * cpicker, const lv_area_t * mask, lv_opa_t lv_color_t color = lv_cpicker_get_color(cpicker); style.body.main_color = color; style.body.grad_color = color; - area_mid.x1 += style_main->line.width; - area_mid.y1 += style_main->line.width; - area_mid.x2 -= style_main->line.width; - area_mid.y2 -= style_main->line.width; + lv_area_increment(&area_mid, -style_main->line.width / 2); lv_draw_rect(&area_mid, mask, &style, opa_scale); } From ca9c4c8fda5183715596f54e3cc96c422d4c2080 Mon Sep 17 00:00:00 2001 From: Paul Peavyhouse Date: Thu, 3 Oct 2019 03:11:38 -0700 Subject: [PATCH 12/64] Code formatting --- src/lv_objx/lv_cpicker.c | 49 +++++++++++++++------------------------- 1 file changed, 18 insertions(+), 31 deletions(-) diff --git a/src/lv_objx/lv_cpicker.c b/src/lv_objx/lv_cpicker.c index d4c259148..898982142 100644 --- a/src/lv_objx/lv_cpicker.c +++ b/src/lv_objx/lv_cpicker.c @@ -571,46 +571,38 @@ static void draw_disc_grad(lv_obj_t * cpicker, const lv_area_t * mask, lv_opa_t if(right && bottom) { start_angle = dl; end_angle = ur; - } - else if(right && onXaxis) { + } else if(right && onXaxis) { start_angle = dl; end_angle = ul; - } - else if(right && top) { + } else if(right && top) { start_angle = dr; end_angle = ul; - } - else if(onYaxis && top) { + } else if(onYaxis && top) { start_angle = dr; end_angle = dl; - } - else if(left && top) { + } else if(left && top) { start_angle = ur; end_angle = dl; - } - else if(left && onXaxis) { + } else if(left && onXaxis) { start_angle = ur; end_angle = dr; - } - else if(left && bottom) { + } else if(left && bottom) { start_angle = ul; end_angle = dr; - } - else if(onYaxis && bottom) { + } else if(onYaxis && bottom) { start_angle = ul; end_angle = ur; } /*rollover angle*/ - if(start_angle > end_angle) end_angle += 360; + if(start_angle > end_angle) end_angle += 360; /*round to QF factor*/ start_angle = (start_angle/LV_CPICKER_DEF_QF) * LV_CPICKER_DEF_QF; end_angle = (end_angle / LV_CPICKER_DEF_QF) * LV_CPICKER_DEF_QF; /*shift angle if necessary before adding offset*/ - if((start_angle - LV_CPICKER_DEF_QF) < 0) - { + if((start_angle - LV_CPICKER_DEF_QF) < 0) { start_angle += 360; end_angle += 360; } @@ -623,8 +615,7 @@ static void draw_disc_grad(lv_obj_t * cpicker, const lv_area_t * mask, lv_opa_t lv_point_t triangle_points[3]; lv_style_t style; lv_style_copy(&style, &lv_style_plain); - for(uint16_t i = start_angle; i <= end_angle; i+= LV_CPICKER_DEF_QF) - { + for(uint16_t i = start_angle; i <= end_angle; i+= LV_CPICKER_DEF_QF) { style.body.main_color = angle_to_mode_color(cpicker, i); style.body.grad_color = style.body.main_color; @@ -638,8 +629,7 @@ static void draw_disc_grad(lv_obj_t * cpicker, const lv_area_t * mask, lv_opa_t /*the last triangle is drawn without additional overlapping pixels*/ triangle_points[2].x = cx + (r * lv_trigo_sin(i + LV_CPICKER_DEF_QF) >> LV_TRIGO_SHIFT); triangle_points[2].y = cy + (r * lv_trigo_sin(i + LV_CPICKER_DEF_QF + 90) >> LV_TRIGO_SHIFT); - } - else { + } else { triangle_points[2].x = cx + (r * lv_trigo_sin(i + LV_CPICKER_DEF_QF + TRI_OFFSET) >> LV_TRIGO_SHIFT); triangle_points[2].y = cy + (r * lv_trigo_sin(i + LV_CPICKER_DEF_QF + TRI_OFFSET + 90) >> LV_TRIGO_SHIFT); } @@ -728,8 +718,9 @@ static void draw_rect_grad(lv_obj_t * cpicker, const lv_area_t * mask, lv_opa_t lv_draw_rect(&rect_area, mask, &style, opa_scale); } } + /** - * Should roughly match up with `lv_cpicker_invalidate_disc_indicator_circle` + * Should roughly match up with `invalidate_indic` */ static void draw_indic(lv_obj_t * cpicker, const lv_area_t * mask, lv_opa_t opa_scale) { @@ -757,7 +748,6 @@ static void draw_indic(lv_obj_t * cpicker, const lv_area_t * mask, lv_opa_t opa_ style_cir.body.grad_color = style_cir.body.main_color; } - lv_draw_rect(&ind_area, mask, &style_cir, opa_scale); } @@ -791,8 +781,7 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p } else if(sign == LV_SIGNAL_CORD_CHG) { /*Refresh extended draw area to make knob visible*/ if(lv_obj_get_width(cpicker) != lv_area_get_width(param) || - lv_obj_get_height(cpicker) != lv_area_get_height(param)) - { + lv_obj_get_height(cpicker) != lv_area_get_height(param)) { lv_obj_refresh_ext_draw_pad(cpicker); refr_indic_pos(cpicker); } @@ -851,7 +840,7 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p lv_indev_get_point(lv_indev_get_act(), &ext->last_press_point); res = double_click_reset(cpicker); if(res != LV_RES_OK) return res; - } else if(sign == LV_SIGNAL_PRESSING){ + } else if(sign == LV_SIGNAL_PRESSING) { lv_indev_t * indev = lv_indev_get_act(); if(indev == NULL) return res; @@ -936,7 +925,7 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p return res; } -static void next_color_mode(lv_obj_t * cpicker ) +static void next_color_mode(lv_obj_t * cpicker) { lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); ext->color_mode = (ext->color_mode + 1) % 3; @@ -946,11 +935,10 @@ static void next_color_mode(lv_obj_t * cpicker ) /** - * Indicator points need to match those set in lv_cpicker_disc_design/lv_cpicker_rect_design + * Should roughly match up with `draw_indic` */ static void invalidate_indic(lv_obj_t * cpicker) { - lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); const lv_style_t * style_main = lv_cpicker_get_style(cpicker, LV_CPICKER_STYLE_MAIN); const lv_style_t * style_indic = lv_cpicker_get_style(cpicker, LV_CPICKER_STYLE_INDICATOR); @@ -994,8 +982,7 @@ static void refr_indic_pos(lv_obj_t * cpicker) ext->indic.pos.x = ind_pos; ext->indic.pos.y = h / 2; - } - if(ext->type == LV_CPICKER_TYPE_DISC) { + } else if(ext->type == LV_CPICKER_TYPE_DISC) { const lv_style_t * style_main = lv_cpicker_get_style(cpicker, LV_CPICKER_STYLE_MAIN); lv_coord_t r = w / 2 - style_main->line.width / 2; uint16_t angle = get_angle(cpicker); From 61dfb5664868ecb33bcce6f276fd45026af6fc0c Mon Sep 17 00:00:00 2001 From: Paul Peavyhouse Date: Thu, 3 Oct 2019 04:02:38 -0700 Subject: [PATCH 13/64] Consolidating common indicator_area calculation code --- src/lv_objx/lv_cpicker.c | 78 +++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 41 deletions(-) diff --git a/src/lv_objx/lv_cpicker.c b/src/lv_objx/lv_cpicker.c index 898982142..7cb21610a 100644 --- a/src/lv_objx/lv_cpicker.c +++ b/src/lv_objx/lv_cpicker.c @@ -57,10 +57,11 @@ static bool lv_cpicker_design(lv_obj_t * cpicker, const lv_area_t * mask, lv_design_mode_t mode); static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * param); -static void invalidate_indic(lv_obj_t * cpicker); static void draw_rect_grad(lv_obj_t * cpicker, const lv_area_t * mask, lv_opa_t opa_scale); static void draw_disc_grad(lv_obj_t * cpicker, const lv_area_t * mask, lv_opa_t opa_scale); static void draw_indic(lv_obj_t * cpicker, const lv_area_t * mask, lv_opa_t opa_scale); +static void invalidate_indic(lv_obj_t * cpicker); +static lv_area_t get_indic_area(lv_obj_t * cpicker, const lv_style_t * style_main, const lv_style_t * style_indic, lv_cpicker_ext_t * ext); static void next_color_mode(lv_obj_t * cpicker); static lv_res_t double_click_reset(lv_obj_t * cpicker); @@ -719,25 +720,13 @@ static void draw_rect_grad(lv_obj_t * cpicker, const lv_area_t * mask, lv_opa_t } } -/** - * Should roughly match up with `invalidate_indic` - */ static void draw_indic(lv_obj_t * cpicker, const lv_area_t * mask, lv_opa_t opa_scale) { lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); const lv_style_t * style_main = lv_cpicker_get_style(cpicker, LV_CPICKER_STYLE_MAIN); const lv_style_t * style_indic = lv_cpicker_get_style(cpicker, LV_CPICKER_STYLE_INDICATOR); - lv_coord_t h = lv_obj_get_height(cpicker); - uint16_t r; - if(ext->type == LV_CPICKER_TYPE_DISC) r = style_main->line.width / 2; - else if(ext->type == LV_CPICKER_TYPE_RECT) r = h / 2; - - lv_area_t ind_area; - ind_area.x1 = cpicker->coords.x1 + ext->indic.pos.x - r - style_indic->body.padding.left; - ind_area.y1 = cpicker->coords.y1 + ext->indic.pos.y - r - style_indic->body.padding.right; - ind_area.x2 = cpicker->coords.x1 + ext->indic.pos.x + r + style_indic->body.padding.top; - ind_area.y2 = cpicker->coords.y1 + ext->indic.pos.y + r + style_indic->body.padding.bottom; + lv_area_t indic_area = get_indic_area(cpicker, style_main, style_indic, ext); lv_style_t style_cir; lv_style_copy(&style_cir, ext->indic.style); @@ -748,7 +737,39 @@ static void draw_indic(lv_obj_t * cpicker, const lv_area_t * mask, lv_opa_t opa_ style_cir.body.grad_color = style_cir.body.main_color; } - lv_draw_rect(&ind_area, mask, &style_cir, opa_scale); + lv_draw_rect(&indic_area, mask, &style_cir, opa_scale); +} + +static void invalidate_indic(lv_obj_t * cpicker) +{ + lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); + const lv_style_t * style_main = lv_cpicker_get_style(cpicker, LV_CPICKER_STYLE_MAIN); + const lv_style_t * style_indic = lv_cpicker_get_style(cpicker, LV_CPICKER_STYLE_INDICATOR); + + lv_area_t indic_area = get_indic_area(cpicker, style_main, style_indic, ext); + + lv_inv_area(lv_obj_get_disp(cpicker), &indic_area); +} + +static lv_area_t get_indic_area(lv_obj_t * cpicker, + const lv_style_t * style_main, + const lv_style_t * style_indic, + const lv_cpicker_ext_t * ext) +{ + uint16_t r; + if(ext->type == LV_CPICKER_TYPE_DISC) r = style_main->line.width / 2; + else if(ext->type == LV_CPICKER_TYPE_RECT) { + lv_coord_t h = lv_obj_get_height(cpicker); + r = h / 2; + } + + lv_area_t indic_area; + indic_area.x1 = cpicker->coords.x1 + ext->indic.pos.x - r - style_indic->body.padding.left; + indic_area.y1 = cpicker->coords.y1 + ext->indic.pos.y - r - style_indic->body.padding.right; + indic_area.x2 = cpicker->coords.x1 + ext->indic.pos.x + r + style_indic->body.padding.top; + indic_area.y2 = cpicker->coords.y1 + ext->indic.pos.y + r + style_indic->body.padding.bottom; + + return indic_area; } /** @@ -933,31 +954,6 @@ static void next_color_mode(lv_obj_t * cpicker) lv_obj_invalidate(cpicker); } - -/** - * Should roughly match up with `draw_indic` - */ -static void invalidate_indic(lv_obj_t * cpicker) -{ - lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); - const lv_style_t * style_main = lv_cpicker_get_style(cpicker, LV_CPICKER_STYLE_MAIN); - const lv_style_t * style_indic = lv_cpicker_get_style(cpicker, LV_CPICKER_STYLE_INDICATOR); - - lv_coord_t h = lv_obj_get_height(cpicker); - - uint16_t r; - if(ext->type == LV_CPICKER_TYPE_DISC) r = style_main->line.width / 2; - else if(ext->type == LV_CPICKER_TYPE_RECT) r = h / 2; - - lv_area_t indic_area; - indic_area.x1 = cpicker->coords.x1 + ext->indic.pos.x - r - style_indic->body.padding.left; - indic_area.y1 = cpicker->coords.y1 + ext->indic.pos.y - r - style_indic->body.padding.top; - indic_area.x2 = cpicker->coords.x1 + ext->indic.pos.x + r + style_indic->body.padding.right; - indic_area.y2 = cpicker->coords.y1 + ext->indic.pos.y + r + style_indic->body.padding.bottom; - - lv_inv_area(lv_obj_get_disp(cpicker), &indic_area); -} - static void refr_indic_pos(lv_obj_t * cpicker) { invalidate_indic(cpicker); @@ -989,7 +985,7 @@ static void refr_indic_pos(lv_obj_t * cpicker) ext->indic.pos.x = (((int32_t)r * lv_trigo_sin(angle)) >> LV_TRIGO_SHIFT); ext->indic.pos.y = (((int32_t)r * lv_trigo_sin(angle + 90)) >> LV_TRIGO_SHIFT); ext->indic.pos.x = ext->indic.pos.x + w / 2; - ext->indic.pos.y = ext->indic.pos.y + w / 2; + ext->indic.pos.y = ext->indic.pos.y + h / 2; } invalidate_indic(cpicker); From 68c39030a6c73703dc248257bac4e92e9201860b Mon Sep 17 00:00:00 2001 From: Paul Peavyhouse Date: Thu, 3 Oct 2019 04:04:27 -0700 Subject: [PATCH 14/64] Missed a line! --- src/lv_objx/lv_cpicker.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lv_objx/lv_cpicker.c b/src/lv_objx/lv_cpicker.c index 7cb21610a..d0061ae2c 100644 --- a/src/lv_objx/lv_cpicker.c +++ b/src/lv_objx/lv_cpicker.c @@ -61,7 +61,10 @@ static void draw_rect_grad(lv_obj_t * cpicker, const lv_area_t * mask, lv_opa_t static void draw_disc_grad(lv_obj_t * cpicker, const lv_area_t * mask, lv_opa_t opa_scale); static void draw_indic(lv_obj_t * cpicker, const lv_area_t * mask, lv_opa_t opa_scale); static void invalidate_indic(lv_obj_t * cpicker); -static lv_area_t get_indic_area(lv_obj_t * cpicker, const lv_style_t * style_main, const lv_style_t * style_indic, lv_cpicker_ext_t * ext); +static lv_area_t get_indic_area(lv_obj_t * cpicker, + const lv_style_t * style_main, + const lv_style_t * style_indic, + const lv_cpicker_ext_t * ext); static void next_color_mode(lv_obj_t * cpicker); static lv_res_t double_click_reset(lv_obj_t * cpicker); From 34faac98a734c73a3be6ee46bd897f267924a349 Mon Sep 17 00:00:00 2001 From: Paul Peavyhouse Date: Thu, 3 Oct 2019 23:35:57 -0700 Subject: [PATCH 15/64] Cleaner calls to `get_indic_area` --- src/lv_objx/lv_cpicker.c | 35 ++++++++++++----------------------- src/lv_objx/lv_cpicker.h | 2 +- 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/src/lv_objx/lv_cpicker.c b/src/lv_objx/lv_cpicker.c index d0061ae2c..459d37213 100644 --- a/src/lv_objx/lv_cpicker.c +++ b/src/lv_objx/lv_cpicker.c @@ -61,10 +61,7 @@ static void draw_rect_grad(lv_obj_t * cpicker, const lv_area_t * mask, lv_opa_t static void draw_disc_grad(lv_obj_t * cpicker, const lv_area_t * mask, lv_opa_t opa_scale); static void draw_indic(lv_obj_t * cpicker, const lv_area_t * mask, lv_opa_t opa_scale); static void invalidate_indic(lv_obj_t * cpicker); -static lv_area_t get_indic_area(lv_obj_t * cpicker, - const lv_style_t * style_main, - const lv_style_t * style_indic, - const lv_cpicker_ext_t * ext); +static lv_area_t get_indic_area(lv_obj_t * cpicker); static void next_color_mode(lv_obj_t * cpicker); static lv_res_t double_click_reset(lv_obj_t * cpicker); @@ -125,7 +122,6 @@ lv_obj_t * lv_cpicker_create(lv_obj_t * par, const lv_obj_t * copy) /*If no copy do the basic initialization*/ if(copy == NULL) { lv_obj_set_protect(new_cpicker, LV_PROTECT_PRESS_LOST); - refr_indic_pos(new_cpicker); lv_theme_t * th = lv_theme_get_current(); if(th) { lv_cpicker_set_style(new_cpicker, LV_CPICKER_STYLE_MAIN, th->style.bg); @@ -550,9 +546,9 @@ static void draw_disc_grad(lv_obj_t * cpicker, const lv_area_t * mask, lv_opa_t lv_coord_t r = w / 2; /*if the mask does not include the center of the object - * redrawing all the wheel is not necessary; - * only a given angular range - */ + * redrawing all the wheel is not necessary; + * only a given angular range + */ lv_point_t center = {cx, cy}; if(!lv_area_is_point_on(mask, ¢er)) { @@ -726,10 +722,6 @@ static void draw_rect_grad(lv_obj_t * cpicker, const lv_area_t * mask, lv_opa_t static void draw_indic(lv_obj_t * cpicker, const lv_area_t * mask, lv_opa_t opa_scale) { lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); - const lv_style_t * style_main = lv_cpicker_get_style(cpicker, LV_CPICKER_STYLE_MAIN); - const lv_style_t * style_indic = lv_cpicker_get_style(cpicker, LV_CPICKER_STYLE_INDICATOR); - - lv_area_t indic_area = get_indic_area(cpicker, style_main, style_indic, ext); lv_style_t style_cir; lv_style_copy(&style_cir, ext->indic.style); @@ -740,25 +732,24 @@ static void draw_indic(lv_obj_t * cpicker, const lv_area_t * mask, lv_opa_t opa_ style_cir.body.grad_color = style_cir.body.main_color; } + lv_area_t indic_area = get_indic_area(cpicker); + lv_draw_rect(&indic_area, mask, &style_cir, opa_scale); } static void invalidate_indic(lv_obj_t * cpicker) { - lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); - const lv_style_t * style_main = lv_cpicker_get_style(cpicker, LV_CPICKER_STYLE_MAIN); - const lv_style_t * style_indic = lv_cpicker_get_style(cpicker, LV_CPICKER_STYLE_INDICATOR); - - lv_area_t indic_area = get_indic_area(cpicker, style_main, style_indic, ext); + lv_area_t indic_area = get_indic_area(cpicker); lv_inv_area(lv_obj_get_disp(cpicker), &indic_area); } -static lv_area_t get_indic_area(lv_obj_t * cpicker, - const lv_style_t * style_main, - const lv_style_t * style_indic, - const lv_cpicker_ext_t * ext) +static lv_area_t get_indic_area(lv_obj_t * cpicker) { + lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); + const lv_style_t * style_main = lv_cpicker_get_style(cpicker, LV_CPICKER_STYLE_MAIN); + const lv_style_t * style_indic = lv_cpicker_get_style(cpicker, LV_CPICKER_STYLE_INDICATOR); + uint16_t r; if(ext->type == LV_CPICKER_TYPE_DISC) r = style_main->line.width / 2; else if(ext->type == LV_CPICKER_TYPE_RECT) { @@ -959,8 +950,6 @@ static void next_color_mode(lv_obj_t * cpicker) static void refr_indic_pos(lv_obj_t * cpicker) { - invalidate_indic(cpicker); - lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); lv_coord_t w = lv_obj_get_width(cpicker); lv_coord_t h = lv_obj_get_height(cpicker); diff --git a/src/lv_objx/lv_cpicker.h b/src/lv_objx/lv_cpicker.h index 8ca26dacd..a9feee5ae 100644 --- a/src/lv_objx/lv_cpicker.h +++ b/src/lv_objx/lv_cpicker.h @@ -93,7 +93,7 @@ lv_obj_t * lv_cpicker_create(lv_obj_t * par, const lv_obj_t * copy); * @param cpicker pointer to a colorpicker object * @param type new type of the colorpicker (from 'lv_cpicker_type_t' enum) */ -void lv_cpicker_set_type(lv_obj_t * chart, lv_cpicker_type_t type); +void lv_cpicker_set_type(lv_obj_t * cpicker, lv_cpicker_type_t type); /** * Set a style of a colorpicker. From 770645ecd06553327418f30684ffd5e538ae2b33 Mon Sep 17 00:00:00 2001 From: Amir Gonnen Date: Fri, 27 Sep 2019 22:32:45 +0300 Subject: [PATCH 16/64] add Hebrew font --- src/lv_font/lv_font_heb_16.c | 1133 ++++++++++++++++++++++++++++++++++ 1 file changed, 1133 insertions(+) create mode 100644 src/lv_font/lv_font_heb_16.c diff --git a/src/lv_font/lv_font_heb_16.c b/src/lv_font/lv_font_heb_16.c new file mode 100644 index 000000000..5cff45178 --- /dev/null +++ b/src/lv_font/lv_font_heb_16.c @@ -0,0 +1,1133 @@ +#include "lvgl/lvgl.h" + +/******************************************************************************* + * Size: 16 px + * Bpp: 4 + * Opts: --font /usr/share/fonts/truetype/culmus/FrankRuehlCLM-Medium.ttf -r 0x20-0x7F -r 0x5d0-0x5ea --size 16 --format lvgl --bpp 4 --no-compress -o /home/amirgon/esp/projects/lv_mpy/lib/lv_bindings/lvgl/src/lv_font/lv_font_heb_16.c + ******************************************************************************/ + +#ifndef LV_FONT_HEB_16 +#define LV_FONT_HEB_16 1 +#endif + +#if LV_FONT_HEB_16 + +/*----------------- + * BITMAPS + *----------------*/ + +/*Store the image of the glyphs*/ +static LV_ATTRIBUTE_LARGE_CONST const uint8_t gylph_bitmap[] = { + /* U+20 " " */ + + /* U+21 "!" */ + 0xab, 0xef, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x1, + 0x46, 0xde, 0x57, + + /* U+22 "\"" */ + 0xa, 0xc3, 0xe4, 0xf, 0x87, 0xf1, 0x1f, 0x18, + 0x90, 0x2a, 0x9, 0x20, 0x12, 0x3, 0x0, + + /* U+23 "#" */ + 0x0, 0x69, 0xc, 0x20, 0x0, 0x86, 0x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x7, 0xa0, 0x3, 0xf2, + 0xb, 0xe0, 0xa1, 0x0, 0x4f, 0x60, 0x2f, 0xc6, + 0x2, 0x20, 0xee, 0x30, 0x9f, 0xa3, 0xb1, 0x3, + 0xcf, 0xc6, 0x6e, 0xe5, 0x0, + + /* U+27 "'" */ + 0xa, 0xc0, 0xf8, 0x1f, 0x12, 0xa0, 0x12, 0x0, + + /* U+28 "(" */ + 0x0, 0x6, 0x0, 0xa6, 0x6, 0xc0, 0xe, 0x60, + 0x4f, 0x30, 0x6f, 0x10, 0x7f, 0x0, 0x7f, 0x10, + 0x4f, 0x20, 0xe, 0x60, 0x7, 0xb0, 0x0, 0xb4, + 0x0, 0x7, + + /* U+29 ")" */ + 0x24, 0x0, 0x0, 0xb5, 0x0, 0x2, 0xf1, 0x0, + 0xc, 0x80, 0x0, 0x8e, 0x0, 0x7, 0xf1, 0x0, + 0x6f, 0x20, 0x7, 0xf1, 0x0, 0x8e, 0x0, 0xb, + 0x90, 0x1, 0xf2, 0x0, 0xa6, 0x0, 0x25, 0x0, + 0x0, + + /* U+2A "*" */ + 0x0, 0xb, 0x0, 0x0, 0x50, 0xb0, 0x50, 0x1c, + 0x77, 0x7b, 0x0, 0x6, 0xf4, 0x0, 0x1d, 0x57, + 0x7d, 0x0, 0x30, 0xc0, 0x40, 0x0, 0x9, 0x0, + 0x0, + + /* U+2B "+" */ + 0x0, 0x4, 0x40, 0x0, 0x0, 0x8, 0x90, 0x0, + 0x0, 0x8, 0x90, 0x0, 0x0, 0x8, 0x90, 0x0, + 0x4f, 0xff, 0xff, 0xf6, 0x2, 0x29, 0xa2, 0x21, + 0x0, 0x8, 0x90, 0x0, 0x0, 0x8, 0x90, 0x0, + + /* U+2C "," */ + 0x3b, 0xa, 0xf4, 0x4c, 0x6, 0x40, 0x10, 0x0, + + /* U+2D "-" */ + 0x19, 0x99, 0x90, 0x5f, 0xff, 0xd0, + + /* U+2E "." */ + 0x18, 0xa, 0xf3, 0x3b, 0x0, + + /* U+2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a0, 0xb, 0x0, + 0x4, 0xf1, 0x19, 0x0, 0x0, 0xe6, 0x73, 0x0, + 0x0, 0x8d, 0xb0, 0x0, 0x0, 0x2f, 0x80, 0x0, + 0x0, 0xb, 0x20, 0x0, 0x0, 0xa, 0x0, 0x0, + 0xc6, 0x74, 0x0, 0x0, 0xad, 0x70, 0x0, 0x0, + + /* U+7A "z" */ + 0x2f, 0xba, 0xfa, 0x29, 0x6, 0xf2, 0x13, 0x1e, + 0x70, 0x0, 0xad, 0x0, 0x4, 0xf3, 0x6, 0xd, + 0x90, 0x1b, 0x6f, 0xba, 0xeb, + + /* U+7B "{" */ + 0x0, 0x99, 0x0, 0xf0, 0x1, 0xe0, 0x1, 0xe0, + 0x2, 0xd0, 0xb, 0x60, 0x8, 0x90, 0x1, 0xd0, + 0x1, 0xe0, 0x1, 0xe0, 0x0, 0xf0, 0x0, 0x69, + + /* U+7C "|" */ + 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, + 0x79, 0x79, 0x79, + + /* U+7D "}" */ + 0x4c, 0x20, 0x8, 0x70, 0x7, 0x80, 0x7, 0x80, + 0x6, 0x90, 0x1, 0xc4, 0x3, 0xc2, 0x7, 0x80, + 0x7, 0x80, 0x7, 0x80, 0x9, 0x60, 0x49, 0x10, + + /* U+7E "~" */ + 0x8, 0xeb, 0x50, 0x72, 0x1a, 0x15, 0xdf, 0xb0, + 0x0, 0x0, 0x1, 0x0, + + /* U+5D0 "א" */ + 0x5, 0x0, 0x3, 0x0, 0xe, 0x80, 0x3f, 0xd3, + 0x9, 0xf5, 0x1d, 0xf7, 0x0, 0xcf, 0x37, 0x61, + 0x2, 0xde, 0xed, 0x0, 0xb, 0x82, 0xff, 0x0, + 0xd, 0xd0, 0x5f, 0xa0, 0xb, 0xf5, 0x7, 0xf5, + 0x2f, 0xf7, 0x0, 0xb5, 0x0, 0x0, 0x0, 0x0, + + /* U+5D1 "ב" */ + 0x13, 0x0, 0x0, 0x4, 0xff, 0xff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x4, 0xb0, 0x0, 0x86, + 0x3, 0xd0, 0x0, 0x86, 0x6e, 0xf0, 0x0, 0x86, + 0xaf, 0xb0, 0x0, 0x73 +}; + + +/*--------------------- + * GLYPH DESCRIPTION + *--------------------*/ + +static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = { + {.bitmap_index = 0, .adv_w = 0, .box_w = 0, .box_h = 0, .ofs_x = 0, .ofs_y = 0} /* id = 0 reserved */, + {.bitmap_index = 0, .adv_w = 80, .box_w = 0, .box_h = 0, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 0, .adv_w = 64, .box_w = 2, .box_h = 11, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 11, .adv_w = 96, .box_w = 6, .box_h = 5, .ofs_x = 0, .ofs_y = 6}, + {.bitmap_index = 26, .adv_w = 128, .box_w = 8, .box_h = 10, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 66, .adv_w = 112, .box_w = 7, .box_h = 14, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 115, .adv_w = 176, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 176, .adv_w = 176, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 237, .adv_w = 48, .box_w = 3, .box_h = 5, .ofs_x = 0, .ofs_y = 6}, + {.bitmap_index = 245, .adv_w = 80, .box_w = 4, .box_h = 13, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 271, .adv_w = 80, .box_w = 5, .box_h = 13, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 304, .adv_w = 112, .box_w = 7, .box_h = 7, .ofs_x = 0, .ofs_y = 4}, + {.bitmap_index = 329, .adv_w = 128, .box_w = 8, .box_h = 8, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 361, .adv_w = 64, .box_w = 3, .box_h = 5, .ofs_x = 1, .ofs_y = -2}, + {.bitmap_index = 369, .adv_w = 96, .box_w = 6, .box_h = 2, .ofs_x = 0, .ofs_y = 4}, + {.bitmap_index = 375, .adv_w = 64, .box_w = 3, .box_h = 3, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 380, .adv_w = 64, .box_w = 6, .box_h = 11, .ofs_x = -1, .ofs_y = 0}, + {.bitmap_index = 413, .adv_w = 128, .box_w = 8, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 457, .adv_w = 128, .box_w = 6, .box_h = 11, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 490, .adv_w = 128, .box_w = 7, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 529, .adv_w = 128, .box_w = 7, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 568, .adv_w = 128, .box_w = 8, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 612, .adv_w = 128, .box_w = 7, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 651, .adv_w = 128, .box_w = 8, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 695, .adv_w = 128, .box_w = 7, .box_h = 12, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 737, .adv_w = 128, .box_w = 8, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 781, .adv_w = 128, .box_w = 8, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 825, .adv_w = 64, .box_w = 3, .box_h = 8, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 837, .adv_w = 64, .box_w = 3, .box_h = 10, .ofs_x = 1, .ofs_y = -2}, + {.bitmap_index = 852, .adv_w = 128, .box_w = 8, .box_h = 9, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 888, .adv_w = 128, .box_w = 8, .box_h = 5, .ofs_x = 0, .ofs_y = 1}, + {.bitmap_index = 908, .adv_w = 128, .box_w = 8, .box_h = 9, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 944, .adv_w = 112, .box_w = 7, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 983, .adv_w = 160, .box_w = 10, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1038, .adv_w = 160, .box_w = 11, .box_h = 11, .ofs_x = -1, .ofs_y = 0}, + {.bitmap_index = 1099, .adv_w = 160, .box_w = 9, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1149, .adv_w = 160, .box_w = 9, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1199, .adv_w = 160, .box_w = 10, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1254, .adv_w = 160, .box_w = 9, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1304, .adv_w = 144, .box_w = 9, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1354, .adv_w = 160, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1415, .adv_w = 176, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1476, .adv_w = 80, .box_w = 5, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1504, .adv_w = 112, .box_w = 8, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1548, .adv_w = 160, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1609, .adv_w = 144, .box_w = 9, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1659, .adv_w = 208, .box_w = 13, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1731, .adv_w = 176, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1792, .adv_w = 160, .box_w = 10, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1847, .adv_w = 144, .box_w = 9, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1897, .adv_w = 160, .box_w = 10, .box_h = 14, .ofs_x = 0, .ofs_y = -3}, + {.bitmap_index = 1967, .adv_w = 160, .box_w = 10, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 2022, .adv_w = 128, .box_w = 8, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 2066, .adv_w = 144, .box_w = 9, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 2116, .adv_w = 176, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 2177, .adv_w = 160, .box_w = 11, .box_h = 11, .ofs_x = -1, .ofs_y = 0}, + {.bitmap_index = 2238, .adv_w = 208, .box_w = 14, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 2315, .adv_w = 144, .box_w = 11, .box_h = 11, .ofs_x = -1, .ofs_y = 0}, + {.bitmap_index = 2376, .adv_w = 144, .box_w = 11, .box_h = 11, .ofs_x = -1, .ofs_y = 0}, + {.bitmap_index = 2437, .adv_w = 128, .box_w = 8, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 2481, .adv_w = 64, .box_w = 4, .box_h = 12, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 2505, .adv_w = 128, .box_w = 7, .box_h = 11, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 2544, .adv_w = 64, .box_w = 4, .box_h = 12, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 2568, .adv_w = 128, .box_w = 8, .box_h = 6, .ofs_x = 0, .ofs_y = 5}, + {.bitmap_index = 2592, .adv_w = 112, .box_w = 7, .box_h = 1, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 2596, .adv_w = 64, .box_w = 4, .box_h = 3, .ofs_x = 0, .ofs_y = 8}, + {.bitmap_index = 2602, .adv_w = 112, .box_w = 8, .box_h = 7, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 2630, .adv_w = 112, .box_w = 7, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 2669, .adv_w = 96, .box_w = 6, .box_h = 7, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 2690, .adv_w = 128, .box_w = 8, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 2734, .adv_w = 112, .box_w = 7, .box_h = 7, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 2759, .adv_w = 64, .box_w = 6, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 2792, .adv_w = 112, .box_w = 8, .box_h = 10, .ofs_x = 0, .ofs_y = -3}, + {.bitmap_index = 2832, .adv_w = 128, .box_w = 8, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 2876, .adv_w = 64, .box_w = 4, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 2898, .adv_w = 64, .box_w = 5, .box_h = 14, .ofs_x = -2, .ofs_y = -3}, + {.bitmap_index = 2933, .adv_w = 128, .box_w = 8, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 2977, .adv_w = 64, .box_w = 4, .box_h = 11, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 2999, .adv_w = 192, .box_w = 12, .box_h = 7, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 3041, .adv_w = 128, .box_w = 8, .box_h = 7, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 3069, .adv_w = 112, .box_w = 7, .box_h = 7, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 3094, .adv_w = 128, .box_w = 8, .box_h = 10, .ofs_x = 0, .ofs_y = -3}, + {.bitmap_index = 3134, .adv_w = 112, .box_w = 8, .box_h = 10, .ofs_x = 0, .ofs_y = -3}, + {.bitmap_index = 3174, .adv_w = 96, .box_w = 6, .box_h = 7, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 3195, .adv_w = 96, .box_w = 6, .box_h = 7, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 3216, .adv_w = 80, .box_w = 5, .box_h = 10, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 3241, .adv_w = 128, .box_w = 8, .box_h = 7, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 3269, .adv_w = 112, .box_w = 8, .box_h = 7, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 3297, .adv_w = 160, .box_w = 11, .box_h = 7, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 3336, .adv_w = 112, .box_w = 8, .box_h = 7, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 3364, .adv_w = 112, .box_w = 8, .box_h = 10, .ofs_x = 0, .ofs_y = -3}, + {.bitmap_index = 3404, .adv_w = 96, .box_w = 6, .box_h = 7, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 3425, .adv_w = 64, .box_w = 4, .box_h = 12, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 3449, .adv_w = 128, .box_w = 2, .box_h = 11, .ofs_x = 3, .ofs_y = 0}, + {.bitmap_index = 3460, .adv_w = 64, .box_w = 4, .box_h = 12, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 3484, .adv_w = 128, .box_w = 8, .box_h = 3, .ofs_x = 0, .ofs_y = 2}, + {.bitmap_index = 3496, .adv_w = 128, .box_w = 8, .box_h = 10, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 3536, .adv_w = 112, .box_w = 7, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 3568, .adv_w = 96, .box_w = 6, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 3595, .adv_w = 112, .box_w = 7, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 3627, .adv_w = 128, .box_w = 8, .box_h = 10, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 3667, .adv_w = 80, .box_w = 4, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 3685, .adv_w = 80, .box_w = 5, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 3708, .adv_w = 128, .box_w = 8, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 3744, .adv_w = 128, .box_w = 8, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 3780, .adv_w = 64, .box_w = 4, .box_h = 6, .ofs_x = 0, .ofs_y = 3}, + {.bitmap_index = 3792, .adv_w = 112, .box_w = 7, .box_h = 13, .ofs_x = 0, .ofs_y = -4}, + {.bitmap_index = 3838, .adv_w = 112, .box_w = 7, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 3870, .adv_w = 112, .box_w = 7, .box_h = 13, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 3916, .adv_w = 112, .box_w = 7, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 3948, .adv_w = 128, .box_w = 8, .box_h = 10, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 3988, .adv_w = 64, .box_w = 4, .box_h = 13, .ofs_x = 0, .ofs_y = -4}, + {.bitmap_index = 4014, .adv_w = 80, .box_w = 5, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 4037, .adv_w = 112, .box_w = 7, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 4069, .adv_w = 128, .box_w = 8, .box_h = 11, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 4113, .adv_w = 112, .box_w = 7, .box_h = 13, .ofs_x = 0, .ofs_y = -4}, + {.bitmap_index = 4159, .adv_w = 112, .box_w = 7, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 4191, .adv_w = 112, .box_w = 7, .box_h = 13, .ofs_x = 0, .ofs_y = -4}, + {.bitmap_index = 4237, .adv_w = 112, .box_w = 7, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 4269, .adv_w = 128, .box_w = 8, .box_h = 13, .ofs_x = 0, .ofs_y = -4}, + {.bitmap_index = 4321, .adv_w = 112, .box_w = 7, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 4353, .adv_w = 160, .box_w = 10, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 4398, .adv_w = 128, .box_w = 8, .box_h = 9, .ofs_x = 0, .ofs_y = 0} +}; + +/*--------------------- + * CHARACTER MAPPING + *--------------------*/ + + + +/*Collect the unicode lists and glyph_id offsets*/ +static const lv_font_fmt_txt_cmap_t cmaps[] = +{ + { + .range_start = 32, .range_length = 95, .glyph_id_start = 1, + .unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY + }, + { + .range_start = 1488, .range_length = 27, .glyph_id_start = 96, + .unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY + } +}; + +/*----------------- + * KERNING + *----------------*/ + + +/*Pair left and right glyphs for kerning*/ +static const uint8_t kern_pair_glyph_ids[] = +{ + 13, 18, + 14, 34, + 14, 53, + 14, 55, + 14, 56, + 14, 58, + 15, 18, + 17, 18, + 17, 21, + 17, 24, + 18, 13, + 18, 15, + 18, 17, + 18, 18, + 18, 19, + 18, 20, + 18, 21, + 18, 22, + 18, 23, + 18, 24, + 18, 25, + 18, 26, + 19, 18, + 19, 21, + 19, 24, + 20, 18, + 20, 21, + 20, 24, + 21, 18, + 21, 21, + 21, 24, + 22, 18, + 22, 21, + 22, 24, + 23, 18, + 23, 21, + 23, 24, + 24, 13, + 24, 15, + 24, 18, + 24, 19, + 24, 20, + 24, 21, + 24, 22, + 24, 23, + 24, 24, + 24, 25, + 24, 27, + 24, 28, + 25, 18, + 25, 21, + 25, 24, + 26, 18, + 26, 24 +}; + +/* Kerning between the respective left and right glyphs + * 4.4 format which needs to scaled with `kern_scale`*/ +static const int8_t kern_pair_values[] = +{ + -7, -1, -16, -12, -9, -19, -9, -11, + 1, -2, -5, -5, -11, -7, 0, -6, + -12, -6, -11, -18, -7, -5, -8, 1, + -3, -10, 0, -6, -7, 3, -10, -13, + 1, -8, -8, 2, -4, -15, -15, -8, + -7, -7, -16, -8, -8, -4, -8, -16, + -16, -9, 2, -5, -10, -2 +}; + +/*Collect the kern pair's data in one place*/ +static const lv_font_fmt_txt_kern_pair_t kern_pairs = +{ + .glyph_ids = kern_pair_glyph_ids, + .values = kern_pair_values, + .pair_cnt = 54, + .glyph_ids_size = 0 +}; + +/*-------------------- + * ALL CUSTOM DATA + *--------------------*/ + +/*Store all the custom data of the font*/ +static lv_font_fmt_txt_dsc_t font_dsc = { + .glyph_bitmap = gylph_bitmap, + .glyph_dsc = glyph_dsc, + .cmaps = cmaps, + .kern_dsc = &kern_pairs, + .kern_scale = 16, + .cmap_num = 2, + .bpp = 4, + .kern_classes = 0, + .bitmap_format = 0 +}; + + +/*----------------- + * PUBLIC FONT + *----------------*/ + +/*Initialize a public general font descriptor*/ +lv_font_t lv_font_heb_16 = { + .get_glyph_dsc = lv_font_get_glyph_dsc_fmt_txt, /*Function pointer to get glyph's data*/ + .get_glyph_bitmap = lv_font_get_bitmap_fmt_txt, /*Function pointer to get glyph's bitmap*/ + .line_height = 17, /*The maximum line height required by the font*/ + .base_line = 4, /*Baseline measured from the bottom of the line*/ + .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ +}; + +#endif /*#if LV_FONT_HEB_16*/ + From c6b7cf130bebd205b0d355622bb8755d541e3d85 Mon Sep 17 00:00:00 2001 From: Amir Gonnen Date: Fri, 18 Oct 2019 02:13:41 +0300 Subject: [PATCH 17/64] Support text wrap for bidi text TODO: conditional LV_USE_BIDI, allocate global buffer once, pass dir as parameter to lv_draw_label --- src/lv_draw/lv_draw_label.c | 17 +++++++++++------ src/lv_misc/lv_bidi.c | 20 +++++++++----------- src/lv_misc/lv_bidi.h | 2 ++ src/lv_objx/lv_btnm.c | 19 ------------------- src/lv_objx/lv_label.c | 18 +----------------- src/lv_objx/lv_table.c | 5 ----- 6 files changed, 23 insertions(+), 58 deletions(-) diff --git a/src/lv_draw/lv_draw_label.c b/src/lv_draw/lv_draw_label.c index 23c660396..c2dc52ebe 100644 --- a/src/lv_draw/lv_draw_label.c +++ b/src/lv_draw/lv_draw_label.c @@ -8,6 +8,7 @@ *********************/ #include "lv_draw_label.h" #include "../lv_misc/lv_math.h" +#include "../lv_misc/lv_bidi.h" /********************* * DEFINES @@ -162,12 +163,16 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st } /*Write all letter of a line*/ cmd_state = CMD_STATE_WAIT; - i = line_start; + i = 0; uint32_t letter; uint32_t letter_next; - while(i < line_end) { - letter = lv_txt_encoded_next(txt, &i); - letter_next = lv_txt_encoded_next(&txt[i], NULL); + while(i < line_end - line_start) { + // TODO handle bidi conditionally on ifdef + static char bidi_txt[1000]; // TODO: allocate dynamically once (gloablly?), according to max label size + lv_bidi_process_paragraph(txt + line_start, bidi_txt, line_end - line_start, LV_BIDI_DIR_RTL /* lv_obj_get_base_dir(label) */ ); // TODO: pass base dir as paramter + + letter = lv_txt_encoded_next(bidi_txt, &i); + letter_next = lv_txt_encoded_next(&bidi_txt[i], NULL); /*Handle the re-color command*/ if((flag & LV_TXT_FLAG_RECOLOR) != 0) { @@ -190,7 +195,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st /*Get the parameter*/ if(i - par_start == LABEL_RECOLOR_PAR_LENGTH + 1) { char buf[LABEL_RECOLOR_PAR_LENGTH + 1]; - memcpy(buf, &txt[par_start], LABEL_RECOLOR_PAR_LENGTH); + memcpy(buf, &bidi_txt[par_start], LABEL_RECOLOR_PAR_LENGTH); buf[LABEL_RECOLOR_PAR_LENGTH] = '\0'; int r, g, b; r = (hex_char_to_num(buf[0]) << 4) + hex_char_to_num(buf[1]); @@ -213,7 +218,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st letter_w = lv_font_get_glyph_width(font, letter, letter_next); if(sel_start != 0xFFFF && sel_end != 0xFFFF) { - int char_ind = lv_encoded_get_char_id(txt, i); + int char_ind = lv_encoded_get_char_id(bidi_txt, i); /*Do not draw the rectangle on the character at `sel_start`.*/ if(char_ind > sel_start && char_ind <= sel_end) { lv_area_t sel_coords; diff --git a/src/lv_misc/lv_bidi.c b/src/lv_misc/lv_bidi.c index e9929bc67..7f829354b 100644 --- a/src/lv_misc/lv_bidi.c +++ b/src/lv_misc/lv_bidi.c @@ -23,9 +23,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void process_paragraph(const char * str_in, char * str_out, uint32_t len, lv_bidi_dir_t base_dir); -static uint32_t get_next_paragraph(const char * txt); -static lv_bidi_dir_t get_next_run(const char * txt, lv_bidi_dir_t base_dir, uint32_t * len); +static lv_bidi_dir_t get_next_run(const char * txt, lv_bidi_dir_t base_dir, uint32_t max_len, uint32_t * len); static void rtl_reverse(char * dest, const char * src, uint32_t len); static uint32_t char_change_to_pair(uint32_t letter); @@ -55,8 +53,8 @@ void lv_bidi_process(const char * str_in, char * str_out, lv_bidi_dir_t base_dir } while(str_in[par_start] != '\0') { - par_len = get_next_paragraph(&str_in[par_start]); - process_paragraph(&str_in[par_start], &str_out[par_start], par_len, base_dir); + par_len = lv_bidi_get_next_paragraph(&str_in[par_start]); + lv_bidi_process_paragraph(&str_in[par_start], &str_out[par_start], par_len, base_dir); par_start += par_len; while(str_in[par_start] == '\n' || str_in[par_start] == '\r') { @@ -134,7 +132,7 @@ bool lv_bidi_letter_is_neutral(uint32_t letter) * STATIC FUNCTIONS **********************/ -static void process_paragraph(const char * str_in, char * str_out, uint32_t len, lv_bidi_dir_t base_dir) +void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len, lv_bidi_dir_t base_dir) { uint32_t run_len = 0; lv_bidi_dir_t run_dir; @@ -168,7 +166,7 @@ static void process_paragraph(const char * str_in, char * str_out, uint32_t len, /*Get and process the runs*/ while(rd < len) { - run_dir = get_next_run(&str_in[rd], base_dir, &run_len); + run_dir = get_next_run(&str_in[rd], base_dir, len - rd, &run_len); if(base_dir == LV_BIDI_DIR_LTR) { if(run_dir == LV_BIDI_DIR_LTR) memcpy(&str_out[wr], &str_in[rd], run_len); @@ -184,7 +182,7 @@ static void process_paragraph(const char * str_in, char * str_out, uint32_t len, } } -static uint32_t get_next_paragraph(const char * txt) +uint32_t lv_bidi_get_next_paragraph(const char * txt) { uint32_t i = 0; @@ -197,7 +195,7 @@ static uint32_t get_next_paragraph(const char * txt) return i; } -static lv_bidi_dir_t get_next_run(const char * txt, lv_bidi_dir_t base_dir, uint32_t * len) +static lv_bidi_dir_t get_next_run(const char * txt, lv_bidi_dir_t base_dir, uint32_t max_len, uint32_t * len) { uint32_t i = 0; uint32_t letter; @@ -209,7 +207,7 @@ static lv_bidi_dir_t get_next_run(const char * txt, lv_bidi_dir_t base_dir, uint while(dir == LV_BIDI_DIR_NEUTRAL || dir == LV_BIDI_DIR_WEAK) { letter = lv_txt_encoded_next(txt, &i); dir = lv_bidi_get_letter_dir(letter); - if(txt[i] == '\0' || txt[i] == '\n' || txt[i] == '\r') { + if(i >= max_len || txt[i] == '\0' || txt[i] == '\n' || txt[i] == '\r') { *len = i; return base_dir; } @@ -222,7 +220,7 @@ static lv_bidi_dir_t get_next_run(const char * txt, lv_bidi_dir_t base_dir, uint /*Find the next char which has different direction*/ lv_bidi_dir_t next_dir = base_dir; - while(txt[i] != '\0'&& txt[i] != '\n' && txt[i] != '\r') { + while(i_prev < max_len && txt[i] != '\0' && txt[i] != '\n' && txt[i] != '\r') { letter = lv_txt_encoded_next(txt, &i); next_dir = lv_bidi_get_letter_dir(letter); diff --git a/src/lv_misc/lv_bidi.h b/src/lv_misc/lv_bidi.h index 233765ca2..9ce0fffa1 100644 --- a/src/lv_misc/lv_bidi.h +++ b/src/lv_misc/lv_bidi.h @@ -53,6 +53,8 @@ typedef uint8_t lv_bidi_dir_t; #if LV_USE_BIDI void lv_bidi_process(const char * str_in, char * str_out, lv_bidi_dir_t base_dir); +void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len, lv_bidi_dir_t base_dir); +uint32_t lv_bidi_get_next_paragraph(const char * txt); lv_bidi_dir_t lv_bidi_detect_base_dir(const char * txt); lv_bidi_dir_t lv_bidi_get_letter_dir(uint32_t letter); bool lv_bidi_letter_is_weak(uint32_t letter); diff --git a/src/lv_objx/lv_btnm.c b/src/lv_objx/lv_btnm.c index c9f095ac4..729b745a2 100644 --- a/src/lv_objx/lv_btnm.c +++ b/src/lv_objx/lv_btnm.c @@ -671,11 +671,6 @@ static bool lv_btnm_design(lv_obj_t * btnm, const lv_area_t * mask, lv_design_mo lv_txt_flag_t txt_flag = LV_TXT_FLAG_NONE; if(ext->recolor) txt_flag = LV_TXT_FLAG_RECOLOR; -#if LV_USE_BIDI - char * bidi_buf = lv_mem_alloc(64); - lv_bidi_dir_t base_dir = lv_obj_get_base_dir(btnm); -#endif - for(btn_i = 0; btn_i < ext->btn_cnt; btn_i++, txt_i++) { /*Search the next valid text in the map*/ while(strcmp(ext->map_p[txt_i], "\n") == 0) { @@ -744,22 +739,8 @@ static bool lv_btnm_design(lv_obj_t * btnm, const lv_area_t * mask, lv_design_mo area_tmp.x2 = area_tmp.x1 + txt_size.x; area_tmp.y2 = area_tmp.y1 + txt_size.y; -#if LV_USE_BIDI == 0 lv_draw_label(&area_tmp, mask, btn_style, opa_scale, ext->map_p[txt_i], txt_flag, NULL, -1, -1, NULL); -#else - uint32_t txt_len = strlen(ext->map_p[txt_i]) + 1; - if(txt_len > lv_mem_get_size(bidi_buf)) { - bidi_buf = lv_mem_realloc(bidi_buf, txt_len); - } - - lv_bidi_process(ext->map_p[txt_i], bidi_buf, base_dir); - lv_draw_label(&area_tmp, mask, btn_style, opa_scale, bidi_buf, txt_flag, NULL, -1, -1, NULL); -#endif } - -#if LV_USE_BIDI - lv_mem_free(bidi_buf); -#endif } return true; diff --git a/src/lv_objx/lv_label.c b/src/lv_objx/lv_label.c index 4ce18f42f..4bb547ffe 100644 --- a/src/lv_objx/lv_label.c +++ b/src/lv_objx/lv_label.c @@ -205,12 +205,8 @@ void lv_label_set_text(lv_obj_t * label, const char * text) LV_ASSERT_MEM(ext->text); if(ext->text == NULL) return; -#if LV_USE_BIDI == 0 strcpy(ext->text, text); -#else - lv_bidi_dir_t base_dir = lv_obj_get_base_dir(label); - lv_bidi_process(text, ext->text, base_dir); -#endif + /*Now the text is dynamically allocated*/ ext->static_txt = 0; } @@ -904,19 +900,7 @@ void lv_label_ins_text(lv_obj_t * label, uint32_t pos, const char * txt) pos = lv_txt_get_encoded_length(ext->text); } -#if LV_USE_BIDI - char * bidi_buf = lv_mem_alloc(ins_len) + 1; - LV_ASSERT_MEM(bidi_buf); - if(bidi_buf == NULL) return; - - lv_bidi_process(txt, bidi_buf, lv_obj_get_base_dir(label)); - lv_txt_ins(ext->text, pos, bidi_buf); - - lv_mem_free(bidi_buf); -#else lv_txt_ins(ext->text, pos, txt); -#endif - lv_label_refr_text(label); } diff --git a/src/lv_objx/lv_table.c b/src/lv_objx/lv_table.c index e1ca6a2d0..3a7ec3f56 100644 --- a/src/lv_objx/lv_table.c +++ b/src/lv_objx/lv_table.c @@ -163,12 +163,7 @@ void lv_table_set_cell_value(lv_obj_t * table, uint16_t row, uint16_t col, const } ext->cell_data[cell] = lv_mem_realloc(ext->cell_data[cell], strlen(txt) + 2); /*+1: trailing '\0; +1: format byte*/ - -#if LV_USE_BIDI == 0 strcpy(ext->cell_data[cell] + 1, txt); /*+1 to skip the format byte*/ -#else - lv_bidi_process(txt, ext->cell_data[cell] + 1, base_dir); -#endif ext->cell_data[cell][0] = format.format_byte; refr_size(table); From f7c2512c76ca3edebc5241465638e59c273e6f67 Mon Sep 17 00:00:00 2001 From: Amir Gonnen Date: Sun, 20 Oct 2019 02:16:57 +0300 Subject: [PATCH 18/64] Bidi fixes Add bidi_dir parameter to lv_draw_label Use draw buffer for bidi processing condition bidi code according to LV_USE_BIDI --- src/lv_draw/lv_draw_img.c | 6 +++--- src/lv_draw/lv_draw_label.c | 12 +++++++----- src/lv_draw/lv_draw_label.h | 3 ++- src/lv_misc/lv_bidi.c | 2 +- src/lv_objx/lv_btnm.c | 2 +- src/lv_objx/lv_calendar.c | 10 +++++----- src/lv_objx/lv_canvas.c | 2 +- src/lv_objx/lv_chart.c | 4 ++-- src/lv_objx/lv_ddlist.c | 4 ++-- src/lv_objx/lv_gauge.c | 2 +- src/lv_objx/lv_img.c | 2 +- src/lv_objx/lv_imgbtn.c | 2 +- src/lv_objx/lv_label.c | 6 +++--- src/lv_objx/lv_roller.c | 2 +- src/lv_objx/lv_ta.c | 2 +- src/lv_objx/lv_table.c | 9 ++++++--- 16 files changed, 38 insertions(+), 32 deletions(-) diff --git a/src/lv_draw/lv_draw_img.c b/src/lv_draw/lv_draw_img.c index eacaa2d23..dcaa444a8 100644 --- a/src/lv_draw/lv_draw_img.c +++ b/src/lv_draw/lv_draw_img.c @@ -51,7 +51,7 @@ void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * if(src == NULL) { LV_LOG_WARN("Image draw: src is NULL"); lv_draw_rect(coords, mask, &lv_style_plain, LV_OPA_COVER); - lv_draw_label(coords, mask, &lv_style_plain, LV_OPA_COVER, "No\ndata", LV_TXT_FLAG_NONE, NULL, -1, -1, NULL); + lv_draw_label(coords, mask, &lv_style_plain, LV_OPA_COVER, "No\ndata", LV_TXT_FLAG_NONE, NULL, -1, -1, NULL, LV_BIDI_DIR_LTR); return; } @@ -61,7 +61,7 @@ void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * if(res == LV_RES_INV) { LV_LOG_WARN("Image draw error"); lv_draw_rect(coords, mask, &lv_style_plain, LV_OPA_COVER); - lv_draw_label(coords, mask, &lv_style_plain, LV_OPA_COVER, "No\ndata", LV_TXT_FLAG_NONE, NULL, -1, -1, NULL); + lv_draw_label(coords, mask, &lv_style_plain, LV_OPA_COVER, "No\ndata", LV_TXT_FLAG_NONE, NULL, -1, -1, NULL, LV_BIDI_DIR_LTR); return; } } @@ -563,7 +563,7 @@ static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mas LV_LOG_WARN("Image draw error"); lv_draw_rect(coords, mask, &lv_style_plain, LV_OPA_COVER); lv_draw_label(coords, mask, &lv_style_plain, LV_OPA_COVER, cdsc->dec_dsc.error_msg, LV_TXT_FLAG_NONE, NULL, -1, - -1, NULL); + -1, NULL, LV_BIDI_DIR_LTR); } /* The decoder open could open the image and gave the entire uncompressed image. * Just draw it!*/ diff --git a/src/lv_draw/lv_draw_label.c b/src/lv_draw/lv_draw_label.c index c2dc52ebe..86b486002 100644 --- a/src/lv_draw/lv_draw_label.c +++ b/src/lv_draw/lv_draw_label.c @@ -57,7 +57,7 @@ static uint8_t hex_char_to_num(char hex); */ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale, const char * txt, lv_txt_flag_t flag, lv_point_t * offset, uint16_t sel_start, uint16_t sel_end, - lv_draw_label_hint_t * hint) + lv_draw_label_hint_t * hint, lv_bidi_dir_t bidi_dir) { const lv_font_t * font = style->text.font; lv_coord_t w; @@ -167,10 +167,12 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st uint32_t letter; uint32_t letter_next; while(i < line_end - line_start) { - // TODO handle bidi conditionally on ifdef - static char bidi_txt[1000]; // TODO: allocate dynamically once (gloablly?), according to max label size - lv_bidi_process_paragraph(txt + line_start, bidi_txt, line_end - line_start, LV_BIDI_DIR_RTL /* lv_obj_get_base_dir(label) */ ); // TODO: pass base dir as paramter - +#if LV_USE_BIDI + char *bidi_txt = lv_draw_get_buf(line_end - line_start + 1); + lv_bidi_process_paragraph(txt + line_start, bidi_txt, line_end - line_start, bidi_dir); +#else + const char *bidi_txt = txt + line_start; +#endif letter = lv_txt_encoded_next(bidi_txt, &i); letter_next = lv_txt_encoded_next(&bidi_txt[i], NULL); diff --git a/src/lv_draw/lv_draw_label.h b/src/lv_draw/lv_draw_label.h index 2328aa2b3..39ec60607 100644 --- a/src/lv_draw/lv_draw_label.h +++ b/src/lv_draw/lv_draw_label.h @@ -14,6 +14,7 @@ extern "C" { * INCLUDES *********************/ #include "lv_draw.h" +#include "../lv_misc/lv_bidi.h" /********************* * DEFINES @@ -58,7 +59,7 @@ typedef struct { */ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale, const char * txt, lv_txt_flag_t flag, lv_point_t * offset, uint16_t sel_start, uint16_t sel_end, - lv_draw_label_hint_t * hint); + lv_draw_label_hint_t * hint, lv_bidi_dir_t bidi_dir); /********************** * MACROS diff --git a/src/lv_misc/lv_bidi.c b/src/lv_misc/lv_bidi.c index 7f829354b..ceae844a0 100644 --- a/src/lv_misc/lv_bidi.c +++ b/src/lv_misc/lv_bidi.c @@ -269,7 +269,7 @@ static void rtl_reverse(char * dest, const char * src, uint32_t len) /*Finish on non-weak char */ /*but treat number and currency related chars as weak*/ - if(lv_bidi_letter_is_weak(letter) == false && letter != '.' && letter != ',' && letter != '$') { + if(lv_bidi_letter_is_weak(letter) == false && letter != '.' && letter != ',' && letter != '$' && letter != '%') { lv_txt_encoded_next(src, &i); /*Rewind one letter*/ first_weak = i; break; diff --git a/src/lv_objx/lv_btnm.c b/src/lv_objx/lv_btnm.c index 729b745a2..9c2634c93 100644 --- a/src/lv_objx/lv_btnm.c +++ b/src/lv_objx/lv_btnm.c @@ -739,7 +739,7 @@ static bool lv_btnm_design(lv_obj_t * btnm, const lv_area_t * mask, lv_design_mo area_tmp.x2 = area_tmp.x1 + txt_size.x; area_tmp.y2 = area_tmp.y1 + txt_size.y; - lv_draw_label(&area_tmp, mask, btn_style, opa_scale, ext->map_p[txt_i], txt_flag, NULL, -1, -1, NULL); + lv_draw_label(&area_tmp, mask, btn_style, opa_scale, ext->map_p[txt_i], txt_flag, NULL, -1, -1, NULL, lv_obj_get_base_dir(btnm)); } } diff --git a/src/lv_objx/lv_calendar.c b/src/lv_objx/lv_calendar.c index e33eccf10..cbeca7c54 100644 --- a/src/lv_objx/lv_calendar.c +++ b/src/lv_objx/lv_calendar.c @@ -687,19 +687,19 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask) txt_buf[5] = '\0'; strcpy(&txt_buf[5], get_month_name(calendar, ext->showed_date.month)); header_area.y1 += ext->style_header->body.padding.top; - lv_draw_label(&header_area, mask, ext->style_header, opa_scale, txt_buf, LV_TXT_FLAG_CENTER, NULL, -1, -1, NULL); + lv_draw_label(&header_area, mask, ext->style_header, opa_scale, txt_buf, LV_TXT_FLAG_CENTER, NULL, -1, -1, NULL, lv_obj_get_base_dir(calendar)); /*Add the left arrow*/ const lv_style_t * arrow_style = ext->btn_pressing < 0 ? ext->style_header_pr : ext->style_header; header_area.x1 += ext->style_header->body.padding.left; - lv_draw_label(&header_area, mask, arrow_style, opa_scale, LV_SYMBOL_LEFT, LV_TXT_FLAG_NONE, NULL, -1, -1, NULL); + lv_draw_label(&header_area, mask, arrow_style, opa_scale, LV_SYMBOL_LEFT, LV_TXT_FLAG_NONE, NULL, -1, -1, NULL, lv_obj_get_base_dir(calendar)); /*Add the right arrow*/ arrow_style = ext->btn_pressing > 0 ? ext->style_header_pr : ext->style_header; header_area.x1 = header_area.x2 - ext->style_header->body.padding.right - lv_txt_get_width(LV_SYMBOL_RIGHT, strlen(LV_SYMBOL_RIGHT), arrow_style->text.font, arrow_style->text.line_space, LV_TXT_FLAG_NONE); - lv_draw_label(&header_area, mask, arrow_style, opa_scale, LV_SYMBOL_RIGHT, LV_TXT_FLAG_NONE, NULL, -1, -1, NULL); + lv_draw_label(&header_area, mask, arrow_style, opa_scale, LV_SYMBOL_RIGHT, LV_TXT_FLAG_NONE, NULL, -1, -1, NULL, lv_obj_get_base_dir(calendar)); } /** @@ -724,7 +724,7 @@ static void draw_day_names(lv_obj_t * calendar, const lv_area_t * mask) label_area.x1 = calendar->coords.x1 + (w * i) / 7 + l_pad; label_area.x2 = label_area.x1 + box_w - 1; lv_draw_label(&label_area, mask, ext->style_day_names, opa_scale, get_day_name(calendar, i), LV_TXT_FLAG_CENTER, - NULL, -1, -1, NULL); + NULL, -1, -1, NULL, lv_obj_get_base_dir(calendar)); } } @@ -853,7 +853,7 @@ static void draw_days(lv_obj_t * calendar, const lv_area_t * mask) /*Write the day's number*/ lv_utils_num_to_str(day_cnt, buf); - lv_draw_label(&label_area, mask, final_style, opa_scale, buf, LV_TXT_FLAG_CENTER, NULL, -1, -1, NULL); + lv_draw_label(&label_area, mask, final_style, opa_scale, buf, LV_TXT_FLAG_CENTER, NULL, -1, -1, NULL, lv_obj_get_base_dir(calendar)); /*Go to the next day*/ day_cnt++; diff --git a/src/lv_objx/lv_canvas.c b/src/lv_objx/lv_canvas.c index a39c11a31..8ba051b46 100644 --- a/src/lv_objx/lv_canvas.c +++ b/src/lv_objx/lv_canvas.c @@ -586,7 +586,7 @@ void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord } lv_draw_label(&coords, &mask, style, LV_OPA_COVER, txt, flag, NULL, LV_LABEL_TEXT_SEL_OFF, LV_LABEL_TEXT_SEL_OFF, - NULL); + NULL, lv_obj_get_base_dir(canvas)); lv_refr_set_disp_refreshing(refr_ori); } diff --git a/src/lv_objx/lv_chart.c b/src/lv_objx/lv_chart.c index c326c8c6b..e82d00f7f 100644 --- a/src/lv_objx/lv_chart.c +++ b/src/lv_objx/lv_chart.c @@ -1379,7 +1379,7 @@ static void lv_chart_draw_y_ticks(lv_obj_t * chart, const lv_area_t * mask, uint a.x2 = p2.x + size.x + LV_CHART_AXIS_TO_LABEL_DISTANCE; } - lv_draw_label(&a, mask, style, opa_scale, buf, LV_TXT_FLAG_CENTER, NULL, -1, -1, NULL); + lv_draw_label(&a, mask, style, opa_scale, buf, LV_TXT_FLAG_CENTER, NULL, -1, -1, NULL, lv_obj_get_base_dir(chart)); } } @@ -1465,7 +1465,7 @@ static void lv_chart_draw_x_ticks(lv_obj_t * chart, const lv_area_t * mask) /* set the area at some distance of the major tick len under of the tick */ lv_area_t a = {(p2.x - size.x / 2), (p2.y + LV_CHART_AXIS_TO_LABEL_DISTANCE), (p2.x + size.x / 2), (p2.y + size.y + LV_CHART_AXIS_TO_LABEL_DISTANCE)}; - lv_draw_label(&a, mask, style, opa_scale, buf, LV_TXT_FLAG_CENTER, NULL, -1, -1, NULL); + lv_draw_label(&a, mask, style, opa_scale, buf, LV_TXT_FLAG_CENTER, NULL, -1, -1, NULL, lv_obj_get_base_dir(chart)); } } } diff --git a/src/lv_objx/lv_ddlist.c b/src/lv_objx/lv_ddlist.c index a6066729d..771902e26 100644 --- a/src/lv_objx/lv_ddlist.c +++ b/src/lv_objx/lv_ddlist.c @@ -609,7 +609,7 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig new_style.text.opa = sel_style->text.opa; lv_txt_flag_t flag = lv_ddlist_get_txt_flag(ddlist); lv_draw_label(&ext->label->coords, &mask_sel, &new_style, opa_scale, lv_label_get_text(ext->label), - flag, NULL, -1, -1, NULL); + flag, NULL, -1, -1, NULL, lv_obj_get_base_dir(ddlist)); } } @@ -643,7 +643,7 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig area_ok = lv_area_intersect(&mask_arrow, mask, &area_arrow); if(area_ok) { lv_draw_label(&area_arrow, &mask_arrow, &new_style, opa_scale, LV_SYMBOL_DOWN, LV_TXT_FLAG_NONE, - NULL, -1, -1, NULL); /*Use a down arrow in ddlist, you can replace it with your + NULL, -1, -1, NULL, lv_obj_get_base_dir(ddlist)); /*Use a down arrow in ddlist, you can replace it with your custom symbol*/ } } diff --git a/src/lv_objx/lv_gauge.c b/src/lv_objx/lv_gauge.c index 3ebb1cb7c..4a9b06e5b 100644 --- a/src/lv_objx/lv_gauge.c +++ b/src/lv_objx/lv_gauge.c @@ -390,7 +390,7 @@ static void lv_gauge_draw_scale(lv_obj_t * gauge, const lv_area_t * mask) label_cord.x2 = label_cord.x1 + label_size.x; label_cord.y2 = label_cord.y1 + label_size.y; - lv_draw_label(&label_cord, mask, style, opa_scale, scale_txt, LV_TXT_FLAG_NONE, NULL, -1, -1, NULL); + lv_draw_label(&label_cord, mask, style, opa_scale, scale_txt, LV_TXT_FLAG_NONE, NULL, -1, -1, NULL, lv_obj_get_base_dir(gauge)); } } /** diff --git a/src/lv_objx/lv_img.c b/src/lv_objx/lv_img.c index 302891ac3..30e994a13 100644 --- a/src/lv_objx/lv_img.c +++ b/src/lv_objx/lv_img.c @@ -384,7 +384,7 @@ static bool lv_img_design(lv_obj_t * img, const lv_area_t * mask, lv_design_mode lv_style_t style_mod; lv_style_copy(&style_mod, style); style_mod.text.color = style->image.color; - lv_draw_label(&coords, mask, &style_mod, opa_scale, ext->src, LV_TXT_FLAG_NONE, NULL, -1, -1, NULL); + lv_draw_label(&coords, mask, &style_mod, opa_scale, ext->src, LV_TXT_FLAG_NONE, NULL, -1, -1, NULL, lv_obj_get_base_dir(img)); } else { /*Trigger the error handler of image drawer*/ LV_LOG_WARN("lv_img_design: image source type is unknown"); diff --git a/src/lv_objx/lv_imgbtn.c b/src/lv_objx/lv_imgbtn.c index e1c4c0309..a17fe8b50 100644 --- a/src/lv_objx/lv_imgbtn.c +++ b/src/lv_objx/lv_imgbtn.c @@ -304,7 +304,7 @@ static bool lv_imgbtn_design(lv_obj_t * imgbtn, const lv_area_t * mask, lv_desig #if LV_IMGBTN_TILED == 0 const void * src = ext->img_src[state]; if(lv_img_src_get_type(src) == LV_IMG_SRC_SYMBOL) { - lv_draw_label(&imgbtn->coords, mask, style, opa_scale, src, LV_TXT_FLAG_NONE, NULL, LV_LABEL_TEXT_SEL_OFF, LV_LABEL_TEXT_SEL_OFF, NULL); + lv_draw_label(&imgbtn->coords, mask, style, opa_scale, src, LV_TXT_FLAG_NONE, NULL, LV_LABEL_TEXT_SEL_OFF, LV_LABEL_TEXT_SEL_OFF, NULL, lv_obj_get_base_dir(imgbtn)); } else { lv_draw_img(&imgbtn->coords, mask, src, style, opa_scale); } diff --git a/src/lv_objx/lv_label.c b/src/lv_objx/lv_label.c index 4bb547ffe..46cc451c4 100644 --- a/src/lv_objx/lv_label.c +++ b/src/lv_objx/lv_label.c @@ -1005,7 +1005,7 @@ static bool lv_label_design(lv_obj_t * label, const lv_area_t * mask, lv_design_ lv_draw_label_hint_t * hint = NULL; #endif lv_draw_label(&coords, mask, style, opa_scale, ext->text, flag, &ext->offset, - lv_label_get_text_sel_start(label), lv_label_get_text_sel_end(label), hint); + lv_label_get_text_sel_start(label), lv_label_get_text_sel_end(label), hint, lv_obj_get_base_dir(label)); if(ext->long_mode == LV_LABEL_LONG_SROLL_CIRC) { @@ -1022,7 +1022,7 @@ static bool lv_label_design(lv_obj_t * label, const lv_area_t * mask, lv_design_ ofs.y = ext->offset.y; lv_draw_label(&coords, mask, style, opa_scale, ext->text, flag, &ofs, - lv_label_get_text_sel_start(label), lv_label_get_text_sel_end(label), NULL); + lv_label_get_text_sel_start(label), lv_label_get_text_sel_end(label), NULL, lv_obj_get_base_dir(label)); } /*Draw the text again below the original to make an circular effect */ @@ -1030,7 +1030,7 @@ static bool lv_label_design(lv_obj_t * label, const lv_area_t * mask, lv_design_ ofs.x = ext->offset.x; ofs.y = ext->offset.y + size.y + lv_font_get_line_height(style->text.font); lv_draw_label(&coords, mask, style, opa_scale, ext->text, flag, &ofs, - lv_label_get_text_sel_start(label), lv_label_get_text_sel_end(label), NULL); + lv_label_get_text_sel_start(label), lv_label_get_text_sel_end(label), NULL, lv_obj_get_base_dir(label)); } } } diff --git a/src/lv_objx/lv_roller.c b/src/lv_objx/lv_roller.c index 75eb9cf74..62c949db5 100644 --- a/src/lv_objx/lv_roller.c +++ b/src/lv_objx/lv_roller.c @@ -397,7 +397,7 @@ static bool lv_roller_design(lv_obj_t * roller, const lv_area_t * mask, lv_desig new_style.text.color = sel_style->text.color; new_style.text.opa = sel_style->text.opa; lv_draw_label(&ext->ddlist.label->coords, &mask_sel, &new_style, opa_scale, - lv_label_get_text(ext->ddlist.label), txt_align, NULL, -1, -1, NULL); + lv_label_get_text(ext->ddlist.label), txt_align, NULL, -1, -1, NULL, lv_obj_get_base_dir(ext->ddlist.label)); } } diff --git a/src/lv_objx/lv_ta.c b/src/lv_objx/lv_ta.c index 77ea629d4..c8ffee521 100644 --- a/src/lv_objx/lv_ta.c +++ b/src/lv_objx/lv_ta.c @@ -1386,7 +1386,7 @@ static bool lv_ta_scrollable_design(lv_obj_t * scrl, const lv_area_t * mask, lv_ cur_area.x1 += cur_style.body.padding.left; cur_area.y1 += cur_style.body.padding.top; lv_draw_label(&cur_area, mask, &cur_style, opa_scale, letter_buf, LV_TXT_FLAG_NONE, 0, - LV_LABEL_TEXT_SEL_OFF, LV_LABEL_TEXT_SEL_OFF, NULL); + LV_LABEL_TEXT_SEL_OFF, LV_LABEL_TEXT_SEL_OFF, NULL, lv_obj_get_base_dir(ta)); } else if(ext->cursor.type == LV_CURSOR_OUTLINE) { cur_style.body.opa = LV_OPA_TRANSP; diff --git a/src/lv_objx/lv_table.c b/src/lv_objx/lv_table.c index 3a7ec3f56..ef49559aa 100644 --- a/src/lv_objx/lv_table.c +++ b/src/lv_objx/lv_table.c @@ -145,17 +145,20 @@ void lv_table_set_cell_value(lv_obj_t * table, uint16_t row, uint16_t col, const uint32_t cell = row * ext->col_cnt + col; lv_table_cell_format_t format; - lv_bidi_dir_t base_dir = lv_obj_get_base_dir(table); - /*Save the format byte*/ if(ext->cell_data[cell]) { format.format_byte = ext->cell_data[cell][0]; } /*Initialize the format byte*/ else { +#if LV_USE_BIDI + lv_bidi_dir_t base_dir = lv_obj_get_base_dir(table); if(base_dir == LV_BIDI_DIR_LTR) format.s.align = LV_LABEL_ALIGN_LEFT; else if(base_dir == LV_BIDI_DIR_RTL) format.s.align = LV_LABEL_ALIGN_RIGHT; else if(base_dir == LV_BIDI_DIR_AUTO) format.s.align = lv_bidi_detect_base_dir(txt); +#else + format.s.align = LV_LABEL_ALIGN_LEFT; +#endif format.s.right_merge = 0; format.s.type = 0; @@ -735,7 +738,7 @@ static bool lv_table_design(lv_obj_t * table, const lv_area_t * mask, lv_design_ label_mask_ok = lv_area_intersect(&label_mask, mask, &cell_area); if(label_mask_ok) { lv_draw_label(&txt_area, &label_mask, cell_style, opa_scale, ext->cell_data[cell] + 1, - txt_flags, NULL, -1, -1, NULL); + txt_flags, NULL, -1, -1, NULL, lv_obj_get_base_dir(table)); } /*Draw lines after '\n's*/ lv_point_t p1; From 3264af9f0ea7cd7101f26590db61bc2e48379dc9 Mon Sep 17 00:00:00 2001 From: Paul Peavyhouse Date: Mon, 21 Oct 2019 15:27:57 -0700 Subject: [PATCH 19/64] Fixing failure to invalidate indicator --- src/lv_objx/lv_cpicker.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lv_objx/lv_cpicker.c b/src/lv_objx/lv_cpicker.c index 459d37213..d2bc62523 100644 --- a/src/lv_objx/lv_cpicker.c +++ b/src/lv_objx/lv_cpicker.c @@ -950,6 +950,8 @@ static void next_color_mode(lv_obj_t * cpicker) static void refr_indic_pos(lv_obj_t * cpicker) { + invalidate_indic(cpicker); + lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker); lv_coord_t w = lv_obj_get_width(cpicker); lv_coord_t h = lv_obj_get_height(cpicker); From 0634b11578fd9f0c4ca31fde6bde31c859d83b3c Mon Sep 17 00:00:00 2001 From: Amir Gonnen Date: Tue, 22 Oct 2019 01:36:37 +0300 Subject: [PATCH 20/64] Add minus (hyphen) as neutral letter --- src/lv_misc/lv_bidi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_misc/lv_bidi.c b/src/lv_misc/lv_bidi.c index ceae844a0..61c12e5b2 100644 --- a/src/lv_misc/lv_bidi.c +++ b/src/lv_misc/lv_bidi.c @@ -119,7 +119,7 @@ bool lv_bidi_letter_is_rtl(uint32_t letter) bool lv_bidi_letter_is_neutral(uint32_t letter) { uint16_t i; - static const char neutrals[] = " \t\n\r.,:;'\"`!?%/\\=()[]{}<>@#&$|"; + static const char neutrals[] = " \t\n\r.,:;'\"`!?%/\\-=()[]{}<>@#&$|"; for(i = 0; neutrals[i] != '\0'; i++) { if(letter == (uint32_t)neutrals[i]) return true; } From 6aff9f65ed8790ac0dd8f302e6d872363bd710fb Mon Sep 17 00:00:00 2001 From: Paul Peavyhouse Date: Tue, 22 Oct 2019 13:02:31 -0700 Subject: [PATCH 21/64] Floating point fix for RGB to HSV Test code at https://github.com/paulpv/lv_examples/blob/master/lv_tests/lv_test_misc/lv_test_color/lv_test_color.ino --- src/lv_misc/lv_color.c | 45 +++++++++++++++++++++++++++++------------- src/lv_misc/lv_color.h | 2 ++ src/lv_misc/lv_log.c | 1 + 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/src/lv_misc/lv_color.c b/src/lv_misc/lv_color.c index f5bec62bb..3a9c0f8a6 100644 --- a/src/lv_misc/lv_color.c +++ b/src/lv_misc/lv_color.c @@ -105,39 +105,56 @@ lv_color_t lv_color_hsv_to_rgb(uint16_t h, uint8_t s, uint8_t v) } /** - * Convert an RGB color to HSV + * Convert an 32-bit RGB color to HSV * @param r red * @param g green * @param b blue * @return the given RGB color n HSV */ -lv_color_hsv_t lv_color_rgb_to_hsv(uint8_t r, uint8_t g, uint8_t b) +lv_color_hsv_t lv_color_rgb_to_hsv(uint8_t r8, uint8_t g8, uint8_t b8) { + float r = r8 / 255.0; + float g = g8 / 255.0; + float b = b8 / 255.0; + + float min = r < g ? (r < b ? r : b) : (g < b ? g : b); + float max = r > g ? (r > b ? r : b) : (g > b ? g : b); + lv_color_hsv_t hsv; - uint8_t rgbMin, rgbMax; - rgbMin = r < g ? (r < b ? r : b) : (g < b ? g : b); - rgbMax = r > g ? (r > b ? r : b) : (g > b ? g : b); + // https://en.wikipedia.org/wiki/HSL_and_HSV#Lightness + hsv.v = max * 100 + 0.5; - hsv.v = rgbMax; - if(hsv.v == 0) { + float delta = max - min; + if (fabs(delta) < 0.009) { hsv.h = 0; hsv.s = 0; return hsv; } - hsv.s = 255 * (long)(rgbMax - rgbMin) / hsv.v; + // https://en.wikipedia.org/wiki/HSL_and_HSV#Saturation + hsv.s = delta / max * 100 + 0.5; if(hsv.s == 0) { hsv.h = 0; return hsv; } - if(rgbMax == r) - hsv.h = 0 + 43 * (g - b) / (rgbMax - rgbMin); - else if(rgbMax == g) - hsv.h = 85 + 43 * (b - r) / (rgbMax - rgbMin); - else - hsv.h = 171 + 43 * (r - g) / (rgbMax - rgbMin); + // https://en.wikipedia.org/wiki/HSL_and_HSV#Hue_and_chroma + float h; + if(max == r) h = (g - b) / delta + (g < b ? 6 : 0); // between yellow & magenta + else if(max == g) h = (b - r) / delta + 2; // between cyan & yellow + else if(max == b) h = (r - g) / delta + 4; // between magenta & cyan + else h = 0; + h *= 60; + if (h < 0) h += 360; + hsv.h = h + 0.5; return hsv; } + +lv_color_hsv_t lv_color_to_hsv(lv_color_t color) +{ + lv_color32_t color32; + color32.full = lv_color_to32(color); + return lv_color_rgb_to_hsv(color32.ch.red, color32.ch.green, color32.ch.blue); +} \ No newline at end of file diff --git a/src/lv_misc/lv_color.h b/src/lv_misc/lv_color.h index 4f994e2ef..35c2301f1 100644 --- a/src/lv_misc/lv_color.h +++ b/src/lv_misc/lv_color.h @@ -471,6 +471,8 @@ lv_color_t lv_color_hsv_to_rgb(uint16_t h, uint8_t s, uint8_t v); */ lv_color_hsv_t lv_color_rgb_to_hsv(uint8_t r, uint8_t g, uint8_t b); +lv_color_hsv_t lv_color_to_hsv(lv_color_t color); + /********************** * MACROS **********************/ diff --git a/src/lv_misc/lv_log.c b/src/lv_misc/lv_log.c index 2d12da4e1..acbdfb732 100644 --- a/src/lv_misc/lv_log.c +++ b/src/lv_misc/lv_log.c @@ -12,6 +12,7 @@ #if LV_LOG_PRINTF #include #endif + /********************* * DEFINES *********************/ From 69d7d5376889d5d3bbc100f74b86118e06695f19 Mon Sep 17 00:00:00 2001 From: Paul Peavyhouse Date: Tue, 22 Oct 2019 13:07:01 -0700 Subject: [PATCH 22/64] Documenting code --- src/lv_misc/lv_color.c | 15 ++++++++++----- src/lv_misc/lv_color.h | 17 +++++++++++------ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/lv_misc/lv_color.c b/src/lv_misc/lv_color.c index 3a9c0f8a6..547dcc298 100644 --- a/src/lv_misc/lv_color.c +++ b/src/lv_misc/lv_color.c @@ -105,11 +105,11 @@ lv_color_t lv_color_hsv_to_rgb(uint16_t h, uint8_t s, uint8_t v) } /** - * Convert an 32-bit RGB color to HSV - * @param r red - * @param g green - * @param b blue - * @return the given RGB color n HSV + * Convert a 32-bit RGB color to HSV + * @param r8 8-bit red + * @param g8 8-bit green + * @param b8 8-bit blue + * @return the given RGB color in HSV */ lv_color_hsv_t lv_color_rgb_to_hsv(uint8_t r8, uint8_t g8, uint8_t b8) { @@ -152,6 +152,11 @@ lv_color_hsv_t lv_color_rgb_to_hsv(uint8_t r8, uint8_t g8, uint8_t b8) return hsv; } +/** + * Convert a color to HSV + * @param color color + * @return the given color in HSV + */ lv_color_hsv_t lv_color_to_hsv(lv_color_t color) { lv_color32_t color32; diff --git a/src/lv_misc/lv_color.h b/src/lv_misc/lv_color.h index 35c2301f1..7e7ad1def 100644 --- a/src/lv_misc/lv_color.h +++ b/src/lv_misc/lv_color.h @@ -463,14 +463,19 @@ static inline lv_color_t lv_color_hex3(uint32_t c) lv_color_t lv_color_hsv_to_rgb(uint16_t h, uint8_t s, uint8_t v); /** - * Convert an RGB color to HSV - * @param r red - * @param g green - * @param b blue - * @return the given RGB color n HSV + * Convert a 32-bit RGB color to HSV + * @param r8 8-bit red + * @param g8 8-bit green + * @param b8 8-bit blue + * @return the given RGB color in HSV */ -lv_color_hsv_t lv_color_rgb_to_hsv(uint8_t r, uint8_t g, uint8_t b); +lv_color_hsv_t lv_color_rgb_to_hsv(uint8_t r8, uint8_t g8, uint8_t b8); +/** + * Convert a color to HSV + * @param color color + * @return the given color in HSV + */ lv_color_hsv_t lv_color_to_hsv(lv_color_t color); /********************** From 65252024bf3703005be2ccad616a98f2ea5982c2 Mon Sep 17 00:00:00 2001 From: Paul Peavyhouse Date: Tue, 22 Oct 2019 13:17:53 -0700 Subject: [PATCH 23/64] Formatting --- src/lv_misc/lv_color.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lv_misc/lv_color.c b/src/lv_misc/lv_color.c index 547dcc298..8ff816061 100644 --- a/src/lv_misc/lv_color.c +++ b/src/lv_misc/lv_color.c @@ -141,10 +141,14 @@ lv_color_hsv_t lv_color_rgb_to_hsv(uint8_t r8, uint8_t g8, uint8_t b8) // https://en.wikipedia.org/wiki/HSL_and_HSV#Hue_and_chroma float h; - if(max == r) h = (g - b) / delta + (g < b ? 6 : 0); // between yellow & magenta - else if(max == g) h = (b - r) / delta + 2; // between cyan & yellow - else if(max == b) h = (r - g) / delta + 4; // between magenta & cyan - else h = 0; + if(max == r) + h = (g - b) / delta + (g < b ? 6 : 0); // between yellow & magenta + else if(max == g) + h = (b - r) / delta + 2; // between cyan & yellow + else if(max == b) + h = (r - g) / delta + 4; // between magenta & cyan + else + h = 0; h *= 60; if (h < 0) h += 360; From a572d8a648fd74387b0707175a8151126918fcda Mon Sep 17 00:00:00 2001 From: Paul Peavyhouse Date: Tue, 22 Oct 2019 13:19:22 -0700 Subject: [PATCH 24/64] Keeping some original variable names --- src/lv_misc/lv_color.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lv_misc/lv_color.c b/src/lv_misc/lv_color.c index 8ff816061..ecb710aa9 100644 --- a/src/lv_misc/lv_color.c +++ b/src/lv_misc/lv_color.c @@ -117,15 +117,15 @@ lv_color_hsv_t lv_color_rgb_to_hsv(uint8_t r8, uint8_t g8, uint8_t b8) float g = g8 / 255.0; float b = b8 / 255.0; - float min = r < g ? (r < b ? r : b) : (g < b ? g : b); - float max = r > g ? (r > b ? r : b) : (g > b ? g : b); + float rgbMin = r < g ? (r < b ? r : b) : (g < b ? g : b); + float rgbMax = r > g ? (r > b ? r : b) : (g > b ? g : b); lv_color_hsv_t hsv; // https://en.wikipedia.org/wiki/HSL_and_HSV#Lightness - hsv.v = max * 100 + 0.5; + hsv.v = rgbMax * 100 + 0.5; - float delta = max - min; + float delta = rgbMax - rgbMin; if (fabs(delta) < 0.009) { hsv.h = 0; hsv.s = 0; @@ -133,7 +133,7 @@ lv_color_hsv_t lv_color_rgb_to_hsv(uint8_t r8, uint8_t g8, uint8_t b8) } // https://en.wikipedia.org/wiki/HSL_and_HSV#Saturation - hsv.s = delta / max * 100 + 0.5; + hsv.s = delta / rgbMax * 100 + 0.5; if(hsv.s == 0) { hsv.h = 0; return hsv; @@ -141,11 +141,11 @@ lv_color_hsv_t lv_color_rgb_to_hsv(uint8_t r8, uint8_t g8, uint8_t b8) // https://en.wikipedia.org/wiki/HSL_and_HSV#Hue_and_chroma float h; - if(max == r) + if(rgbMax == r) h = (g - b) / delta + (g < b ? 6 : 0); // between yellow & magenta - else if(max == g) + else if(rgbMax == g) h = (b - r) / delta + 2; // between cyan & yellow - else if(max == b) + else if(rgbMax == b) h = (r - g) / delta + 4; // between magenta & cyan else h = 0; From ddd7c1d30cadfd93db2a36ea3c886c2fbbcc5576 Mon Sep 17 00:00:00 2001 From: Paul Peavyhouse Date: Tue, 22 Oct 2019 13:29:38 -0700 Subject: [PATCH 25/64] Adding ending newline --- src/lv_misc/lv_color.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_misc/lv_color.c b/src/lv_misc/lv_color.c index ecb710aa9..808b9d968 100644 --- a/src/lv_misc/lv_color.c +++ b/src/lv_misc/lv_color.c @@ -166,4 +166,4 @@ lv_color_hsv_t lv_color_to_hsv(lv_color_t color) lv_color32_t color32; color32.full = lv_color_to32(color); return lv_color_rgb_to_hsv(color32.ch.red, color32.ch.green, color32.ch.blue); -} \ No newline at end of file +} From 4158334a400563217cca99ed29131962b9fc8c18 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 24 Oct 2019 07:15:00 +0200 Subject: [PATCH 26/64] bidi: ahndle LV_BIDI_DIR_AUTO in lv_bidi_process_paragraph --- src/lv_misc/lv_bidi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lv_misc/lv_bidi.c b/src/lv_misc/lv_bidi.c index 61c12e5b2..933773d93 100644 --- a/src/lv_misc/lv_bidi.c +++ b/src/lv_misc/lv_bidi.c @@ -138,6 +138,8 @@ void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len lv_bidi_dir_t run_dir; uint32_t rd = 0; uint32_t wr; + + if(base_dir == LV_BIDI_DIR_AUTO) base_dir = lv_bidi_detect_base_dir(str_in); if(base_dir == LV_BIDI_DIR_RTL) wr = len; else wr = 0; From 372b133b18f3f06fd7db7102ad95c465a2017dd3 Mon Sep 17 00:00:00 2001 From: Paul Peavyhouse Date: Thu, 24 Oct 2019 16:46:30 -0700 Subject: [PATCH 27/64] Converting to integer based math --- src/lv_misc/lv_color.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/lv_misc/lv_color.c b/src/lv_misc/lv_color.c index 808b9d968..8835c0747 100644 --- a/src/lv_misc/lv_color.c +++ b/src/lv_misc/lv_color.c @@ -113,46 +113,47 @@ lv_color_t lv_color_hsv_to_rgb(uint16_t h, uint8_t s, uint8_t v) */ lv_color_hsv_t lv_color_rgb_to_hsv(uint8_t r8, uint8_t g8, uint8_t b8) { - float r = r8 / 255.0; - float g = g8 / 255.0; - float b = b8 / 255.0; + uint16_t r = ((uint32_t)r8 << 10) / 255; + uint16_t g = ((uint32_t)g8 << 10) / 255; + uint16_t b = ((uint32_t)b8 << 10) / 255; - float rgbMin = r < g ? (r < b ? r : b) : (g < b ? g : b); - float rgbMax = r > g ? (r > b ? r : b) : (g > b ? g : b); + uint16_t rgbMin = r < g ? (r < b ? r : b) : (g < b ? g : b); + uint16_t rgbMax = r > g ? (r > b ? r : b) : (g > b ? g : b); lv_color_hsv_t hsv; // https://en.wikipedia.org/wiki/HSL_and_HSV#Lightness - hsv.v = rgbMax * 100 + 0.5; + hsv.v = (100 * rgbMax) >> 10; - float delta = rgbMax - rgbMin; - if (fabs(delta) < 0.009) { + int32_t delta = rgbMax - rgbMin; + if (abs(delta) < 3) { hsv.h = 0; hsv.s = 0; return hsv; } // https://en.wikipedia.org/wiki/HSL_and_HSV#Saturation - hsv.s = delta / rgbMax * 100 + 0.5; - if(hsv.s == 0) { + hsv.s = 100 * delta / rgbMax; + if(hsv.s < 3) { hsv.h = 0; return hsv; } // https://en.wikipedia.org/wiki/HSL_and_HSV#Hue_and_chroma - float h; + int32_t h; if(rgbMax == r) - h = (g - b) / delta + (g < b ? 6 : 0); // between yellow & magenta + h = (((g - b) << 10) / delta) + (g < b ? (6 << 10) : 0); // between yellow & magenta else if(rgbMax == g) - h = (b - r) / delta + 2; // between cyan & yellow + h = (((b - r) << 10) / delta) + (2 << 10); // between cyan & yellow else if(rgbMax == b) - h = (r - g) / delta + 4; // between magenta & cyan + h = (((r - g) << 10) / delta) + (4 << 10); // between magenta & cyan else h = 0; h *= 60; + h >>= 10; if (h < 0) h += 360; - hsv.h = h + 0.5; + hsv.h = h; return hsv; } From 6df1fe190a6bc7a09bc901360fe14c693c134063 Mon Sep 17 00:00:00 2001 From: Paul Peavyhouse Date: Thu, 24 Oct 2019 20:13:03 -0700 Subject: [PATCH 28/64] #include and use LV_MATH_ABS --- src/lv_misc/lv_color.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lv_misc/lv_color.c b/src/lv_misc/lv_color.c index 8835c0747..cd4825dfe 100644 --- a/src/lv_misc/lv_color.c +++ b/src/lv_misc/lv_color.c @@ -7,6 +7,7 @@ * INCLUDES *********************/ #include "lv_color.h" +#include "lv_math.h" /********************* * DEFINES @@ -126,7 +127,7 @@ lv_color_hsv_t lv_color_rgb_to_hsv(uint8_t r8, uint8_t g8, uint8_t b8) hsv.v = (100 * rgbMax) >> 10; int32_t delta = rgbMax - rgbMin; - if (abs(delta) < 3) { + if (LV_MATH_ABS(delta) < 3) { hsv.h = 0; hsv.s = 0; return hsv; From 57a8ee8e325e861be920d0860bedd3e388f0b027 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 25 Oct 2019 06:15:11 +0200 Subject: [PATCH 29/64] bidi: add bracket algorithm --- src/lv_misc/lv_bidi.c | 110 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 104 insertions(+), 6 deletions(-) diff --git a/src/lv_misc/lv_bidi.c b/src/lv_misc/lv_bidi.c index e9929bc67..4c365d660 100644 --- a/src/lv_misc/lv_bidi.c +++ b/src/lv_misc/lv_bidi.c @@ -15,10 +15,16 @@ /********************* * DEFINES *********************/ +#define LV_BIDI_BRACKLET_DEPTH 4 /********************** * TYPEDEFS **********************/ +typedef struct +{ + uint32_t bracklet_pos; + lv_bidi_dir_t dir; +}bracket_stack_t; /********************** * STATIC PROTOTYPES @@ -28,10 +34,15 @@ static uint32_t get_next_paragraph(const char * txt); static lv_bidi_dir_t get_next_run(const char * txt, lv_bidi_dir_t base_dir, uint32_t * len); static void rtl_reverse(char * dest, const char * src, uint32_t len); static uint32_t char_change_to_pair(uint32_t letter); +static lv_bidi_dir_t bracket_process(const uint8_t * txt, uint32_t next_pos, uint32_t len, uint32_t letter, lv_bidi_dir_t base_dir); /********************** * STATIC VARIABLES **********************/ +static const uint8_t bracket_left[] = {"<({["}; +static const uint8_t bracket_right[] = {">)}]"}; +static bracket_stack_t br_stack[LV_BIDI_BRACKLET_DEPTH]; +static uint8_t br_stack_p; /********************** * MACROS @@ -43,6 +54,7 @@ static uint32_t char_change_to_pair(uint32_t letter); void lv_bidi_process(const char * str_in, char * str_out, lv_bidi_dir_t base_dir) { + br_stack_p = 0; if(base_dir == LV_BIDI_DIR_AUTO) base_dir = lv_bidi_detect_base_dir(str_in); @@ -151,6 +163,8 @@ static void process_paragraph(const char * str_in, char * str_out, uint32_t len, while(rd < len) { uint32_t letter = lv_txt_encoded_next(str_in, &rd); dir = lv_bidi_get_letter_dir(letter); + if(dir == LV_BIDI_DIR_NEUTRAL) dir = bracket_process(str_in, rd, len, letter, base_dir); + if(dir != LV_BIDI_DIR_NEUTRAL && dir != LV_BIDI_DIR_WEAK) break; } @@ -204,11 +218,15 @@ static lv_bidi_dir_t get_next_run(const char * txt, lv_bidi_dir_t base_dir, uint letter = lv_txt_encoded_next(txt, NULL); lv_bidi_dir_t dir = lv_bidi_get_letter_dir(letter); + if(dir == LV_BIDI_DIR_NEUTRAL) dir = bracket_process(txt, 0, len, letter, base_dir); + /*Find the first strong char. Skip the neutrals*/ while(dir == LV_BIDI_DIR_NEUTRAL || dir == LV_BIDI_DIR_WEAK) { letter = lv_txt_encoded_next(txt, &i); dir = lv_bidi_get_letter_dir(letter); + if(dir == LV_BIDI_DIR_NEUTRAL) dir = bracket_process(txt, i, len, letter, base_dir); + if(txt[i] == '\0' || txt[i] == '\n' || txt[i] == '\r') { *len = i; return base_dir; @@ -225,6 +243,7 @@ static lv_bidi_dir_t get_next_run(const char * txt, lv_bidi_dir_t base_dir, uint while(txt[i] != '\0'&& txt[i] != '\n' && txt[i] != '\r') { letter = lv_txt_encoded_next(txt, &i); next_dir = lv_bidi_get_letter_dir(letter); + if(dir == LV_BIDI_DIR_NEUTRAL) dir = bracket_process(txt, i, len, letter, base_dir); /*New dir found?*/ if((next_dir == LV_BIDI_DIR_RTL || next_dir == LV_BIDI_DIR_LTR) && next_dir != run_dir) { @@ -303,19 +322,98 @@ static void rtl_reverse(char * dest, const char * src, uint32_t len) static uint32_t char_change_to_pair(uint32_t letter) { - static uint8_t left[] = {"<({["}; - static uint8_t right[] = {">)}]"}; uint8_t i; - for(i = 0; left[i] != '\0'; i++) { - if(letter == left[i]) return right[i]; + for(i = 0; bracket_left[i] != '\0'; i++) { + if(letter == bracket_left[i]) return bracket_right[i]; } - for(i = 0; right[i] != '\0'; i++) { - if(letter == right[i]) return left[i]; + for(i = 0; bracket_right[i] != '\0'; i++) { + if(letter == bracket_right[i]) return bracket_left[i]; } return letter; } +static lv_bidi_dir_t bracket_process(const uint8_t * txt, uint32_t next_pos, uint32_t len, uint32_t letter, lv_bidi_dir_t base_dir) +{ + if(br_stack_p >= LV_BIDI_BRACKLET_DEPTH) return LV_BIDI_DIR_NEUTRAL; + + lv_bidi_dir_t bracket_dir = LV_BIDI_DIR_NEUTRAL; + + uint8_t i; + /*Is the letter an opening bracket?*/ + for(i = 0; bracket_left[i] != '\0'; i++) { + if(bracket_left[i] == letter) { + /* If so find it's matching closing bracket. + * If a char with base dir. direction is found then the brackets will have `base_dir` direction*/ + uint32_t txt_i = next_pos; + while(txt_i < len) { + uint32_t letter_next = lv_txt_encoded_next(txt, &txt_i); + if(letter_next == bracket_right[i]) { + /*Closing bracket found*/ + break; + } else { + /*Save the dir*/ + lv_bidi_dir_t letter_dir = lv_bidi_get_letter_dir(letter); + if(letter_dir == base_dir) { + bracket_dir = base_dir; + } + } + } + + /*There were no matching closing bracket*/ + if(txt_i >= len) return LV_BIDI_DIR_NEUTRAL; + + /*There where a strong char with base dir in the bracket so the dir is found.*/ + if(bracket_dir != LV_BIDI_DIR_NEUTRAL) break; + + /*If there were no matching strong chars in the brackets then check the previous chars*/ + txt_i = next_pos; + if(txt_i) lv_txt_encoded_prev(txt, &txt_i); + if(txt_i) lv_txt_encoded_prev(txt, &txt_i); + while(txt_i > 0) { + uint32_t letter_next = lv_txt_encoded_prev(txt, &txt_i); + lv_bidi_dir_t letter_dir = lv_bidi_get_letter_dir(letter); + if(letter_dir == LV_BIDI_DIR_LTR || letter_dir == LV_BIDI_DIR_RTL) { + bracket_dir = letter_dir; + break; + } + } + + + /*There where a previous strong char which can be used*/ + if(bracket_dir != LV_BIDI_DIR_NEUTRAL) break; + + /*There were no strong chars before the bracket, so use the base dir.*/ + if(txt_i == 0) bracket_dir = base_dir; + + break; + } + } + + + /*The letter was an opening bracket*/ + if(bracket_left[i] != '\0') { + + if(bracket_dir == LV_BIDI_DIR_NEUTRAL) break; + + br_stack[br_stack_p].bracklet_pos = i; + br_stack[br_stack_p].dir = bracket_dir; + + br_stack_p++; + return bracket_dir; + } else { + /*Is the letter a closing bracket of the last opening?*/ + if(letter == bracket_right[br_stack[br_stack_p].bracklet_pos]) { + bracket_dir = br_stack[br_stack_p].dir; + br_stack_p--; + return bracket_dir; + } + } + + return LV_BIDI_DIR_NEUTRAL; +} + + #endif /*LV_USE_BIDI*/ From 081b2c2271ae4c42d051f2c670a4e92aaebb8546 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 27 Oct 2019 10:21:37 +0100 Subject: [PATCH 30/64] bidi: barcket handle fixes --- src/lv_misc/lv_bidi.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/lv_misc/lv_bidi.c b/src/lv_misc/lv_bidi.c index 4c365d660..c00485dc6 100644 --- a/src/lv_misc/lv_bidi.c +++ b/src/lv_misc/lv_bidi.c @@ -34,7 +34,7 @@ static uint32_t get_next_paragraph(const char * txt); static lv_bidi_dir_t get_next_run(const char * txt, lv_bidi_dir_t base_dir, uint32_t * len); static void rtl_reverse(char * dest, const char * src, uint32_t len); static uint32_t char_change_to_pair(uint32_t letter); -static lv_bidi_dir_t bracket_process(const uint8_t * txt, uint32_t next_pos, uint32_t len, uint32_t letter, lv_bidi_dir_t base_dir); +static lv_bidi_dir_t bracket_process(const char * txt, uint32_t next_pos, uint32_t len, uint32_t letter, lv_bidi_dir_t base_dir); /********************** * STATIC VARIABLES @@ -54,8 +54,6 @@ static uint8_t br_stack_p; void lv_bidi_process(const char * str_in, char * str_out, lv_bidi_dir_t base_dir) { - br_stack_p = 0; - if(base_dir == LV_BIDI_DIR_AUTO) base_dir = lv_bidi_detect_base_dir(str_in); uint32_t par_start = 0; @@ -159,6 +157,9 @@ static void process_paragraph(const char * str_in, char * str_out, uint32_t len, lv_bidi_dir_t dir = base_dir; + /*Empty the bracket stack*/ + br_stack_p = 0; + /*Process neutral chars in the beginning*/ while(rd < len) { uint32_t letter = lv_txt_encoded_next(str_in, &rd); @@ -218,14 +219,14 @@ static lv_bidi_dir_t get_next_run(const char * txt, lv_bidi_dir_t base_dir, uint letter = lv_txt_encoded_next(txt, NULL); lv_bidi_dir_t dir = lv_bidi_get_letter_dir(letter); - if(dir == LV_BIDI_DIR_NEUTRAL) dir = bracket_process(txt, 0, len, letter, base_dir); + if(dir == LV_BIDI_DIR_NEUTRAL) dir = bracket_process(txt, 0, *len, letter, base_dir); /*Find the first strong char. Skip the neutrals*/ while(dir == LV_BIDI_DIR_NEUTRAL || dir == LV_BIDI_DIR_WEAK) { letter = lv_txt_encoded_next(txt, &i); dir = lv_bidi_get_letter_dir(letter); - if(dir == LV_BIDI_DIR_NEUTRAL) dir = bracket_process(txt, i, len, letter, base_dir); + if(dir == LV_BIDI_DIR_NEUTRAL) dir = bracket_process(txt, i, *len, letter, base_dir); if(txt[i] == '\0' || txt[i] == '\n' || txt[i] == '\r') { *len = i; @@ -243,7 +244,7 @@ static lv_bidi_dir_t get_next_run(const char * txt, lv_bidi_dir_t base_dir, uint while(txt[i] != '\0'&& txt[i] != '\n' && txt[i] != '\r') { letter = lv_txt_encoded_next(txt, &i); next_dir = lv_bidi_get_letter_dir(letter); - if(dir == LV_BIDI_DIR_NEUTRAL) dir = bracket_process(txt, i, len, letter, base_dir); + if(dir == LV_BIDI_DIR_NEUTRAL) dir = bracket_process(txt, i, *len, letter, base_dir); /*New dir found?*/ if((next_dir == LV_BIDI_DIR_RTL || next_dir == LV_BIDI_DIR_LTR) && next_dir != run_dir) { @@ -335,7 +336,7 @@ static uint32_t char_change_to_pair(uint32_t letter) return letter; } -static lv_bidi_dir_t bracket_process(const uint8_t * txt, uint32_t next_pos, uint32_t len, uint32_t letter, lv_bidi_dir_t base_dir) +static lv_bidi_dir_t bracket_process(const char * txt, uint32_t next_pos, uint32_t len, uint32_t letter, lv_bidi_dir_t base_dir) { if(br_stack_p >= LV_BIDI_BRACKLET_DEPTH) return LV_BIDI_DIR_NEUTRAL; @@ -396,7 +397,7 @@ static lv_bidi_dir_t bracket_process(const uint8_t * txt, uint32_t next_pos, uin /*The letter was an opening bracket*/ if(bracket_left[i] != '\0') { - if(bracket_dir == LV_BIDI_DIR_NEUTRAL) break; + if(bracket_dir == LV_BIDI_DIR_NEUTRAL) return bracket_dir; br_stack[br_stack_p].bracklet_pos = i; br_stack[br_stack_p].dir = bracket_dir; From 98a4d9b06291e14ec83b41ba85bcb6cdd61e4ba5 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 27 Oct 2019 10:44:00 +0100 Subject: [PATCH 31/64] bidi: barcket process fixes --- src/lv_misc/lv_bidi.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/lv_misc/lv_bidi.c b/src/lv_misc/lv_bidi.c index ea67499dc..13ecdc17d 100644 --- a/src/lv_misc/lv_bidi.c +++ b/src/lv_misc/lv_bidi.c @@ -219,14 +219,14 @@ static lv_bidi_dir_t get_next_run(const char * txt, lv_bidi_dir_t base_dir, uint letter = lv_txt_encoded_next(txt, NULL); lv_bidi_dir_t dir = lv_bidi_get_letter_dir(letter); - if(dir == LV_BIDI_DIR_NEUTRAL) dir = bracket_process(txt, 0, *len, letter, base_dir); + if(dir == LV_BIDI_DIR_NEUTRAL) dir = bracket_process(txt, 0, max_len, letter, base_dir); /*Find the first strong char. Skip the neutrals*/ while(dir == LV_BIDI_DIR_NEUTRAL || dir == LV_BIDI_DIR_WEAK) { letter = lv_txt_encoded_next(txt, &i); dir = lv_bidi_get_letter_dir(letter); - if(dir == LV_BIDI_DIR_NEUTRAL) dir = bracket_process(txt, i, *len, letter, base_dir); + if(dir == LV_BIDI_DIR_NEUTRAL) dir = bracket_process(txt, i, max_len, letter, base_dir); if(i >= max_len || txt[i] == '\0' || txt[i] == '\n' || txt[i] == '\r') { *len = i; @@ -244,7 +244,7 @@ static lv_bidi_dir_t get_next_run(const char * txt, lv_bidi_dir_t base_dir, uint while(i_prev < max_len && txt[i] != '\0' && txt[i] != '\n' && txt[i] != '\r') { letter = lv_txt_encoded_next(txt, &i); next_dir = lv_bidi_get_letter_dir(letter); - if(dir == LV_BIDI_DIR_NEUTRAL) dir = bracket_process(txt, i, *len, letter, base_dir); + if(next_dir == LV_BIDI_DIR_NEUTRAL) next_dir = bracket_process(txt, i, max_len, letter, base_dir); /*New dir found?*/ if((next_dir == LV_BIDI_DIR_RTL || next_dir == LV_BIDI_DIR_LTR) && next_dir != run_dir) { @@ -356,7 +356,7 @@ static lv_bidi_dir_t bracket_process(const char * txt, uint32_t next_pos, uint32 break; } else { /*Save the dir*/ - lv_bidi_dir_t letter_dir = lv_bidi_get_letter_dir(letter); + lv_bidi_dir_t letter_dir = lv_bidi_get_letter_dir(letter_next); if(letter_dir == base_dir) { bracket_dir = base_dir; } @@ -364,18 +364,17 @@ static lv_bidi_dir_t bracket_process(const char * txt, uint32_t next_pos, uint32 } /*There were no matching closing bracket*/ - if(txt_i >= len) return LV_BIDI_DIR_NEUTRAL; + if(txt_i > len) return LV_BIDI_DIR_NEUTRAL; /*There where a strong char with base dir in the bracket so the dir is found.*/ - if(bracket_dir != LV_BIDI_DIR_NEUTRAL) break; + if(bracket_dir != LV_BIDI_DIR_NEUTRAL && bracket_dir != LV_BIDI_DIR_WEAK) break; /*If there were no matching strong chars in the brackets then check the previous chars*/ txt_i = next_pos; if(txt_i) lv_txt_encoded_prev(txt, &txt_i); - if(txt_i) lv_txt_encoded_prev(txt, &txt_i); while(txt_i > 0) { uint32_t letter_next = lv_txt_encoded_prev(txt, &txt_i); - lv_bidi_dir_t letter_dir = lv_bidi_get_letter_dir(letter); + lv_bidi_dir_t letter_dir = lv_bidi_get_letter_dir(letter_next); if(letter_dir == LV_BIDI_DIR_LTR || letter_dir == LV_BIDI_DIR_RTL) { bracket_dir = letter_dir; break; @@ -404,10 +403,10 @@ static lv_bidi_dir_t bracket_process(const char * txt, uint32_t next_pos, uint32 br_stack_p++; return bracket_dir; - } else { + } else if(br_stack_p > 0) { /*Is the letter a closing bracket of the last opening?*/ - if(letter == bracket_right[br_stack[br_stack_p].bracklet_pos]) { - bracket_dir = br_stack[br_stack_p].dir; + if(letter == bracket_right[br_stack[br_stack_p - 1].bracklet_pos]) { + bracket_dir = br_stack[br_stack_p - 1].dir; br_stack_p--; return bracket_dir; } From dd68877aae8cd70f3b4a26118770d1735e21e1e0 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 28 Oct 2019 05:47:31 +0100 Subject: [PATCH 32/64] bidi bracket handling fixies --- src/lv_misc/lv_bidi.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/lv_misc/lv_bidi.c b/src/lv_misc/lv_bidi.c index 13ecdc17d..634e1f896 100644 --- a/src/lv_misc/lv_bidi.c +++ b/src/lv_misc/lv_bidi.c @@ -338,8 +338,6 @@ static uint32_t char_change_to_pair(uint32_t letter) static lv_bidi_dir_t bracket_process(const char * txt, uint32_t next_pos, uint32_t len, uint32_t letter, lv_bidi_dir_t base_dir) { - if(br_stack_p >= LV_BIDI_BRACKLET_DEPTH) return LV_BIDI_DIR_NEUTRAL; - lv_bidi_dir_t bracket_dir = LV_BIDI_DIR_NEUTRAL; uint8_t i; @@ -396,7 +394,7 @@ static lv_bidi_dir_t bracket_process(const char * txt, uint32_t next_pos, uint32 /*The letter was an opening bracket*/ if(bracket_left[i] != '\0') { - if(bracket_dir == LV_BIDI_DIR_NEUTRAL) return bracket_dir; + if(bracket_dir == LV_BIDI_DIR_NEUTRAL || br_stack_p == LV_BIDI_BRACKLET_DEPTH) return LV_BIDI_DIR_NEUTRAL; br_stack[br_stack_p].bracklet_pos = i; br_stack[br_stack_p].dir = bracket_dir; From 5222bf92c4e234f18a0a67687dd55f4ad588230d Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sat, 2 Nov 2019 23:33:25 +0100 Subject: [PATCH 33/64] kb: use LV_SYMBOL_NEW_LINE as new line --- src/lv_objx/lv_kb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_objx/lv_kb.c b/src/lv_objx/lv_kb.c index 1229ffa8b..1c896ba6a 100644 --- a/src/lv_objx/lv_kb.c +++ b/src/lv_objx/lv_kb.c @@ -395,7 +395,7 @@ void lv_kb_def_event_cb(lv_obj_t * kb, lv_event_t event) /*Add the characters to the text area if set*/ if(ext->ta == NULL) return; - if(strcmp(txt, "Enter") == 0) + if(strcmp(txt, "Enter") == 0 || strcmp(txt, LV_SYMBOL_NEW_LINE) == 0) lv_ta_add_char(ext->ta, '\n'); else if(strcmp(txt, LV_SYMBOL_LEFT) == 0) lv_ta_cursor_left(ext->ta); From 9472d0d0c7e601e92b6ded005605004e2dfb35c4 Mon Sep 17 00:00:00 2001 From: Jan Van Winkel Date: Sun, 3 Nov 2019 14:43:26 +0100 Subject: [PATCH 34/64] Added missing lv_indev.h includes (#1251) --- lvgl.h | 1 + src/lv_objx/lv_slider.c | 1 + src/lv_objx/lv_sw.c | 1 + 3 files changed, 3 insertions(+) diff --git a/lvgl.h b/lvgl.h index b6e29b61b..8344953f8 100644 --- a/lvgl.h +++ b/lvgl.h @@ -25,6 +25,7 @@ extern "C" { #include "src/lv_core/lv_obj.h" #include "src/lv_core/lv_group.h" +#include "src/lv_core/lv_indev.h" #include "src/lv_core/lv_refr.h" #include "src/lv_core/lv_disp.h" diff --git a/src/lv_objx/lv_slider.c b/src/lv_objx/lv_slider.c index a7fb4333b..a1624e37f 100644 --- a/src/lv_objx/lv_slider.c +++ b/src/lv_objx/lv_slider.c @@ -11,6 +11,7 @@ #if LV_USE_SLIDER != 0 #include "../lv_core/lv_group.h" +#include "../lv_core/lv_indev.h" #include "../lv_draw/lv_draw.h" #include "../lv_themes/lv_theme.h" #include "../lv_misc/lv_math.h" diff --git a/src/lv_objx/lv_sw.c b/src/lv_objx/lv_sw.c index 80854b0a0..c710dbc65 100644 --- a/src/lv_objx/lv_sw.c +++ b/src/lv_objx/lv_sw.c @@ -17,6 +17,7 @@ #include "../lv_themes/lv_theme.h" #include "../lv_misc/lv_math.h" +#include "../lv_core/lv_indev.h" /********************* * DEFINES From f6829a17b22f0f89917197957e120f951b2585a4 Mon Sep 17 00:00:00 2001 From: Amir Gonnen Date: Mon, 4 Nov 2019 01:31:54 +0200 Subject: [PATCH 35/64] WIP: Bidi pos_conv --- src/lv_draw/lv_draw_label.c | 2 +- src/lv_misc/lv_bidi.c | 152 +++++++++++++++++++++++++++--------- src/lv_misc/lv_bidi.h | 2 +- 3 files changed, 116 insertions(+), 40 deletions(-) diff --git a/src/lv_draw/lv_draw_label.c b/src/lv_draw/lv_draw_label.c index 86b486002..5bd0592c5 100644 --- a/src/lv_draw/lv_draw_label.c +++ b/src/lv_draw/lv_draw_label.c @@ -169,7 +169,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st while(i < line_end - line_start) { #if LV_USE_BIDI char *bidi_txt = lv_draw_get_buf(line_end - line_start + 1); - lv_bidi_process_paragraph(txt + line_start, bidi_txt, line_end - line_start, bidi_dir); + lv_bidi_process_paragraph(txt + line_start, bidi_txt, line_end - line_start, bidi_dir, NULL, 0); #else const char *bidi_txt = txt + line_start; #endif diff --git a/src/lv_misc/lv_bidi.c b/src/lv_misc/lv_bidi.c index 634e1f896..1d962c64a 100644 --- a/src/lv_misc/lv_bidi.c +++ b/src/lv_misc/lv_bidi.c @@ -29,10 +29,11 @@ typedef struct /********************** * STATIC PROTOTYPES **********************/ -static lv_bidi_dir_t get_next_run(const char * txt, lv_bidi_dir_t base_dir, uint32_t max_len, uint32_t * len); -static void rtl_reverse(char * dest, const char * src, uint32_t len); +static lv_bidi_dir_t get_next_run(const char * txt, lv_bidi_dir_t base_dir, uint32_t max_len, uint32_t * len, uint16_t * pos_conv_len); +static void rtl_reverse(char * dest, const char * src, uint32_t len, uint16_t *pos_conv_out, uint16_t pos_conv_rd_base, uint16_t pos_conv_len); static uint32_t char_change_to_pair(uint32_t letter); static lv_bidi_dir_t bracket_process(const char * txt, uint32_t next_pos, uint32_t len, uint32_t letter, lv_bidi_dir_t base_dir); +static void fill_pos_conv(uint16_t * out, uint16_t len, uint16_t index); /********************** * STATIC VARIABLES @@ -64,7 +65,7 @@ void lv_bidi_process(const char * str_in, char * str_out, lv_bidi_dir_t base_dir while(str_in[par_start] != '\0') { par_len = lv_bidi_get_next_paragraph(&str_in[par_start]); - lv_bidi_process_paragraph(&str_in[par_start], &str_out[par_start], par_len, base_dir); + lv_bidi_process_paragraph(&str_in[par_start], &str_out[par_start], par_len, base_dir, NULL, 0); par_start += par_len; while(str_in[par_start] == '\n' || str_in[par_start] == '\r') { @@ -137,23 +138,27 @@ bool lv_bidi_letter_is_neutral(uint32_t letter) return false; } - -/********************** - * STATIC FUNCTIONS - **********************/ - -void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len, lv_bidi_dir_t base_dir) +void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len, lv_bidi_dir_t base_dir, uint16_t *pos_conv_out, uint16_t pos_conv_len) { uint32_t run_len = 0; lv_bidi_dir_t run_dir; uint32_t rd = 0; uint32_t wr; + uint16_t pos_conv_run_len = 0; + uint16_t pos_conv_rd = 0; + uint16_t pos_conv_wr; if(base_dir == LV_BIDI_DIR_AUTO) base_dir = lv_bidi_detect_base_dir(str_in); - if(base_dir == LV_BIDI_DIR_RTL) wr = len; - else wr = 0; + if(base_dir == LV_BIDI_DIR_RTL) { + wr = len; + pos_conv_wr = pos_conv_len; + } + else { + wr = 0; + pos_conv_wr = 0; + } - str_out[len] = '\0'; + if (str_out) str_out[len] = '\0'; lv_bidi_dir_t dir = base_dir; @@ -163,39 +168,59 @@ void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len /*Process neutral chars in the beginning*/ while(rd < len) { uint32_t letter = lv_txt_encoded_next(str_in, &rd); + pos_conv_rd++; dir = lv_bidi_get_letter_dir(letter); if(dir == LV_BIDI_DIR_NEUTRAL) dir = bracket_process(str_in, rd, len, letter, base_dir); - if(dir != LV_BIDI_DIR_NEUTRAL && dir != LV_BIDI_DIR_WEAK) break; } - if(rd && str_in[rd] != '\0') lv_txt_encoded_prev(str_in, &rd); + if(rd && str_in[rd] != '\0') { + lv_txt_encoded_prev(str_in, &rd); + pos_conv_rd--; + } if(rd) { if(base_dir == LV_BIDI_DIR_LTR) { - memcpy(&str_out[wr], str_in, rd); - wr += rd; + if (str_out) { + memcpy(&str_out[wr], str_in, rd); + wr += rd; + } + if (pos_conv_out) { + fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_rd, 0); + pos_conv_wr += pos_conv_rd; + } } else { wr -= rd; - rtl_reverse(&str_out[wr], str_in, rd); + pos_conv_wr -= pos_conv_rd; + rtl_reverse(str_out? &str_out[wr]: NULL, str_in, rd, pos_conv_out? &pos_conv_out[pos_conv_wr]: NULL, 0, pos_conv_rd); } } /*Get and process the runs*/ + while(rd < len) { - run_dir = get_next_run(&str_in[rd], base_dir, len - rd, &run_len); + run_dir = get_next_run(&str_in[rd], base_dir, len - rd, &run_len, &pos_conv_run_len); if(base_dir == LV_BIDI_DIR_LTR) { - if(run_dir == LV_BIDI_DIR_LTR) memcpy(&str_out[wr], &str_in[rd], run_len); - else rtl_reverse(&str_out[wr], &str_in[rd], run_len); + if(run_dir == LV_BIDI_DIR_LTR) { + if (str_out) memcpy(&str_out[wr], &str_in[rd], run_len); + if (pos_conv_out) fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_run_len, pos_conv_rd); + } + else rtl_reverse(str_out? &str_out[wr]: NULL, &str_in[rd], run_len, pos_conv_out? &pos_conv_out[pos_conv_wr] : NULL, pos_conv_rd, pos_conv_run_len); wr += run_len; + pos_conv_wr += pos_conv_run_len; } else { wr -= run_len; - if(run_dir == LV_BIDI_DIR_LTR) memcpy(&str_out[wr], &str_in[rd], run_len); - else rtl_reverse(&str_out[wr], &str_in[rd], run_len); + pos_conv_wr -= pos_conv_run_len; + if(run_dir == LV_BIDI_DIR_LTR) { + if (str_out) memcpy(&str_out[wr], &str_in[rd], run_len); + if (pos_conv_out) fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_run_len, pos_conv_rd); + } + else rtl_reverse(str_out? &str_out[wr]: NULL, &str_in[rd], run_len, pos_conv_out? &pos_conv_out[pos_conv_wr] : NULL, pos_conv_rd, pos_conv_run_len); } rd += run_len; + pos_conv_rd += pos_conv_run_len; } } @@ -212,24 +237,40 @@ uint32_t lv_bidi_get_next_paragraph(const char * txt) return i; } -static lv_bidi_dir_t get_next_run(const char * txt, lv_bidi_dir_t base_dir, uint32_t max_len, uint32_t * len) +/********************** + * STATIC FUNCTIONS + **********************/ + +static void fill_pos_conv(uint16_t * out, uint16_t len, uint16_t index) +{ + for (uint16_t i = 0; i < len; i++) + { + out[i] = index; + index++; + } +} + +static lv_bidi_dir_t get_next_run(const char * txt, lv_bidi_dir_t base_dir, uint32_t max_len, uint32_t * len, uint16_t * pos_conv_len) { uint32_t i = 0; uint32_t letter; + uint16_t pos_conv_i = 0; + letter = lv_txt_encoded_next(txt, NULL); lv_bidi_dir_t dir = lv_bidi_get_letter_dir(letter); if(dir == LV_BIDI_DIR_NEUTRAL) dir = bracket_process(txt, 0, max_len, letter, base_dir); - /*Find the first strong char. Skip the neutrals*/ while(dir == LV_BIDI_DIR_NEUTRAL || dir == LV_BIDI_DIR_WEAK) { letter = lv_txt_encoded_next(txt, &i); + pos_conv_i++; dir = lv_bidi_get_letter_dir(letter); if(dir == LV_BIDI_DIR_NEUTRAL) dir = bracket_process(txt, i, max_len, letter, base_dir); if(i >= max_len || txt[i] == '\0' || txt[i] == '\n' || txt[i] == '\r') { *len = i; + *pos_conv_len = pos_conv_i; return base_dir; } } @@ -238,84 +279,119 @@ static lv_bidi_dir_t get_next_run(const char * txt, lv_bidi_dir_t base_dir, uint uint32_t i_prev = i; uint32_t i_last_strong = i; + uint16_t pos_conv_i_prev = pos_conv_i; + uint16_t pos_conv_i_last_strong = pos_conv_i; /*Find the next char which has different direction*/ lv_bidi_dir_t next_dir = base_dir; while(i_prev < max_len && txt[i] != '\0' && txt[i] != '\n' && txt[i] != '\r') { letter = lv_txt_encoded_next(txt, &i); + pos_conv_i++; next_dir = lv_bidi_get_letter_dir(letter); if(next_dir == LV_BIDI_DIR_NEUTRAL) next_dir = bracket_process(txt, i, max_len, letter, base_dir); /*New dir found?*/ if((next_dir == LV_BIDI_DIR_RTL || next_dir == LV_BIDI_DIR_LTR) && next_dir != run_dir) { /*Include neutrals if `run_dir == base_dir` */ - if(run_dir == base_dir) *len = i_prev; + if(run_dir == base_dir) { + *len = i_prev; + *pos_conv_len = pos_conv_i_prev; + } /*Exclude neutrals if `run_dir != base_dir` */ - else *len = i_last_strong; + else { + *len = i_last_strong; + *pos_conv_len = pos_conv_i_last_strong; + } return run_dir; } - if(next_dir != LV_BIDI_DIR_NEUTRAL) i_last_strong = i; + if(next_dir != LV_BIDI_DIR_NEUTRAL) { + i_last_strong = i; + pos_conv_i_last_strong = pos_conv_i; + } i_prev = i; + pos_conv_i_prev = pos_conv_i; } - /*Handle end of of string. Apply `base_dir` on trailing neutrals*/ /*Include neutrals if `run_dir == base_dir` */ - if(run_dir == base_dir) *len = i_prev; + if(run_dir == base_dir) { + *len = i_prev; + *pos_conv_len = pos_conv_i_prev; + } /*Exclude neutrals if `run_dir != base_dir` */ - else *len = i_last_strong; + else { + *len = i_last_strong; + *pos_conv_len = pos_conv_i_last_strong; + } return run_dir; - } -static void rtl_reverse(char * dest, const char * src, uint32_t len) +static void rtl_reverse(char * dest, const char * src, uint32_t len, uint16_t *pos_conv_out, uint16_t pos_conv_rd_base, uint16_t pos_conv_len) { uint32_t i = len; uint32_t wr = 0; + uint16_t pos_conv_i = pos_conv_len; + uint16_t pos_conv_wr = 0; while(i) { uint32_t letter = lv_txt_encoded_prev(src, &i); + uint16_t pos_conv_letter = --pos_conv_i; /*Keep weak letters (numbers) as LTR*/ if(lv_bidi_letter_is_weak(letter)) { uint32_t last_weak = i; uint32_t first_weak = i; + uint16_t pos_conv_last_weak = pos_conv_i; + uint16_t pos_conv_first_weak = pos_conv_i; while(i) { letter = lv_txt_encoded_prev(src, &i); + pos_conv_letter = --pos_conv_i; + /*No need to call `char_change_to_pair` because there not such chars here*/ /*Finish on non-weak char */ /*but treat number and currency related chars as weak*/ - if(lv_bidi_letter_is_weak(letter) == false && letter != '.' && letter != ',' && letter != '$' && letter != '%') { + if (lv_bidi_letter_is_weak(letter) == false && letter != '.' && letter != ',' && letter != '$' && letter != '%') { lv_txt_encoded_next(src, &i); /*Rewind one letter*/ + pos_conv_i++; first_weak = i; + pos_conv_first_weak = pos_conv_i; break; } } - if(i == 0) first_weak = 0; + if(i == 0) { + first_weak = 0; + pos_conv_first_weak = 0; + } - memcpy(&dest[wr], &src[first_weak], last_weak - first_weak + 1); + if (dest) memcpy(&dest[wr], &src[first_weak], last_weak - first_weak + 1); + if (pos_conv_out) fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_last_weak - pos_conv_first_weak + 1, pos_conv_rd_base + pos_conv_first_weak); wr += last_weak - first_weak + 1; - + pos_conv_wr += pos_conv_last_weak - pos_conv_first_weak + 1; } + /*Simply store in reversed order*/ else { uint32_t letter_size = lv_txt_encoded_size((const char *)&src[i]); /*Swap arithmetical symbols*/ if(letter_size == 1) { uint32_t new_letter = letter = char_change_to_pair(letter); - dest[wr] = (uint8_t)new_letter; + if (dest) dest[wr] = (uint8_t)new_letter; + if (pos_conv_out) pos_conv_out[pos_conv_wr] = pos_conv_rd_base + pos_conv_letter; wr += 1; + pos_conv_wr += 1; } /*Just store the letter*/ else { - memcpy(&dest[wr], &src[i], letter_size); + if (dest) memcpy(&dest[wr], &src[i], letter_size); + if (pos_conv_out) pos_conv_out[pos_conv_wr] = pos_conv_rd_base + pos_conv_i; wr += letter_size; + pos_conv_wr++; } } } diff --git a/src/lv_misc/lv_bidi.h b/src/lv_misc/lv_bidi.h index 9ce0fffa1..4d586e570 100644 --- a/src/lv_misc/lv_bidi.h +++ b/src/lv_misc/lv_bidi.h @@ -53,7 +53,7 @@ typedef uint8_t lv_bidi_dir_t; #if LV_USE_BIDI void lv_bidi_process(const char * str_in, char * str_out, lv_bidi_dir_t base_dir); -void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len, lv_bidi_dir_t base_dir); +void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len, lv_bidi_dir_t base_dir, uint16_t *pos_conv_out, uint16_t pos_conv_len); uint32_t lv_bidi_get_next_paragraph(const char * txt); lv_bidi_dir_t lv_bidi_detect_base_dir(const char * txt); lv_bidi_dir_t lv_bidi_get_letter_dir(uint32_t letter); From c7a7d1adca367fdccc86dd690e77a581229247ec Mon Sep 17 00:00:00 2001 From: Amir Gonnen Date: Mon, 4 Nov 2019 09:26:52 +0200 Subject: [PATCH 36/64] WIP: pos_conv add lv_bidi_get_logical/visual_pos functions --- src/lv_misc/lv_bidi.c | 36 ++++++++++++++++++++++++++++++++---- src/lv_misc/lv_bidi.h | 2 ++ 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/lv_misc/lv_bidi.c b/src/lv_misc/lv_bidi.c index 1d962c64a..fcb2f7b7c 100644 --- a/src/lv_misc/lv_bidi.c +++ b/src/lv_misc/lv_bidi.c @@ -6,9 +6,10 @@ /********************* * INCLUDES *********************/ -#include "lv_bidi.h" #include +#include "lv_bidi.h" #include "lv_txt.h" +#include "../lv_draw/lv_draw.h" #if LV_USE_BIDI @@ -34,6 +35,7 @@ static void rtl_reverse(char * dest, const char * src, uint32_t len, uint16_t *p static uint32_t char_change_to_pair(uint32_t letter); static lv_bidi_dir_t bracket_process(const char * txt, uint32_t next_pos, uint32_t len, uint32_t letter, lv_bidi_dir_t base_dir); static void fill_pos_conv(uint16_t * out, uint16_t len, uint16_t index); +static uint32_t get_txt_len(const char * txt, uint32_t max_len); /********************** * STATIC VARIABLES @@ -138,6 +140,19 @@ bool lv_bidi_letter_is_neutral(uint32_t letter) return false; } +uint16_t lv_bidi_get_logical_pos(const char * str_in, uint16_t len, lv_bidi_dir_t base_dir, uint32_t visual_pos) +{ + return 0; // TODO +} + +uint16_t lv_bidi_get_visual_pos(const char * str_in, uint16_t len, lv_bidi_dir_t base_dir, uint32_t logical_pos) +{ + uint32_t pos_conv_len = get_txt_len(str_in, len) * sizeof(uint16_t); + uint16_t *pos_conv_buf = lv_draw_get_buf(pos_conv_len); + lv_bidi_process_paragraph(str_in, NULL, len, base_dir, pos_conv_buf, pos_conv_len); + return pos_conv_buf[logical_pos]; +} + void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len, lv_bidi_dir_t base_dir, uint16_t *pos_conv_out, uint16_t pos_conv_len) { uint32_t run_len = 0; @@ -192,7 +207,7 @@ void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len } else { wr -= rd; pos_conv_wr -= pos_conv_rd; - rtl_reverse(str_out? &str_out[wr]: NULL, str_in, rd, pos_conv_out? &pos_conv_out[pos_conv_wr]: NULL, 0, pos_conv_rd); + rtl_reverse(str_out? &str_out[wr]: NULL, str_in, rd, pos_conv_out? &pos_conv_out[pos_conv_rd]: NULL, 0, pos_conv_rd); } } @@ -206,7 +221,7 @@ void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len if (str_out) memcpy(&str_out[wr], &str_in[rd], run_len); if (pos_conv_out) fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_run_len, pos_conv_rd); } - else rtl_reverse(str_out? &str_out[wr]: NULL, &str_in[rd], run_len, pos_conv_out? &pos_conv_out[pos_conv_wr] : NULL, pos_conv_rd, pos_conv_run_len); + else rtl_reverse(str_out? &str_out[wr]: NULL, &str_in[rd], run_len, pos_conv_out? &pos_conv_out[pos_conv_rd] : NULL, pos_conv_rd, pos_conv_run_len); wr += run_len; pos_conv_wr += pos_conv_run_len; } else { @@ -216,7 +231,7 @@ void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len if (str_out) memcpy(&str_out[wr], &str_in[rd], run_len); if (pos_conv_out) fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_run_len, pos_conv_rd); } - else rtl_reverse(str_out? &str_out[wr]: NULL, &str_in[rd], run_len, pos_conv_out? &pos_conv_out[pos_conv_wr] : NULL, pos_conv_rd, pos_conv_run_len); + else rtl_reverse(str_out? &str_out[wr]: NULL, &str_in[rd], run_len, pos_conv_out? &pos_conv_out[pos_conv_rd] : NULL, pos_conv_rd, pos_conv_run_len); } rd += run_len; @@ -241,6 +256,19 @@ uint32_t lv_bidi_get_next_paragraph(const char * txt) * STATIC FUNCTIONS **********************/ +static uint32_t get_txt_len(const char * txt, uint32_t max_len) +{ + uint32_t len = 0; + uint32_t i = 0; + + while(i < max_len && txt[i] != '\0') { + lv_txt_encoded_next(txt, &i); + len++; + } + + return len; +} + static void fill_pos_conv(uint16_t * out, uint16_t len, uint16_t index) { for (uint16_t i = 0; i < len; i++) diff --git a/src/lv_misc/lv_bidi.h b/src/lv_misc/lv_bidi.h index 4d586e570..d5129c4cc 100644 --- a/src/lv_misc/lv_bidi.h +++ b/src/lv_misc/lv_bidi.h @@ -60,6 +60,8 @@ lv_bidi_dir_t lv_bidi_get_letter_dir(uint32_t letter); bool lv_bidi_letter_is_weak(uint32_t letter); bool lv_bidi_letter_is_rtl(uint32_t letter); bool lv_bidi_letter_is_neutral(uint32_t letter); +uint16_t lv_bidi_get_logical_pos(const char * str_in, uint16_t len, lv_bidi_dir_t base_dir, uint32_t visual_pos); +uint16_t lv_bidi_get_visual_pos(const char * str_in, uint16_t len, lv_bidi_dir_t base_dir, uint32_t logical_pos); /********************** * MACROS From 769c1a8f8ac94b45ce5e57b81d12c443daa8549a Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 4 Nov 2019 20:35:47 +0100 Subject: [PATCH 37/64] define empty LV_DEBUG_ASSERT if LV_USE_DEBUG is 0 --- src/lv_core/lv_debug.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lv_core/lv_debug.h b/src/lv_core/lv_debug.h index f9b8082dd..f225f766a 100644 --- a/src/lv_core/lv_debug.h +++ b/src/lv_core/lv_debug.h @@ -136,6 +136,8 @@ void lv_debug_log_error(const char * msg, uint64_t value); #else /* LV_USE_DEBUG == 0 */ +#define LV_DEBUG_ASSERT(expr, msg, value) do{}while(0) + #define LV_ASSERT_NULL(p) true #define LV_ASSERT_MEM(p) true #define LV_ASSERT_STR(p) true From 6f57de051b35486ee219674d3a5ac8786257476f Mon Sep 17 00:00:00 2001 From: Amir Gonnen Date: Tue, 5 Nov 2019 01:03:40 +0200 Subject: [PATCH 38/64] WIP: pos_conv, bugfixes, use in lv_label --- src/lv_misc/lv_bidi.c | 35 +++++++++++++++++++---------- src/lv_misc/lv_bidi.h | 4 ++-- src/lv_objx/lv_label.c | 50 ++++++++++++++++++++++++++++++++---------- 3 files changed, 63 insertions(+), 26 deletions(-) diff --git a/src/lv_misc/lv_bidi.c b/src/lv_misc/lv_bidi.c index fcb2f7b7c..c52e3212a 100644 --- a/src/lv_misc/lv_bidi.c +++ b/src/lv_misc/lv_bidi.c @@ -140,17 +140,28 @@ bool lv_bidi_letter_is_neutral(uint32_t letter) return false; } -uint16_t lv_bidi_get_logical_pos(const char * str_in, uint16_t len, lv_bidi_dir_t base_dir, uint32_t visual_pos) +uint16_t lv_bidi_get_logical_pos(const char * str_in, char **bidi_txt, uint32_t len, lv_bidi_dir_t base_dir, uint32_t visual_pos) { - return 0; // TODO + uint32_t pos_conv_len = get_txt_len(str_in, len); + void *buf = lv_draw_get_buf(len + pos_conv_len * sizeof(uint16_t)); + if (bidi_txt) *bidi_txt = buf; + uint16_t *pos_conv_buf = (uint16_t*) ((char*)buf + len); + lv_bidi_process_paragraph(str_in, bidi_txt? *bidi_txt: NULL, len, base_dir, pos_conv_buf, pos_conv_len); + return pos_conv_buf[visual_pos]; } -uint16_t lv_bidi_get_visual_pos(const char * str_in, uint16_t len, lv_bidi_dir_t base_dir, uint32_t logical_pos) +uint16_t lv_bidi_get_visual_pos(const char * str_in, char **bidi_txt, uint16_t len, lv_bidi_dir_t base_dir, uint32_t logical_pos) { - uint32_t pos_conv_len = get_txt_len(str_in, len) * sizeof(uint16_t); - uint16_t *pos_conv_buf = lv_draw_get_buf(pos_conv_len); - lv_bidi_process_paragraph(str_in, NULL, len, base_dir, pos_conv_buf, pos_conv_len); - return pos_conv_buf[logical_pos]; + uint32_t pos_conv_len = get_txt_len(str_in, len); + void *buf = lv_draw_get_buf(len + pos_conv_len * sizeof(uint16_t)); + if (bidi_txt) *bidi_txt = buf; + uint16_t *pos_conv_buf = (uint16_t*) ((char*)buf + len); + lv_bidi_process_paragraph(str_in, bidi_txt? *bidi_txt: NULL, len, base_dir, pos_conv_buf, pos_conv_len); + for (uint16_t i = 0; i < pos_conv_len; i++){ + if (pos_conv_buf[i] == logical_pos) + return i; + } + return (uint16_t) -1; } void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len, lv_bidi_dir_t base_dir, uint16_t *pos_conv_out, uint16_t pos_conv_len) @@ -207,7 +218,7 @@ void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len } else { wr -= rd; pos_conv_wr -= pos_conv_rd; - rtl_reverse(str_out? &str_out[wr]: NULL, str_in, rd, pos_conv_out? &pos_conv_out[pos_conv_rd]: NULL, 0, pos_conv_rd); + rtl_reverse(str_out? &str_out[wr]: NULL, str_in, rd, pos_conv_out? &pos_conv_out[pos_conv_wr]: NULL, 0, pos_conv_rd); } } @@ -221,7 +232,7 @@ void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len if (str_out) memcpy(&str_out[wr], &str_in[rd], run_len); if (pos_conv_out) fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_run_len, pos_conv_rd); } - else rtl_reverse(str_out? &str_out[wr]: NULL, &str_in[rd], run_len, pos_conv_out? &pos_conv_out[pos_conv_rd] : NULL, pos_conv_rd, pos_conv_run_len); + else rtl_reverse(str_out? &str_out[wr]: NULL, &str_in[rd], run_len, pos_conv_out? &pos_conv_out[pos_conv_wr] : NULL, pos_conv_rd, pos_conv_run_len); wr += run_len; pos_conv_wr += pos_conv_run_len; } else { @@ -231,7 +242,7 @@ void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len if (str_out) memcpy(&str_out[wr], &str_in[rd], run_len); if (pos_conv_out) fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_run_len, pos_conv_rd); } - else rtl_reverse(str_out? &str_out[wr]: NULL, &str_in[rd], run_len, pos_conv_out? &pos_conv_out[pos_conv_rd] : NULL, pos_conv_rd, pos_conv_run_len); + else rtl_reverse(str_out? &str_out[wr]: NULL, &str_in[rd], run_len, pos_conv_out? &pos_conv_out[pos_conv_wr] : NULL, pos_conv_rd, pos_conv_run_len); } rd += run_len; @@ -411,8 +422,8 @@ static void rtl_reverse(char * dest, const char * src, uint32_t len, uint16_t *p uint32_t new_letter = letter = char_change_to_pair(letter); if (dest) dest[wr] = (uint8_t)new_letter; if (pos_conv_out) pos_conv_out[pos_conv_wr] = pos_conv_rd_base + pos_conv_letter; - wr += 1; - pos_conv_wr += 1; + wr++; + pos_conv_wr++; } /*Just store the letter*/ else { diff --git a/src/lv_misc/lv_bidi.h b/src/lv_misc/lv_bidi.h index d5129c4cc..09bb04efd 100644 --- a/src/lv_misc/lv_bidi.h +++ b/src/lv_misc/lv_bidi.h @@ -60,8 +60,8 @@ lv_bidi_dir_t lv_bidi_get_letter_dir(uint32_t letter); bool lv_bidi_letter_is_weak(uint32_t letter); bool lv_bidi_letter_is_rtl(uint32_t letter); bool lv_bidi_letter_is_neutral(uint32_t letter); -uint16_t lv_bidi_get_logical_pos(const char * str_in, uint16_t len, lv_bidi_dir_t base_dir, uint32_t visual_pos); -uint16_t lv_bidi_get_visual_pos(const char * str_in, uint16_t len, lv_bidi_dir_t base_dir, uint32_t logical_pos); +uint16_t lv_bidi_get_logical_pos(const char * str_in, char **bidi_txt, uint32_t len, lv_bidi_dir_t base_dir, uint32_t visual_pos); +uint16_t lv_bidi_get_visual_pos(const char * str_in, char **bidi_txt, uint16_t len, lv_bidi_dir_t base_dir, uint32_t logical_pos); /********************** * MACROS diff --git a/src/lv_objx/lv_label.c b/src/lv_objx/lv_label.c index 46cc451c4..bbf6a8469 100644 --- a/src/lv_objx/lv_label.c +++ b/src/lv_objx/lv_label.c @@ -593,6 +593,8 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_point_t uint8_t letter_height = lv_font_get_line_height(font); lv_coord_t y = 0; lv_txt_flag_t flag = LV_TXT_FLAG_NONE; + uint16_t visual_pos; + char *bidi_txt; if(ext->recolor != 0) flag |= LV_TXT_FLAG_RECOLOR; if(ext->expand != 0) flag |= LV_TXT_FLAG_EXPAND; @@ -626,19 +628,27 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_point_t } } +#if LV_USE_BIDI + /*Handle Bidi*/ + visual_pos = lv_bidi_get_visual_pos(&txt[line_start], &bidi_txt, new_line_start - line_start, lv_obj_get_base_dir(label), index - line_start); +#else + visual_pos = index - line_start; + bidi_txt = &txt[line_start]; +#endif + /*Calculate the x coordinate*/ - lv_coord_t x = lv_txt_get_width(&txt[line_start], index - line_start, font, style->text.letter_space, flag); + lv_coord_t x = lv_txt_get_width(bidi_txt, visual_pos, font, style->text.letter_space, flag); if(index != line_start) x += style->text.letter_space; if(align == LV_LABEL_ALIGN_CENTER) { lv_coord_t line_w; - line_w = lv_txt_get_width(&txt[line_start], new_line_start - line_start, font, style->text.letter_space, flag); + line_w = lv_txt_get_width(bidi_txt, new_line_start - line_start, font, style->text.letter_space, flag); x += lv_obj_get_width(label) / 2 - line_w / 2; } else if(align == LV_LABEL_ALIGN_RIGHT) { lv_coord_t line_w; - line_w = lv_txt_get_width(&txt[line_start], new_line_start - line_start, font, style->text.letter_space, flag); + line_w = lv_txt_get_width(bidi_txt, new_line_start - line_start, font, style->text.letter_space, flag); x += lv_obj_get_width(label) - line_w; } @@ -668,6 +678,8 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos) uint8_t letter_height = lv_font_get_line_height(font); lv_coord_t y = 0; lv_txt_flag_t flag = LV_TXT_FLAG_NONE; + uint16_t logical_pos; + char *bidi_txt; if(ext->recolor != 0) flag |= LV_TXT_FLAG_RECOLOR; if(ext->expand != 0) flag |= LV_TXT_FLAG_EXPAND; @@ -691,37 +703,44 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos) line_start = new_line_start; } +#if LV_USE_BIDI + bidi_txt = lv_draw_get_buf(new_line_start - line_start + 1); + lv_bidi_process_paragraph(txt + line_start, bidi_txt, new_line_start - line_start, lv_obj_get_base_dir(label), NULL, 0); +#else + bidi_txt = txt + line_start; +#endif + /*Calculate the x coordinate*/ lv_coord_t x = 0; if(align == LV_LABEL_ALIGN_CENTER) { lv_coord_t line_w; - line_w = lv_txt_get_width(&txt[line_start], new_line_start - line_start, font, style->text.letter_space, flag); + line_w = lv_txt_get_width(bidi_txt, new_line_start - line_start, font, style->text.letter_space, flag); x += lv_obj_get_width(label) / 2 - line_w / 2; } else if(align == LV_LABEL_ALIGN_RIGHT) { lv_coord_t line_w; - line_w = lv_txt_get_width(&txt[line_start], new_line_start - line_start, font, style->text.letter_space, flag); + line_w = lv_txt_get_width(bidi_txt, new_line_start - line_start, font, style->text.letter_space, flag); x += lv_obj_get_width(label) - line_w; } lv_txt_cmd_state_t cmd_state = LV_TXT_CMD_STATE_WAIT; - uint32_t i = line_start; + uint32_t i = 0; uint32_t i_act = i; uint32_t letter; uint32_t letter_next; if(new_line_start > 0) { - while(i < new_line_start) { + while(i + line_start < new_line_start) { /* Get the current letter.*/ - letter = lv_txt_encoded_next(txt, &i); + letter = lv_txt_encoded_next(bidi_txt, &i); /*Get the next letter too for kerning*/ - letter_next = lv_txt_encoded_next(&txt[i], NULL); + letter_next = lv_txt_encoded_next(&bidi_txt[i], NULL); /*Handle the recolor command*/ if((flag & LV_TXT_FLAG_RECOLOR) != 0) { - if(lv_txt_is_cmd(&cmd_state, txt[i]) != false) { + if(lv_txt_is_cmd(&cmd_state, bidi_txt[i]) != false) { continue; /*Skip the letter is it is part of a command*/ } } @@ -729,7 +748,7 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos) x += lv_font_get_glyph_width(font, letter, letter_next); /*Finish if the x position or the last char of the line is reached*/ - if(pos->x < x || i == new_line_start) { + if(pos->x < x || i + line_start == new_line_start) { i = i_act; break; } @@ -738,7 +757,14 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos) } } - return lv_encoded_get_char_id(txt, i); +#if LV_USE_BIDI + /*Handle Bidi*/ + logical_pos = lv_bidi_get_logical_pos(&txt[line_start], NULL, new_line_start - line_start, lv_obj_get_base_dir(label), lv_encoded_get_char_id(bidi_txt, i)); +#else + logical_pos = lv_encoded_get_char_id(bidi_txt, i); +#endif + + return logical_pos; } /** From 5d5a8b4894f54988bf0f904b389284c23417d4d3 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 5 Nov 2019 16:00:32 +0100 Subject: [PATCH 39/64] convert lv_bidi_get_visual_pos to byteindex --- src/lv_objx/lv_label.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lv_objx/lv_label.c b/src/lv_objx/lv_label.c index bbf6a8469..7427e69a7 100644 --- a/src/lv_objx/lv_label.c +++ b/src/lv_objx/lv_label.c @@ -631,11 +631,16 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_point_t #if LV_USE_BIDI /*Handle Bidi*/ visual_pos = lv_bidi_get_visual_pos(&txt[line_start], &bidi_txt, new_line_start - line_start, lv_obj_get_base_dir(label), index - line_start); + + printf("vp:%d, ", visual_pos); + visual_pos = lv_txt_encoded_get_byte_id(bidi_txt, visual_pos); + printf("vpb:%d, ", visual_pos); #else visual_pos = index - line_start; bidi_txt = &txt[line_start]; #endif + /*Calculate the x coordinate*/ lv_coord_t x = lv_txt_get_width(bidi_txt, visual_pos, font, style->text.letter_space, flag); From 74254975cddbd90911f44bb77d70eb64e9899728 Mon Sep 17 00:00:00 2001 From: Maximilian Schwab Date: Wed, 6 Nov 2019 01:40:22 +0100 Subject: [PATCH 40/64] Update comment for logging callback (#1255) Changed lv_log_register_print to lv_log_register_print_cb --- lv_conf_template.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lv_conf_template.h b/lv_conf_template.h index 08e9beb9e..707e4a238 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -225,7 +225,7 @@ typedef void * lv_indev_drv_user_data_t; /*Type of user data in the i # define LV_LOG_LEVEL LV_LOG_LEVEL_WARN /* 1: Print the log with 'printf'; - * 0: user need to register a callback with `lv_log_register_print`*/ + * 0: user need to register a callback with `lv_log_register_print_cb`*/ # define LV_LOG_PRINTF 0 #endif /*LV_USE_LOG*/ From 5441cf9998aadb7393d09e451130c6f6b26d6bae Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 6 Nov 2019 05:19:06 +0100 Subject: [PATCH 41/64] bidi fixes + add missing prefix to lv_encoded_get_char_id --- src/lv_draw/lv_draw_label.c | 2 +- src/lv_misc/lv_txt.c | 4 ++-- src/lv_misc/lv_txt.h | 2 +- src/lv_objx/lv_label.c | 29 +++++++++++++---------------- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/lv_draw/lv_draw_label.c b/src/lv_draw/lv_draw_label.c index 5bd0592c5..d7650690c 100644 --- a/src/lv_draw/lv_draw_label.c +++ b/src/lv_draw/lv_draw_label.c @@ -220,7 +220,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st letter_w = lv_font_get_glyph_width(font, letter, letter_next); if(sel_start != 0xFFFF && sel_end != 0xFFFF) { - int char_ind = lv_encoded_get_char_id(bidi_txt, i); + int char_ind = lv_txt_encoded_get_char_id(bidi_txt, i); /*Do not draw the rectangle on the character at `sel_start`.*/ if(char_ind > sel_start && char_ind <= sel_end) { lv_area_t sel_coords; diff --git a/src/lv_misc/lv_txt.c b/src/lv_misc/lv_txt.c index d18e456b0..0c4027761 100644 --- a/src/lv_misc/lv_txt.c +++ b/src/lv_misc/lv_txt.c @@ -56,7 +56,7 @@ uint32_t (*lv_txt_encoded_conv_wc)(uint32_t) = lv_txt_utf8_con uint32_t (*lv_txt_encoded_next)(const char *, uint32_t *) = lv_txt_utf8_next; uint32_t (*lv_txt_encoded_prev)(const char *, uint32_t *) = lv_txt_utf8_prev; uint32_t (*lv_txt_encoded_get_byte_id)(const char *, uint32_t) = lv_txt_utf8_get_byte_id; -uint32_t (*lv_encoded_get_char_id)(const char *, uint32_t) = lv_txt_utf8_get_char_id; +uint32_t (*lv_txt_encoded_get_char_id)(const char *, uint32_t) = lv_txt_utf8_get_char_id; uint32_t (*lv_txt_get_encoded_length)(const char *) = lv_txt_utf8_get_length; #elif LV_TXT_ENC == LV_TXT_ENC_ASCII uint8_t (*lv_txt_encoded_size)(const char *) = lv_txt_iso8859_1_size; @@ -65,7 +65,7 @@ uint32_t (*lv_txt_encoded_conv_wc)(uint32_t) = lv_txt_iso8859_ uint32_t (*lv_txt_encoded_next)(const char *, uint32_t *) = lv_txt_iso8859_1_next; uint32_t (*lv_txt_encoded_prev)(const char *, uint32_t *) = lv_txt_iso8859_1_prev; uint32_t (*lv_txt_encoded_get_byte_id)(const char *, uint32_t) = lv_txt_iso8859_1_get_byte_id; -uint32_t (*lv_encoded_get_char_id)(const char *, uint32_t) = lv_txt_iso8859_1_get_char_id; +uint32_t (*lv_txt_encoded_get_char_id)(const char *, uint32_t) = lv_txt_iso8859_1_get_char_id; uint32_t (*lv_txt_get_encoded_length)(const char *) = lv_txt_iso8859_1_get_length; #endif diff --git a/src/lv_misc/lv_txt.h b/src/lv_misc/lv_txt.h index 6fc6e4a63..865e2c97c 100644 --- a/src/lv_misc/lv_txt.h +++ b/src/lv_misc/lv_txt.h @@ -188,7 +188,7 @@ extern uint32_t (*lv_txt_encoded_get_byte_id)(const char *, uint32_t); * @param byte_id byte index * @return character index of the letter at 'byte_id'th position */ -extern uint32_t (*lv_encoded_get_char_id)(const char *, uint32_t); +extern uint32_t (*lv_txt_encoded_get_char_id)(const char *, uint32_t); /** * Get the number of characters (and NOT bytes) in a string. diff --git a/src/lv_objx/lv_label.c b/src/lv_objx/lv_label.c index 7427e69a7..3bdfd04a8 100644 --- a/src/lv_objx/lv_label.c +++ b/src/lv_objx/lv_label.c @@ -578,7 +578,7 @@ uint16_t lv_label_get_anim_speed(const lv_obj_t * label) * index (different in UTF-8) * @param pos store the result here (E.g. index = 0 gives 0;0 coordinates) */ -void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_point_t * pos) +void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t char_id, lv_point_t * pos) { LV_ASSERT_OBJ(label, LV_OBJX_NAME); LV_ASSERT_NULL(pos); @@ -593,8 +593,6 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_point_t uint8_t letter_height = lv_font_get_line_height(font); lv_coord_t y = 0; lv_txt_flag_t flag = LV_TXT_FLAG_NONE; - uint16_t visual_pos; - char *bidi_txt; if(ext->recolor != 0) flag |= LV_TXT_FLAG_RECOLOR; if(ext->expand != 0) flag |= LV_TXT_FLAG_EXPAND; @@ -608,12 +606,12 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_point_t max_w = LV_COORD_MAX; } - index = lv_txt_encoded_get_byte_id(txt, index); + uint16_t byte_id = lv_txt_encoded_get_byte_id(txt, char_id); /*Search the line of the index letter */; while(txt[new_line_start] != '\0') { new_line_start += lv_txt_get_next_line(&txt[line_start], font, style->text.letter_space, max_w, flag); - if(index < new_line_start || txt[new_line_start] == '\0') + if(byte_id < new_line_start || txt[new_line_start] == '\0') break; /*The line of 'index' letter begins at 'line_start'*/ y += letter_height + style->text.line_space; @@ -621,30 +619,29 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_point_t } /*If the last character is line break then go to the next line*/ - if(index > 0) { - if((txt[index - 1] == '\n' || txt[index - 1] == '\r') && txt[index] == '\0') { + if(byte_id > 0) { + if((txt[byte_id - 1] == '\n' || txt[byte_id - 1] == '\r') && txt[byte_id] == '\0') { y += letter_height + style->text.line_space; - line_start = index; + line_start = byte_id; } } + char *bidi_txt; #if LV_USE_BIDI /*Handle Bidi*/ - visual_pos = lv_bidi_get_visual_pos(&txt[line_start], &bidi_txt, new_line_start - line_start, lv_obj_get_base_dir(label), index - line_start); + uint16_t line_char_id = lv_txt_encoded_get_char_id(&txt[line_start], byte_id - line_start); - printf("vp:%d, ", visual_pos); - visual_pos = lv_txt_encoded_get_byte_id(bidi_txt, visual_pos); - printf("vpb:%d, ", visual_pos); + uint16_t visual_char_pos = lv_bidi_get_visual_pos(&txt[line_start], &bidi_txt, new_line_start - line_start, lv_obj_get_base_dir(label), line_char_id); + uint16_t visual_byte_pos = lv_txt_encoded_get_byte_id(bidi_txt, visual_char_pos); #else - visual_pos = index - line_start; bidi_txt = &txt[line_start]; #endif /*Calculate the x coordinate*/ - lv_coord_t x = lv_txt_get_width(bidi_txt, visual_pos, font, style->text.letter_space, flag); + lv_coord_t x = lv_txt_get_width(bidi_txt, visual_byte_pos, font, style->text.letter_space, flag); - if(index != line_start) x += style->text.letter_space; + if(char_id != line_start) x += style->text.letter_space; if(align == LV_LABEL_ALIGN_CENTER) { lv_coord_t line_w; @@ -764,7 +761,7 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos) #if LV_USE_BIDI /*Handle Bidi*/ - logical_pos = lv_bidi_get_logical_pos(&txt[line_start], NULL, new_line_start - line_start, lv_obj_get_base_dir(label), lv_encoded_get_char_id(bidi_txt, i)); + logical_pos = lv_bidi_get_logical_pos(&txt[line_start], NULL, new_line_start - line_start, lv_obj_get_base_dir(label), lv_txt_encoded_get_char_id(bidi_txt, i)); #else logical_pos = lv_encoded_get_char_id(bidi_txt, i); #endif From 86f44c974d24d950ed83666a30c8c3f73e6ae796 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 6 Nov 2019 05:32:42 +0100 Subject: [PATCH 42/64] cpicker: set default type --- src/lv_objx/lv_cpicker.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lv_objx/lv_cpicker.c b/src/lv_objx/lv_cpicker.c index d2bc62523..ae3d68cd3 100644 --- a/src/lv_objx/lv_cpicker.c +++ b/src/lv_objx/lv_cpicker.c @@ -106,6 +106,7 @@ lv_obj_t * lv_cpicker_create(lv_obj_t * par, const lv_obj_t * copy) if(ext == NULL) return NULL; /*Initialize the allocated 'ext' */ + ext->type = LV_CPICKER_DEF_TYPE; ext->hsv = LV_CPICKER_DEF_HSV; ext->indic.style = &lv_style_plain; ext->indic.colored = 0; @@ -121,6 +122,7 @@ lv_obj_t * lv_cpicker_create(lv_obj_t * par, const lv_obj_t * copy) /*If no copy do the basic initialization*/ if(copy == NULL) { + lv_obj_set_size(new_cpicker, LV_DPI * 2, LV_DPI * 2); lv_obj_set_protect(new_cpicker, LV_PROTECT_PRESS_LOST); lv_theme_t * th = lv_theme_get_current(); if(th) { From 45c6dbab6290b96165e431cc9ac6e4bea853c4b3 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Wed, 6 Nov 2019 08:11:58 -0500 Subject: [PATCH 43/64] lv_cpicker: credit @AloyseTech and @paulpv --- src/lv_objx/lv_cpicker.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lv_objx/lv_cpicker.c b/src/lv_objx/lv_cpicker.c index ae3d68cd3..cf1f1a129 100644 --- a/src/lv_objx/lv_cpicker.c +++ b/src/lv_objx/lv_cpicker.c @@ -1,6 +1,7 @@ /** * @file lv_cpicker.c * + * From @AloyseTech and @paulpv. */ /********************* From a3a326c2ffaffeefd1d5ad6faa33031b497a0fb8 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 8 Nov 2019 13:49:52 +0100 Subject: [PATCH 44/64] fix lv_label_get_letter_on in case of multi-line texts --- src/lv_objx/lv_label.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_objx/lv_label.c b/src/lv_objx/lv_label.c index 3bdfd04a8..ab81f4a24 100644 --- a/src/lv_objx/lv_label.c +++ b/src/lv_objx/lv_label.c @@ -766,7 +766,7 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos) logical_pos = lv_encoded_get_char_id(bidi_txt, i); #endif - return logical_pos; + return logical_pos + line_start; } /** From 0130f3e5f2606388d466d5476fdd1c4c80810b8c Mon Sep 17 00:00:00 2001 From: Amir Gonnen Date: Sat, 9 Nov 2019 01:02:51 +0200 Subject: [PATCH 45/64] Add RTL indication to pos_conv When getting visual/logical pos, also get whether this pos is RTL (was reversed) --- src/lv_misc/lv_bidi.c | 22 +++++++++++++++------- src/lv_misc/lv_bidi.h | 4 ++-- src/lv_objx/lv_label.c | 8 ++++++-- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/lv_misc/lv_bidi.c b/src/lv_misc/lv_bidi.c index c52e3212a..0f1153b52 100644 --- a/src/lv_misc/lv_bidi.c +++ b/src/lv_misc/lv_bidi.c @@ -18,6 +18,11 @@ *********************/ #define LV_BIDI_BRACKLET_DEPTH 4 +// Highest bit of the 16-bit pos_conv value specifies whether this pos is RTL or not +#define GET_POS(x) ((x) & 0x7FFF) +#define IS_RTL_POS(x) (((x) & 0x8000) != 0) +#define SET_RTL_POS(x, is_rtl) (GET_POS(x) | ((is_rtl)? 0x8000: 0)) + /********************** * TYPEDEFS **********************/ @@ -140,17 +145,18 @@ bool lv_bidi_letter_is_neutral(uint32_t letter) return false; } -uint16_t lv_bidi_get_logical_pos(const char * str_in, char **bidi_txt, uint32_t len, lv_bidi_dir_t base_dir, uint32_t visual_pos) +uint16_t lv_bidi_get_logical_pos(const char * str_in, char **bidi_txt, uint32_t len, lv_bidi_dir_t base_dir, uint32_t visual_pos, bool *is_rtl) { uint32_t pos_conv_len = get_txt_len(str_in, len); void *buf = lv_draw_get_buf(len + pos_conv_len * sizeof(uint16_t)); if (bidi_txt) *bidi_txt = buf; uint16_t *pos_conv_buf = (uint16_t*) ((char*)buf + len); lv_bidi_process_paragraph(str_in, bidi_txt? *bidi_txt: NULL, len, base_dir, pos_conv_buf, pos_conv_len); - return pos_conv_buf[visual_pos]; + if (is_rtl) *is_rtl = IS_RTL_POS(pos_conv_buf[visual_pos]); + return GET_POS(pos_conv_buf[visual_pos]); } -uint16_t lv_bidi_get_visual_pos(const char * str_in, char **bidi_txt, uint16_t len, lv_bidi_dir_t base_dir, uint32_t logical_pos) +uint16_t lv_bidi_get_visual_pos(const char * str_in, char **bidi_txt, uint16_t len, lv_bidi_dir_t base_dir, uint32_t logical_pos, bool *is_rtl) { uint32_t pos_conv_len = get_txt_len(str_in, len); void *buf = lv_draw_get_buf(len + pos_conv_len * sizeof(uint16_t)); @@ -158,8 +164,10 @@ uint16_t lv_bidi_get_visual_pos(const char * str_in, char **bidi_txt, uint16_t l uint16_t *pos_conv_buf = (uint16_t*) ((char*)buf + len); lv_bidi_process_paragraph(str_in, bidi_txt? *bidi_txt: NULL, len, base_dir, pos_conv_buf, pos_conv_len); for (uint16_t i = 0; i < pos_conv_len; i++){ - if (pos_conv_buf[i] == logical_pos) + if (GET_POS(pos_conv_buf[i]) == logical_pos){ + if (is_rtl) *is_rtl = IS_RTL_POS(pos_conv_buf[i]); return i; + } } return (uint16_t) -1; } @@ -284,7 +292,7 @@ static void fill_pos_conv(uint16_t * out, uint16_t len, uint16_t index) { for (uint16_t i = 0; i < len; i++) { - out[i] = index; + out[i] = SET_RTL_POS(index, false); index++; } } @@ -421,14 +429,14 @@ static void rtl_reverse(char * dest, const char * src, uint32_t len, uint16_t *p if(letter_size == 1) { uint32_t new_letter = letter = char_change_to_pair(letter); if (dest) dest[wr] = (uint8_t)new_letter; - if (pos_conv_out) pos_conv_out[pos_conv_wr] = pos_conv_rd_base + pos_conv_letter; + if (pos_conv_out) pos_conv_out[pos_conv_wr] = SET_RTL_POS(pos_conv_rd_base + pos_conv_letter, true); wr++; pos_conv_wr++; } /*Just store the letter*/ else { if (dest) memcpy(&dest[wr], &src[i], letter_size); - if (pos_conv_out) pos_conv_out[pos_conv_wr] = pos_conv_rd_base + pos_conv_i; + if (pos_conv_out) pos_conv_out[pos_conv_wr] = SET_RTL_POS(pos_conv_rd_base + pos_conv_i, true); wr += letter_size; pos_conv_wr++; } diff --git a/src/lv_misc/lv_bidi.h b/src/lv_misc/lv_bidi.h index 09bb04efd..215727aa7 100644 --- a/src/lv_misc/lv_bidi.h +++ b/src/lv_misc/lv_bidi.h @@ -60,8 +60,8 @@ lv_bidi_dir_t lv_bidi_get_letter_dir(uint32_t letter); bool lv_bidi_letter_is_weak(uint32_t letter); bool lv_bidi_letter_is_rtl(uint32_t letter); bool lv_bidi_letter_is_neutral(uint32_t letter); -uint16_t lv_bidi_get_logical_pos(const char * str_in, char **bidi_txt, uint32_t len, lv_bidi_dir_t base_dir, uint32_t visual_pos); -uint16_t lv_bidi_get_visual_pos(const char * str_in, char **bidi_txt, uint16_t len, lv_bidi_dir_t base_dir, uint32_t logical_pos); +uint16_t lv_bidi_get_logical_pos(const char * str_in, char **bidi_txt, uint32_t len, lv_bidi_dir_t base_dir, uint32_t visual_pos, bool *is_rtl); +uint16_t lv_bidi_get_visual_pos(const char * str_in, char **bidi_txt, uint16_t len, lv_bidi_dir_t base_dir, uint32_t logical_pos, bool *is_rtl); /********************** * MACROS diff --git a/src/lv_objx/lv_label.c b/src/lv_objx/lv_label.c index ab81f4a24..de3874fe4 100644 --- a/src/lv_objx/lv_label.c +++ b/src/lv_objx/lv_label.c @@ -631,7 +631,9 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t char_id, lv_point_ /*Handle Bidi*/ uint16_t line_char_id = lv_txt_encoded_get_char_id(&txt[line_start], byte_id - line_start); - uint16_t visual_char_pos = lv_bidi_get_visual_pos(&txt[line_start], &bidi_txt, new_line_start - line_start, lv_obj_get_base_dir(label), line_char_id); + bool is_rtl; + uint16_t visual_char_pos = lv_bidi_get_visual_pos(&txt[line_start], &bidi_txt, new_line_start - line_start, lv_obj_get_base_dir(label), line_char_id, &is_rtl); + if (is_rtl) visual_char_pos++; uint16_t visual_byte_pos = lv_txt_encoded_get_byte_id(bidi_txt, visual_char_pos); #else bidi_txt = &txt[line_start]; @@ -761,7 +763,9 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos) #if LV_USE_BIDI /*Handle Bidi*/ - logical_pos = lv_bidi_get_logical_pos(&txt[line_start], NULL, new_line_start - line_start, lv_obj_get_base_dir(label), lv_txt_encoded_get_char_id(bidi_txt, i)); + bool is_rtl; + logical_pos = lv_bidi_get_logical_pos(&txt[line_start], NULL, new_line_start - line_start, lv_obj_get_base_dir(label), lv_txt_encoded_get_char_id(bidi_txt, i), &is_rtl); + if (is_rtl) logical_pos++; #else logical_pos = lv_encoded_get_char_id(bidi_txt, i); #endif From 96b9114a5afbe06b5d37b8c83d3cbd9135248241 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sat, 9 Nov 2019 01:53:02 +0100 Subject: [PATCH 46/64] bidi fixes for multi line text handling --- src/lv_draw/lv_draw_label.c | 5 +++-- src/lv_objx/lv_label.c | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lv_draw/lv_draw_label.c b/src/lv_draw/lv_draw_label.c index d7650690c..2a5b22903 100644 --- a/src/lv_draw/lv_draw_label.c +++ b/src/lv_draw/lv_draw_label.c @@ -166,13 +166,14 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st i = 0; uint32_t letter; uint32_t letter_next; - while(i < line_end - line_start) { #if LV_USE_BIDI char *bidi_txt = lv_draw_get_buf(line_end - line_start + 1); lv_bidi_process_paragraph(txt + line_start, bidi_txt, line_end - line_start, bidi_dir, NULL, 0); #else const char *bidi_txt = txt + line_start; #endif + while(i < line_end - line_start) { + letter = lv_txt_encoded_next(bidi_txt, &i); letter_next = lv_txt_encoded_next(&bidi_txt[i], NULL); @@ -220,7 +221,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st letter_w = lv_font_get_glyph_width(font, letter, letter_next); if(sel_start != 0xFFFF && sel_end != 0xFFFF) { - int char_ind = lv_txt_encoded_get_char_id(bidi_txt, i); + int char_ind = lv_txt_encoded_get_char_id(bidi_txt, i + line_start); /*Do not draw the rectangle on the character at `sel_start`.*/ if(char_ind > sel_start && char_ind <= sel_end) { lv_area_t sel_coords; diff --git a/src/lv_objx/lv_label.c b/src/lv_objx/lv_label.c index de3874fe4..cd02a0ed0 100644 --- a/src/lv_objx/lv_label.c +++ b/src/lv_objx/lv_label.c @@ -767,10 +767,10 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos) logical_pos = lv_bidi_get_logical_pos(&txt[line_start], NULL, new_line_start - line_start, lv_obj_get_base_dir(label), lv_txt_encoded_get_char_id(bidi_txt, i), &is_rtl); if (is_rtl) logical_pos++; #else - logical_pos = lv_encoded_get_char_id(bidi_txt, i); + logical_pos = lv_txt_encoded_get_char_id(bidi_txt, i); #endif - return logical_pos + line_start; + return logical_pos + lv_txt_encoded_get_char_id(txt, line_start) ; } /** From 6f762bb7c776894ca49f8143cf28dade4099d988 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 10 Nov 2019 10:45:49 +0100 Subject: [PATCH 47/64] fix lv_cpicker_set_color with 16 bit color depth and byte swap Fixes #1257 --- src/lv_objx/lv_cpicker.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lv_objx/lv_cpicker.c b/src/lv_objx/lv_cpicker.c index cf1f1a129..73197d374 100644 --- a/src/lv_objx/lv_cpicker.c +++ b/src/lv_objx/lv_cpicker.c @@ -275,7 +275,12 @@ bool lv_cpicker_set_hsv(lv_obj_t * cpicker, lv_color_hsv_t hsv) */ bool lv_cpicker_set_color(lv_obj_t * cpicker, lv_color_t color) { +#if LV_COLOR_DEPTH == 16 && LV_COLOR_16_SWAP != 0 + uint8_t green = (color.ch.green_h << 3) + color.ch.green_l; + return lv_cpicker_set_hsv(cpicker, lv_color_rgb_to_hsv(color.ch.red, green, color.ch.blue)); +#else return lv_cpicker_set_hsv(cpicker, lv_color_rgb_to_hsv(color.ch.red, color.ch.green, color.ch.blue)); +#endif } /** From 8dfcba6aa864f3aeb66139c815c8b7e44b3e7db0 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 10 Nov 2019 10:52:49 +0100 Subject: [PATCH 48/64] text sel fixes with bidi --- src/lv_draw/lv_draw_label.c | 21 +++++++++++++++++++-- src/lv_objx/lv_label.c | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/lv_draw/lv_draw_label.c b/src/lv_draw/lv_draw_label.c index 2a5b22903..ae6470ab8 100644 --- a/src/lv_draw/lv_draw_label.c +++ b/src/lv_draw/lv_draw_label.c @@ -113,6 +113,24 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st pos.y += hint->y; } + if(sel_start != 0xFFFF) { + sel_start = lv_bidi_get_visual_pos(txt, NULL, strlen(txt), bidi_dir, sel_start, NULL); + sel_start = lv_txt_encoded_get_byte_id(txt, sel_start); + } + + if(sel_end != 0xFFFF) { + sel_end = lv_bidi_get_visual_pos(txt, NULL, strlen(txt), bidi_dir, sel_end, NULL); + sel_end = lv_txt_encoded_get_byte_id(txt, sel_end); + } + + if(sel_start > sel_end) { + uint16_t tmp = sel_start; + sel_start = sel_end; + sel_end = tmp; + } + + + uint32_t line_end = line_start + lv_txt_get_next_line(&txt[line_start], font, style->text.letter_space, w, flag); /*Go the first visible line*/ @@ -221,9 +239,8 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st letter_w = lv_font_get_glyph_width(font, letter, letter_next); if(sel_start != 0xFFFF && sel_end != 0xFFFF) { - int char_ind = lv_txt_encoded_get_char_id(bidi_txt, i + line_start); /*Do not draw the rectangle on the character at `sel_start`.*/ - if(char_ind > sel_start && char_ind <= sel_end) { + if(i + line_start > sel_start && i + line_start <= sel_end) { lv_area_t sel_coords; sel_coords.x1 = pos.x; sel_coords.y1 = pos.y; diff --git a/src/lv_objx/lv_label.c b/src/lv_objx/lv_label.c index cd02a0ed0..004da981b 100644 --- a/src/lv_objx/lv_label.c +++ b/src/lv_objx/lv_label.c @@ -770,7 +770,7 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos) logical_pos = lv_txt_encoded_get_char_id(bidi_txt, i); #endif - return logical_pos + lv_txt_encoded_get_char_id(txt, line_start) ; + return logical_pos + lv_txt_encoded_get_char_id(txt, line_start); } /** From 6eaf8dd6d3eefc87455ad856999295bbe92b812d Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 10 Nov 2019 11:03:19 +0100 Subject: [PATCH 49/64] text sel fix, if start > end --- src/lv_objx/lv_label.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lv_objx/lv_label.c b/src/lv_objx/lv_label.c index 004da981b..40d2cead5 100644 --- a/src/lv_objx/lv_label.c +++ b/src/lv_objx/lv_label.c @@ -831,10 +831,11 @@ bool lv_label_is_char_under_pos(const lv_obj_t * label, lv_point_t * pos) uint8_t letter_height = lv_font_get_line_height(font); lv_coord_t y = 0; lv_txt_flag_t flag = LV_TXT_FLAG_NONE; + lv_label_align_t align = lv_label_get_align(label); if(ext->recolor != 0) flag |= LV_TXT_FLAG_RECOLOR; if(ext->expand != 0) flag |= LV_TXT_FLAG_EXPAND; - if(ext->align == LV_LABEL_ALIGN_CENTER) flag |= LV_TXT_FLAG_CENTER; + if(align == LV_LABEL_ALIGN_CENTER) flag |= LV_TXT_FLAG_CENTER; /*If the width will be expanded set the max length to very big */ if(ext->long_mode == LV_LABEL_LONG_EXPAND) { @@ -854,11 +855,16 @@ bool lv_label_is_char_under_pos(const lv_obj_t * label, lv_point_t * pos) /*Calculate the x coordinate*/ lv_coord_t x = 0; lv_coord_t last_x = 0; - if(ext->align == LV_LABEL_ALIGN_CENTER) { + if(align == LV_LABEL_ALIGN_CENTER) { lv_coord_t line_w; line_w = lv_txt_get_width(&txt[line_start], new_line_start - line_start, font, style->text.letter_space, flag); x += lv_obj_get_width(label) / 2 - line_w / 2; } + else if(align == LV_LABEL_ALIGN_RIGHT) { + lv_coord_t line_w; + line_w = lv_txt_get_width(&txt[line_start], new_line_start - line_start, font, style->text.letter_space, flag); + x += lv_obj_get_width(label) - line_w; + } lv_txt_cmd_state_t cmd_state = LV_TXT_CMD_STATE_WAIT; From 57e2a6d983e101e3e022912afae76fd984caac71 Mon Sep 17 00:00:00 2001 From: Brian Pugh Date: Sun, 10 Nov 2019 21:44:27 -0800 Subject: [PATCH 50/64] fix 1bit lv_color compilation warnings/errors introduced by 3da868a0905ccbdafb4bbbf9c301d4f66eb2cf86 --- src/lv_misc/lv_color.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lv_misc/lv_color.h b/src/lv_misc/lv_color.h index 04551fe7f..95542afb6 100644 --- a/src/lv_misc/lv_color.h +++ b/src/lv_misc/lv_color.h @@ -392,10 +392,10 @@ static inline uint8_t lv_color_brightness(lv_color_t color) /* 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){(b8 >> 7 | g8 >> 7 | r8 >> 7)}) +#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){.full = (b8 >> 7 | g8 >> 7 | r8 >> 7)}) static inline lv_color_t lv_color_make(int r8, int g8, int b8) { - lv_color_t color; + lv_color_t color = { 0 }; color.full = (b8 >> 7 | g8 >> 7 | r8 >> 7); return color; } From 183d849e8429afd66ad284919ffc019c78344a71 Mon Sep 17 00:00:00 2001 From: Brian Pugh Date: Sun, 10 Nov 2019 23:16:54 -0800 Subject: [PATCH 51/64] Fix cursor wrapping described in https://github.com/littlevgl/lvgl/issues/1256 --- src/lv_misc/lv_txt.c | 20 ++++++++--------- src/lv_objx/lv_label.c | 50 +++++++++++++++++++++++------------------- 2 files changed, 37 insertions(+), 33 deletions(-) diff --git a/src/lv_misc/lv_txt.c b/src/lv_misc/lv_txt.c index f89671518..b7570b1cb 100644 --- a/src/lv_misc/lv_txt.c +++ b/src/lv_misc/lv_txt.c @@ -266,6 +266,9 @@ static uint16_t lv_txt_get_next_word(const char * txt, const lv_font_t * font, /** * Get the next line of text. Check line length and break chars too. + * + * A line of txt includes the \n character. + * * @param txt a '\0' terminated string * @param font pointer to a font * @param letter_space letter space @@ -295,18 +298,13 @@ uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font, i += advance; - if(txt[i] == '\n') break; - } + if(txt[0] == '\n') break; + + if(txt[i] == '\n'){ + i++; /* Include the following newline in the current line */ + break; + } - /* If this is the last of the string, make sure pointer is at NULL-terminator. - * This catches the case, for example of a string ending in "\n" */ - if(txt[i] != '\0'){ - uint32_t i_next = i; - int tmp; - uint32_t letter_next = lv_txt_encoded_next(txt, &i_next); /*Gets current character*/ - tmp = i_next; - letter_next = lv_txt_encoded_next(txt, &i_next); /*Gets subsequent character*/ - if(letter_next == '\0') i = tmp; } /*Always step at least one to avoid infinite loops*/ diff --git a/src/lv_objx/lv_label.c b/src/lv_objx/lv_label.c index b52f06052..c9f3b81a1 100644 --- a/src/lv_objx/lv_label.c +++ b/src/lv_objx/lv_label.c @@ -661,7 +661,15 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos) while(txt[line_start] != '\0') { new_line_start += lv_txt_get_next_line(&txt[line_start], font, style->text.letter_space, max_w, flag); - if(pos->y <= y + letter_height) break; /*The line is found (stored in 'line_start')*/ + if(pos->y <= y + letter_height) { + /*The line is found (stored in 'line_start')*/ + /* Include the NULL terminator in the last line */ + uint32_t tmp = new_line_start; + uint32_t letter; + letter = lv_txt_encoded_prev(txt, &tmp); + if(letter != '\n' && txt[new_line_start] == '\0' ) new_line_start++; + break; + } y += letter_height + style->text.line_space; line_start = new_line_start; @@ -682,31 +690,29 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos) uint32_t letter; uint32_t letter_next; - if(new_line_start > 0) { - while(i < new_line_start) { - /* Get the current letter.*/ - letter = lv_txt_encoded_next(txt, &i); + while(i < new_line_start) { + /* Get the current letter.*/ + letter = lv_txt_encoded_next(txt, &i); - /*Get the next letter too for kerning*/ - letter_next = lv_txt_encoded_next(&txt[i], NULL); + /*Get the next letter too for kerning*/ + letter_next = lv_txt_encoded_next(&txt[i], NULL); - /*Handle the recolor command*/ - if((flag & LV_TXT_FLAG_RECOLOR) != 0) { - if(lv_txt_is_cmd(&cmd_state, txt[i]) != false) { - continue; /*Skip the letter is it is part of a command*/ - } + /*Handle the recolor command*/ + if((flag & LV_TXT_FLAG_RECOLOR) != 0) { + if(lv_txt_is_cmd(&cmd_state, txt[i]) != false) { + continue; /*Skip the letter is it is part of a command*/ } - - x += lv_font_get_glyph_width(font, letter, letter_next); - - /*Finish if the x position or the last char of the line is reached*/ - if(pos->x < x || i == new_line_start) { - i = i_act; - break; - } - x += style->text.letter_space; - i_act = i; } + + x += lv_font_get_glyph_width(font, letter, letter_next); + + /*Finish if the x position or the last char of the line is reached*/ + if(pos->x < x || i == new_line_start) { + i = i_act; + break; + } + x += style->text.letter_space; + i_act = i; } return lv_encoded_get_char_id(txt, i); From c4f8d8cd5bbe267cada86d3817d59ec3fd097875 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 11 Nov 2019 11:10:01 +0100 Subject: [PATCH 52/64] bidi: txt_sel fixes --- src/lv_draw/lv_draw_label.c | 63 ++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/src/lv_draw/lv_draw_label.c b/src/lv_draw/lv_draw_label.c index ae6470ab8..4990d3e13 100644 --- a/src/lv_draw/lv_draw_label.c +++ b/src/lv_draw/lv_draw_label.c @@ -56,8 +56,8 @@ static uint8_t hex_char_to_num(char hex); * @param sel_end end index of selected area (`LV_LABEL_TXT_SEL_OFF` if none) */ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale, - const char * txt, lv_txt_flag_t flag, lv_point_t * offset, uint16_t sel_start, uint16_t sel_end, - lv_draw_label_hint_t * hint, lv_bidi_dir_t bidi_dir) + const char * txt, lv_txt_flag_t flag, lv_point_t * offset, uint16_t sel_start, uint16_t sel_end, + lv_draw_label_hint_t * hint, lv_bidi_dir_t bidi_dir) { const lv_font_t * font = style->text.font; lv_coord_t w; @@ -75,7 +75,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st /*If EXAPND is enabled then not limit the text's width to the object's width*/ lv_point_t p; lv_txt_get_size(&p, txt, style->text.font, style->text.letter_space, style->text.line_space, LV_COORD_MAX, - flag); + flag); w = p.x; } @@ -113,23 +113,6 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st pos.y += hint->y; } - if(sel_start != 0xFFFF) { - sel_start = lv_bidi_get_visual_pos(txt, NULL, strlen(txt), bidi_dir, sel_start, NULL); - sel_start = lv_txt_encoded_get_byte_id(txt, sel_start); - } - - if(sel_end != 0xFFFF) { - sel_end = lv_bidi_get_visual_pos(txt, NULL, strlen(txt), bidi_dir, sel_end, NULL); - sel_end = lv_txt_encoded_get_byte_id(txt, sel_end); - } - - if(sel_start > sel_end) { - uint16_t tmp = sel_start; - sel_start = sel_end; - sel_end = tmp; - } - - uint32_t line_end = line_start + lv_txt_get_next_line(&txt[line_start], font, style->text.letter_space, w, flag); @@ -165,6 +148,12 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->text.opa : (uint16_t)((uint16_t)style->text.opa * opa_scale) >> 8; + if(sel_start > sel_end) { + uint16_t tmp = sel_start; + sel_start = sel_end; + sel_end = tmp; + } + cmd_state_t cmd_state = CMD_STATE_WAIT; uint32_t i; uint16_t par_start = 0; @@ -185,16 +174,24 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st uint32_t letter; uint32_t letter_next; #if LV_USE_BIDI - char *bidi_txt = lv_draw_get_buf(line_end - line_start + 1); - lv_bidi_process_paragraph(txt + line_start, bidi_txt, line_end - line_start, bidi_dir, NULL, 0); + char *bidi_txt = lv_draw_get_buf(line_end - line_start + 1); + lv_bidi_process_paragraph(txt + line_start, bidi_txt, line_end - line_start, bidi_dir, NULL, 0); #else - const char *bidi_txt = txt + line_start; + const char *bidi_txt = txt + line_start; #endif + while(i < line_end - line_start) { + uint16_t logical_char_pos = 0; + if(sel_start != 0xFFFF && sel_end != 0xFFFF) { + logical_char_pos = lv_txt_encoded_get_char_id(txt, line_start); + uint16_t t = lv_txt_encoded_get_char_id(bidi_txt, i); + logical_char_pos += lv_bidi_get_logical_pos(bidi_txt, NULL, line_end - line_start, bidi_dir, t, NULL); + } letter = lv_txt_encoded_next(bidi_txt, &i); letter_next = lv_txt_encoded_next(&bidi_txt[i], NULL); + /*Handle the re-color command*/ if((flag & LV_TXT_FLAG_RECOLOR) != 0) { if(letter == (uint32_t)LV_TXT_COLOR_CMD[0]) { @@ -240,7 +237,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st if(sel_start != 0xFFFF && sel_end != 0xFFFF) { /*Do not draw the rectangle on the character at `sel_start`.*/ - if(i + line_start > sel_start && i + line_start <= sel_end) { + if(logical_char_pos > sel_start && logical_char_pos <= sel_end) { lv_area_t sel_coords; sel_coords.x1 = pos.x; sel_coords.y1 = pos.y; @@ -263,7 +260,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st /*Align to middle*/ if(flag & LV_TXT_FLAG_CENTER) { line_width = - lv_txt_get_width(&txt[line_start], line_end - line_start, font, style->text.letter_space, flag); + lv_txt_get_width(&txt[line_start], line_end - line_start, font, style->text.letter_space, flag); pos.x += (lv_area_get_width(coords) - line_width) / 2; @@ -271,7 +268,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st /*Align to the right*/ else if(flag & LV_TXT_FLAG_RIGHT) { line_width = - lv_txt_get_width(&txt[line_start], line_end - line_start, font, style->text.letter_space, flag); + lv_txt_get_width(&txt[line_start], line_end - line_start, font, style->text.letter_space, flag); pos.x += lv_area_get_width(coords) - line_width; } @@ -301,13 +298,13 @@ static uint8_t hex_char_to_num(char hex) if(hex >= 'a') hex -= 'a' - 'A'; /*Convert to upper case*/ switch(hex) { - case 'A': result = 10; break; - case 'B': result = 11; break; - case 'C': result = 12; break; - case 'D': result = 13; break; - case 'E': result = 14; break; - case 'F': result = 15; break; - default: result = 0; break; + case 'A': result = 10; break; + case 'B': result = 11; break; + case 'C': result = 12; break; + case 'D': result = 13; break; + case 'E': result = 14; break; + case 'F': result = 15; break; + default: result = 0; break; } } From 23b58d598de37bf5e6ede52671a5b128b46791d7 Mon Sep 17 00:00:00 2001 From: Amir Gonnen Date: Mon, 11 Nov 2019 22:43:12 +0200 Subject: [PATCH 53/64] bugfixes Prevent infinite loop when reaching end of string on get_next_run Prevent warning about conversion to non const bidi_txt --- src/lv_misc/lv_bidi.c | 2 +- src/lv_objx/lv_label.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lv_misc/lv_bidi.c b/src/lv_misc/lv_bidi.c index 0f1153b52..bde752071 100644 --- a/src/lv_misc/lv_bidi.c +++ b/src/lv_misc/lv_bidi.c @@ -232,7 +232,7 @@ void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len /*Get and process the runs*/ - while(rd < len) { + while(rd < len && str_in[rd]) { run_dir = get_next_run(&str_in[rd], base_dir, len - rd, &run_len, &pos_conv_run_len); if(base_dir == LV_BIDI_DIR_LTR) { diff --git a/src/lv_objx/lv_label.c b/src/lv_objx/lv_label.c index 29fae15b0..bd99c10c8 100644 --- a/src/lv_objx/lv_label.c +++ b/src/lv_objx/lv_label.c @@ -626,7 +626,7 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t char_id, lv_point_ } } - char *bidi_txt; + const char *bidi_txt; uint16_t visual_byte_pos; #if LV_USE_BIDI /*Handle Bidi*/ @@ -638,7 +638,9 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t char_id, lv_point_ uint16_t line_char_id = lv_txt_encoded_get_char_id(&txt[line_start], byte_id - line_start); bool is_rtl; - uint16_t visual_char_pos = lv_bidi_get_visual_pos(&txt[line_start], &bidi_txt, new_line_start - line_start, lv_obj_get_base_dir(label), line_char_id, &is_rtl); + char *mutable_bidi_txt; + uint16_t visual_char_pos = lv_bidi_get_visual_pos(&txt[line_start], &mutable_bidi_txt, new_line_start - line_start, lv_obj_get_base_dir(label), line_char_id, &is_rtl); + bidi_txt = mutable_bidi_txt; if (is_rtl) visual_char_pos++; visual_byte_pos = lv_txt_encoded_get_byte_id(bidi_txt, visual_char_pos); } From f3b88a57cac92e5bedbba4286980a07c30049485 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 12 Nov 2019 05:38:26 +0100 Subject: [PATCH 54/64] add LV_COLOR_SET/GET_R/G/B It was mainly because when LV_COLOR_16_SWAP = 1 and green is split to green_h and green_l --- src/lv_conf_checker.h | 2 +- src/lv_draw/lv_draw_basic.c | 32 ++------ src/lv_misc/lv_color.h | 141 ++++++++++++++++++++---------------- src/lv_objx/lv_cpicker.c | 8 +- 4 files changed, 90 insertions(+), 93 deletions(-) diff --git a/src/lv_conf_checker.h b/src/lv_conf_checker.h index a855707b4..a6ad94c81 100644 --- a/src/lv_conf_checker.h +++ b/src/lv_conf_checker.h @@ -475,7 +475,7 @@ /* If a character is at least this long, will break wherever "prettiest" */ #ifndef LV_TXT_LINE_BREAK_LONG_LEN -#define LV_TXT_LINE_BREAK_LONG_LEN 12 +#define LV_TXT_LINE_BREAK_LONG_LEN 120 #endif /* Minimum number of characters of a word to put on a line before a break */ diff --git a/src/lv_draw/lv_draw_basic.c b/src/lv_draw/lv_draw_basic.c index f00a30b65..d15429c7b 100644 --- a/src/lv_draw/lv_draw_basic.c +++ b/src/lv_draw/lv_draw_basic.c @@ -343,11 +343,7 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p, const lv #endif uint8_t font_rgb[3]; -#if LV_COLOR_16_SWAP == 0 - uint8_t txt_rgb[3] = {color.ch.red, color.ch.green, color.ch.blue}; -#else - uint8_t txt_rgb[3] = {color.ch.red, (color.ch.green_h << 3) + color.ch.green_l, color.ch.blue}; -#endif + uint8_t txt_rgb[3] = {LV_COLOR_GET_R(color), LV_COLOR_GET_G(color), LV_COLOR_GET_B(color)}; for(row = row_start; row < row_end; row++) { bitmask = bitmask_init >> col_bit; @@ -407,30 +403,16 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p, const lv res_color = *vdb_buf_tmp; } else { -#if LV_COLOR_16_SWAP == 0 - uint8_t bg_rgb[3] = {vdb_buf_tmp->ch.red, vdb_buf_tmp->ch.green, vdb_buf_tmp->ch.blue}; -#else - uint8_t bg_rgb[3] = {vdb_buf_tmp->ch.red, - (vdb_buf_tmp->ch.green_h << 3) + vdb_buf_tmp->ch.green_l, - vdb_buf_tmp->ch.blue}; -#endif + uint8_t bg_rgb[3] = {LV_COLOR_GET_R(*vdb_buf_tmp), LV_COLOR_GET_G(*vdb_buf_tmp), LV_COLOR_GET_B(*vdb_buf_tmp)}; #if LV_SUBPX_BGR - res_color.ch.blue = (uint16_t)((uint16_t)txt_rgb[0] * font_rgb[0] + (bg_rgb[2] * (255 - font_rgb[0]))) >> 8; - res_color.ch.red = (uint16_t)((uint16_t)txt_rgb[2] * font_rgb[2] + (bg_rgb[0] * (255 - font_rgb[2]))) >> 8; + LV_COLOR_SET_B(res_color, (uint16_t)((uint16_t)txt_rgb[0] * font_rgb[0] + (bg_rgb[2] * (255 - font_rgb[0]))) >> 8); + LV_COLOR_SET_R(res_color, (uint16_t)((uint16_t)txt_rgb[2] * font_rgb[2] + (bg_rgb[0] * (255 - font_rgb[2]))) >> 8); #else - res_color.ch.red = (uint16_t)((uint16_t)txt_rgb[0] * font_rgb[0] + (bg_rgb[0] * (255 - font_rgb[0]))) >> 8; - res_color.ch.blue = (uint16_t)((uint16_t)txt_rgb[2] * font_rgb[2] + (bg_rgb[2] * (255 - font_rgb[2]))) >> 8; + LV_COLOR_SET_R(res_color, (uint16_t)((uint16_t)txt_rgb[0] * font_rgb[0] + (bg_rgb[0] * (255 - font_rgb[0]))) >> 8); + LV_COLOR_SET_B(res_color, (uint16_t)((uint16_t)txt_rgb[2] * font_rgb[2] + (bg_rgb[2] * (255 - font_rgb[2]))) >> 8); #endif - -#if LV_COLOR_16_SWAP == 0 - res_color.ch.green = (uint16_t)((uint16_t)txt_rgb[1] * font_rgb[1] + (bg_rgb[1] * (255 - font_rgb[1]))) >> 8; -#else - uint8_t green = (uint16_t)((uint16_t)txt_rgb[1] * font_rgb[1] + (bg_rgb[1] * (255 - font_rgb[1]))) >> 8; - res_color.ch.green_h = green >> 3; - res_color.ch.green_l = green & 0x7; -#endif - + LV_COLOR_SET_G(res_color, (uint16_t)((uint16_t)txt_rgb[1] * font_rgb[1] + (bg_rgb[1] * (255 - font_rgb[1]))) >> 8); } if(scr_transp == false) { vdb_buf_tmp->full = res_color.full; diff --git a/src/lv_misc/lv_color.h b/src/lv_misc/lv_color.h index 95542afb6..ddc4a7436 100644 --- a/src/lv_misc/lv_color.h +++ b/src/lv_misc/lv_color.h @@ -90,6 +90,55 @@ enum { #error "Invalid LV_COLOR_DEPTH in lv_conf.h! Set it to 1, 8, 16 or 32!" #endif +/*----------------------- + * Macros to set/get values + * of the color channels + *-----------------------*/ +#if LV_COLOR_DEPTH == 1 +# define LV_COLOR_SET_R(c, v) (c).ch.red = v & 0x1; +# define LV_COLOR_SET_G(c, v) (c).ch.green = v & 0x1; +# define LV_COLOR_SET_B(c, v) (c).ch.blue = v & 0x1; + +# define LV_COLOR_GET_R(c) (c).ch.red +# define LV_COLOR_GET_G(c) (c).ch.green +# define LV_COLOR_GET_B(c) (c).ch.blue + +#elif LV_COLOR_DEPTH == 8 +# define LV_COLOR_SET_R(c, v) (c).ch.red = v & 0x7; +# define LV_COLOR_SET_G(c, v) (c).ch.green = v & 0x7; +# define LV_COLOR_SET_B(c, v) c(c).ch.blue = v & 0x3; + +# define LV_COLOR_GET_R(c) (c).ch.red +# define LV_COLOR_GET_G(c) (c).ch.green +# define LV_COLOR_GET_B(c) (c).ch.blue + +#elif LV_COLOR_DEPTH == 16 +# define LV_COLOR_SET_R(c, v) (c).ch.red = v & 0x1F; +# if LV_COLOR_16_SWAP == 0 +# define LV_COLOR_SET_G(c, v) (c).ch.green = v & 0x3F; +# else +# define LV_COLOR_SET_G(c, v) {(c).ch.green_h = ((v) >> 3) & 0x3; (c).ch.green_l = (v) & 0x3;} +# endif +# define LV_COLOR_SET_B(c, v) (c).ch.blue= v & 0x1F; + +# define LV_COLOR_GET_R(c) (c).ch.red +# if LV_COLOR_16_SWAP == 0 +# define LV_COLOR_GET_G(c) (c).ch.green +# else +# define LV_COLOR_GET_G(c) (((c).ch.green_h << 3) + (c).ch.green_l) +# endif +# define LV_COLOR_GET_B(c) (c).ch.blue + +#elif LV_COLOR_DEPTH == 32 +# define LV_COLOR_SET_R(c, v) (c).ch.red = v & 0xFF; +# define LV_COLOR_SET_G(c, v) (c).ch.green = v & 0xFF; +# define LV_COLOR_SET_B(c, v) (c).ch.blue = v & 0xFF; + +# define LV_COLOR_GET_R(c) (c).ch.red +# define LV_COLOR_GET_G(c) (c).ch.green +# define LV_COLOR_GET_B(c) (c).ch.blue +#endif + /********************** * TYPEDEFS **********************/ @@ -194,24 +243,19 @@ static inline uint8_t lv_color_to1(lv_color_t color) #if LV_COLOR_DEPTH == 1 return color.full; #elif LV_COLOR_DEPTH == 8 - if((color.ch.red & 0x4) || (color.ch.green & 0x4) || (color.ch.blue & 0x2)) { + if((LV_COLOR_GET_R(color) & 0x4) || (LV_COLOR_GET_G(color) & 0x4) || (LV_COLOR_GET_B(color) & 0x2)) { return 1; } else { return 0; } #elif LV_COLOR_DEPTH == 16 -#if LV_COLOR_16_SWAP == 0 - if((color.ch.red & 0x10) || (color.ch.green & 0x20) || (color.ch.blue & 0x10)) { + if((LV_COLOR_GET_R(color) & 0x10) || (LV_COLOR_GET_G(color) & 0x20) || (LV_COLOR_GET_B(color) & 0x10)) { return 1; -#else - if((color.ch.red & 0x10) || (color.ch.green_h & 0x20) || (color.ch.blue & 0x10)) { - return 1; -#endif } else { return 0; } #elif LV_COLOR_DEPTH == 32 - if((color.ch.red & 0x80) || (color.ch.green & 0x80) || (color.ch.blue & 0x80)) { + if((cLV_COLOR_GET_R(color) & 0x80) || (LV_COLOR_GET_G(color) & 0x80) || (LV_COLOR_GET_B(color) & 0x80)) { return 1; } else { return 0; @@ -229,25 +273,16 @@ static inline uint8_t lv_color_to8(lv_color_t color) #elif LV_COLOR_DEPTH == 8 return color.full; #elif LV_COLOR_DEPTH == 16 - -#if LV_COLOR_16_SWAP == 0 lv_color8_t ret; - ret.ch.red = color.ch.red >> 2; /* 5 - 3 = 2*/ - ret.ch.green = color.ch.green >> 3; /* 6 - 3 = 3*/ - ret.ch.blue = color.ch.blue >> 3; /* 5 - 2 = 3*/ + ret.ch.red = LV_COLOR_GET_R(color) >> 2; /* 5 - 3 = 2*/ + ret.ch.green = LV_COLOR_GET_G(color) >> 3; /* 6 - 3 = 3*/ + ret.ch.blue = LV_COLOR_GET_B(color) >> 3; /* 5 - 2 = 3*/ return ret.full; -#else - lv_color8_t ret; - ret.ch.red = color.ch.red >> 2; /* 5 - 3 = 2*/ - ret.ch.green = color.ch.green_h; /* 6 - 3 = 3*/ - ret.ch.blue = color.ch.blue >> 3; /* 5 - 2 = 3*/ - return ret.full; -#endif #elif LV_COLOR_DEPTH == 32 lv_color8_t ret; - ret.ch.red = color.ch.red >> 5; /* 8 - 3 = 5*/ - ret.ch.green = color.ch.green >> 5; /* 8 - 3 = 5*/ - ret.ch.blue = color.ch.blue >> 6; /* 8 - 2 = 6*/ + ret.ch.red = LV_COLOR_GET_R(color) >> 5; /* 8 - 3 = 5*/ + ret.ch.green = LV_COLOR_GET_G(color) >> 5; /* 8 - 3 = 5*/ + ret.ch.blue = LV_COLOR_GET_B(color) >> 6; /* 8 - 2 = 6*/ return ret.full; #endif } @@ -261,32 +296,29 @@ static inline uint16_t lv_color_to16(lv_color_t color) return 0xFFFF; #elif LV_COLOR_DEPTH == 8 lv_color16_t ret; + ret.ch.red = LV_COLOR_GET_R(color) * 4; /*(2^5 - 1)/(2^3 - 1) = 31/7 = 4*/ #if LV_COLOR_16_SWAP == 0 - ret.ch.red = color.ch.red * 4; /*(2^5 - 1)/(2^3 - 1) = 31/7 = 4*/ - ret.ch.green = color.ch.green * 9; /*(2^6 - 1)/(2^3 - 1) = 63/7 = 9*/ - ret.ch.blue = color.ch.blue * 10; /*(2^5 - 1)/(2^2 - 1) = 31/3 = 10*/ + ret.ch.green = LV_COLOR_GET_G(color) * 9; /*(2^6 - 1)/(2^3 - 1) = 63/7 = 9*/ #else - ret.red = color.ch.red * 4; - uint8_t g_tmp = color.ch.green * 9; - ret.ch.green_h = (g_tmp & 0x1F) >> 3; - ret.ch.green_l = g_tmp & 0x07; - ret.ch.blue = color.ch.blue * 10; + ret.ch.green_h = (LV_COLOR_GET_G(color) * 9) >> 3; /*(2^6 - 1)/(2^3 - 1) = 63/7 = 9*/ + ret.ch.green_l = (LV_COLOR_GET_G(color) * 9) & 0x7; #endif + ret.ch.blue = LV_COLOR_GET_B(color) * 10; /*(2^5 - 1)/(2^2 - 1) = 31/3 = 10*/ return ret.full; #elif LV_COLOR_DEPTH == 16 return color.full; #elif LV_COLOR_DEPTH == 32 lv_color16_t ret; + ret.ch.red = LV_COLOR_GET_R(color) >> 3; /* 8 - 5 = 3*/ + #if LV_COLOR_16_SWAP == 0 - ret.ch.red = color.ch.red >> 3; /* 8 - 5 = 3*/ - ret.ch.green = color.ch.green >> 2; /* 8 - 6 = 2*/ - ret.ch.blue = color.ch.blue >> 3; /* 8 - 5 = 3*/ + ret.ch.green = LV_COLOR_GET_G(color) >> 2; /* 8 - 6 = 2*/ #else - ret.ch.red = color.ch.red >> 3; - ret.ch.green_h = (color.ch.green & 0xE0) >> 5; - ret.ch.green_l = (color.ch.green & 0x1C) >> 2; - ret.ch.blue = color.ch.blue >> 3; + ret.ch.green_h = (LV_COLOR_GET_G(color) >> 5; /*(2^6 - 1)/(2^3 - 1) = 63/7 = 9*/ + ret.ch.green_l = (LV_COLOR_GET_G(color) >> 2) & 0x7; #endif + ret.ch.green = LV_COLOR_GET_G(color) >> 2; /* 8 - 6 = 2*/ + ret.ch.blue = LV_COLOR_GET_B(color) >> 3; /* 8 - 5 = 3*/ return ret.full; #endif } @@ -300,9 +332,9 @@ static inline uint32_t lv_color_to32(lv_color_t color) return 0xFFFFFFFF; #elif LV_COLOR_DEPTH == 8 lv_color32_t ret; - ret.ch.red = color.ch.red * 36; /*(2^8 - 1)/(2^3 - 1) = 255/7 = 36*/ - ret.ch.green = color.ch.green * 36; /*(2^8 - 1)/(2^3 - 1) = 255/7 = 36*/ - ret.ch.blue = color.ch.blue * 85; /*(2^8 - 1)/(2^2 - 1) = 255/3 = 85*/ + ret.ch.red = LV_COLOR_GET_R(color) * 36; /*(2^8 - 1)/(2^3 - 1) = 255/7 = 36*/ + ret.ch.green = LV_COLOR_GET_G(color) * 36; /*(2^8 - 1)/(2^3 - 1) = 255/7 = 36*/ + ret.ch.blue = LV_COLOR_GET_B(color) * 85; /*(2^8 - 1)/(2^2 - 1) = 255/3 = 85*/ ret.ch.alpha = 0xFF; return ret.full; #elif LV_COLOR_DEPTH == 16 @@ -335,13 +367,9 @@ static inline uint32_t lv_color_to32(lv_color_t color) * 6 259 3 0 255 */ lv_color32_t ret; - ret.ch.red = ( color.ch.red * 263 + 7 ) >> 5; -#if LV_COLOR_16_SWAP == 0 - ret.ch.green = ( color.ch.green * 259 + 3 ) >> 6; -#else - ret.ch.green = (((color.ch.green_h << 3) + color.ch.green_l) * 259 + 3 ) >> 6; -#endif - ret.ch.blue = ( color.ch.blue * 263 + 7 ) >> 5; + ret.ch.red = (LV_COLOR_GET_R(color) * 263 + 7 ) >> 5; + ret.ch.green = (LV_COLOR_GET_G(color) * 259 + 3 ) >> 6; + ret.ch.blue = (LV_COLOR_GET_B(color) * 263 + 7 ) >> 5; ret.ch.alpha = 0xFF; return ret.full; #elif LV_COLOR_DEPTH == 32 @@ -354,18 +382,9 @@ static inline lv_color_t lv_color_mix(lv_color_t c1, lv_color_t c2, uint8_t mix) lv_color_t ret; #if LV_COLOR_DEPTH != 1 /*LV_COLOR_DEPTH == 8, 16 or 32*/ - ret.ch.red = (uint16_t)((uint16_t)c1.ch.red * mix + (c2.ch.red * (255 - mix))) >> 8; -#if LV_COLOR_DEPTH == 16 && LV_COLOR_16_SWAP - /*If swapped Green is in 2 parts*/ - uint16_t g_1 = (c1.ch.green_h << 3) + c1.ch.green_l; - uint16_t g_2 = (c2.ch.green_h << 3) + c2.ch.green_l; - uint16_t g_out = (uint16_t)((uint16_t)g_1 * mix + (g_2 * (255 - mix))) >> 8; - ret.ch.green_h = g_out >> 3; - ret.ch.green_l = g_out & 0x7; -#else - ret.ch.green = (uint16_t)((uint16_t)c1.ch.green * mix + (c2.ch.green * (255 - mix))) >> 8; -#endif - ret.ch.blue = (uint16_t)((uint16_t)c1.ch.blue * mix + (c2.ch.blue * (255 - mix))) >> 8; + LV_COLOR_SET_R(ret, (uint16_t)((uint16_t) LV_COLOR_GET_R(c1) * mix + LV_COLOR_GET_R(c2) * (255 - mix)) >> 8); + LV_COLOR_SET_G(ret, (uint16_t)((uint16_t) LV_COLOR_GET_G(c1) * mix + LV_COLOR_GET_G(c2) * (255 - mix)) >> 8); + LV_COLOR_SET_B(ret, (uint16_t)((uint16_t) LV_COLOR_GET_B(c1) * mix + LV_COLOR_GET_B(c2) * (255 - mix)) >> 8); #if LV_COLOR_DEPTH == 32 ret.ch.alpha = 0xFF; #endif @@ -386,7 +405,7 @@ static inline uint8_t lv_color_brightness(lv_color_t color) { lv_color32_t c32; c32.full = lv_color_to32(color); - uint16_t bright = 3 * c32.ch.red + c32.ch.blue + 4 * c32.ch.green; + uint16_t bright = 3 * LV_COLOR_GET_R(c32) + LV_COLOR_GET_B(c32) + 4 * LV_COLOR_GET_G(c32); return (uint16_t)bright >> 3; } diff --git a/src/lv_objx/lv_cpicker.c b/src/lv_objx/lv_cpicker.c index 73197d374..383607171 100644 --- a/src/lv_objx/lv_cpicker.c +++ b/src/lv_objx/lv_cpicker.c @@ -275,12 +275,8 @@ bool lv_cpicker_set_hsv(lv_obj_t * cpicker, lv_color_hsv_t hsv) */ bool lv_cpicker_set_color(lv_obj_t * cpicker, lv_color_t color) { -#if LV_COLOR_DEPTH == 16 && LV_COLOR_16_SWAP != 0 - uint8_t green = (color.ch.green_h << 3) + color.ch.green_l; - return lv_cpicker_set_hsv(cpicker, lv_color_rgb_to_hsv(color.ch.red, green, color.ch.blue)); -#else - return lv_cpicker_set_hsv(cpicker, lv_color_rgb_to_hsv(color.ch.red, color.ch.green, color.ch.blue)); -#endif + return lv_cpicker_set_hsv(cpicker, + lv_color_rgb_to_hsv(LV_COLOR_GET_R(color), LV_COLOR_GET_G(color), LV_COLOR_GET_B(color))); } /** From bb91aeb64c56cb69b0c23ce26ecc66a983012941 Mon Sep 17 00:00:00 2001 From: Brian Pugh Date: Mon, 11 Nov 2019 20:57:33 -0800 Subject: [PATCH 55/64] Add ability to disable inter-long-word breaks by setting LV_TXT_LINE_BREAK_LONG_LEN<=0. Fix some off-by-one character wrapping logic --- lv_conf_template.h | 9 ++++++--- src/lv_misc/lv_txt.c | 33 ++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/lv_conf_template.h b/lv_conf_template.h index aab872fc4..37e2abb95 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -344,13 +344,16 @@ typedef void * lv_font_user_data_t; /*Can break (wrap) texts on these chars*/ #define LV_TXT_BREAK_CHARS " ,.;:-_" -/* If a character is at least this long, will break wherever "prettiest" */ +/* If a character is at least this long, will break wherever "prettiest" + * To disable, set to a value <= 0 */ #define LV_TXT_LINE_BREAK_LONG_LEN 12 -/* Minimum number of characters of a word to put on a line before a break */ +/* Minimum number of characters in a long word to put on a line before a break. + * Depends on LV_TXT_LINE_BREAK_LONG_LEN. */ #define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3 -/* Minimum number of characters of a word to put on a line after a break */ +/* Minimum number of characters in a long word to put on a line after a break. + * Depends on LV_TXT_LINE_BREAK_LONG_LEN. */ #define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 3 /*Change the built in (v)snprintf functions*/ diff --git a/src/lv_misc/lv_txt.c b/src/lv_misc/lv_txt.c index b7570b1cb..40d579ef7 100644 --- a/src/lv_misc/lv_txt.c +++ b/src/lv_misc/lv_txt.c @@ -155,11 +155,12 @@ void lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t * * @param max_width max with of the text (break the lines to fit this size) Set CORD_MAX to avoid line breaks * @param flags settings for the text from 'txt_flag_type' enum * @param[out] word_w_ptr width (in pixels) of the parsed word. May be NULL. + * @param force Force return the fraction of the word that can fit in the provided space. * @return the index of the first char of the next word (in byte index not letter index. With UTF-8 they are different) */ static uint16_t lv_txt_get_next_word(const char * txt, const lv_font_t * font, lv_coord_t letter_space, lv_coord_t max_width, - lv_txt_flag_t flag, uint32_t *word_w_ptr) + lv_txt_flag_t flag, uint32_t *word_w_ptr, bool force) { if(txt == NULL || txt[0] == '\0') return 0; if(font == NULL) return 0; @@ -179,6 +180,7 @@ static uint16_t lv_txt_get_next_word(const char * txt, const lv_font_t * font, letter = lv_txt_encoded_next(txt, &i_next); i_next_next = i_next; + /* Obtain the full word, regardless if it fits or not in max_width */ while(txt[i] != '\0') { letter_next = lv_txt_encoded_next(txt, &i_next_next); word_len++; @@ -196,17 +198,10 @@ static uint16_t lv_txt_get_next_word(const char * txt, const lv_font_t * font, letter_w = lv_font_get_glyph_width(font, letter, letter_next); cur_w += letter_w; - /* Test if this character fits within max_width */ - if( break_index == NO_BREAK_FOUND && cur_w > max_width) { + if(break_index == NO_BREAK_FOUND && cur_w > max_width) { break_index = i; - if(break_index > 0) { /* zero is possible if first character doesn't fit in width */ - lv_txt_encoded_prev(txt, &break_index); - break_letter_count = word_len - 2; - } - else{ - break_letter_count = word_len - 1; - } + break_letter_count = word_len - 1; /* break_index is now pointing at the character that doesn't fit */ } @@ -237,9 +232,14 @@ static uint16_t lv_txt_get_next_word(const char * txt, const lv_font_t * font, return i; } + if( force ) { + return break_index; + } + +#if LV_TXT_LINE_BREAK_LONG_LEN > 0 /* Word doesn't fit in provided space, but isn't "long" */ if(word_len < LV_TXT_LINE_BREAK_LONG_LEN) { - if(word_w_ptr != NULL) *word_w_ptr = 0; + if(word_w_ptr != NULL) *word_w_ptr = 0; /* Return no word */ return 0; } @@ -256,12 +256,15 @@ static uint16_t lv_txt_get_next_word(const char * txt, const lv_font_t * font, /* Move pointer "i" backwards */ for(;n_move>0; n_move--){ lv_txt_encoded_prev(txt, &i); - // todo: it would be appropriate to update the returned word width here + // TODO: it would be appropriate to update the returned word width here // However, in current usage, this doesn't impact anything. } } - return i; +#else + (void) break_letter_count; + return 0; +#endif } /** @@ -288,7 +291,7 @@ uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font, while(txt[i] != '\0' && max_width > 0) { uint32_t word_w = 0; - uint32_t advance = lv_txt_get_next_word(&txt[i], font, letter_space, max_width, flag, &word_w); + uint32_t advance = lv_txt_get_next_word(&txt[i], font, letter_space, max_width, flag, &word_w, i==0); max_width -= word_w; if( advance == 0 ){ @@ -307,7 +310,7 @@ uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font, } - /*Always step at least one to avoid infinite loops*/ + /* Always step at least one to avoid infinite loops */ if(i == 0) { lv_txt_encoded_next(txt, &i); } From 1764220debcc0c4be856483f655834bd3f7d8e53 Mon Sep 17 00:00:00 2001 From: Brian Pugh Date: Mon, 11 Nov 2019 21:18:32 -0800 Subject: [PATCH 56/64] lv_txt set word width to 0 when not returning a word in lv_txt_get_next_word --- src/lv_misc/lv_txt.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lv_misc/lv_txt.c b/src/lv_misc/lv_txt.c index 40d579ef7..a19a5ab44 100644 --- a/src/lv_misc/lv_txt.c +++ b/src/lv_misc/lv_txt.c @@ -263,6 +263,7 @@ static uint16_t lv_txt_get_next_word(const char * txt, const lv_font_t * font, return i; #else (void) break_letter_count; + if(word_w_ptr != NULL) *word_w_ptr = 0; /* Return no word */ return 0; #endif } From 49e105917ecf2504024c6cc80b4bd84e53f16bf4 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 12 Nov 2019 06:39:26 +0100 Subject: [PATCH 57/64] add LV_COLOR_SET/GET for every color depth configuration --- src/lv_misc/lv_color.h | 208 +++++++++++++++++++++++++---------------- 1 file changed, 127 insertions(+), 81 deletions(-) diff --git a/src/lv_misc/lv_color.h b/src/lv_misc/lv_color.h index ddc4a7436..d45aa0a61 100644 --- a/src/lv_misc/lv_color.h +++ b/src/lv_misc/lv_color.h @@ -90,53 +90,108 @@ enum { #error "Invalid LV_COLOR_DEPTH in lv_conf.h! Set it to 1, 8, 16 or 32!" #endif -/*----------------------- - * Macros to set/get values - * of the color channels - *-----------------------*/ -#if LV_COLOR_DEPTH == 1 -# define LV_COLOR_SET_R(c, v) (c).ch.red = v & 0x1; -# define LV_COLOR_SET_G(c, v) (c).ch.green = v & 0x1; -# define LV_COLOR_SET_B(c, v) (c).ch.blue = v & 0x1; +/*--------------------------------------- + * Macros for all existing color depths + * to set/get values of the color channels + *------------------------------------------*/ +# define LV_COLOR_SET_R1(c, v) (c).ch.red = (v) & 0x1; +# define LV_COLOR_SET_G1(c, v) (c).ch.green = (v) & 0x1; +# define LV_COLOR_SET_B1(c, v) (c).ch.blue = (v) & 0x1; +# define LV_COLOR_SET_A1(c, v) -# define LV_COLOR_GET_R(c) (c).ch.red -# define LV_COLOR_GET_G(c) (c).ch.green -# define LV_COLOR_GET_B(c) (c).ch.blue +# define LV_COLOR_GET_R1(c) (c).ch.red +# define LV_COLOR_GET_G1(c) (c).ch.green +# define LV_COLOR_GET_B1(c) (c).ch.blue +# define LV_COLOR_GET_A1(c) 1 + +# define LV_COLOR_SET_R8(c, v) (c).ch.red = (v) & 0x7; +# define LV_COLOR_SET_G8(c, v) (c).ch.green = (v) & 0x7; +# define LV_COLOR_SET_B8(c, v) (c).ch.blue = (v) & 0x3; +# define LV_COLOR_SET_A8(c, v) + +# define LV_COLOR_GET_R8(c) (c).ch.red +# define LV_COLOR_GET_G8(c) (c).ch.green +# define LV_COLOR_GET_B8(c) (c).ch.blue +# define LV_COLOR_GET_A8(c) 0xFF + +# define LV_COLOR_SET_R16(c, v) (c).ch.red = (v) & 0x1F; +# define LV_COLOR_SET_G16(c, v) (c).ch.green = (v) & 0x3F; +# define LV_COLOR_SET_G16_SWAP(c, v) {(c).ch.green_h = ((v) >> 3) & 0x7; (c).ch.green_l = (v) & 0x7;} +# define LV_COLOR_SET_B16(c, v) (c).ch.blue = (v) & 0x1F; +# define LV_COLOR_SET_A16(c, v) + +# define LV_COLOR_GET_R16(c) (c).ch.red +# define LV_COLOR_GET_G16(c) (c).ch.green +# define LV_COLOR_GET_G16_SWAP(c) (((c).ch.green_h << 3) + (c).ch.green_l) +# define LV_COLOR_GET_B16(c) (c).ch.blue +# define LV_COLOR_GET_A16(c) 0xFF + +# define LV_COLOR_SET_R32(c, v) (c).ch.red = (v) & 0xFF; +# define LV_COLOR_SET_G32(c, v) (c).ch.green = (v) & 0xFF; +# define LV_COLOR_SET_B32(c, v) (c).ch.blue = (v) & 0xFF; +# define LV_COLOR_SET_A32(c, v) (c).ch.alpha = (v) & 0xFF; + +# define LV_COLOR_GET_R32(c) (c).ch.red +# define LV_COLOR_GET_G32(c) (c).ch.green +# define LV_COLOR_GET_B32(c) (c).ch.blue +# define LV_COLOR_GET_A32(c) (c).ch.alpha + + +/*--------------------------------------- + * Macros for the current color depth + * to set/get values of the color channels + *------------------------------------------*/ +#if LV_COLOR_DEPTH == 1 +# define LV_COLOR_SET_R(c, v) LV_COLOR_SET_R1(c,v) +# define LV_COLOR_SET_G(c, v) LV_COLOR_SET_G1(c,v) +# define LV_COLOR_SET_B(c, v) LV_COLOR_SET_B1(c,v) +# define LV_COLOR_SET_A(c, v) LV_COLOR_SET_A1(c,v) + +# define LV_COLOR_GET_R(c) LV_COLOR_GET_R1(c) +# define LV_COLOR_GET_G(c) LV_COLOR_GET_G1(c) +# define LV_COLOR_GET_B(c) LV_COLOR_GET_B1(c) +# define LV_COLOR_GET_A(c) LV_COLOR_GET_A1(c) #elif LV_COLOR_DEPTH == 8 -# define LV_COLOR_SET_R(c, v) (c).ch.red = v & 0x7; -# define LV_COLOR_SET_G(c, v) (c).ch.green = v & 0x7; -# define LV_COLOR_SET_B(c, v) c(c).ch.blue = v & 0x3; +# define LV_COLOR_SET_R(c, v) LV_COLOR_SET_R8(c,v) +# define LV_COLOR_SET_G(c, v) LV_COLOR_SET_G8(c,v) +# define LV_COLOR_SET_B(c, v) LV_COLOR_SET_B8(c,v) +# define LV_COLOR_SET_A(c, v) LV_COLOR_SET_A8(c,v) -# define LV_COLOR_GET_R(c) (c).ch.red -# define LV_COLOR_GET_G(c) (c).ch.green -# define LV_COLOR_GET_B(c) (c).ch.blue +# define LV_COLOR_GET_R(c) LV_COLOR_GET_R8(c) +# define LV_COLOR_GET_G(c) LV_COLOR_GET_G8(c) +# define LV_COLOR_GET_B(c) LV_COLOR_GET_B8(c) +# define LV_COLOR_GET_A(c) LV_COLOR_GET_A8(c) #elif LV_COLOR_DEPTH == 16 -# define LV_COLOR_SET_R(c, v) (c).ch.red = v & 0x1F; +# define LV_COLOR_SET_R(c, v) LV_COLOR_SET_R16(c,v) # if LV_COLOR_16_SWAP == 0 -# define LV_COLOR_SET_G(c, v) (c).ch.green = v & 0x3F; +# define LV_COLOR_SET_G(c, v) LV_COLOR_SET_G16(c,v) # else -# define LV_COLOR_SET_G(c, v) {(c).ch.green_h = ((v) >> 3) & 0x3; (c).ch.green_l = (v) & 0x3;} +# define LV_COLOR_SET_G(c, v) LV_COLOR_SET_G16_SWAP(c,v) # endif -# define LV_COLOR_SET_B(c, v) (c).ch.blue= v & 0x1F; +# define LV_COLOR_SET_B(c, v) LV_COLOR_SET_B16(c,v) +# define LV_COLOR_SET_A(c, v) LV_COLOR_SET_A16(c,v) -# define LV_COLOR_GET_R(c) (c).ch.red +# define LV_COLOR_GET_R(c) LV_COLOR_GET_R16(c) # if LV_COLOR_16_SWAP == 0 -# define LV_COLOR_GET_G(c) (c).ch.green +# define LV_COLOR_GET_G(c) LV_COLOR_GET_G16(c) # else -# define LV_COLOR_GET_G(c) (((c).ch.green_h << 3) + (c).ch.green_l) +# define LV_COLOR_GET_G(c) LV_COLOR_GET_G16_SWAP(c) # endif -# define LV_COLOR_GET_B(c) (c).ch.blue +# define LV_COLOR_GET_B(c) LV_COLOR_GET_B16(c) +# define LV_COLOR_GET_A(c) LV_COLOR_GET_A16(c) #elif LV_COLOR_DEPTH == 32 -# define LV_COLOR_SET_R(c, v) (c).ch.red = v & 0xFF; -# define LV_COLOR_SET_G(c, v) (c).ch.green = v & 0xFF; -# define LV_COLOR_SET_B(c, v) (c).ch.blue = v & 0xFF; +# define LV_COLOR_SET_R(c, v) LV_COLOR_SET_R32(c,v) +# define LV_COLOR_SET_G(c, v) LV_COLOR_SET_G32(c,v) +# define LV_COLOR_SET_B(c, v) LV_COLOR_SET_B32(c,v) +# define LV_COLOR_SET_A(c, v) LV_COLOR_SET_A32(c,v) -# define LV_COLOR_GET_R(c) (c).ch.red -# define LV_COLOR_GET_G(c) (c).ch.green -# define LV_COLOR_GET_B(c) (c).ch.blue +# define LV_COLOR_GET_R(c) LV_COLOR_GET_R32(c) +# define LV_COLOR_GET_G(c) LV_COLOR_GET_G32(c) +# define LV_COLOR_GET_B(c) LV_COLOR_GET_B32(c) +# define LV_COLOR_GET_A(c) LV_COLOR_GET_A32(c) #endif /********************** @@ -255,7 +310,7 @@ static inline uint8_t lv_color_to1(lv_color_t color) return 0; } #elif LV_COLOR_DEPTH == 32 - if((cLV_COLOR_GET_R(color) & 0x80) || (LV_COLOR_GET_G(color) & 0x80) || (LV_COLOR_GET_B(color) & 0x80)) { + if((LV_COLOR_GET_R(color) & 0x80) || (LV_COLOR_GET_G(color) & 0x80) || (LV_COLOR_GET_B(color) & 0x80)) { return 1; } else { return 0; @@ -274,21 +329,22 @@ static inline uint8_t lv_color_to8(lv_color_t color) return color.full; #elif LV_COLOR_DEPTH == 16 lv_color8_t ret; - ret.ch.red = LV_COLOR_GET_R(color) >> 2; /* 5 - 3 = 2*/ - ret.ch.green = LV_COLOR_GET_G(color) >> 3; /* 6 - 3 = 3*/ - ret.ch.blue = LV_COLOR_GET_B(color) >> 3; /* 5 - 2 = 3*/ + LV_COLOR_SET_R8(ret, LV_COLOR_GET_R(color) >> 2); /* 5 - 3 = 2*/ + LV_COLOR_SET_G8(ret, LV_COLOR_GET_G(color) >> 3); /* 6 - 3 = 3*/ + LV_COLOR_SET_B8(ret, LV_COLOR_GET_B(color) >> 3); /* 5 - 2 = 3*/ return ret.full; #elif LV_COLOR_DEPTH == 32 lv_color8_t ret; - ret.ch.red = LV_COLOR_GET_R(color) >> 5; /* 8 - 3 = 5*/ - ret.ch.green = LV_COLOR_GET_G(color) >> 5; /* 8 - 3 = 5*/ - ret.ch.blue = LV_COLOR_GET_B(color) >> 6; /* 8 - 2 = 6*/ + LV_COLOR_SET_R8(ret, LV_COLOR_GET_R(color) >> 5); /* 8 - 3 = 5*/ + LV_COLOR_SET_G8(ret, LV_COLOR_GET_G(color) >> 5); /* 8 - 3 = 5*/ + LV_COLOR_SET_B8(ret, LV_COLOR_GET_B(color) >> 6); /* 8 - 2 = 6*/ return ret.full; #endif } static inline uint16_t lv_color_to16(lv_color_t color) { + #if LV_COLOR_DEPTH == 1 if(color.full == 0) return 0; @@ -296,31 +352,30 @@ static inline uint16_t lv_color_to16(lv_color_t color) return 0xFFFF; #elif LV_COLOR_DEPTH == 8 lv_color16_t ret; - ret.ch.red = LV_COLOR_GET_R(color) * 4; /*(2^5 - 1)/(2^3 - 1) = 31/7 = 4*/ + LV_COLOR_SET_R16(ret, LV_COLOR_GET_R(color) * 4); /*(2^5 - 1)/(2^3 - 1) = 31/7 = 4*/ #if LV_COLOR_16_SWAP == 0 - ret.ch.green = LV_COLOR_GET_G(color) * 9; /*(2^6 - 1)/(2^3 - 1) = 63/7 = 9*/ + LV_COLOR_SET_G16(ret, LV_COLOR_GET_G(color) * 9); /*(2^6 - 1)/(2^3 - 1) = 63/7 = 9*/ #else - ret.ch.green_h = (LV_COLOR_GET_G(color) * 9) >> 3; /*(2^6 - 1)/(2^3 - 1) = 63/7 = 9*/ - ret.ch.green_l = (LV_COLOR_GET_G(color) * 9) & 0x7; + LV_COLOR_SET_G16_SWAP(ret, (LV_COLOR_GET_G(color) * 9)); /*(2^6 - 1)/(2^3 - 1) = 63/7 = 9*/ #endif - ret.ch.blue = LV_COLOR_GET_B(color) * 10; /*(2^5 - 1)/(2^2 - 1) = 31/3 = 10*/ + LV_COLOR_SET_B16(ret, LV_COLOR_GET_B(color) * 10); /*(2^5 - 1)/(2^2 - 1) = 31/3 = 10*/ return ret.full; #elif LV_COLOR_DEPTH == 16 return color.full; #elif LV_COLOR_DEPTH == 32 lv_color16_t ret; - ret.ch.red = LV_COLOR_GET_R(color) >> 3; /* 8 - 5 = 3*/ + LV_COLOR_SET_R16(ret, LV_COLOR_GET_R(color) >> 3); /* 8 - 5 = 3*/ #if LV_COLOR_16_SWAP == 0 - ret.ch.green = LV_COLOR_GET_G(color) >> 2; /* 8 - 6 = 2*/ + LV_COLOR_SET_G16(ret, LV_COLOR_GET_G(color) >> 2); /* 8 - 6 = 2*/ #else - ret.ch.green_h = (LV_COLOR_GET_G(color) >> 5; /*(2^6 - 1)/(2^3 - 1) = 63/7 = 9*/ - ret.ch.green_l = (LV_COLOR_GET_G(color) >> 2) & 0x7; + LV_COLOR_SET_G16_SWAP(ret, ret.ch.green_h = (LV_COLOR_GET_G(color) >> 2); /*(2^6 - 1)/(2^3 - 1) = 63/7 = 9*/ #endif - ret.ch.green = LV_COLOR_GET_G(color) >> 2; /* 8 - 6 = 2*/ - ret.ch.blue = LV_COLOR_GET_B(color) >> 3; /* 8 - 5 = 3*/ + LV_COLOR_SET_B16(ret, LV_COLOR_GET_B(color) >> 3); /* 8 - 5 = 3*/ return ret.full; #endif + + return 0; } static inline uint32_t lv_color_to32(lv_color_t color) @@ -332,10 +387,10 @@ static inline uint32_t lv_color_to32(lv_color_t color) return 0xFFFFFFFF; #elif LV_COLOR_DEPTH == 8 lv_color32_t ret; - ret.ch.red = LV_COLOR_GET_R(color) * 36; /*(2^8 - 1)/(2^3 - 1) = 255/7 = 36*/ - ret.ch.green = LV_COLOR_GET_G(color) * 36; /*(2^8 - 1)/(2^3 - 1) = 255/7 = 36*/ - ret.ch.blue = LV_COLOR_GET_B(color) * 85; /*(2^8 - 1)/(2^2 - 1) = 255/3 = 85*/ - ret.ch.alpha = 0xFF; + LV_COLOR_SET_R32(ret, LV_COLOR_GET_R(color) * 36); /*(2^8 - 1)/(2^3 - 1) = 255/7 = 36*/ + LV_COLOR_SET_G32(ret, LV_COLOR_GET_G(color) * 36); /*(2^8 - 1)/(2^3 - 1) = 255/7 = 36*/ + LV_COLOR_SET_B32(ret, LV_COLOR_GET_B(color) * 85); /*(2^8 - 1)/(2^2 - 1) = 255/3 = 85*/ + LV_COLOR_SET_A32(color, 0xFF); return ret.full; #elif LV_COLOR_DEPTH == 16 /** @@ -367,10 +422,10 @@ static inline uint32_t lv_color_to32(lv_color_t color) * 6 259 3 0 255 */ lv_color32_t ret; - ret.ch.red = (LV_COLOR_GET_R(color) * 263 + 7 ) >> 5; - ret.ch.green = (LV_COLOR_GET_G(color) * 259 + 3 ) >> 6; - ret.ch.blue = (LV_COLOR_GET_B(color) * 263 + 7 ) >> 5; - ret.ch.alpha = 0xFF; + LV_COLOR_SET_R32(ret, (LV_COLOR_GET_R(color) * 263 + 7 ) >> 5); + LV_COLOR_SET_G32(ret, (LV_COLOR_GET_G(color) * 259 + 3 ) >> 6); + LV_COLOR_SET_B32(ret, (LV_COLOR_GET_B(color) * 263 + 7 ) >> 5); + LV_COLOR_SET_A32(ret, 0xFF); return ret.full; #elif LV_COLOR_DEPTH == 32 return color.full; @@ -385,9 +440,7 @@ static inline lv_color_t lv_color_mix(lv_color_t c1, lv_color_t c2, uint8_t mix) LV_COLOR_SET_R(ret, (uint16_t)((uint16_t) LV_COLOR_GET_R(c1) * mix + LV_COLOR_GET_R(c2) * (255 - mix)) >> 8); LV_COLOR_SET_G(ret, (uint16_t)((uint16_t) LV_COLOR_GET_G(c1) * mix + LV_COLOR_GET_G(c2) * (255 - mix)) >> 8); LV_COLOR_SET_B(ret, (uint16_t)((uint16_t) LV_COLOR_GET_B(c1) * mix + LV_COLOR_GET_B(c2) * (255 - mix)) >> 8); -#if LV_COLOR_DEPTH == 32 - ret.ch.alpha = 0xFF; -#endif + LV_COLOR_SET_A(ret, 0xFF); #else /*LV_COLOR_DEPTH == 1*/ ret.full = mix > LV_OPA_50 ? c1.full : c2.full; @@ -405,7 +458,7 @@ static inline uint8_t lv_color_brightness(lv_color_t color) { lv_color32_t c32; c32.full = lv_color_to32(color); - uint16_t bright = 3 * LV_COLOR_GET_R(c32) + LV_COLOR_GET_B(c32) + 4 * LV_COLOR_GET_G(c32); + uint16_t bright = 3 * LV_COLOR_GET_R32(c32) + LV_COLOR_GET_B32(c32) + 4 * LV_COLOR_GET_G32(c32); return (uint16_t)bright >> 3; } @@ -423,43 +476,36 @@ static inline lv_color_t lv_color_make(int r8, int g8, int b8) static inline lv_color_t lv_color_make(uint8_t r8, int g8, int b8) { lv_color_t color; - color.ch.blue = b8 >> 6; - color.ch.green = g8 >> 5; - color.ch.red = r8 >> 5; + LV_COLOR_SET_B(color, b8 >> 6); + LV_COLOR_SET_G(color, g8 >> 5); + LV_COLOR_SET_R(color, r8 >> 5); + LV_COLOR_SET_A(color, 0xFF); return color; } #elif LV_COLOR_DEPTH == 16 #if LV_COLOR_16_SWAP == 0 #define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{b8 >> 3, g8 >> 2, r8 >> 3}}) -static inline lv_color_t lv_color_make(uint8_t r8, uint8_t g8, uint8_t b8) -{ - lv_color_t color; - color.ch.blue = (uint16_t)(b8 >> 3); - color.ch.green = (uint16_t)(g8 >> 2); - color.ch.red = (uint16_t)(r8 >> 3); - return color; -} #else #define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{g8 >> 5, r8 >> 3, b8 >> 3, (g8 >> 2) & 0x7}}) +#endif static inline lv_color_t lv_color_make(uint8_t r8, uint8_t g8, uint8_t b8) { lv_color_t color; - color.ch.green_h = (uint16_t)(g8 >> 5); - color.ch.red = (uint16_t)(r8 >> 3); - color.ch.blue = (uint16_t)(b8 >> 3); - color.ch.green_l = (uint16_t)((g8 >> 2) & 0x7); + LV_COLOR_SET_B(color, b8 >> 3); + LV_COLOR_SET_G(color, g8 >> 2); + LV_COLOR_SET_R(color, r8 >> 3); + LV_COLOR_SET_A(color, 0xFF); return color; } -#endif #elif LV_COLOR_DEPTH == 32 #define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{b8, g8, r8, 0xff}}) /*Fix 0xff alpha*/ static inline lv_color_t lv_color_make(uint8_t r8, uint8_t g8, uint8_t b8) { lv_color_t color; - color.ch.blue = b8; - color.ch.green = g8; - color.ch.red = r8; - color.ch.alpha = 0xff; + LV_COLOR_SET_B(color, b8); + LV_COLOR_SET_G(color, g8); + LV_COLOR_SET_R(color, r8); + LV_COLOR_SET_A(color, 0xFF); return color; } #endif From 79f403ddc5a44a4176123ab569b982daabe4490f Mon Sep 17 00:00:00 2001 From: Brian Pugh Date: Mon, 11 Nov 2019 23:08:45 -0800 Subject: [PATCH 58/64] lv_txt enforce pretty wrapping when first word of a line is a long word. --- src/lv_misc/lv_txt.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/lv_misc/lv_txt.c b/src/lv_misc/lv_txt.c index a19a5ab44..14c2620ba 100644 --- a/src/lv_misc/lv_txt.c +++ b/src/lv_misc/lv_txt.c @@ -149,6 +149,9 @@ void lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t * * 3. Return i=9, pointing at breakchar '\n' * 4. Parenting lv_txt_get_next_line() would detect subsequent '\0' * + * TODO: Returned word_w_ptr may overestimate the returned word's width when + * max_width is reached. In current usage, this has no impact. + * * @param txt a '\0' terminated string * @param font pointer to a font * @param letter_space letter space @@ -232,19 +235,17 @@ static uint16_t lv_txt_get_next_word(const char * txt, const lv_font_t * font, return i; } - if( force ) { - return break_index; - } - #if LV_TXT_LINE_BREAK_LONG_LEN > 0 /* Word doesn't fit in provided space, but isn't "long" */ if(word_len < LV_TXT_LINE_BREAK_LONG_LEN) { + if( force ) return break_index; if(word_w_ptr != NULL) *word_w_ptr = 0; /* Return no word */ return 0; } /* Word is "long," but insufficient amounts can fit in provided space */ if(break_letter_count < LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN) { + if( force ) return break_index; if(word_w_ptr != NULL) *word_w_ptr = 0; return 0; } @@ -262,8 +263,9 @@ static uint16_t lv_txt_get_next_word(const char * txt, const lv_font_t * font, } return i; #else - (void) break_letter_count; + if( force ) return break_index; if(word_w_ptr != NULL) *word_w_ptr = 0; /* Return no word */ + (void) break_letter_count; return 0; #endif } From 3cd2120b60983a6cc6c34c55910d7115cdfe126f Mon Sep 17 00:00:00 2001 From: Mattia Maldini Date: Tue, 12 Nov 2019 13:07:26 +0100 Subject: [PATCH 59/64] Added rotation feature to the lmeter --- src/lv_objx/lv_lmeter.c | 17 ++++++++++++++++- src/lv_objx/lv_lmeter.h | 8 ++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/lv_objx/lv_lmeter.c b/src/lv_objx/lv_lmeter.c index 78f7a8e61..b77211009 100644 --- a/src/lv_objx/lv_lmeter.c +++ b/src/lv_objx/lv_lmeter.c @@ -168,6 +168,21 @@ void lv_lmeter_set_scale(lv_obj_t * lmeter, uint16_t angle, uint8_t line_cnt) lv_obj_invalidate(lmeter); } +/** + * Set the rotation settings of a line meter + * @param lmeter pointer to a line meter object + * @param angle angle of rotation (relative to the northen axis) + */ +void lv_lmeter_set_rotation(lv_obj_t * lmeter, uint16_t angle) +{ + lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter); + if(ext->rotation == angle) return; + + ext->rotation = angle; + + lv_obj_invalidate(lmeter); +} + /*===================== * Getter functions *====================*/ @@ -268,7 +283,7 @@ static bool lv_lmeter_design(lv_obj_t * lmeter, const lv_area_t * mask, lv_desig lv_coord_t x_ofs = lv_obj_get_width(lmeter) / 2 + lmeter->coords.x1; lv_coord_t y_ofs = lv_obj_get_height(lmeter) / 2 + lmeter->coords.y1; - int16_t angle_ofs = 90 + (360 - ext->scale_angle) / 2; + int16_t angle_ofs = ext->rotation + 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); uint8_t i; diff --git a/src/lv_objx/lv_lmeter.h b/src/lv_objx/lv_lmeter.h index e1a70a64f..ea7c08236 100644 --- a/src/lv_objx/lv_lmeter.h +++ b/src/lv_objx/lv_lmeter.h @@ -36,6 +36,7 @@ typedef struct /*No inherited ext.*/ /*Ext. of ancestor*/ /*New data for this type */ uint16_t scale_angle; /*Angle of the scale in deg. (0..360)*/ + uint16_t rotation; uint8_t line_cnt; /*Count of lines */ int16_t cur_value; int16_t min_value; @@ -88,6 +89,13 @@ void lv_lmeter_set_range(lv_obj_t * lmeter, int16_t min, int16_t max); */ void lv_lmeter_set_scale(lv_obj_t * lmeter, uint16_t angle, uint8_t line_cnt); +/** + * Set the rotation settings of a line meter + * @param lmeter pointer to a line meter object + * @param angle angle of rotation (relative to the northen axis) + */ +void lv_lmeter_set_rotation(lv_obj_t * lmeter, uint16_t angle); + /** * Set the styles of a line meter * @param lmeter pointer to a line meter object From b7c3732da73b5a0dd6c5dd33ef65f734d171d5cb Mon Sep 17 00:00:00 2001 From: Mattia Maldini Date: Tue, 12 Nov 2019 16:14:18 +0100 Subject: [PATCH 60/64] Different wording --- src/lv_objx/lv_lmeter.c | 12 ++++++------ src/lv_objx/lv_lmeter.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lv_objx/lv_lmeter.c b/src/lv_objx/lv_lmeter.c index b77211009..6e23f24ae 100644 --- a/src/lv_objx/lv_lmeter.c +++ b/src/lv_objx/lv_lmeter.c @@ -169,16 +169,16 @@ void lv_lmeter_set_scale(lv_obj_t * lmeter, uint16_t angle, uint8_t line_cnt) } /** - * Set the rotation settings of a line meter + * Set the angle settings of a line meter * @param lmeter pointer to a line meter object - * @param angle angle of rotation (relative to the northen axis) + * @param angle angle where the meter will be facing (with its center) */ -void lv_lmeter_set_rotation(lv_obj_t * lmeter, uint16_t angle) +void lv_lmeter_set_angle(lv_obj_t * lmeter, uint16_t angle) { lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter); - if(ext->rotation == angle) return; + if(ext->angle == angle) return; - ext->rotation = angle; + ext->angle = angle; lv_obj_invalidate(lmeter); } @@ -283,7 +283,7 @@ static bool lv_lmeter_design(lv_obj_t * lmeter, const lv_area_t * mask, lv_desig lv_coord_t x_ofs = lv_obj_get_width(lmeter) / 2 + lmeter->coords.x1; lv_coord_t y_ofs = lv_obj_get_height(lmeter) / 2 + lmeter->coords.y1; - int16_t angle_ofs = ext->rotation + 90 + (360 - ext->scale_angle) / 2; + int16_t angle_ofs = ext->angle + 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); uint8_t i; diff --git a/src/lv_objx/lv_lmeter.h b/src/lv_objx/lv_lmeter.h index ea7c08236..49d662819 100644 --- a/src/lv_objx/lv_lmeter.h +++ b/src/lv_objx/lv_lmeter.h @@ -36,7 +36,7 @@ typedef struct /*No inherited ext.*/ /*Ext. of ancestor*/ /*New data for this type */ uint16_t scale_angle; /*Angle of the scale in deg. (0..360)*/ - uint16_t rotation; + uint16_t angle; uint8_t line_cnt; /*Count of lines */ int16_t cur_value; int16_t min_value; @@ -94,7 +94,7 @@ void lv_lmeter_set_scale(lv_obj_t * lmeter, uint16_t angle, uint8_t line_cnt); * @param lmeter pointer to a line meter object * @param angle angle of rotation (relative to the northen axis) */ -void lv_lmeter_set_rotation(lv_obj_t * lmeter, uint16_t angle); +void lv_lmeter_set_angle(lv_obj_t * lmeter, uint16_t angle); /** * Set the styles of a line meter From 1e4ce0b14323ff97e5a9c58b7bb1d3a4a4615550 Mon Sep 17 00:00:00 2001 From: Pete Bone Date: Tue, 12 Nov 2019 15:26:35 +0000 Subject: [PATCH 61/64] Dev 6.1 Minor fixes lv_draw_arc.c -> line 218 Removed unsed fast_atan2() function which appears to have been moved to lv_math.c as lv_atan2() function. lv_font_heb_16.c -> line 1 Fixed inconsistent include path. lv_label.c -> line 734 Added (char*) cast to const char* variable 'txt' to silence compiler warning when LV_USE_BIDI is disabled. lv_style.c -> line 93 Removed this line lv_style.c -> line 97 Reverted this line to remove override of LV_FONT_DEFAULT defined in lv_conf.h --- src/lv_core/lv_style.c | 4 +- src/lv_draw/lv_draw_arc.c | 73 ------------------------------------ src/lv_font/lv_font_heb_16.c | 2 +- src/lv_objx/lv_label.c | 2 +- 4 files changed, 4 insertions(+), 77 deletions(-) diff --git a/src/lv_core/lv_style.c b/src/lv_core/lv_style.c index d86f262ef..718fa6b37 100644 --- a/src/lv_core/lv_style.c +++ b/src/lv_core/lv_style.c @@ -90,11 +90,11 @@ void lv_style_init(void) lv_style_scr.body.shadow.color = LV_COLOR_GRAY; lv_style_scr.body.shadow.type = LV_SHADOW_FULL; lv_style_scr.body.shadow.width = 0; - LV_FONT_DECLARE(lv_font_heb_16); + lv_style_scr.text.opa = LV_OPA_COVER; lv_style_scr.text.color = lv_color_make(0x30, 0x30, 0x30); lv_style_scr.text.sel_color = lv_color_make(0x55, 0x96, 0xd8); - lv_style_scr.text.font = &lv_font_heb_16;//LV_FONT_DEFAULT; + lv_style_scr.text.font = LV_FONT_DEFAULT; lv_style_scr.text.letter_space = 0; lv_style_scr.text.line_space = 2; diff --git a/src/lv_draw/lv_draw_arc.c b/src/lv_draw/lv_draw_arc.c index ed4192dfe..e42a67dbf 100644 --- a/src/lv_draw/lv_draw_arc.c +++ b/src/lv_draw/lv_draw_arc.c @@ -215,79 +215,6 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, cons } } -static uint16_t fast_atan2(int x, int y) -{ - // Fast XY vector to integer degree algorithm - Jan 2011 www.RomanBlack.com - // Converts any XY values including 0 to a degree value that should be - // within +/- 1 degree of the accurate value without needing - // large slow trig functions like ArcTan() or ArcCos(). - // NOTE! at least one of the X or Y values must be non-zero! - // This is the full version, for all 4 quadrants and will generate - // the angle in integer degrees from 0-360. - // Any values of X and Y are usable including negative values provided - // they are between -1456 and 1456 so the 16bit multiply does not overflow. - - unsigned char negflag; - unsigned char tempdegree; - unsigned char comp; - unsigned int degree; /*this will hold the result*/ - unsigned int ux; - unsigned int uy; - - /*Save the sign flags then remove signs and get XY as unsigned ints*/ - negflag = 0; - if(x < 0) { - negflag += 0x01; /*x flag bit*/ - x = (0 - x); /*is now +*/ - } - ux = x; /*copy to unsigned var before multiply*/ - if(y < 0) { - negflag += 0x02; /*y flag bit*/ - y = (0 - y); /*is now +*/ - } - uy = y; /*copy to unsigned var before multiply*/ - - /*1. Calc the scaled "degrees"*/ - if(ux > uy) { - degree = (uy * 45) / ux; /*degree result will be 0-45 range*/ - negflag += 0x10; /*octant flag bit*/ - } else { - degree = (ux * 45) / uy; /*degree result will be 0-45 range*/ - } - - /*2. Compensate for the 4 degree error curve*/ - comp = 0; - tempdegree = degree; /*use an unsigned char for speed!*/ - if(tempdegree > 22) { /*if top half of range*/ - if(tempdegree <= 44) comp++; - if(tempdegree <= 41) comp++; - if(tempdegree <= 37) comp++; - if(tempdegree <= 32) comp++; /*max is 4 degrees compensated*/ - } else { /*else is lower half of range*/ - if(tempdegree >= 2) comp++; - if(tempdegree >= 6) comp++; - if(tempdegree >= 10) comp++; - if(tempdegree >= 15) comp++; /*max is 4 degrees compensated*/ - } - degree += comp; /*degree is now accurate to +/- 1 degree!*/ - - /*Invert degree if it was X>Y octant, makes 0-45 into 90-45*/ - if(negflag & 0x10) degree = (90 - degree); - - /*3. Degree is now 0-90 range for this quadrant,*/ - /*need to invert it for whichever quadrant it was in*/ - if(negflag & 0x02) { /*if -Y*/ - if(negflag & 0x01) /*if -Y -X*/ - degree = (180 + degree); - else /*else is -Y +X*/ - degree = (180 - degree); - } else { /*else is +Y*/ - if(negflag & 0x01) /*if +Y -X*/ - degree = (360 - degree); - } - return degree; -} - /********************** * STATIC FUNCTIONS **********************/ diff --git a/src/lv_font/lv_font_heb_16.c b/src/lv_font/lv_font_heb_16.c index 5cff45178..b7723192e 100644 --- a/src/lv_font/lv_font_heb_16.c +++ b/src/lv_font/lv_font_heb_16.c @@ -1,4 +1,4 @@ -#include "lvgl/lvgl.h" +#include "../../lvgl.h" /******************************************************************************* * Size: 16 px diff --git a/src/lv_objx/lv_label.c b/src/lv_objx/lv_label.c index bd99c10c8..9d7072006 100644 --- a/src/lv_objx/lv_label.c +++ b/src/lv_objx/lv_label.c @@ -731,7 +731,7 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos) if(bidi_txt[new_line_start] == '\0') txt_len--; lv_bidi_process_paragraph(txt + line_start, bidi_txt, txt_len, lv_obj_get_base_dir(label), NULL, 0); #else - bidi_txt = txt + line_start; + bidi_txt = (char*)txt + line_start; #endif /*Calculate the x coordinate*/ From de102f9d20f6c8f429c9972e61bc5eeced0a5061 Mon Sep 17 00:00:00 2001 From: George Slater Date: Wed, 13 Nov 2019 11:54:05 -0600 Subject: [PATCH 62/64] Updated lv_refr_area and lv_img_design to account for single pixel height/width objects. lv_refr_area: Updated height for area refresh to correctly include areas that are a height of only 1 pixel. lv_img_design: Updated draw loop to account for objects that are 1 pixel in height or width. --- src/lv_core/lv_refr.c | 10 +++++----- src/lv_objx/lv_img.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lv_core/lv_refr.c b/src/lv_core/lv_refr.c index 7399835f5..5ee3fbb20 100644 --- a/src/lv_core/lv_refr.c +++ b/src/lv_core/lv_refr.c @@ -318,19 +318,19 @@ static void lv_refr_area(const lv_area_t * area_p) tmp.x2 = 0; tmp.y1 = 0; - lv_coord_t y_tmp = max_row - 1; + lv_coord_t h_tmp = max_row; do { - tmp.y2 = y_tmp; + tmp.y2 = h_tmp - 1; disp_refr->driver.rounder_cb(&disp_refr->driver, &tmp); /*If this height fits into `max_row` then fine*/ if(lv_area_get_height(&tmp) <= max_row) break; /*Decrement the height of the area until it fits into `max_row` after rounding*/ - y_tmp--; - } while(y_tmp != 0); + h_tmp--; + } while(h_tmp > 0); - if(y_tmp == 0) { + if(h_tmp <= 0) { LV_LOG_WARN("Can't set VDB height using the round function. (Wrong round_cb or to " "small VDB)"); return; diff --git a/src/lv_objx/lv_img.c b/src/lv_objx/lv_img.c index c62ad0b44..55e64e804 100644 --- a/src/lv_objx/lv_img.c +++ b/src/lv_objx/lv_img.c @@ -372,10 +372,10 @@ static bool lv_img_design(lv_obj_t * img, const lv_area_t * mask, lv_design_mode cords_tmp.y1 = coords.y1; cords_tmp.y2 = coords.y1 + ext->h - 1; - for(; cords_tmp.y1 < coords.y2; cords_tmp.y1 += ext->h, cords_tmp.y2 += ext->h) { + for(; cords_tmp.y1 <= coords.y2; cords_tmp.y1 += ext->h, cords_tmp.y2 += ext->h) { cords_tmp.x1 = coords.x1; cords_tmp.x2 = coords.x1 + ext->w - 1; - for(; cords_tmp.x1 < coords.x2; cords_tmp.x1 += ext->w, cords_tmp.x2 += ext->w) { + for(; cords_tmp.x1 <= coords.x2; cords_tmp.x1 += ext->w, cords_tmp.x2 += ext->w) { lv_draw_img(&cords_tmp, mask, ext->src, style, opa_scale); } } From 575df77a02d139b75ba75eda8d61edfef53102cc Mon Sep 17 00:00:00 2001 From: Themba Dube Date: Thu, 14 Nov 2019 20:38:47 -0500 Subject: [PATCH 63/64] Fix public -Wconversion warnings --- src/lv_core/lv_style.h | 2 +- src/lv_misc/lv_anim.h | 4 ++-- src/lv_misc/lv_area.h | 4 ++-- src/lv_misc/lv_color.h | 36 ++++++++++++++++++------------------ 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/lv_core/lv_style.h b/src/lv_core/lv_style.h index a334a4a5e..e002b2ea4 100644 --- a/src/lv_core/lv_style.h +++ b/src/lv_core/lv_style.h @@ -196,7 +196,7 @@ void lv_style_anim_set_styles(lv_anim_t * a, lv_style_t * to_anim, const lv_styl * @param duration duration of the animation in milliseconds * @param delay delay before the animation in milliseconds */ -static inline void lv_style_anim_set_time(lv_anim_t * a, uint16_t duration, uint16_t delay) +static inline void lv_style_anim_set_time(lv_anim_t * a, uint16_t duration, int16_t delay) { lv_anim_set_time(a, duration, delay); } diff --git a/src/lv_misc/lv_anim.h b/src/lv_misc/lv_anim.h index 299f7c455..36cc35adc 100644 --- a/src/lv_misc/lv_anim.h +++ b/src/lv_misc/lv_anim.h @@ -129,10 +129,10 @@ static inline void lv_anim_set_exec_cb(lv_anim_t * a, void * var, lv_anim_exec_x * @param duration duration of the animation in milliseconds * @param delay delay before the animation in milliseconds */ -static inline void lv_anim_set_time(lv_anim_t * a, uint16_t duration, uint16_t delay) +static inline void lv_anim_set_time(lv_anim_t * a, uint16_t duration, int16_t delay) { a->time = duration; - a->act_time = -delay; + a->act_time = (int16_t)(-delay); } /** diff --git a/src/lv_misc/lv_area.h b/src/lv_misc/lv_area.h index 7a827c91a..211bebd84 100644 --- a/src/lv_misc/lv_area.h +++ b/src/lv_misc/lv_area.h @@ -85,7 +85,7 @@ inline static void lv_area_copy(lv_area_t * dest, const lv_area_t * src) */ static inline lv_coord_t lv_area_get_width(const lv_area_t * area_p) { - return area_p->x2 - area_p->x1 + 1; + return (lv_coord_t)(area_p->x2 - area_p->x1 + 1); } /** @@ -95,7 +95,7 @@ static inline lv_coord_t lv_area_get_width(const lv_area_t * area_p) */ static inline lv_coord_t lv_area_get_height(const lv_area_t * area_p) { - return area_p->y2 - area_p->y1 + 1; + return (lv_coord_t)(area_p->y2 - area_p->y1 + 1); } /** diff --git a/src/lv_misc/lv_color.h b/src/lv_misc/lv_color.h index d45aa0a61..54b62aa2b 100644 --- a/src/lv_misc/lv_color.h +++ b/src/lv_misc/lv_color.h @@ -94,9 +94,9 @@ enum { * Macros for all existing color depths * to set/get values of the color channels *------------------------------------------*/ -# define LV_COLOR_SET_R1(c, v) (c).ch.red = (v) & 0x1; -# define LV_COLOR_SET_G1(c, v) (c).ch.green = (v) & 0x1; -# define LV_COLOR_SET_B1(c, v) (c).ch.blue = (v) & 0x1; +# define LV_COLOR_SET_R1(c, v) (c).ch.red = (uint8_t)((v) & 0x1); +# define LV_COLOR_SET_G1(c, v) (c).ch.green = (uint8_t)((v) & 0x1); +# define LV_COLOR_SET_B1(c, v) (c).ch.blue = (uint8_t)((v) & 0x1); # define LV_COLOR_SET_A1(c, v) # define LV_COLOR_GET_R1(c) (c).ch.red @@ -104,21 +104,21 @@ enum { # define LV_COLOR_GET_B1(c) (c).ch.blue # define LV_COLOR_GET_A1(c) 1 -# define LV_COLOR_SET_R8(c, v) (c).ch.red = (v) & 0x7; -# define LV_COLOR_SET_G8(c, v) (c).ch.green = (v) & 0x7; -# define LV_COLOR_SET_B8(c, v) (c).ch.blue = (v) & 0x3; -# define LV_COLOR_SET_A8(c, v) +# define LV_COLOR_SET_R8(c, v) (c).ch.red = (uint8_t)((v) & 0x7); +# define LV_COLOR_SET_G8(c, v) (c).ch.green = (uint8_t)((v) & 0x7); +# define LV_COLOR_SET_B8(c, v) (c).ch.blue = (uint8_t)((v) & 0x3); +# define LV_COLOR_SET_A8(c, v) do {} while(0) # define LV_COLOR_GET_R8(c) (c).ch.red # define LV_COLOR_GET_G8(c) (c).ch.green # define LV_COLOR_GET_B8(c) (c).ch.blue # define LV_COLOR_GET_A8(c) 0xFF -# define LV_COLOR_SET_R16(c, v) (c).ch.red = (v) & 0x1F; -# define LV_COLOR_SET_G16(c, v) (c).ch.green = (v) & 0x3F; -# define LV_COLOR_SET_G16_SWAP(c, v) {(c).ch.green_h = ((v) >> 3) & 0x7; (c).ch.green_l = (v) & 0x7;} -# define LV_COLOR_SET_B16(c, v) (c).ch.blue = (v) & 0x1F; -# define LV_COLOR_SET_A16(c, v) +# define LV_COLOR_SET_R16(c, v) (c).ch.red = (uint16_t)((v) & 0x1F); +# define LV_COLOR_SET_G16(c, v) (c).ch.green = (uint16_t)((v) & 0x3F); +# define LV_COLOR_SET_G16_SWAP(c, v) {(c).ch.green_h = (uint16_t)(((v) >> 3) & 0x7); (c).ch.green_l = (uint16_t)((v) & 0x7);} +# define LV_COLOR_SET_B16(c, v) (c).ch.blue = (uint16_t)((v) & 0x1F); +# define LV_COLOR_SET_A16(c, v) do {} while(0) # define LV_COLOR_GET_R16(c) (c).ch.red # define LV_COLOR_GET_G16(c) (c).ch.green @@ -126,10 +126,10 @@ enum { # define LV_COLOR_GET_B16(c) (c).ch.blue # define LV_COLOR_GET_A16(c) 0xFF -# define LV_COLOR_SET_R32(c, v) (c).ch.red = (v) & 0xFF; -# define LV_COLOR_SET_G32(c, v) (c).ch.green = (v) & 0xFF; -# define LV_COLOR_SET_B32(c, v) (c).ch.blue = (v) & 0xFF; -# define LV_COLOR_SET_A32(c, v) (c).ch.alpha = (v) & 0xFF; +# define LV_COLOR_SET_R32(c, v) (c).ch.red = (uint32_t)((v) & 0xFF); +# define LV_COLOR_SET_G32(c, v) (c).ch.green = (uint32_t)((v) & 0xFF); +# define LV_COLOR_SET_B32(c, v) (c).ch.blue = (uint32_t)((v) & 0xFF); +# define LV_COLOR_SET_A32(c, v) (c).ch.alpha = (uint32_t)((v) & 0xFF); # define LV_COLOR_GET_R32(c) (c).ch.red # define LV_COLOR_GET_G32(c) (c).ch.green @@ -458,8 +458,8 @@ static inline uint8_t lv_color_brightness(lv_color_t color) { lv_color32_t c32; c32.full = lv_color_to32(color); - uint16_t bright = 3 * LV_COLOR_GET_R32(c32) + LV_COLOR_GET_B32(c32) + 4 * LV_COLOR_GET_G32(c32); - return (uint16_t)bright >> 3; + uint16_t bright = (uint16_t)(3u * LV_COLOR_GET_R32(c32) + LV_COLOR_GET_B32(c32) + 4u * LV_COLOR_GET_G32(c32)); + return (uint8_t)(bright >> 3); } /* The most simple macro to create a color from R,G and B values */ From bf5ea6658b4dfcca032ac8a89ae0d90c3320b2cb Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 15 Nov 2019 06:30:45 +0100 Subject: [PATCH 64/64] update lv_conf_checker.h --- src/lv_conf_checker.h | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/lv_conf_checker.h b/src/lv_conf_checker.h index fe67fbdfc..4c9a08d3e 100644 --- a/src/lv_conf_checker.h +++ b/src/lv_conf_checker.h @@ -269,9 +269,11 @@ /* Export integer constant to binding. * This macro is used with constants in the form of LV_ that * should also appear on lvgl binding API such as Micropython + * + * The default value just prevents a GCC warning. */ #ifndef LV_EXPORT_CONST_INT -#define LV_EXPORT_CONST_INT(int_value) +#define LV_EXPORT_CONST_INT(int_value) struct _silence_gcc_warning #endif /*=================== @@ -314,7 +316,7 @@ #endif /* 1: Print the log with 'printf'; - * 0: user need to register a callback with `lv_log_register_print`*/ + * 0: user need to register a callback with `lv_log_register_print_cb`*/ #ifndef LV_LOG_PRINTF # define LV_LOG_PRINTF 0 #endif @@ -473,21 +475,25 @@ #define LV_TXT_BREAK_CHARS " ,.;:-_" #endif - /* If a character is at least this long, will break wherever "prettiest" */ + +/* If a word is at least this long, will break wherever "prettiest" + * To disable, set to a value <= 0 */ #ifndef LV_TXT_LINE_BREAK_LONG_LEN #define LV_TXT_LINE_BREAK_LONG_LEN 12 #endif - /* Minimum number of characters of a word to put on a line before a break */ +/* Minimum number of characters in a long word to put on a line before a break. + * Depends on LV_TXT_LINE_BREAK_LONG_LEN. */ #ifndef LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN - #define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3 +#define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3 #endif - /* Minimum number of characters of a word to put on a line after a break */ +/* Minimum number of characters in a long word to put on a line after a break. + * Depends on LV_TXT_LINE_BREAK_LONG_LEN. */ #ifndef LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN - #define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 3 +#define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 3 #endif - + /* Support bidirectional texts. * Allows mixing Left-to-Right and Right-to-Left texts. * The direction will be processed according to the Unicode Bidirectioanl Algorithm: