1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

minor APU updates

This commit is contained in:
Gabor Kiss-Vamosi 2019-06-19 13:43:02 +02:00
parent d80cc562d4
commit 1844d060ab
8 changed files with 143 additions and 76 deletions

View File

@ -393,6 +393,10 @@ typedef void * lv_obj_user_data_t;
/*Page (dependencies: lv_cont)*/
#define LV_USE_PAGE 1
#if LV_USE_PAGE != 0
/*Focus default animation time [ms] (0: no animation)*/
# define LV_PAGE_DEF_ANIM_TIME 400
#endif
/*Preload (dependencies: lv_arc, lv_anim)*/
#define LV_USE_PRELOAD 1

View File

@ -96,6 +96,10 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
ext->series.dark = LV_OPA_50;
ext->series.width = 2;
ext->margin = 0;
ext->x_axis.major_tick_len = LV_CHART_TICK_LENGTH_AUTO;
ext->x_axis.minor_tick_len = LV_CHART_TICK_LENGTH_AUTO;
ext->y_axis.major_tick_len = LV_CHART_TICK_LENGTH_AUTO;
ext->y_axis.minor_tick_len = LV_CHART_TICK_LENGTH_AUTO;
memset(&ext->x_axis, 0, sizeof(ext->x_axis));
memset(&ext->y_axis, 0, sizeof(ext->y_axis));
@ -119,6 +123,7 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
} else {
lv_chart_ext_t * ext_copy = lv_obj_get_ext_attr(copy);
ext->type = ext_copy->type;
ext->ymin = ext_copy->ymin;
ext->ymax = ext_copy->ymax;
@ -431,9 +436,72 @@ void lv_chart_set_update_mode(lv_obj_t * chart, lv_chart_update_mode_t update_mo
}
/**
* Set the margin around the chart, used for axes value and labels
* @param margin value of the margin
* Set the length of the tick marks on the x axis
* @param chart pointer to the chart
* @param major_tick_len the length of the major tick or `LV_CHART_TICK_LENGTH_AUTO` to set automatically
* (where labels are added)
* @param minor_tick_len the length of the minor tick, `LV_CHART_TICK_LENGTH_AUTO` to set automatically
* (where no labels are added)
*/
void lv_chart_set_x_tick_length(lv_obj_t * chart, uint8_t major_tick_len, uint8_t minor_tick_len)
{
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
ext->x_axis.major_tick_len = major_tick_len;
ext->x_axis.minor_tick_len = minor_tick_len;
}
/**
* Set the length of the tick marks on the y axis
* @param chart pointer to the chart
* @param major_tick_len the length of the major tick or `LV_CHART_TICK_LENGTH_AUTO` to set automatically
* (where labels are added)
* @param minor_tick_len the length of the minor tick, `LV_CHART_TICK_LENGTH_AUTO` to set automatically
* (where no labels are added)
*/
void lv_chart_set_y_tick_length(lv_obj_t * chart, uint8_t major_tick_len, uint8_t minor_tick_len)
{
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
ext->y_axis.major_tick_len = major_tick_len;
ext->y_axis.minor_tick_len = minor_tick_len;
}
/**
* Set the x-axis tick count and labels of a chart
* @param chart pointer to a chart object
* @param list_of_values list of string values, terminated with \n, except the last
* @param num_tick_marks if list_of_values is NULL: total number of ticks per axis
* else number of ticks between two value labels
* @param options extra options
*/
void lv_chart_set_x_tick_texts(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks, lv_chart_axis_options_t options)
{
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
ext->x_axis.num_tick_marks = num_tick_marks;
ext->x_axis.list_of_values = list_of_values;
ext->x_axis.options = options;
}
/**
* Set the y-axis tick count and labels of a chart
* @param chart pointer to a chart object
* @param list_of_values list of string values, terminated with \n, except the last
* @param num_tick_marks if list_of_values is NULL: total number of ticks per axis
* else number of ticks between two value labels
* @param options extra options
*/
void lv_chart_set_y_tick_texts(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks, lv_chart_axis_options_t options)
{
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
ext->y_axis.num_tick_marks = num_tick_marks;
ext->y_axis.list_of_values = list_of_values;
ext->y_axis.options = options;
}
/**
* Set the margin around the chart, used for axes value and ticks
* @param chart pointer to an chart object
* @param margin value of the margin [px]
*/
void lv_chart_set_margin(lv_obj_t * chart, uint16_t margin)
{
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
@ -441,38 +509,6 @@ void lv_chart_set_margin(lv_obj_t * chart, uint16_t margin)
lv_obj_refresh_ext_draw_pad(chart);
}
/**
* Set the x/y-axis ticks of a chart
* @param chart pointer to a chart object
* @param list_of_values list of string values, terminated with \n, except the last
* @param num_tick_marks if list_of_values is NULL: total number of ticks per axis
* else step in ticks between two value labels
* @param major_tick_len the length of the major tick, AUTO if 0
* @param minor_tick_len the length of the minor tick, AUTO if 0
* @param options extra options
*/
void lv_chart_set_x_ticks(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks, uint8_t major_tick_len,
uint8_t minor_tick_len, lv_chart_axis_options_t options)
{
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
ext->x_axis.num_tick_marks = num_tick_marks;
ext->x_axis.list_of_values = list_of_values;
ext->x_axis.major_tick_len = major_tick_len;
ext->x_axis.minor_tick_len = minor_tick_len;
ext->x_axis.options = options;
}
void lv_chart_set_y_ticks(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks, uint8_t major_tick_len,
uint8_t minor_tick_len, lv_chart_axis_options_t options)
{
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
ext->y_axis.num_tick_marks = num_tick_marks;
ext->y_axis.list_of_values = list_of_values;
ext->y_axis.major_tick_len = major_tick_len;
ext->y_axis.minor_tick_len = minor_tick_len;
ext->y_axis.options = options;
}
/*=====================
* Getter functions
*====================*/
@ -1029,12 +1065,12 @@ static void lv_chart_draw_y_ticks(lv_obj_t * chart, const lv_area_t * mask)
char buf[LV_CHART_AXIS_TICK_LABEL_MAX_LEN + 1]; /* up to N symbols per label + null terminator */
/* calculate the size of tick marks */
if(ext->y_axis.major_tick_len == 0)
if(ext->y_axis.major_tick_len == LV_CHART_TICK_LENGTH_AUTO)
major_tick_len = (int32_t)w * LV_CHART_AXIS_MAJOR_TICK_LEN_COE;
else
major_tick_len = ext->y_axis.major_tick_len;
if(ext->y_axis.minor_tick_len == 0)
if(ext->y_axis.minor_tick_len == LV_CHART_TICK_LENGTH_AUTO)
minor_tick_len = major_tick_len * LV_CHART_AXIS_MINOR_TICK_LEN_COE;
else
minor_tick_len = ext->y_axis.minor_tick_len;
@ -1116,7 +1152,6 @@ static void lv_chart_draw_y_ticks(lv_obj_t * chart, const lv_area_t * mask)
static void lv_chart_draw_x_ticks(lv_obj_t * chart, const lv_area_t * mask)
{
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
if(ext->x_axis.list_of_values != NULL || ext->x_axis.num_tick_marks != 0) {
@ -1138,12 +1173,12 @@ static void lv_chart_draw_x_ticks(lv_obj_t * chart, const lv_area_t * mask)
char buf[LV_CHART_AXIS_TICK_LABEL_MAX_LEN + 1]; /* up to N symbols per label + null terminator */
/* calculate the size of tick marks */
if(ext->x_axis.major_tick_len == 0)
if(ext->x_axis.major_tick_len == LV_CHART_TICK_LENGTH_AUTO)
major_tick_len = (int32_t)w * LV_CHART_AXIS_MAJOR_TICK_LEN_COE;
else
major_tick_len = ext->x_axis.major_tick_len;
if(ext->x_axis.minor_tick_len == 0)
if(ext->x_axis.minor_tick_len == LV_CHART_TICK_LENGTH_AUTO)
minor_tick_len = major_tick_len * LV_CHART_AXIS_MINOR_TICK_LEN_COE;
else
minor_tick_len = ext->x_axis.minor_tick_len;

View File

@ -29,6 +29,9 @@ extern "C" {
*********************/
#define LV_CHART_POINT_DEF (LV_COORD_MIN)
/**Automatically calculate the tick length*/
#define LV_CHART_TICK_LENGTH_AUTO 255
/**********************
* TYPEDEFS
**********************/
@ -60,15 +63,16 @@ typedef struct
/*Data of axis */
enum {
LV_CHART_AXIS_DRAW_LAST_TICK = 0x01 /* draw the last tick */
LV_CHART_AXIS_SKIP_LAST_TICK = 0x00, /* don't draw the last tick */
LV_CHART_AXIS_DRAW_LAST_TICK = 0x01 /* draw the last tick */
};
typedef uint8_t lv_chart_axis_options_t;
typedef struct
{
const char * list_of_values;
uint8_t num_tick_marks;
lv_chart_axis_options_t options;
uint8_t num_tick_marks;
uint8_t major_tick_len;
uint8_t minor_tick_len;
} lv_chart_axis_cfg_t;
@ -234,37 +238,51 @@ static inline void lv_chart_set_style(lv_obj_t * chart, lv_chart_style_t type, c
}
/**
* Set the margin around the chart, used for axes value and labels
* @param chart pointer to an chart object
* @param margin value of the margin
* Set the length of the tick marks on the x axis
* @param chart pointer to the chart
* @param major_tick_len the length of the major tick or `LV_CHART_TICK_LENGTH_AUTO` to set automatically
* (where labels are added)
* @param minor_tick_len the length of the minor tick, `LV_CHART_TICK_LENGTH_AUTO` to set automatically
* (where no labels are added)
*/
void lv_chart_set_margin(lv_obj_t * chart, uint16_t margin);
void lv_chart_set_x_tick_length(lv_obj_t * chart, uint8_t major_tick_len, uint8_t minor_tick_len);
/**
* Set the y-axis ticks of a chart
* @param chart pointer to a chart object
* @param list_of_values list of string values, terminated with \n, except the last
* @param num_tick_marks if list_of_values is NULL: total number of ticks per axis
* else step in ticks between two value labels
* @param major_tick_len the length of the major tick, AUTO if 0
* @param minor_tick_len the length of the minor tick, AUTO if 0
* @param options extra options
* Set the length of the tick marks on the y axis
* @param chart pointer to the chart
* @param major_tick_len the length of the major tick or `LV_CHART_TICK_LENGTH_AUTO` to set automatically
* (where labels are added)
* @param minor_tick_len the length of the minor tick, `LV_CHART_TICK_LENGTH_AUTO` to set automatically
* (where no labels are added)
*/
void lv_chart_set_x_ticks(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks, uint8_t major_tick_len,
uint8_t minor_tick_len, lv_chart_axis_options_t options);
void lv_chart_set_y_tick_length(lv_obj_t * chart, uint8_t major_tick_len, uint8_t minor_tick_len);
/**
* Set the y-axis ticks of a chart
* Set the x-axis tick count and labels of a chart
* @param chart pointer to a chart object
* @param list_of_values list of string values, terminated with \n, except the last
* @param num_tick_marks if list_of_values is NULL: total number of ticks per axis
* else step in ticks between two value labels
* @param major_tick_len the length of the major tick, AUTO if 0
* @param minor_tick_len the length of the minor tick, AUTO if 0
* else number of ticks between two value labels
* @param options extra options
*/
void lv_chart_set_y_ticks(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks, uint8_t major_tick_len,
uint8_t minor_tick_len, lv_chart_axis_options_t options);
void lv_chart_set_x_tick_texts(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks, lv_chart_axis_options_t options);
/**
* Set the y-axis tick count and labels of a chart
* @param chart pointer to a chart object
* @param list_of_values list of string values, terminated with \n, except the last
* @param num_tick_marks if list_of_values is NULL: total number of ticks per axis
* else number of ticks between two value labels
* @param options extra options
*/
void lv_chart_set_y_tick_texts(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks, lv_chart_axis_options_t options);
/**
* Set the margin around the chart, used for axes value and ticks
* @param chart pointer to an chart object
* @param margin value of the margin [px]
*/
void lv_chart_set_margin(lv_obj_t * chart, uint16_t margin);
/*=====================
* Getter functions

View File

@ -450,7 +450,7 @@ static lv_res_t lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
mbox_realign(mbox);
} else if(sign == LV_SIGNAL_RELEASED) {
if(ext->btnm) {
uint16_t btn_id = lv_btnm_get_active_btn(ext->btnm);
uint32_t btn_id = lv_btnm_get_active_btn(ext->btnm);
if(btn_id != LV_BTNM_BTN_NONE) lv_event_send(mbox, LV_EVENT_VALUE_CHANGED, &btn_id);
}
} else if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS || sign == LV_SIGNAL_CONTROL ||
@ -523,7 +523,7 @@ static void lv_mbox_default_event_cb(lv_obj_t * mbox, lv_event_t event)
{
if(event != LV_EVENT_VALUE_CHANGED) return;
uint16_t btn_id = lv_mbox_get_active_btn(mbox);
uint32_t btn_id = lv_mbox_get_active_btn(mbox);
if(btn_id == LV_BTNM_BTN_NONE) return;
lv_mbox_start_auto_close(mbox, 0);

View File

@ -28,6 +28,11 @@
#define LV_PAGE_END_ANIM_TIME 300
#define LV_PAGE_END_ANIM_WAIT_TIME 300
#if LV_USE_ANIMATION == 0
#undef LV_PAGE_DEF_ANIM_TIME
#define LV_PAGE_DEF_ANIM_TIME 0 /*No animation*/
#endif
/**********************
* TYPEDEFS
**********************/
@ -96,6 +101,7 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
ext->edge_flash.right_ip = 0;
ext->edge_flash.state = 0;
ext->edge_flash.style = &lv_style_plain_color;
ext->anim_time = LV_PAGE_DEF_ANIM_TIME;
#endif
ext->arrow_scroll = 0;
ext->scroll_prop = 0;

View File

@ -50,8 +50,12 @@ enum {
typedef uint8_t lv_sb_mode_t;
/*Edges: describes the four edges of the page*/
enum { LV_PAGE_EDGE_LEFT = 0x0, LV_PAGE_EDGE_TOP = 0x1, LV_PAGE_EDGE_RIGHT = 0x2, LV_PAGE_EDGE_BOTTOM = 0x3 };
enum {
LV_PAGE_EDGE_LEFT = 0x0,
LV_PAGE_EDGE_TOP = 0x1,
LV_PAGE_EDGE_RIGHT = 0x2,
LV_PAGE_EDGE_BOTTOM = 0x3
};
typedef uint8_t lv_page_edge_t;
/*Data of page*/

View File

@ -111,7 +111,7 @@ lv_obj_t * lv_preload_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_refresh_style(new_preload);
}
lv_preload_set_anim_type(new_preload, ext->anim_type);
lv_preload_set_type(new_preload, ext->anim_type);
LV_LOG_INFO("preload created");
@ -144,7 +144,7 @@ void lv_preload_set_spin_time(lv_obj_t * preload, uint16_t time)
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
ext->time = time;
lv_preload_set_anim_type(preload, ext->anim_type);
lv_preload_set_type(preload, ext->anim_type);
}
/*=====================
* Setter functions
@ -168,7 +168,7 @@ void lv_preload_set_style(lv_obj_t * preload, lv_preload_style_t type, const lv_
* @param preload pointer to pre loader object
* @param type animation type of the preload
* */
void lv_preload_set_anim_type(lv_obj_t * preload, lv_preload_type_t type)
void lv_preload_set_type(lv_obj_t * preload, lv_preload_type_t type)
{
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
@ -248,12 +248,12 @@ void lv_preload_set_anim_type(lv_obj_t * preload, lv_preload_type_t type)
}
}
void lv_preload_set_anim_dir(lv_obj_t * preload, lv_preload_dir_t dir)
void lv_preload_set_dir(lv_obj_t * preload, lv_preload_dir_t dir)
{
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
ext->anim_dir = dir;
lv_preload_set_anim_type(preload, ext->anim_type);
lv_preload_set_type(preload, ext->anim_type);
}
/*=====================
@ -303,13 +303,13 @@ const lv_style_t * lv_preload_get_style(const lv_obj_t * preload, lv_preload_sty
* @param preload pointer to pre loader object
* @return animation type
* */
lv_preload_type_t lv_preload_get_anim_type(lv_obj_t * preload)
lv_preload_type_t lv_preload_get_type(lv_obj_t * preload)
{
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
return ext->anim_type;
}
lv_preload_dir_t lv_preload_get_anim_dir(lv_obj_t * preload)
lv_preload_dir_t lv_preload_get_dir(lv_obj_t * preload)
{
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
return ext->anim_dir;

View File

@ -119,14 +119,14 @@ void lv_preload_set_style(lv_obj_t * preload, lv_preload_style_t type, const lv_
* @param preload pointer to pre loader object
* @param type animation type of the preload
* */
void lv_preload_set_anim_type(lv_obj_t * preload, lv_preload_type_t type);
void lv_preload_set_type(lv_obj_t * preload, lv_preload_type_t type);
/**
* Set the animation direction of a preloader
* @param preload pointer to pre loader object
* @param direction animation direction of the preload
*/
void lv_preload_set_anim_dir(lv_obj_t * preload, lv_preload_dir_t dir);
void lv_preload_set_dir(lv_obj_t * preload, lv_preload_dir_t dir);
/*=====================
* Getter functions
@ -157,14 +157,14 @@ const lv_style_t * lv_preload_get_style(const lv_obj_t * preload, lv_preload_sty
* @param preload pointer to pre loader object
* @return animation type
* */
lv_preload_type_t lv_preload_get_anim_type(lv_obj_t * preload);
lv_preload_type_t lv_preload_get_type(lv_obj_t * preload);
/**
* Get the animation direction of a preloader
* @param preload pointer to pre loader object
* @return animation direction
*/
lv_preload_dir_t lv_preload_get_anim_dir(lv_obj_t * preload);
lv_preload_dir_t lv_preload_get_dir(lv_obj_t * preload);
/*=====================
* Other functions