Skip to content

Commit

Permalink
Merge branch 'dev-6.1' into feat-cpicker
Browse files Browse the repository at this point in the history
  • Loading branch information
embeddedt committed Oct 13, 2019
2 parents 34faac9 + dcc287c commit 7f5ce8c
Show file tree
Hide file tree
Showing 33 changed files with 140 additions and 59 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ You can use the [Simulators](https://docs.littlevgl.com/en/html/get-started/pc-s

1. [Download](https://littlevgl.com/download) or [Clone](https://github.com/littlevgl/lvgl) the library
2. Copy the `lvgl` folder into your project
3. Copy `lvgl/lv_conf_templ.h` as `lv_conf.h` next to the `lvgl` folder and set at least `LV_HOR_RES_MAX`, `LV_VER_RES_MAX` and `LV_COLOR_DEPTH`.
3. Copy `lvgl/lv_conf_template.h` as `lv_conf.h` next to the `lvgl` folder and set at least `LV_HOR_RES_MAX`, `LV_VER_RES_MAX` and `LV_COLOR_DEPTH`.
4. Include `lvgl/lvgl.h` where you need to use LittlevGL related functions.
5. Call `lv_tick_inc(x)` every `x` milliseconds **in a Timer or Task** (`x` should be between 1 and 10). It is required for the internal timing of LittlevGL.
6. Call `lv_init()`
Expand Down
6 changes: 6 additions & 0 deletions lv_conf_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ typedef void * lv_img_decoder_user_data_t;
* font's bitmaps */
#define LV_ATTRIBUTE_LARGE_CONST

/* Export integer constant to binding.
* This macro is used with constants in the form of LV_<CONST> that
* should also appear on lvgl binding API such as Micropython
*/
#define LV_EXPORT_CONST_INT(int_value)

/*===================
* HAL settings
*==================*/
Expand Down
6 changes: 5 additions & 1 deletion scripts/lv_conf_checker.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python3.6

'''
Generates a checker file for lv_conf.h from lv_conf_templ.h define all the not defined values
'''
Expand Down Expand Up @@ -34,9 +36,11 @@
if '/*--END OF LV_CONF_H--*/' in i: break

r = re.search(r'^ *# *define ([^\s]+).*$', i)

if r:
line = re.sub('\(.*?\)', '', r[1], 1) #remove parentheses from macros
fout.write(
f'#ifndef {r[1]}\n'
f'#ifndef {line}\n'
f'{i}\n'
'#endif\n'
)
Expand Down
8 changes: 8 additions & 0 deletions src/lv_conf_checker.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,14 @@
#define LV_ATTRIBUTE_LARGE_CONST
#endif

/* Export integer constant to binding.
* This macro is used with constants in the form of LV_<CONST> that
* should also appear on lvgl binding API such as Micropython
*/
#ifndef LV_EXPORT_CONST_INT
#define LV_EXPORT_CONST_INT(int_value)
#endif

/*===================
* HAL settings
*==================*/
Expand Down
1 change: 1 addition & 0 deletions src/lv_core/lv_core.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CSRCS += lv_disp.c
CSRCS += lv_obj.c
CSRCS += lv_refr.c
CSRCS += lv_style.c
CSRCS += lv_debug.c

DEPPATH += --dep-path $(LVGL_DIR)/lvgl/src/lv_core
VPATH += :$(LVGL_DIR)/lvgl/src/lv_core
Expand Down
18 changes: 2 additions & 16 deletions src/lv_core/lv_obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <stdint.h>
#include <string.h>
#include "../lv_misc/lv_gc.h"
#include "../lv_misc/lv_math.h"

#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
Expand Down Expand Up @@ -1115,21 +1116,6 @@ void lv_obj_set_auto_realign(lv_obj_t * obj, bool en)
#endif
}

#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY
/**
* Set the size of an extended clickable area
* @param obj pointer to an object
* @param w extended width to both sides
* @param h extended height to both sides
*/
void lv_obj_set_ext_click_area(lv_obj_t * obj, uint8_t w, uint8_t h)
{
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);

obj->ext_click_pad_hor = w;
obj->ext_click_pad_ver = h;
}
#endif

/**
* Set the size of an extended clickable area
Expand Down Expand Up @@ -1913,7 +1899,7 @@ lv_coord_t lv_obj_get_ext_click_pad_bottom(const lv_obj_t * obj)
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);

#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY
return obj->ext_click_pad_ver
return obj->ext_click_pad_ver;
#elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL
return obj->ext_click_pad.y2;
#else
Expand Down
2 changes: 2 additions & 0 deletions src/lv_core/lv_style.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ extern "C" {
#define LV_RADIUS_CIRCLE (LV_COORD_MAX) /**< A very big radius to always draw as circle*/
#define LV_STYLE_DEGUG_SENTINEL_VALUE 0x12345678

LV_EXPORT_CONST_INT(LV_RADIUS_CIRCLE);

/**********************
* TYPEDEFS
**********************/
Expand Down
12 changes: 11 additions & 1 deletion src/lv_draw/lv_img_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
*********************/
#include "../lv_core/lv_debug.h"
#include "lv_img_cache.h"
#include "lv_img_decoder.h"
#include "lv_draw_img.h"
#include "../lv_hal/lv_hal_tick.h"
#include "../lv_misc/lv_gc.h"

Expand Down Expand Up @@ -80,7 +82,15 @@ lv_img_cache_entry_t * lv_img_cache_open(const void * src, const lv_style_t * st
/*Is the image cached?*/
lv_img_cache_entry_t * cached_src = NULL;
for(i = 0; i < entry_cnt; i++) {
if(cache[i].dec_dsc.src == src) {
bool match = false;
lv_img_src_t src_type = lv_img_src_get_type(cache[i].dec_dsc.src);
if(src_type == LV_IMG_SRC_VARIABLE) {
if(cache[i].dec_dsc.src == src) match = true;
} else if(src_type == LV_IMG_SRC_FILE) {
if(strcmp(cache[i].dec_dsc.src, src) == 0) match = true;
}

if(match) {
/* If opened increment its life.
* Image difficult to open should live longer to keep avoid frequent their recaching.
* Therefore increase `life` with `time_to_open`*/
Expand Down
14 changes: 13 additions & 1 deletion src/lv_draw/lv_img_decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,17 @@ lv_res_t lv_img_decoder_get_info(const char * src, lv_img_header_t * header)
lv_res_t lv_img_decoder_open(lv_img_decoder_dsc_t * dsc, const void * src, const lv_style_t * style)
{
dsc->style = style;
dsc->src = src;
dsc->src_type = lv_img_src_get_type(src);
dsc->user_data = NULL;

if(dsc->src_type == LV_IMG_SRC_FILE) {
uint16_t fnlen = strlen(src);
dsc->src = lv_mem_alloc(fnlen + 1);
strcpy((char *)dsc->src, src);
} else {
dsc->src = src;
}

lv_res_t res = LV_RES_INV;

lv_img_decoder_t * d;
Expand Down Expand Up @@ -177,6 +184,11 @@ void lv_img_decoder_close(lv_img_decoder_dsc_t * dsc)
{
if(dsc->decoder) {
if(dsc->decoder->close_cb) dsc->decoder->close_cb(dsc->decoder, dsc);

if(dsc->src_type == LV_IMG_SRC_FILE) {
lv_mem_free(dsc->src);
dsc->src = NULL;
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/lv_font/lv_font_fmt_txt.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ typedef struct
uint8_t box_w; /**< Width of the glyph's bounding box*/
uint8_t box_h; /**< Height of the glyph's bounding box*/
int8_t ofs_x; /**< x offset of the bounding box*/
uint8_t ofs_y; /**< y offset of the bounding box. Measured from the top of the line*/
int8_t ofs_y; /**< y offset of the bounding box. Measured from the top of the line*/
}lv_font_fmt_txt_glyph_dsc_t;


Expand Down Expand Up @@ -141,7 +141,7 @@ typedef struct {
3. value = class_pair_values[(left_class-1)*right_class_cnt + (righ_class-1)]
*/

const uint8_t * class_pair_values; /*left_class_num * right_class_num value*/
const int8_t * class_pair_values; /*left_class_num * right_class_num value*/
const uint8_t * left_class_mapping; /*Map the glyph_ids to classes: index -> glyph_id -> class_id*/
const uint8_t * right_class_mapping; /*Map the glyph_ids to classes: index -> glyph_id -> class_id*/
uint8_t left_class_cnt;
Expand Down
2 changes: 1 addition & 1 deletion src/lv_font/lv_font_roboto_12.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "lvgl/lvgl.h"
#include "../../lvgl.h"

/*******************************************************************************
* Size: 12 px
Expand Down
2 changes: 1 addition & 1 deletion src/lv_font/lv_font_roboto_16.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "lvgl/lvgl.h"
#include "../../lvgl.h"

/*******************************************************************************
* Size: 16 px
Expand Down
2 changes: 1 addition & 1 deletion src/lv_font/lv_font_roboto_22.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "lvgl/lvgl.h"
#include "../../lvgl.h"

/*******************************************************************************
* Size: 22 px
Expand Down
2 changes: 1 addition & 1 deletion src/lv_font/lv_font_roboto_28.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "lvgl/lvgl.h"
#include "../../lvgl.h"

/*******************************************************************************
* Size: 28 px
Expand Down
3 changes: 1 addition & 2 deletions src/lv_font/lv_font_unscii_8.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ static LV_ATTRIBUTE_LARGE_CONST const uint8_t gylph_bitmap[] = {
* GLYPH DESCRIPTION
*--------------------*/

static lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = {
static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = {
{.bitmap_index = 0, .adv_w = 0, .box_h = 0, .box_w = 0, .ofs_x = 0, .ofs_y = 0} /* id = 0 reserved */,
{.bitmap_index = 0, .adv_w = 128, .box_h = 0, .box_w = 0, .ofs_x = 0, .ofs_y = 0},
{.bitmap_index = 0, .adv_w = 128, .box_h = 7, .box_w = 1, .ofs_x = 3, .ofs_y = -1},
Expand Down Expand Up @@ -460,4 +460,3 @@ lv_font_t lv_font_unscii_8 = {
};

#endif /*#if LV_FONT_UNSCII_8*/

2 changes: 1 addition & 1 deletion src/lv_hal/lv_hal_disp.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)

disp->act_scr = lv_obj_create(NULL, NULL); /*Create a default screen on the display*/
disp->top_layer = lv_obj_create(NULL, NULL); /*Create top layer on the display*/
disp->sys_layer = lv_obj_create(NULL, NULL); /*Create top layer on the display*/
disp->sys_layer = lv_obj_create(NULL, NULL); /*Create sys layer on the display*/
lv_obj_set_style(disp->top_layer, &lv_style_transp);
lv_obj_set_style(disp->sys_layer, &lv_style_transp);

Expand Down
3 changes: 3 additions & 0 deletions src/lv_misc/lv_area.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ extern "C" {
#define LV_COORD_MAX ((lv_coord_t)((uint32_t)((uint32_t)1 << (8 * sizeof(lv_coord_t) - 1)) - 1000))
#define LV_COORD_MIN (-LV_COORD_MAX)

LV_EXPORT_CONST_INT(LV_COORD_MAX);
LV_EXPORT_CONST_INT(LV_COORD_MIN);

/**********************
* TYPEDEFS
**********************/
Expand Down
15 changes: 8 additions & 7 deletions src/lv_misc/lv_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ extern "C" {

/*Possible log level. For compatibility declare it independently from `LV_USE_LOG`*/

#define LV_LOG_LEVEL_TRACE 0 /**< A lot of logs to give detailed information*/
#define LV_LOG_LEVEL_INFO 1 /**< Log important events*/
#define LV_LOG_LEVEL_WARN 2 /**< Log if something unwanted happened but didn't caused problem*/
#define LV_LOG_LEVEL_ERROR 3 /**< Only critical issue, when the system may fail*/
#define LV_LOG_LEVEL_NONE 4 /**< Do not log anything*/
#define _LV_LOG_LEVEL_NUM 5 /**< Number of log levels */

enum {
LV_LOG_LEVEL_TRACE = 0, /**< A lot of logs to give detailed information*/
LV_LOG_LEVEL_INFO = 1, /**< Log important events*/
LV_LOG_LEVEL_WARN = 2, /**< Log if something unwanted happened but didn't caused problem*/
LV_LOG_LEVEL_ERROR = 3, /**< Only critical issue, when the system may fail*/
LV_LOG_LEVEL_NONE = 4, /**< Do not log anything*/
_LV_LOG_LEVEL_NUM = 5 /**< Number of log levels */
};
typedef int8_t lv_log_level_t;

#if LV_USE_LOG
Expand Down
5 changes: 5 additions & 0 deletions src/lv_objx/lv_bar.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ extern "C" {
/** log2(LV_BAR_ANIM_STATE_END) used to normalize data*/
#define LV_BAR_ANIM_STATE_NORM 8

LV_EXPORT_CONST_INT(LV_BAR_ANIM_STATE_START);
LV_EXPORT_CONST_INT(LV_BAR_ANIM_STATE_END);
LV_EXPORT_CONST_INT(LV_BAR_ANIM_STATE_INV);
LV_EXPORT_CONST_INT(LV_BAR_ANIM_STATE_NORM);

/**********************
* TYPEDEFS
**********************/
Expand Down
2 changes: 1 addition & 1 deletion src/lv_objx/lv_btn.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ uint16_t lv_btn_get_ink_out_time(const lv_obj_t * btn)

#if LV_USE_ANIMATION && LV_BTN_INK_EFFECT
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
return ext->ink_in_time;
return ext->ink_out_time;
#else
(void)btn; /*Unused*/
return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/lv_objx/lv_btnm.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ void lv_btnm_set_map(const lv_obj_t * btnm, const char * map[])
btn_i++;
}
}
act_y += btn_h + style_bg->body.padding.inner;
act_y += btn_h + style_bg->body.padding.inner + 1;

if(strlen(map_p_tmp[btn_cnt]) == 0) break; /*Break on end of map*/
map_p_tmp = &map_p_tmp[btn_cnt + 1]; /*Set the map to the next line*/
Expand Down
2 changes: 2 additions & 0 deletions src/lv_objx/lv_btnm.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ extern "C" {
#define LV_BTNM_WIDTH_MASK 0x0007
#define LV_BTNM_BTN_NONE 0xFFFF

LV_EXPORT_CONST_INT(LV_BTNM_BTN_NONE);

/**********************
* TYPEDEFS
**********************/
Expand Down
28 changes: 27 additions & 1 deletion src/lv_objx/lv_canvas.c
Original file line number Diff line number Diff line change
Expand Up @@ -695,11 +695,37 @@ void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t * points, uint32_t
lv_disp_t * refr_ori = lv_refr_get_disp_refreshing();
lv_refr_set_disp_refreshing(&disp);

lv_style_t circle_style_tmp; /*If rounded...*/
if(style->line.rounded) {
lv_style_copy(&circle_style_tmp, style);
circle_style_tmp.body.radius = LV_RADIUS_CIRCLE;
circle_style_tmp.body.main_color = style->line.color;
circle_style_tmp.body.grad_color = style->line.color;
circle_style_tmp.body.opa = style->line.opa;
}
lv_area_t circle_area;
uint32_t i;
for(i = 0; i < point_cnt - 1; i++) {
lv_draw_line(&points[i], &points[i + 1], &mask, style, LV_OPA_COVER);

/*Draw circle on the joints if enabled*/
if(style->line.rounded) {
circle_area.x1 = points[i].x - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1);
circle_area.y1 = points[i].y - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1);
circle_area.x2 = points[i].x + ((style->line.width - 1) >> 1);
circle_area.y2 = points[i].y + ((style->line.width - 1) >> 1);
lv_draw_rect(&circle_area, &mask, &circle_style_tmp, LV_OPA_COVER);
}
}

/*Draw circle on the last point too if enabled*/
if(style->line.rounded) {
circle_area.x1 = points[i].x - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1);
circle_area.y1 = points[i].y - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1);
circle_area.x2 = points[i].x + ((style->line.width - 1) >> 1);
circle_area.y2 = points[i].y + ((style->line.width - 1) >> 1);
lv_draw_rect(&circle_area, &mask, &circle_style_tmp, LV_OPA_COVER);
}

lv_refr_set_disp_refreshing(refr_ori);
}

Expand Down
5 changes: 2 additions & 3 deletions src/lv_objx/lv_chart.c
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,7 @@ static void lv_chart_draw_y_ticks(lv_obj_t * chart, const lv_area_t * mask, uint
const lv_style_t * style = lv_obj_get_style(chart);
lv_opa_t opa_scale = lv_obj_get_opa_scale(chart);

uint8_t i, j;
uint8_t i;
uint8_t num_of_labels;
uint8_t num_scale_ticks;
int8_t major_tick_len, minor_tick_len;
Expand Down Expand Up @@ -1396,8 +1396,7 @@ static void lv_chart_draw_x_ticks(lv_obj_t * chart, const lv_area_t * mask)
const lv_style_t * style = lv_obj_get_style(chart);
lv_opa_t opa_scale = lv_obj_get_opa_scale(chart);

uint8_t i, j;
uint8_t list_index;
uint8_t i;
uint8_t num_of_labels;
uint8_t num_scale_ticks;
uint8_t major_tick_len, minor_tick_len;
Expand Down
3 changes: 3 additions & 0 deletions src/lv_objx/lv_chart.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ extern "C" {
/**Automatically calculate the tick length*/
#define LV_CHART_TICK_LENGTH_AUTO 255

LV_EXPORT_CONST_INT(LV_CHART_POINT_DEF);
LV_EXPORT_CONST_INT(LV_CHART_TICK_LENGTH_AUTO);

/**********************
* TYPEDEFS
**********************/
Expand Down
1 change: 0 additions & 1 deletion src/lv_objx/lv_gauge.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, const lv_obj_t * copy)
void lv_gauge_set_needle_count(lv_obj_t * gauge, uint8_t needle_cnt, const lv_color_t colors[])
{
LV_ASSERT_OBJ(gauge, LV_OBJX_NAME);
LV_ASSERT_NULL(colors);

lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);

Expand Down
Loading

0 comments on commit 7f5ce8c

Please sign in to comment.