Merge master

This commit is contained in:
Gabor Kiss-Vamosi
2021-03-16 16:32:58 +01:00
11 changed files with 2635 additions and 13 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ extern "C" {
#define LVGL_VERSION_MAJOR 8
#define LVGL_VERSION_MINOR 0
#define LVGL_VERSION_PATCH 0
#define LVGL_VERSION_INFO "dev"
#define LVGL_VERSION_INFO ""
/*********************
* INCLUDES
+12 -8
View File
@@ -818,7 +818,7 @@ static void draw_buf_rotate_90_sqr(bool is_270, lv_coord_t w, lv_color_t * color
&color_p[inv_j * w + i]
);
}
}
}
}
@@ -848,7 +848,8 @@ static void draw_buf_rotate(lv_area_t *area, lv_color_t *color_p) {
if(drv->rotated == LV_DISP_ROT_90) {
area->y2 = drv->ver_res - area->x1 - 1;
area->y1 = area->y2 - area_w + 1;
} else {
}
else {
area->y1 = area->x1;
area->y2 = area->y1 + area_w - 1;
}
@@ -864,20 +865,23 @@ static void draw_buf_rotate(lv_area_t *area, lv_color_t *color_p) {
draw_buf_rotate_90_sqr(drv->rotated == LV_DISP_ROT_270, area_w, color_p);
if(drv->rotated == LV_DISP_ROT_90) {
area->x1 = init_y_off;
area->x2 = init_y_off+area_w-1;
} else {
area->x2 = init_y_off + area_w - 1;
}
else {
area->x2 = drv->hor_res - 1 - init_y_off;
area->x1 = area->x2 - area_w + 1;
}
} else {
}
else {
/*Rotate other areas using a maximum buffer size*/
if(rot_buf == NULL) rot_buf = lv_mem_buf_get(LV_DISP_ROT_MAX_BUF);
draw_buf_rotate_90(drv->rotated == LV_DISP_ROT_270, area_w, height, color_p, rot_buf);
if(drv->rotated == LV_DISP_ROT_90) {
area->x1 = init_y_off+row;
area->x2 = init_y_off+row+height-1;
} else {
area->x1 = init_y_off + row;
area->x2 = init_y_off + row + height - 1;
}
else {
area->x2 = drv->hor_res - 1 - init_y_off - row;
area->x1 = area->x2 - height + 1;
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -34,7 +34,7 @@
* STATIC PROTOTYPES
**********************/
#if LV_IMG_CACHE_DEF_SIZE
static bool lv_img_cache_match(const void * src1, const void * src2);
static bool lv_img_cache_match(const void * src1, const void * src2);
#endif
/**********************
+9
View File
@@ -182,6 +182,15 @@ bool lv_anim_del(void * var, lv_anim_exec_xcb_t exec_cb)
return del;
}
/**
* Delete all the animations animation
*/
void lv_anim_del_all(void)
{
_lv_ll_clear(&LV_GC_ROOT(_lv_anim_ll));
anim_mark_list_change();
}
/**
* Get the animation of a variable and its `exec_cb`.
* @param var pointer to variable
+5
View File
@@ -323,6 +323,11 @@ static inline uint32_t lv_anim_get_delay(lv_anim_t * a)
*/
bool lv_anim_del(void * var, lv_anim_exec_xcb_t exec_cb);
/**
* Delete all the animations animation
*/
void lv_anim_del_all(void);
/**
* Get the animation of a variable and its `exec_cb`.
* @param var pointer to variable
+2 -1
View File
@@ -383,7 +383,8 @@ static void draw_indic(lv_obj_t * obj, const lv_area_t * clip_area)
*axis1 = *axis2;
*axis2 = zero;
}
} else {
}
else {
zero = *axis2 - shift + 1;
if(*axis1 > zero)
*axis2 = zero;
+2 -2
View File
@@ -921,7 +921,7 @@ static void lv_label_refr_text(lv_obj_t * obj)
if (base_dir == LV_BIDI_DIR_AUTO)
base_dir = _lv_bidi_detect_base_dir(label->text);
if (base_dir == LV_BIDI_DIR_RTL) {
if(base_dir == LV_BIDI_DIR_RTL) {
start = lv_area_get_width(&txt_coords) - size.x;
end = 0;
}
@@ -1019,7 +1019,7 @@ static void lv_label_refr_text(lv_obj_t * obj)
if (base_dir == LV_BIDI_DIR_AUTO)
base_dir = _lv_bidi_detect_base_dir(label->text);
if (base_dir == LV_BIDI_DIR_RTL) {
if(base_dir == LV_BIDI_DIR_RTL) {
start = -size.x - lv_font_get_glyph_width(font, ' ', ' ') * LV_LABEL_WAIT_CHAR_COUNT;
end = 0;
}
+244
View File
@@ -0,0 +1,244 @@
/**
* @file lv_led.c
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_led.h"
#if LV_USE_LED != 0
#include "../lv_misc/lv_debug.h"
#include "../lv_themes/lv_theme.h"
#include "../lv_draw/lv_draw.h"
/*********************
* DEFINES
*********************/
#define LV_OBJX_NAME "lv_led"
#define LV_LED_WIDTH_DEF (LV_DPI / 3)
#define LV_LED_HEIGHT_DEF (LV_DPI / 3)
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
static lv_design_res_t lv_led_design(lv_obj_t * led, const lv_area_t * clip_area, lv_design_mode_t mode);
static lv_res_t lv_led_signal(lv_obj_t * led, lv_signal_t sign, void * param);
/**********************
* STATIC VARIABLES
**********************/
static lv_design_cb_t ancestor_design;
static lv_signal_cb_t ancestor_signal;
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/**
* Create a led objects
* @param par pointer to an object, it will be the parent of the new led
* @param copy pointer to a led object, if not NULL then the new object will be copied from it
* @return pointer to the created led
*/
lv_obj_t * lv_led_create(lv_obj_t * par, const lv_obj_t * copy)
{
LV_LOG_TRACE("led create started");
/*Create the ancestor basic object*/
lv_obj_t * led = lv_obj_create(par, copy);
LV_ASSERT_MEM(led);
if(led == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(led);
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(led);
/*Allocate the object type specific extended data*/
lv_led_ext_t * ext = lv_obj_allocate_ext_attr(led, sizeof(lv_led_ext_t));
LV_ASSERT_MEM(ext);
if(ext == NULL) {
lv_obj_del(led);
return NULL;
}
ext->bright = LV_LED_BRIGHT_MAX;
lv_obj_set_signal_cb(led, lv_led_signal);
lv_obj_set_design_cb(led, lv_led_design);
/*Init the new led object*/
if(copy == NULL) {
lv_obj_set_size(led, LV_LED_WIDTH_DEF, LV_LED_HEIGHT_DEF);
lv_theme_apply(led, LV_THEME_LED);
}
/*Copy an existing object*/
else {
lv_led_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
ext->bright = copy_ext->bright;
/*Refresh the style with new signal function*/
lv_obj_refresh_style(led, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
}
LV_LOG_INFO("led created");
return led;
}
/*=====================
* Setter functions
*====================*/
/**
* Set the brightness of a LED object
* @param led pointer to a LED object
* @param bright LV_LED_BRIGHT_MIN (max. dark) ... LV_LED_BRIGHT_MAX (max. light)
*/
void lv_led_set_bright(lv_obj_t * led, uint8_t bright)
{
LV_ASSERT_OBJ(led, LV_OBJX_NAME);
/*Set the brightness*/
lv_led_ext_t * ext = lv_obj_get_ext_attr(led);
if(ext->bright == bright) return;
if(bright <= LV_LED_BRIGHT_MIN) bright = LV_LED_BRIGHT_MIN;
if(bright >= LV_LED_BRIGHT_MAX) bright = LV_LED_BRIGHT_MAX;
ext->bright = bright;
/*Invalidate the object there fore it will be redrawn*/
lv_obj_invalidate(led);
}
/**
* Light on a LED
* @param led pointer to a LED object
*/
void lv_led_on(lv_obj_t * led)
{
LV_ASSERT_OBJ(led, LV_OBJX_NAME);
lv_led_set_bright(led, LV_LED_BRIGHT_MAX);
}
/**
* Light off a LED
* @param led pointer to a LED object
*/
void lv_led_off(lv_obj_t * led)
{
LV_ASSERT_OBJ(led, LV_OBJX_NAME);
lv_led_set_bright(led, LV_LED_BRIGHT_MIN);
}
/**
* Toggle the state of a LED
* @param led pointer to a LED object
*/
void lv_led_toggle(lv_obj_t * led)
{
LV_ASSERT_OBJ(led, LV_OBJX_NAME);
uint8_t bright = lv_led_get_bright(led);
if(bright > (LV_LED_BRIGHT_MIN + LV_LED_BRIGHT_MAX) >> 1)
lv_led_off(led);
else
lv_led_on(led);
}
/*=====================
* Getter functions
*====================*/
/**
* Get the brightness of a LEd object
* @param led pointer to LED object
* @return bright 0 (max. dark) ... 255 (max. light)
*/
uint8_t lv_led_get_bright(const lv_obj_t * led)
{
LV_ASSERT_OBJ(led, LV_OBJX_NAME);
lv_led_ext_t * ext = lv_obj_get_ext_attr(led);
return ext->bright;
}
/**********************
* STATIC FUNCTIONS
**********************/
/**
* Handle the drawing related tasks of the leds
* @param led pointer to an object
* @param clip_area the object will be drawn only in this area
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
* (return 'true' if yes)
* LV_DESIGN_DRAW: draw the object (always return 'true')
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
* @param return an element of `lv_design_res_t`
*/
static lv_design_res_t lv_led_design(lv_obj_t * led, const lv_area_t * clip_area, lv_design_mode_t mode)
{
if(mode == LV_DESIGN_COVER_CHK) {
/*Return false if the object is not covers the clip_area area*/
return ancestor_design(led, clip_area, mode);
}
else if(mode == LV_DESIGN_DRAW_MAIN) {
/*Make darker colors in a temporary style according to the brightness*/
lv_led_ext_t * ext = lv_obj_get_ext_attr(led);
lv_draw_rect_dsc_t rect_dsc;
lv_draw_rect_dsc_init(&rect_dsc);
lv_obj_init_draw_rect_dsc(led, LV_LED_PART_MAIN, &rect_dsc);
/*Mix. the color with black proportionally with brightness*/
rect_dsc.bg_color = lv_color_mix(rect_dsc.bg_color, LV_COLOR_BLACK, ext->bright);
rect_dsc.bg_grad_color = lv_color_mix(rect_dsc.bg_grad_color, LV_COLOR_BLACK, ext->bright);
rect_dsc.border_color = lv_color_mix(rect_dsc.border_color, LV_COLOR_BLACK, ext->bright);
rect_dsc.shadow_color = lv_color_mix(rect_dsc.shadow_color, LV_COLOR_BLACK, ext->bright);
/*Set the current shadow width according to brightness proportionally between LV_LED_BRIGHT_OFF
* and LV_LED_BRIGHT_ON*/
rect_dsc.shadow_width = ((ext->bright - LV_LED_BRIGHT_MIN) * rect_dsc.shadow_width) /
(LV_LED_BRIGHT_MAX - LV_LED_BRIGHT_MIN);
rect_dsc.shadow_spread = ((ext->bright - LV_LED_BRIGHT_MIN) * rect_dsc.shadow_spread) /
(LV_LED_BRIGHT_MAX - LV_LED_BRIGHT_MIN);
lv_draw_rect(&led->coords, clip_area, &rect_dsc);
}
return LV_DESIGN_RES_OK;
}
/**
* Signal function of the led
* @param led pointer to a led object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
* @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted
*/
static lv_res_t lv_led_signal(lv_obj_t * led, lv_signal_t sign, void * param)
{
lv_res_t res;
/* Include the ancient signal function */
res = ancestor_signal(led, sign, param);
if(res != LV_RES_OK) return res;
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
return res;
}
#endif
File diff suppressed because it is too large Load Diff