Merge branch 'master' into font_icon

This commit is contained in:
Gabor Kiss-Vamosi
2017-01-16 13:47:39 +01:00
committed by GitHub
67 changed files with 4030 additions and 1002 deletions

View File

@@ -51,12 +51,43 @@ typedef struct
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Init. the animation module
*/
void anim_init(void);
/**
* Create an animation
* @param anim_p an initialized 'anim_t' variable. Not required after call.
*/
void anim_create(anim_t * anim_p);
anim_path_t * anim_get_path(anim_path_name_t type);
/**
* Delete an animation for a variable with a given animatior function
* @param var pointer to variable
* @param fp a function pointer which is animating 'var',
* or NULL to ignore it and delete all animation with 'var
* @return true: at least 1 animation is deleted, false: no animation is deleted
*/
bool anim_del(void * var, anim_fp_t fp);
/**
* Calculate the time of an animation with a given speed and the start and end values
* @param speed speed of animation in unit/sec
* @param start start value of the animation
* @param end end value of the animation
* @return the required time [ms] for the animation with the given parameters
*/
uint16_t anim_speed_to_time(uint16_t speed, int32_t start, int32_t end);
/**
* Get a predefine animation path
* @param name name of the path from 'anim_path_name_t'
* @return pointer to the path array
*/
anim_path_t * anim_get_path(anim_path_name_t name);
/**********************
* MACROS
**********************/

View File

@@ -49,16 +49,32 @@ void area_set(area_t * area_p, cord_t x1, cord_t y1, cord_t x2, cord_t y2)
area_p->y2 = y2;
}
/**
* Set the width of an area
* @param area_p pointer to an area
* @param w the new width of the area (w == 1 makes x1 == x2)
*/
void area_set_width(area_t * area_p, cord_t w)
{
area_p->x2 = area_p->x1 + w - 1;
}
/**
* Set the height of an area
* @param area_p pointer to an area
* @param h the new height of the area (h == 1 makes y1 == y2)
*/
void area_set_height(area_t * area_p, cord_t h)
{
area_p->y2 = area_p->y1 + h - 1;
}
/**
* Set the position of an area (width and height will be kept)
* @param area_p pointer to an area
* @param x the new x coordinate of the area
* @param y the new y coordinate of the area
*/
void area_set_pos(area_t * area_p, cord_t x, cord_t y)
{
cord_t w = area_get_width(area_p);
@@ -94,10 +110,10 @@ uint32_t area_get_size(const area_t * area_p)
bool area_union(area_t * res_p, const area_t * a1_p, const area_t * a2_p)
{
/* Get the smaller area from 'a1_p' and 'a2_p' */
res_p->x1 = max(a1_p->x1, a2_p->x1);
res_p->y1 = max(a1_p->y1, a2_p->y1);
res_p->x2 = min(a1_p->x2, a2_p->x2);
res_p->y2 = min(a1_p->y2, a2_p->y2);
res_p->x1 = MATH_MAX(a1_p->x1, a2_p->x1);
res_p->y1 = MATH_MAX(a1_p->y1, a2_p->y1);
res_p->x2 = MATH_MIN(a1_p->x2, a2_p->x2);
res_p->y2 = MATH_MIN(a1_p->y2, a2_p->y2);
/*If x1 or y1 greater then x2 or y2 then the areas union is empty*/
bool union_ok = true;
@@ -117,10 +133,10 @@ bool area_union(area_t * res_p, const area_t * a1_p, const area_t * a2_p)
*/
void area_join(area_t * a_res_p, const area_t * a1_p, const area_t * a2_p)
{
a_res_p->x1 = min(a1_p->x1, a2_p->x1);
a_res_p->y1 = min(a1_p->y1, a2_p->y1);
a_res_p->x2 = max(a1_p->x2, a2_p->x2);
a_res_p->y2 = max(a1_p->y2, a2_p->y2);
a_res_p->x1 = MATH_MIN(a1_p->x1, a2_p->x1);
a_res_p->y1 = MATH_MIN(a1_p->y1, a2_p->y1);
a_res_p->x2 = MATH_MAX(a1_p->x2, a2_p->x2);
a_res_p->y2 = MATH_MAX(a1_p->y2, a2_p->y2);
}
/**
@@ -146,7 +162,8 @@ bool area_is_point_on(const area_t * a_p, const point_t * p_p)
* Check if two area has common parts
* @param a1_p pointer to an area.
* @param a2_p pointer to an other area
* @return false: a1_p and a2_p has no common parts */
* @return false: a1_p and a2_p has no common parts
*/
bool area_is_on(const area_t * a1_p, const area_t * a2_p)
{
/*Two area are on each other if... */

View File

@@ -41,31 +41,115 @@ typedef struct
* GLOBAL PROTOTYPES
**********************/
/**
* Initialize an area
* @param area_p pointer to an area
* @param x1 left coordinate of the area
* @param y1 top coordinate of the area
* @param x2 right coordinate of the area
* @param y2 bottom coordinate of the area
*/
void area_set(area_t * area_p, cord_t x1, cord_t y1, cord_t x2, cord_t y2);
/**
* Copy an area
* @param dest pointer to the destination area
* @param src pointer to the source area
*/
static void inline area_cpy(area_t * dest, const area_t * src)
{
memcpy(dest, src, sizeof(area_t));
}
/**
* Get the width of an area
* @param area_p pointer to an area
* @return the width of the area (if x1 == x2 -> width = 1)
*/
static inline cord_t area_get_width(const area_t * area_p)
{
return area_p->x2 - area_p->x1 + 1;
}
/**
* Get the height of an area
* @param area_p pointer to an area
* @return the height of the area (if y1 == y2 -> height = 1)
*/
static inline cord_t area_get_height(const area_t * area_p)
{
return area_p->y2 - area_p->y1 + 1;
}
void area_set(area_t * area_p, cord_t x1, cord_t y1, cord_t x2, cord_t y2);
/**
* Set the width of an area
* @param area_p pointer to an area
* @param w the new width of the area (w == 1 makes x1 == x2)
*/
void area_set_width(area_t * area_p, cord_t w);
/**
* Set the height of an area
* @param area_p pointer to an area
* @param h the new height of the area (h == 1 makes y1 == y2)
*/
void area_set_height(area_t * area_p, cord_t h);
/**
* Set the position of an area (width and height will be kept)
* @param area_p pointer to an area
* @param x the new x coordinate of the area
* @param y the new y coordinate of the area
*/
void area_set_pos(area_t * area_p, cord_t x, cord_t y);
/**
* Return with area of an area (x * y)
* @param area_p pointer to an area
* @return size of area
*/
uint32_t area_get_size(const area_t * area_p);
/**
* Get the common parts of two areas
* @param res_p pointer to an area, the result will be stored her
* @param a1_p pointer to the first area
* @param a2_p pointer to the second area
* @return false: the two area has NO common parts, res_p is invalid
*/
bool area_union(area_t * res_p, const area_t * a1_p, const area_t * a2_p);
/**
* Join two areas into a third which involves the other two
* @param res_p pointer to an area, the result will be stored here
* @param a1_p pointer to the first area
* @param a2_p pointer to the second area
*/
void area_join(area_t * a_res_p, const area_t * a1_p, const area_t * a2_p);
/**
* Check if a point is on an area
* @param a_p pointer to an area
* @param p_p pointer to a point
* @return false:the point is out of the area
*/
bool area_is_point_on(const area_t * a_p, const point_t * p_p);
/**
* Check if two area has common parts
* @param a1_p pointer to an area.
* @param a2_p pointer to an other area
* @return false: a1_p and a2_p has no common parts
*/
bool area_is_on(const area_t * a1_p, const area_t * a2_p);
bool area_is_in(const area_t * a_in, const area_t * a_holder);
/**
* Check if an area is fully on an other
* @param ain_p pointer to an area which could be on aholder_p
* @param aholder pointer to an area which could involve ain_p
* @return
*/
bool area_is_in(const area_t * ain_p, const area_t * aholder_p);
/**********************
* MACROS

View File

@@ -40,8 +40,27 @@
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initialize the circle drawing
* @param c pointer to a point. The coordinates will be calculated here
* @param tmp point to a variable. It will store temporary data
* @param radius radius of the circle
*/
void circ_init(point_t * c, cord_t * tmp, cord_t radius);
/**
* Test the circle drawing is ready or not
* @param c same as in circ_init
* @return true if the circle is not ready yet
*/
bool circ_cont(point_t * c);
/**
* Get the next point from the circle
* @param c same as in circ_init. The next point stored here.
* @param tmp same as in circ_init.
*/
void circ_next(point_t * c, cord_t * tmp);
/**********************

View File

@@ -6,6 +6,7 @@
/*********************
* INCLUDES
*********************/
#include <lvgl/lv_misc/fonts/symbol_30.h>
#include <stddef.h>
#include "font.h"
#include "fonts/dejavu_8.h"
@@ -108,6 +109,7 @@ const font_t * font_get(font_types_t font_id)
font_p = symbol_30_get_dsc();
break;
#endif
#if USE_FONT_SYMBOL_60 != 0
case FONT_SYMBOL_60:
font_p = symbol_60_get_dsc();
@@ -120,6 +122,40 @@ const font_t * font_get(font_types_t font_id)
return font_p;
}
/**
* Return with the bitmap of a font.
* @param font_p pointer to a font
* @param letter a letter
* @return pointer to the bitmap of the letter
*/
const uint8_t * font_get_bitmap(const font_t * font_p, uint8_t letter)
{
if(letter < font_p->start_ascii || letter >= font_p->start_ascii + font_p->letter_cnt) return NULL;
uint32_t index = (letter - font_p->start_ascii) * font_p->height_row * font_p->width_byte;
return &font_p->bitmaps_a[index];
}
/**
* Get the width of a letter in a font
* @param font_p pointer to a font
* @param letter a letter
* @return the width of a letter
*/
uint8_t font_get_width(const font_t * font_p, uint8_t letter)
{
if(letter < font_p->start_ascii) return 0;
letter -= font_p->start_ascii;
uint8_t w = 0;
if(letter < font_p->letter_cnt) {
w = font_p->fixed_width != 0 ? font_p->fixed_width :
font_p->width_bit_a[letter];
}
return w;
}
/**********************
* STATIC FUNCTIONS
**********************/

View File

@@ -98,25 +98,22 @@ typedef struct
/**********************
* GLOBAL PROTOTYPES
**********************/
const font_t * font_get(font_types_t letter);
/**********************
* MACROS
**********************/
/**
* Return with the bitmap of a font.
* Get the font from its id
* @param font_id: the id of a font (an element of font_types_t enum)
* @return pointer to a font descriptor
*/
const font_t * font_get(font_types_t font_id);
/**
* Return with the bitmap of a font.
* @param font_p pointer to a font
* @param letter a letter
* @return pointer to the bitmap of the letter
*/
static inline const uint8_t * font_get_bitmap(const font_t * font_p, uint8_t letter)
{
if(letter < font_p->start_ascii || letter >= font_p->start_ascii + font_p->letter_cnt) return NULL;
uint32_t index = (letter - font_p->start_ascii) * font_p->height_row * font_p->width_byte;
return &font_p->bitmaps_a[index];
}
const uint8_t * font_get_bitmap(const font_t * font_p, uint8_t letter);
/**
* Get the height of a font
@@ -128,24 +125,19 @@ static inline uint8_t font_get_height(const font_t * font_p)
return font_p->height_row;
}
/**
* Get the width of a letter in a font
* @param font_p pointer to a font
* @param letter a letter
* @return the width of a letter
*/
static inline uint8_t font_get_width(const font_t * font_p, uint8_t letter)
{
if(letter < font_p->start_ascii) return 0;
letter -= font_p->start_ascii;
uint8_t w = 0;
if(letter < font_p->letter_cnt) {
w = font_p->fixed_width != 0 ? font_p->fixed_width :
font_p->width_bit_a[letter];
}
uint8_t font_get_width(const font_t * font_p, uint8_t letter);
/**********************
* MACROS
**********************/
return w;
}
#endif

View File

@@ -6,7 +6,6 @@
#include "lv_conf.h"
#if USE_FONT_SYMBOL_30 != 0
#include <stdint.h>
#include "../font.h"

View File

@@ -4,7 +4,7 @@
#include <stdint.h>
#include "../font.h"
static const uint8_t symbol_60_bitmaps[12480] =
static const uint8_t symbol_60_bitmaps[12480] =
{
// ASCII: 97, char width: 60
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ------------------------------------------------------------....
@@ -1619,15 +1619,16 @@ static const uint8_t symbol_60_bitmaps[12480] =
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ----------------------------------------------------------------
};
static const uint8_t symbol_60_widths[26] =
static const uint8_t symbol_60_widths[26] =
{
60, 51, 64, 47, 51, 51, 60, 47,
60, 43, 43, 60, 34, 34, 47, 60,
49, 59, 59, 59, 59, 59, 60, 51,
51, 68,
60, 51, 64, 47, 51, 51, 60, 47,
60, 43, 43, 60, 34, 34, 47, 60,
49, 59, 59, 59, 59, 59, 60, 51,
51, 68,
};
static const font_t symbol_60_dsc =
static const font_t symbol_60_dsc =
{
26, // Letter count
97, // First ascii code
@@ -1644,4 +1645,4 @@ const font_t * symbol_60_get_dsc(void)
}
#endif
#endif

View File

@@ -6,11 +6,9 @@
#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

View File

@@ -0,0 +1,41 @@
#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*/

View File

@@ -35,15 +35,28 @@ static bool txt_is_break_char(char letter);
* GLOBAL FUNCTIONS
**********************/
/**
* Get size of a text
* @param size_res pointer to a 'point_t' variable to store the result
* @param text pointer to a text
* @param font pinter to font of the text
* @param letter_space letter space of the text
* @param line_space line space of the text
* @param max_width max with of the text (break the lines to fit this size) Set LV_CORD_MAX to avoid line breaks
*/
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')
@@ -56,7 +69,7 @@ void txt_get_size(point_t * size_res, const char * text, const font_t * font,
act_line_length = txt_get_width(&text[line_start], new_line_start - line_start,
font, letter_space);
size_res->x = max(act_line_length, size_res->x);
size_res->x = MATH_MAX(act_line_length, size_res->x);
line_start = new_line_start;
}
@@ -73,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;
@@ -97,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) {
@@ -133,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;

View File

@@ -26,10 +26,40 @@
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Get size of a text
* @param size_res pointer to a 'point_t' variable to store the result
* @param text pointer to a text
* @param font pinter to font of the text
* @param letter_space letter space of the text
* @param line_space line space of the text
* @param max_width max with of the text (break the lines to fit this size) Set LV_CORD_MAX to avoid line breaks
*/
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);
uint16_t txt_get_next_line(const char * txt, const font_t * font_p, uint16_t letter_space, cord_t max_l);
cord_t txt_get_width(const char * txt, uint16_t char_num, const font_t * font_p, uint16_t letter_space);
uint16_t letter_space, uint16_t line_space, cord_t max_width);
/**
* 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 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 letter_space, cord_t max_l);
/**
* 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 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);
/**********************
* MACROS