Fixing some compile-time errors and warning (on mipsel-gcc 4.6)

This commit is contained in:
Alexander
2018-09-12 18:55:28 +03:00
parent a89548ed48
commit a6b3addb4f
4 changed files with 287 additions and 320 deletions

View File

@@ -21,7 +21,7 @@
* STATIC PROTOTYPES * STATIC PROTOTYPES
**********************/ **********************/
static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mask, static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mask,
const void * src, const lv_style_t * style, lv_opa_t opa_scale); const void * src, const lv_style_t * style, lv_opa_t opa_scale);
static const uint8_t * lv_img_decoder_open(const void * src, const lv_style_t * style); static const uint8_t * lv_img_decoder_open(const void * src, const lv_style_t * style);
static lv_res_t lv_img_decoder_read_line(lv_coord_t x, lv_coord_t y, lv_coord_t len, uint8_t * buf); static lv_res_t lv_img_decoder_read_line(lv_coord_t x, lv_coord_t y, lv_coord_t len, uint8_t * buf);
@@ -38,7 +38,7 @@ static lv_img_src_t decoder_src_type;
static lv_img_header_t decoder_header; static lv_img_header_t decoder_header;
static const lv_style_t * decoder_style; static const lv_style_t * decoder_style;
static lv_fs_file_t decoder_file; static lv_fs_file_t decoder_file;
static lv_color_t decoder_index_map[256] = {LV_COLOR_RED, LV_COLOR_BLUE, LV_COLOR_GREEN, LV_COLOR_PURPLE}; static lv_color_t decoder_index_map[256] = {{{0}}};
static lv_img_decoder_info_f_t lv_img_decoder_info_custom; static lv_img_decoder_info_f_t lv_img_decoder_info_custom;
static lv_img_decoder_open_f_t lv_img_decoder_open_custom; static lv_img_decoder_open_f_t lv_img_decoder_open_custom;
@@ -102,8 +102,7 @@ lv_res_t lv_img_dsc_get_info(const char * src, lv_img_header_t * header)
lv_img_src_t src_type = lv_img_src_get_type(src); lv_img_src_t src_type = lv_img_src_get_type(src);
if(src_type == LV_IMG_SRC_VARIABLE) { if(src_type == LV_IMG_SRC_VARIABLE) {
header->cf = header->w = ((lv_img_dsc_t *)src)->header.w;
header->w = ((lv_img_dsc_t *)src)->header.w;
header->h = ((lv_img_dsc_t *)src)->header.h; header->h = ((lv_img_dsc_t *)src)->header.h;
header->cf = ((lv_img_dsc_t *)src)->header.cf; header->cf = ((lv_img_dsc_t *)src)->header.cf;
} }
@@ -144,75 +143,75 @@ lv_res_t lv_img_dsc_get_info(const char * src, lv_img_header_t * header)
uint8_t lv_img_color_format_get_px_size(lv_img_cf_t cf) uint8_t lv_img_color_format_get_px_size(lv_img_cf_t cf)
{ {
switch(cf) { switch(cf) {
case LV_IMG_CF_UNKOWN: case LV_IMG_CF_UNKOWN:
case LV_IMG_CF_RAW: case LV_IMG_CF_RAW:
return 0; return 0;
case LV_IMG_CF_TRUE_COLOR: case LV_IMG_CF_TRUE_COLOR:
case LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED: case LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED:
return LV_COLOR_SIZE; return LV_COLOR_SIZE;
case LV_IMG_CF_TRUE_COLOR_ALPHA: case LV_IMG_CF_TRUE_COLOR_ALPHA:
#if LV_COLOR_DEPTH != 24 #if LV_COLOR_DEPTH != 24
return LV_COLOR_SIZE; return LV_COLOR_SIZE;
#else #else
return LV_COLOR_SIZE + 1; return LV_COLOR_SIZE + 1;
#endif #endif
case LV_IMG_CF_INDEXED_1BIT: case LV_IMG_CF_INDEXED_1BIT:
case LV_IMG_CF_ALPHA_1BIT: case LV_IMG_CF_ALPHA_1BIT:
return 1; return 1;
case LV_IMG_CF_INDEXED_2BIT: case LV_IMG_CF_INDEXED_2BIT:
case LV_IMG_CF_ALPHA_2BIT: case LV_IMG_CF_ALPHA_2BIT:
return 2; return 2;
case LV_IMG_CF_INDEXED_4BIT: case LV_IMG_CF_INDEXED_4BIT:
case LV_IMG_CF_ALPHA_4BIT: case LV_IMG_CF_ALPHA_4BIT:
return 4; return 4;
case LV_IMG_CF_INDEXED_8BIT: case LV_IMG_CF_INDEXED_8BIT:
case LV_IMG_CF_ALPHA_8BIT: case LV_IMG_CF_ALPHA_8BIT:
return 8; return 8;
default: default:
return 0; return 0;
} }
return 0; return 0;
} }
bool lv_img_color_format_is_chroma_keyed(lv_img_cf_t cf) bool lv_img_color_format_is_chroma_keyed(lv_img_cf_t cf)
{ {
switch(cf) { switch(cf) {
case LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED: case LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED:
case LV_IMG_CF_RAW_CHROMA_KEYED: case LV_IMG_CF_RAW_CHROMA_KEYED:
case LV_IMG_CF_INDEXED_1BIT: case LV_IMG_CF_INDEXED_1BIT:
case LV_IMG_CF_INDEXED_2BIT: case LV_IMG_CF_INDEXED_2BIT:
case LV_IMG_CF_INDEXED_4BIT: case LV_IMG_CF_INDEXED_4BIT:
case LV_IMG_CF_INDEXED_8BIT: case LV_IMG_CF_INDEXED_8BIT:
return true; return true;
default: default:
return false; return false;
} }
return false; return false;
} }
bool lv_img_color_format_has_alpha(lv_img_cf_t cf) bool lv_img_color_format_has_alpha(lv_img_cf_t cf)
{ {
switch(cf) { switch(cf) {
case LV_IMG_CF_TRUE_COLOR_ALPHA: case LV_IMG_CF_TRUE_COLOR_ALPHA:
case LV_IMG_CF_RAW_ALPHA: case LV_IMG_CF_RAW_ALPHA:
case LV_IMG_CF_ALPHA_1BIT: case LV_IMG_CF_ALPHA_1BIT:
case LV_IMG_CF_ALPHA_2BIT: case LV_IMG_CF_ALPHA_2BIT:
case LV_IMG_CF_ALPHA_4BIT: case LV_IMG_CF_ALPHA_4BIT:
case LV_IMG_CF_ALPHA_8BIT: case LV_IMG_CF_ALPHA_8BIT:
return true; return true;
default: default:
return false; return false;
} }
return false; return false;
} }
/** /**
@@ -231,11 +230,9 @@ lv_img_src_t lv_img_src_get_type(const void * src)
/*The first byte shows the type of the image source*/ /*The first byte shows the type of the image source*/
if(u8_p[0] >= 0x20 && u8_p[0] <= 0x7F) { if(u8_p[0] >= 0x20 && u8_p[0] <= 0x7F) {
return LV_IMG_SRC_FILE; /*If it's an ASCII character then it's file name*/ return LV_IMG_SRC_FILE; /*If it's an ASCII character then it's file name*/
} } else if(u8_p[0] >= 0x80) {
else if(u8_p[0] >= 0x80) {
return LV_IMG_SRC_SYMBOL; /*Symbols begins after 0x7F*/ return LV_IMG_SRC_SYMBOL; /*Symbols begins after 0x7F*/
} } else {
else {
return LV_IMG_SRC_VARIABLE; /*`lv_img_dsc_t` is design to the first byte < 0x20*/ return LV_IMG_SRC_VARIABLE; /*`lv_img_dsc_t` is design to the first byte < 0x20*/
} }
@@ -250,11 +247,11 @@ lv_img_src_t lv_img_src_get_type(const void * src)
* @param close_fp clode function * @param close_fp clode function
*/ */
void lv_img_decoder_set_custom(lv_img_decoder_info_f_t info_fp, lv_img_decoder_open_f_t open_fp, void lv_img_decoder_set_custom(lv_img_decoder_info_f_t info_fp, lv_img_decoder_open_f_t open_fp,
lv_img_decoder_read_line_f_t read_fp, lv_img_decoder_close_f_t close_fp) lv_img_decoder_read_line_f_t read_fp, lv_img_decoder_close_f_t close_fp)
{ {
lv_img_decoder_info_custom = info_fp; lv_img_decoder_info_custom = info_fp;
lv_img_decoder_open_custom = open_fp; lv_img_decoder_open_custom = open_fp;
lv_img_decoder_read_line_custom= read_fp; lv_img_decoder_read_line_custom = read_fp;
lv_img_decoder_close_custom = close_fp; lv_img_decoder_close_custom = close_fp;
} }
@@ -265,7 +262,7 @@ void lv_img_decoder_set_custom(lv_img_decoder_info_f_t info_fp, lv_img_decoder_
static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mask, static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mask,
const void * src, const lv_style_t * style, lv_opa_t opa_scale) const void * src, const lv_style_t * style, lv_opa_t opa_scale)
{ {
lv_area_t mask_com; /*Common area of mask and coords*/ lv_area_t mask_com; /*Common area of mask and coords*/
@@ -387,8 +384,7 @@ static const uint8_t * lv_img_decoder_open(const void * src, const lv_style_t *
lv_img_cf_t cf = decoder_header.cf; lv_img_cf_t cf = decoder_header.cf;
if(cf == LV_IMG_CF_TRUE_COLOR || if(cf == LV_IMG_CF_TRUE_COLOR ||
cf == LV_IMG_CF_TRUE_COLOR_ALPHA || cf == LV_IMG_CF_TRUE_COLOR_ALPHA ||
cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) {
{
if(decoder_src_type == LV_IMG_SRC_VARIABLE) { if(decoder_src_type == LV_IMG_SRC_VARIABLE) {
/*In case of uncompressed formats if the image stored in the ROM/RAM simply give it's pointer*/ /*In case of uncompressed formats if the image stored in the ROM/RAM simply give it's pointer*/
return ((lv_img_dsc_t *)decoder_src)->data; return ((lv_img_dsc_t *)decoder_src)->data;
@@ -396,12 +392,10 @@ static const uint8_t * lv_img_decoder_open(const void * src, const lv_style_t *
/*If it's file it need to be read line by line later*/ /*If it's file it need to be read line by line later*/
return NULL; return NULL;
} }
} } else if(cf == LV_IMG_CF_INDEXED_1BIT ||
else if (cf == LV_IMG_CF_INDEXED_1BIT || cf == LV_IMG_CF_INDEXED_2BIT ||
cf == LV_IMG_CF_INDEXED_2BIT || cf == LV_IMG_CF_INDEXED_4BIT ||
cf == LV_IMG_CF_INDEXED_4BIT || cf == LV_IMG_CF_INDEXED_8BIT) {
cf == LV_IMG_CF_INDEXED_8BIT)
{
lv_color24_t palette_file[256]; lv_color24_t palette_file[256];
lv_color24_t * palette_p = NULL; lv_color24_t * palette_p = NULL;
uint8_t px_size = lv_img_color_format_get_px_size(cf); uint8_t px_size = lv_img_color_format_get_px_size(cf);
@@ -416,7 +410,7 @@ static const uint8_t * lv_img_decoder_open(const void * src, const lv_style_t *
palette_file[0] = 0; /*Just to solve warnings*/ palette_file[0] = 0; /*Just to solve warnings*/
#endif #endif
} else { } else {
palette_p = (lv_color_t*)((lv_img_dsc_t *)decoder_src)->data; palette_p = (lv_color_t *)((lv_img_dsc_t *)decoder_src)->data;
} }
uint32_t i; uint32_t i;
@@ -424,16 +418,12 @@ static const uint8_t * lv_img_decoder_open(const void * src, const lv_style_t *
decoder_index_map[i] = LV_COLOR_MAKE(palette_p[i].red, palette_p[i].green, palette_p[i].blue); decoder_index_map[i] = LV_COLOR_MAKE(palette_p[i].red, palette_p[i].green, palette_p[i].blue);
} }
return NULL; return NULL;
} } else if(cf == LV_IMG_CF_ALPHA_1BIT ||
else if (cf == LV_IMG_CF_ALPHA_1BIT || cf == LV_IMG_CF_ALPHA_2BIT ||
cf == LV_IMG_CF_ALPHA_2BIT || cf == LV_IMG_CF_ALPHA_4BIT ||
cf == LV_IMG_CF_ALPHA_4BIT || cf == LV_IMG_CF_ALPHA_8BIT) {
cf == LV_IMG_CF_ALPHA_8BIT)
{
return NULL; /*Nothing to process*/ return NULL; /*Nothing to process*/
} } else {
else
{
LV_LOG_WARN("Image decoder open: unknown color format") LV_LOG_WARN("Image decoder open: unknown color format")
return LV_IMG_DECODER_OPEN_FAIL; return LV_IMG_DECODER_OPEN_FAIL;
} }
@@ -461,9 +451,8 @@ static lv_res_t lv_img_decoder_read_line(lv_coord_t x, lv_coord_t y, lv_coord_t
lv_fs_res_t res; lv_fs_res_t res;
if(decoder_header.cf == LV_IMG_CF_TRUE_COLOR || if(decoder_header.cf == LV_IMG_CF_TRUE_COLOR ||
decoder_header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA || decoder_header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA ||
decoder_header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) decoder_header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) {
{
uint32_t pos = ((y * decoder_header.w + x) * px_size) >> 3; uint32_t pos = ((y * decoder_header.w + x) * px_size) >> 3;
res = lv_fs_seek(&decoder_file, pos); res = lv_fs_seek(&decoder_file, pos);
if(res != LV_FS_RES_OK) { if(res != LV_FS_RES_OK) {
@@ -477,18 +466,15 @@ static lv_res_t lv_img_decoder_read_line(lv_coord_t x, lv_coord_t y, lv_coord_t
LV_LOG_WARN("Built-in image decoder read failed"); LV_LOG_WARN("Built-in image decoder read failed");
return false; return false;
} }
} } else if(decoder_header.cf == LV_IMG_CF_ALPHA_1BIT ||
else if(decoder_header.cf == LV_IMG_CF_ALPHA_1BIT || decoder_header.cf == LV_IMG_CF_ALPHA_2BIT ||
decoder_header.cf == LV_IMG_CF_ALPHA_2BIT || decoder_header.cf == LV_IMG_CF_ALPHA_4BIT ||
decoder_header.cf == LV_IMG_CF_ALPHA_4BIT || decoder_header.cf == LV_IMG_CF_ALPHA_8BIT) {
decoder_header.cf == LV_IMG_CF_ALPHA_8BIT)
{
lv_img_built_in_decoder_line_alpha(x, y, len, buf); lv_img_built_in_decoder_line_alpha(x, y, len, buf);
} else if(decoder_header.cf == LV_IMG_CF_INDEXED_1BIT || } else if(decoder_header.cf == LV_IMG_CF_INDEXED_1BIT ||
decoder_header.cf == LV_IMG_CF_INDEXED_2BIT || decoder_header.cf == LV_IMG_CF_INDEXED_2BIT ||
decoder_header.cf == LV_IMG_CF_INDEXED_4BIT || decoder_header.cf == LV_IMG_CF_INDEXED_4BIT ||
decoder_header.cf == LV_IMG_CF_INDEXED_8BIT) decoder_header.cf == LV_IMG_CF_INDEXED_8BIT) {
{
lv_img_built_in_decoder_line_indexed(x, y, len, buf); lv_img_built_in_decoder_line_indexed(x, y, len, buf);
} else { } else {
LV_LOG_WARN("Built-in image decoder read not supports the color format"); LV_LOG_WARN("Built-in image decoder read not supports the color format");
@@ -498,20 +484,18 @@ static lv_res_t lv_img_decoder_read_line(lv_coord_t x, lv_coord_t y, lv_coord_t
LV_LOG_WARN("Image built-in decoder can't read file because USE_LV_FILESYSTEM = 0"); LV_LOG_WARN("Image built-in decoder can't read file because USE_LV_FILESYSTEM = 0");
return false; return false;
#endif #endif
} else if (decoder_src_type == LV_IMG_SRC_VARIABLE) { } else if(decoder_src_type == LV_IMG_SRC_VARIABLE) {
const lv_img_dsc_t * img_dsc = decoder_src; const lv_img_dsc_t * img_dsc = decoder_src;
if(img_dsc->header.cf == LV_IMG_CF_ALPHA_1BIT || if(img_dsc->header.cf == LV_IMG_CF_ALPHA_1BIT ||
img_dsc->header.cf == LV_IMG_CF_ALPHA_2BIT || img_dsc->header.cf == LV_IMG_CF_ALPHA_2BIT ||
img_dsc->header.cf == LV_IMG_CF_ALPHA_4BIT || img_dsc->header.cf == LV_IMG_CF_ALPHA_4BIT ||
img_dsc->header.cf == LV_IMG_CF_ALPHA_8BIT) img_dsc->header.cf == LV_IMG_CF_ALPHA_8BIT) {
{
lv_img_built_in_decoder_line_alpha(x, y, len, buf); lv_img_built_in_decoder_line_alpha(x, y, len, buf);
} else if(img_dsc->header.cf == LV_IMG_CF_INDEXED_1BIT || } else if(img_dsc->header.cf == LV_IMG_CF_INDEXED_1BIT ||
img_dsc->header.cf == LV_IMG_CF_INDEXED_2BIT || img_dsc->header.cf == LV_IMG_CF_INDEXED_2BIT ||
img_dsc->header.cf == LV_IMG_CF_INDEXED_4BIT || img_dsc->header.cf == LV_IMG_CF_INDEXED_4BIT ||
img_dsc->header.cf == LV_IMG_CF_INDEXED_8BIT) img_dsc->header.cf == LV_IMG_CF_INDEXED_8BIT) {
{
lv_img_built_in_decoder_line_indexed(x, y, len, buf); lv_img_built_in_decoder_line_indexed(x, y, len, buf);
} else { } else {
LV_LOG_WARN("Built-in image decoder not supports the color format"); LV_LOG_WARN("Built-in image decoder not supports the color format");
@@ -546,9 +530,9 @@ static lv_res_t lv_img_built_in_decoder_line_alpha(lv_coord_t x, lv_coord_t y, l
const lv_opa_t alpha1_opa_table[2] = {0, 255}; /*Opacity mapping with bpp = 1 (Just for compatibility)*/ const lv_opa_t alpha1_opa_table[2] = {0, 255}; /*Opacity mapping with bpp = 1 (Just for compatibility)*/
const lv_opa_t alpha2_opa_table[4] = {0, 85, 170, 255}; /*Opacity mapping with bpp = 2*/ const lv_opa_t alpha2_opa_table[4] = {0, 85, 170, 255}; /*Opacity mapping with bpp = 2*/
const lv_opa_t alpha4_opa_table[16] = {0, 17, 34, 51, /*Opacity mapping with bpp = 4*/ const lv_opa_t alpha4_opa_table[16] = {0, 17, 34, 51, /*Opacity mapping with bpp = 4*/
68, 85, 102, 119, 68, 85, 102, 119,
136, 153, 170, 187, 136, 153, 170, 187,
204, 221, 238, 255 204, 221, 238, 255
}; };
/*Simply fill the buffer with the color. Later only the alpha value will be modified.*/ /*Simply fill the buffer with the color. Later only the alpha value will be modified.*/
@@ -562,54 +546,54 @@ static lv_res_t lv_img_built_in_decoder_line_alpha(lv_coord_t x, lv_coord_t y, l
buf[i * LV_IMG_PX_SIZE_ALPHA_BYTE] = bg_color.full & 0xFF; buf[i * LV_IMG_PX_SIZE_ALPHA_BYTE] = bg_color.full & 0xFF;
buf[i * LV_IMG_PX_SIZE_ALPHA_BYTE + 1] = (bg_color.full >> 8) & 0xFF; buf[i * LV_IMG_PX_SIZE_ALPHA_BYTE + 1] = (bg_color.full >> 8) & 0xFF;
#elif LV_COLOR_DEPTH == 24 #elif LV_COLOR_DEPTH == 24
*((uint32_t*)&buf[i * LV_IMG_PX_SIZE_ALPHA_BYTE]) = bg_color.full; *((uint32_t *)&buf[i * LV_IMG_PX_SIZE_ALPHA_BYTE]) = bg_color.full;
#endif #endif
} }
const lv_opa_t * opa_table = NULL; const lv_opa_t * opa_table = NULL;
uint8_t px_size = lv_img_color_format_get_px_size(decoder_header.cf); uint8_t px_size = lv_img_color_format_get_px_size(decoder_header.cf);
uint16_t mask = (1 << px_size) - 1; /*E.g. px_size = 2; mask = 0x03*/ uint16_t mask = (1 << px_size) - 1; /*E.g. px_size = 2; mask = 0x03*/
lv_coord_t w = 0; lv_coord_t w = 0;
uint32_t ofs = 0; uint32_t ofs = 0;
int8_t pos = 0; int8_t pos = 0;
switch(decoder_header.cf) { switch(decoder_header.cf) {
case LV_IMG_CF_ALPHA_1BIT: case LV_IMG_CF_ALPHA_1BIT:
w = (decoder_header.w >> 3); /*E.g. w = 20 -> w = 2 + 1*/ w = (decoder_header.w >> 3); /*E.g. w = 20 -> w = 2 + 1*/
if(decoder_header.w & 0x7) w++; if(decoder_header.w & 0x7) w++;
ofs += w * y + (x >> 3); /*First pixel*/ ofs += w * y + (x >> 3); /*First pixel*/
pos = 7 - (x & 0x7); pos = 7 - (x & 0x7);
opa_table = alpha1_opa_table; opa_table = alpha1_opa_table;
break; break;
case LV_IMG_CF_ALPHA_2BIT: case LV_IMG_CF_ALPHA_2BIT:
w = (decoder_header.w >> 2); /*E.g. w = 13 -> w = 3 + 1 (bytes)*/ w = (decoder_header.w >> 2); /*E.g. w = 13 -> w = 3 + 1 (bytes)*/
if(decoder_header.w & 0x3) w++; if(decoder_header.w & 0x3) w++;
ofs += w * y + (x >> 2); /*First pixel*/ ofs += w * y + (x >> 2); /*First pixel*/
pos = 6 - ((x & 0x3) * 2); pos = 6 - ((x & 0x3) * 2);
opa_table = alpha2_opa_table; opa_table = alpha2_opa_table;
break; break;
case LV_IMG_CF_ALPHA_4BIT: case LV_IMG_CF_ALPHA_4BIT:
w = (decoder_header.w >> 1); /*E.g. w = 13 -> w = 6 + 1 (bytes)*/ w = (decoder_header.w >> 1); /*E.g. w = 13 -> w = 6 + 1 (bytes)*/
if(decoder_header.w & 0x1) w++; if(decoder_header.w & 0x1) w++;
ofs += w * y + (x >> 1); /*First pixel*/ ofs += w * y + (x >> 1); /*First pixel*/
pos = 4 - ((x & 0x1) * 4); pos = 4 - ((x & 0x1) * 4);
opa_table = alpha4_opa_table; opa_table = alpha4_opa_table;
break; break;
case LV_IMG_CF_ALPHA_8BIT: case LV_IMG_CF_ALPHA_8BIT:
w = decoder_header.w; /*E.g. x = 7 -> w = 7 (bytes)*/ w = decoder_header.w; /*E.g. x = 7 -> w = 7 (bytes)*/
ofs += w * y + x; /*First pixel*/ ofs += w * y + x; /*First pixel*/
pos = 0; pos = 0;
break; break;
} }
#if USE_LV_FILESYSTEM #if USE_LV_FILESYSTEM
# if LV_COMPILER_VLA_SUPPORTED # if LV_COMPILER_VLA_SUPPORTED
uint8_t fs_buf[w]; uint8_t fs_buf[w];
# else # else
# if LV_HOR_RES > LV_VER_RES # if LV_HOR_RES > LV_VER_RES
uint8_t fs_buf[LV_HOR_RES]; uint8_t fs_buf[LV_HOR_RES];
# else # else
uint8_t fs_buf[LV_VER_RES]; uint8_t fs_buf[LV_VER_RES];
# endif # endif
# endif # endif
#endif #endif
@@ -630,22 +614,22 @@ static lv_res_t lv_img_built_in_decoder_line_alpha(lv_coord_t x, lv_coord_t y, l
} }
uint8_t byte_act = 0; uint8_t byte_act = 0;
uint8_t val_act; uint8_t val_act;
for(i = 0; i < len; i ++) { for(i = 0; i < len; i ++) {
val_act = (data_tmp[byte_act] & (mask << pos)) >> pos; val_act = (data_tmp[byte_act] & (mask << pos)) >> pos;
buf[i * LV_IMG_PX_SIZE_ALPHA_BYTE + LV_IMG_PX_SIZE_ALPHA_BYTE - 1] = buf[i * LV_IMG_PX_SIZE_ALPHA_BYTE + LV_IMG_PX_SIZE_ALPHA_BYTE - 1] =
decoder_header.cf == LV_IMG_CF_ALPHA_8BIT ? val_act : opa_table[val_act]; decoder_header.cf == LV_IMG_CF_ALPHA_8BIT ? val_act : opa_table[val_act];
pos -= px_size; pos -= px_size;
if(pos < 0) { if(pos < 0) {
pos = 8 - px_size; pos = 8 - px_size;
data_tmp++; data_tmp++;
} }
} }
return LV_RES_OK; return LV_RES_OK;
} }
static lv_res_t lv_img_built_in_decoder_line_indexed(lv_coord_t x, lv_coord_t y, lv_coord_t len, uint8_t * buf) static lv_res_t lv_img_built_in_decoder_line_indexed(lv_coord_t x, lv_coord_t y, lv_coord_t len, uint8_t * buf)
@@ -664,37 +648,37 @@ static lv_res_t lv_img_built_in_decoder_line_indexed(lv_coord_t x, lv_coord_t y,
ofs += w * y + (x >> 3); /*First pixel*/ ofs += w * y + (x >> 3); /*First pixel*/
ofs += 8; /*Skip the palette*/ ofs += 8; /*Skip the palette*/
pos = 7 - (x & 0x7); pos = 7 - (x & 0x7);
break; break;
case LV_IMG_CF_INDEXED_2BIT: case LV_IMG_CF_INDEXED_2BIT:
w = (decoder_header.w >> 2); /*E.g. w = 13 -> w = 3 + 1 (bytes)*/ w = (decoder_header.w >> 2); /*E.g. w = 13 -> w = 3 + 1 (bytes)*/
if(decoder_header.w & 0x3) w++; if(decoder_header.w & 0x3) w++;
ofs += w * y + (x >> 2); /*First pixel*/ ofs += w * y + (x >> 2); /*First pixel*/
ofs += 16; /*Skip the palette*/ ofs += 16; /*Skip the palette*/
pos = 6 - ((x & 0x3) * 2); pos = 6 - ((x & 0x3) * 2);
break; break;
case LV_IMG_CF_INDEXED_4BIT: case LV_IMG_CF_INDEXED_4BIT:
w = (decoder_header.w >> 1); /*E.g. w = 13 -> w = 6 + 1 (bytes)*/ w = (decoder_header.w >> 1); /*E.g. w = 13 -> w = 6 + 1 (bytes)*/
if(decoder_header.w & 0x1) w++; if(decoder_header.w & 0x1) w++;
ofs += w * y + (x >> 1); /*First pixel*/ ofs += w * y + (x >> 1); /*First pixel*/
ofs += 64; /*Skip the palette*/ ofs += 64; /*Skip the palette*/
pos = 4 - ((x & 0x1) * 4); pos = 4 - ((x & 0x1) * 4);
break; break;
case LV_IMG_CF_INDEXED_8BIT: case LV_IMG_CF_INDEXED_8BIT:
w = decoder_header.w; /*E.g. x = 7 -> w = 7 (bytes)*/ w = decoder_header.w; /*E.g. x = 7 -> w = 7 (bytes)*/
ofs += w * y + x; /*First pixel*/ ofs += w * y + x; /*First pixel*/
ofs += 1024; /*Skip the palette*/ ofs += 1024; /*Skip the palette*/
pos = 0; pos = 0;
break; break;
} }
#if USE_LV_FILESYSTEM #if USE_LV_FILESYSTEM
# if LV_COMPILER_VLA_SUPPORTED # if LV_COMPILER_VLA_SUPPORTED
uint8_t fs_buf[w]; uint8_t fs_buf[w];
# else # else
# if LV_HOR_RES > LV_VER_RES # if LV_HOR_RES > LV_VER_RES
uint8_t fs_buf[LV_HOR_RES]; uint8_t fs_buf[LV_HOR_RES];
# else # else
uint8_t fs_buf[LV_VER_RES]; uint8_t fs_buf[LV_VER_RES];
# endif # endif
# endif # endif
#endif #endif

View File

@@ -62,8 +62,8 @@ static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_
*/ */
void lv_vpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa) void lv_vpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa)
{ {
if(opa < LV_OPA_MIN) return; if(opa < LV_OPA_MIN) return;
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER; if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
lv_vdb_t * vdb_p = lv_vdb_get(); lv_vdb_t * vdb_p = lv_vdb_get();
@@ -81,14 +81,14 @@ void lv_vpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t col
lv_disp_t * disp = lv_disp_get_active(); lv_disp_t * disp = lv_disp_get_active();
if(disp->driver.vdb_wr) { if(disp->driver.vdb_wr) {
disp->driver.vdb_wr((uint8_t*)vdb_p->buf, vdb_width, x, y, color, opa); disp->driver.vdb_wr((uint8_t *)vdb_p->buf, vdb_width, x, y, color, opa);
} else { } else {
lv_color_t * vdb_px_p = vdb_p->buf + y * vdb_width + x; lv_color_t * vdb_px_p = vdb_p->buf + y * vdb_width + x;
if(opa == LV_OPA_COVER) { if(opa == LV_OPA_COVER) {
*vdb_px_p = color; *vdb_px_p = color;
} else { } else {
*vdb_px_p = lv_color_mix(color, *vdb_px_p, opa); *vdb_px_p = lv_color_mix(color, *vdb_px_p, opa);
} }
} }
} }
@@ -103,8 +103,8 @@ void lv_vpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t col
void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p, void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
lv_color_t color, lv_opa_t opa) lv_color_t color, lv_opa_t opa)
{ {
if(opa < LV_OPA_MIN) return; if(opa < LV_OPA_MIN) return;
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER; if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
lv_area_t res_a; lv_area_t res_a;
bool union_ok; bool union_ok;
@@ -221,16 +221,16 @@ void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
const uint8_t bpp1_opa_table[2] = {0, 255}; /*Opacity mapping with bpp = 1 (Just for compatibility)*/ const uint8_t bpp1_opa_table[2] = {0, 255}; /*Opacity mapping with bpp = 1 (Just for compatibility)*/
const uint8_t bpp2_opa_table[4] = {0, 85, 170, 255}; /*Opacity mapping with bpp = 2*/ const uint8_t bpp2_opa_table[4] = {0, 85, 170, 255}; /*Opacity mapping with bpp = 2*/
const uint8_t bpp4_opa_table[16] = {0, 17, 34, 51, /*Opacity mapping with bpp = 4*/ const uint8_t bpp4_opa_table[16] = {0, 17, 34, 51, /*Opacity mapping with bpp = 4*/
68, 85, 102, 119, 68, 85, 102, 119,
136, 153, 170, 187, 136, 153, 170, 187,
204, 221, 238, 255 204, 221, 238, 255
}; };
if(opa < LV_OPA_MIN) return; if(opa < LV_OPA_MIN) return;
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER; if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
if(font_p == NULL) { if(font_p == NULL) {
LV_LOG_WARN("Font: character's bitmap not found"); LV_LOG_WARN("Font: character's bitmap not found");
return; return;
} }
lv_coord_t pos_x = pos_p->x; lv_coord_t pos_x = pos_p->x;
@@ -238,12 +238,12 @@ void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
uint8_t letter_w = lv_font_get_real_width(font_p, letter); uint8_t letter_w = lv_font_get_real_width(font_p, letter);
uint8_t letter_h = lv_font_get_height(font_p); uint8_t letter_h = lv_font_get_height(font_p);
uint8_t bpp = lv_font_get_bpp(font_p, letter); /*Bit per pixel (1,2, 4 or 8)*/ uint8_t bpp = lv_font_get_bpp(font_p, letter); /*Bit per pixel (1,2, 4 or 8)*/
uint8_t * bpp_opa_table; const uint8_t * bpp_opa_table;
uint8_t mask_init; uint8_t mask_init;
uint8_t mask; uint8_t mask;
if(lv_font_is_monospace(font_p, letter)) { if(lv_font_is_monospace(font_p, letter)) {
pos_x += (lv_font_get_width(font_p, letter) - letter_w) / 2; pos_x += (lv_font_get_width(font_p, letter) - letter_w) / 2;
} }
@@ -314,21 +314,21 @@ void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
for(col = col_start; col < col_end; col ++) { for(col = col_start; col < col_end; col ++) {
letter_px = (*map_p & mask) >> (8 - col_bit - bpp); letter_px = (*map_p & mask) >> (8 - col_bit - bpp);
if(letter_px != 0) { if(letter_px != 0) {
if(opa == LV_OPA_COVER) { if(opa == LV_OPA_COVER) {
px_opa = bpp == 8 ? letter_px : bpp_opa_table[letter_px]; px_opa = bpp == 8 ? letter_px : bpp_opa_table[letter_px];
} else { } else {
px_opa = bpp == 8 ? px_opa = bpp == 8 ?
(uint16_t)((uint16_t)letter_px * opa) >> 8 : (uint16_t)((uint16_t)letter_px * opa) >> 8 :
(uint16_t)((uint16_t)bpp_opa_table[letter_px] * opa) >> 8; (uint16_t)((uint16_t)bpp_opa_table[letter_px] * opa) >> 8;
} }
if(disp->driver.vdb_wr) { if(disp->driver.vdb_wr) {
disp->driver.vdb_wr((uint8_t*)vdb_p->buf, vdb_width, disp->driver.vdb_wr((uint8_t *)vdb_p->buf, vdb_width,
(col + pos_x) - vdb_p->area.x1, (row + pos_y) - vdb_p->area.y1, (col + pos_x) - vdb_p->area.x1, (row + pos_y) - vdb_p->area.y1,
color, px_opa); color, px_opa);
} else { } else {
*vdb_buf_tmp = lv_color_mix(color, *vdb_buf_tmp, px_opa); *vdb_buf_tmp = lv_color_mix(color, *vdb_buf_tmp, px_opa);
} }
} }
vdb_buf_tmp++; vdb_buf_tmp++;
@@ -365,8 +365,8 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
lv_color_t recolor, lv_opa_t recolor_opa) lv_color_t recolor, lv_opa_t recolor_opa)
{ {
if(opa < LV_OPA_MIN) return; if(opa < LV_OPA_MIN) return;
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER; if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
lv_area_t masked_a; lv_area_t masked_a;
bool union_ok; bool union_ok;
@@ -411,33 +411,33 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
/*The simplest case just copy the pixels into the VDB*/ /*The simplest case just copy the pixels into the VDB*/
if(chroma_key == false && alpha_byte == false && opa == LV_OPA_COVER && recolor_opa == LV_OPA_TRANSP) { if(chroma_key == false && alpha_byte == false && opa == LV_OPA_COVER && recolor_opa == LV_OPA_TRANSP) {
/*Use the custom VDB write function is exists*/ /*Use the custom VDB write function is exists*/
if(disp->driver.vdb_wr) { if(disp->driver.vdb_wr) {
lv_coord_t col; lv_coord_t col;
for(row = masked_a.y1; row <= masked_a.y2; row++) { for(row = masked_a.y1; row <= masked_a.y2; row++) {
for(col = 0; col < map_useful_w; col++) { for(col = 0; col < map_useful_w; col++) {
lv_color_t px_color = (lv_color_t) *((lv_color_t *)&map_p[(uint32_t)col * px_size_byte]); lv_color_t px_color = (lv_color_t) * ((lv_color_t *)&map_p[(uint32_t)col * px_size_byte]);
disp->driver.vdb_wr((uint8_t*)vdb_p->buf, vdb_width, col + masked_a.x1, row, px_color, opa); disp->driver.vdb_wr((uint8_t *)vdb_p->buf, vdb_width, col + masked_a.x1, row, px_color, opa);
} }
map_p += map_width * px_size_byte; /*Next row on the map*/ map_p += map_width * px_size_byte; /*Next row on the map*/
} }
} }
/*Normal native VDB*/ /*Normal native VDB*/
else { else {
for(row = masked_a.y1; row <= masked_a.y2; row++) { for(row = masked_a.y1; row <= masked_a.y2; row++) {
#if USE_LV_GPU #if USE_LV_GPU
if(lv_disp_is_mem_blend_supported() == false) { if(lv_disp_is_mem_blend_supported() == false) {
sw_mem_blend(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa); sw_mem_blend(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa);
} else { } else {
lv_disp_mem_blend(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa); lv_disp_mem_blend(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa);
} }
#else #else
sw_mem_blend(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa); sw_mem_blend(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa);
#endif #endif
map_p += map_width * px_size_byte; /*Next row on the map*/ map_p += map_width * px_size_byte; /*Next row on the map*/
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/ vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
} }
} }
} }
/*In the other cases every pixel need to be checked one-by-one*/ /*In the other cases every pixel need to be checked one-by-one*/
@@ -480,28 +480,28 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
} }
/*Handle custom VDB write is present*/ /*Handle custom VDB write is present*/
if(disp->driver.vdb_wr) { if(disp->driver.vdb_wr) {
disp->driver.vdb_wr((uint8_t*)vdb_p->buf, vdb_width, col + masked_a.x1, row, recolored_px, opa_result); disp->driver.vdb_wr((uint8_t *)vdb_p->buf, vdb_width, col + masked_a.x1, row, recolored_px, opa_result);
} }
/*Normal native VDB write*/ /*Normal native VDB write*/
else { else {
if(opa_result == LV_OPA_COVER) vdb_buf_tmp[col].full = recolored_px.full; if(opa_result == LV_OPA_COVER) vdb_buf_tmp[col].full = recolored_px.full;
else vdb_buf_tmp[col] = lv_color_mix(recolored_px, vdb_buf_tmp[col], opa_result); else vdb_buf_tmp[col] = lv_color_mix(recolored_px, vdb_buf_tmp[col], opa_result);
} }
} else { } else {
/*Handle custom VDB write is present*/ /*Handle custom VDB write is present*/
if(disp->driver.vdb_wr) { if(disp->driver.vdb_wr) {
disp->driver.vdb_wr((uint8_t*)vdb_p->buf, vdb_width, col + masked_a.x1, row, px_color, opa_result); disp->driver.vdb_wr((uint8_t *)vdb_p->buf, vdb_width, col + masked_a.x1, row, px_color, opa_result);
} }
/*Normal native VDB write*/ /*Normal native VDB write*/
else { else {
if(opa_result == LV_OPA_COVER) vdb_buf_tmp[col] = px_color; if(opa_result == LV_OPA_COVER) vdb_buf_tmp[col] = px_color;
else vdb_buf_tmp[col] = lv_color_mix(px_color, vdb_buf_tmp[col], opa_result); else vdb_buf_tmp[col] = lv_color_mix(px_color, vdb_buf_tmp[col], opa_result);
} }
} }
} }
map_p += map_width * px_size_byte; /*Next row on the map*/ map_p += map_width * px_size_byte; /*Next row on the map*/
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/ vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
} }
} }
} }
@@ -546,48 +546,48 @@ static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_
lv_disp_t * disp = lv_disp_get_active(); lv_disp_t * disp = lv_disp_get_active();
if(disp->driver.vdb_wr) { if(disp->driver.vdb_wr) {
for(col = fill_area->x1; col <= fill_area->x2; col++) { for(col = fill_area->x1; col <= fill_area->x2; col++) {
for(row = fill_area->y1; row <= fill_area->y2; row++) { for(row = fill_area->y1; row <= fill_area->y2; row++) {
disp->driver.vdb_wr((uint8_t*)mem, mem_width, col, row, color, opa); disp->driver.vdb_wr((uint8_t *)mem, mem_width, col, row, color, opa);
} }
} }
} else { } else {
mem += fill_area->y1 * mem_width; /*Go to the first row*/ mem += fill_area->y1 * mem_width; /*Go to the first row*/
/*Run simpler function without opacity*/ /*Run simpler function without opacity*/
if(opa == LV_OPA_COVER) { if(opa == LV_OPA_COVER) {
/*Fill the first row with 'color'*/ /*Fill the first row with 'color'*/
for(col = fill_area->x1; col <= fill_area->x2; col++) { for(col = fill_area->x1; col <= fill_area->x2; col++) {
mem[col] = color; mem[col] = color;
} }
/*Copy the first row to all other rows*/ /*Copy the first row to all other rows*/
lv_color_t * mem_first = &mem[fill_area->x1]; lv_color_t * mem_first = &mem[fill_area->x1];
lv_coord_t copy_size = (fill_area->x2 - fill_area->x1 + 1) * sizeof(lv_color_t); lv_coord_t copy_size = (fill_area->x2 - fill_area->x1 + 1) * sizeof(lv_color_t);
mem += mem_width; mem += mem_width;
for(row = fill_area->y1 + 1; row <= fill_area->y2; row++) { for(row = fill_area->y1 + 1; row <= fill_area->y2; row++) {
memcpy(&mem[fill_area->x1], mem_first, copy_size); memcpy(&mem[fill_area->x1], mem_first, copy_size);
mem += mem_width; mem += mem_width;
} }
} }
/*Calculate with alpha too*/ /*Calculate with alpha too*/
else { else {
lv_color_t bg_tmp = LV_COLOR_BLACK; lv_color_t bg_tmp = LV_COLOR_BLACK;
lv_color_t opa_tmp = lv_color_mix(color, bg_tmp, opa); lv_color_t opa_tmp = lv_color_mix(color, bg_tmp, opa);
for(row = fill_area->y1; row <= fill_area->y2; row++) { for(row = fill_area->y1; row <= fill_area->y2; row++) {
for(col = fill_area->x1; col <= fill_area->x2; col++) { for(col = fill_area->x1; col <= fill_area->x2; col++) {
/*If the bg color changed recalculate the result color*/ /*If the bg color changed recalculate the result color*/
if(mem[col].full != bg_tmp.full) { if(mem[col].full != bg_tmp.full) {
bg_tmp = mem[col]; bg_tmp = mem[col];
opa_tmp = lv_color_mix(color, bg_tmp, opa); opa_tmp = lv_color_mix(color, bg_tmp, opa);
} }
mem[col] = opa_tmp; mem[col] = opa_tmp;
} }
mem += mem_width; mem += mem_width;
} }
} }
} }
} }

View File

@@ -64,7 +64,7 @@ static lv_signal_func_t ancestor_signal;
*/ */
lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy) lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy)
{ {
LV_LOG_TRACE("button matrix create started"); LV_LOG_TRACE("button matrix create started");
/*Create the ancestor object*/ /*Create the ancestor object*/
lv_obj_t * new_btnm = lv_obj_create(par, copy); lv_obj_t * new_btnm = lv_obj_create(par, copy);
@@ -124,7 +124,7 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy)
lv_btnm_set_map(new_btnm, lv_btnm_get_map(copy)); lv_btnm_set_map(new_btnm, lv_btnm_get_map(copy));
} }
LV_LOG_INFO("button matrix created"); LV_LOG_INFO("button matrix created");
return new_btnm; return new_btnm;
} }
@@ -505,11 +505,9 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
lv_point_t p; lv_point_t p;
if(sign == LV_SIGNAL_CLEANUP) { if(sign == LV_SIGNAL_CLEANUP) {
lv_mem_free(ext->button_areas); lv_mem_free(ext->button_areas);
} } else if(sign == LV_SIGNAL_STYLE_CHG || sign == LV_SIGNAL_CORD_CHG) {
else if(sign == LV_SIGNAL_STYLE_CHG || sign == LV_SIGNAL_CORD_CHG) {
lv_btnm_set_map(btnm, ext->map_p); lv_btnm_set_map(btnm, ext->map_p);
} } else if(sign == LV_SIGNAL_PRESSING) {
else if(sign == LV_SIGNAL_PRESSING) {
uint16_t btn_pr; uint16_t btn_pr;
/*Search the pressed area*/ /*Search the pressed area*/
lv_indev_get_point(param, &p); lv_indev_get_point(param, &p);
@@ -549,8 +547,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
} }
} }
} }
} } else if(sign == LV_SIGNAL_RELEASED) {
else if(sign == LV_SIGNAL_RELEASED) {
if(ext->btn_id_pr != LV_BTNM_PR_NONE) { if(ext->btn_id_pr != LV_BTNM_PR_NONE) {
if(ext->action) { if(ext->action) {
uint16_t txt_i = get_button_text(btnm, ext->btn_id_pr); uint16_t txt_i = get_button_text(btnm, ext->btn_id_pr);
@@ -586,34 +583,31 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
/*Leave the clicked button as pressed if this the focused object in a group*/ /*Leave the clicked button as pressed if this the focused object in a group*/
lv_group_t * g = lv_obj_get_group(btnm); lv_group_t * g = lv_obj_get_group(btnm);
if(lv_group_get_focused(g) != btnm) { if(lv_group_get_focused(g) != btnm) {
ext->btn_id_pr = LV_BTNM_PR_NONE; ext->btn_id_pr = LV_BTNM_PR_NONE;
} }
#else #else
ext->btn_id_pr = LV_BTNM_PR_NONE; ext->btn_id_pr = LV_BTNM_PR_NONE;
#endif #endif
} }
} } else if(sign == LV_SIGNAL_PRESS_LOST || sign == LV_SIGNAL_DEFOCUS) {
else if(sign == LV_SIGNAL_PRESS_LOST || sign == LV_SIGNAL_DEFOCUS) {
ext->btn_id_pr = LV_BTNM_PR_NONE; ext->btn_id_pr = LV_BTNM_PR_NONE;
lv_obj_invalidate(btnm); lv_obj_invalidate(btnm);
} } else if(sign == LV_SIGNAL_FOCUS) {
else if(sign == LV_SIGNAL_FOCUS) {
#if USE_LV_GROUP #if USE_LV_GROUP
lv_indev_t * indev = lv_indev_get_act(); lv_indev_t * indev = lv_indev_get_act();
if(lv_obj_is_focused(btnm) && lv_indev_get_type(indev) == LV_INDEV_TYPE_POINTER) { if(lv_obj_is_focused(btnm) && lv_indev_get_type(indev) == LV_INDEV_TYPE_POINTER) {
lv_point_t p; lv_point_t p1;
lv_indev_get_point(indev, &p); lv_indev_get_point(indev, &p1);
uint16_t btn_i = get_button_from_point(btnm, &p); uint16_t btn_i = get_button_from_point(btnm, &p1);
ext->btn_id_pr = btn_i; ext->btn_id_pr = btn_i;
} else { } else {
ext->btn_id_pr = 0; ext->btn_id_pr = 0;
} }
#else #else
ext->btn_id_pr = 0; ext->btn_id_pr = 0;
#endif #endif
lv_obj_invalidate(btnm); lv_obj_invalidate(btnm);
} } else if(sign == LV_SIGNAL_CONTROLL) {
else if(sign == LV_SIGNAL_CONTROLL) {
char c = *((char *)param); char c = *((char *)param);
if(c == LV_GROUP_KEY_RIGHT) { if(c == LV_GROUP_KEY_RIGHT) {
if(ext->btn_id_pr == LV_BTNM_PR_NONE) ext->btn_id_pr = 0; if(ext->btn_id_pr == LV_BTNM_PR_NONE) ext->btn_id_pr = 0;
@@ -624,8 +618,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
if(ext->btn_id_pr == LV_BTNM_PR_NONE) ext->btn_id_pr = 0; if(ext->btn_id_pr == LV_BTNM_PR_NONE) ext->btn_id_pr = 0;
if(ext->btn_id_pr > 0) ext->btn_id_pr--; if(ext->btn_id_pr > 0) ext->btn_id_pr--;
lv_obj_invalidate(btnm); lv_obj_invalidate(btnm);
} } else if(c == LV_GROUP_KEY_DOWN) {
else if(c == LV_GROUP_KEY_DOWN) {
lv_style_t * style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BG); lv_style_t * style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BG);
/*Find the area below the the current*/ /*Find the area below the the current*/
if(ext->btn_id_pr == LV_BTNM_PR_NONE) { if(ext->btn_id_pr == LV_BTNM_PR_NONE) {
@@ -645,8 +638,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
if(area_below < ext->btn_cnt) ext->btn_id_pr = area_below; if(area_below < ext->btn_cnt) ext->btn_id_pr = area_below;
} }
lv_obj_invalidate(btnm); lv_obj_invalidate(btnm);
} } else if(c == LV_GROUP_KEY_UP) {
else if(c == LV_GROUP_KEY_UP) {
lv_style_t * style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BG); lv_style_t * style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BG);
/*Find the area below the the current*/ /*Find the area below the the current*/
if(ext->btn_id_pr == LV_BTNM_PR_NONE) { if(ext->btn_id_pr == LV_BTNM_PR_NONE) {
@@ -666,8 +658,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
} }
lv_obj_invalidate(btnm); lv_obj_invalidate(btnm);
} } else if(c == LV_GROUP_KEY_ENTER) {
else if(c == LV_GROUP_KEY_ENTER) {
if(ext->action != NULL) { if(ext->action != NULL) {
uint16_t txt_i = get_button_text(btnm, ext->btn_id_pr); uint16_t txt_i = get_button_text(btnm, ext->btn_id_pr);
if(txt_i != LV_BTNM_PR_NONE) { if(txt_i != LV_BTNM_PR_NONE) {
@@ -675,19 +666,17 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
} }
} }
} }
} else if(sign == LV_SIGNAL_GET_EDITABLE) {
bool * editable = (bool *)param;
*editable = true;
} 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*/
if(buf->type[i] == NULL) break;
}
buf->type[i] = "lv_btnm";
} }
else if(sign == LV_SIGNAL_GET_EDITABLE) {
bool * editable = (bool *)param;
*editable = true;
}
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*/
if(buf->type[i] == NULL) break;
}
buf->type[i] = "lv_btnm";
}
return res; return res;

View File

@@ -54,7 +54,7 @@ static lv_signal_func_t ancestor_signal;
*/ */
lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy) lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy)
{ {
LV_LOG_TRACE("image create started"); LV_LOG_TRACE("image create started");
lv_obj_t * new_img = NULL; lv_obj_t * new_img = NULL;
@@ -83,15 +83,15 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy)
if(copy == NULL) { if(copy == NULL) {
lv_obj_set_click(new_img, false); lv_obj_set_click(new_img, false);
/* Enable auto size for non screens /* Enable auto size for non screens
* because image screens are wallpapers * because image screens are wallpapers
* and must be screen sized*/ * and must be screen sized*/
if(par != NULL) { if(par != NULL) {
ext->auto_size = 1; ext->auto_size = 1;
lv_obj_set_style(new_img, NULL); /*Inherit the style by default*/ lv_obj_set_style(new_img, NULL); /*Inherit the style by default*/
} else { } else {
ext->auto_size = 0; ext->auto_size = 0;
lv_obj_set_style(new_img, &lv_style_plain); /*Set a style for screens*/ lv_obj_set_style(new_img, &lv_style_plain); /*Set a style for screens*/
} }
} else { } else {
lv_img_ext_t * copy_ext = lv_obj_get_ext_attr(copy); lv_img_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
@@ -103,7 +103,7 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy)
} }
LV_LOG_INFO("image created"); LV_LOG_INFO("image created");
return new_img; return new_img;
} }
@@ -135,13 +135,12 @@ void lv_img_set_src(lv_obj_t * img, const void * src_img)
} }
lv_img_header_t header; lv_img_header_t header;
lv_img_dsc_get_info(src_img, &header); lv_img_dsc_get_info(src_img, &header);
/*Save the source*/ /*Save the source*/
if(src_type == LV_IMG_SRC_VARIABLE) { if(src_type == LV_IMG_SRC_VARIABLE) {
ext->src = src_img; ext->src = src_img;
} } else if(src_type == LV_IMG_SRC_FILE || src_type == LV_IMG_SRC_SYMBOL) {
else if(src_type == LV_IMG_SRC_FILE || src_type == LV_IMG_SRC_SYMBOL) {
/* If the new and the old src are the same then it was only a refresh.*/ /* If the new and the old src are the same then it was only a refresh.*/
if(ext->src != src_img) { if(ext->src != src_img) {
lv_mem_free(ext->src); lv_mem_free(ext->src);
@@ -151,21 +150,19 @@ void lv_img_set_src(lv_obj_t * img, const void * src_img)
strcpy(new_str, src_img); strcpy(new_str, src_img);
ext->src = new_str; ext->src = new_str;
} }
} } else if(src_type == LV_IMG_SRC_SYMBOL) {
/*`lv_img_dsc_get_info` couldn't set the with and height of a font so set it here*/
if(src_type == LV_IMG_SRC_SYMBOL) { lv_style_t * style = lv_img_get_style(img);
/*`lv_img_dsc_get_info` couldn't set the with and height of a font so set it here*/ lv_point_t size;
lv_style_t * style = lv_img_get_style(img); lv_txt_get_size(&size, src_img, style->text.font, style->text.letter_space, style->text.line_space, LV_COORD_MAX, LV_TXT_FLAG_NONE);
lv_point_t size; header.w = size.x;
lv_txt_get_size(&size, src_img, style->text.font, style->text.letter_space, style->text.line_space, LV_COORD_MAX, LV_TXT_FLAG_NONE); header.h = size.y;
header.w = size.x; }
header.h = size.y;
}
ext->src_type = src_type; ext->src_type = src_type;
ext->w = header.w; ext->w = header.w;
ext->h = header.h; ext->h = header.h;
ext->cf = header.cf; ext->cf = header.cf;
if(lv_img_get_auto_size(img) != false) { if(lv_img_get_auto_size(img) != false) {
lv_obj_set_size(img, ext->w, ext->h); lv_obj_set_size(img, ext->w, ext->h);
@@ -278,12 +275,9 @@ static bool lv_img_design(lv_obj_t * img, const lv_area_t * mask, lv_design_mode
} }
} else if(ext->src_type == LV_IMG_SRC_SYMBOL) { } else if(ext->src_type == LV_IMG_SRC_SYMBOL) {
lv_draw_label(&coords, mask, style, opa_scale, ext->src, LV_TXT_FLAG_NONE, NULL); lv_draw_label(&coords, mask, style, opa_scale, ext->src, LV_TXT_FLAG_NONE, NULL);
} else { } else {
/*Trigger the error handler of image drawer*/ /*Trigger the error handler of image drawer*/
lv_draw_img(&img->coords, mask, NULL, style, opa_scale); lv_draw_img(&img->coords, mask, NULL, style, opa_scale);
} }
} }