mirror of
https://github.com/lvgl/lvgl.git
synced 2024-11-30 21:24:07 +08:00
lv_misc: all functions are renamed
This commit is contained in:
parent
1fcda8092e
commit
a8ceb6bcaf
@ -6,6 +6,7 @@
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <lvgl/lv_misc/lv_txt.h>
|
||||
#include "lv_conf.h"
|
||||
|
||||
#include <stdio.h>
|
||||
@ -13,7 +14,6 @@
|
||||
#include "lv_draw.h"
|
||||
#include "lv_draw_rbasic.h"
|
||||
#include "lv_draw_vbasic.h"
|
||||
#include "../lv_misc/lv_text.h"
|
||||
#include "../lv_misc/lv_circ.h"
|
||||
#include "../lv_misc/lv_fs.h"
|
||||
#include "../lv_misc/lv_math.h"
|
||||
@ -145,17 +145,17 @@ void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, lv_colo
|
||||
|
||||
/*Draw the triangle*/
|
||||
lv_point_t edge1;
|
||||
lv_coord_t dx1 = MATH_ABS(tri[0].x - tri[1].x);
|
||||
lv_coord_t dx1 = LV_MATH_ABS(tri[0].x - tri[1].x);
|
||||
lv_coord_t sx1 = tri[0].x < tri[1].x ? 1 : -1;
|
||||
lv_coord_t dy1 = MATH_ABS(tri[0].y - tri[1].y);
|
||||
lv_coord_t dy1 = LV_MATH_ABS(tri[0].y - tri[1].y);
|
||||
lv_coord_t sy1 = tri[0].y < tri[1].y ? 1 : -1;
|
||||
lv_coord_t err1 = (dx1 > dy1 ? dx1 : -dy1) / 2;
|
||||
lv_coord_t err_tmp1;
|
||||
|
||||
lv_point_t edge2;
|
||||
lv_coord_t dx2 = MATH_ABS(tri[0].x - tri[2].x);
|
||||
lv_coord_t dx2 = LV_MATH_ABS(tri[0].x - tri[2].x);
|
||||
lv_coord_t sx2 = tri[0].x < tri[2].x ? 1 : -1;
|
||||
lv_coord_t dy2 = MATH_ABS(tri[0].y - tri[2].y);
|
||||
lv_coord_t dy2 = LV_MATH_ABS(tri[0].y - tri[2].y);
|
||||
lv_coord_t sy2 = tri[0].y < tri[2].y ? 1 : -1;
|
||||
lv_coord_t err2 = (dx1 > dy2 ? dx2 : -dy2) / 2;
|
||||
lv_coord_t err_tmp2;
|
||||
@ -177,10 +177,10 @@ void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, lv_colo
|
||||
act_area.y2 = edge2.y ;
|
||||
|
||||
|
||||
draw_area.x1 = MATH_MIN(act_area.x1, act_area.x2);
|
||||
draw_area.x2 = MATH_MAX(act_area.x1, act_area.x2);
|
||||
draw_area.y1 = MATH_MIN(act_area.y1, act_area.y2);
|
||||
draw_area.y2 = MATH_MAX(act_area.y1, act_area.y2);
|
||||
draw_area.x1 = LV_MATH_MIN(act_area.x1, act_area.x2);
|
||||
draw_area.x2 = LV_MATH_MAX(act_area.x1, act_area.x2);
|
||||
draw_area.y1 = LV_MATH_MIN(act_area.y1, act_area.y2);
|
||||
draw_area.y2 = LV_MATH_MAX(act_area.y1, act_area.y2);
|
||||
draw_area.x2--; /*Do not draw most right pixel because it will be drawn by the adjacent triangle*/
|
||||
fill_fp(&draw_area, mask, color, LV_OPA_50);
|
||||
|
||||
@ -189,9 +189,9 @@ void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, lv_colo
|
||||
do {
|
||||
if (edge1.x == tri[1].x && edge1.y == tri[1].y) {
|
||||
|
||||
dx1 = MATH_ABS(tri[1].x - tri[2].x);
|
||||
dx1 = LV_MATH_ABS(tri[1].x - tri[2].x);
|
||||
sx1 = tri[1].x < tri[2].x ? 1 : -1;
|
||||
dy1 = MATH_ABS(tri[1].y - tri[2].y);
|
||||
dy1 = LV_MATH_ABS(tri[1].y - tri[2].y);
|
||||
sy1 = tri[1].y < tri[2].y ? 1 : -1;
|
||||
err1 = (dx1 > dy1 ? dx1 : -dy1) / 2;
|
||||
}
|
||||
@ -236,30 +236,30 @@ void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, lv_colo
|
||||
*
|
||||
*/
|
||||
void lv_draw_label(const lv_area_t * coords,const lv_area_t * mask, const lv_style_t * style,
|
||||
const char * txt, txt_flag_t flag, lv_point_t * offset)
|
||||
const char * txt, lv_txt_flag_t flag, lv_point_t * offset)
|
||||
{
|
||||
const lv_font_t * font = style->text.font;
|
||||
lv_coord_t w;
|
||||
|
||||
if((flag & TXT_FLAG_EXPAND) == 0) {
|
||||
if((flag & LV_TXT_FLAG_EXPAND) == 0) {
|
||||
w = area_get_width(coords);
|
||||
} else {
|
||||
lv_point_t p;
|
||||
txt_get_size(&p, txt, style->text.font, style->text.letter_space, style->text.line_space, LV_COORD_MAX, flag);
|
||||
lv_txt_get_size(&p, txt, style->text.font, style->text.letter_space, style->text.line_space, LV_COORD_MAX, flag);
|
||||
w = p.x;
|
||||
}
|
||||
/*Init variables for the first line*/
|
||||
lv_coord_t line_length = 0;
|
||||
uint32_t line_start = 0;
|
||||
uint32_t line_end = txt_get_next_line(txt, font, style->text.letter_space, w, flag);
|
||||
uint32_t line_end = lv_txt_get_next_line(txt, font, style->text.letter_space, w, flag);
|
||||
|
||||
lv_point_t pos;
|
||||
pos.x = coords->x1;
|
||||
pos.y = coords->y1;
|
||||
|
||||
/*Align the line to middle if enabled*/
|
||||
if(flag & TXT_FLAG_CENTER) {
|
||||
line_length = txt_get_width(&txt[line_start], line_end - line_start,
|
||||
if(flag & LV_TXT_FLAG_CENTER) {
|
||||
line_length = lv_txt_get_width(&txt[line_start], line_end - line_start,
|
||||
font, style->text.letter_space, flag);
|
||||
pos.x += (w - line_length) / 2;
|
||||
}
|
||||
@ -283,12 +283,12 @@ void lv_draw_label(const lv_area_t * coords,const lv_area_t * mask, const lv_sty
|
||||
i = line_start;
|
||||
uint32_t letter;
|
||||
while(i < line_end) {
|
||||
letter = txt_utf8_next(txt, &i);
|
||||
letter = lv_txt_utf8_next(txt, &i);
|
||||
/*Handle the re-color command*/
|
||||
if((flag & TXT_FLAG_RECOLOR) != 0) {
|
||||
if(letter == TXT_RELV_COLOR_CMD) {
|
||||
if((flag & LV_TXT_FLAG_RECOLOR) != 0) {
|
||||
if(letter == LV_TXT_COLOR_CMD[0]) {
|
||||
if(cmd_state == CMD_STATE_WAIT) { /*Start char*/
|
||||
par_start = i + txt_utf8_size(txt[i]);
|
||||
par_start = i + lv_txt_utf8_size(txt[i]);
|
||||
cmd_state = CMD_STATE_PAR;
|
||||
continue;
|
||||
} else if(cmd_state == CMD_STATE_PAR) { /*Other start char in parameter escaped cmd. char */
|
||||
@ -329,12 +329,12 @@ void lv_draw_label(const lv_area_t * coords,const lv_area_t * mask, const lv_sty
|
||||
}
|
||||
/*Go to next line*/
|
||||
line_start = line_end;
|
||||
line_end += txt_get_next_line(&txt[line_start], font, style->text.letter_space, w, flag);
|
||||
line_end += lv_txt_get_next_line(&txt[line_start], font, style->text.letter_space, w, flag);
|
||||
|
||||
pos.x = coords->x1;
|
||||
/*Align to middle*/
|
||||
if(flag & TXT_FLAG_CENTER) {
|
||||
line_length = txt_get_width(&txt[line_start], line_end - line_start,
|
||||
if(flag & LV_TXT_FLAG_CENTER) {
|
||||
line_length = lv_txt_get_width(&txt[line_start], line_end - line_start,
|
||||
font, style->text.letter_space, flag);
|
||||
pos.x += (w - line_length) / 2;
|
||||
}
|
||||
@ -357,14 +357,14 @@ void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask,
|
||||
{
|
||||
if(fn == NULL) {
|
||||
lv_draw_rect(coords, mask, &lv_style_plain);
|
||||
lv_draw_label(coords, mask, &lv_style_plain, "No data", TXT_FLAG_NONE, NULL);
|
||||
lv_draw_label(coords, mask, &lv_style_plain, "No data", LV_TXT_FLAG_NONE, NULL);
|
||||
} else {
|
||||
fs_file_t file;
|
||||
fs_res_t res = fs_open(&file, fn, FS_MODE_RD);
|
||||
lv_fs_file_t file;
|
||||
lv_fs_res_t res = lv_fs_open(&file, fn, FS_MODE_RD);
|
||||
if(res == FS_RES_OK) {
|
||||
lv_img_raw_header_t header;
|
||||
uint32_t br;
|
||||
res = fs_read(&file, &header, sizeof(lv_img_raw_header_t), &br);
|
||||
res = lv_fs_read(&file, &header, sizeof(lv_img_raw_header_t), &br);
|
||||
|
||||
/*If the width is greater then real img. width then it is upscaled */
|
||||
bool upscale = false;
|
||||
@ -374,7 +374,7 @@ void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask,
|
||||
bool union_ok;
|
||||
union_ok = lv_area_union(&mask_com, mask, coords);
|
||||
if(union_ok == false) {
|
||||
fs_close(&file);
|
||||
lv_fs_close(&file);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -393,7 +393,7 @@ void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask,
|
||||
/*If the img. data is inside the MCU then do not use FS reading just a pointer*/
|
||||
if(fn[0] == UFS_LETTER) {
|
||||
const_data = true;
|
||||
uint8_t * f_data = ((ufs_file_t*)file.file_d)->ent->data_d;
|
||||
uint8_t * f_data = ((lv_ufs_file_t*)file.file_d)->ent->data_d;
|
||||
f_data += sizeof(lv_img_raw_header_t);
|
||||
map_fp(coords, &mask_com, (void*)f_data , style->image.opa, header.transp, upscale, style->image.color, style->image.intense);
|
||||
}
|
||||
@ -414,7 +414,7 @@ void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask,
|
||||
start_offset += (area_get_width(coords) >> us_shift) *
|
||||
((mask_com.y1 - coords->y1) >> us_shift) * sizeof(lv_color_t); /*First row*/
|
||||
start_offset += ((mask_com.x1 - coords->x1) >> us_shift) * sizeof(lv_color_t); /*First col*/
|
||||
fs_seek(&file, start_offset);
|
||||
lv_fs_seek(&file, start_offset);
|
||||
|
||||
uint32_t useful_data = (area_get_width(&mask_com) >> us_shift) * sizeof(lv_color_t);
|
||||
uint32_t next_row = (area_get_width(coords) >> us_shift) * sizeof(lv_color_t) - useful_data;
|
||||
@ -427,24 +427,24 @@ void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask,
|
||||
uint32_t act_pos;
|
||||
lv_color_t buf[LV_HOR_RES];
|
||||
for(row = mask_com.y1; row <= mask_com.y2; row += us_val) {
|
||||
res = fs_read(&file, buf, useful_data, &br);
|
||||
res = lv_fs_read(&file, buf, useful_data, &br);
|
||||
|
||||
map_fp(&line, &mask_com, buf, style->image.opa, header.transp, upscale,
|
||||
style->image.color, style->image.intense);
|
||||
|
||||
fs_tell(&file, &act_pos);
|
||||
fs_seek(&file, act_pos + next_row);
|
||||
lv_fs_tell(&file, &act_pos);
|
||||
lv_fs_seek(&file, act_pos + next_row);
|
||||
line.y1 += us_val; /*Go down a line*/
|
||||
line.y2 += us_val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fs_close(&file);
|
||||
lv_fs_close(&file);
|
||||
|
||||
if(res != FS_RES_OK) {
|
||||
lv_draw_rect(coords, mask, &lv_style_plain);
|
||||
lv_draw_label(coords, mask, &lv_style_plain, "No data", TXT_FLAG_NONE, NULL);
|
||||
lv_draw_label(coords, mask, &lv_style_plain, "No data", LV_TXT_FLAG_NONE, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -464,9 +464,9 @@ void lv_draw_line(const lv_point_t * p1, const lv_point_t * p2, const lv_area_t
|
||||
|
||||
if(p1->x == p2->x && p1->y == p2->y) return;
|
||||
|
||||
lv_coord_t dx = MATH_ABS(p2->x - p1->x);
|
||||
lv_coord_t dx = LV_MATH_ABS(p2->x - p1->x);
|
||||
lv_coord_t sx = p1->x < p2->x ? 1 : -1;
|
||||
lv_coord_t dy = MATH_ABS(p2->y - p1->y);
|
||||
lv_coord_t dy = LV_MATH_ABS(p2->y - p1->y);
|
||||
lv_coord_t sy = p1->y < p2->y ? 1 : -1;
|
||||
lv_coord_t err = (dx > dy ? dx : -dy) / 2;
|
||||
lv_coord_t e2;
|
||||
@ -511,10 +511,10 @@ void lv_draw_line(const lv_point_t * p1, const lv_point_t * p2, const lv_area_t
|
||||
last_y = act_point.y;
|
||||
last_x = act_point.x;
|
||||
|
||||
draw_area.x1 = MATH_MIN(act_area.x1, act_area.x2);
|
||||
draw_area.x2 = MATH_MAX(act_area.x1, act_area.x2);
|
||||
draw_area.y1 = MATH_MIN(act_area.y1, act_area.y2);
|
||||
draw_area.y2 = MATH_MAX(act_area.y1, act_area.y2);
|
||||
draw_area.x1 = LV_MATH_MIN(act_area.x1, act_area.x2);
|
||||
draw_area.x2 = LV_MATH_MAX(act_area.x1, act_area.x2);
|
||||
draw_area.y1 = LV_MATH_MIN(act_area.y1, act_area.y2);
|
||||
draw_area.y2 = LV_MATH_MAX(act_area.y1, act_area.y2);
|
||||
fill_fp(&draw_area, mask, style->line.color, style->line.opa);
|
||||
}
|
||||
if (hor == false && last_x != act_point.x) {
|
||||
@ -527,10 +527,10 @@ void lv_draw_line(const lv_point_t * p1, const lv_point_t * p2, const lv_area_t
|
||||
last_y = act_point.y;
|
||||
last_x = act_point.x;
|
||||
|
||||
draw_area.x1 = MATH_MIN(act_area.x1, act_area.x2);
|
||||
draw_area.x2 = MATH_MAX(act_area.x1, act_area.x2);
|
||||
draw_area.y1 = MATH_MIN(act_area.y1, act_area.y2);
|
||||
draw_area.y2 = MATH_MAX(act_area.y1, act_area.y2);
|
||||
draw_area.x1 = LV_MATH_MIN(act_area.x1, act_area.x2);
|
||||
draw_area.x2 = LV_MATH_MAX(act_area.x1, act_area.x2);
|
||||
draw_area.y1 = LV_MATH_MIN(act_area.y1, act_area.y2);
|
||||
draw_area.y2 = LV_MATH_MAX(act_area.y1, act_area.y2);
|
||||
fill_fp(&draw_area, mask, style->line.color, style->line.opa);
|
||||
}
|
||||
|
||||
@ -555,10 +555,10 @@ void lv_draw_line(const lv_point_t * p1, const lv_point_t * p2, const lv_area_t
|
||||
act_area.y1 = last_y - width_half ;
|
||||
act_area.y2 = act_point.y + width_half + width_1;
|
||||
|
||||
draw_area.x1 = MATH_MIN(act_area.x1, act_area.x2);
|
||||
draw_area.x2 = MATH_MAX(act_area.x1, act_area.x2);
|
||||
draw_area.y1 = MATH_MIN(act_area.y1, act_area.y2);
|
||||
draw_area.y2 = MATH_MAX(act_area.y1, act_area.y2);
|
||||
draw_area.x1 = LV_MATH_MIN(act_area.x1, act_area.x2);
|
||||
draw_area.x2 = LV_MATH_MAX(act_area.x1, act_area.x2);
|
||||
draw_area.y1 = LV_MATH_MIN(act_area.y1, act_area.y2);
|
||||
draw_area.y2 = LV_MATH_MAX(act_area.y1, act_area.y2);
|
||||
fill_fp(&draw_area, mask, style->line.color, style->line.opa);
|
||||
}
|
||||
if (hor == false) {
|
||||
@ -569,10 +569,10 @@ void lv_draw_line(const lv_point_t * p1, const lv_point_t * p2, const lv_area_t
|
||||
act_area.y1 = last_y;
|
||||
act_area.y2 = act_point.y;
|
||||
|
||||
draw_area.x1 = MATH_MIN(act_area.x1, act_area.x2);
|
||||
draw_area.x2 = MATH_MAX(act_area.x1, act_area.x2);
|
||||
draw_area.y1 = MATH_MIN(act_area.y1, act_area.y2);
|
||||
draw_area.y2 = MATH_MAX(act_area.y1, act_area.y2);
|
||||
draw_area.x1 = LV_MATH_MIN(act_area.x1, act_area.x2);
|
||||
draw_area.x2 = LV_MATH_MAX(act_area.x1, act_area.x2);
|
||||
draw_area.y1 = LV_MATH_MIN(act_area.y1, act_area.y2);
|
||||
draw_area.y2 = LV_MATH_MAX(act_area.y1, act_area.y2);
|
||||
fill_fp(&draw_area, mask, style->line.color, style->line.opa);
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ extern "C" {
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "misc_conf.h"
|
||||
#include "../lv_misc/lv_text.h"
|
||||
#include <lvgl/lv_misc/lv_txt.h>
|
||||
#include "../lv_obj/lv_style.h"
|
||||
|
||||
/*********************
|
||||
@ -71,7 +71,7 @@ void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask_p, lv_co
|
||||
* @param offset text offset in x and y direction (NULL if unused)
|
||||
*/
|
||||
void lv_draw_label(const lv_area_t * cords_p,const lv_area_t * mask_p, const lv_style_t * style_p,
|
||||
const char * txt, txt_flag_t flag, lv_point_t * offset);
|
||||
const char * txt, lv_txt_flag_t flag, lv_point_t * offset);
|
||||
|
||||
/**
|
||||
* Draw an image
|
||||
|
@ -39,7 +39,7 @@ static bool anim_ready_handler(lv_anim_t * a);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static ll_dsc_t anim_ll;
|
||||
static lv_ll_t anim_ll;
|
||||
static uint32_t last_task_run;
|
||||
static bool anim_del_global_flag = false;
|
||||
|
||||
@ -68,9 +68,9 @@ static lv_anim_path_t anim_path_step[] =
|
||||
*/
|
||||
void lv_anim_init(void)
|
||||
{
|
||||
ll_init(&anim_ll, sizeof(lv_anim_t));
|
||||
lv_ll_init(&anim_ll, sizeof(lv_anim_t));
|
||||
last_task_run = MISC_SYSTICK_GET();
|
||||
ptask_create(anim_task, ANIM_REFR_PERIOD, PTASK_PRIO_MID, NULL);
|
||||
lv_task_create(anim_task, ANIM_REFR_PERIOD, LV_TASK_PRIO_MID, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -83,7 +83,7 @@ void lv_anim_create(lv_anim_t * anim_p)
|
||||
if(anim_p->fp != NULL) lv_anim_del(anim_p->var, anim_p->fp); /*fp == NULL would delete all animations of var*/
|
||||
|
||||
/*Add the new animation to the animation linked list*/
|
||||
lv_anim_t * new_anim = ll_ins_head(&anim_ll);
|
||||
lv_anim_t * new_anim = lv_ll_ins_head(&anim_ll);
|
||||
dm_assert(new_anim);
|
||||
|
||||
/*Initialize the animation descriptor*/
|
||||
@ -106,13 +106,13 @@ bool lv_anim_del(void * var, lv_anim_fp_t fp)
|
||||
bool del = false;
|
||||
lv_anim_t * a;
|
||||
lv_anim_t * a_next;
|
||||
a = ll_get_head(&anim_ll);
|
||||
a = lv_ll_get_head(&anim_ll);
|
||||
while(a != NULL) {
|
||||
/*'a' might be deleted, so get the next object while 'a' is valid*/
|
||||
a_next = ll_get_next(&anim_ll, a);
|
||||
a_next = lv_ll_get_next(&anim_ll, a);
|
||||
|
||||
if(a->var == var && (a->fp == fp || fp == NULL)) {
|
||||
ll_rem(&anim_ll, a);
|
||||
lv_ll_rem(&anim_ll, a);
|
||||
lv_mem_free(a);
|
||||
del = true;
|
||||
anim_del_global_flag = true;
|
||||
@ -133,7 +133,7 @@ bool lv_anim_del(void * var, lv_anim_fp_t fp)
|
||||
*/
|
||||
uint16_t lv_anim_speed_to_time(uint16_t speed, int32_t start, int32_t end)
|
||||
{
|
||||
int32_t d = MATH_ABS((int32_t) start - end);
|
||||
int32_t d = LV_MATH_ABS((int32_t) start - end);
|
||||
uint16_t time = (int32_t)((int32_t)(d * 1000) / speed);
|
||||
|
||||
if(time == 0) {
|
||||
@ -177,10 +177,10 @@ static void anim_task (void * param)
|
||||
|
||||
lv_anim_t * a;
|
||||
lv_anim_t * a_next;
|
||||
a = ll_get_head(&anim_ll);
|
||||
a = lv_ll_get_head(&anim_ll);
|
||||
while(a != NULL) {
|
||||
/*'a' might be deleted, so get the next object while 'a' is valid*/
|
||||
a_next = ll_get_next(&anim_ll, a);
|
||||
a_next = lv_ll_get_next(&anim_ll, a);
|
||||
|
||||
a->act_time += elaps;
|
||||
if(a->act_time >= 0) {
|
||||
@ -207,7 +207,7 @@ static void anim_task (void * param)
|
||||
bool invalid;
|
||||
invalid = anim_ready_handler(a);
|
||||
if(invalid != false) {
|
||||
a_next = ll_get_head(&anim_ll); /*a_next might be invalid if animation delete occurred*/
|
||||
a_next = lv_ll_get_head(&anim_ll); /*a_next might be invalid if animation delete occurred*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -235,7 +235,7 @@ static bool anim_ready_handler(lv_anim_t * a)
|
||||
(a->repeat == 0 && a->playback == 1 && a->playback_now == 1)) {
|
||||
void (*cb) (void *) = a->end_cb;
|
||||
void * p = a->var;
|
||||
ll_rem(&anim_ll, a);
|
||||
lv_ll_rem(&anim_ll, a);
|
||||
lv_mem_free(a);
|
||||
|
||||
/*Call the callback function at the end*/
|
||||
@ -269,7 +269,7 @@ static bool anim_ready_handler(lv_anim_t * a)
|
||||
/*For compatibility add dummy functions*/
|
||||
#else
|
||||
|
||||
#if USE_PTASK != 0
|
||||
#if USE_LV_TASK != 0
|
||||
static void anim_dummy_handler(void * anim_dm);
|
||||
#endif
|
||||
|
||||
@ -285,14 +285,14 @@ void lv_anim_create(lv_anim_t * anim_p)
|
||||
if(anim_p->fp != NULL) anim_p->fp(anim_p->var, anim_p->end);
|
||||
if(anim_p->end_cb != NULL) anim_p->end_cb(anim_p->var);
|
||||
}
|
||||
/*With delay set the start value and set a one shot ptask to set end value and call the callback*/
|
||||
/*With delay set the start value and set a one shot lv_task to set end value and call the callback*/
|
||||
else {
|
||||
#if USE_DYN_MEM != 0 && USE_PTASK != 0
|
||||
#if USE_DYN_MEM != 0 && USE_LV_TASK != 0
|
||||
if(anim_p->fp != NULL) anim_p->fp(anim_p->var, anim_p->start);
|
||||
void * anim_dm = dm_alloc(sizeof(lv_anim_t));
|
||||
memcpy(anim_dm, anim_p, sizeof(lv_anim_t));
|
||||
ptask_t * ptask = ptask_create(anim_dummy_handler, -anim_p->act_time, PTASK_PRIO_LOW, anim_dm);
|
||||
ptask_once(ptask);
|
||||
lv_task_t * lv_task = lv_task_create(anim_dummy_handler, -anim_p->act_time, LV_TASK_PRIO_LOW, anim_dm);
|
||||
lv_task_once(lv_task);
|
||||
#else
|
||||
if(anim_p->fp != NULL) anim_p->fp(anim_p->var, anim_p->end);
|
||||
if(anim_p->end_cb != NULL) anim_p->end_cb(anim_p->var);
|
||||
@ -334,10 +334,10 @@ lv_anim_path_t * lv_anim_get_path(lv_anim_path_name_t name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if USE_PTASK != 0
|
||||
#if USE_LV_TASK != 0
|
||||
|
||||
/**
|
||||
* A One Shot ptask to handle end callbacks with delay
|
||||
* A One Shot lv_task to handle end callbacks with delay
|
||||
* @param anim_dm pointer to temporal dynamically allocated animation
|
||||
*/
|
||||
static void anim_dummy_handler(void * anim_dm)
|
||||
|
@ -112,10 +112,10 @@ uint32_t lv_area_get_size(const lv_area_t * area_p)
|
||||
bool lv_area_union(lv_area_t * res_p, const lv_area_t * a1_p, const lv_area_t * a2_p)
|
||||
{
|
||||
/* Get the smaller area from 'a1_p' and 'a2_p' */
|
||||
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);
|
||||
res_p->x1 = LV_MATH_MAX(a1_p->x1, a2_p->x1);
|
||||
res_p->y1 = LV_MATH_MAX(a1_p->y1, a2_p->y1);
|
||||
res_p->x2 = LV_MATH_MIN(a1_p->x2, a2_p->x2);
|
||||
res_p->y2 = LV_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;
|
||||
@ -135,10 +135,10 @@ bool lv_area_union(lv_area_t * res_p, const lv_area_t * a1_p, const lv_area_t *
|
||||
*/
|
||||
void lv_area_join(lv_area_t * a_res_p, const lv_area_t * a1_p, const lv_area_t * a2_p)
|
||||
{
|
||||
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);
|
||||
a_res_p->x1 = LV_MATH_MIN(a1_p->x1, a2_p->x1);
|
||||
a_res_p->y1 = LV_MATH_MIN(a1_p->y1, a2_p->y1);
|
||||
a_res_p->x2 = LV_MATH_MAX(a1_p->x2, a2_p->x2);
|
||||
a_res_p->y2 = LV_MATH_MAX(a1_p->y2, a2_p->y2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
138
lv_misc/lv_fs.c
138
lv_misc/lv_fs.c
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @file fs_int.c
|
||||
* @file lv_fs_int.c
|
||||
*
|
||||
*/
|
||||
|
||||
@ -25,14 +25,14 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static const char * fs_get_real_path(const char * path);
|
||||
static fs_drv_t* fs_get_drv(char letter);
|
||||
static const char * lv_fs_get_real_path(const char * path);
|
||||
static lv_fs_drv_t* lv_fs_get_drv(char letter);
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static ll_dsc_t drv_ll;
|
||||
static lv_ll_t drv_ll;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -45,21 +45,21 @@ static ll_dsc_t drv_ll;
|
||||
/**
|
||||
* Initialize the File system interface
|
||||
*/
|
||||
void fs_init(void)
|
||||
void lv_fs_init(void)
|
||||
{
|
||||
ll_init(&drv_ll, sizeof(fs_drv_t));
|
||||
lv_ll_init(&drv_ll, sizeof(lv_fs_drv_t));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Open a file
|
||||
* @param file_p pointer to a fs_file_t variable
|
||||
* @param file_p pointer to a lv_fs_file_t variable
|
||||
* @param path path to the file beginning with the driver letter (e.g. S:/folder/file.txt)
|
||||
* @param mode read: FS_MODE_RD, write: FS_MODE_WR, both: FS_MODE_RD | FS_MODE_WR
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
* @return FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_open (fs_file_t * file_p, const char * path, fs_mode_t mode)
|
||||
lv_fs_res_t lv_fs_open (lv_fs_file_t * file_p, const char * path, lv_fs_mode_t mode)
|
||||
{
|
||||
file_p->drv = NULL;
|
||||
file_p->file_d = NULL;
|
||||
@ -68,7 +68,7 @@ fs_res_t fs_open (fs_file_t * file_p, const char * path, fs_mode_t mode)
|
||||
|
||||
char letter = path[0];
|
||||
|
||||
file_p->drv = fs_get_drv(letter);
|
||||
file_p->drv = lv_fs_get_drv(letter);
|
||||
|
||||
if(file_p->drv == NULL) {
|
||||
file_p->file_d = NULL;
|
||||
@ -93,18 +93,18 @@ fs_res_t fs_open (fs_file_t * file_p, const char * path, fs_mode_t mode)
|
||||
return FS_RES_NOT_IMP;
|
||||
}
|
||||
|
||||
const char * real_path = fs_get_real_path(path);
|
||||
fs_res_t res = file_p->drv->open(file_p->file_d, real_path, mode);
|
||||
const char * real_path = lv_fs_get_real_path(path);
|
||||
lv_fs_res_t res = file_p->drv->open(file_p->file_d, real_path, mode);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close an already opened file
|
||||
* @param file_p pointer to a fs_file_t variable
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
* @param file_p pointer to a lv_fs_file_t variable
|
||||
* @return FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_close (fs_file_t * file_p)
|
||||
lv_fs_res_t lv_fs_close (lv_fs_file_t * file_p)
|
||||
{
|
||||
if(file_p->drv == NULL) {
|
||||
return FS_RES_INV_PARAM;
|
||||
@ -114,7 +114,7 @@ fs_res_t fs_close (fs_file_t * file_p)
|
||||
return FS_RES_NOT_IMP;
|
||||
}
|
||||
|
||||
fs_res_t res = file_p->drv->close(file_p->file_d);
|
||||
lv_fs_res_t res = file_p->drv->close(file_p->file_d);
|
||||
|
||||
lv_mem_free(file_p->file_d); /*Clean up*/
|
||||
file_p->file_d = NULL;
|
||||
@ -127,16 +127,16 @@ fs_res_t fs_close (fs_file_t * file_p)
|
||||
/**
|
||||
* Delete a file
|
||||
* @param path path of the file to delete
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
* @return FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_remove (const char * path)
|
||||
lv_fs_res_t lv_fs_remove (const char * path)
|
||||
{
|
||||
if(path == NULL) return FS_RES_INV_PARAM;
|
||||
fs_drv_t * drv = NULL;
|
||||
lv_fs_drv_t * drv = NULL;
|
||||
|
||||
char letter = path[0];
|
||||
|
||||
drv = fs_get_drv(letter);
|
||||
drv = lv_fs_get_drv(letter);
|
||||
if(drv == NULL) return FS_RES_NOT_EX;
|
||||
if(drv->ready != NULL) {
|
||||
if(drv->ready() == false) return FS_RES_HW_ERR;
|
||||
@ -144,28 +144,28 @@ fs_res_t fs_remove (const char * path)
|
||||
|
||||
if(drv->remove == NULL) return FS_RES_NOT_IMP;
|
||||
|
||||
const char * real_path = fs_get_real_path(path);
|
||||
fs_res_t res = drv->remove(real_path);
|
||||
const char * real_path = lv_fs_get_real_path(path);
|
||||
lv_fs_res_t res = drv->remove(real_path);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read from a file
|
||||
* @param file_p pointer to a fs_file_t variable
|
||||
* @param file_p pointer to a lv_fs_file_t variable
|
||||
* @param buf pointer to a buffer where the read bytes are stored
|
||||
* @param btr Bytes To Read
|
||||
* @param br the number of real read bytes (Bytes Read). NULL if unused.
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
* @return FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_read (fs_file_t * file_p, void * buf, uint32_t btr, uint32_t * br)
|
||||
lv_fs_res_t lv_fs_read (lv_fs_file_t * file_p, void * buf, uint32_t btr, uint32_t * br)
|
||||
{
|
||||
if(br != NULL) *br = 0;
|
||||
if(file_p->drv == NULL || file_p->drv == NULL) return FS_RES_INV_PARAM;
|
||||
if(file_p->drv->read == NULL) return FS_RES_NOT_IMP;
|
||||
|
||||
uint32_t br_tmp = 0;
|
||||
fs_res_t res = file_p->drv->read(file_p->file_d, buf, btr, &br_tmp);
|
||||
lv_fs_res_t res = file_p->drv->read(file_p->file_d, buf, btr, &br_tmp);
|
||||
if(br != NULL) *br = br_tmp;
|
||||
|
||||
return res;
|
||||
@ -173,13 +173,13 @@ fs_res_t fs_read (fs_file_t * file_p, void * buf, uint32_t btr, uint32_t * br)
|
||||
|
||||
/**
|
||||
* Write into a file
|
||||
* @param file_p pointer to a fs_file_t variable
|
||||
* @param file_p pointer to a lv_fs_file_t variable
|
||||
* @param buf pointer to a buffer with the bytes to write
|
||||
* @param btr Bytes To Write
|
||||
* @param br the number of real written bytes (Bytes Written). NULL if unused.
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
* @return FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_write (fs_file_t * file_p, const void * buf, uint32_t btw, uint32_t * bw)
|
||||
lv_fs_res_t lv_fs_write (lv_fs_file_t * file_p, const void * buf, uint32_t btw, uint32_t * bw)
|
||||
{
|
||||
if(bw != NULL) *bw = 0;
|
||||
|
||||
@ -192,7 +192,7 @@ fs_res_t fs_write (fs_file_t * file_p, const void * buf, uint32_t btw, uint32_t
|
||||
}
|
||||
|
||||
uint32_t bw_tmp = 0;
|
||||
fs_res_t res = file_p->drv->write(file_p->file_d, buf, btw, &bw_tmp);
|
||||
lv_fs_res_t res = file_p->drv->write(file_p->file_d, buf, btw, &bw_tmp);
|
||||
if(bw != NULL) *bw = bw_tmp;
|
||||
|
||||
return res;
|
||||
@ -200,11 +200,11 @@ fs_res_t fs_write (fs_file_t * file_p, const void * buf, uint32_t btw, uint32_t
|
||||
|
||||
/**
|
||||
* Set the position of the 'cursor' (read write pointer) in a file
|
||||
* @param file_p pointer to a fs_file_t variable
|
||||
* @param file_p pointer to a lv_fs_file_t variable
|
||||
* @param pos the new position expressed in bytes index (0: start of file)
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
* @return FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_seek (fs_file_t * file_p, uint32_t pos)
|
||||
lv_fs_res_t lv_fs_seek (lv_fs_file_t * file_p, uint32_t pos)
|
||||
{
|
||||
if(file_p->drv == NULL || file_p->drv == NULL) {
|
||||
return FS_RES_INV_PARAM;
|
||||
@ -214,18 +214,18 @@ fs_res_t fs_seek (fs_file_t * file_p, uint32_t pos)
|
||||
return FS_RES_NOT_IMP;
|
||||
}
|
||||
|
||||
fs_res_t res = file_p->drv->seek(file_p->file_d, pos);
|
||||
lv_fs_res_t res = file_p->drv->seek(file_p->file_d, pos);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the position of the read write pointer
|
||||
* @param file_p pointer to a fs_file_t variable
|
||||
* @param file_p pointer to a lv_fs_file_t variable
|
||||
* @param pos_p pointer to store the position of the read write pointer
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t fs_tell (fs_file_t * file_p, uint32_t * pos)
|
||||
lv_fs_res_t lv_fs_tell (lv_fs_file_t * file_p, uint32_t * pos)
|
||||
{
|
||||
if(file_p->drv == NULL || file_p->drv == NULL) {
|
||||
pos = 0;
|
||||
@ -237,18 +237,18 @@ fs_res_t fs_tell (fs_file_t * file_p, uint32_t * pos)
|
||||
return FS_RES_NOT_IMP;
|
||||
}
|
||||
|
||||
fs_res_t res = file_p->drv->tell(file_p->file_d, pos);
|
||||
lv_fs_res_t res = file_p->drv->tell(file_p->file_d, pos);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the size of a file bytes
|
||||
* @param file_p pointer to a fs_file_t variable
|
||||
* @param file_p pointer to a lv_fs_file_t variable
|
||||
* @param size pointer to a variable to store the size
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
* @return FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_size (fs_file_t * file_p, uint32_t * size)
|
||||
lv_fs_res_t lv_fs_size (lv_fs_file_t * file_p, uint32_t * size)
|
||||
{
|
||||
if(file_p->drv == NULL || file_p->drv == NULL) {
|
||||
return FS_RES_INV_PARAM;
|
||||
@ -259,7 +259,7 @@ fs_res_t fs_size (fs_file_t * file_p, uint32_t * size)
|
||||
|
||||
if(size == NULL) return FS_RES_INV_PARAM;
|
||||
|
||||
fs_res_t res = file_p->drv->size(file_p->file_d, size);
|
||||
lv_fs_res_t res = file_p->drv->size(file_p->file_d, size);
|
||||
|
||||
return res;
|
||||
}
|
||||
@ -268,15 +268,15 @@ fs_res_t fs_size (fs_file_t * file_p, uint32_t * size)
|
||||
* Initialize a 'fs_read_dir_t' variable for directory reading
|
||||
* @param rddir_p pointer to a 'fs_read_dir_t' variable
|
||||
* @param path path to a directory
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
* @return FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_readdir_init(fs_readdir_t * rddir_p, const char * path)
|
||||
lv_fs_res_t lv_fs_readdir_init(lv_fs_readdir_t * rddir_p, const char * path)
|
||||
{
|
||||
if(path == NULL) return FS_RES_INV_PARAM;
|
||||
|
||||
char letter = path[0];
|
||||
|
||||
rddir_p->drv = fs_get_drv(letter);
|
||||
rddir_p->drv = lv_fs_get_drv(letter);
|
||||
|
||||
if(rddir_p->drv == NULL) {
|
||||
rddir_p->rddir_d = NULL;
|
||||
@ -293,8 +293,8 @@ fs_res_t fs_readdir_init(fs_readdir_t * rddir_p, const char * path)
|
||||
return FS_RES_NOT_IMP;
|
||||
}
|
||||
|
||||
const char * real_path = fs_get_real_path(path);
|
||||
fs_res_t res = rddir_p->drv->rddir_init(rddir_p->rddir_d, real_path);
|
||||
const char * real_path = lv_fs_get_real_path(path);
|
||||
lv_fs_res_t res = rddir_p->drv->rddir_init(rddir_p->rddir_d, real_path);
|
||||
|
||||
return res;
|
||||
}
|
||||
@ -304,9 +304,9 @@ fs_res_t fs_readdir_init(fs_readdir_t * rddir_p, const char * path)
|
||||
* The name of the directories will begin with '/'
|
||||
* @param rddir_p pointer to an initialized 'fs_read_dir_t' variable
|
||||
* @param fn pointer to a buffer to store the filename
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
* @return FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_readdir (fs_readdir_t * rddir_p, char * fn)
|
||||
lv_fs_res_t lv_fs_readdir (lv_fs_readdir_t * rddir_p, char * fn)
|
||||
{
|
||||
if(rddir_p->drv == NULL || rddir_p->rddir_d == NULL) {
|
||||
return FS_RES_INV_PARAM;
|
||||
@ -316,7 +316,7 @@ fs_res_t fs_readdir (fs_readdir_t * rddir_p, char * fn)
|
||||
return FS_RES_NOT_IMP;
|
||||
}
|
||||
|
||||
fs_res_t res = rddir_p->drv->rddir(rddir_p->rddir_d, fn);
|
||||
lv_fs_res_t res = rddir_p->drv->rddir(rddir_p->rddir_d, fn);
|
||||
|
||||
return res;
|
||||
}
|
||||
@ -324,15 +324,15 @@ fs_res_t fs_readdir (fs_readdir_t * rddir_p, char * fn)
|
||||
/**
|
||||
* Close the directory reading
|
||||
* @param rddir_p pointer to an initialized 'fs_read_dir_t' variable
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
* @return FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_readdir_close (fs_readdir_t * rddir_p)
|
||||
lv_fs_res_t lv_fs_readdir_close (lv_fs_readdir_t * rddir_p)
|
||||
{
|
||||
if(rddir_p->drv == NULL || rddir_p->rddir_d == NULL) {
|
||||
return FS_RES_INV_PARAM;
|
||||
}
|
||||
|
||||
fs_res_t res;
|
||||
lv_fs_res_t res;
|
||||
|
||||
if(rddir_p->drv->rddir_close == NULL) {
|
||||
res = FS_RES_NOT_IMP;
|
||||
@ -353,17 +353,17 @@ fs_res_t fs_readdir_close (fs_readdir_t * rddir_p)
|
||||
* @param letter the driver letter
|
||||
* @param total_p pointer to store the total size [kB]
|
||||
* @param free_p pointer to store the free size [kB]
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
* @return FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_free (char letter, uint32_t * total_p, uint32_t * free_p)
|
||||
lv_fs_res_t lv_fs_free (char letter, uint32_t * total_p, uint32_t * free_p)
|
||||
{
|
||||
fs_drv_t * drv = fs_get_drv(letter);
|
||||
lv_fs_drv_t * drv = lv_fs_get_drv(letter);
|
||||
|
||||
if(drv == NULL) {
|
||||
return FS_RES_INV_PARAM;
|
||||
}
|
||||
|
||||
fs_res_t res;
|
||||
lv_fs_res_t res;
|
||||
|
||||
if(drv->free == NULL) {
|
||||
res = FS_RES_NOT_IMP;
|
||||
@ -381,16 +381,16 @@ fs_res_t fs_free (char letter, uint32_t * total_p, uint32_t * free_p)
|
||||
|
||||
/**
|
||||
* Add a new drive
|
||||
* @param drv_p pointer to an fs_drv_t structure which is inited with the
|
||||
* @param drv_p pointer to an lv_fs_drv_t structure which is inited with the
|
||||
* corresponding function pointer. The data will be copied so the variable can be local.
|
||||
*/
|
||||
void fs_add_drv(fs_drv_t * drv_p)
|
||||
void lv_fs_add_drv(lv_fs_drv_t * drv_p)
|
||||
{
|
||||
/*Save the new driver*/
|
||||
fs_drv_t* new_drv;
|
||||
new_drv = ll_ins_head(&drv_ll);
|
||||
lv_fs_drv_t* new_drv;
|
||||
new_drv = lv_ll_ins_head(&drv_ll);
|
||||
dm_assert(new_drv);
|
||||
memcpy(new_drv, drv_p, sizeof(fs_drv_t));
|
||||
memcpy(new_drv, drv_p, sizeof(lv_fs_drv_t));
|
||||
|
||||
}
|
||||
|
||||
@ -399,9 +399,9 @@ void fs_add_drv(fs_drv_t * drv_p)
|
||||
* @param buf buffer to store the letters ('\0' added after the last letter)
|
||||
* @return the buffer
|
||||
*/
|
||||
char * fs_get_letters(char * buf)
|
||||
char * lv_fs_get_letters(char * buf)
|
||||
{
|
||||
fs_drv_t* drv;
|
||||
lv_fs_drv_t* drv;
|
||||
uint8_t i = 0;
|
||||
|
||||
LL_READ(drv_ll, drv) {
|
||||
@ -420,7 +420,7 @@ char * fs_get_letters(char * buf)
|
||||
* @param fn string with a filename
|
||||
* @return pointer to the beginning extension or empty string if no extension
|
||||
*/
|
||||
const char * fs_get_ext(const char * fn)
|
||||
const char * lv_fs_get_ext(const char * fn)
|
||||
{
|
||||
uint16_t i;
|
||||
for(i = strlen(fn); i > 0; i --) {
|
||||
@ -439,7 +439,7 @@ const char * fs_get_ext(const char * fn)
|
||||
* @param path pointer to a file name
|
||||
* @return the truncated file name
|
||||
*/
|
||||
char * fs_up(char * path)
|
||||
char * lv_fs_up(char * path)
|
||||
{
|
||||
uint16_t len = strlen(path);
|
||||
if(len == 0) return path;
|
||||
@ -468,7 +468,7 @@ char * fs_up(char * path)
|
||||
* @param path a character sting with the path to search in
|
||||
* @return pointer to the beginning of the last element in the path
|
||||
*/
|
||||
const char * fs_get_last(const char * path)
|
||||
const char * lv_fs_get_last(const char * path)
|
||||
{
|
||||
uint16_t len = strlen(path);
|
||||
if(len == 0) return path;
|
||||
@ -500,7 +500,7 @@ const char * fs_get_last(const char * path)
|
||||
* @param path path string (E.g. S:/folder/file.txt)
|
||||
* @return pointer to the beginning of the real path (E.g. folder/file.txt)
|
||||
*/
|
||||
static const char * fs_get_real_path(const char * path)
|
||||
static const char * lv_fs_get_real_path(const char * path)
|
||||
{
|
||||
/* Example path: "S:/folder/file.txt"
|
||||
* Leave the letter and the : / \ characters*/
|
||||
@ -524,9 +524,9 @@ static const char * fs_get_real_path(const char * path)
|
||||
* @param letter the driver letter
|
||||
* @return pointer to a driver or NULL if not found
|
||||
*/
|
||||
static fs_drv_t* fs_get_drv(char letter)
|
||||
static lv_fs_drv_t* lv_fs_get_drv(char letter)
|
||||
{
|
||||
fs_drv_t* drv;
|
||||
lv_fs_drv_t* drv;
|
||||
|
||||
LL_READ(drv_ll, drv) {
|
||||
if(drv->letter == letter) {
|
||||
|
120
lv_misc/lv_fs.h
120
lv_misc/lv_fs.h
@ -1,10 +1,10 @@
|
||||
/**
|
||||
* @file fsint.h
|
||||
* @file lv_fs.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FSINT_H
|
||||
#define FSINT_H
|
||||
#ifndef LV_FS_H
|
||||
#define LV_FS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -15,7 +15,6 @@ extern "C" {
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "misc_conf.h"
|
||||
#if USE_FSINT != 0
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
@ -44,7 +43,7 @@ typedef enum
|
||||
FS_RES_OUT_OF_MEM, /*Not enough memory for an internal opretion*/
|
||||
FS_RES_INV_PARAM, /*Invalid parameter among arguments*/
|
||||
FS_RES_UNKNOWN, /*Other unknown error*/
|
||||
}fs_res_t;
|
||||
}lv_fs_res_t;
|
||||
|
||||
struct __fs_drv_struct;
|
||||
|
||||
@ -52,20 +51,20 @@ typedef struct
|
||||
{
|
||||
void * file_d;
|
||||
struct __fs_drv_struct* drv;
|
||||
}fs_file_t;
|
||||
}lv_fs_file_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void * rddir_d;
|
||||
struct __fs_drv_struct * drv;
|
||||
}fs_readdir_t;
|
||||
}lv_fs_readdir_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FS_MODE_WR = 0x01,
|
||||
FS_MODE_RD = 0x02,
|
||||
}fs_mode_t;
|
||||
}lv_fs_mode_t;
|
||||
|
||||
typedef struct __fs_drv_struct
|
||||
{
|
||||
@ -74,21 +73,21 @@ typedef struct __fs_drv_struct
|
||||
uint16_t rddir_size;
|
||||
bool (*ready) (void);
|
||||
|
||||
fs_res_t (*open) (void * file_p, const char * path, fs_mode_t mode);
|
||||
fs_res_t (*close) (void * file_p);
|
||||
fs_res_t (*remove) (const char * fn);
|
||||
fs_res_t (*read) (void * file_p, void * buf, uint32_t btr, uint32_t * br);
|
||||
fs_res_t (*write) (void * file_p, const void * buf, uint32_t btw, uint32_t * bw);
|
||||
fs_res_t (*seek) (void * file_p, uint32_t pos);
|
||||
fs_res_t (*tell) (void * file_p, uint32_t * pos_p);
|
||||
fs_res_t (*trunc) (void * file_p);
|
||||
fs_res_t (*size) (void * file_p, uint32_t * size_p);
|
||||
fs_res_t (*free) (uint32_t * total_p, uint32_t * free_p);
|
||||
lv_fs_res_t (*open) (void * file_p, const char * path, lv_fs_mode_t mode);
|
||||
lv_fs_res_t (*close) (void * file_p);
|
||||
lv_fs_res_t (*remove) (const char * fn);
|
||||
lv_fs_res_t (*read) (void * file_p, void * buf, uint32_t btr, uint32_t * br);
|
||||
lv_fs_res_t (*write) (void * file_p, const void * buf, uint32_t btw, uint32_t * bw);
|
||||
lv_fs_res_t (*seek) (void * file_p, uint32_t pos);
|
||||
lv_fs_res_t (*tell) (void * file_p, uint32_t * pos_p);
|
||||
lv_fs_res_t (*trunc) (void * file_p);
|
||||
lv_fs_res_t (*size) (void * file_p, uint32_t * size_p);
|
||||
lv_fs_res_t (*free) (uint32_t * total_p, uint32_t * free_p);
|
||||
|
||||
fs_res_t (*rddir_init) (void * rddir_p, const char * path);
|
||||
fs_res_t (*rddir) (void * rddir_p, char * fn);
|
||||
fs_res_t (*rddir_close) (void * rddir_p);
|
||||
}fs_drv_t;
|
||||
lv_fs_res_t (*rddir_init) (void * rddir_p, const char * path);
|
||||
lv_fs_res_t (*rddir) (void * rddir_p, char * fn);
|
||||
lv_fs_res_t (*rddir_close) (void * rddir_p);
|
||||
}lv_fs_drv_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
@ -97,152 +96,149 @@ typedef struct __fs_drv_struct
|
||||
/**
|
||||
* Initialize the File system interface
|
||||
*/
|
||||
void fs_init(void);
|
||||
void lv_fs_init(void);
|
||||
|
||||
/**
|
||||
* Add a new drive
|
||||
* @param drv_p pointer to an fs_drv_t structure which is inited with the
|
||||
* @param drv_p pointer to an lv_fs_drv_t structure which is inited with the
|
||||
* corresponding function pointer
|
||||
*/
|
||||
void fs_add_drv(fs_drv_t * drv_p);
|
||||
void lv_fs_add_drv(lv_fs_drv_t * drv_p);
|
||||
|
||||
/**
|
||||
* Open a file
|
||||
* @param file_p pointer to a fs_file_t variable
|
||||
* @param file_p pointer to a lv_fs_file_t variable
|
||||
* @param path path to the file beginning with the driver letter (e.g. S:/folder/file.txt)
|
||||
* @param mode read: FS_MODE_RD, write: FS_MODE_WR, both: FS_MODE_RD | FS_MODE_WR
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
* @return FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_open (fs_file_t * file_p, const char * path, fs_mode_t mode);
|
||||
lv_fs_res_t lv_fs_open (lv_fs_file_t * file_p, const char * path, lv_fs_mode_t mode);
|
||||
|
||||
/**
|
||||
* Close an already opened file
|
||||
* @param file_p pointer to a fs_file_t variable
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
* @param file_p pointer to a lv_fs_file_t variable
|
||||
* @return FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_close (fs_file_t * file_p);
|
||||
lv_fs_res_t lv_fs_close (lv_fs_file_t * file_p);
|
||||
|
||||
/**
|
||||
* Delete a file
|
||||
* @param path path of the file to delete
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
* @return FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_remove (const char * path);
|
||||
lv_fs_res_t lv_fs_remove (const char * path);
|
||||
|
||||
/**
|
||||
* Read from a file
|
||||
* @param file_p pointer to a fs_file_t variable
|
||||
* @param file_p pointer to a lv_fs_file_t variable
|
||||
* @param buf pointer to a buffer where the read bytes are stored
|
||||
* @param btr Bytes To Read
|
||||
* @param br the number of real read bytes (Bytes Read). NULL if unused.
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
* @return FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_read (fs_file_t * file_p, void * buf, uint32_t btr, uint32_t * br);
|
||||
lv_fs_res_t lv_fs_read (lv_fs_file_t * file_p, void * buf, uint32_t btr, uint32_t * br);
|
||||
|
||||
/**
|
||||
* Write into a file
|
||||
* @param file_p pointer to a fs_file_t variable
|
||||
* @param file_p pointer to a lv_fs_file_t variable
|
||||
* @param buf pointer to a buffer with the bytes to write
|
||||
* @param btr Bytes To Write
|
||||
* @param br the number of real written bytes (Bytes Written). NULL if unused.
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
* @return FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_write (fs_file_t * file_p, const void * buf, uint32_t btw, uint32_t * bw);
|
||||
lv_fs_res_t lv_fs_write (lv_fs_file_t * file_p, const void * buf, uint32_t btw, uint32_t * bw);
|
||||
|
||||
/**
|
||||
* Set the position of the 'cursor' (read write pointer) in a file
|
||||
* @param file_p pointer to a fs_file_t variable
|
||||
* @param file_p pointer to a lv_fs_file_t variable
|
||||
* @param pos the new position expressed in bytes index (0: start of file)
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
* @return FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_seek (fs_file_t * file_p, uint32_t pos);
|
||||
lv_fs_res_t lv_fs_seek (lv_fs_file_t * file_p, uint32_t pos);
|
||||
|
||||
/**
|
||||
* Give the position of the read write pointer
|
||||
* @param file_p pointer to a fs_file_t variable
|
||||
* @param file_p pointer to a lv_fs_file_t variable
|
||||
* @param pos_p pointer to store the position of the read write pointer
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t fs_tell (fs_file_t * file_p, uint32_t * pos);
|
||||
lv_fs_res_t lv_fs_tell (lv_fs_file_t * file_p, uint32_t * pos);
|
||||
|
||||
/**
|
||||
* Give the size of a file bytes
|
||||
* @param file_p pointer to a fs_file_t variable
|
||||
* @param file_p pointer to a lv_fs_file_t variable
|
||||
* @param size pointer to a variable to store the size
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
* @return FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_size (fs_file_t * file_p, uint32_t * size);
|
||||
lv_fs_res_t lv_fs_size (lv_fs_file_t * file_p, uint32_t * size);
|
||||
|
||||
/**
|
||||
* Initialize a 'fs_read_dir_t' variable for directory reading
|
||||
* @param rddir_p pointer to a 'fs_read_dir_t' variable
|
||||
* @param path path to a directory
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
* @return FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_readdir_init(fs_readdir_t * rddir_p, const char * path);
|
||||
lv_fs_res_t lv_fs_readdir_init(lv_fs_readdir_t * rddir_p, const char * path);
|
||||
|
||||
/**
|
||||
* Read the next filename form a directory.
|
||||
* The name of the directories will begin with '/'
|
||||
* @param rddir_p pointer to an initialized 'fs_read_dir_t' variable
|
||||
* @param fn pointer to a buffer to store the filename
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
* @return FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_readdir (fs_readdir_t * rddir_p, char * fn);
|
||||
lv_fs_res_t lv_fs_readdir (lv_fs_readdir_t * rddir_p, char * fn);
|
||||
|
||||
/**
|
||||
* Close the directory reading
|
||||
* @param rddir_p pointer to an initialized 'fs_read_dir_t' variable
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
* @return FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_readdir_close (fs_readdir_t * rddir_p);
|
||||
lv_fs_res_t lv_fs_readdir_close (lv_fs_readdir_t * rddir_p);
|
||||
|
||||
/**
|
||||
* Get the free and total size of a driver in kB
|
||||
* @param letter the driver letter
|
||||
* @param total_p pointer to store the total size [kB]
|
||||
* @param free_p pointer to store the free size [kB]
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
* @return FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_free (char letter, uint32_t * total_p, uint32_t * free_p);
|
||||
lv_fs_res_t lv_fs_free (char letter, uint32_t * total_p, uint32_t * free_p);
|
||||
|
||||
/**
|
||||
* Fill a buffer with the letters of existing drivers
|
||||
* @param buf buffer to store the letters ('\0' added after the last letter)
|
||||
* @return the buffer
|
||||
*/
|
||||
char * fs_get_letters(char * buf);
|
||||
char * lv_fs_get_letters(char * buf);
|
||||
|
||||
/**
|
||||
* Return with the extension of the filename
|
||||
* @param fn string with a filename
|
||||
* @return pointer to the beginning extension or empty string if no extension
|
||||
*/
|
||||
const char * fs_get_ext(const char * fn);
|
||||
const char * lv_fs_get_ext(const char * fn);
|
||||
|
||||
/**
|
||||
* Step up one level
|
||||
* @param path pointer to a file name
|
||||
* @return the truncated file name
|
||||
*/
|
||||
char * fs_up(char * path);
|
||||
char * lv_fs_up(char * path);
|
||||
|
||||
/**
|
||||
* Get the last element of a path (e.g. U:/folder/file -> file)
|
||||
* @param buf buffer to store the letters ('\0' added after the last letter)
|
||||
* @return pointer to the beginning of the last element in the path
|
||||
*/
|
||||
const char * fs_get_last(const char * path);
|
||||
const char * lv_fs_get_last(const char * path);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,14 +1,13 @@
|
||||
/**
|
||||
* @file linked_list.c
|
||||
* @file lv_ll.c
|
||||
* Handle linked lists.
|
||||
* The nodes are dynamically allocated by the dyn_mem module,
|
||||
* The nodes are dynamically allocated by the 'lv_mem' module,
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "misc_conf.h"
|
||||
#if USE_LINKED_LIST != 0
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
@ -19,9 +18,10 @@
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LL_NODE_META_SIZE (sizeof(ll_node_t*) + sizeof(ll_node_t*))
|
||||
#define LL_NODE_META_SIZE (sizeof(lv_ll_node_t*) + sizeof(lv_ll_node_t*))
|
||||
#define LL_PREV_P_OFFSET(ll_p) (ll_p->n_size)
|
||||
#define LL_NEXT_P_OFFSET(ll_p) (ll_p->n_size + sizeof(ll_node_t*))
|
||||
#define LL_NEXT_P_OFFSET(ll_p) (ll_p->n_size + sizeof(lv_ll_node_t*))
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
@ -29,8 +29,8 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void node_set_prev(ll_dsc_t * ll_p, ll_node_t* act, ll_node_t* prev);
|
||||
static void node_set_next(ll_dsc_t * ll_p, ll_node_t* act, ll_node_t* next);
|
||||
static void node_set_prev(lv_ll_t * ll_p, lv_ll_node_t* act, lv_ll_node_t* prev);
|
||||
static void node_set_next(lv_ll_t * ll_p, lv_ll_node_t* act, lv_ll_node_t* next);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@ -49,7 +49,7 @@ static void node_set_next(ll_dsc_t * ll_p, ll_node_t* act, ll_node_t* next);
|
||||
* @param ll_dsc pointer to ll_dsc variable
|
||||
* @param n_size the size of 1 node in bytes
|
||||
*/
|
||||
void ll_init(ll_dsc_t * ll_p, uint32_t n_size)
|
||||
void lv_ll_init(lv_ll_t * ll_p, uint32_t n_size)
|
||||
{
|
||||
ll_p->head = NULL;
|
||||
ll_p->tail = NULL;
|
||||
@ -67,9 +67,9 @@ void ll_init(ll_dsc_t * ll_p, uint32_t n_size)
|
||||
* @param ll_p pointer to linked list
|
||||
* @return pointer to the new head
|
||||
*/
|
||||
void * ll_ins_head(ll_dsc_t * ll_p)
|
||||
void * lv_ll_ins_head(lv_ll_t * ll_p)
|
||||
{
|
||||
ll_node_t* n_new;
|
||||
lv_ll_node_t* n_new;
|
||||
|
||||
n_new = lv_mem_alloc(ll_p->n_size + LL_NODE_META_SIZE);
|
||||
|
||||
@ -95,9 +95,9 @@ void * ll_ins_head(ll_dsc_t * ll_p)
|
||||
* @param ll_p pointer to linked list
|
||||
* @return pointer to the new tail
|
||||
*/
|
||||
void * ll_ins_tail(ll_dsc_t * ll_p)
|
||||
void * lv_ll_ins_tail(lv_ll_t * ll_p)
|
||||
{
|
||||
ll_node_t* n_new;
|
||||
lv_ll_node_t* n_new;
|
||||
|
||||
n_new = lv_mem_alloc(ll_p->n_size + LL_NODE_META_SIZE);
|
||||
|
||||
@ -124,11 +124,11 @@ void * ll_ins_tail(ll_dsc_t * ll_p)
|
||||
* @param ll_p pointer to the linked list of 'node_p'
|
||||
* @param node_p pointer to node in 'll_p' linked list
|
||||
*/
|
||||
void ll_rem(ll_dsc_t * ll_p, void * node_p)
|
||||
void lv_ll_rem(lv_ll_t * ll_p, void * node_p)
|
||||
{
|
||||
if(ll_get_head(ll_p) == node_p) {
|
||||
if(lv_ll_get_head(ll_p) == node_p) {
|
||||
/*The new head will be the node after 'n_act'*/
|
||||
ll_p->head = ll_get_next(ll_p, node_p);
|
||||
ll_p->head = lv_ll_get_next(ll_p, node_p);
|
||||
if(ll_p->head == NULL) {
|
||||
ll_p->tail = NULL;
|
||||
}
|
||||
@ -136,9 +136,9 @@ void ll_rem(ll_dsc_t * ll_p, void * node_p)
|
||||
node_set_prev(ll_p, ll_p->head, NULL);
|
||||
}
|
||||
}
|
||||
else if(ll_get_tail(ll_p) == node_p) {
|
||||
else if(lv_ll_get_tail(ll_p) == node_p) {
|
||||
/*The new tail will be the node before 'n_act'*/
|
||||
ll_p->tail = ll_get_prev(ll_p, node_p);
|
||||
ll_p->tail = lv_ll_get_prev(ll_p, node_p);
|
||||
if(ll_p->tail == NULL) {
|
||||
ll_p->head = NULL;
|
||||
}
|
||||
@ -148,8 +148,8 @@ void ll_rem(ll_dsc_t * ll_p, void * node_p)
|
||||
}
|
||||
else
|
||||
{
|
||||
ll_node_t* n_prev = ll_get_prev(ll_p, node_p);
|
||||
ll_node_t* n_next = ll_get_next(ll_p, node_p);
|
||||
lv_ll_node_t* n_prev = lv_ll_get_prev(ll_p, node_p);
|
||||
lv_ll_node_t* n_next = lv_ll_get_next(ll_p, node_p);
|
||||
|
||||
node_set_next(ll_p, n_prev, n_next);
|
||||
node_set_prev(ll_p, n_next, n_prev);
|
||||
@ -157,21 +157,21 @@ void ll_rem(ll_dsc_t * ll_p, void * node_p)
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove and free all elements from a linked list.
|
||||
* Remove and free all elements from a linked list. The list remain valid but become empty.
|
||||
* @param ll_p pointer to linked list
|
||||
*/
|
||||
void ll_clear(ll_dsc_t * ll_p)
|
||||
void lv_ll_clear(lv_ll_t * ll_p)
|
||||
{
|
||||
void * i;
|
||||
void * i_next;
|
||||
|
||||
i = ll_get_head(ll_p);
|
||||
i = lv_ll_get_head(ll_p);
|
||||
i_next = NULL;
|
||||
|
||||
while(i != NULL) {
|
||||
i_next = ll_get_next(ll_p, i);
|
||||
i_next = lv_ll_get_next(ll_p, i);
|
||||
|
||||
ll_rem(ll_p, i);
|
||||
lv_ll_rem(ll_p, i);
|
||||
lv_mem_free(i);
|
||||
|
||||
i = i_next;
|
||||
@ -184,9 +184,9 @@ void ll_clear(ll_dsc_t * ll_p)
|
||||
* @param ll_new_p pointer to the new linked list
|
||||
* @param node pointer to a node
|
||||
*/
|
||||
void ll_chg_list(ll_dsc_t * ll_ori_p, ll_dsc_t * ll_new_p, void * node)
|
||||
void lv_ll_chg_list(lv_ll_t * ll_ori_p, lv_ll_t * ll_new_p, void * node)
|
||||
{
|
||||
ll_rem(ll_ori_p, node);
|
||||
lv_ll_rem(ll_ori_p, node);
|
||||
|
||||
/*Set node as head*/
|
||||
node_set_prev(ll_new_p, node, NULL);
|
||||
@ -207,7 +207,7 @@ void ll_chg_list(ll_dsc_t * ll_ori_p, ll_dsc_t * ll_new_p, void * node)
|
||||
* @param ll_p pointer to linked list
|
||||
* @return pointer to the head of 'll_p'
|
||||
*/
|
||||
void * ll_get_head(ll_dsc_t * ll_p)
|
||||
void * lv_ll_get_head(lv_ll_t * ll_p)
|
||||
{
|
||||
void * head = NULL;
|
||||
|
||||
@ -223,7 +223,7 @@ void * ll_get_head(ll_dsc_t * ll_p)
|
||||
* @param ll_p pointer to linked list
|
||||
* @return pointer to the head of 'll_p'
|
||||
*/
|
||||
void * ll_get_tail(ll_dsc_t * ll_p)
|
||||
void * lv_ll_get_tail(lv_ll_t * ll_p)
|
||||
{
|
||||
void * tail = NULL;
|
||||
|
||||
@ -240,12 +240,12 @@ void * ll_get_tail(ll_dsc_t * ll_p)
|
||||
* @param n_act pointer a node
|
||||
* @return pointer to the next node
|
||||
*/
|
||||
void * ll_get_next(ll_dsc_t * ll_p, void * n_act)
|
||||
void * lv_ll_get_next(lv_ll_t * ll_p, void * n_act)
|
||||
{
|
||||
void * next = NULL;
|
||||
|
||||
if(ll_p != NULL) {
|
||||
ll_node_t* n_act_d = n_act;
|
||||
lv_ll_node_t* n_act_d = n_act;
|
||||
memcpy(&next, n_act_d + LL_NEXT_P_OFFSET(ll_p), sizeof(void *));
|
||||
}
|
||||
|
||||
@ -258,21 +258,21 @@ void * ll_get_next(ll_dsc_t * ll_p, void * n_act)
|
||||
* @param n_act pointer a node
|
||||
* @return pointer to the previous node
|
||||
*/
|
||||
void * ll_get_prev(ll_dsc_t * ll_p, void * n_act)
|
||||
void * lv_ll_get_prev(lv_ll_t * ll_p, void * n_act)
|
||||
{
|
||||
void * prev = NULL;
|
||||
|
||||
if(ll_p != NULL) {
|
||||
ll_node_t* n_act_d = n_act;
|
||||
lv_ll_node_t* n_act_d = n_act;
|
||||
memcpy(&prev, n_act_d + LL_PREV_P_OFFSET(ll_p), sizeof(void *));
|
||||
}
|
||||
|
||||
return prev;
|
||||
}
|
||||
|
||||
void ll_swap(ll_dsc_t * ll_p, void * n1_p, void * n2_p)
|
||||
void lv_ll_swap(lv_ll_t * ll_p, void * n1_p, void * n2_p)
|
||||
{
|
||||
|
||||
/*TODO*/
|
||||
}
|
||||
|
||||
/**********************
|
||||
@ -285,9 +285,9 @@ void ll_swap(ll_dsc_t * ll_p, void * n1_p, void * n2_p)
|
||||
* @param act pointer to a node which prev. node pointer should be set
|
||||
* @param prev pointer to a node which should be the previous node before 'act'
|
||||
*/
|
||||
static void node_set_prev(ll_dsc_t * ll_p, ll_node_t* act, ll_node_t* prev)
|
||||
static void node_set_prev(lv_ll_t * ll_p, lv_ll_node_t* act, lv_ll_node_t* prev)
|
||||
{
|
||||
memcpy(act + LL_PREV_P_OFFSET(ll_p), &prev, sizeof(ll_node_t*));
|
||||
memcpy(act + LL_PREV_P_OFFSET(ll_p), &prev, sizeof(lv_ll_node_t*));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -296,9 +296,8 @@ static void node_set_prev(ll_dsc_t * ll_p, ll_node_t* act, ll_node_t* prev)
|
||||
* @param act pointer to a node which next node pointer should be set
|
||||
* @param next pointer to a node which should be the next node before 'act'
|
||||
*/
|
||||
static void node_set_next(ll_dsc_t * ll_p, ll_node_t* act, ll_node_t* next)
|
||||
static void node_set_next(lv_ll_t * ll_p, lv_ll_node_t* act, lv_ll_node_t* next)
|
||||
{
|
||||
memcpy(act + LL_NEXT_P_OFFSET(ll_p), &next, sizeof(ll_node_t*));
|
||||
memcpy(act + LL_NEXT_P_OFFSET(ll_p), &next, sizeof(lv_ll_node_t*));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
* @file linked_list.c
|
||||
* Handle linked lists. The nodes are dynamically allocated by the dyn_mem module.
|
||||
* @file lv_ll.c
|
||||
* Handle linked lists. The nodes are dynamically allocated by the 'lv_mem' module.
|
||||
*/
|
||||
|
||||
#ifndef LINKED_LIST_H
|
||||
#define LINKED_LIST_H
|
||||
#ifndef LV_LL_H
|
||||
#define LV_LL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -30,15 +30,15 @@ extern "C" {
|
||||
**********************/
|
||||
|
||||
/*Dummy type to make handling easier*/
|
||||
typedef uint8_t ll_node_t;
|
||||
typedef uint8_t lv_ll_node_t;
|
||||
|
||||
/*Description of a linked list*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t n_size;
|
||||
ll_node_t* head;
|
||||
ll_node_t* tail;
|
||||
}ll_dsc_t;
|
||||
lv_ll_node_t* head;
|
||||
lv_ll_node_t* tail;
|
||||
}lv_ll_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
@ -47,23 +47,23 @@ typedef struct
|
||||
/**
|
||||
* Initialize linked list
|
||||
* @param ll_dsc pointer to ll_dsc variable
|
||||
* @param n_size the size of 1 node in bytes
|
||||
* @param node_size the size of 1 node in bytes
|
||||
*/
|
||||
void ll_init(ll_dsc_t * ll_p, uint32_t n_size);
|
||||
void lv_ll_init(lv_ll_t * ll_p, uint32_t node_size);
|
||||
|
||||
/**
|
||||
* Add a new head to a linked list
|
||||
* @param ll_p pointer to linked list
|
||||
* @return pointer to the new head
|
||||
*/
|
||||
void * ll_ins_head(ll_dsc_t * ll_p);
|
||||
void * lv_ll_ins_head(lv_ll_t * ll_p);
|
||||
|
||||
/**
|
||||
* Add a new tail to a linked list
|
||||
* @param ll_p pointer to linked list
|
||||
* @return pointer to the new tail
|
||||
*/
|
||||
void * ll_ins_tail(ll_dsc_t * ll_p);
|
||||
void * lv_ll_ins_tail(lv_ll_t * ll_p);
|
||||
|
||||
/**
|
||||
* Remove the node 'node_p' from 'll_p' linked list.
|
||||
@ -71,13 +71,13 @@ void * ll_ins_tail(ll_dsc_t * ll_p);
|
||||
* @param ll_p pointer to the linked list of 'node_p'
|
||||
* @param node_p pointer to node in 'll_p' linked list
|
||||
*/
|
||||
void ll_rem(ll_dsc_t * ll_p, void * node_p);
|
||||
void lv_ll_rem(lv_ll_t * ll_p, void * node_p);
|
||||
|
||||
/**
|
||||
* Remove and free all elements from a linked list.
|
||||
* Remove and free all elements from a linked list. The list remain valid but become empty.
|
||||
* @param ll_p pointer to linked list
|
||||
*/
|
||||
void ll_clear(ll_dsc_t * ll_p);
|
||||
void lv_ll_clear(lv_ll_t * ll_p);
|
||||
|
||||
/**
|
||||
* Move a node to a new linked list
|
||||
@ -85,21 +85,21 @@ void ll_clear(ll_dsc_t * ll_p);
|
||||
* @param ll_new_p pointer to the new linked list
|
||||
* @param node pointer to a node
|
||||
*/
|
||||
void ll_chg_list(ll_dsc_t * ll_ori_p, ll_dsc_t * ll_new_p, void * node);
|
||||
void lv_ll_chg_list(lv_ll_t * ll_ori_p, lv_ll_t * ll_new_p, void * node);
|
||||
|
||||
/**
|
||||
* Return with head node of the linked list
|
||||
* @param ll_p pointer to linked list
|
||||
* @return pointer to the head of 'll_p'
|
||||
*/
|
||||
void * ll_get_head(ll_dsc_t * ll_p);
|
||||
void * lv_ll_get_head(lv_ll_t * ll_p);
|
||||
|
||||
/**
|
||||
* Return with tail node of the linked list
|
||||
* @param ll_p pointer to linked list
|
||||
* @return pointer to the head of 'll_p'
|
||||
*/
|
||||
void * ll_get_tail(ll_dsc_t * ll_p);
|
||||
void * lv_ll_get_tail(lv_ll_t * ll_p);
|
||||
|
||||
/**
|
||||
* Return with the pointer of the next node after 'n_act'
|
||||
@ -107,7 +107,7 @@ void * ll_get_tail(ll_dsc_t * ll_p);
|
||||
* @param n_act pointer a node
|
||||
* @return pointer to the next node
|
||||
*/
|
||||
void * ll_get_next(ll_dsc_t * ll_p, void * n_act);
|
||||
void * lv_ll_get_next(lv_ll_t * ll_p, void * n_act);
|
||||
|
||||
/**
|
||||
* Return with the pointer of the previous node after 'n_act'
|
||||
@ -115,15 +115,15 @@ void * ll_get_next(ll_dsc_t * ll_p, void * n_act);
|
||||
* @param n_act pointer a node
|
||||
* @return pointer to the previous node
|
||||
*/
|
||||
void * ll_get_prev(ll_dsc_t * ll_p, void * n_act);
|
||||
void * lv_ll_get_prev(lv_ll_t * ll_p, void * n_act);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#define LL_READ(list, i) for(i = ll_get_head(&list); i != NULL; i = ll_get_next(&list, i))
|
||||
#define LL_READ(list, i) for(i = lv_ll_get_head(&list); i != NULL; i = lv_ll_get_next(&list, i))
|
||||
|
||||
#define LL_READ_BACK(list, i) for(i = ll_get_tail(&list); i != NULL; i = ll_get_prev(&list, i))
|
||||
#define LL_READ_BACK(list, i) for(i = lv_ll_get_tail(&list); i != NULL; i = lv_ll_get_prev(&list, i))
|
||||
|
||||
#endif /*USE_LINKED_LIST*/
|
||||
|
||||
|
@ -3,8 +3,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MATH_BASE_H
|
||||
#define MATH_BASE_H
|
||||
#ifndef LV_MATH_H
|
||||
#define LV_MATH_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -15,15 +15,14 @@ extern "C" {
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "misc_conf.h"
|
||||
#if USE_MATH_BASE != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
#define MATH_MIN(a,b) (a<b?a:b)
|
||||
#define MATH_MAX(a,b) (a>b?a:b)
|
||||
#define MATH_ABS(x) ((x)>0?(x):(-(x)))
|
||||
#define LV_MATH_MIN(a,b) (a<b?a:b)
|
||||
#define LV_MATH_MAX(a,b) (a>b?a:b)
|
||||
#define LV_MATH_ABS(x) ((x)>0?(x):(-(x)))
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
@ -37,8 +36,6 @@ extern "C" {
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_MATH_BASE*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @file dyn_mem.c
|
||||
* @file lv_mem.c
|
||||
* General and portable implementation of malloc and free.
|
||||
* The dynamic memory monitoring is also supported.
|
||||
*/
|
||||
@ -177,7 +177,7 @@ void * lv_mem_realloc(void * data_p, uint32_t new_size)
|
||||
if(e->header.used == 0) data_p = NULL;
|
||||
}
|
||||
|
||||
uint32_t old_size = dm_get_size(data_p);
|
||||
uint32_t old_size = lv_mem_get_size(data_p);
|
||||
if(old_size == new_size) return data_p;
|
||||
|
||||
void * new_p;
|
||||
@ -186,7 +186,7 @@ void * lv_mem_realloc(void * data_p, uint32_t new_size)
|
||||
if(new_p != NULL && data_p != NULL) {
|
||||
/*Copy the old data to the new. Use the smaller size*/
|
||||
if(old_size != 0) {
|
||||
memcpy(new_p, data_p, MATH_MIN(new_size, old_size));
|
||||
memcpy(new_p, data_p, LV_MATH_MIN(new_size, old_size));
|
||||
lv_mem_free(data_p);
|
||||
}
|
||||
}
|
||||
@ -276,7 +276,7 @@ void lv_mem_monitor(dm_mon_t * mon_p)
|
||||
* @param data pointer to an allocated memory
|
||||
* @return the size of data memory in bytes
|
||||
*/
|
||||
uint32_t dm_get_size(void * data)
|
||||
uint32_t lv_mem_get_size(void * data)
|
||||
{
|
||||
if(data == NULL) return 0;
|
||||
if(data == &zero_mem) return 0;
|
||||
@ -285,6 +285,7 @@ uint32_t dm_get_size(void * data)
|
||||
|
||||
return e->header.d_size;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
@ -89,7 +89,7 @@ void lv_mem_monitor(dm_mon_t * mon_p);
|
||||
* @param data pointer to an allocated memory
|
||||
* @return the size of data memory in bytes
|
||||
*/
|
||||
uint32_t dm_get_size(void * data);
|
||||
uint32_t lv_mem_get_size(void * data);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
@ -1,15 +1,13 @@
|
||||
/**
|
||||
* @file ptask.c
|
||||
* A Periodic Tasks is a void (*fp) (void) type function which will be called periodically.
|
||||
* A priority (5 levels + disable) can be assigned to ptasks.
|
||||
* @file lv_task.c
|
||||
* An 'lv_task' is a void (*fp) (void* param) type function which will be called periodically.
|
||||
* A priority (5 levels + disable) can be assigned to lv_tasks.
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "misc_conf.h"
|
||||
#if USE_PTASK != 0
|
||||
|
||||
|
||||
#include "lv_task.h"
|
||||
#include "../lv_hal/lv_hal_tick.h"
|
||||
@ -26,13 +24,13 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool ptask_exec(ptask_t* ptask_p, ptask_prio_t prio_act);
|
||||
static bool lv_task_exec(lv_task_t* lv_task_p, lv_task_prio_t prio_act);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static ll_dsc_t ptask_ll; /*Linked list to store the ptasks*/
|
||||
static bool ptask_run = false;
|
||||
static lv_ll_t lv_task_ll; /*Linked list to store the lv_tasks*/
|
||||
static bool lv_task_run = false;
|
||||
static uint8_t idle_last = 0;
|
||||
|
||||
/**********************
|
||||
@ -44,180 +42,166 @@ static uint8_t idle_last = 0;
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Init the ptask module
|
||||
* Init the lv_task module
|
||||
*/
|
||||
void ptask_init(void)
|
||||
void lv_task_init(void)
|
||||
{
|
||||
ll_init(&ptask_ll, sizeof(ptask_t));
|
||||
lv_ll_init(&lv_task_ll, sizeof(lv_task_t));
|
||||
|
||||
/*Initially enable the ptask handling*/
|
||||
ptask_en(true);
|
||||
/*Initially enable the lv_task handling*/
|
||||
lv_task_enable(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call it periodically to handle ptasks.
|
||||
* Call it periodically to handle lv_tasks.
|
||||
*/
|
||||
void ptask_handler(void)
|
||||
void lv_task_handler(void)
|
||||
{
|
||||
if(ptask_run == false) return;
|
||||
if(lv_task_run == false) return;
|
||||
|
||||
static uint32_t idle_tick = 0;
|
||||
static uint32_t used_tick = 0;
|
||||
uint32_t start_tick = MISC_SYSTICK_GET();
|
||||
|
||||
if(idle_tick == 0) idle_tick = MISC_SYSTICK_GET();
|
||||
|
||||
ptask_t* ptask_prio_a[PTASK_PRIO_NUM]; /*Lists for all prio.*/
|
||||
ptask_prio_t prio_act;
|
||||
lv_task_t* lv_task_prio_a[LV_TASK_PRIO_NUM]; /*Lists for all prio.*/
|
||||
lv_task_prio_t prio_act;
|
||||
bool prio_reset = false; /*Used to go back to the highest priority*/
|
||||
ptask_t* ptask_next;
|
||||
lv_task_t* lv_task_next;
|
||||
|
||||
/*Init. the lists*/
|
||||
for(prio_act = PTASK_PRIO_LOWEST; prio_act <= PTASK_PRIO_HIGHEST; prio_act++) {
|
||||
ptask_prio_a[prio_act] = ll_get_head(&ptask_ll);
|
||||
for(prio_act = LV_TASK_PRIO_LOWEST; prio_act <= LV_TASK_PRIO_HIGHEST; prio_act++) {
|
||||
lv_task_prio_a[prio_act] = lv_ll_get_head(&lv_task_ll);
|
||||
}
|
||||
|
||||
/*Handle the ptasks on all priority*/
|
||||
for(prio_act = PTASK_PRIO_HIGHEST; prio_act > PTASK_PRIO_OFF; prio_act --) {
|
||||
/*Handle the lv_tasks on all priority*/
|
||||
for(prio_act = LV_TASK_PRIO_HIGHEST; prio_act > LV_TASK_PRIO_OFF; prio_act --) {
|
||||
/*Reset the prio. if necessary*/
|
||||
if(prio_reset != false) {
|
||||
prio_reset = false;
|
||||
prio_act = PTASK_PRIO_HIGHEST; /*Go again with highest prio */
|
||||
prio_act = LV_TASK_PRIO_HIGHEST; /*Go again with highest prio */
|
||||
}
|
||||
|
||||
/* Read all ptask on 'prio_act' but stop on 'prio_reset' */
|
||||
while(ptask_prio_a[prio_act] != NULL && prio_reset == false) {
|
||||
/* Get the next task. (Invalid pointer if a ptask deletes itself)*/
|
||||
ptask_next = ll_get_next(&ptask_ll, ptask_prio_a[prio_act]);
|
||||
/* Read all lv_task on 'prio_act' but stop on 'prio_reset' */
|
||||
while(lv_task_prio_a[prio_act] != NULL && prio_reset == false) {
|
||||
/* Get the next task. (Invalid pointer if a lv_task deletes itself)*/
|
||||
lv_task_next = lv_ll_get_next(&lv_task_ll, lv_task_prio_a[prio_act]);
|
||||
|
||||
/*Execute the current ptask*/
|
||||
bool executed = ptask_exec(ptask_prio_a[prio_act], prio_act);
|
||||
/*Execute the current lv_task*/
|
||||
bool executed = lv_task_exec(lv_task_prio_a[prio_act], prio_act);
|
||||
if(executed != false) { /*If the task is executed*/
|
||||
/* During the execution higher priority ptasks
|
||||
/* During the execution higher priority lv_tasks
|
||||
* can be ready, so reset the priority if it is not highest*/
|
||||
if(prio_act != PTASK_PRIO_HIGHEST) {
|
||||
if(prio_act != LV_TASK_PRIO_HIGHEST) {
|
||||
prio_reset = true;
|
||||
}
|
||||
}
|
||||
|
||||
ptask_prio_a[prio_act] = ptask_next; /*Load the next task*/
|
||||
lv_task_prio_a[prio_act] = lv_task_next; /*Load the next task*/
|
||||
}
|
||||
|
||||
/*Reset higher priority lists on 'prio_reset' query*/
|
||||
if(prio_reset != false) {
|
||||
for(prio_act = prio_act + 1; prio_act <= PTASK_PRIO_HIGHEST; prio_act++) {
|
||||
ptask_prio_a[prio_act] = ll_get_head(&ptask_ll);
|
||||
for(prio_act = prio_act + 1; prio_act <= LV_TASK_PRIO_HIGHEST; prio_act++) {
|
||||
lv_task_prio_a[prio_act] = lv_ll_get_head(&lv_task_ll);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
used_tick += MISC_SYSTICK_ELAPS(start_tick);
|
||||
if(MISC_SYSTICK_ELAPS(idle_tick) > PTASK_IDLE_PERIOD) {
|
||||
idle_last = (uint32_t)((uint32_t) used_tick * 100) / MISC_SYSTICK_ELAPS(idle_tick); /*Calculate the busy time*/
|
||||
idle_last = idle_last > 100 ? 0 : 100 - idle_last; /*Convert he busy time to idle time*/
|
||||
idle_tick = 0;
|
||||
used_tick = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new ptask
|
||||
* Create a new lv_task
|
||||
* @param task a function which is the task itself
|
||||
* @param period call period in ms unit
|
||||
* @param prio priority of the task (PTASK_PRIO_OFF means the task is stopped)
|
||||
* @param prio priority of the task (LV_TASK_PRIO_OFF means the task is stopped)
|
||||
* @param param free parameter
|
||||
* @return pointer to the new task
|
||||
*/
|
||||
ptask_t* ptask_create(void (*task) (void *), uint32_t period, ptask_prio_t prio, void * param)
|
||||
lv_task_t* lv_task_create(void (*task) (void *), uint32_t period, lv_task_prio_t prio, void * param)
|
||||
{
|
||||
ptask_t* new_ptask;
|
||||
lv_task_t* new_lv_task;
|
||||
|
||||
new_ptask = ll_ins_head(&ptask_ll);
|
||||
dm_assert(new_ptask);
|
||||
new_lv_task = lv_ll_ins_head(&lv_task_ll);
|
||||
dm_assert(new_lv_task);
|
||||
|
||||
new_ptask->period = period;
|
||||
new_ptask->task = task;
|
||||
new_ptask->prio = prio;
|
||||
new_ptask->param = param;
|
||||
new_ptask->once = 0;
|
||||
new_ptask->last_run = MISC_SYSTICK_GET();
|
||||
new_lv_task->period = period;
|
||||
new_lv_task->task = task;
|
||||
new_lv_task->prio = prio;
|
||||
new_lv_task->param = param;
|
||||
new_lv_task->once = 0;
|
||||
new_lv_task->last_run = MISC_SYSTICK_GET();
|
||||
|
||||
return new_ptask;
|
||||
return new_lv_task;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a ptask
|
||||
* @param ptask_p pointer to task created by ptask_p
|
||||
* Delete a lv_task
|
||||
* @param lv_task_p pointer to task created by lv_task_p
|
||||
*/
|
||||
void ptask_del(ptask_t* ptask_p)
|
||||
void lv_task_del(lv_task_t* lv_task_p)
|
||||
{
|
||||
ll_rem(&ptask_ll, ptask_p);
|
||||
lv_ll_rem(&lv_task_ll, lv_task_p);
|
||||
|
||||
lv_mem_free(ptask_p);
|
||||
lv_mem_free(lv_task_p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set new priority for a ptask
|
||||
* @param ptask_p pointer to a ptask
|
||||
* Set new priority for a lv_task
|
||||
* @param lv_task_p pointer to a lv_task
|
||||
* @param prio the new priority
|
||||
*/
|
||||
void ptask_set_prio(ptask_t* ptask_p, ptask_prio_t prio)
|
||||
void lv_task_set_prio(lv_task_t* lv_task_p, lv_task_prio_t prio)
|
||||
{
|
||||
ptask_p->prio = prio;
|
||||
lv_task_p->prio = prio;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set new period for a ptask
|
||||
* @param ptask_p pointer to a ptask
|
||||
* Set new period for a lv_task
|
||||
* @param lv_task_p pointer to a lv_task
|
||||
* @param period the new period
|
||||
*/
|
||||
void ptask_set_period(ptask_t* ptask_p, uint32_t period)
|
||||
void lv_task_set_period(lv_task_t* lv_task_p, uint32_t period)
|
||||
{
|
||||
ptask_p->period = period;
|
||||
lv_task_p->period = period;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a ptask ready. It will not wait its period.
|
||||
* @param ptask_p pointer to a ptask.
|
||||
* Make a lv_task ready. It will not wait its period.
|
||||
* @param lv_task_p pointer to a lv_task.
|
||||
*/
|
||||
void ptask_ready(ptask_t* ptask_p)
|
||||
void lv_task_ready(lv_task_t* lv_task_p)
|
||||
{
|
||||
ptask_p->last_run = MISC_SYSTICK_GET() - ptask_p->period - 1;
|
||||
lv_task_p->last_run = MISC_SYSTICK_GET() - lv_task_p->period - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the ptask after one call
|
||||
* @param ptask_p pointer to a ptask.
|
||||
* Delete the lv_task after one call
|
||||
* @param lv_task_p pointer to a lv_task.
|
||||
*/
|
||||
void ptask_once(ptask_t * ptask_p)
|
||||
void lv_task_once(lv_task_t * lv_task_p)
|
||||
{
|
||||
ptask_p->once = 1;
|
||||
lv_task_p->once = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset a ptask.
|
||||
* Reset a lv_task.
|
||||
* It will be called the previously set period milliseconds later.
|
||||
* @param ptask_p pointer to a ptask.
|
||||
* @param lv_task_p pointer to a lv_task.
|
||||
*/
|
||||
void ptask_reset(ptask_t* ptask_p)
|
||||
void lv_task_reset(lv_task_t* lv_task_p)
|
||||
{
|
||||
ptask_p->last_run = MISC_SYSTICK_GET();
|
||||
lv_task_p->last_run = MISC_SYSTICK_GET();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable ptask handling
|
||||
* @param en: true: ptask handling is running, false: ptask handling is suspended
|
||||
* Enable or disable the whole lv_task handling
|
||||
* @param en: true: lv_task handling is running, false: lv_task handling is suspended
|
||||
*/
|
||||
void ptask_en(bool en)
|
||||
void lv_task_enable(bool en)
|
||||
{
|
||||
ptask_run = en;
|
||||
lv_task_run = en;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get idle percentage
|
||||
* @return the ptask idle in percentage
|
||||
* @return the lv_task idle in percentage
|
||||
*/
|
||||
uint8_t ptask_get_idle(void)
|
||||
uint8_t lv_task_get_idle(void)
|
||||
{
|
||||
return idle_last;
|
||||
}
|
||||
@ -229,24 +213,24 @@ uint8_t ptask_get_idle(void)
|
||||
|
||||
/**
|
||||
* Execute task if its the priority is appropriate
|
||||
* @param ptask_p pointer to ptask
|
||||
* @param lv_task_p pointer to lv_task
|
||||
* @param prio_act the current priority
|
||||
* @return true: execute, false: not executed
|
||||
*/
|
||||
static bool ptask_exec (ptask_t* ptask_p, ptask_prio_t prio_act)
|
||||
static bool lv_task_exec (lv_task_t* lv_task_p, lv_task_prio_t prio_act)
|
||||
{
|
||||
bool exec = false;
|
||||
|
||||
/*Execute ptask if its prio is 'prio_act'*/
|
||||
if(ptask_p->prio == prio_act) {
|
||||
/*Execute lv_task if its prio is 'prio_act'*/
|
||||
if(lv_task_p->prio == prio_act) {
|
||||
/*Execute if at least 'period' time elapsed*/
|
||||
uint32_t elp = MISC_SYSTICK_ELAPS(ptask_p->last_run);
|
||||
if(elp >= ptask_p->period) {
|
||||
ptask_p->last_run = MISC_SYSTICK_GET();
|
||||
ptask_p->task(ptask_p->param);
|
||||
uint32_t elp = MISC_SYSTICK_ELAPS(lv_task_p->last_run);
|
||||
if(elp >= lv_task_p->period) {
|
||||
lv_task_p->last_run = MISC_SYSTICK_GET();
|
||||
lv_task_p->task(lv_task_p->param);
|
||||
|
||||
/*Delete if it was a one shot ptask*/
|
||||
if(ptask_p->once != 0) ptask_del(ptask_p);
|
||||
/*Delete if it was a one shot lv_task*/
|
||||
if(lv_task_p->once != 0) lv_task_del(lv_task_p);
|
||||
|
||||
exec = true;
|
||||
}
|
||||
@ -255,5 +239,3 @@ static bool ptask_exec (ptask_t* ptask_p, ptask_prio_t prio_act)
|
||||
return exec;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,11 +1,11 @@
|
||||
/**
|
||||
* @file ptask.h
|
||||
* A Periodic Tasks is a void (*fp) (void) type function which will be called periodically.
|
||||
* A priority (5 levels + disable) can be assigned to ptasks.
|
||||
* @file lv_task.c
|
||||
* An 'lv_task' is a void (*fp) (void* param) type function which will be called periodically.
|
||||
* A priority (5 levels + disable) can be assigned to lv_tasks.
|
||||
*/
|
||||
|
||||
#ifndef PTASK_H
|
||||
#define PTASK_H
|
||||
#ifndef LV_TASK_H
|
||||
#define LV_TASK_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -16,7 +16,6 @@ extern "C" {
|
||||
*********************/
|
||||
#include "misc_conf.h"
|
||||
|
||||
#if USE_PTASK != 0
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "lv_mem.h"
|
||||
@ -25,30 +24,26 @@ extern "C" {
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#ifndef PTASK_IDLE_PERIOD
|
||||
#define PTASK_IDLE_PERIOD 500
|
||||
#endif
|
||||
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
/**
|
||||
* Possible priorities for ptasks
|
||||
* Possible priorities for lv_tasks
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PTASK_PRIO_OFF = 0,
|
||||
PTASK_PRIO_LOWEST,
|
||||
PTASK_PRIO_LOW,
|
||||
PTASK_PRIO_MID,
|
||||
PTASK_PRIO_HIGH,
|
||||
PTASK_PRIO_HIGHEST,
|
||||
PTASK_PRIO_NUM,
|
||||
}ptask_prio_t;
|
||||
LV_TASK_PRIO_OFF = 0,
|
||||
LV_TASK_PRIO_LOWEST,
|
||||
LV_TASK_PRIO_LOW,
|
||||
LV_TASK_PRIO_MID,
|
||||
LV_TASK_PRIO_HIGH,
|
||||
LV_TASK_PRIO_HIGHEST,
|
||||
LV_TASK_PRIO_NUM,
|
||||
}lv_task_prio_t;
|
||||
|
||||
/**
|
||||
* Descriptor of a ptask
|
||||
* Descriptor of a lv_task
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
@ -58,86 +53,82 @@ typedef struct
|
||||
void * param;
|
||||
uint8_t prio:3;
|
||||
uint8_t once:1;
|
||||
}ptask_t;
|
||||
}lv_task_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Init the ptask module
|
||||
* Init the lv_task module
|
||||
*/
|
||||
void ptask_init(void);
|
||||
void lv_task_init(void);
|
||||
|
||||
/**
|
||||
* Call it periodically to handle ptasks.
|
||||
* Call it periodically to handle lv_tasks.
|
||||
*/
|
||||
void ptask_handler(void);
|
||||
void lv_task_handler(void);
|
||||
|
||||
/**
|
||||
* Create a new ptask
|
||||
* Create a new lv_task
|
||||
* @param task a function which is the task itself
|
||||
* @param period call period in ms unit
|
||||
* @param prio priority of the task (PTASK_PRIO_OFF means the task is stopped)
|
||||
* @param prio priority of the task (LV_TASK_PRIO_OFF means the task is stopped)
|
||||
* @param param free parameter
|
||||
* @return pointer to the new task
|
||||
*/
|
||||
ptask_t* ptask_create(void (*task) (void *), uint32_t period, ptask_prio_t prio, void * param);
|
||||
lv_task_t* lv_task_create(void (*task) (void *), uint32_t period, lv_task_prio_t prio, void * param);
|
||||
|
||||
/**
|
||||
* Delete a ptask
|
||||
* @param ptask_p pointer to task created by ptask_p
|
||||
* Delete a lv_task
|
||||
* @param lv_task_p pointer to task created by lv_task_p
|
||||
*/
|
||||
void ptask_del(ptask_t* ptask_p);
|
||||
void lv_task_del(lv_task_t* lv_task_p);
|
||||
|
||||
/**
|
||||
* Set new priority for a ptask
|
||||
* @param ptask_p pointer to a ptask
|
||||
* Set new priority for a lv_task
|
||||
* @param lv_task_p pointer to a lv_task
|
||||
* @param prio the new priority
|
||||
*/
|
||||
void ptask_set_prio(ptask_t* ptask_p, ptask_prio_t prio);
|
||||
void lv_task_set_prio(lv_task_t* lv_task_p, lv_task_prio_t prio);
|
||||
|
||||
/**
|
||||
* Set new period for a ptask
|
||||
* @param ptask_p pointer to a ptask
|
||||
* Set new period for a lv_task
|
||||
* @param lv_task_p pointer to a lv_task
|
||||
* @param period the new period
|
||||
*/
|
||||
void ptask_set_period(ptask_t* ptask_p, uint32_t period);
|
||||
void lv_task_set_period(lv_task_t* lv_task_p, uint32_t period);
|
||||
|
||||
/**
|
||||
* Make a ptask ready. It will not wait its period.
|
||||
* @param ptask_p pointer to a ptask.
|
||||
* Make a lv_task ready. It will not wait its period.
|
||||
* @param lv_task_p pointer to a lv_task.
|
||||
*/
|
||||
void ptask_ready(ptask_t* ptask_p);
|
||||
void lv_task_ready(lv_task_t* lv_task_p);
|
||||
|
||||
|
||||
/**
|
||||
* Delete the ptask after one call
|
||||
* @param ptask_p pointer to a ptask.
|
||||
* Delete the lv_task after one call
|
||||
* @param lv_task_p pointer to a lv_task.
|
||||
*/
|
||||
void ptask_once(ptask_t * ptask_p);
|
||||
void lv_task_once(lv_task_t * lv_task_p);
|
||||
|
||||
/**
|
||||
* Reset a ptask.
|
||||
* Reset a lv_task.
|
||||
* It will be called the previously set period milliseconds later.
|
||||
* @param ptask_p pointer to a ptask.
|
||||
* @param lv_task_p pointer to a lv_task.
|
||||
*/
|
||||
void ptask_reset(ptask_t* ptask_p);
|
||||
void lv_task_reset(lv_task_t* lv_task_p);
|
||||
|
||||
/**
|
||||
* Enable or disable ptask handling
|
||||
* @param en: true: ptask handling is running, false: ptask handling is suspended
|
||||
* Enable or disable the whole lv_task handling
|
||||
* @param en: true: lv_task handling is running, false: lv_task handling is suspended
|
||||
*/
|
||||
void ptask_en(bool en);
|
||||
|
||||
uint8_t ptask_get_idle(void);
|
||||
void lv_task_enable(bool en);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
@ -1,14 +1,13 @@
|
||||
|
||||
/**
|
||||
* @file trigo.c
|
||||
* Basic trigonometrical integer functions
|
||||
* @file lv_trigo.c
|
||||
* Basic trigonometric integer functions
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "misc_conf.h"
|
||||
#if USE_TRIGO != 0
|
||||
|
||||
#include "lv_trigo.h"
|
||||
|
||||
@ -54,7 +53,7 @@ static int16_t sin0_90_table[] =
|
||||
* @param angle
|
||||
* @return sinus of 'angle'. sin(-90) = -32767, sin(90) = 32767
|
||||
*/
|
||||
int16_t trigo_sin(int16_t angle)
|
||||
int16_t lv_trigo_sin(int16_t angle)
|
||||
{
|
||||
int16_t ret = 0;
|
||||
angle = angle % 360;
|
||||
@ -83,5 +82,3 @@ int16_t trigo_sin(int16_t angle)
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
#endif
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
* @file trig.h
|
||||
* @file lv_trig.h
|
||||
* Basic trigonometric integer functions
|
||||
*/
|
||||
|
||||
#ifndef TRIGO_H
|
||||
#define TRIGO_H
|
||||
#ifndef LV_TRIGO_H
|
||||
#define LV_TRIGO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -37,7 +37,7 @@ extern "C" {
|
||||
* @param angle
|
||||
* @return sinus of 'angle'. sin(-90) = -32767, sin(90) = 32767
|
||||
*/
|
||||
int16_t trigo_sin(int16_t angle);
|
||||
int16_t lv_trigo_sin(int16_t angle);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
@ -1,21 +1,20 @@
|
||||
/**
|
||||
* @file font.c
|
||||
* @file lv_text.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <lvgl/lv_misc/lv_txt.h>
|
||||
#include "misc_conf.h"
|
||||
#if USE_TEXT != 0
|
||||
|
||||
#include "lv_text.h"
|
||||
#include "lv_math.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define TXT_NO_BREAK_FOUND UINT32_MAX
|
||||
#define NO_BREAK_FOUND UINT32_MAX
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
@ -24,7 +23,7 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool txt_is_break_char(uint32_t letter);
|
||||
static bool is_break_char(uint32_t letter);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@ -48,8 +47,8 @@ static bool txt_is_break_char(uint32_t letter);
|
||||
* @param flags settings for the text from 'txt_flag_t' enum
|
||||
* @param max_width max with of the text (break the lines to fit this size) Set CORD_MAX to avoid line breaks
|
||||
*/
|
||||
void txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t * font,
|
||||
lv_coord_t letter_space, lv_coord_t line_space, lv_coord_t max_width, txt_flag_t flag)
|
||||
void lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t * font,
|
||||
lv_coord_t letter_space, lv_coord_t line_space, lv_coord_t max_width, lv_txt_flag_t flag)
|
||||
{
|
||||
size_res->x = 0;
|
||||
size_res->y = 0;
|
||||
@ -57,7 +56,7 @@ void txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t * fo
|
||||
if(text == NULL) return;
|
||||
if(font == NULL) return;
|
||||
|
||||
if(flag & TXT_FLAG_EXPAND) max_width = LV_COORD_MAX;
|
||||
if(flag & LV_TXT_FLAG_EXPAND) max_width = LV_COORD_MAX;
|
||||
|
||||
uint32_t line_start = 0;
|
||||
uint32_t new_line_start = 0;
|
||||
@ -66,15 +65,15 @@ void txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t * fo
|
||||
|
||||
/*Calc. the height and longest line*/
|
||||
while (text[line_start] != '\0') {
|
||||
new_line_start += txt_get_next_line(&text[line_start], font, letter_space, max_width, flag);
|
||||
new_line_start += lv_txt_get_next_line(&text[line_start], font, letter_space, max_width, flag);
|
||||
size_res->y += letter_height ;
|
||||
size_res->y += line_space;
|
||||
|
||||
/*Calculate the the longest line*/
|
||||
act_line_length = txt_get_width(&text[line_start], new_line_start - line_start,
|
||||
act_line_length = lv_txt_get_width(&text[line_start], new_line_start - line_start,
|
||||
font, letter_space, flag);
|
||||
|
||||
size_res->x = MATH_MAX(act_line_length, size_res->x);
|
||||
size_res->x = LV_MATH_MAX(act_line_length, size_res->x);
|
||||
line_start = new_line_start;
|
||||
}
|
||||
|
||||
@ -97,34 +96,34 @@ void txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t * fo
|
||||
* @param flags settings for the text from 'txt_flag_type' enum
|
||||
* @return the index of the first char of the new line (in byte index not letter index. With UTF-8 they are different)
|
||||
*/
|
||||
uint16_t txt_get_next_line(const char * txt, const lv_font_t * font,
|
||||
lv_coord_t letter_space, lv_coord_t max_width, txt_flag_t flag)
|
||||
uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font,
|
||||
lv_coord_t letter_space, lv_coord_t max_width, lv_txt_flag_t flag)
|
||||
{
|
||||
if(txt == NULL) return 0;
|
||||
if(font == NULL) return 0;
|
||||
|
||||
if(flag & TXT_FLAG_EXPAND) max_width = LV_COORD_MAX;
|
||||
if(flag & LV_TXT_FLAG_EXPAND) max_width = LV_COORD_MAX;
|
||||
|
||||
uint32_t i = 0;
|
||||
lv_coord_t act_l = 0;
|
||||
uint32_t last_break = TXT_NO_BREAK_FOUND;
|
||||
txt_cmd_state_t cmd_state = TXT_CMD_STATE_WAIT;
|
||||
uint32_t last_break = NO_BREAK_FOUND;
|
||||
lv_txt_cmd_state_t cmd_state = LV_TXT_CMD_STATE_WAIT;
|
||||
uint32_t letter = 0;
|
||||
|
||||
while(txt[i] != '\0') {
|
||||
letter = txt_utf8_next(txt, &i);
|
||||
letter = lv_txt_utf8_next(txt, &i);
|
||||
|
||||
/*Handle the recolor command*/
|
||||
if((flag & TXT_FLAG_RECOLOR) != 0) {
|
||||
if(txt_is_cmd(&cmd_state, letter) != false) {
|
||||
if((flag & LV_TXT_FLAG_RECOLOR) != 0) {
|
||||
if(lv_txt_is_cmd(&cmd_state, letter) != false) {
|
||||
continue; /*Skip the letter is it is part of a command*/
|
||||
}
|
||||
}
|
||||
/*Check for new line chars*/
|
||||
if((flag & TXT_FLAG_NO_BREAK) == 0 && (letter == '\n' || letter == '\r')) {
|
||||
if((flag & LV_TXT_FLAG_NO_BREAK) == 0 && (letter == '\n' || letter == '\r')) {
|
||||
/*Handle \r\n as well*/
|
||||
uint32_t i_tmp = i;
|
||||
uint32_t letter_next = txt_utf8_next(txt, &i_tmp);
|
||||
uint32_t letter_next = lv_txt_utf8_next(txt, &i_tmp);
|
||||
if(letter == '\r' && letter_next == '\n') i = i_tmp;
|
||||
|
||||
return i; /*Return with the first letter of the next line*/
|
||||
@ -135,29 +134,29 @@ uint16_t txt_get_next_line(const char * txt, const lv_font_t * font,
|
||||
/*If the txt is too long then finish, this is the line end*/
|
||||
if(act_l > max_width) {
|
||||
/*If this a break char then break here.*/
|
||||
if(txt_is_break_char(letter)) {
|
||||
if(is_break_char(letter)) {
|
||||
/* Now 'i' points to the next char because of txt_utf8_next()
|
||||
* But we need the first char of the next line so keep it.
|
||||
* Hence do nothing here*/
|
||||
}
|
||||
/*If already a break character is found, then break there*/
|
||||
else if(last_break != TXT_NO_BREAK_FOUND ) {
|
||||
else if(last_break != NO_BREAK_FOUND ) {
|
||||
i = last_break;
|
||||
} else {
|
||||
/* Now this character is out of the area but 'i' points to the next char because of txt_utf8_next()
|
||||
* So step back one char*/
|
||||
txt_utf8_prev(txt, &i);
|
||||
lv_txt_utf8_prev(txt, &i);
|
||||
}
|
||||
|
||||
/* Do not let to return without doing nothing.
|
||||
* Find at least one character (Avoid infinite loop )*/
|
||||
if(i == 0) txt_utf8_next(txt, &i);
|
||||
if(i == 0) lv_txt_utf8_next(txt, &i);
|
||||
|
||||
return i;
|
||||
}
|
||||
/*If this char still can fit to this line then check if
|
||||
* txt can be broken here later */
|
||||
else if(txt_is_break_char(letter)) {
|
||||
else if(is_break_char(letter)) {
|
||||
last_break = i; /*Save the first char index after break*/
|
||||
}
|
||||
}
|
||||
@ -177,22 +176,22 @@ uint16_t txt_get_next_line(const char * txt, const lv_font_t * font,
|
||||
* @param flags settings for the text from 'txt_flag_t' enum
|
||||
* @return length of a char_num long text
|
||||
*/
|
||||
lv_coord_t txt_get_width(const char * txt, uint16_t length,
|
||||
const lv_font_t * font, lv_coord_t letter_space, txt_flag_t flag)
|
||||
lv_coord_t lv_txt_get_width(const char * txt, uint16_t length,
|
||||
const lv_font_t * font, lv_coord_t letter_space, lv_txt_flag_t flag)
|
||||
{
|
||||
if(txt == NULL) return 0;
|
||||
if(font == NULL) return 0;
|
||||
|
||||
uint32_t i = 0;
|
||||
lv_coord_t width = 0;
|
||||
txt_cmd_state_t cmd_state = TXT_CMD_STATE_WAIT;
|
||||
lv_txt_cmd_state_t cmd_state = LV_TXT_CMD_STATE_WAIT;
|
||||
uint32_t letter;
|
||||
|
||||
if(length != 0) {
|
||||
while(i < length) {
|
||||
letter = txt_utf8_next(txt, &i);
|
||||
if((flag & TXT_FLAG_RECOLOR) != 0) {
|
||||
if(txt_is_cmd(&cmd_state, letter) != false) {
|
||||
letter = lv_txt_utf8_next(txt, &i);
|
||||
if((flag & LV_TXT_FLAG_RECOLOR) != 0) {
|
||||
if(lv_txt_is_cmd(&cmd_state, letter) != false) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -222,26 +221,26 @@ lv_coord_t txt_get_width(const char * txt, uint16_t length,
|
||||
* @return true: the character is part of a command and should not be written,
|
||||
* false: the character should be written
|
||||
*/
|
||||
bool txt_is_cmd(txt_cmd_state_t * state, uint32_t c)
|
||||
bool lv_txt_is_cmd(lv_txt_cmd_state_t * state, uint32_t c)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
if(c == TXT_RELV_COLOR_CMD) {
|
||||
if(*state == TXT_CMD_STATE_WAIT) { /*Start char*/
|
||||
*state = TXT_CMD_STATE_PAR;
|
||||
if(c == LV_TXT_COLOR_CMD[0]) {
|
||||
if(*state == LV_TXT_CMD_STATE_WAIT) { /*Start char*/
|
||||
*state = LV_TXT_CMD_STATE_PAR;
|
||||
ret = true;
|
||||
} else if(*state == TXT_CMD_STATE_PAR) { /*Other start char in parameter is escaped cmd. char */
|
||||
*state = TXT_CMD_STATE_WAIT;
|
||||
}else if(*state == TXT_CMD_STATE_IN) { /*Command end */
|
||||
*state = TXT_CMD_STATE_WAIT;
|
||||
} else if(*state == LV_TXT_CMD_STATE_PAR) { /*Other start char in parameter is escaped cmd. char */
|
||||
*state = LV_TXT_CMD_STATE_WAIT;
|
||||
}else if(*state == LV_TXT_CMD_STATE_IN) { /*Command end */
|
||||
*state = LV_TXT_CMD_STATE_WAIT;
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*Skip the color parameter and wait the space after it*/
|
||||
if(*state == TXT_CMD_STATE_PAR) {
|
||||
if(*state == LV_TXT_CMD_STATE_PAR) {
|
||||
if(c == ' ') {
|
||||
*state = TXT_CMD_STATE_IN; /*After the parameter the text is in the command*/
|
||||
*state = LV_TXT_CMD_STATE_IN; /*After the parameter the text is in the command*/
|
||||
}
|
||||
ret = true;
|
||||
}
|
||||
@ -256,7 +255,7 @@ bool txt_is_cmd(txt_cmd_state_t * state, uint32_t c)
|
||||
* 0: before the original text, 1: after the first char etc.
|
||||
* @param ins_txt text to insert
|
||||
*/
|
||||
void txt_ins(char * txt_buf, uint32_t pos, const char * ins_txt)
|
||||
void lv_txt_ins(char * txt_buf, uint32_t pos, const char * ins_txt)
|
||||
{
|
||||
uint32_t old_len = strlen(txt_buf);
|
||||
uint32_t ins_len = strlen(ins_txt);
|
||||
@ -280,7 +279,7 @@ void txt_ins(char * txt_buf, uint32_t pos, const char * ins_txt)
|
||||
* @param pos position where to start the deleting (0: before the first char, 1: after the first char etc.)
|
||||
* @param len number of characters to delete
|
||||
*/
|
||||
void txt_cut(char * txt, uint32_t pos, uint32_t len)
|
||||
void lv_txt_cut(char * txt, uint32_t pos, uint32_t len)
|
||||
{
|
||||
|
||||
uint32_t old_len = strlen(txt);
|
||||
@ -301,7 +300,7 @@ void txt_cut(char * txt, uint32_t pos, uint32_t len)
|
||||
* @param c A character where the UTF-8 character starts
|
||||
* @return length of the UTF-8 character (1,2,3 or 4). O on invalid code
|
||||
*/
|
||||
uint8_t txt_utf8_size(uint8_t c)
|
||||
uint8_t lv_txt_utf8_size(uint8_t c)
|
||||
{
|
||||
if((c & 0b10000000) == 0) return 1;
|
||||
else if((c & 0b11100000) == 0b11000000) return 2;
|
||||
@ -346,12 +345,12 @@ uint32_t txt_unicode_to_utf8(uint32_t letter_uni)
|
||||
/**
|
||||
* Decode an UTF-8 character from a string.
|
||||
* @param txt pointer to '\0' terminated string
|
||||
* @param i start index in 'txt' where to start.
|
||||
* After the call it will point to the next UTF-8 char in 'txt'.
|
||||
* @param i start byte index in 'txt' where to start.
|
||||
* After call it will point to the next UTF-8 char in 'txt'.
|
||||
* NULL to use txt[0] as index
|
||||
* @return the decoded Unicode character or 0 on invalid UTF-8 code
|
||||
*/
|
||||
uint32_t txt_utf8_next(const char * txt, uint32_t * i)
|
||||
uint32_t lv_txt_utf8_next(const char * txt, uint32_t * i)
|
||||
{
|
||||
#if TXT_UTF8 == 0
|
||||
if(i == NULL) return txt[1]; /*Get the next char */
|
||||
@ -428,38 +427,47 @@ uint32_t txt_utf8_next(const char * txt, uint32_t * i)
|
||||
/**
|
||||
* Get previous UTF-8 character form a string.
|
||||
* @param txt pointer to '\0' terminated string
|
||||
* @param i_start index in 'txt' where to start. After the call it will point to the next UTF-8 char in 'txt'.
|
||||
* @param i start byte index in 'txt' where to start. After the call it will point to the previous UTF-8 char in 'txt'.
|
||||
* @return the decoded Unicode character or 0 on invalid UTF-8 code
|
||||
*/
|
||||
uint32_t txt_utf8_prev(const char * txt, uint32_t * i_start)
|
||||
uint32_t lv_txt_utf8_prev(const char * txt, uint32_t * i)
|
||||
{
|
||||
#if TXT_UTF8 == 0
|
||||
if(i == NULL) return *(txt- 1); /*Get the prev. char */
|
||||
|
||||
(*i)--;
|
||||
uint8_t letter = txt[*i)] ;
|
||||
|
||||
return letter;
|
||||
#else
|
||||
uint8_t c_size;
|
||||
uint8_t cnt = 0;
|
||||
|
||||
/*Try to find a !0 long UTF-8 char by stepping one character back*/
|
||||
(*i_start)--;
|
||||
(*i)--;
|
||||
do {
|
||||
if(cnt >= 4) return 0; /*No UTF-8 char found before the initial*/
|
||||
|
||||
c_size = txt_utf8_size(txt[*i_start]);
|
||||
c_size = lv_txt_utf8_size(txt[*i]);
|
||||
if(c_size == 0) {
|
||||
if(*i_start != 0) (*i_start)--;
|
||||
if(*i != 0) (*i)--;
|
||||
else return 0;
|
||||
}
|
||||
cnt++;
|
||||
} while(c_size == 0);
|
||||
|
||||
uint32_t i_tmp = *i_start;
|
||||
uint32_t letter = txt_utf8_next(txt, &i_tmp); /*Character found, get it*/
|
||||
uint32_t i_tmp = *i;
|
||||
uint32_t letter = lv_txt_utf8_next(txt, &i_tmp); /*Character found, get it*/
|
||||
|
||||
return letter;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a character index (in an UTF-8 text) to byte index.
|
||||
* E.g. in "AÁRT" index of 'R' is 2 but start at byte 3 because 'Á' is 2 bytes long
|
||||
* E.g. in "AÁRT" index of 'R' is 2th char but start at byte 3 because 'Á' is 2 bytes long
|
||||
* @param txt a '\0' terminated UTF-8 string
|
||||
* @param utf8_id letter index
|
||||
* @param utf8_id character index
|
||||
* @return byte index of the 'utf8_id'th letter
|
||||
*/
|
||||
uint32_t txt_utf8_get_byte_id(const char * txt, uint32_t utf8_id)
|
||||
@ -470,7 +478,7 @@ uint32_t txt_utf8_get_byte_id(const char * txt, uint32_t utf8_id)
|
||||
uint32_t i;
|
||||
uint32_t byte_cnt = 0;
|
||||
for(i = 0; i < utf8_id; i++) {
|
||||
byte_cnt += txt_utf8_size(txt[byte_cnt]);
|
||||
byte_cnt += lv_txt_utf8_size(txt[byte_cnt]);
|
||||
}
|
||||
|
||||
return byte_cnt;
|
||||
@ -480,12 +488,12 @@ uint32_t txt_utf8_get_byte_id(const char * txt, uint32_t utf8_id)
|
||||
|
||||
/**
|
||||
* Convert a byte index (in an UTF-8 text) to character index.
|
||||
* E.g. in "AÁRT" index of 'R' is 2 but start at byte 3 because 'Á' is 2 bytes long
|
||||
* E.g. in "AÁRT" index of 'R' is 2th char but start at byte 3 because 'Á' is 2 bytes long
|
||||
* @param txt a '\0' terminated UTF-8 string
|
||||
* @param byte_id byte index
|
||||
* @return character index of the letter at 'byte_id'th position
|
||||
*/
|
||||
uint32_t txt_utf8_get_char_id(const char * txt, uint32_t byte_id)
|
||||
uint32_t lv_txt_utf8_get_char_id(const char * txt, uint32_t byte_id)
|
||||
{
|
||||
#if TXT_UTF8 == 0
|
||||
return byte_id; /*In Non UTF-8 no difference*/
|
||||
@ -494,7 +502,7 @@ uint32_t txt_utf8_get_char_id(const char * txt, uint32_t byte_id)
|
||||
uint32_t char_cnt = 0;
|
||||
|
||||
while(i < byte_id) {
|
||||
txt_utf8_next(txt, &i); /*'i' points to the next letter so use the prev. value*/
|
||||
lv_txt_utf8_next(txt, &i); /*'i' points to the next letter so use the prev. value*/
|
||||
char_cnt++;
|
||||
}
|
||||
|
||||
@ -509,7 +517,7 @@ uint32_t txt_utf8_get_char_id(const char * txt, uint32_t byte_id)
|
||||
* @param txt a '\0' terminated char string
|
||||
* @return number of characters
|
||||
*/
|
||||
uint32_t txt_len(const char * txt)
|
||||
uint32_t lv_txt_get_length(const char * txt)
|
||||
{
|
||||
#if TXT_UTF8 == 0
|
||||
return strlen(txt);
|
||||
@ -518,7 +526,7 @@ uint32_t txt_len(const char * txt)
|
||||
uint32_t i = 0;
|
||||
|
||||
while(txt[i] != '\0') {
|
||||
txt_utf8_next(txt, &i);
|
||||
lv_txt_utf8_next(txt, &i);
|
||||
len++;
|
||||
}
|
||||
|
||||
@ -535,7 +543,7 @@ uint32_t txt_len(const char * txt)
|
||||
* @param letter a letter
|
||||
* @return false: 'letter' is not break char
|
||||
*/
|
||||
static bool txt_is_break_char(uint32_t letter)
|
||||
static bool is_break_char(uint32_t letter)
|
||||
{
|
||||
uint8_t i;
|
||||
bool ret = false;
|
||||
@ -551,4 +559,3 @@ static bool txt_is_break_char(uint32_t letter)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /*USE_TEXT*/
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
* @file text.h
|
||||
* @file lv_text.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TEXT_H
|
||||
#define TEXT_H
|
||||
#ifndef LV_TEXT_H
|
||||
#define LV_TEXT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -14,7 +14,6 @@ extern "C" {
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "misc_conf.h"
|
||||
#if USE_FONT != 0
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "lv_area.h"
|
||||
@ -24,26 +23,26 @@ extern "C" {
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define TXT_RELV_COLOR_CMD '#'
|
||||
#define LV_TXT_COLOR_CMD "#"
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef enum
|
||||
{
|
||||
TXT_FLAG_NONE = 0x00,
|
||||
TXT_FLAG_RECOLOR = 0x01, /*Enable parsing of recolor command*/
|
||||
TXT_FLAG_EXPAND = 0x02, /*Ignore width (Used by the library)*/
|
||||
TXT_FLAG_NO_BREAK = 0x04, /*Ignore line breaks (Used by the library)*/
|
||||
TXT_FLAG_CENTER = 0x08, /*Align the text to the middle*/
|
||||
}txt_flag_t;
|
||||
LV_TXT_FLAG_NONE = 0x00,
|
||||
LV_TXT_FLAG_RECOLOR = 0x01, /*Enable parsing of recolor command*/
|
||||
LV_TXT_FLAG_EXPAND = 0x02, /*Ignore width (Used by the library)*/
|
||||
LV_TXT_FLAG_NO_BREAK = 0x04, /*Ignore line breaks (Used by the library)*/
|
||||
LV_TXT_FLAG_CENTER = 0x08, /*Align the text to the middle*/
|
||||
}lv_txt_flag_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TXT_CMD_STATE_WAIT,
|
||||
TXT_CMD_STATE_PAR,
|
||||
TXT_CMD_STATE_IN,
|
||||
}txt_cmd_state_t;
|
||||
LV_TXT_CMD_STATE_WAIT, /*Waiting for command*/
|
||||
LV_TXT_CMD_STATE_PAR, /*Processing the parameter*/
|
||||
LV_TXT_CMD_STATE_IN, /*Processing the command*/
|
||||
}lv_txt_cmd_state_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
@ -59,8 +58,8 @@ typedef enum
|
||||
* @param flags settings for the text from 'txt_flag_t' enum
|
||||
* @param max_width max with of the text (break the lines to fit this size) Set CORD_MAX to avoid line breaks
|
||||
*/
|
||||
void txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t * font,
|
||||
lv_coord_t letter_space, lv_coord_t line_space, lv_coord_t max_width, txt_flag_t flag);
|
||||
void lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t * font,
|
||||
lv_coord_t letter_space, lv_coord_t line_space, lv_coord_t max_width, lv_txt_flag_t flag);
|
||||
|
||||
/**
|
||||
* Get the next line of text. Check line length and break chars too.
|
||||
@ -71,8 +70,8 @@ void txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t * fo
|
||||
* @param flags settings for the text from 'txt_flag_t' enum
|
||||
* @return the index of the first char of the new line
|
||||
*/
|
||||
uint16_t txt_get_next_line(const char * txt, const lv_font_t * font_p,
|
||||
lv_coord_t letter_space, lv_coord_t max_l, txt_flag_t flag);
|
||||
uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font_p,
|
||||
lv_coord_t letter_space, lv_coord_t max_l, lv_txt_flag_t flag);
|
||||
|
||||
/**
|
||||
* Give the length of a text with a given font
|
||||
@ -83,8 +82,8 @@ uint16_t txt_get_next_line(const char * txt, const lv_font_t * font_p,
|
||||
* @param flags settings for the text from 'txt_flag_t' enum
|
||||
* @return length of a char_num long text
|
||||
*/
|
||||
lv_coord_t txt_get_width(const char * txt, uint16_t char_num,
|
||||
const lv_font_t * font_p, lv_coord_t letter_space, txt_flag_t flag);
|
||||
lv_coord_t lv_txt_get_width(const char * txt, uint16_t char_num,
|
||||
const lv_font_t * font_p, lv_coord_t letter_space, lv_txt_flag_t flag);
|
||||
|
||||
/**
|
||||
* Check next character in a string and decide if te character is part of the command or not
|
||||
@ -93,7 +92,7 @@ lv_coord_t txt_get_width(const char * txt, uint16_t char_num,
|
||||
* @return true: the character is part of a command and should not be written,
|
||||
* false: the character should be written
|
||||
*/
|
||||
bool txt_is_cmd(txt_cmd_state_t * state, uint32_t c);
|
||||
bool lv_txt_is_cmd(lv_txt_cmd_state_t * state, uint32_t c);
|
||||
|
||||
/**
|
||||
* Insert a string into an other
|
||||
@ -101,7 +100,7 @@ bool txt_is_cmd(txt_cmd_state_t * state, uint32_t c);
|
||||
* @param pos position to insert (0: before the original text, 1: after the first char etc.)
|
||||
* @param ins_txt text to insert
|
||||
*/
|
||||
void txt_ins(char * txt_buf, uint32_t pos, const char * ins_txt);
|
||||
void lv_txt_ins(char * txt_buf, uint32_t pos, const char * ins_txt);
|
||||
|
||||
/**
|
||||
* Delete a part of a string
|
||||
@ -109,14 +108,14 @@ void txt_ins(char * txt_buf, uint32_t pos, const char * ins_txt);
|
||||
* @param pos position where to start the deleting (0: before the first char, 1: after the first char etc.)
|
||||
* @param len number of characters to delete
|
||||
*/
|
||||
void txt_cut(char * txt, uint32_t pos, uint32_t len);
|
||||
void lv_txt_cut(char * txt, uint32_t pos, uint32_t len);
|
||||
|
||||
/**
|
||||
* Give the size of an UTF-8 coded character
|
||||
* @param c A character where the UTF-8 character starts
|
||||
* @return length of the UTF-8 character (1,2,3 or 4). O on invalid code
|
||||
*/
|
||||
uint8_t txt_utf8_size(uint8_t c);
|
||||
uint8_t lv_txt_utf8_size(uint8_t c);
|
||||
|
||||
|
||||
/**
|
||||
@ -134,7 +133,7 @@ uint32_t txt_unicode_to_utf8(uint32_t letter_uni);
|
||||
* NULL to use txt[0] as index
|
||||
* @return the decoded Unicode character or 0 on invalid UTF-8 code
|
||||
*/
|
||||
uint32_t txt_utf8_next(const char * txt, uint32_t * i);
|
||||
uint32_t lv_txt_utf8_next(const char * txt, uint32_t * i);
|
||||
|
||||
/**
|
||||
* Get previous UTF-8 character form a string.
|
||||
@ -142,7 +141,7 @@ uint32_t txt_utf8_next(const char * txt, uint32_t * i);
|
||||
* @param i_start index in 'txt' where to start. After the call it will point to the next UTF-8 char in 'txt'.
|
||||
* @return the decoded Unicode character or 0 on invalid UTF-8 code
|
||||
*/
|
||||
uint32_t txt_utf8_prev(const char * txt, uint32_t * i_start);
|
||||
uint32_t lv_txt_utf8_prev(const char * txt, uint32_t * i_start);
|
||||
|
||||
/**
|
||||
* Convert a letter index (in an UTF-8 text) to byte index.
|
||||
@ -160,7 +159,7 @@ uint32_t txt_utf8_get_byte_id(const char * txt, uint32_t utf8_id);
|
||||
* @param byte_id byte index
|
||||
* @return character index of the letter at 'byte_id'th position
|
||||
*/
|
||||
uint32_t txt_utf8_get_char_id(const char * txt, uint32_t byte_id);
|
||||
uint32_t lv_txt_utf8_get_char_id(const char * txt, uint32_t byte_id);
|
||||
|
||||
/**
|
||||
* Get the number of characters (and NOT bytes) in a string. Decode it with UTF-8 if enabled.
|
||||
@ -168,7 +167,7 @@ uint32_t txt_utf8_get_char_id(const char * txt, uint32_t byte_id);
|
||||
* @param txt a '\0' terminated char string
|
||||
* @return number of characters
|
||||
*/
|
||||
uint32_t txt_len(const char * txt);
|
||||
uint32_t lv_txt_get_length(const char * txt);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -179,6 +178,3 @@ uint32_t txt_len(const char * txt);
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
208
lv_misc/lv_ufs.c
208
lv_misc/lv_ufs.c
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file ufs.c
|
||||
* @file lv_ufs.c
|
||||
* Implementation of RAM file system which do NOT support directories.
|
||||
* The API is compatible with the fs_int module.
|
||||
* The API is compatible with the lv_fs_int module.
|
||||
*/
|
||||
|
||||
/*********************
|
||||
@ -9,7 +9,6 @@
|
||||
*********************/
|
||||
|
||||
#include "misc_conf.h"
|
||||
#if USE_UFS != 0
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
@ -28,13 +27,13 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static ufs_ent_t* ufs_ent_get(const char * fn);
|
||||
static ufs_ent_t* ufs_ent_new(const char * fn);
|
||||
static lv_ufs_ent_t* lv_ufs_ent_get(const char * fn);
|
||||
static lv_ufs_ent_t* lv_ufs_ent_new(const char * fn);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static ll_dsc_t file_ll;
|
||||
static lv_ll_t file_ll;
|
||||
static bool inited = false;
|
||||
|
||||
/**********************
|
||||
@ -48,34 +47,34 @@ static bool inited = false;
|
||||
/**
|
||||
* Create a driver for ufs and initialize it.
|
||||
*/
|
||||
void ufs_init(void)
|
||||
void lv_ufs_init(void)
|
||||
{
|
||||
ll_init(&file_ll, sizeof(ufs_ent_t));
|
||||
lv_ll_init(&file_ll, sizeof(lv_ufs_ent_t));
|
||||
|
||||
fs_drv_t ufs_drv;
|
||||
memset(&ufs_drv, 0, sizeof(fs_drv_t)); /*Initialization*/
|
||||
lv_fs_drv_t ufs_drv;
|
||||
memset(&ufs_drv, 0, sizeof(lv_fs_drv_t)); /*Initialization*/
|
||||
|
||||
ufs_drv.file_size = sizeof(ufs_file_t);
|
||||
ufs_drv.rddir_size = sizeof(ufs_read_dir_t);
|
||||
ufs_drv.file_size = sizeof(lv_ufs_file_t);
|
||||
ufs_drv.rddir_size = sizeof(lv_ufs_dir_t);
|
||||
ufs_drv.letter = UFS_LETTER;
|
||||
ufs_drv.ready = ufs_ready;
|
||||
ufs_drv.ready = lv_ufs_ready;
|
||||
|
||||
ufs_drv.open = ufs_open;
|
||||
ufs_drv.close = ufs_close;
|
||||
ufs_drv.remove = ufs_remove;
|
||||
ufs_drv.read = ufs_read;
|
||||
ufs_drv.write = ufs_write;
|
||||
ufs_drv.seek = ufs_seek;
|
||||
ufs_drv.tell = ufs_tell;
|
||||
ufs_drv.size = ufs_size;
|
||||
ufs_drv.trunc = ufs_trunc;
|
||||
ufs_drv.free = ufs_free;
|
||||
ufs_drv.open = lv_ufs_open;
|
||||
ufs_drv.close = lv_ufs_close;
|
||||
ufs_drv.remove = lv_ufs_remove;
|
||||
ufs_drv.read = lv_ufs_read;
|
||||
ufs_drv.write = lv_ufs_write;
|
||||
ufs_drv.seek = lv_ufs_seek;
|
||||
ufs_drv.tell = lv_ufs_tell;
|
||||
ufs_drv.size = lv_ufs_size;
|
||||
ufs_drv.trunc = lv_ufs_trunc;
|
||||
ufs_drv.free = lv_ufs_free;
|
||||
|
||||
ufs_drv.rddir_init = ufs_readdir_init;
|
||||
ufs_drv.rddir = ufs_readdir;
|
||||
ufs_drv.rddir_close = ufs_readdir_close;
|
||||
ufs_drv.rddir_init = lv_ufs_readdir_init;
|
||||
ufs_drv.rddir = lv_ufs_readdir;
|
||||
ufs_drv.rddir_close = lv_ufs_readdir_close;
|
||||
|
||||
fs_add_drv(&ufs_drv);
|
||||
lv_fs_add_drv(&ufs_drv);
|
||||
|
||||
inited = true;
|
||||
}
|
||||
@ -84,30 +83,30 @@ void ufs_init(void)
|
||||
* Give the state of the ufs
|
||||
* @return true if ufs is initialized and can be used else false
|
||||
*/
|
||||
bool ufs_ready(void)
|
||||
bool lv_ufs_ready(void)
|
||||
{
|
||||
return inited;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a file in ufs
|
||||
* @param file_p pointer to a ufs_file_t variable
|
||||
* @param file_p pointer to a lv_ufs_file_t variable
|
||||
* @param fn name of the file. There are no directories so e.g. "myfile.txt"
|
||||
* @param mode element of 'fs_mode_t' enum or its 'OR' connection (e.g. FS_MODE_WR | FS_MODE_RD)
|
||||
* @return FS_RES_OK: no error, the file is opened
|
||||
* any error from fs_res_t enum
|
||||
* any error from lv__fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_open (void * file_p, const char * fn, fs_mode_t mode)
|
||||
lv_fs_res_t lv_ufs_open (void * file_p, const char * fn, lv_fs_mode_t mode)
|
||||
{
|
||||
ufs_file_t * fp = file_p; /*Convert type*/
|
||||
ufs_ent_t* ent = ufs_ent_get(fn);
|
||||
lv_ufs_file_t * fp = file_p; /*Convert type*/
|
||||
lv_ufs_ent_t* ent = lv_ufs_ent_get(fn);
|
||||
|
||||
fp->ent = NULL;
|
||||
|
||||
/*If the file not exists ...*/
|
||||
if( ent == NULL) {
|
||||
if((mode & FS_MODE_WR) != 0) { /*Create the file if opened for write*/
|
||||
ent = ufs_ent_new(fn);
|
||||
ent = lv_ufs_ent_new(fn);
|
||||
if(ent == NULL) return FS_RES_FULL; /*No space for the new file*/
|
||||
} else {
|
||||
return FS_RES_NOT_EX; /*Can not read not existing file*/
|
||||
@ -137,26 +136,26 @@ fs_res_t ufs_open (void * file_p, const char * fn, fs_mode_t mode)
|
||||
* @param const_p pointer to a constant data
|
||||
* @param len length of the data pointed by 'const_p' in bytes
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
* any error from lv__fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_create_const(const char * fn, const void * const_p, uint32_t len)
|
||||
lv_fs_res_t lv_ufs_create_const(const char * fn, const void * const_p, uint32_t len)
|
||||
{
|
||||
ufs_file_t file;
|
||||
fs_res_t res;
|
||||
lv_ufs_file_t file;
|
||||
lv_fs_res_t res;
|
||||
|
||||
/*Error if the file already exists*/
|
||||
res = ufs_open(&file, fn, FS_MODE_RD);
|
||||
res = lv_ufs_open(&file, fn, FS_MODE_RD);
|
||||
if(res == FS_RES_OK) {
|
||||
ufs_close(&file);
|
||||
lv_ufs_close(&file);
|
||||
return FS_RES_DENIED;
|
||||
}
|
||||
|
||||
ufs_close(&file);
|
||||
lv_ufs_close(&file);
|
||||
|
||||
res = ufs_open(&file, fn, FS_MODE_WR);
|
||||
res = lv_ufs_open(&file, fn, FS_MODE_WR);
|
||||
if(res != FS_RES_OK) return res;
|
||||
|
||||
ufs_ent_t* ent = file.ent;
|
||||
lv_ufs_ent_t* ent = file.ent;
|
||||
|
||||
if(ent->data_d != NULL) return FS_RES_DENIED;
|
||||
|
||||
@ -164,7 +163,7 @@ fs_res_t ufs_create_const(const char * fn, const void * const_p, uint32_t len)
|
||||
ent->size = len;
|
||||
ent->const_data = 1;
|
||||
|
||||
res = ufs_close(&file);
|
||||
res = lv_ufs_close(&file);
|
||||
if(res != FS_RES_OK) return res;
|
||||
|
||||
return FS_RES_OK;
|
||||
@ -172,13 +171,13 @@ fs_res_t ufs_create_const(const char * fn, const void * const_p, uint32_t len)
|
||||
|
||||
/**
|
||||
* Close an opened file
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with ufs_open)
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with lv_ufs_open)
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
* any error from lv__fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_close (void * file_p)
|
||||
lv_fs_res_t lv_ufs_close (void * file_p)
|
||||
{
|
||||
ufs_file_t * fp = file_p; /*Convert type*/
|
||||
lv_ufs_file_t * fp = file_p; /*Convert type*/
|
||||
|
||||
if(fp->ent == NULL) return FS_RES_OK;
|
||||
|
||||
@ -196,14 +195,14 @@ fs_res_t ufs_close (void * file_p)
|
||||
* @return FS_RES_OK: no error, the file is removed
|
||||
* FS_RES_DENIED: the file was opened, remove failed
|
||||
*/
|
||||
fs_res_t ufs_remove(const char * fn)
|
||||
lv_fs_res_t lv_ufs_remove(const char * fn)
|
||||
{
|
||||
ufs_ent_t* ent = ufs_ent_get(fn);
|
||||
lv_ufs_ent_t* ent = lv_ufs_ent_get(fn);
|
||||
|
||||
/*Can not be deleted is opened*/
|
||||
if(ent->oc != 0) return FS_RES_DENIED;
|
||||
|
||||
ll_rem(&file_ll, ent);
|
||||
lv_ll_rem(&file_ll, ent);
|
||||
lv_mem_free(ent->fn_d);
|
||||
ent->fn_d = NULL;
|
||||
if(ent->const_data == 0){
|
||||
@ -218,18 +217,18 @@ fs_res_t ufs_remove(const char * fn)
|
||||
|
||||
/**
|
||||
* Read data from an opened file
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with ufs_open )
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with lv_ufs_open )
|
||||
* @param buf pointer to a memory block where to store the read data
|
||||
* @param btr number of Bytes To Read
|
||||
* @param br the real number of read bytes (Byte Read)
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
* any error from lv__fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_read (void * file_p, void * buf, uint32_t btr, uint32_t * br)
|
||||
lv_fs_res_t lv_ufs_read (void * file_p, void * buf, uint32_t btr, uint32_t * br)
|
||||
{
|
||||
ufs_file_t * fp = file_p; /*Convert type*/
|
||||
lv_ufs_file_t * fp = file_p; /*Convert type*/
|
||||
|
||||
ufs_ent_t* ent = fp->ent;
|
||||
lv_ufs_ent_t* ent = fp->ent;
|
||||
*br = 0;
|
||||
|
||||
if(ent->data_d == NULL || ent->size == 0) { /*Don't read empty files*/
|
||||
@ -263,21 +262,21 @@ fs_res_t ufs_read (void * file_p, void * buf, uint32_t btr, uint32_t * br)
|
||||
|
||||
/**
|
||||
* Write data to an opened file
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with ufs_open)
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with lv_ufs_open)
|
||||
* @param buf pointer to a memory block which content will be written
|
||||
* @param btw the number Bytes To Write
|
||||
* @param bw The real number of written bytes (Byte Written)
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
* any error from lv__fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_write (void * file_p, const void * buf, uint32_t btw, uint32_t * bw)
|
||||
lv_fs_res_t lv_ufs_write (void * file_p, const void * buf, uint32_t btw, uint32_t * bw)
|
||||
{
|
||||
ufs_file_t * fp = file_p; /*Convert type*/
|
||||
lv_ufs_file_t * fp = file_p; /*Convert type*/
|
||||
*bw = 0;
|
||||
|
||||
if(fp->aw == 0) return FS_RES_DENIED; /*Not opened for write*/
|
||||
|
||||
ufs_ent_t* ent = fp->ent;
|
||||
lv_ufs_ent_t* ent = fp->ent;
|
||||
|
||||
/*Reallocate data array if it necessary*/
|
||||
uint32_t new_size = fp->rwp + btw;
|
||||
@ -301,15 +300,15 @@ fs_res_t ufs_write (void * file_p, const void * buf, uint32_t btw, uint32_t * bw
|
||||
|
||||
/**
|
||||
* Set the read write pointer. Also expand the file size if necessary.
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with ufs_open )
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with lv_ufs_open )
|
||||
* @param pos the new position of read write pointer
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
* any error from lv__fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_seek (void * file_p, uint32_t pos)
|
||||
lv_fs_res_t lv_ufs_seek (void * file_p, uint32_t pos)
|
||||
{
|
||||
ufs_file_t * fp = file_p; /*Convert type*/
|
||||
ufs_ent_t* ent = fp->ent;
|
||||
lv_ufs_file_t * fp = file_p; /*Convert type*/
|
||||
lv_ufs_ent_t* ent = fp->ent;
|
||||
|
||||
/*Simply move the rwp before EOF*/
|
||||
if(pos < ent->size) {
|
||||
@ -330,14 +329,14 @@ fs_res_t ufs_seek (void * file_p, uint32_t pos)
|
||||
|
||||
/**
|
||||
* Give the position of the read write pointer
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with ufs_open )
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with lv_ufs_open )
|
||||
* @param pos_p pointer to to store the result
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
* any error from lv__fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_tell (void * file_p, uint32_t * pos_p)
|
||||
lv_fs_res_t lv_ufs_tell (void * file_p, uint32_t * pos_p)
|
||||
{
|
||||
ufs_file_t * fp = file_p; /*Convert type*/
|
||||
lv_ufs_file_t * fp = file_p; /*Convert type*/
|
||||
|
||||
*pos_p = fp->rwp;
|
||||
|
||||
@ -346,14 +345,14 @@ fs_res_t ufs_tell (void * file_p, uint32_t * pos_p)
|
||||
|
||||
/**
|
||||
* Truncate the file size to the current position of the read write pointer
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with ufs_open )
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with lv_ufs_open )
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
* any error from lv__fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_trunc (void * file_p)
|
||||
lv_fs_res_t lv_ufs_trunc (void * file_p)
|
||||
{
|
||||
ufs_file_t * fp = file_p; /*Convert type*/
|
||||
ufs_ent_t* ent = fp->ent;
|
||||
lv_ufs_file_t * fp = file_p; /*Convert type*/
|
||||
lv_ufs_ent_t* ent = fp->ent;
|
||||
|
||||
if(fp->aw == 0) return FS_RES_DENIED; /*Not opened for write*/
|
||||
|
||||
@ -368,15 +367,15 @@ fs_res_t ufs_trunc (void * file_p)
|
||||
|
||||
/**
|
||||
* Give the size of the file in bytes
|
||||
* @param file_p file_p pointer to an 'ufs_file_t' variable. (opened with ufs_open )
|
||||
* @param file_p file_p pointer to an 'ufs_file_t' variable. (opened with lv_ufs_open )
|
||||
* @param size_p pointer to store the size
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
* any error from lv__fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_size (void * file_p, uint32_t * size_p)
|
||||
lv_fs_res_t lv_ufs_size (void * file_p, uint32_t * size_p)
|
||||
{
|
||||
ufs_file_t * fp = file_p; /*Convert type*/
|
||||
ufs_ent_t* ent = fp->ent;
|
||||
lv_ufs_file_t * fp = file_p; /*Convert type*/
|
||||
lv_ufs_ent_t* ent = fp->ent;
|
||||
|
||||
*size_p = ent->size;
|
||||
|
||||
@ -384,16 +383,16 @@ fs_res_t ufs_size (void * file_p, uint32_t * size_p)
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a ufs_read_dir_t variable to directory reading
|
||||
* Initialize a lv_ufs_read_dir_t variable to directory reading
|
||||
* @param rddir_p pointer to a 'ufs_read_dir_t' variable
|
||||
* @param path uFS doesn't support folders so it has to be ""
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
* @return FS_RES_OK or any error from lv__fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_readdir_init(void * rddir_p, const char * path)
|
||||
lv_fs_res_t lv_ufs_readdir_init(void * rddir_p, const char * path)
|
||||
{
|
||||
ufs_read_dir_t * ufs_rddir_p = rddir_p;
|
||||
lv_ufs_dir_t * lv_ufs_rddir_p = rddir_p;
|
||||
|
||||
ufs_rddir_p->last_ent = NULL;
|
||||
lv_ufs_rddir_p->last_ent = NULL;
|
||||
|
||||
if(path[0] != '\0') return FS_RES_NOT_EX;
|
||||
else return FS_RES_OK;
|
||||
@ -401,22 +400,22 @@ fs_res_t ufs_readdir_init(void * rddir_p, const char * path)
|
||||
|
||||
/**
|
||||
* Read the next file name
|
||||
* @param rddir_p pointer to an initialized 'ufs_read_dir_t' variable
|
||||
* @param dir_p pointer to an initialized 'ufs_read_dir_t' variable
|
||||
* @param fn pointer to buffer to sore the file name
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
* @return FS_RES_OK or any error from lv__fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_readdir(void * rddir_p, char * fn)
|
||||
lv_fs_res_t lv_ufs_readdir(void * dir_p, char * fn)
|
||||
{
|
||||
ufs_read_dir_t * ufs_rddir_p = rddir_p;
|
||||
lv_ufs_dir_t * ufs_dir_p = dir_p;
|
||||
|
||||
if(ufs_rddir_p->last_ent == NULL) {
|
||||
ufs_rddir_p->last_ent = ll_get_head(&file_ll);
|
||||
if(ufs_dir_p->last_ent == NULL) {
|
||||
ufs_dir_p->last_ent = lv_ll_get_head(&file_ll);
|
||||
} else {
|
||||
ufs_rddir_p->last_ent = ll_get_next(&file_ll, ufs_rddir_p->last_ent);
|
||||
ufs_dir_p->last_ent = lv_ll_get_next(&file_ll, ufs_dir_p->last_ent);
|
||||
}
|
||||
|
||||
if(ufs_rddir_p->last_ent != NULL) {
|
||||
strcpy(fn, ufs_rddir_p->last_ent->fn_d);
|
||||
if(ufs_dir_p->last_ent != NULL) {
|
||||
strcpy(fn, ufs_dir_p->last_ent->fn_d);
|
||||
} else {
|
||||
fn[0] = '\0';
|
||||
}
|
||||
@ -427,9 +426,9 @@ fs_res_t ufs_readdir(void * rddir_p, char * fn)
|
||||
/**
|
||||
* Close the directory reading
|
||||
* @param rddir_p pointer to an initialized 'ufs_read_dir_t' variable
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
* @return FS_RES_OK or any error from lv__fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_readdir_close(void * rddir_p)
|
||||
lv_fs_res_t lv_ufs_readdir_close(void * rddir_p)
|
||||
{
|
||||
return FS_RES_OK;
|
||||
}
|
||||
@ -438,9 +437,9 @@ fs_res_t ufs_readdir_close(void * rddir_p)
|
||||
* Give the size of a drive
|
||||
* @param total_p pointer to store the total size [kB]
|
||||
* @param free_p pointer to store the free site [kB]
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
* @return FS_RES_OK or any error from 'lv_fs_res_t'
|
||||
*/
|
||||
fs_res_t ufs_free (uint32_t * total_p, uint32_t * free_p)
|
||||
lv_fs_res_t lv_ufs_free (uint32_t * total_p, uint32_t * free_p)
|
||||
{
|
||||
dm_mon_t mon;
|
||||
|
||||
@ -456,14 +455,14 @@ fs_res_t ufs_free (uint32_t * total_p, uint32_t * free_p)
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Gives the ufs_entry from a filename
|
||||
* Gives the lv_ufs_entry from a filename
|
||||
* @param fn filename ('\0' terminated string)
|
||||
* @return pointer to the dynamically allocated entry with 'fn' filename.
|
||||
* NULL if no entry found with that name.
|
||||
*/
|
||||
static ufs_ent_t* ufs_ent_get(const char * fn)
|
||||
static lv_ufs_ent_t* lv_ufs_ent_get(const char * fn)
|
||||
{
|
||||
ufs_ent_t* fp;
|
||||
lv_ufs_ent_t* fp;
|
||||
|
||||
LL_READ(file_ll, fp) {
|
||||
if(strcmp(fp->fn_d, fn) == 0) {
|
||||
@ -480,10 +479,10 @@ static ufs_ent_t* ufs_ent_get(const char * fn)
|
||||
* @return pointer to the dynamically allocated new entry.
|
||||
* NULL if no space for the entry.
|
||||
*/
|
||||
static ufs_ent_t* ufs_ent_new(const char * fn)
|
||||
static lv_ufs_ent_t* lv_ufs_ent_new(const char * fn)
|
||||
{
|
||||
ufs_ent_t* new_ent = NULL;
|
||||
new_ent = ll_ins_head(&file_ll); /*Create a new file*/
|
||||
lv_ufs_ent_t* new_ent = NULL;
|
||||
new_ent = lv_ll_ins_head(&file_ll); /*Create a new file*/
|
||||
if(new_ent == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@ -498,4 +497,3 @@ static ufs_ent_t* ufs_ent_new(const char * fn)
|
||||
return new_ent;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,11 +1,11 @@
|
||||
/**
|
||||
* @file ufs.h
|
||||
* @file lv_ufs.h
|
||||
* Implementation of RAM file system which do NOT support directories.
|
||||
* The API is compatible with the fs_int module.
|
||||
* The API is compatible with the lv_fs_int module.
|
||||
*/
|
||||
|
||||
#ifndef UFS_H
|
||||
#define UFS_H
|
||||
#ifndef LV_UFS_H
|
||||
#define LV_UFS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -16,7 +16,6 @@ extern "C" {
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "misc_conf.h"
|
||||
#if USE_UFS != 0
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "lv_fs.h"
|
||||
@ -37,24 +36,24 @@ typedef struct
|
||||
uint32_t size; /*Data length in bytes*/
|
||||
uint16_t oc; /*Open Count*/
|
||||
uint8_t const_data :1;
|
||||
}ufs_ent_t;
|
||||
}lv_ufs_ent_t;
|
||||
|
||||
/*File descriptor, used to handle opening an entry more times simultaneously
|
||||
Contains unique informations about the specific opening*/
|
||||
typedef struct
|
||||
{
|
||||
ufs_ent_t* ent; /*Pointer to the entry*/
|
||||
lv_ufs_ent_t* ent; /*Pointer to the entry*/
|
||||
uint32_t rwp; /*Read Write Pointer*/
|
||||
uint8_t ar :1; /*1: Access for read is enabled */
|
||||
uint8_t aw :1; /*1: Access for write is enabled */
|
||||
}ufs_file_t;
|
||||
}lv_ufs_file_t;
|
||||
|
||||
/* Read directory descriptor.
|
||||
* It is used to to iterate through the entries in a directory*/
|
||||
typedef struct
|
||||
{
|
||||
ufs_ent_t * last_ent;
|
||||
}ufs_read_dir_t;
|
||||
lv_ufs_ent_t * last_ent;
|
||||
}lv_ufs_dir_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
@ -63,23 +62,23 @@ typedef struct
|
||||
/**
|
||||
* Create a driver for ufs and initialize it.
|
||||
*/
|
||||
void ufs_init(void);
|
||||
void lv_ufs_init(void);
|
||||
|
||||
/**
|
||||
* Give the state of the ufs
|
||||
* @return true if ufs is initialized and can be used else false
|
||||
*/
|
||||
bool ufs_ready(void);
|
||||
bool lv_ufs_ready(void);
|
||||
|
||||
/**
|
||||
* Open a file in ufs
|
||||
* @param file_p pointer to a ufs_file_t variable
|
||||
* @param file_p pointer to a lv_ufs_file_t variable
|
||||
* @param fn name of the file. There are no directories so e.g. "myfile.txt"
|
||||
* @param mode element of 'fs_mode_t' enum or its 'OR' connection (e.g. FS_MODE_WR | FS_MODE_RD)
|
||||
* @return FS_RES_OK: no error, the file is opened
|
||||
* any error from fs_res_t enum
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_open (void * file_p, const char * fn, fs_mode_t mode);
|
||||
lv_fs_res_t lv_ufs_open (void * file_p, const char * fn, lv_fs_mode_t mode);
|
||||
|
||||
/**
|
||||
* Create a file with a constant data
|
||||
@ -87,17 +86,17 @@ fs_res_t ufs_open (void * file_p, const char * fn, fs_mode_t mode);
|
||||
* @param const_p pointer to a constant data
|
||||
* @param len length of the data pointed by 'const_p' in bytes
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_create_const(const char * fn, const void * const_p, uint32_t len);
|
||||
lv_fs_res_t lv_ufs_create_const(const char * fn, const void * const_p, uint32_t len);
|
||||
|
||||
/**
|
||||
* Close an opened file
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with ufs_open)
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with lv_ufs_open)
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_close (void * file_p);
|
||||
lv_fs_res_t lv_ufs_close (void * file_p);
|
||||
|
||||
/**
|
||||
* Remove a file. The file can not be opened.
|
||||
@ -105,87 +104,87 @@ fs_res_t ufs_close (void * file_p);
|
||||
* @return FS_RES_OK: no error, the file is removed
|
||||
* FS_RES_DENIED: the file was opened, remove failed
|
||||
*/
|
||||
fs_res_t ufs_remove(const char * fn);
|
||||
lv_fs_res_t lv_ufs_remove(const char * fn);
|
||||
|
||||
/**
|
||||
* Read data from an opened file
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with ufs_open )
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with lv_ufs_open )
|
||||
* @param buf pointer to a memory block where to store the read data
|
||||
* @param btr number of Bytes To Read
|
||||
* @param br the real number of read bytes (Byte Read)
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_read (void * file_p, void * buf, uint32_t btr, uint32_t * br);
|
||||
lv_fs_res_t lv_ufs_read (void * file_p, void * buf, uint32_t btr, uint32_t * br);
|
||||
|
||||
/**
|
||||
* Write data to an opened file
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with ufs_open)
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with lv_ufs_open)
|
||||
* @param buf pointer to a memory block which content will be written
|
||||
* @param btw the number Bytes To Write
|
||||
* @param bw The real number of written bytes (Byte Written)
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_write (void * file_p, const void * buf, uint32_t btw, uint32_t * bw);
|
||||
lv_fs_res_t lv_ufs_write (void * file_p, const void * buf, uint32_t btw, uint32_t * bw);
|
||||
|
||||
/**
|
||||
* Set the read write pointer. Also expand the file size if necessary.
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with ufs_open )
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with lv_ufs_open )
|
||||
* @param pos the new position of read write pointer
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_seek (void * file_p, uint32_t pos);
|
||||
lv_fs_res_t lv_ufs_seek (void * file_p, uint32_t pos);
|
||||
|
||||
/**
|
||||
* Give the position of the read write pointer
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with ufs_open )
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with lv_ufs_open )
|
||||
* @param pos_p pointer to to store the result
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_tell (void * file_p, uint32_t * pos_p);
|
||||
lv_fs_res_t lv_ufs_tell (void * file_p, uint32_t * pos_p);
|
||||
|
||||
/**
|
||||
* Truncate the file size to the current position of the read write pointer
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with ufs_open )
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with lv_ufs_open )
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_trunc (void * file_p);
|
||||
lv_fs_res_t lv_ufs_trunc (void * file_p);
|
||||
|
||||
/**
|
||||
* Give the size of the file in bytes
|
||||
* @param file_p file_p pointer to an 'ufs_file_t' variable. (opened with ufs_open )
|
||||
* @param file_p file_p pointer to an 'ufs_file_t' variable. (opened with lv_ufs_open )
|
||||
* @param size_p pointer to store the size
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_size (void * file_p, uint32_t * size_p);
|
||||
lv_fs_res_t lv_ufs_size (void * file_p, uint32_t * size_p);
|
||||
|
||||
/**
|
||||
* Initialize a ufs_read_dir_t variable to directory reading
|
||||
* Initialize a lv_ufs_read_dir_t variable to directory reading
|
||||
* @param rddir_p pointer to a 'ufs_read_dir_t' variable
|
||||
* @param path uFS doesn't support folders so it has to be ""
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
* @return FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_readdir_init(void * rddir_p, const char * path);
|
||||
lv_fs_res_t lv_ufs_readdir_init(void * rddir_p, const char * path);
|
||||
|
||||
/**
|
||||
* Read the next file name
|
||||
* @param rddir_p pointer to an initialized 'ufs_read_dir_t' variable
|
||||
* @param dir_p pointer to an initialized 'ufs_read_dir_t' variable
|
||||
* @param fn pointer to buffer to sore the file name
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
* @return FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_readdir(void * rddir_p, char * fn);
|
||||
lv_fs_res_t lv_ufs_readdir(void * dir_p, char * fn);
|
||||
|
||||
/**
|
||||
* Close the directory reading
|
||||
* @param rddir_p pointer to an initialized 'ufs_read_dir_t' variable
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
* @return FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_readdir_close(void * rddir_p);
|
||||
lv_fs_res_t lv_ufs_readdir_close(void * rddir_p);
|
||||
|
||||
/**
|
||||
* Give the size of a drive
|
||||
@ -193,14 +192,12 @@ fs_res_t ufs_readdir_close(void * rddir_p);
|
||||
* @param free_p pointer to store the free site [kB]
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t ufs_free (uint32_t * total_p, uint32_t * free_p);
|
||||
lv_fs_res_t lv_ufs_free (uint32_t * total_p, uint32_t * free_p);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
@ -42,7 +42,7 @@ static void style_mod_def(lv_style_t * style);
|
||||
lv_group_t * lv_group_create(void)
|
||||
{
|
||||
lv_group_t * group = lv_mem_alloc(sizeof(lv_group_t));
|
||||
ll_init(&group->obj_ll, sizeof(lv_obj_t *));
|
||||
lv_ll_init(&group->obj_ll, sizeof(lv_obj_t *));
|
||||
|
||||
group->style_mod = style_mod_def;
|
||||
group->obj_focus = NULL;
|
||||
@ -59,12 +59,12 @@ lv_group_t * lv_group_create(void)
|
||||
void lv_group_add_obj(lv_group_t * group, lv_obj_t * obj)
|
||||
{
|
||||
obj->group_p = group;
|
||||
lv_obj_t ** next = ll_ins_tail(&group->obj_ll);
|
||||
lv_obj_t ** next = lv_ll_ins_tail(&group->obj_ll);
|
||||
*next = obj;
|
||||
|
||||
/* If the head and the tail is equal then there is only one object in the linked list.
|
||||
* In this case automatically activate it*/
|
||||
if(ll_get_head(&group->obj_ll) == next) {
|
||||
if(lv_ll_get_head(&group->obj_ll) == next) {
|
||||
lv_group_focus_next(group);
|
||||
}
|
||||
}
|
||||
@ -81,7 +81,7 @@ void lv_group_remove_obj(lv_obj_t * obj)
|
||||
|
||||
LL_READ(g->obj_ll, i) {
|
||||
if(*i == obj) {
|
||||
ll_rem(&g->obj_ll, i);
|
||||
lv_ll_rem(&g->obj_ll, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -137,10 +137,10 @@ void lv_group_focus_next(lv_group_t * group)
|
||||
}
|
||||
|
||||
lv_obj_t ** obj_next;
|
||||
if(group->obj_focus == NULL) obj_next = ll_get_head(&group->obj_ll);
|
||||
else obj_next = ll_get_next(&group->obj_ll, group->obj_focus);
|
||||
if(group->obj_focus == NULL) obj_next = lv_ll_get_head(&group->obj_ll);
|
||||
else obj_next = lv_ll_get_next(&group->obj_ll, group->obj_focus);
|
||||
|
||||
if(obj_next == NULL) obj_next = ll_get_head(&group->obj_ll);
|
||||
if(obj_next == NULL) obj_next = lv_ll_get_head(&group->obj_ll);
|
||||
group->obj_focus = obj_next;
|
||||
|
||||
if(group->obj_focus){
|
||||
@ -163,10 +163,10 @@ void lv_group_focus_prev(lv_group_t * group)
|
||||
}
|
||||
|
||||
lv_obj_t ** obj_next;
|
||||
if(group->obj_focus == NULL) obj_next = ll_get_tail(&group->obj_ll);
|
||||
else obj_next = ll_get_prev(&group->obj_ll, group->obj_focus);
|
||||
if(group->obj_focus == NULL) obj_next = lv_ll_get_tail(&group->obj_ll);
|
||||
else obj_next = lv_ll_get_prev(&group->obj_ll, group->obj_focus);
|
||||
|
||||
if(obj_next == NULL) obj_next = ll_get_tail(&group->obj_ll);
|
||||
if(obj_next == NULL) obj_next = lv_ll_get_tail(&group->obj_ll);
|
||||
group->obj_focus = obj_next;
|
||||
|
||||
if(group->obj_focus != NULL){
|
||||
|
@ -36,7 +36,7 @@ extern "C" {
|
||||
**********************/
|
||||
typedef struct _lv_group_t
|
||||
{
|
||||
ll_dsc_t obj_ll;
|
||||
lv_ll_t obj_ll;
|
||||
lv_obj_t ** obj_focus;
|
||||
void (*style_mod)(lv_style_t * style);
|
||||
lv_style_t style_tmp;
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "../lv_hal/lv_hal_tick.h"
|
||||
#include "../lv_obj/lv_group.h"
|
||||
#include "../lv_misc/lv_task.h"
|
||||
#include "../misc/math/math_base.h"
|
||||
#include "../lv_misc/lv_math.h"
|
||||
#include "../lv_draw/lv_draw_rbasic.h"
|
||||
#include "lv_obj.h"
|
||||
|
||||
@ -38,7 +38,7 @@ static void indev_drag_throw(lv_indev_state_t * state);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static ptask_t *indev_proc_task_p;
|
||||
static lv_task_t *indev_proc_task_p;
|
||||
static lv_indev_t *indev_act;
|
||||
|
||||
/**********************
|
||||
@ -55,9 +55,9 @@ static lv_indev_t *indev_act;
|
||||
void lv_indev_init(void)
|
||||
{
|
||||
#if LV_INDEV_READ_PERIOD != 0
|
||||
indev_proc_task_p = ptask_create(indev_proc_task, LV_INDEV_READ_PERIOD, PTASK_PRIO_MID, NULL);
|
||||
indev_proc_task_p = lv_task_create(indev_proc_task, LV_INDEV_READ_PERIOD, LV_TASK_PRIO_MID, NULL);
|
||||
#else
|
||||
indev_proc_task_p = ptask_create(indev_proc_task, 1, PTASK_PRIO_OFF); /*Not use lv_indev_proc*/
|
||||
indev_proc_task_p = lv_task_create(indev_proc_task, 1, LV_TASK_PRIO_OFF); /*Not use lv_indev_proc*/
|
||||
#endif
|
||||
|
||||
lv_indev_reset(NULL); /*Reset all input devices*/
|
||||
@ -358,7 +358,7 @@ static void indev_proc_press(lv_indev_state_t * state)
|
||||
/*Move the last_top object to the foreground*/
|
||||
lv_obj_t * par = lv_obj_get_parent(last_top);
|
||||
/*After list change it will be the new head*/
|
||||
ll_chg_list(&par->child_ll, &par->child_ll, last_top);
|
||||
lv_ll_chg_list(&par->child_ll, &par->child_ll, last_top);
|
||||
lv_obj_invalidate(last_top);
|
||||
}
|
||||
|
||||
@ -506,8 +506,8 @@ static void indev_drag(lv_indev_state_t * state)
|
||||
state->drag_sum.y += state->vect.y;
|
||||
|
||||
/*If a move is greater then LV_DRAG_LIMIT then begin the drag*/
|
||||
if(MATH_ABS(state->drag_sum.x) >= LV_INDEV_DRAG_LIMIT ||
|
||||
MATH_ABS(state->drag_sum.y) >= LV_INDEV_DRAG_LIMIT)
|
||||
if(LV_MATH_ABS(state->drag_sum.x) >= LV_INDEV_DRAG_LIMIT ||
|
||||
LV_MATH_ABS(state->drag_sum.y) >= LV_INDEV_DRAG_LIMIT)
|
||||
{
|
||||
state->drag_range_out = 1;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ static lv_obj_t * def_scr = NULL;
|
||||
static lv_obj_t * act_scr = NULL;
|
||||
static lv_obj_t * top_layer = NULL;
|
||||
static lv_obj_t * sys_layer = NULL;
|
||||
static ll_dsc_t scr_ll; /*Linked list of screens*/
|
||||
static lv_ll_t scr_ll; /*Linked list of screens*/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -68,16 +68,16 @@ void lv_init(void)
|
||||
lv_mem_init();
|
||||
#endif
|
||||
|
||||
#if USE_PTASK != 0
|
||||
ptask_init();
|
||||
#if USE_LV_TASK != 0
|
||||
lv_task_init();
|
||||
#endif
|
||||
|
||||
#if USE_FSINT != 0 /*Init is befor other FS inits*/
|
||||
fs_init();
|
||||
lv_fs_init();
|
||||
#endif
|
||||
|
||||
#if USE_UFS != 0
|
||||
ufs_init();
|
||||
lv_ufs_init();
|
||||
#endif
|
||||
|
||||
#if USE_FONT != 0
|
||||
@ -100,7 +100,7 @@ void lv_init(void)
|
||||
lv_refr_init();
|
||||
|
||||
/*Create the default screen*/
|
||||
ll_init(&scr_ll, sizeof(lv_obj_t));
|
||||
lv_ll_init(&scr_ll, sizeof(lv_obj_t));
|
||||
def_scr = lv_obj_create(NULL, NULL);
|
||||
|
||||
act_scr = def_scr;
|
||||
@ -142,10 +142,10 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
|
||||
lv_obj_t * new_obj = NULL;
|
||||
/*Create a screen if the parent is NULL*/
|
||||
if(parent == NULL) {
|
||||
new_obj = ll_ins_head(&scr_ll);
|
||||
new_obj = lv_ll_ins_head(&scr_ll);
|
||||
|
||||
new_obj->par = NULL; /*Screens has no a parent*/
|
||||
ll_init(&(new_obj->child_ll), sizeof(lv_obj_t));
|
||||
lv_ll_init(&(new_obj->child_ll), sizeof(lv_obj_t));
|
||||
|
||||
/*Set coordinates to full screen size*/
|
||||
new_obj->coords.x1 = 0;
|
||||
@ -187,10 +187,10 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
|
||||
/*parent != NULL create normal obj. on a parent*/
|
||||
else
|
||||
{
|
||||
new_obj = ll_ins_head(&(parent)->child_ll);
|
||||
new_obj = lv_ll_ins_head(&(parent)->child_ll);
|
||||
|
||||
new_obj->par = parent; /*Set the parent*/
|
||||
ll_init(&(new_obj->child_ll), sizeof(lv_obj_t));
|
||||
lv_ll_init(&(new_obj->child_ll), sizeof(lv_obj_t));
|
||||
|
||||
/*Set coordinates left top corner of parent*/
|
||||
new_obj->coords.x1 = parent->coords.x1;
|
||||
@ -287,10 +287,10 @@ lv_res_t lv_obj_del(lv_obj_t * obj)
|
||||
/*Recursively delete the children*/
|
||||
lv_obj_t * i;
|
||||
lv_obj_t * i_next;
|
||||
i = ll_get_head(&(obj->child_ll));
|
||||
i = lv_ll_get_head(&(obj->child_ll));
|
||||
while(i != NULL) {
|
||||
/*Get the next object before delete this*/
|
||||
i_next = ll_get_next(&(obj->child_ll), i);
|
||||
i_next = lv_ll_get_next(&(obj->child_ll), i);
|
||||
|
||||
/*Call the recursive del to the child too*/
|
||||
delete_children(i);
|
||||
@ -305,9 +305,9 @@ lv_res_t lv_obj_del(lv_obj_t * obj)
|
||||
/*Remove the object from parent's children list*/
|
||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||
if(par == NULL) { /*It is a screen*/
|
||||
ll_rem(&scr_ll, obj);
|
||||
lv_ll_rem(&scr_ll, obj);
|
||||
} else {
|
||||
ll_rem(&(par->child_ll), obj);
|
||||
lv_ll_rem(&(par->child_ll), obj);
|
||||
}
|
||||
|
||||
/* All children deleted.
|
||||
@ -432,7 +432,7 @@ void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent)
|
||||
|
||||
lv_obj_t * old_par = obj->par;
|
||||
|
||||
ll_chg_list(&obj->par->child_ll, &parent->child_ll, obj);
|
||||
lv_ll_chg_list(&obj->par->child_ll, &parent->child_ll, obj);
|
||||
obj->par = parent;
|
||||
lv_obj_set_pos(obj, old_pos.x, old_pos.y);
|
||||
|
||||
@ -1084,9 +1084,9 @@ lv_obj_t * lv_obj_get_parent(lv_obj_t * obj)
|
||||
lv_obj_t * lv_obj_get_child(lv_obj_t * obj, lv_obj_t * child)
|
||||
{
|
||||
if(child == NULL) {
|
||||
return ll_get_head(&obj->child_ll);
|
||||
return lv_ll_get_head(&obj->child_ll);
|
||||
} else {
|
||||
return ll_get_next(&obj->child_ll, child);
|
||||
return lv_ll_get_next(&obj->child_ll, child);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@ -1102,9 +1102,9 @@ lv_obj_t * lv_obj_get_child(lv_obj_t * obj, lv_obj_t * child)
|
||||
lv_obj_t * lv_obj_get_child_back(lv_obj_t * obj, lv_obj_t * child)
|
||||
{
|
||||
if(child == NULL) {
|
||||
return ll_get_tail(&obj->child_ll);
|
||||
return lv_ll_get_tail(&obj->child_ll);
|
||||
} else {
|
||||
return ll_get_prev(&obj->child_ll, child);
|
||||
return lv_ll_get_prev(&obj->child_ll, child);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@ -1535,10 +1535,10 @@ static void delete_children(lv_obj_t * obj)
|
||||
{
|
||||
lv_obj_t * i;
|
||||
lv_obj_t * i_next;
|
||||
i = ll_get_head(&(obj->child_ll));
|
||||
i = lv_ll_get_head(&(obj->child_ll));
|
||||
while(i != NULL) {
|
||||
/*Get the next object before delete this*/
|
||||
i_next = ll_get_next(&(obj->child_ll), i);
|
||||
i_next = lv_ll_get_next(&(obj->child_ll), i);
|
||||
|
||||
/*Call the recursive del to the child too*/
|
||||
delete_children(i);
|
||||
@ -1557,7 +1557,7 @@ static void delete_children(lv_obj_t * obj)
|
||||
|
||||
/*Remove the object from parent's children list*/
|
||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||
ll_rem(&(par->child_ll), obj);
|
||||
lv_ll_rem(&(par->child_ll), obj);
|
||||
|
||||
/* Clean up the object specific data*/
|
||||
obj->signal_func(obj, LV_SIGNAL_CLEANUP, NULL);
|
||||
|
@ -102,7 +102,7 @@ typedef lv_res_t (* lv_signal_func_t) (struct _lv_obj_t * obj, lv_signal_t sign,
|
||||
typedef struct _lv_obj_t
|
||||
{
|
||||
struct _lv_obj_t * par; /*Pointer to the parent object*/
|
||||
ll_dsc_t child_ll; /*Linked list to store the children objects*/
|
||||
lv_ll_t child_ll; /*Linked list to store the children objects*/
|
||||
|
||||
lv_area_t coords; /*Coordinates of the object (x1, y1, x2, y2)*/
|
||||
|
||||
|
@ -67,8 +67,8 @@ void lv_refr_init(void)
|
||||
inv_buf_p = 0;
|
||||
memset(inv_buf, 0, sizeof(inv_buf));
|
||||
|
||||
ptask_t* task;
|
||||
task = ptask_create(lv_refr_task, LV_REFR_PERIOD, PTASK_PRIO_MID, NULL);
|
||||
lv_task_t* task;
|
||||
task = lv_task_create(lv_refr_task, LV_REFR_PERIOD, LV_TASK_PRIO_MID, NULL);
|
||||
dm_assert(task);
|
||||
}
|
||||
|
||||
@ -387,12 +387,12 @@ static void lv_refr_make(lv_obj_t * top_p, const lv_area_t * mask_p)
|
||||
/*Do until not reach the screen*/
|
||||
while(par != NULL) {
|
||||
/*object before border_p has to be redrawn*/
|
||||
i = ll_get_prev(&(par->child_ll), border_p);
|
||||
i = lv_ll_get_prev(&(par->child_ll), border_p);
|
||||
|
||||
while(i != NULL) {
|
||||
/*Refresh the objects*/
|
||||
lv_refr_obj(i, mask_p);
|
||||
i = ll_get_prev(&(par->child_ll), i);
|
||||
i = lv_ll_get_prev(&(par->child_ll), i);
|
||||
}
|
||||
|
||||
/*The new border will be there last parents,
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_obj/lv_refr.h"
|
||||
#include "../lv_themes/lv_theme.h"
|
||||
#include "../lv_misc/lv_text.h"
|
||||
#include <lvgl/lv_misc/lv_txt.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@ -435,9 +435,9 @@ static bool lv_btnm_design(lv_obj_t * btnm, const lv_area_t * mask, lv_design_mo
|
||||
/*Calculate the size of the text*/
|
||||
const lv_font_t * font = btn_style->text.font;
|
||||
lv_point_t txt_size;
|
||||
txt_get_size(&txt_size, ext->map_p[txt_i], font,
|
||||
lv_txt_get_size(&txt_size, ext->map_p[txt_i], font,
|
||||
btn_style->text.letter_space, btn_style->text.line_space,
|
||||
area_get_width(&area_btnm), TXT_FLAG_NONE);
|
||||
area_get_width(&area_btnm), LV_TXT_FLAG_NONE);
|
||||
|
||||
area_tmp.x1 += (btn_w - txt_size.x) / 2;
|
||||
area_tmp.y1 += (btn_h - txt_size.y) / 2;
|
||||
@ -446,7 +446,7 @@ static bool lv_btnm_design(lv_obj_t * btnm, const lv_area_t * mask, lv_design_mo
|
||||
|
||||
|
||||
if(btn_style->glass) btn_style = bg_style;
|
||||
lv_draw_label(&area_tmp, mask, btn_style, ext->map_p[txt_i], TXT_FLAG_NONE, NULL);
|
||||
lv_draw_label(&area_tmp, mask, btn_style, ext->map_p[txt_i], LV_TXT_FLAG_NONE, NULL);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -65,7 +65,7 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
/*Allocate the object type specific extended data*/
|
||||
lv_chart_ext_t * ext = lv_obj_allocate_ext_attr(new_chart, sizeof(lv_chart_ext_t));
|
||||
dm_assert(ext);
|
||||
ll_init(&ext->series_ll, sizeof(lv_chart_series_t));
|
||||
lv_ll_init(&ext->series_ll, sizeof(lv_chart_series_t));
|
||||
ext->series.num = 0;
|
||||
ext->ymin = LV_CHART_YMIN_DEF;
|
||||
ext->ymax = LV_CHART_YMAX_DEF;
|
||||
@ -125,7 +125,7 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
lv_chart_series_t *ser = ll_ins_head(&ext->series_ll);
|
||||
lv_chart_series_t *ser = lv_ll_ins_head(&ext->series_ll);
|
||||
lv_coord_t def = (ext->ymin + ext->ymax) >> 1; /*half range as default value*/
|
||||
|
||||
if(ser == NULL) return NULL;
|
||||
@ -405,7 +405,7 @@ static lv_res_t lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param
|
||||
LL_READ(ext->series_ll, datal) {
|
||||
lv_mem_free(*datal);
|
||||
}
|
||||
ll_clear(&ext->series_ll);
|
||||
lv_ll_clear(&ext->series_ll);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
@ -37,7 +37,7 @@ typedef struct
|
||||
{
|
||||
/*No inherited ext*/ /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
ll_dsc_t series_ll; /*Linked list for the data line pointers (stores lv_chart_dl_t)*/
|
||||
lv_ll_t series_ll; /*Linked list for the data line pointers (stores lv_chart_dl_t)*/
|
||||
lv_coord_t ymin; /*y min value (used to scale the data)*/
|
||||
lv_coord_t ymax; /*y max value (used to scale the data)*/
|
||||
uint8_t hdiv_cnt; /*Number of horizontal division lines*/
|
||||
|
@ -392,7 +392,7 @@ static void lv_cont_layout_pretty(lv_obj_t * cont)
|
||||
/* Disable child change action because the children will be moved a lot
|
||||
* an unnecessary child change signals could be sent*/
|
||||
|
||||
child_rs = ll_get_tail(&cont->child_ll); /*Set the row starter child*/
|
||||
child_rs = lv_ll_get_tail(&cont->child_ll); /*Set the row starter child*/
|
||||
if(child_rs == NULL) return; /*Return if no child*/
|
||||
|
||||
lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
@ -411,17 +411,17 @@ static void lv_cont_layout_pretty(lv_obj_t * cont)
|
||||
if(w_row + lv_obj_get_width(child_rc) > w_obj) {
|
||||
/*Step back one child because the last already not fit, so the previous is the closer*/
|
||||
if(child_rc != NULL && obj_num != 0 ) {
|
||||
child_rc = ll_get_next(&cont->child_ll, child_rc);
|
||||
child_rc = lv_ll_get_next(&cont->child_ll, child_rc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
w_row += lv_obj_get_width(child_rc) + style->body.padding.inner; /*Add the object width + opad*/
|
||||
h_row = MATH_MAX(h_row, lv_obj_get_height(child_rc)); /*Search the highest object*/
|
||||
h_row = LV_MATH_MAX(h_row, lv_obj_get_height(child_rc)); /*Search the highest object*/
|
||||
obj_num ++;
|
||||
if(lv_obj_is_protected(child_rc, LV_PROTECT_FOLLOW)) break; /*If can not be followed by an other object then break here*/
|
||||
|
||||
}
|
||||
child_rc = ll_get_prev(&cont->child_ll, child_rc); /*Load the next object*/
|
||||
child_rc = lv_ll_get_prev(&cont->child_ll, child_rc); /*Load the next object*/
|
||||
if(obj_num == 0) child_rs = child_rc; /*If the first object was hidden (or too long) then set the next as first */
|
||||
}while(child_rc != NULL);
|
||||
|
||||
@ -439,7 +439,7 @@ static void lv_cont_layout_pretty(lv_obj_t * cont)
|
||||
/*If are two object in the row then align them proportionally*/
|
||||
else if (obj_num == 2) {
|
||||
lv_obj_t * obj1 = child_rs;
|
||||
lv_obj_t * obj2 = ll_get_prev(&cont->child_ll, child_rs);
|
||||
lv_obj_t * obj2 = lv_ll_get_prev(&cont->child_ll, child_rs);
|
||||
w_row = lv_obj_get_width(obj1) + lv_obj_get_width(obj2);
|
||||
lv_coord_t pad = (w_obj - w_row) / 3;
|
||||
lv_obj_align(obj1, cont, LV_ALIGN_IN_TOP_LEFT, pad, act_y);
|
||||
@ -458,14 +458,14 @@ static void lv_cont_layout_pretty(lv_obj_t * cont)
|
||||
act_x += lv_obj_get_width(child_tmp) + new_opad;
|
||||
}
|
||||
if(child_tmp == child_rc) break;
|
||||
child_tmp = ll_get_prev(&cont->child_ll, child_tmp);
|
||||
child_tmp = lv_ll_get_prev(&cont->child_ll, child_tmp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(child_rc == NULL) break;
|
||||
act_y += style->body.padding.inner + h_row; /*y increment*/
|
||||
child_rs = ll_get_prev(&cont->child_ll, child_rc); /*Go to the next object*/
|
||||
child_rs = lv_ll_get_prev(&cont->child_ll, child_rc); /*Go to the next object*/
|
||||
child_rc = child_rs;
|
||||
}
|
||||
lv_obj_clear_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
@ -552,10 +552,10 @@ static void lv_cont_refr_autofit(lv_obj_t * cont)
|
||||
|
||||
LL_READ(cont->child_ll, i) {
|
||||
if(lv_obj_get_hidden(i) != false) continue;
|
||||
new_cords.x1 = MATH_MIN(new_cords.x1, i->coords.x1);
|
||||
new_cords.y1 = MATH_MIN(new_cords.y1, i->coords.y1);
|
||||
new_cords.x2 = MATH_MAX(new_cords.x2, i->coords.x2);
|
||||
new_cords.y2 = MATH_MAX(new_cords.y2, i->coords.y2);
|
||||
new_cords.x1 = LV_MATH_MIN(new_cords.x1, i->coords.x1);
|
||||
new_cords.y1 = LV_MATH_MIN(new_cords.y1, i->coords.y1);
|
||||
new_cords.x2 = LV_MATH_MAX(new_cords.x2, i->coords.x2);
|
||||
new_cords.y2 = LV_MATH_MAX(new_cords.y2, i->coords.y2);
|
||||
}
|
||||
|
||||
/*If the value is not the init value then the page has >=1 child.*/
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "lv_gauge.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_themes/lv_theme.h"
|
||||
#include "../lv_misc/lv_text.h"
|
||||
#include <lvgl/lv_misc/lv_txt.h>
|
||||
#include "../lv_misc/lv_trigo.h"
|
||||
#include "../lv_misc/lv_math.h"
|
||||
#include <stdio.h>
|
||||
@ -338,10 +338,10 @@ static void lv_gauge_draw_scale(lv_obj_t * gauge, const lv_area_t * mask)
|
||||
/*Calculate the position a scale label*/
|
||||
int16_t angle = (i * scale_angle) / (label_num - 1) + angle_ofs;
|
||||
|
||||
lv_coord_t y = (int32_t)((int32_t)trigo_sin(angle) * r) / TRIGO_SIN_MAX;
|
||||
lv_coord_t y = (int32_t)((int32_t)lv_trigo_sin(angle) * r) / TRIGO_SIN_MAX;
|
||||
y += y_ofs;
|
||||
|
||||
lv_coord_t x = (int32_t)((int32_t)trigo_sin(angle + 90) * r) / TRIGO_SIN_MAX;
|
||||
lv_coord_t x = (int32_t)((int32_t)lv_trigo_sin(angle + 90) * r) / TRIGO_SIN_MAX;
|
||||
x += x_ofs;
|
||||
|
||||
int16_t scale_act = (int32_t)((int32_t)(max - min) * i) / (label_num - 1);
|
||||
@ -350,9 +350,8 @@ static void lv_gauge_draw_scale(lv_obj_t * gauge, const lv_area_t * mask)
|
||||
|
||||
lv_area_t label_cord;
|
||||
lv_point_t label_size;
|
||||
txt_get_size(&label_size, scale_txt, style->text.font,
|
||||
style->text.letter_space, style->text.line_space,
|
||||
LV_COORD_MAX, TXT_FLAG_NONE);
|
||||
lv_txt_get_size(&label_size, scale_txt, style->text.font,
|
||||
style->text.letter_space, style->text.line_space, LV_COORD_MAX, LV_TXT_FLAG_NONE);
|
||||
|
||||
/*Draw the label*/
|
||||
label_cord.x1 = x - label_size.x / 2;
|
||||
@ -360,7 +359,7 @@ static void lv_gauge_draw_scale(lv_obj_t * gauge, const lv_area_t * mask)
|
||||
label_cord.x2 = label_cord.x1 + label_size.x;
|
||||
label_cord.y2 = label_cord.y1 + label_size.y;
|
||||
|
||||
lv_draw_label(&label_cord, mask, style, scale_txt, TXT_FLAG_NONE, NULL);
|
||||
lv_draw_label(&label_cord, mask, style, scale_txt, LV_TXT_FLAG_NONE, NULL);
|
||||
}
|
||||
}
|
||||
/**
|
||||
@ -392,8 +391,8 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * mask)
|
||||
for(i = 0; i < ext->needle_count; i++) {
|
||||
/*Calculate the end point of a needle*/
|
||||
int16_t needle_angle = (ext->values[i] - min) * angle / (max - min) + angle_ofs;
|
||||
p_end.y = (trigo_sin(needle_angle) * r) / TRIGO_SIN_MAX + y_ofs;
|
||||
p_end.x = (trigo_sin(needle_angle + 90) * r) / TRIGO_SIN_MAX + x_ofs;
|
||||
p_end.y = (lv_trigo_sin(needle_angle) * r) / TRIGO_SIN_MAX + y_ofs;
|
||||
p_end.x = (lv_trigo_sin(needle_angle + 90) * r) / TRIGO_SIN_MAX + x_ofs;
|
||||
|
||||
/*Draw the needle with the corresponding color*/
|
||||
if(ext->needle_colors == NULL) style_needle.line.color = LV_GAUGE_DEF_NEEDLE_COLOR;
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "../lv_themes/lv_theme.h"
|
||||
#include "../lv_misc/lv_fs.h"
|
||||
#include "../lv_misc/lv_ufs.h"
|
||||
#include "../lv_misc/lv_text.h"
|
||||
#include <lvgl/lv_misc/lv_txt.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@ -99,14 +99,14 @@ lv_obj_t * lv_img_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
* Create a file to the RAMFS from a picture data
|
||||
* @param fn file name of the new file (e.g. "pic1", will be available at "U:/pic1")
|
||||
* @param data pointer to a color map with lv_img_raw_header_t header
|
||||
* @return result of the file operation. FS_RES_OK or any error from fs_res_t
|
||||
* @return result of the file operation. FS_RES_OK or any error from lv_fs_res_t
|
||||
*/
|
||||
fs_res_t lv_img_create_file(const char * fn, const color_int_t * data)
|
||||
lv_fs_res_t lv_img_create_file(const char * fn, const color_int_t * data)
|
||||
{
|
||||
#if USE_UFS != 0
|
||||
const lv_img_raw_header_t * raw_p = (lv_img_raw_header_t *) data;
|
||||
fs_res_t res;
|
||||
res = ufs_create_const(fn, data, raw_p->w * raw_p->h * sizeof(lv_color_t) + sizeof(lv_img_raw_header_t));
|
||||
lv_fs_res_t res;
|
||||
res = lv_ufs_create_const(fn, data, raw_p->w * raw_p->h * sizeof(lv_color_t) + sizeof(lv_img_raw_header_t));
|
||||
|
||||
return res;
|
||||
#else
|
||||
@ -129,13 +129,13 @@ void lv_img_set_file(lv_obj_t * img, const char * fn)
|
||||
|
||||
/*Handle normal images*/
|
||||
if(lv_img_is_symbol(fn) == false) {
|
||||
fs_file_t file;
|
||||
fs_res_t res;
|
||||
lv_fs_file_t file;
|
||||
lv_fs_res_t res;
|
||||
lv_img_raw_header_t header;
|
||||
uint32_t rn;
|
||||
res = fs_open(&file, fn, FS_MODE_RD);
|
||||
res = lv_fs_open(&file, fn, FS_MODE_RD);
|
||||
if(res == FS_RES_OK) {
|
||||
res = fs_read(&file, &header, sizeof(header), &rn);
|
||||
res = lv_fs_read(&file, &header, sizeof(header), &rn);
|
||||
}
|
||||
|
||||
/*Create a dummy header on fs error*/
|
||||
@ -146,7 +146,7 @@ void lv_img_set_file(lv_obj_t * img, const char * fn)
|
||||
header.cd = 0;
|
||||
}
|
||||
|
||||
fs_close(&file);
|
||||
lv_fs_close(&file);
|
||||
|
||||
ext->w = header.w;
|
||||
ext->h = header.h;
|
||||
@ -163,7 +163,7 @@ void lv_img_set_file(lv_obj_t * img, const char * fn)
|
||||
else {
|
||||
lv_style_t * style = lv_obj_get_style(img);
|
||||
lv_point_t size;
|
||||
txt_get_size(&size, fn, style->text.font, style->text.letter_space, style->text.line_space, LV_COORD_MAX, TXT_FLAG_NONE);
|
||||
lv_txt_get_size(&size, fn, style->text.font, style->text.letter_space, style->text.line_space, LV_COORD_MAX, LV_TXT_FLAG_NONE);
|
||||
ext->w = size.x;
|
||||
ext->h = size.y;
|
||||
ext->transp = 1; /*Symbols always have transparent parts*/
|
||||
@ -300,7 +300,7 @@ static bool lv_img_design(lv_obj_t * img, const lv_area_t * mask, lv_design_mode
|
||||
cords_tmp.x2 = cords.x1 + ext->w - 1;
|
||||
for(; cords_tmp.x1 < cords.x2; cords_tmp.x1 += ext->w, cords_tmp.x2 += ext->w) {
|
||||
if(sym == false) lv_draw_img(&cords_tmp, mask, style, ext->fn);
|
||||
else lv_draw_label(&cords_tmp, mask, style, ext->fn, TXT_FLAG_NONE, NULL);
|
||||
else lv_draw_label(&cords_tmp, mask, style, ext->fn, LV_TXT_FLAG_NONE, NULL);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -65,9 +65,9 @@ lv_obj_t * lv_img_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
* Create a file to the RAMFS from a picture data
|
||||
* @param fn file name of the new file (e.g. "pic1", will be available at "U:/pic1")
|
||||
* @param data pointer to a color map with lv_img_raw_header_t header
|
||||
* @return result of the file operation. FS_RES_OK or any error from fs_res_t
|
||||
* @return result of the file operation. FS_RES_OK or any error from lv_fs_res_t
|
||||
*/
|
||||
fs_res_t lv_img_create_file(const char * fn, const color_int_t * data);
|
||||
lv_fs_res_t lv_img_create_file(const char * fn, const color_int_t * data);
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
|
@ -14,9 +14,9 @@
|
||||
#include "../lv_obj/lv_group.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_misc/lv_color.h"
|
||||
#include "../lv_misc/lv_text.h"
|
||||
#include <lvgl/lv_misc/lv_txt.h>
|
||||
#include "../lv_misc/lv_math.h"
|
||||
#include "../lv_misc/lv_text.h"
|
||||
#include <lvgl/lv_misc/lv_txt.h>
|
||||
#include "../lv_misc/lv_anim.h"
|
||||
|
||||
/*********************
|
||||
@ -109,8 +109,8 @@ lv_obj_t * lv_label_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
|
||||
/*In DOT mode save the text byte-to-byte because a '\0' can be in the middle*/
|
||||
if(copy_ext->long_mode == LV_LABEL_LONG_DOT) {
|
||||
ext->text = lv_mem_realloc(ext->text, dm_get_size(copy_ext->text));
|
||||
memcpy(ext->text, copy_ext->text, dm_get_size(copy_ext->text));
|
||||
ext->text = lv_mem_realloc(ext->text, lv_mem_get_size(copy_ext->text));
|
||||
memcpy(ext->text, copy_ext->text, lv_mem_get_size(copy_ext->text));
|
||||
}
|
||||
|
||||
memcpy(ext->dot_tmp, copy_ext->dot_tmp, sizeof(ext->dot_tmp));
|
||||
@ -409,12 +409,12 @@ void lv_label_get_letter_pos(lv_obj_t * label, uint16_t index, lv_point_t * pos)
|
||||
const lv_font_t * font = style->text.font;
|
||||
uint8_t letter_height = lv_font_get_height_scale(font);
|
||||
lv_coord_t y = 0;
|
||||
txt_flag_t flag = TXT_FLAG_NONE;
|
||||
lv_txt_flag_t flag = LV_TXT_FLAG_NONE;
|
||||
|
||||
if(ext->recolor != 0) flag |= TXT_FLAG_RECOLOR;
|
||||
if(ext->expand != 0) flag |= TXT_FLAG_EXPAND;
|
||||
if(ext->no_break != 0) flag |= TXT_FLAG_NO_BREAK;
|
||||
if(ext->align == LV_LABEL_ALIGN_CENTER) flag |= TXT_FLAG_CENTER;
|
||||
if(ext->recolor != 0) flag |= LV_TXT_FLAG_RECOLOR;
|
||||
if(ext->expand != 0) flag |= LV_TXT_FLAG_EXPAND;
|
||||
if(ext->no_break != 0) flag |= LV_TXT_FLAG_NO_BREAK;
|
||||
if(ext->align == LV_LABEL_ALIGN_CENTER) flag |= LV_TXT_FLAG_CENTER;
|
||||
|
||||
/*If the width will be expanded the set the max length to very big */
|
||||
if(ext->long_mode == LV_LABEL_LONG_EXPAND || ext->long_mode == LV_LABEL_LONG_SCROLL) {
|
||||
@ -425,7 +425,7 @@ void lv_label_get_letter_pos(lv_obj_t * label, uint16_t index, lv_point_t * pos)
|
||||
|
||||
/*Search the line of the index letter */;
|
||||
while (txt[new_line_start] != '\0') {
|
||||
new_line_start += txt_get_next_line(&txt[line_start], font, style->text.letter_space, max_w, flag);
|
||||
new_line_start += lv_txt_get_next_line(&txt[line_start], font, style->text.letter_space, max_w, flag);
|
||||
if(index < new_line_start || txt[new_line_start] == '\0') break; /*The line of 'index' letter begins at 'line_start'*/
|
||||
|
||||
y += letter_height + style->text.line_space;
|
||||
@ -442,14 +442,14 @@ void lv_label_get_letter_pos(lv_obj_t * label, uint16_t index, lv_point_t * pos)
|
||||
lv_coord_t x = 0;
|
||||
uint32_t i = line_start;
|
||||
uint32_t cnt = line_start; /*Count the letter (in UTF-8 1 letter not 1 byte)*/
|
||||
txt_cmd_state_t cmd_state = TXT_CMD_STATE_WAIT;
|
||||
lv_txt_cmd_state_t cmd_state = LV_TXT_CMD_STATE_WAIT;
|
||||
uint32_t letter;
|
||||
while(cnt < index) {
|
||||
cnt += txt_utf8_size(txt[i]);
|
||||
letter = txt_utf8_next(txt, &i);
|
||||
cnt += lv_txt_utf8_size(txt[i]);
|
||||
letter = lv_txt_utf8_next(txt, &i);
|
||||
/*Handle the recolor command*/
|
||||
if((flag & TXT_FLAG_RECOLOR) != 0) {
|
||||
if(txt_is_cmd(&cmd_state, txt[i]) != false) {
|
||||
if((flag & LV_TXT_FLAG_RECOLOR) != 0) {
|
||||
if(lv_txt_is_cmd(&cmd_state, txt[i]) != false) {
|
||||
continue; /*Skip the letter is it is part of a command*/
|
||||
}
|
||||
}
|
||||
@ -458,7 +458,7 @@ void lv_label_get_letter_pos(lv_obj_t * label, uint16_t index, lv_point_t * pos)
|
||||
|
||||
if(ext->align == LV_LABEL_ALIGN_CENTER) {
|
||||
lv_coord_t line_w;
|
||||
line_w = txt_get_width(&txt[line_start], new_line_start - line_start,
|
||||
line_w = lv_txt_get_width(&txt[line_start], new_line_start - line_start,
|
||||
font, style->text.letter_space, flag);
|
||||
x += lv_obj_get_width(label) / 2 - line_w / 2;
|
||||
}
|
||||
@ -486,12 +486,12 @@ uint16_t lv_label_get_letter_on(lv_obj_t * label, lv_point_t * pos)
|
||||
const lv_font_t * font = style->text.font;
|
||||
uint8_t letter_height = lv_font_get_height_scale(font);
|
||||
lv_coord_t y = 0;
|
||||
txt_flag_t flag = TXT_FLAG_NONE;
|
||||
lv_txt_flag_t flag = LV_TXT_FLAG_NONE;
|
||||
|
||||
if(ext->recolor != 0) flag |= TXT_FLAG_RECOLOR;
|
||||
if(ext->expand != 0) flag |= TXT_FLAG_EXPAND;
|
||||
if(ext->no_break != 0) flag |= TXT_FLAG_NO_BREAK;
|
||||
if(ext->align == LV_LABEL_ALIGN_CENTER) flag |= TXT_FLAG_CENTER;
|
||||
if(ext->recolor != 0) flag |= LV_TXT_FLAG_RECOLOR;
|
||||
if(ext->expand != 0) flag |= LV_TXT_FLAG_EXPAND;
|
||||
if(ext->no_break != 0) flag |= LV_TXT_FLAG_NO_BREAK;
|
||||
if(ext->align == LV_LABEL_ALIGN_CENTER) flag |= LV_TXT_FLAG_CENTER;
|
||||
|
||||
/*If the width will be expanded set the max length to very big */
|
||||
if(ext->long_mode == LV_LABEL_LONG_EXPAND || ext->long_mode == LV_LABEL_LONG_SCROLL) {
|
||||
@ -500,7 +500,7 @@ uint16_t lv_label_get_letter_on(lv_obj_t * label, lv_point_t * pos)
|
||||
|
||||
/*Search the line of the index letter */;
|
||||
while (txt[line_start] != '\0') {
|
||||
new_line_start += txt_get_next_line(&txt[line_start], font, style->text.letter_space, max_w, flag);
|
||||
new_line_start += lv_txt_get_next_line(&txt[line_start], font, style->text.letter_space, max_w, flag);
|
||||
if(pos->y <= y + letter_height) break; /*The line is found (stored in 'line_start')*/
|
||||
y += letter_height + style->text.line_space;
|
||||
line_start = new_line_start;
|
||||
@ -510,20 +510,20 @@ uint16_t lv_label_get_letter_on(lv_obj_t * label, lv_point_t * pos)
|
||||
lv_coord_t x = 0;
|
||||
if(ext->align == LV_LABEL_ALIGN_CENTER) {
|
||||
lv_coord_t line_w;
|
||||
line_w = txt_get_width(&txt[line_start], new_line_start - line_start,
|
||||
line_w = lv_txt_get_width(&txt[line_start], new_line_start - line_start,
|
||||
font, style->text.letter_space, flag);
|
||||
x += lv_obj_get_width(label) / 2 - line_w / 2;
|
||||
}
|
||||
|
||||
txt_cmd_state_t cmd_state = TXT_CMD_STATE_WAIT;
|
||||
lv_txt_cmd_state_t cmd_state = LV_TXT_CMD_STATE_WAIT;
|
||||
uint32_t i = line_start;
|
||||
uint32_t i_current = i;
|
||||
uint32_t letter;
|
||||
while(i < new_line_start - 1) {
|
||||
letter = txt_utf8_next(txt, &i); /*Be careful 'i' already points to the next character*/
|
||||
letter = lv_txt_utf8_next(txt, &i); /*Be careful 'i' already points to the next character*/
|
||||
/*Handle the recolor command*/
|
||||
if((flag & TXT_FLAG_RECOLOR) != 0) {
|
||||
if(txt_is_cmd(&cmd_state, txt[i]) != false) {
|
||||
if((flag & LV_TXT_FLAG_RECOLOR) != 0) {
|
||||
if(lv_txt_is_cmd(&cmd_state, txt[i]) != false) {
|
||||
continue; /*Skip the letter is it is part of a command*/
|
||||
}
|
||||
}
|
||||
@ -537,7 +537,7 @@ uint16_t lv_label_get_letter_on(lv_obj_t * label, lv_point_t * pos)
|
||||
i_current = i;
|
||||
}
|
||||
|
||||
return txt_utf8_get_char_id(txt, i);
|
||||
return lv_txt_utf8_get_char_id(txt, i);
|
||||
}
|
||||
|
||||
|
||||
@ -572,11 +572,11 @@ void lv_label_ins_text(lv_obj_t * label, uint32_t pos, const char * txt)
|
||||
#if TXT_UTF8 == 0
|
||||
pos = old_len;
|
||||
#else
|
||||
pos = txt_len(ext->text);
|
||||
pos = lv_txt_get_length(ext->text);
|
||||
#endif
|
||||
}
|
||||
|
||||
txt_ins(ext->text, pos, txt);
|
||||
lv_txt_ins(ext->text, pos, txt);
|
||||
|
||||
lv_label_refr_text(label);
|
||||
}
|
||||
@ -599,7 +599,7 @@ void lv_label_cut_text(lv_obj_t * label, uint32_t pos, uint32_t cnt)
|
||||
|
||||
char * label_txt = lv_label_get_text(label);
|
||||
/*Delete the characters*/
|
||||
txt_cut(label_txt, pos, cnt);
|
||||
lv_txt_cut(label_txt, pos, cnt);
|
||||
|
||||
/*Refresh the label*/
|
||||
lv_label_refr_text(label);
|
||||
@ -642,11 +642,11 @@ static bool lv_label_design(lv_obj_t * label, const lv_area_t * mask, lv_design_
|
||||
/*TEST: draw a background for the label*/
|
||||
// lv_vfill(&label->coords, mask, LV_COLOR_LIME, LV_OPA_COVER);
|
||||
|
||||
txt_flag_t flag = TXT_FLAG_NONE;
|
||||
if(ext->recolor != 0) flag |= TXT_FLAG_RECOLOR;
|
||||
if(ext->expand != 0) flag |= TXT_FLAG_EXPAND;
|
||||
if(ext->no_break != 0) flag |= TXT_FLAG_NO_BREAK;
|
||||
if(ext->align == LV_LABEL_ALIGN_CENTER) flag |= TXT_FLAG_CENTER;
|
||||
lv_txt_flag_t flag = LV_TXT_FLAG_NONE;
|
||||
if(ext->recolor != 0) flag |= LV_TXT_FLAG_RECOLOR;
|
||||
if(ext->expand != 0) flag |= LV_TXT_FLAG_EXPAND;
|
||||
if(ext->no_break != 0) flag |= LV_TXT_FLAG_NO_BREAK;
|
||||
if(ext->align == LV_LABEL_ALIGN_CENTER) flag |= LV_TXT_FLAG_CENTER;
|
||||
|
||||
lv_draw_label(&cords, mask, style, ext->text, flag, &ext->offset);
|
||||
}
|
||||
@ -717,11 +717,11 @@ static void lv_label_refr_text(lv_obj_t * label)
|
||||
|
||||
/*Calc. the height and longest line*/
|
||||
lv_point_t size;
|
||||
txt_flag_t flag = TXT_FLAG_NONE;
|
||||
if(ext->recolor != 0) flag |= TXT_FLAG_RECOLOR;
|
||||
if(ext->expand != 0) flag |= TXT_FLAG_EXPAND;
|
||||
if(ext->no_break != 0) flag |= TXT_FLAG_NO_BREAK;
|
||||
txt_get_size(&size, ext->text, font, style->text.letter_space, style->text.line_space, max_w, flag);
|
||||
lv_txt_flag_t flag = LV_TXT_FLAG_NONE;
|
||||
if(ext->recolor != 0) flag |= LV_TXT_FLAG_RECOLOR;
|
||||
if(ext->expand != 0) flag |= LV_TXT_FLAG_EXPAND;
|
||||
if(ext->no_break != 0) flag |= LV_TXT_FLAG_NO_BREAK;
|
||||
lv_txt_get_size(&size, ext->text, font, style->text.letter_space, style->text.line_space, max_w, flag);
|
||||
|
||||
/*Set the full size in expand mode*/
|
||||
if(ext->long_mode == LV_LABEL_LONG_EXPAND || ext->long_mode == LV_LABEL_LONG_SCROLL) {
|
||||
@ -801,7 +801,7 @@ static void lv_label_refr_text(lv_obj_t * label)
|
||||
else if(ext->long_mode == LV_LABEL_LONG_DOT) {
|
||||
if(size.y <= lv_obj_get_height(label)) { /*No dots are required, the text is short enough*/
|
||||
ext->dot_end = LV_LABEL_DOT_END_INV;
|
||||
} else if(txt_len(ext->text) <= LV_LABEL_DOT_NUM) { /*Don't turn to dots all the characters*/
|
||||
} else if(lv_txt_get_length(ext->text) <= LV_LABEL_DOT_NUM) { /*Don't turn to dots all the characters*/
|
||||
ext->dot_end = LV_LABEL_DOT_END_INV;
|
||||
} else {
|
||||
lv_point_t p;
|
||||
@ -831,8 +831,8 @@ static void lv_label_refr_text(lv_obj_t * label)
|
||||
uint32_t byte_id_ori = byte_id;
|
||||
uint8_t len = 0;
|
||||
for(i = 0; i <= LV_LABEL_DOT_NUM; i++) {
|
||||
len += txt_utf8_size(ext->text[byte_id]);
|
||||
txt_utf8_next(ext->text, &byte_id);
|
||||
len += lv_txt_utf8_size(ext->text[byte_id]);
|
||||
lv_txt_utf8_next(ext->text, &byte_id);
|
||||
}
|
||||
|
||||
memcpy(ext->dot_tmp, &ext->text[byte_id_ori], len);
|
||||
|
@ -18,7 +18,7 @@ extern "C" {
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include "../lv_misc/lv_font.h"
|
||||
#include "../lv_misc/lv_text.h"
|
||||
#include <lvgl/lv_misc/lv_txt.h>
|
||||
#include "../lv_misc/lv_fonts/symbol_def.h"
|
||||
|
||||
/*********************
|
||||
|
@ -115,8 +115,8 @@ void lv_line_set_points(lv_obj_t * line, const lv_point_t * point_a, uint16_t po
|
||||
lv_coord_t xmax = LV_COORD_MIN;
|
||||
lv_coord_t ymax = LV_COORD_MIN;
|
||||
for(i = 0; i < point_num; i++) {
|
||||
xmax = MATH_MAX(point_a[i].x * us, xmax);
|
||||
ymax = MATH_MAX(point_a[i].y * us, ymax);
|
||||
xmax = LV_MATH_MAX(point_a[i].x * us, xmax);
|
||||
ymax = LV_MATH_MAX(point_a[i].y * us, ymax);
|
||||
}
|
||||
|
||||
lv_style_t * lines = lv_obj_get_style(line);
|
||||
|
@ -263,10 +263,10 @@ static bool lv_lmeter_design(lv_obj_t * lmeter, const lv_area_t * mask, lv_desig
|
||||
/*Calculate the position a scale label*/
|
||||
int16_t angle = (i * ext->scale_angle) / (ext->line_cnt - 1) + angle_ofs;
|
||||
|
||||
lv_coord_t y_out = (int32_t)((int32_t)trigo_sin(angle) * r_out) / TRIGO_SIN_MAX;
|
||||
lv_coord_t x_out = (int32_t)((int32_t)trigo_sin(angle + 90) * r_out) / TRIGO_SIN_MAX;
|
||||
lv_coord_t y_in = (int32_t)((int32_t)trigo_sin(angle) * r_in) / TRIGO_SIN_MAX;
|
||||
lv_coord_t x_in = (int32_t)((int32_t)trigo_sin(angle + 90) * r_in) / TRIGO_SIN_MAX;
|
||||
lv_coord_t y_out = (int32_t)((int32_t)lv_trigo_sin(angle) * r_out) / TRIGO_SIN_MAX;
|
||||
lv_coord_t x_out = (int32_t)((int32_t)lv_trigo_sin(angle + 90) * r_out) / TRIGO_SIN_MAX;
|
||||
lv_coord_t y_in = (int32_t)((int32_t)lv_trigo_sin(angle) * r_in) / TRIGO_SIN_MAX;
|
||||
lv_coord_t x_in = (int32_t)((int32_t)lv_trigo_sin(angle + 90) * r_in) / TRIGO_SIN_MAX;
|
||||
|
||||
lv_point_t p1;
|
||||
lv_point_t p2;
|
||||
|
@ -641,8 +641,8 @@ static void lv_page_sb_refresh(lv_obj_t * page)
|
||||
* else:
|
||||
* - horizontal and vertical scrollbars can overlap on the corners
|
||||
* - if the page has radius the scrollbar can be out of the radius */
|
||||
lv_coord_t sb_hor_pad = MATH_MAX(ext->sb.style->body.padding.inner, style->body.padding.hor);
|
||||
lv_coord_t sb_ver_pad = MATH_MAX(ext->sb.style->body.padding.inner, style->body.padding.ver);
|
||||
lv_coord_t sb_hor_pad = LV_MATH_MAX(ext->sb.style->body.padding.inner, style->body.padding.hor);
|
||||
lv_coord_t sb_ver_pad = LV_MATH_MAX(ext->sb.style->body.padding.inner, style->body.padding.ver);
|
||||
|
||||
if(ext->sb.mode == LV_SB_MODE_OFF) return;
|
||||
|
||||
|
@ -227,7 +227,8 @@ static bool lv_roller_design(lv_obj_t * roller, const lv_area_t * mask, lv_desig
|
||||
lv_style_copy(&new_style, style);
|
||||
new_style.text.color = sel_style->text.color;
|
||||
new_style.text.opa = sel_style->text.opa;
|
||||
lv_draw_label(&ext->ddlist.label->coords, &mask_sel, &new_style, lv_label_get_text(ext->ddlist.label), TXT_FLAG_CENTER, NULL);
|
||||
lv_draw_label(&ext->ddlist.label->coords, &mask_sel, &new_style,
|
||||
lv_label_get_text(ext->ddlist.label), LV_TXT_FLAG_CENTER, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -404,10 +404,10 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
|
||||
lv_style_t *knob_style = lv_slider_get_style(slider, LV_SLIDER_STYLE_KNOB);
|
||||
lv_coord_t shadow_w = knob_style->body.shadow.width;
|
||||
if(ext->knob_in == 0) {
|
||||
lv_coord_t x = MATH_MIN(w / 2 + shadow_w, h / 2 + shadow_w); /*The smaller size is the knob diameter*/
|
||||
lv_coord_t x = LV_MATH_MIN(w / 2 + shadow_w, h / 2 + shadow_w); /*The smaller size is the knob diameter*/
|
||||
if(slider->ext_size < x) slider->ext_size = x;
|
||||
} else {
|
||||
lv_coord_t pad = MATH_MIN(style->body.padding.hor, style->body.padding.ver);
|
||||
lv_coord_t pad = LV_MATH_MIN(style->body.padding.hor, style->body.padding.ver);
|
||||
if(pad < 0) {
|
||||
pad = -pad;
|
||||
if(slider->ext_size < pad) slider->ext_size = pad;
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_themes/lv_theme.h"
|
||||
#include "../lv_misc/lv_anim.h"
|
||||
#include "../lv_misc/lv_text.h"
|
||||
#include <lvgl/lv_misc/lv_txt.h>
|
||||
#include "../lv_misc/lv_math.h"
|
||||
|
||||
/*********************
|
||||
@ -181,7 +181,7 @@ void lv_ta_add_char(lv_obj_t * ta, char c)
|
||||
|
||||
ext->pwd_tmp = lv_mem_realloc(ext->pwd_tmp, strlen(ext->pwd_tmp) + 2); /*+2: the new char + \0 */
|
||||
dm_assert(ext->pwd_tmp);
|
||||
txt_ins(ext->pwd_tmp, ext->cursor.pos, letter_buf);
|
||||
lv_txt_ins(ext->pwd_tmp, ext->cursor.pos, letter_buf);
|
||||
|
||||
lv_anim_t a;
|
||||
a.var = ta;
|
||||
@ -221,7 +221,7 @@ void lv_ta_add_text(lv_obj_t * ta, const char * txt)
|
||||
ext->pwd_tmp = lv_mem_realloc(ext->pwd_tmp, strlen(ext->pwd_tmp) + strlen(txt) + 1);
|
||||
dm_assert(ext->pwd_tmp);
|
||||
|
||||
txt_ins(ext->pwd_tmp, ext->cursor.pos, txt);
|
||||
lv_txt_ins(ext->pwd_tmp, ext->cursor.pos, txt);
|
||||
|
||||
lv_anim_t a;
|
||||
a.var = ta;
|
||||
@ -240,7 +240,7 @@ void lv_ta_add_text(lv_obj_t * ta, const char * txt)
|
||||
}
|
||||
|
||||
/*Move the cursor after the new text*/
|
||||
lv_ta_set_cursor_pos(ta, lv_ta_get_cursor_pos(ta) + txt_len(txt));
|
||||
lv_ta_set_cursor_pos(ta, lv_ta_get_cursor_pos(ta) + lv_txt_get_length(txt));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -256,7 +256,7 @@ void lv_ta_del_char(lv_obj_t * ta)
|
||||
|
||||
char * label_txt = lv_label_get_text(ext->label);
|
||||
/*Delete a character*/
|
||||
txt_cut(label_txt, ext->cursor.pos - 1, 1);
|
||||
lv_txt_cut(label_txt, ext->cursor.pos - 1, 1);
|
||||
/*Refresh the label*/
|
||||
lv_label_set_text(ext->label, label_txt);
|
||||
|
||||
@ -268,10 +268,10 @@ void lv_ta_del_char(lv_obj_t * ta)
|
||||
|
||||
if(ext->pwd_mode != 0) {
|
||||
#if TXT_UTF8 == 0
|
||||
txt_cut(ext->pwd_tmp, ext->cursor.pos - 1, 1);
|
||||
lv_txt_cut(ext->pwd_tmp, ext->cursor.pos - 1, 1);
|
||||
#else
|
||||
uint32_t byte_pos = txt_utf8_get_byte_id(ext->pwd_tmp, ext->cursor.pos - 1);
|
||||
txt_cut(ext->pwd_tmp, ext->cursor.pos - 1, txt_utf8_size(label_txt[byte_pos]));
|
||||
lv_txt_cut(ext->pwd_tmp, ext->cursor.pos - 1, lv_txt_utf8_size(label_txt[byte_pos]));
|
||||
#endif
|
||||
ext->pwd_tmp = lv_mem_realloc(ext->pwd_tmp, strlen(ext->pwd_tmp) + 1);
|
||||
dm_assert(ext->pwd_tmp);
|
||||
@ -333,7 +333,7 @@ void lv_ta_set_text(lv_obj_t * ta, const char * txt)
|
||||
void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
uint16_t len = txt_len(lv_label_get_text(ext->label));
|
||||
uint16_t len = lv_txt_get_length(lv_label_get_text(ext->label));
|
||||
|
||||
if(pos < 0) pos = len + pos;
|
||||
|
||||
@ -779,7 +779,7 @@ static bool lv_ta_scrollable_design(lv_obj_t * scrl, const lv_area_t * mask, lv_
|
||||
byte_pos = cur_pos;
|
||||
#endif
|
||||
|
||||
uint32_t letter = txt_utf8_next(&txt[byte_pos], NULL);
|
||||
uint32_t letter = lv_txt_utf8_next(&txt[byte_pos], NULL);
|
||||
lv_coord_t letter_h = lv_font_get_height_scale(label_style->text.font);
|
||||
/*Set letter_w (set not 0 on non printable but valid chars)*/
|
||||
lv_coord_t letter_w;
|
||||
@ -798,8 +798,8 @@ static bool lv_ta_scrollable_design(lv_obj_t * scrl, const lv_area_t * mask, lv_
|
||||
letter_pos.y += letter_h + label_style->text.line_space;
|
||||
|
||||
if(letter != '\0'){
|
||||
byte_pos += txt_utf8_size(txt[byte_pos]);
|
||||
letter = txt_utf8_next(&txt[byte_pos], NULL);
|
||||
byte_pos += lv_txt_utf8_size(txt[byte_pos]);
|
||||
letter = lv_txt_utf8_next(&txt[byte_pos], NULL);
|
||||
}
|
||||
|
||||
if(letter == '\0' || letter == '\n' || letter == '\r') {
|
||||
@ -832,11 +832,11 @@ static bool lv_ta_scrollable_design(lv_obj_t * scrl, const lv_area_t * mask, lv_
|
||||
letter_buf[1] = '\0';
|
||||
#else
|
||||
char letter_buf[8] = {0};
|
||||
memcpy(letter_buf, &txt[byte_pos], txt_utf8_size(txt[byte_pos]));
|
||||
memcpy(letter_buf, &txt[byte_pos], lv_txt_utf8_size(txt[byte_pos]));
|
||||
#endif
|
||||
cur_area.x1 += cur_style.body.padding.hor;
|
||||
cur_area.y1 += cur_style.body.padding.ver;
|
||||
lv_draw_label(&cur_area, mask, &cur_style, letter_buf, TXT_FLAG_NONE, 0);
|
||||
lv_draw_label(&cur_area, mask, &cur_style, letter_buf, LV_TXT_FLAG_NONE, 0);
|
||||
|
||||
} else if(ta_ext->cursor.type == LV_CURSOR_OUTLINE) {
|
||||
cur_area.x1 = letter_pos.x + ta_ext->label->coords.x1 - cur_style.body.padding.hor;
|
||||
@ -967,7 +967,7 @@ static lv_res_t lv_ta_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, void
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
lv_style_t * style_label = lv_obj_get_style(ext->label);
|
||||
lv_coord_t font_h = lv_font_get_height_scale(style_label->text.font);
|
||||
scrl->ext_size = MATH_MAX(scrl->ext_size, style_label->text.line_space + font_h);
|
||||
scrl->ext_size = LV_MATH_MAX(scrl->ext_size, style_label->text.line_space + font_h);
|
||||
}
|
||||
|
||||
return res;
|
||||
@ -1012,7 +1012,7 @@ static void pwd_char_hider(lv_obj_t * ta)
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
if(ext->pwd_mode != 0) {
|
||||
char * txt = lv_label_get_text(ext->label);
|
||||
int16_t len = txt_len(txt);
|
||||
int16_t len = lv_txt_get_length(txt);
|
||||
bool refr = false;
|
||||
uint16_t i;
|
||||
for(i = 0; i < len; i++) txt[i] = '*';
|
||||
|
Loading…
Reference in New Issue
Block a user