BigW Consortium Gitlab

Commit 2cb9d8ed by Gabor

Merge symbols: solve conficts

parent 398d5e32
......@@ -61,6 +61,8 @@
#define USE_FONT_DEJAVU_40 1
#define USE_FONT_DEJAVU_60 1
#define USE_FONT_DEJAVU_80 1
#define USE_FONT_SYMBOL_30 1
#define USE_FONT_SYMBOL_60 1
#define LV_FONT_DEFAULT FONT_DEJAVU_30 /*Always set a default font*/
#define LV_TXT_BREAK_CHARS " ,.;-" /*Can break texts on these chars*/
......@@ -93,10 +95,17 @@
/*Line (dependencies: -*/
#define USE_LV_LINE 1
/*Image (dependencies: from misc: fsint, ufs)*/
/*Image (dependencies: lv_label (if symbols are enabled) from misc: FSINT, UFS)*/
#define USE_LV_IMG 1
#if USE_LV_IMG != 0
//#define LV_IMG_DEF_WALLPAPER img_wallpaper_var /*Comment this line to NOT use wallpaper*/
#define LV_IMG_DEF_WALLPAPER img_square_x2 /*Comment this line to NOT use wallpaper*/
/* 1: enables to interpret the file names as symbol name
* from symbol_def.h if they begin with a lower case letter.
* (driver letters are always upper case)*/
#define LV_IMG_ENABLE_SYMBOLS 1
#if LV_IMG_ENABLE_SYMBOLS != 0
#define LV_IMG_DEF_SYMBOL_FONT FONT_SYMBOL_30
#endif /*LV_IMG_ENABLE_SYMBOLS*/
#endif /*USE_LV_IMG*/
/*Page (dependencies: lv_rect)*/
......
......@@ -59,9 +59,8 @@ void lv_rletter(const point_t * pos_p, const area_t * mask_p,
* @param recolor_opa the intense of recoloring (not supported)
*/
void lv_rmap(const area_t * cords_p, const area_t * mask_p,
const color_t * map_p, opa_t opa, bool transp, bool upscale,
color_t recolor, opa_t recolor_opa);
const color_t * map_p, opa_t opa, bool transp, bool upscale,
color_t recolor, opa_t recolor_opa);
/**********************
* MACROS
**********************/
......
......@@ -68,6 +68,7 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p,
color_t recolor, opa_t recolor_opa);
/**********************
* MACROS
**********************/
......
......@@ -6,6 +6,7 @@
/*********************
* INCLUDES
*********************/
#include <lvgl/lv_misc/fonts/symbol_30.h>
#include <stddef.h>
#include "font.h"
#include "fonts/dejavu_8.h"
......@@ -16,6 +17,8 @@
#include "fonts/dejavu_40.h"
#include "fonts/dejavu_60.h"
#include "fonts/dejavu_80.h"
#include "fonts/symbol_30.h"
#include "fonts/symbol_60.h"
/*********************
* DEFINES
......@@ -100,6 +103,18 @@ const font_t * font_get(font_types_t font_id)
font_p = dejavu_80_get_dsc();
break;
#endif
#if USE_FONT_SYMBOL_30 != 0
case FONT_SYMBOL_30:
font_p = symbol_30_get_dsc();
break;
#endif
#if USE_FONT_SYMBOL_60 != 0
case FONT_SYMBOL_60:
font_p = symbol_60_get_dsc();
break;
#endif
default:
font_p = NULL;
}
......
......@@ -47,6 +47,12 @@ typedef enum
#if USE_FONT_DEJAVU_80 != 0
FONT_DEJAVU_80,
#endif
#if USE_FONT_SYMBOL_30 != 0
FONT_SYMBOL_30,
#endif
#if USE_FONT_SYMBOL_60 != 0
FONT_SYMBOL_60,
#endif
FONT_TYPE_NUM,
}font_types_t;
......
#ifndef SYMBOL_30_H
#define SYMBOL_30_H
/*Use ISO8859-1 encoding in the IDE*/
#include "lv_conf.h"
#if USE_FONT_SYMBOL_30 != 0
#include <stdint.h>
#include "../font.h"
const font_t * symbol_30_get_dsc(void);
#endif
#endif
This source diff could not be displayed because it is too large. You can view the blob instead.
#ifndef SYMBOL_60_H
#define SYMBOL_60_H
/*Use ISO8859-1 encoding in the IDE*/
#include "lv_conf.h"
#if USE_FONT_SYMBOL_60 != 0
#include <stdint.h>
#include "../font.h"
const font_t * symbol_60_get_dsc(void);
#endif
#endif
#ifndef SYMBOL_DEF_H
#define SYMBOL_DEF_H
/*Use ISO8859-1 encoding in the IDE*/
#include "lv_conf.h"
#if USE_FONT_SYMBOL_30 != 0
#include <stdint.h>
#include "../font.h"
#define SYMBOL_DRIVE "a"
#define SYMBOL_FILE "b"
#define SYMBOL_FOLDER "c"
#define SYMBOL_DELETE "d"
#define SYMBOL_SAVE "e"
#define SYMBOL_EDIT "f"
#define SYMBOL_OK "g"
#define SYMBOL_CLOSE "h"
#define SYMBOL_DOWN "i"
#define SYMBOL_LEFT "j"
#define SYMBOL_RIGHT "k"
#define SYMBOL_UP "l"
#define SYMBOL_BT "m"
#define SYMBOL_THERM "n"
#define SYMBOL_GPS "o"
#define SYMBOL_WARN "p"
#define SYMBOL_INFO "q"
#define SYMBOL_BATT1 "r"
#define SYMBOL_BATT2 "s"
#define SYMBOL_BATT3 "t"
#define SYMBOL_BATT4 "u"
#define SYMBOL_BATTCH "v"
#define SYMBOL_HELP "w"
#define SYMBOL_POWER "x"
#define SYMBOL_SETUP "y"
#define SYMBOL_WIFI "z"
#endif
#endif /*SYMBOL_DEF_H*/
......@@ -47,12 +47,16 @@ static bool txt_is_break_char(char letter);
void txt_get_size(point_t * size_res, const char * text, const font_t * font,
uint16_t letter_space, uint16_t line_space, cord_t max_width)
{
size_res->x = 0;
size_res->y = 0;
if(text == NULL) return;
if(font == NULL) return;
uint32_t line_start = 0;
uint32_t new_line_start = 0;
cord_t act_line_length;
uint8_t letter_height = font_get_height(font);
size_res->x = 0;
size_res->y = 0;
/*Calc. the height and longest line*/
while (text[line_start] != '\0')
......@@ -82,14 +86,17 @@ void txt_get_size(point_t * size_res, const char * text, const font_t * font,
/**
* Get the next line of text. Check line length and break chars too.
* @param txt a '\0' terminated string
* @param font_p pointer to a font
* @param font pointer to a font
* @param letter_space letter space
* @param max_l max line length
* @return the index of the first char of the new line
*/
uint16_t txt_get_next_line(const char * txt, const font_t * font_p,
uint16_t txt_get_next_line(const char * txt, const font_t * font,
uint16_t letter_space, cord_t max_l)
{
if(txt == NULL) return 0;
if(font == NULL) return 0;
uint32_t i = 0;
cord_t act_l = 0;
uint16_t last_break = TXT_NO_BREAK_FOUND;
......@@ -106,7 +113,7 @@ uint16_t txt_get_next_line(const char * txt, const font_t * font_p,
return i+1; /*Return with the first letter of the next line*/
} else { /*Check the actual length*/
act_l += font_get_width(font_p, txt[i]);
act_l += font_get_width(font, txt[i]);
/*If the txt is too long then finish, this is the line end*/
if(act_l > max_l) {
......@@ -142,26 +149,29 @@ uint16_t txt_get_next_line(const char * txt, const font_t * font_p,
* Give the length of a text with a given font
* @param txt a '\0' terminate string
* @param char_num number of characters in 'txt'
* @param font_p pointer to a font
* @param font pointer to a font
* @param letter_space letter sapce
* @return length of a char_num long text
*/
cord_t txt_get_width(const char * txt, uint16_t char_num,
const font_t * font_p, uint16_t letter_space)
const font_t * font, uint16_t letter_space)
{
if(txt == NULL) return 0;
if(font == NULL) return 0;
uint16_t i;
cord_t len = 0;
if(char_num != 0) {
for(i = 0; i < char_num; i++) {
len += font_get_width(font_p, txt[i]);
len += font_get_width(font, txt[i]);
len += letter_space;
}
/*Trim closing spaces */
for(i = char_num - 1; i > 0; i--) {
if(txt[i] == ' ') {
len -= font_get_width(font_p, txt[i]);
len -= font_get_width(font, txt[i]);
len -= letter_space;
} else {
break;
......
......@@ -15,6 +15,10 @@
#include "misc/fs/fsint.h"
#include "misc/fs/ufs/ufs.h"
#if LV_IMG_ENABLE_SYMBOLS != 0
#include "../lv_misc/text.h"
#endif
/*********************
* DEFINES
*********************/
......@@ -29,6 +33,8 @@
static bool lv_img_design(lv_obj_t * img, const area_t * mask, lv_design_mode_t mode);
static void lv_imgs_init(void);
static bool lv_img_is_symbol(const char * txt);
/**********************
* STATIC VARIABLES
**********************/
......@@ -186,28 +192,53 @@ void lv_img_set_file(lv_obj_t * img, const char * fn)
{
lv_img_ext_t * ext = lv_obj_get_ext(img);
fs_file_t file;
fs_res_t res;
lv_img_raw_header_t header;
uint32_t rn;
res = fs_open(&file, fn, FS_MODE_RD);
if(res == FS_RES_OK) {
res = fs_read(&file, &header, sizeof(header), &rn);
}
/*Handle normal images*/
if(lv_img_is_symbol(fn) == false) {
fs_file_t file;
fs_res_t res;
lv_img_raw_header_t header;
uint32_t rn;
res = fs_open(&file, fn, FS_MODE_RD);
if(res == FS_RES_OK) {
res = fs_read(&file, &header, sizeof(header), &rn);
}
/*Create a dummy header on fs error*/
if(res != FS_RES_OK || rn != sizeof(header)) {
header.w = lv_obj_get_width(img);
header.h = lv_obj_get_height(img);
header.transp = 0;
}
/*Create a dummy header on fs error*/
if(res != FS_RES_OK || rn != sizeof(header)) {
header.w = lv_obj_get_width(img);
header.h = lv_obj_get_height(img);
header.transp = 0;
}
fs_close(&file);
fs_close(&file);
ext->w = header.w;
ext->h = header.h;
ext->transp = header.transp;
ext->w = header.w;
ext->h = header.h;
ext->transp = header.transp;
if(ext->upscale != 0) {
ext->w *= 2;
ext->h *= 2;
}
}
/*Handle symbol texts*/
else {
#if LV_IMG_ENABLE_SYMBOLS
lv_imgs_t * imgs = lv_obj_get_style(img);
point_t size;
txt_get_size(&size, fn, font_get(imgs->sym_font), 0, 0, LV_CORD_MAX);
ext->w = size.x;
ext->h = size.y;
ext->transp = 0;
#else
/*Never goes here, just to be sure handle this */
ext->w = lv_obj_get_width(img);
ext->h = lv_obj_get_height(img);
ext->transp = 0;
#endif
}
if(ext->upscale != 0) {
ext->w *= LV_DOWNSCALE;
......@@ -221,8 +252,9 @@ void lv_img_set_file(lv_obj_t * img, const char * fn)
ext->fn = NULL;
}
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);
}
lv_obj_inv(img);
......@@ -241,6 +273,7 @@ void lv_img_set_auto_size(lv_obj_t * img, bool en)
ext->auto_size = (en == false ? 0 : 1);
}
/**
* Enable the upscaling with LV_DOWNSCALE.
* If enabled the object size will be same as the picture size.
......@@ -313,6 +346,17 @@ static bool lv_img_design(lv_obj_t * img, const area_t * mask, lv_design_mode_t
} else if(mode == LV_DESIGN_DRAW_MAIN) {
if(ext->h == 0 || ext->w == 0) return true;
area_t cords;
/*Create a default style for symbol texts*/
#if LV_IMG_ENABLE_SYMBOLS != 0
bool sym = lv_img_is_symbol(ext->fn);
lv_labels_t sym_style;
lv_labels_get(LV_LABELS_DEF, &sym_style);
sym_style.font = imgs_p->sym_font;
sym_style.letter_space = 0;
sym_style.line_space = 0;
sym_style.mid = 0;
sym_style.objs.color = imgs_p->objs.color;
#endif
lv_obj_get_cords(img, &cords);
opa_t opa = lv_obj_get_opa(img);
......@@ -325,13 +369,42 @@ static bool lv_img_design(lv_obj_t * img, const area_t * mask, lv_design_mode_t
cords_tmp.x1 = cords.x1;
cords_tmp.x2 = cords.x1 + ext->w - 1;
for(; cords_tmp.x1 < cords.x2; cords_tmp.x1 += ext->w, cords_tmp.x2 += ext->w) {
lv_draw_img(&cords_tmp, mask, imgs_p, opa, ext->fn);
#if LV_IMG_ENABLE_SYMBOLS == 0
lv_draw_img(&cords_tmp, mask, imgs_p, opa, ext->fn);
#else
if(sym == false) lv_draw_img(&cords_tmp, mask, imgs_p, opa, ext->fn);
else lv_draw_label(&cords_tmp, mask, &sym_style, opa, ext->fn);
#endif
}
}
}
return true;
}
/**
* From the settings in lv_conf.h and the file name
* tells it a filename or a symbol text.
* @param txt a file name (e.g. "U:/file1") or a symbol (e.g. SYMBOL_OK)
* @return true: 'txt' is a symbol text, false: 'txt' is a file name
*/
static bool lv_img_is_symbol(const char * txt)
{
/*If the symbols are not enabled always tell false*/
#if LV_IMG_ENABLE_SYMBOLS == 0
return false;
#endif
/* if txt begins with an upper case letter then it refers to a driver
* so it is a file name*/
if(txt[0] >= 'A' && txt[0] <= 'Z') return false;
/*If not returned during the above tests then it is symbol text*/
return true;
}
/**
* Initialize the image styles
*/
......@@ -340,7 +413,9 @@ static void lv_imgs_init(void)
/*Default style*/
lv_imgs_def.objs.color = COLOR_BLACK;
lv_imgs_def.recolor_opa = OPA_TRANSP;
#if LV_IMG_ENABLE_SYMBOLS != 0
lv_imgs_def.sym_font = LV_IMG_DEF_SYMBOL_FONT;
#endif
/*Dark style*/
memcpy(&lv_imgs_dark, &lv_imgs_def, sizeof(lv_imgs_t));
lv_imgs_dark.objs.color = COLOR_BLACK; lv_imgs_dark.recolor_opa = OPA_50;
......
......@@ -24,6 +24,11 @@
#include "../lv_obj/lv_obj.h"
#include "misc/fs/fsint.h"
#if LV_IMG_ENABLE_SYMBOLS
#include "lv_label.h"
#include "../lv_misc/fonts/symbol_def.h"
#endif
/*********************
* DEFINES
*********************/
......@@ -49,7 +54,10 @@ typedef struct
{
lv_objs_t objs; /*Style of ancestor*/
/*New style element for this type */
opa_t recolor_opa; /*Intensity of recoloring (OPA_TRANSP, OPA_10 ... OPA_COVER)*/
opa_t recolor_opa; /*Intensity of recoloring (OPA_TRANSP, OPA_10 ... OPA_COVER)*/
#if LV_IMG_ENABLE_SYMBOLS != 0
font_types_t sym_font; /*Symbol font*/
#endif
}lv_imgs_t;
/*Built-in styles of image*/
......@@ -60,16 +68,18 @@ typedef enum
LV_IMGS_DARK,
}lv_imgs_builtin_t;
/* Image header it is compatible with
* the result image converter utility*/
typedef struct
{
uint16_t w; /*Width of the image map*/
uint16_t h; /*Height of the image map*/
uint16_t cd; /*Color depth (8/16 or 24)*/
uint16_t transp :1; /*1: Do not draw LV_IMG_TRANSP_COLOR pixels*/
uint16_t w; /*Width of the image map*/
uint16_t h; /*Height of the image map*/
uint16_t cd; /*Color depth (8/16 or 24)*/
uint16_t transp :1; /*1: Do not draw LV_IMG_TRANSP_COLOR pixels*/
}lv_img_raw_header_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
......@@ -136,6 +146,7 @@ void lv_img_set_upscale(lv_obj_t * img, bool en);
*/
bool lv_img_get_auto_size(lv_obj_t * img);
/**
* Get the upscale enable attribute
* @param img pointer to an image
......@@ -143,6 +154,10 @@ bool lv_img_get_auto_size(lv_obj_t * img);
*/
bool lv_img_get_upscale(lv_obj_t * img);
lv_imgs_t * lv_imgs_get(lv_imgs_builtin_t style, lv_imgs_t * copy);
/**********************
* MACROS
**********************/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment