Merge branch 'dev-5.3' into mixed

This commit is contained in:
Gabor Kiss-Vamosi
2019-01-23 14:44:18 +01:00
7 changed files with 144 additions and 28 deletions

7
.editorconfig Normal file
View File

@@ -0,0 +1,7 @@
[*.{c,h}]
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

View File

@@ -29,7 +29,7 @@ In the simplest case you need 5 things:
3. Register a function which can **read an input device**. (E.g. touch pad) 3. Register a function which can **read an input device**. (E.g. touch pad)
4. Copy `lv_conf_templ.h` as `lv_conf.h` and set at least `LV_HOR_RES`, `LV_VER_RES` and `LV_COLOR_DEPTH`. 4. Copy `lv_conf_templ.h` as `lv_conf.h` and set at least `LV_HOR_RES`, `LV_VER_RES` and `LV_COLOR_DEPTH`.
5. Call `lv_task_handler()` periodically every few milliseconds. 5. Call `lv_task_handler()` periodically every few milliseconds.
For a detailed description visit https://github.com/littlevgl/lvgl/wiki/Porting For a detailed description visit https://docs.littlevgl.com/#Porting
Or check the [Porting tutorial](https://github.com/littlevgl/lv_examples/blob/master/lv_tutorial/0_porting/lv_tutorial_porting.c) Or check the [Porting tutorial](https://github.com/littlevgl/lv_examples/blob/master/lv_tutorial/0_porting/lv_tutorial_porting.c)
## Project set-up ## Project set-up

View File

@@ -371,7 +371,7 @@
/************************* /*************************
* Non-user section * Non-user section
*************************/ *************************/
#ifdef _MSC_VER /* Disable warnings for Visual Studio*/ #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) /* Disable warnings for Visual Studio*/
#define _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS
#endif #endif

View File

@@ -157,7 +157,6 @@ uint16_t lv_anim_speed_to_time(uint16_t speed, int32_t start, int32_t end)
int32_t lv_anim_path_linear(const lv_anim_t * a) int32_t lv_anim_path_linear(const lv_anim_t * a)
{ {
/*Calculate the current step*/ /*Calculate the current step*/
uint16_t step; uint16_t step;
if(a->time == a->act_time) step = LV_ANIM_RESOLUTION; /*Use the last value if the time fully elapsed*/ if(a->time == a->act_time) step = LV_ANIM_RESOLUTION; /*Use the last value if the time fully elapsed*/
else step = (a->act_time * LV_ANIM_RESOLUTION) / a->time; else step = (a->act_time * LV_ANIM_RESOLUTION) / a->time;
@@ -172,6 +171,53 @@ int32_t lv_anim_path_linear(const lv_anim_t * a)
return new_value; return new_value;
} }
/**
* Calculate the current value of an animation slowing down the start phase
* @param a pointer to an animation
* @return the current value to set
*/
int32_t lv_anim_path_ease_in(const lv_anim_t * a)
{
/*Calculate the current step*/
uint32_t t;
if(a->time == a->act_time) t = 1024;
else t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time;
int32_t step = lv_bezier3(t, 0, 1, 1, 1024);
int32_t new_value;
new_value = (int32_t) step * (a->end - a->start);
new_value = new_value >> 10;
new_value += a->start;
return new_value;
}
/**
* Calculate the current value of an animation slowing down the end phase
* @param a pointer to an animation
* @return the current value to set
*/
int32_t lv_anim_path_ease_out(const lv_anim_t * a)
{
/*Calculate the current step*/
uint32_t t;
if(a->time == a->act_time) t = 1024;
else t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time;
int32_t step = lv_bezier3(t, 0, 1023, 1023, 1024);
int32_t new_value;
new_value = (int32_t) step * (a->end - a->start);
new_value = new_value >> 10;
new_value += a->start;
return new_value;
}
/** /**
* Calculate the current value of an animation applying an "S" characteristic (cosine) * Calculate the current value of an animation applying an "S" characteristic (cosine)
* @param a pointer to an animation * @param a pointer to an animation

View File

@@ -121,6 +121,19 @@ uint16_t lv_anim_speed_to_time(uint16_t speed, int32_t start, int32_t end);
*/ */
int32_t lv_anim_path_linear(const lv_anim_t *a); int32_t lv_anim_path_linear(const lv_anim_t *a);
/**
* Calculate the current value of an animation slowing down the start phase
* @param a pointer to an animation
* @return the current value to set
*/
int32_t lv_anim_path_ease_in(const lv_anim_t * a);
/**
* Calculate the current value of an animation slowing down the end phase
* @param a pointer to an animation
* @return the current value to set
*/
int32_t lv_anim_path_ease_out(const lv_anim_t * a);
/** /**
* Calculate the current value of an animation applying an "S" characteristic (cosine) * Calculate the current value of an animation applying an "S" characteristic (cosine)

View File

@@ -123,26 +123,66 @@ void lv_canvas_set_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t
* @param x left side of the destination position * @param x left side of the destination position
* @param y top side of the destination position * @param y top side of the destination position
*/ */
void lv_canvas_copy_to_buf(lv_obj_t * canvas, void * to_copy, lv_coord_t w, lv_coord_t h, lv_coord_t x, lv_coord_t y) void lv_canvas_copy_buf(lv_obj_t * canvas, void * to_copy, lv_coord_t w, lv_coord_t h, lv_coord_t x, lv_coord_t y)
{ {
lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas); lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
if(x + w >= ext->dsc.header.w || y + h >= ext->dsc.header.h) { if(x + w >= ext->dsc.header.w || y + h >= ext->dsc.header.h) {
LV_LOG_WARN("lv_canvas_copy_to_buf: x or y out of the canvas"); LV_LOG_WARN("lv_canvas_copy_buf: x or y out of the canvas");
return; return;
} }
uint32_t px_size = lv_img_color_format_get_px_size(ext->dsc.header.cf) >> 3;
uint32_t px = ext->dsc.header.w * y * px_size + x * px_size;
uint8_t * to_copy8 = (uint8_t *) to_copy;
lv_coord_t i;
for(i = 0; i < h; i++) {
memcpy(&ext->dsc.data[px], to_copy8, w * px_size);
px += ext->dsc.header.w * px_size;
to_copy8 += w * px_size;
}
uint32_t px_size = lv_img_color_format_get_px_size(ext->dsc.header.cf) >> 3;
uint32_t px = ext->dsc.header.w * y * px_size + x * px_size;
uint8_t * to_copy8 = (uint8_t *) to_copy;
lv_coord_t i;
for(i = 0; i < h; i++) {
memcpy(&ext->dsc.data[px], to_copy8, w * px_size);
px += ext->dsc.header.w * px_size;
to_copy8 += w * px_size;
}
} }
/**
* Multiply a buffer with the canvas
* @param canvas pointer to a canvas object
* @param to_copy buffer to copy (multiply). LV_IMG_CF_TRUE_COLOR_ALPHA is not supported
* @param w width of the buffer to copy
* @param h height of the buffer to copy
* @param x left side of the destination position
* @param y top side of the destination position
*/
void lv_canvas_mult_buf(lv_obj_t * canvas, void * to_copy, lv_coord_t w, lv_coord_t h, lv_coord_t x, lv_coord_t y)
{
lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
if(x + w >= ext->dsc.header.w || y + h >= ext->dsc.header.h) {
LV_LOG_WARN("lv_canvas_mult_buf: x or y out of the canvas");
return;
}
if(ext->dsc.header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) {
LV_LOG_WARN("lv_canvas_mult_buf: LV_IMG_CF_TRUE_COLOR_ALPHA is not supported");
return;
}
uint32_t px_size = lv_img_color_format_get_px_size(ext->dsc.header.cf) >> 3;
uint32_t px = ext->dsc.header.w * y * px_size + x * px_size;
lv_color_t * copy_buf_color = (lv_color_t *) to_copy;
lv_color_t * canvas_buf_color = (lv_color_t *) &ext->dsc.data[px];
lv_coord_t i;
lv_coord_t j;
for(i = 0; i < h; i++) {
for(j = 0; j < w; j++) {
canvas_buf_color[j].red = (uint16_t) ((uint16_t) canvas_buf_color[j].red * copy_buf_color[j].red) >> 8;
canvas_buf_color[j].green = (uint16_t) ((uint16_t) canvas_buf_color[j].green * copy_buf_color[j].green) >> 8;
canvas_buf_color[j].blue = (uint16_t) ((uint16_t) canvas_buf_color[j].blue * copy_buf_color[j].blue) >> 8;
}
copy_buf_color += w;
canvas_buf_color += ext->dsc.header.w;
}
}
/*===================== /*=====================
* Setter functions * Setter functions
*====================*/ *====================*/
@@ -183,9 +223,9 @@ void lv_canvas_set_buffer(lv_obj_t * canvas, void * buf, lv_coord_t w, lv_coord_
void lv_canvas_set_style(lv_obj_t * canvas, lv_canvas_style_t type, lv_style_t * style) void lv_canvas_set_style(lv_obj_t * canvas, lv_canvas_style_t type, lv_style_t * style)
{ {
switch(type) { switch(type) {
case LV_CANVAS_STYLE_MAIN: case LV_CANVAS_STYLE_MAIN:
lv_img_set_style(canvas, style); lv_img_set_style(canvas, style);
break; break;
} }
} }
@@ -205,11 +245,11 @@ lv_style_t * lv_canvas_get_style(const lv_obj_t * canvas, lv_canvas_style_t type
lv_style_t * style = NULL; lv_style_t * style = NULL;
switch(type) { switch(type) {
case LV_CANVAS_STYLE_MAIN: case LV_CANVAS_STYLE_MAIN:
style = lv_img_get_style(canvas); style = lv_img_get_style(canvas);
break; break;
default: default:
style = NULL; style = NULL;
} }
return style; return style;
@@ -239,7 +279,6 @@ static lv_res_t lv_canvas_signal(lv_obj_t * canvas, lv_signal_t sign, void * par
res = ancestor_signal(canvas, sign, param); res = ancestor_signal(canvas, sign, param);
if(res != LV_RES_OK) return res; 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')*/ /*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
} else if(sign == LV_SIGNAL_GET_TYPE) { } else if(sign == LV_SIGNAL_GET_TYPE) {

View File

@@ -80,7 +80,18 @@ void lv_canvas_set_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t
* @param x left side of the destination position * @param x left side of the destination position
* @param y top side of the destination position * @param y top side of the destination position
*/ */
void lv_canvas_copy_to_buf(lv_obj_t * canvas, void * to_copy, lv_coord_t w, lv_coord_t h, lv_coord_t x, lv_coord_t y); void lv_canvas_copy_buf(lv_obj_t * canvas, void * to_copy, lv_coord_t w, lv_coord_t h, lv_coord_t x, lv_coord_t y);
/**
* Multiply a buffer with the canvas
* @param canvas pointer to a canvas object
* @param to_copy buffer to copy (multiply). LV_IMG_CF_TRUE_COLOR_ALPHA is not supported
* @param w width of the buffer to copy
* @param h height of the buffer to copy
* @param x left side of the destination position
* @param y top side of the destination position
*/
void lv_canvas_mult_buf(lv_obj_t * canvas, void * to_copy, lv_coord_t w, lv_coord_t h, lv_coord_t x, lv_coord_t y);
/*===================== /*=====================
* Setter functions * Setter functions