Merge branch 'indev_runtime' into dev-6.0

This commit is contained in:
Gabor Kiss-Vamosi
2019-04-04 07:10:43 +02:00
19 changed files with 578 additions and 401 deletions

View File

@@ -40,7 +40,7 @@
/*Default screen refresh period in milliseconds. LittlevGL will redraw the screen with this period*/
#ifndef LV_REFR_PERIOD
#define LV_REFR_PERIOD 30 /*[ms]*/
#define LV_DISP_DEF_REFR_PERIOD 30 /*[ms]*/
#endif
/* Dot Per Inch: used to initialize default sizes. E.g. a button with width = LV_DPI / 2 -> half inch wide
@@ -106,22 +106,22 @@
/*Input device settings*/
#ifndef LV_INDEV_READ_PERIOD
#define LV_INDEV_READ_PERIOD 30 /*Input device read period in milliseconds*/
#define LV_INDEV_DEF_READ_PERIOD 30 /*Input device read period in milliseconds*/
#endif
#ifndef LV_INDEV_POINT_MARKER
#define LV_INDEV_POINT_MARKER 0 /*Mark the pressed points (required: LV_USE_REAL_DRAW = 1)*/
#endif
#ifndef LV_INDEV_DRAG_LIMIT
#define LV_INDEV_DRAG_LIMIT 10 /*Drag threshold in pixels */
#define LV_INDEV_DEF_DRAG_LIMIT 10 /*Drag threshold in pixels */
#endif
#ifndef LV_INDEV_DRAG_THROW
#define LV_INDEV_DRAG_THROW 20 /*Drag throw slow-down in [%]. Greater value means faster slow-down */
#define LV_INDEV_DEF_DRAG_THROW 20 /*Drag throw slow-down in [%]. Greater value means faster slow-down */
#endif
#ifndef LV_INDEV_LONG_PRESS_TIME
#define LV_INDEV_LONG_PRESS_TIME 400 /*Long press time in milliseconds*/
#define LV_INDEV_DEF_LONG_PRESS_TIME 400 /*Long press time in milliseconds*/
#endif
#ifndef LV_INDEV_LONG_PRESS_REP_TIME
#define LV_INDEV_LONG_PRESS_REP_TIME 100 /*Repeated trigger period in long press [ms] */
#define LV_INDEV_DEF_LONG_PRESS_REP_TIME 100 /*Repeated trigger period in long press [ms] */
#endif
/*Text settings*/
@@ -346,7 +346,7 @@
#endif
#if LV_USE_LABEL != 0
#ifndef LV_LABEL_SCROLL_SPEED
# define LV_LABEL_SCROLL_SPEED 25 /*Hor, or ver. scroll speed [px/sec] in 'LV_LABEL_LONG_SCROLL/ROLL' mode*/
# define LV_LABEL_DEF_SCROLL_SPEED 25 /*Hor, or ver. scroll speed [px/sec] in 'LV_LABEL_LONG_SCROLL/ROLL' mode*/
#endif
#endif
@@ -398,7 +398,7 @@
#endif
# if LV_USE_TABVIEW != 0
#ifndef LV_TABVIEW_ANIM_TIME
# define LV_TABVIEW_ANIM_TIME 300 /*Time of slide animation [ms] (0: no animation)*/
# define LV_TABVIEW_DEF_ANIM_TIME 300 /*Time of slide animation [ms] (0: no animation)*/
#endif
#endif
@@ -408,7 +408,7 @@
#endif
#if LV_USE_TILEVIEW
#ifndef LV_TILEVIEW_ANIM_TIME
# define LV_TILEVIEW_ANIM_TIME 300 /*Time of slide animation [ms] (0: no animation)*/
# define LV_TILEVIEW_DEF_ANIM_TIME 300 /*Time of slide animation [ms] (0: no animation)*/
#endif
#endif
@@ -547,7 +547,7 @@
#endif
#if LV_USE_LIST != 0
#ifndef LV_LIST_FOCUS_TIME
# define LV_LIST_FOCUS_TIME 100 /*Default animation time of focusing to a list element [ms] (0: no animation) */
# define LV_LIST_DEF_ANIM_TIME 100 /*Default animation time of focusing to a list element [ms] (0: no animation) */
#endif
#endif
@@ -557,7 +557,7 @@
#endif
#if LV_USE_DDLIST != 0
#ifndef LV_DDLIST_ANIM_TIME
# define LV_DDLIST_ANIM_TIME 200 /*Open and close default animation time [ms] (0: no animation)*/
# define LV_DDLIST_DEF_ANIM_TIME 200 /*Open and close default animation time [ms] (0: no animation)*/
#endif
#endif
@@ -567,7 +567,7 @@
#endif
#if LV_USE_ROLLER != 0
#ifndef LV_ROLLER_ANIM_TIME
# define LV_ROLLER_ANIM_TIME 200 /*Focus animation time [ms] (0: no animation)*/
# define LV_ROLLER_DEF_ANIM_TIME 200 /*Focus animation time [ms] (0: no animation)*/
#endif
#ifndef LV_ROLLER_INF_PAGES
# define LV_ROLLER_INF_PAGES 7 /*With inifinite rollers the options are added multiple times (on select positioned back to the center)*/

View File

@@ -7,6 +7,7 @@
* INCLUDES
*********************/
#include "lv_disp.h"
#include "../lv_misc/lv_math.h"
/*********************
* DEFINES
@@ -113,23 +114,63 @@ void lv_disp_assign_screen(lv_disp_t * disp, lv_obj_t * scr)
}
/**
* Get the a pointer to the screen refresher task.
* It's parameters can be modified with `lv_task_...` functions,
* Get a pointer to the screen refresher task to
* modify its parameters with `lv_task_...` functions.
* @param disp pointer to a display
* @return pointer to the display refresher task. (NULL on error)
*/
lv_task_t * lv_disp_get_refr_task(lv_disp_t * disp)
{
if(!disp) disp = lv_disp_get_default();
if(!disp) {
LV_LOG_WARN("lv_disp_get_refr_task: no display registered to get its top layer");
LV_LOG_WARN("lv_disp_get_refr_task: no display registered");
return NULL;
}
return disp->refr_task;
}
/**
* Get elapsed time since last user activity on a display (e.g. click)
* @param disp pointer to an display (NULL to get the overall smallest inactivity)
* @return elapsed ticks (milliseconds) since the last activity
*/
uint32_t lv_disp_get_inactive_time(const lv_disp_t * disp)
{
if(!disp) disp = lv_disp_get_default();
if(!disp) {
LV_LOG_WARN("lv_disp_get_inactive_time: no display registered");
return 0;
}
if(disp) return lv_tick_elaps(disp->last_activity_time);
lv_disp_t * d;
uint32_t t = UINT32_MAX;
d = lv_disp_get_next(NULL);
while(d) {
t = LV_MATH_MIN(t, lv_tick_elaps(d->last_activity_time));
d = lv_disp_get_next(d);
}
return t;
}
/**
* Manually trigger an activity on a display
* @param disp pointer to an display (NULL to use the default display)
*/
void lv_disp_trig_activity(lv_disp_t * disp)
{
if(!disp) disp = lv_disp_get_default();
if(!disp) {
LV_LOG_WARN("lv_disp_trig_activity: no display registered");
return;
}
disp->last_activity_time = lv_tick_get();
}
/**********************
* STATIC FUNCTIONS
**********************/

View File

@@ -63,13 +63,26 @@ lv_obj_t * lv_disp_get_layer_sys(lv_disp_t * disp);
void lv_disp_assign_screen(lv_disp_t * disp, lv_obj_t * scr);
/**
* Get the a pointer to the screen refresher task.
* It's parameters can be modified with `lv_task_...` functions,
* Get a pointer to the screen refresher task to
* modify its parameters with `lv_task_...` functions.
* @param disp pointer to a display
* @return pointer to the display refresher task. (NULL on error)
*/
lv_task_t * lv_disp_get_refr_task(lv_disp_t * disp) ;
/**
* Get elapsed time since last user activity on a display (e.g. click)
* @param disp pointer to an display (NULL to get the overall smallest inactivity)
* @return elapsed ticks (milliseconds) since the last activity
*/
uint32_t lv_disp_get_inactive_time(const lv_disp_t * disp);
/**
* Manually trigger an activity on a display
* @param disp pointer to an display (NULL to use the default display)
*/
void lv_disp_trig_activity(lv_disp_t * disp);
/*------------------------------------------------
* To improve backward compatibility
* Recommended only if you have one display

View File

@@ -20,7 +20,7 @@
* DEFINES
*********************/
#if LV_INDEV_DRAG_THROW <= 0
#if LV_INDEV_DEF_DRAG_THROW <= 0
#warning "LV_INDEV_DRAG_THROW must be greater than 0"
#endif
@@ -32,8 +32,6 @@
* STATIC PROTOTYPES
**********************/
#if LV_INDEV_READ_PERIOD != 0
static void indev_proc_task(void * param);
static void indev_pointer_proc(lv_indev_t * i, lv_indev_data_t * data);
static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data);
static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data);
@@ -44,7 +42,6 @@ static void indev_proc_reset_query_handler(lv_indev_t * indev);
static lv_obj_t * indev_search_obj(const lv_indev_proc_t * proc, lv_obj_t * obj);
static void indev_drag(lv_indev_proc_t * state);
static void indev_drag_throw(lv_indev_proc_t * proc);
#endif
/**********************
* STATIC VARIABLES
@@ -64,13 +61,61 @@ static lv_indev_t * indev_act;
*/
void lv_indev_init(void)
{
#if LV_INDEV_READ_PERIOD != 0
lv_task_create(indev_proc_task, LV_INDEV_READ_PERIOD, LV_TASK_PRIO_MID, NULL);
#endif
lv_indev_reset(NULL); /*Reset all input devices*/
}
/**
* Called periodically to read the input devices
* @param param pointer to and input device to read
*/
void lv_indev_read_task(void * param)
{
LV_LOG_TRACE("indev read task started");
lv_indev_data_t data;
indev_act = param;
/*Read and process all indevs*/
if(indev_act->driver.disp == NULL) return; /*Not assigned to any displays*/
/*Handle reset query before processing the point*/
indev_proc_reset_query_handler(indev_act);
if(indev_act->proc.disabled) return;
bool more_to_read;
do {
/*Read the data*/
more_to_read = lv_indev_read(indev_act, &data);
/*The active object might deleted even in the read function*/
indev_proc_reset_query_handler(indev_act);
indev_act->proc.state = data.state;
if(indev_act->proc.state == LV_INDEV_STATE_PR) {
indev_act->driver.disp->last_activity_time = lv_tick_get();
}
if(indev_act->driver.type == LV_INDEV_TYPE_POINTER) {
indev_pointer_proc(indev_act, &data);
} else if(indev_act->driver.type == LV_INDEV_TYPE_KEYPAD) {
indev_keypad_proc(indev_act, &data);
} else if(indev_act->driver.type == LV_INDEV_TYPE_ENCODER) {
indev_encoder_proc(indev_act, &data);
} else if(indev_act->driver.type == LV_INDEV_TYPE_BUTTON) {
indev_button_proc(indev_act, &data);
}
/*Handle reset query if it happened in during processing*/
indev_proc_reset_query_handler(indev_act);
} while(more_to_read);
/*End of indev processing, so no act indev*/
indev_act = NULL;
LV_LOG_TRACE("indev read task finished");
}
/**
* Get the currently processed input device. Can be used in action functions too.
* @return pointer to the currently processed input device or NULL if no input device processing right now
@@ -99,10 +144,10 @@ void lv_indev_reset(lv_indev_t * indev)
{
if(indev) indev->proc.reset_query = 1;
else {
lv_indev_t * i = lv_indev_next(NULL);
lv_indev_t * i = lv_indev_get_next(NULL);
while(i) {
i->proc.reset_query = 1;
i = lv_indev_next(i);
i = lv_indev_get_next(i);
}
}
}
@@ -178,7 +223,7 @@ void lv_indev_set_button_points(lv_indev_t * indev, const lv_point_t * points)
*/
void lv_indev_set_feedback(lv_indev_t *indev, lv_indev_feedback_t feedback)
{
indev->feedback = feedback;
indev->feedback = feedback;
}
/**
@@ -242,29 +287,6 @@ void lv_indev_get_vect(const lv_indev_t * indev, lv_point_t * point)
}
}
/**
* Get elapsed time since last press
* @param indev pointer to an input device (NULL to get the overall smallest inactivity)
* @return Elapsed ticks (milliseconds) since last press
*/
uint32_t lv_indev_get_inactive_time(const lv_indev_t * indev)
{
uint32_t t;
if(indev) return t = lv_tick_elaps(indev->last_activity_time);
lv_indev_t * i;
t = UINT16_MAX;
i = lv_indev_next(NULL);
while(i) {
t = LV_MATH_MIN(t, lv_tick_elaps(i->last_activity_time));
i = lv_indev_next(i);
}
return t;
}
/**
* Get feedback callback for indev.
* @param indev pointer to an input device
@@ -272,7 +294,7 @@ uint32_t lv_indev_get_inactive_time(const lv_indev_t * indev)
*/
lv_indev_feedback_t lv_indev_get_feedback(const lv_indev_t *indev)
{
return indev->feedback;
return indev->feedback;
}
/**
@@ -284,67 +306,26 @@ void lv_indev_wait_release(lv_indev_t * indev)
indev->proc.wait_until_release = 1;
}
/**
* Get a pointer to the indev read task to
* modify its parameters with `lv_task_...` functions.
* @param indev pointer to an input device
* @return pointer to the indev read refresher task. (NULL on error)
*/
lv_task_t * lv_indev_get_read_task(lv_disp_t * indev)
{
if(!indev) {
LV_LOG_WARN("lv_indev_get_read_task: indev was NULL");
return NULL;
}
return indev->refr_task;
}
/**********************
* STATIC FUNCTIONS
**********************/
#if LV_INDEV_READ_PERIOD != 0
/**
* Called periodically to handle the input devices
* @param param unused
*/
static void indev_proc_task(void * param)
{
(void)param;
LV_LOG_TRACE("indev task started");
lv_indev_data_t data;
lv_indev_t * i;
i = lv_indev_next(NULL);
/*Read and process all indevs*/
while(i) {
if(i->driver.disp == NULL) continue; /*Not assigned to any displays*/
indev_act = i;
/*Handle reset query before processing the point*/
indev_proc_reset_query_handler(i);
if(i->proc.disabled == 0) {
bool more_to_read;
do {
/*Read the data*/
more_to_read = lv_indev_read(i, &data);
indev_proc_reset_query_handler(i); /*The active object might deleted even in the read function*/
i->proc.state = data.state;
if(i->proc.state == LV_INDEV_STATE_PR) {
i->last_activity_time = lv_tick_get();
}
if(i->driver.type == LV_INDEV_TYPE_POINTER) {
indev_pointer_proc(i, &data);
} else if(i->driver.type == LV_INDEV_TYPE_KEYPAD) {
indev_keypad_proc(i, &data);
} else if(i->driver.type == LV_INDEV_TYPE_ENCODER) {
indev_encoder_proc(i, &data);
} else if(i->driver.type == LV_INDEV_TYPE_BUTTON) {
indev_button_proc(i, &data);
}
/*Handle reset query if it happened in during processing*/
indev_proc_reset_query_handler(i);
} while(more_to_read);
}
i = lv_indev_next(i); /*Go to the next indev*/
}
indev_act = NULL; /*End of indev processing, so no act indev*/
LV_LOG_TRACE("indev task finished");
}
/**
* Process a new point from LV_INDEV_TYPE_POINTER input device
* @param i pointer to an input device
@@ -355,7 +336,7 @@ static void indev_pointer_proc(lv_indev_t * i, lv_indev_data_t * data)
/*Move the cursor if set and moved*/
if(i->cursor != NULL &&
(i->proc.types.pointer.last_point.x != data->point.x ||
i->proc.types.pointer.last_point.y != data->point.y)) {
i->proc.types.pointer.last_point.y != data->point.y)) {
lv_obj_set_pos(i->cursor, data->point.x, data->point.y);
}
@@ -444,7 +425,7 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
else if(data->state == LV_INDEV_STATE_PR && prev_state == LV_INDEV_STATE_PR)
{
/*Long press time has elapsed?*/
if(i->proc.long_pr_sent == 0 && lv_tick_elaps(i->proc.pr_timestamp) > LV_INDEV_LONG_PRESS_TIME) {
if(i->proc.long_pr_sent == 0 && lv_tick_elaps(i->proc.pr_timestamp) > i->driver.long_press_time) {
i->proc.long_pr_sent = 1;
if(data->key == LV_GROUP_KEY_ENTER) {
i->proc.longpr_rep_timestamp = lv_tick_get();
@@ -455,7 +436,7 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
}
}
/*Long press repeated time has elapsed?*/
else if(i->proc.long_pr_sent != 0 && lv_tick_elaps(i->proc.longpr_rep_timestamp) > LV_INDEV_LONG_PRESS_REP_TIME) {
else if(i->proc.long_pr_sent != 0 && lv_tick_elaps(i->proc.longpr_rep_timestamp) > i->driver.long_press_rep_time) {
i->proc.longpr_rep_timestamp = lv_tick_get();
@@ -583,7 +564,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
/*Pressing*/
else if(data->state == LV_INDEV_STATE_PR && i->proc.types.keypad.last_state == LV_INDEV_STATE_PR) {
if(i->proc.long_pr_sent == 0 &&
lv_tick_elaps(i->proc.pr_timestamp) > LV_INDEV_LONG_PRESS_TIME)
lv_tick_elaps(i->proc.pr_timestamp) > i->driver.long_press_time)
{
bool editable = false;
focused->signal_cb(focused, LV_SIGNAL_GET_EDITABLE, &editable);
@@ -800,7 +781,7 @@ static void indev_proc_press(lv_indev_proc_t * proc)
/*If there is no drag then check for long press time*/
if(proc->types.pointer.drag_in_prog == 0 && proc->long_pr_sent == 0) {
/*Send a signal about the long press if enough time elapsed*/
if(lv_tick_elaps(proc->pr_timestamp) > LV_INDEV_LONG_PRESS_TIME) {
if(lv_tick_elaps(proc->pr_timestamp) > indev_act->driver.long_press_time) {
pr_obj->signal_cb(pr_obj, LV_SIGNAL_LONG_PRESS, indev_act);
if(proc->reset_query) return; /*The object might be deleted*/
lv_event_send(pr_obj, LV_EVENT_LONG_PRESSED, NULL);
@@ -816,7 +797,7 @@ static void indev_proc_press(lv_indev_proc_t * proc)
/*Send long press repeated signal*/
if(proc->types.pointer.drag_in_prog == 0 && proc->long_pr_sent == 1) {
/*Send a signal about the long press repeate if enough time elapsed*/
if(lv_tick_elaps(proc->longpr_rep_timestamp) > LV_INDEV_LONG_PRESS_REP_TIME) {
if(lv_tick_elaps(proc->longpr_rep_timestamp) > indev_act->driver.long_press_rep_time) {
pr_obj->signal_cb(pr_obj, LV_SIGNAL_LONG_PRESS_REP, indev_act);
if(proc->reset_query) return; /*The object might be deleted*/
lv_event_send(pr_obj, LV_EVENT_LONG_PRESSED_REPEAT, NULL);
@@ -1030,8 +1011,8 @@ static void indev_drag(lv_indev_proc_t * state)
/*Enough move?*/
if(state->types.pointer.drag_limit_out == 0) {
/*If a move is greater then LV_DRAG_LIMIT then begin the drag*/
if(LV_MATH_ABS(state->types.pointer.drag_sum.x) >= LV_INDEV_DRAG_LIMIT ||
LV_MATH_ABS(state->types.pointer.drag_sum.y) >= LV_INDEV_DRAG_LIMIT) {
if(LV_MATH_ABS(state->types.pointer.drag_sum.x) >= indev_act->driver.drag_limit ||
LV_MATH_ABS(state->types.pointer.drag_sum.y) >= indev_act->driver.drag_limit) {
state->types.pointer.drag_limit_out = 1;
}
}
@@ -1108,8 +1089,8 @@ static void indev_drag_throw(lv_indev_proc_t * proc)
}
/*Reduce the vectors*/
proc->types.pointer.drag_throw_vect.x = proc->types.pointer.drag_throw_vect.x * (100 - LV_INDEV_DRAG_THROW) / 100;
proc->types.pointer.drag_throw_vect.y = proc->types.pointer.drag_throw_vect.y * (100 - LV_INDEV_DRAG_THROW) / 100;
proc->types.pointer.drag_throw_vect.x = proc->types.pointer.drag_throw_vect.x * (100 - indev_act->driver.drag_throw) / 100;
proc->types.pointer.drag_throw_vect.y = proc->types.pointer.drag_throw_vect.y * (100 - indev_act->driver.drag_throw) / 100;
if(proc->types.pointer.drag_throw_vect.x != 0 ||
proc->types.pointer.drag_throw_vect.y != 0) {
@@ -1144,4 +1125,3 @@ static void indev_drag_throw(lv_indev_proc_t * proc)
}
}
#endif

View File

@@ -34,6 +34,12 @@ extern "C" {
*/
void lv_indev_init(void);
/**
* Called periodically to read the input devices
* @param param pointer to and input device to read
*/
void lv_indev_read_task(void * param);
/**
* Get the currently processed input device. Can be used in action functions too.
* @return pointer to the currently processed input device or NULL if no input device processing right now
@@ -125,12 +131,6 @@ bool lv_indev_is_dragging(const lv_indev_t * indev);
* @param point pointer to a point to store the vector
*/
void lv_indev_get_vect(const lv_indev_t * indev, lv_point_t * point);
/**
* Get elapsed time since last press
* @param indev pointer to an input device (NULL to get the overall smallest inactivity)
* @return Elapsed ticks (milliseconds) since last press
*/
uint32_t lv_indev_get_inactive_time(const lv_indev_t * indev);
/**
* Get feedback callback for indev.
@@ -145,6 +145,14 @@ lv_indev_feedback_t lv_indev_get_feedback(const lv_indev_t *indev);
*/
void lv_indev_wait_release(lv_indev_t * indev);
/**
* Get a pointer to the indev read task to
* modify its parameters with `lv_task_...` functions.
* @param indev pointer to an inout device
* @return pointer to the indev read refresher task. (NULL on error)
*/
lv_task_t * lv_indev_get_read_task(lv_disp_t * indev);
/**********************
* MACROS
**********************/

View File

@@ -386,7 +386,7 @@ lv_res_t lv_obj_del(lv_obj_t * obj)
/* Reset all input devices if
* the object to delete is used*/
lv_indev_t * indev = lv_indev_next(NULL);
lv_indev_t * indev = lv_indev_get_next(NULL);
while(indev) {
if(indev->proc.types.pointer.act_obj == obj || indev->proc.types.pointer.last_obj == obj) {
lv_indev_reset(indev);
@@ -397,7 +397,7 @@ lv_res_t lv_obj_del(lv_obj_t * obj)
lv_indev_reset(indev);
}
#endif
indev = lv_indev_next(indev);
indev = lv_indev_get_next(indev);
}
/* All children deleted.
@@ -2056,7 +2056,7 @@ static void delete_children(lv_obj_t * obj)
/* Reset the input devices if
* the object to delete is used*/
lv_indev_t * indev = lv_indev_next(NULL);
lv_indev_t * indev = lv_indev_get_next(NULL);
while(indev) {
if(indev->proc.types.pointer.act_obj == obj || indev->proc.types.pointer.last_obj == obj) {
lv_indev_reset(indev);
@@ -2066,7 +2066,7 @@ static void delete_children(lv_obj_t * obj)
lv_indev_reset(indev);
}
#endif
indev = lv_indev_next(indev);
indev = lv_indev_get_next(indev);
}
/*Remove the object from parent's children list*/

View File

@@ -138,7 +138,7 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)
disp_def = disp_def_tmp; /*Revert the default display*/
/*Create a refresh task*/
disp->refr_task = lv_task_create(lv_disp_refr_task, LV_REFR_PERIOD, LV_TASK_PRIO_MID, disp);
disp->refr_task = lv_task_create(lv_disp_refr_task, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, disp);
lv_mem_assert(disp->refr_task);
if(disp->refr_task == NULL) return NULL;
@@ -147,6 +147,21 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)
return disp;
}
/**
* Update the driver in run time.
* @param disp pointer to a display. (return value of `lv_disp_drv_register`)
* @param new_drv pointer to the new driver
*/
void lv_disp_drv_update(lv_disp_t * disp, lv_disp_drv_t * new_drv)
{
memcpy(&disp->driver, new_drv, sizeof(lv_disp_drv_t));
lv_obj_t * scr;
LV_LL_READ(disp->scr_ll, scr) {
lv_obj_set_size(scr, lv_disp_get_hor_res(disp), lv_disp_get_ver_res(disp));
}
}
/**
* Remove a display
* @param disp pointer to display
@@ -158,12 +173,12 @@ void lv_disp_remove(lv_disp_t * disp)
/*Detach the input devices */
lv_indev_t * indev;
indev = lv_indev_next(NULL);
indev = lv_indev_get_next(NULL);
while(indev) {
if(indev->driver.disp == disp) {
indev->driver.disp = NULL;
}
indev = lv_indev_next(indev);
indev = lv_indev_get_next(indev);
}
lv_ll_rem(&LV_GC_ROOT(_lv_disp_ll), disp);
@@ -172,20 +187,6 @@ void lv_disp_remove(lv_disp_t * disp)
if(was_default) lv_disp_set_default(lv_ll_get_head(&LV_GC_ROOT(_lv_disp_ll)));
}
/**
* Update the driver in run time.
* @param disp Pointer toa display. (return value of `lv_disp_drv_register`)
* @param new_drv pointer to the new driver
*/
void lv_disp_update_drv(lv_disp_t * disp, lv_disp_drv_t * new_drv)
{
memcpy(&disp->driver, new_drv, sizeof(lv_disp_drv_t));
lv_obj_t * scr;
LV_LL_READ(disp->scr_ll, scr) {
lv_obj_set_size(scr, lv_disp_get_hor_res(disp), lv_disp_get_ver_res(disp));
}
}
/**
* Set a default screen. The new screens will be created on it by default.
@@ -248,6 +249,7 @@ bool lv_disp_get_antialiasing(lv_disp_t * disp)
#endif
}
/**
* Call in the display driver's `flush_cb` function when the flushing is finished
* @param disp_drv pointer to display driver in `flush_cb` where this function is called

View File

@@ -129,6 +129,9 @@ typedef struct _disp_t {
lv_area_t inv_areas[LV_INV_BUF_SIZE];
uint8_t inv_area_joined[LV_INV_BUF_SIZE];
uint32_t inv_p :10;
/*Miscellaneous data*/
uint32_t last_activity_time;
} lv_disp_t;
/**********************
@@ -169,6 +172,13 @@ void lv_disp_buf_init(lv_disp_buf_t * disp_buf, void * buf1, void * buf2, uint32
*/
lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver);
/**
* Update the driver in run time.
* @param disp pointer to a display. (return value of `lv_disp_drv_register`)
* @param new_drv pointer to the new driver
*/
void lv_disp_drv_update(lv_disp_t * disp, lv_disp_drv_t * new_drv);
/**
* Remove a display
* @param disp pointer to display

View File

@@ -9,6 +9,7 @@
* INCLUDES
*********************/
#include "../lv_hal/lv_hal_indev.h"
#include "../lv_core/lv_indev.h"
#include "../lv_misc/lv_mem.h"
#include "../lv_misc/lv_gc.h"
#include "lv_hal_disp.h"
@@ -53,6 +54,10 @@ void lv_indev_drv_init(lv_indev_drv_t * driver)
memset(driver, 0, sizeof(lv_indev_drv_t));
driver->type = LV_INDEV_TYPE_NONE;
driver->drag_limit = LV_INDEV_DEF_DRAG_LIMIT;
driver->drag_throw = LV_INDEV_DEF_DRAG_THROW;
driver->long_press_time = LV_INDEV_DEF_LONG_PRESS_TIME;
driver->long_press_rep_time = LV_INDEV_DEF_LONG_PRESS_REP_TIME;
}
/**
@@ -70,21 +75,33 @@ lv_indev_t * lv_indev_drv_register(lv_indev_drv_t * driver)
return NULL;
}
lv_indev_t * node = lv_ll_ins_head(&LV_GC_ROOT(_lv_indev_ll));
if(!node) {
lv_mem_assert(node);
lv_indev_t * indev = lv_ll_ins_head(&LV_GC_ROOT(_lv_indev_ll));
if(!indev) {
lv_mem_assert(indev);
return NULL;
}
memset(node, 0, sizeof(lv_indev_t));
memcpy(&node->driver, driver, sizeof(lv_indev_drv_t));
memset(indev, 0, sizeof(lv_indev_t));
memcpy(&indev->driver, driver, sizeof(lv_indev_drv_t));
node->proc.reset_query = 1;
node->cursor = NULL;
node->group = NULL;
node->btn_points = NULL;
indev->proc.reset_query = 1;
indev->cursor = NULL;
indev->group = NULL;
indev->btn_points = NULL;
return node;
indev->driver.read_task = lv_task_create(lv_indev_read_task, LV_INDEV_DEF_READ_PERIOD, LV_TASK_PRIO_MID, indev);
return indev;
}
/**
* Update the driver in run time.
* @param indev pointer to a input device. (return value of `lv_indev_drv_register`)
* @param new_drv pointer to the new driver
*/
void lv_indev_drv_update(lv_indev_t * indev, lv_indev_drv_t * new_drv)
{
memcpy(&indev->driver, new_drv, sizeof(lv_indev_drv_t));
}
/**
@@ -92,7 +109,7 @@ lv_indev_t * lv_indev_drv_register(lv_indev_drv_t * driver)
* @param indev pointer to the current input device. NULL to initialize.
* @return the next input devise or NULL if no more. Give the first input device when the parameter is NULL
*/
lv_indev_t * lv_indev_next(lv_indev_t * indev)
lv_indev_t * lv_indev_get_next(lv_indev_t * indev)
{
if(indev == NULL) return lv_ll_get_head(&LV_GC_ROOT(_lv_indev_ll));
else return lv_ll_get_next(&LV_GC_ROOT(_lv_indev_ll), indev);

View File

@@ -24,6 +24,7 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
#include "../lv_misc/lv_area.h"
#include "../lv_misc/lv_task.h"
/*********************
* DEFINES
@@ -68,17 +69,38 @@ typedef struct {
/*Initialized by the user and registered by 'lv_indev_add()'*/
typedef struct _lv_indev_drv_t {
lv_indev_type_t type; /*Input device type*/
bool (*read_cb)(struct _lv_indev_drv_t * indev_drv, lv_indev_data_t *data); /*Function pointer to read_cb data. Return 'true' if there is still data to be read_cb (buffered)*/
/*Input device type*/
lv_indev_type_t type;
/*Function pointer to read_cb data. Return 'true' if there is still data to be read_cb (buffered)*/
bool (*read_cb)(struct _lv_indev_drv_t * indev_drv, lv_indev_data_t *data);
#if LV_USE_USER_DATA_MULTI
lv_indev_drv_user_data_t read_user_data; /*Pointer to user defined data, passed in 'lv_indev_data_t' on read*/
lv_indev_drv_user_data_t read_user_data;
#endif
#if LV_USE_USER_DATA_SINGLE
lv_indev_drv_user_data_t user_data;
#endif
struct _disp_t * disp; /*Pointer to the assigned display*/
/*Pointer to the assigned display*/
struct _disp_t * disp;
/*Task to read the periodically read the input device*/
lv_task_t * read_task;
/*Number of pixels to slide before actually drag the object*/
uint8_t drag_limit;
/*Drag throw slow-down in [%]. Greater value means faster slow-down */
uint8_t drag_throw;
/*Long press time in milliseconds*/
uint16_t long_press_time;
/*Repeated trigger period in long press [ms] */
uint16_t long_press_rep_time;
} lv_indev_drv_t;
@@ -90,7 +112,7 @@ typedef struct _lv_indev_proc_t {
lv_point_t act_point;
lv_point_t last_point;
lv_point_t vect;
lv_point_t drag_sum; /*Count the dragged pixels to check LV_INDEV_DRAG_LIMIT*/
lv_point_t drag_sum; /*Count the dragged pixels to check LV_INDEV_DEF_DRAG_LIMIT*/
lv_point_t drag_throw_vect;
struct _lv_obj_t * act_obj; /*The object being pressed*/
struct _lv_obj_t * last_obj; /*The last obejct which was pressed (used by dragthrow and other post-release event)*/
@@ -126,7 +148,6 @@ typedef struct _lv_indev_t {
lv_indev_drv_t driver;
lv_indev_proc_t proc;
lv_indev_feedback_t feedback;
uint32_t last_activity_time;
struct _lv_obj_t *cursor; /*Cursor for LV_INPUT_TYPE_POINTER*/
struct _lv_group_t *group; /*Keypad destination group*/
const lv_point_t * btn_points; /*Array points assigned to the button ()screen will be pressed here by the buttons*/
@@ -151,12 +172,19 @@ void lv_indev_drv_init(lv_indev_drv_t *driver);
*/
lv_indev_t * lv_indev_drv_register(lv_indev_drv_t *driver);
/**
* Update the driver in run time.
* @param indev pointer to a input device. (return value of `lv_indev_drv_register`)
* @param new_drv pointer to the new driver
*/
void lv_indev_drv_update(lv_indev_t * indev, lv_indev_drv_t * new_drv);
/**
* Get the next input device.
* @param indev pointer to the current input device. NULL to initialize.
* @return the next input devise or NULL if no more. Give the first input device when the parameter is NULL
*/
lv_indev_t * lv_indev_next(lv_indev_t * indev);
lv_indev_t * lv_indev_get_next(lv_indev_t * indev);
/**
* Read data from an input device.

View File

@@ -58,7 +58,7 @@ void lv_anim_init(void)
{
lv_ll_init(&LV_GC_ROOT(_lv_anim_ll), sizeof(lv_anim_t));
last_task_run = lv_tick_get();
lv_task_create(anim_task, LV_REFR_PERIOD, LV_TASK_PRIO_MID, NULL);
lv_task_create(anim_task, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, NULL);
}
/**

View File

@@ -24,11 +24,11 @@
*********************/
#if LV_USE_ANIMATION
# ifndef LV_DDLIST_ANIM_TIME
# define LV_DDLIST_ANIM_TIME 200 /*ms*/
# define LV_DDLIST_DEF_ANIM_TIME 200 /*ms*/
# endif
#else
# undef LV_DDLIST_ANIM_TIME
# define LV_DDLIST_ANIM_TIME 0 /*No animation*/
# undef LV_DDLIST_DEF_ANIM_TIME
# define LV_DDLIST_DEF_ANIM_TIME 0 /*No animation*/
#endif
/**********************
@@ -93,7 +93,7 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
ext->sel_opt_id = 0;
ext->sel_opt_id_ori = 0;
ext->option_cnt = 0;
ext->anim_time = LV_DDLIST_ANIM_TIME;
ext->anim_time = LV_DDLIST_DEF_ANIM_TIME;
ext->sel_style = &lv_style_plain_color;
ext->draw_arrow = 0; /*Do not draw arrow by default*/
ext->stay_open = 0;

View File

@@ -20,7 +20,7 @@
*********************/
/*Test configurations*/
#ifndef LV_LABEL_SCROLL_SPEED
#define LV_LABEL_SCROLL_SPEED (25) /*Hor, or ver. scroll speed (px/sec) in 'LV_LABEL_LONG_SCROLL/ROLL' mode*/
#define LV_LABEL_DEF_SCROLL_SPEED (25) /*Hor, or ver. scroll speed (px/sec) in 'LV_LABEL_LONG_SCROLL/ROLL' mode*/
#endif
#define ANIM_WAIT_CHAR_COUNT 3
@@ -87,7 +87,7 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy)
ext->align = LV_LABEL_ALIGN_LEFT;
ext->dot_end = LV_LABEL_DOT_END_INV;
ext->long_mode = LV_LABEL_LONG_EXPAND;
ext->anim_speed = LV_LABEL_SCROLL_SPEED;
ext->anim_speed = LV_LABEL_DEF_SCROLL_SPEED;
ext->offset.x = 0;
ext->offset.y = 0;
ext->selection_start = -1;

View File

@@ -21,11 +21,11 @@
#if LV_USE_ANIMATION
# ifndef LV_LIST_FOCUS_TIME
# define LV_LIST_FOCUS_TIME 100 /*Animation time of focusing to the a list element [ms] (0: no animation) */
# define LV_LIST_DEF_ANIM_TIME 100 /*Animation time of focusing to the a list element [ms] (0: no animation) */
# endif
#else
# undef LV_LIST_FOCUS_TIME
# define LV_LIST_FOCUS_TIME 0 /*No animations*/
# undef LV_LIST_DEF_ANIM_TIME
# define LV_LIST_DEF_ANIM_TIME 0 /*No animations*/
#endif
/**********************
@@ -88,7 +88,7 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
ext->styles_btn[LV_BTN_STATE_TGL_REL] = &lv_style_btn_tgl_rel;
ext->styles_btn[LV_BTN_STATE_TGL_PR] = &lv_style_btn_tgl_pr;
ext->styles_btn[LV_BTN_STATE_INA] = &lv_style_btn_ina;
ext->anim_time = LV_LIST_FOCUS_TIME;
ext->anim_time = LV_LIST_DEF_ANIM_TIME;
ext->single_mode = false;
ext->size = 0;
@@ -643,7 +643,7 @@ void lv_list_up(const lv_obj_t * list)
a.path = lv_anim_path_linear;
a.end_cb = NULL;
a.act_time = 0;
a.time = LV_LIST_FOCUS_TIME;
a.time = LV_LIST_DEF_ANIM_TIME;
a.playback = 0;
a.playback_pause = 0;
a.repeat = 0;
@@ -686,7 +686,7 @@ void lv_list_down(const lv_obj_t * list)
a.path = lv_anim_path_linear;
a.end_cb = NULL;
a.act_time = 0;
a.time = LV_LIST_FOCUS_TIME;
a.time = LV_LIST_DEF_ANIM_TIME;
a.playback = 0;
a.playback_pause = 0;
a.repeat = 0;

View File

@@ -18,11 +18,11 @@
*********************/
#if LV_USE_ANIMATION
# ifndef LV_ROLLER_ANIM_TIME
# define LV_ROLLER_ANIM_TIME 200 /*ms*/
# define LV_ROLLER_DEF_ANIM_TIME 200 /*ms*/
# endif
#else
# undef LV_ROLLER_ANIM_TIME
# define LV_ROLLER_ANIM_TIME 0 /*No animation*/
# undef LV_ROLLER_DEF_ANIM_TIME
# define LV_ROLLER_DEF_ANIM_TIME 0 /*No animation*/
#endif
@@ -88,7 +88,7 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_set_drag(scrl, true); /*In ddlist it might be disabled*/
lv_page_set_scrl_fit2(new_roller, LV_FIT_TIGHT, LV_FIT_NONE); /*Height is specified directly*/
lv_ddlist_open(new_roller, false);
lv_ddlist_set_anim_time(new_roller, LV_ROLLER_ANIM_TIME);
lv_ddlist_set_anim_time(new_roller, LV_ROLLER_DEF_ANIM_TIME);
lv_ddlist_set_stay_open(new_roller, true);
lv_roller_set_visible_row_count(new_roller, 3);
lv_label_set_align(ext->ddlist.label, LV_LABEL_ALIGN_CENTER);

View File

@@ -307,7 +307,7 @@ static lv_res_t lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param)
if(indev) {
lv_point_t p = {0,0};
lv_indev_get_point(indev, &p);
if(LV_MATH_ABS(p.x - ext->start_x) > LV_INDEV_DRAG_LIMIT) ext->slided = 1;
if(LV_MATH_ABS(p.x - ext->start_x) > LV_INDEV_DEF_DRAG_LIMIT) ext->slided = 1;
}
/*If didn't slide then revert the min/max value. So click without slide won't move the switch as a slider*/

View File

@@ -18,11 +18,11 @@
*********************/
#if LV_USE_ANIMATION
# ifndef LV_TABVIEW_ANIM_TIME
# define LV_TABVIEW_ANIM_TIME 300 /*Animation time of focusing to the a list element [ms] (0: no animation) */
# define LV_TABVIEW_DEF_ANIM_TIME 300 /*Animation time of focusing to the a list element [ms] (0: no animation) */
# endif
#else
# undef LV_TABVIEW_ANIM_TIME
# define LV_TABVIEW_ANIM_TIME 0 /*No animations*/
# undef LV_TABVIEW_DEF_ANIM_TIME
# define LV_TABVIEW_DEF_ANIM_TIME 0 /*No animations*/
#endif
/**********************
@@ -91,7 +91,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
ext->indic = NULL;
ext->btns = NULL;
ext->btns_pos = LV_TABVIEW_BTNS_POS_TOP;
ext->anim_time = LV_TABVIEW_ANIM_TIME;
ext->anim_time = LV_TABVIEW_DEF_ANIM_TIME;
ext->btns_hide = 0;
@@ -735,7 +735,7 @@ static void tabpage_pressing_handler(lv_obj_t * tabview, lv_obj_t * tabpage)
lv_coord_t y_diff = point_act.y - ext->point_last.y;
if(!ext->scroll_ver && (x_diff >= LV_INDEV_DRAG_LIMIT || x_diff <= -LV_INDEV_DRAG_LIMIT)) {
if(!ext->scroll_ver && (x_diff >= LV_INDEV_DEF_DRAG_LIMIT || x_diff <= -LV_INDEV_DEF_DRAG_LIMIT)) {
ext->draging = 1;
/*Check if the page is on the edge */
if((lv_page_on_edge(tabpage, LV_PAGE_EDGE_LEFT) && x_diff > 0) ||
@@ -750,7 +750,7 @@ static void tabpage_pressing_handler(lv_obj_t * tabview, lv_obj_t * tabpage)
} else if(ext->drag_hor == 0) {
ext->drag_hor = 0;
}
} else if(y_diff >= LV_INDEV_DRAG_LIMIT || y_diff <= -LV_INDEV_DRAG_LIMIT) {
} else if(y_diff >= LV_INDEV_DEF_DRAG_LIMIT || y_diff <= -LV_INDEV_DEF_DRAG_LIMIT) {
ext->drag_hor = 0;
ext->draging = 1;
ext->scroll_ver = 1;
@@ -795,7 +795,7 @@ static void tabpage_press_lost_handler(lv_obj_t * tabview, lv_obj_t * tabpage)
while(vect.x != 0) {
x_predict += vect.x;
vect.x = vect.x * (100 - LV_INDEV_DRAG_THROW) / 100;
vect.x = vect.x * (100 - LV_INDEV_DEF_DRAG_THROW) / 100;
}
lv_coord_t page_x1 = tabpage->coords.x1 - tabview->coords.x1 + x_predict;

View File

@@ -18,11 +18,11 @@
*********************/
#if LV_USE_ANIMATION
# ifndef LV_TILEVIEW_ANIM_TIME
# define LV_TILEVIEW_ANIM_TIME 300 /*Animation time loading a tile [ms] (0: no animation) */
# define LV_TILEVIEW_DEF_ANIM_TIME 300 /*Animation time loading a tile [ms] (0: no animation) */
# endif
#else
# undef LV_TILEVIEW_ANIM_TIME
# define LV_TILEVIEW_ANIM_TIME 0 /*No animations*/
# undef LV_TILEVIEW_DEF_ANIM_TIME
# define LV_TILEVIEW_DEF_ANIM_TIME 0 /*No animations*/
#endif
/**********************
@@ -77,7 +77,7 @@ lv_obj_t * lv_tileview_create(lv_obj_t * par, const lv_obj_t * copy)
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_func(new_tileview);
/*Initialize the allocated 'ext' */
ext->anim_time = LV_TILEVIEW_ANIM_TIME;
ext->anim_time = LV_TILEVIEW_DEF_ANIM_TIME;
ext->act_id.x = 0;
ext->act_id.y = 0;
ext->valid_pos = NULL;
@@ -361,14 +361,14 @@ static lv_res_t lv_tileview_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void
/*Set horizontal drag constraint if no vertical constraint an dragged to valid x direction */
if(ext->drag_ver == 0 &&
((ext->drag_right_en && indev->proc.types.pointer.drag_sum.x <= -LV_INDEV_DRAG_LIMIT) ||
(ext->drag_left_en && indev->proc.types.pointer.drag_sum.x >= LV_INDEV_DRAG_LIMIT))) {
((ext->drag_right_en && indev->proc.types.pointer.drag_sum.x <= -LV_INDEV_DEF_DRAG_LIMIT) ||
(ext->drag_left_en && indev->proc.types.pointer.drag_sum.x >= LV_INDEV_DEF_DRAG_LIMIT))) {
ext->drag_hor = 1;
}
/*Set vertical drag constraint if no horizontal constraint an dragged to valid y direction */
if(ext->drag_hor == 0 &&
((ext->drag_bottom_en && indev->proc.types.pointer.drag_sum.y <= -LV_INDEV_DRAG_LIMIT) ||
(ext->drag_top_en && indev->proc.types.pointer.drag_sum.y >= LV_INDEV_DRAG_LIMIT))) {
((ext->drag_bottom_en && indev->proc.types.pointer.drag_sum.y <= -LV_INDEV_DEF_DRAG_LIMIT) ||
(ext->drag_top_en && indev->proc.types.pointer.drag_sum.y >= LV_INDEV_DEF_DRAG_LIMIT))) {
ext->drag_ver = 1;
}
@@ -493,7 +493,7 @@ static void drag_end_handler(lv_obj_t * tileview)
while(vect.x != 0) {
predict += vect.x;
vect.x = vect.x * (100 - LV_INDEV_DRAG_THROW) / 100;
vect.x = vect.x * (100 - LV_INDEV_DEF_DRAG_THROW) / 100;
}
p.x -= predict;
@@ -505,7 +505,7 @@ static void drag_end_handler(lv_obj_t * tileview)
while(vect.y != 0) {
predict += vect.y;
vect.y = vect.y * (100 - LV_INDEV_DRAG_THROW) / 100;
vect.y = vect.y * (100 - LV_INDEV_DEF_DRAG_THROW) / 100;
}
p.y -= predict;