apps/examples/lvgldemo: Port tp_cal.c for LVGL V6.1.2
Signed-off-by: Qi Huang <huangqi3@xiaomi.com> Change-Id: I1fead13274822276e08d3f54016b079b174a1544
This commit is contained in:
parent
6f2ed3dfd4
commit
1fa30e59d3
@ -68,7 +68,7 @@ enum tp_cal_state_e
|
|||||||
* Private Function Prototypes
|
* Private Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static lv_res_t btn_click_action(lv_obj_t * scr);
|
static void btn_click_action(FAR lv_obj_t *scr, lv_event_t event);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
@ -92,19 +92,22 @@ static lv_obj_t *circ_area;
|
|||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* scr
|
* scr
|
||||||
|
* event
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* ?
|
* ?
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static lv_res_t btn_click_action(FAR lv_obj_t *scr)
|
static void btn_click_action(FAR lv_obj_t *scr, lv_event_t event)
|
||||||
|
{
|
||||||
|
if (event == LV_EVENT_CLICKED)
|
||||||
{
|
{
|
||||||
if (state == TP_CAL_STATE_WAIT_TOP_LEFT)
|
if (state == TP_CAL_STATE_WAIT_TOP_LEFT)
|
||||||
{
|
{
|
||||||
lv_indev_t *indev = lv_indev_get_act();
|
lv_indev_t *indev = lv_indev_get_act();
|
||||||
char buf[64];
|
char buf[64];
|
||||||
#if USE_LV_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
lv_anim_t a;
|
lv_anim_t a;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -121,13 +124,13 @@ static lv_res_t btn_click_action(FAR lv_obj_t *scr)
|
|||||||
(LV_HOR_RES - lv_obj_get_width(label_main)) / 2,
|
(LV_HOR_RES - lv_obj_get_width(label_main)) / 2,
|
||||||
(LV_VER_RES - lv_obj_get_height(label_main)) / 2);
|
(LV_VER_RES - lv_obj_get_height(label_main)) / 2);
|
||||||
|
|
||||||
#if USE_LV_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
a.var = circ_area;
|
a.var = circ_area;
|
||||||
a.start = 0;
|
a.start = 0;
|
||||||
a.end = LV_HOR_RES - CIRCLE_SIZE;
|
a.end = LV_HOR_RES - CIRCLE_SIZE;
|
||||||
a.fp = (lv_anim_fp_t) lv_obj_set_x;
|
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_x;
|
||||||
a.path = lv_anim_path_linear;
|
a.path_cb = (lv_anim_path_cb_t)lv_anim_path_linear;
|
||||||
a.end_cb = NULL;
|
a.ready_cb = NULL;
|
||||||
a.act_time = 0;
|
a.act_time = 0;
|
||||||
a.time = 200;
|
a.time = 200;
|
||||||
a.playback = 0;
|
a.playback = 0;
|
||||||
@ -137,8 +140,8 @@ static lv_res_t btn_click_action(FAR lv_obj_t *scr)
|
|||||||
lv_anim_create(&a);
|
lv_anim_create(&a);
|
||||||
a.start = 0;
|
a.start = 0;
|
||||||
a.end = 0;
|
a.end = 0;
|
||||||
a.fp = (lv_anim_fp_t)lv_obj_set_y;
|
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_y;
|
||||||
a.end_cb = NULL;
|
a.ready_cb = NULL;
|
||||||
a.time = 200;
|
a.time = 200;
|
||||||
lv_anim_create(&a);
|
lv_anim_create(&a);
|
||||||
#else
|
#else
|
||||||
@ -152,7 +155,7 @@ static lv_res_t btn_click_action(FAR lv_obj_t *scr)
|
|||||||
lv_indev_t *indev = lv_indev_get_act();
|
lv_indev_t *indev = lv_indev_get_act();
|
||||||
char buf[64];
|
char buf[64];
|
||||||
|
|
||||||
#if USE_LV_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
lv_anim_t a;
|
lv_anim_t a;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -161,7 +164,8 @@ static lv_res_t btn_click_action(FAR lv_obj_t *scr)
|
|||||||
sprintf(buf, "x: %d\ny: %d", p[1].x, p[1].y);
|
sprintf(buf, "x: %d\ny: %d", p[1].x, p[1].y);
|
||||||
lv_obj_t *label_coord = lv_label_create(lv_scr_act(), NULL);
|
lv_obj_t *label_coord = lv_label_create(lv_scr_act(), NULL);
|
||||||
lv_label_set_text(label_coord, buf);
|
lv_label_set_text(label_coord, buf);
|
||||||
lv_obj_set_pos(label_coord, LV_HOR_RES - lv_obj_get_width(label_coord),
|
lv_obj_set_pos(label_coord,
|
||||||
|
LV_HOR_RES - lv_obj_get_width(label_coord),
|
||||||
0);
|
0);
|
||||||
|
|
||||||
lv_label_set_text(label_main, "Click the circle in\n"
|
lv_label_set_text(label_main, "Click the circle in\n"
|
||||||
@ -170,13 +174,14 @@ static lv_res_t btn_click_action(FAR lv_obj_t *scr)
|
|||||||
lv_obj_set_pos(label_main,
|
lv_obj_set_pos(label_main,
|
||||||
(LV_HOR_RES - lv_obj_get_width(label_main)) / 2,
|
(LV_HOR_RES - lv_obj_get_width(label_main)) / 2,
|
||||||
(LV_VER_RES - lv_obj_get_height(label_main)) / 2);
|
(LV_VER_RES - lv_obj_get_height(label_main)) / 2);
|
||||||
#if USE_LV_ANIMATION
|
|
||||||
|
#if LV_USE_ANIMATION
|
||||||
a.var = circ_area;
|
a.var = circ_area;
|
||||||
a.start = LV_HOR_RES - CIRCLE_SIZE;
|
a.start = LV_HOR_RES - CIRCLE_SIZE;
|
||||||
a.end = LV_HOR_RES - CIRCLE_SIZE;
|
a.end = LV_HOR_RES - CIRCLE_SIZE;
|
||||||
a.fp = (lv_anim_fp_t)lv_obj_set_x;
|
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_x;
|
||||||
a.path = lv_anim_path_linear;
|
a.path_cb = (lv_anim_path_cb_t)lv_anim_path_linear;
|
||||||
a.end_cb = NULL;
|
a.ready_cb = NULL;
|
||||||
a.act_time = 0;
|
a.act_time = 0;
|
||||||
a.time = 200;
|
a.time = 200;
|
||||||
a.playback = 0;
|
a.playback = 0;
|
||||||
@ -187,12 +192,13 @@ static lv_res_t btn_click_action(FAR lv_obj_t *scr)
|
|||||||
|
|
||||||
a.start = 0;
|
a.start = 0;
|
||||||
a.end = LV_VER_RES - CIRCLE_SIZE;
|
a.end = LV_VER_RES - CIRCLE_SIZE;
|
||||||
a.fp = (lv_anim_fp_t) lv_obj_set_y;
|
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_y;
|
||||||
a.end_cb = NULL;
|
a.ready_cb = NULL;
|
||||||
a.time = 200;
|
a.time = 200;
|
||||||
lv_anim_create(&a);
|
lv_anim_create(&a);
|
||||||
#else
|
#else
|
||||||
lv_obj_set_pos(circ_area, LV_HOR_RES - CIRCLE_SIZE, LV_VER_RES - CIRCLE_SIZE);
|
lv_obj_set_pos(circ_area,
|
||||||
|
LV_HOR_RES - CIRCLE_SIZE, LV_VER_RES - CIRCLE_SIZE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
state = TP_CAL_STATE_WAIT_BOTTOM_RIGHT;
|
state = TP_CAL_STATE_WAIT_BOTTOM_RIGHT;
|
||||||
@ -201,7 +207,7 @@ static lv_res_t btn_click_action(FAR lv_obj_t *scr)
|
|||||||
{
|
{
|
||||||
lv_indev_t *indev = lv_indev_get_act();
|
lv_indev_t *indev = lv_indev_get_act();
|
||||||
char buf[64];
|
char buf[64];
|
||||||
#if USE_LV_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
lv_anim_t a;
|
lv_anim_t a;
|
||||||
#endif
|
#endif
|
||||||
lv_indev_get_point(indev, &p[2]);
|
lv_indev_get_point(indev, &p[2]);
|
||||||
@ -209,7 +215,8 @@ static lv_res_t btn_click_action(FAR lv_obj_t *scr)
|
|||||||
sprintf(buf, "x: %d\ny: %d", p[2].x, p[2].y);
|
sprintf(buf, "x: %d\ny: %d", p[2].x, p[2].y);
|
||||||
lv_obj_t *label_coord = lv_label_create(lv_scr_act(), NULL);
|
lv_obj_t *label_coord = lv_label_create(lv_scr_act(), NULL);
|
||||||
lv_label_set_text(label_coord, buf);
|
lv_label_set_text(label_coord, buf);
|
||||||
lv_obj_set_pos(label_coord, LV_HOR_RES - lv_obj_get_width(label_coord),
|
lv_obj_set_pos(label_coord,
|
||||||
|
LV_HOR_RES - lv_obj_get_width(label_coord),
|
||||||
LV_VER_RES - lv_obj_get_height(label_coord));
|
LV_VER_RES - lv_obj_get_height(label_coord));
|
||||||
|
|
||||||
lv_label_set_text(label_main, "Click the circle in\n"
|
lv_label_set_text(label_main, "Click the circle in\n"
|
||||||
@ -219,13 +226,13 @@ static lv_res_t btn_click_action(FAR lv_obj_t *scr)
|
|||||||
(LV_HOR_RES - lv_obj_get_width(label_main)) / 2,
|
(LV_HOR_RES - lv_obj_get_width(label_main)) / 2,
|
||||||
(LV_VER_RES - lv_obj_get_height(label_main)) / 2);
|
(LV_VER_RES - lv_obj_get_height(label_main)) / 2);
|
||||||
|
|
||||||
#if USE_LV_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
a.var = circ_area;
|
a.var = circ_area;
|
||||||
a.start = LV_HOR_RES - CIRCLE_SIZE;
|
a.start = LV_HOR_RES - CIRCLE_SIZE;
|
||||||
a.end = 0;
|
a.end = 0;
|
||||||
a.fp = (lv_anim_fp_t)lv_obj_set_x;
|
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_x;
|
||||||
a.path = lv_anim_path_linear;
|
a.path_cb = (lv_anim_path_cb_t)lv_anim_path_linear;
|
||||||
a.end_cb = NULL;
|
a.ready_cb = NULL;
|
||||||
a.act_time = 0;
|
a.act_time = 0;
|
||||||
a.time = 200;
|
a.time = 200;
|
||||||
a.playback = 0;
|
a.playback = 0;
|
||||||
@ -236,8 +243,8 @@ static lv_res_t btn_click_action(FAR lv_obj_t *scr)
|
|||||||
|
|
||||||
a.start = LV_VER_RES - CIRCLE_SIZE;
|
a.start = LV_VER_RES - CIRCLE_SIZE;
|
||||||
a.end = LV_VER_RES - CIRCLE_SIZE;
|
a.end = LV_VER_RES - CIRCLE_SIZE;
|
||||||
a.fp = (lv_anim_fp_t) lv_obj_set_y;
|
a.exec_cb = (lv_anim_exec_xcb_t) lv_obj_set_y;
|
||||||
a.end_cb = NULL;
|
a.ready_cb = NULL;
|
||||||
a.time = 200;
|
a.time = 200;
|
||||||
lv_anim_create(&a);
|
lv_anim_create(&a);
|
||||||
#else
|
#else
|
||||||
@ -246,7 +253,6 @@ static lv_res_t btn_click_action(FAR lv_obj_t *scr)
|
|||||||
|
|
||||||
state = TP_CAL_STATE_WAIT_BOTTOM_LEFT;
|
state = TP_CAL_STATE_WAIT_BOTTOM_LEFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (state == TP_CAL_STATE_WAIT_BOTTOM_LEFT)
|
else if (state == TP_CAL_STATE_WAIT_BOTTOM_LEFT)
|
||||||
{
|
{
|
||||||
lv_indev_t *indev = lv_indev_get_act();
|
lv_indev_t *indev = lv_indev_get_act();
|
||||||
@ -280,8 +286,7 @@ static lv_res_t btn_click_action(FAR lv_obj_t *scr)
|
|||||||
else if (state == TP_CAL_STATE_READY)
|
else if (state == TP_CAL_STATE_READY)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return LV_RES_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -305,7 +310,7 @@ static lv_res_t btn_click_action(FAR lv_obj_t *scr)
|
|||||||
void tp_cal_create(void)
|
void tp_cal_create(void)
|
||||||
{
|
{
|
||||||
static lv_style_t style_circ;
|
static lv_style_t style_circ;
|
||||||
#if USE_LV_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
lv_anim_t a;
|
lv_anim_t a;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -323,7 +328,7 @@ void tp_cal_create(void)
|
|||||||
lv_obj_set_size(big_btn, TP_MAX_VALUE, TP_MAX_VALUE);
|
lv_obj_set_size(big_btn, TP_MAX_VALUE, TP_MAX_VALUE);
|
||||||
lv_btn_set_style(big_btn, LV_BTN_STYLE_REL, &lv_style_transp);
|
lv_btn_set_style(big_btn, LV_BTN_STYLE_REL, &lv_style_transp);
|
||||||
lv_btn_set_style(big_btn, LV_BTN_STYLE_PR, &lv_style_transp);
|
lv_btn_set_style(big_btn, LV_BTN_STYLE_PR, &lv_style_transp);
|
||||||
lv_btn_set_action(big_btn, LV_BTN_ACTION_CLICK, btn_click_action);
|
lv_obj_set_event_cb(big_btn, btn_click_action);
|
||||||
lv_btn_set_layout(big_btn, LV_LAYOUT_OFF);
|
lv_btn_set_layout(big_btn, LV_LAYOUT_OFF);
|
||||||
|
|
||||||
label_main = lv_label_create(lv_scr_act(), NULL);
|
label_main = lv_label_create(lv_scr_act(), NULL);
|
||||||
@ -342,13 +347,13 @@ void tp_cal_create(void)
|
|||||||
lv_obj_set_style(circ_area, &style_circ);
|
lv_obj_set_style(circ_area, &style_circ);
|
||||||
lv_obj_set_click(circ_area, false);
|
lv_obj_set_click(circ_area, false);
|
||||||
|
|
||||||
#if USE_LV_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
a.var = circ_area;
|
a.var = circ_area;
|
||||||
a.start = LV_HOR_RES / 2;
|
a.start = LV_HOR_RES / 2;
|
||||||
a.end = 0;
|
a.end = 0;
|
||||||
a.fp = (lv_anim_fp_t) lv_obj_set_x;
|
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_x;
|
||||||
a.path = lv_anim_path_linear;
|
a.path_cb = (lv_anim_path_cb_t)lv_anim_path_linear;
|
||||||
a.end_cb = NULL;
|
a.ready_cb = NULL;
|
||||||
a.act_time = -500;
|
a.act_time = -500;
|
||||||
a.time = 200;
|
a.time = 200;
|
||||||
a.playback = 0;
|
a.playback = 0;
|
||||||
@ -359,8 +364,8 @@ void tp_cal_create(void)
|
|||||||
|
|
||||||
a.start = LV_VER_RES / 2;
|
a.start = LV_VER_RES / 2;
|
||||||
a.end = 0;
|
a.end = 0;
|
||||||
a.fp = (lv_anim_fp_t) lv_obj_set_y;
|
a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_y;
|
||||||
a.end_cb = NULL;
|
a.ready_cb = NULL;
|
||||||
a.time = 200;
|
a.time = 200;
|
||||||
lv_anim_create(&a);
|
lv_anim_create(&a);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user