fixes for #935
This commit is contained in:
@@ -85,7 +85,7 @@ lv_indev_t * lv_indev_get_act(void)
|
||||
* @param indev pointer to an input device
|
||||
* @return the type of the input device from `lv_hal_indev_type_t` (`LV_INDEV_TYPE_...`)
|
||||
*/
|
||||
lv_hal_indev_type_t lv_indev_get_type(const lv_indev_t * indev)
|
||||
lv_indev_type_t lv_indev_get_type(const lv_indev_t * indev)
|
||||
{
|
||||
if(indev == NULL) return LV_INDEV_TYPE_NONE;
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ lv_indev_t * lv_indev_get_act(void);
|
||||
* @param indev pointer to an input device
|
||||
* @return the type of the input device from `lv_hal_indev_type_t` (`LV_INDEV_TYPE_...`)
|
||||
*/
|
||||
lv_hal_indev_type_t lv_indev_get_type(const lv_indev_t * indev);
|
||||
lv_indev_type_t lv_indev_get_type(const lv_indev_t * indev);
|
||||
|
||||
/**
|
||||
* Reset one or all input devices
|
||||
|
||||
@@ -46,7 +46,7 @@ enum {
|
||||
LV_INDEV_TYPE_BUTTON, /*External (hardware button) which is assinged to a specific point of the screen*/
|
||||
LV_INDEV_TYPE_ENCODER, /*Encoder with only Left, Right turn and a Button*/
|
||||
};
|
||||
typedef uint8_t lv_hal_indev_type_t;
|
||||
typedef uint8_t lv_indev_type_t;
|
||||
|
||||
/*States for input devices*/
|
||||
enum {
|
||||
@@ -68,7 +68,7 @@ typedef struct {
|
||||
|
||||
/*Initialized by the user and registered by 'lv_indev_add()'*/
|
||||
typedef struct _lv_indev_drv_t {
|
||||
lv_hal_indev_type_t type; /*Input device type*/
|
||||
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)*/
|
||||
|
||||
#if LV_USE_USER_DATA_MULTI
|
||||
|
||||
@@ -811,7 +811,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
else if(sign == LV_SIGNAL_FOCUS) {
|
||||
#if LV_USE_GROUP
|
||||
lv_indev_t * indev = lv_indev_get_act();
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(indev);
|
||||
lv_indev_type_t indev_type = lv_indev_get_type(indev);
|
||||
if(indev_type == LV_INDEV_TYPE_POINTER) {
|
||||
/*Select the clicked button*/
|
||||
lv_point_t p1;
|
||||
|
||||
@@ -339,8 +339,9 @@ uint16_t lv_ddlist_get_selected(const lv_obj_t * ddlist)
|
||||
* Get the current selected option as a string
|
||||
* @param ddlist pointer to ddlist object
|
||||
* @param buf pointer to an array to store the string
|
||||
* @param buf_size size of `buf` in bytes. 0: to ignore it.
|
||||
*/
|
||||
void lv_ddlist_get_selected_str(const lv_obj_t * ddlist, char * buf)
|
||||
void lv_ddlist_get_selected_str(const lv_obj_t * ddlist, char * buf, uint16_t buf_size)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
|
||||
@@ -355,7 +356,13 @@ void lv_ddlist_get_selected_str(const lv_obj_t * ddlist, char * buf)
|
||||
}
|
||||
|
||||
uint16_t c;
|
||||
for(c = 0; opt_txt[i] != '\n' && i < txt_len; c++, i++) buf[c] = opt_txt[i];
|
||||
for(c = 0; opt_txt[i] != '\n' && i < txt_len; c++, i++) {
|
||||
if(buf_size && c >= buf_size - 1) {
|
||||
LV_LOG_WARN("lv_ddlist_get_selected_str: the buffer was too small")
|
||||
break;
|
||||
}
|
||||
buf[c] = opt_txt[i];
|
||||
}
|
||||
|
||||
buf[c] = '\0';
|
||||
}
|
||||
@@ -641,7 +648,7 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
|
||||
#if LV_USE_GROUP
|
||||
lv_group_t * g = lv_obj_get_group(ddlist);
|
||||
bool editing = lv_group_get_editing(g);
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
|
||||
/*Encoders need special handling*/
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER) {
|
||||
|
||||
@@ -181,9 +181,9 @@ uint16_t lv_ddlist_get_selected(const lv_obj_t * ddlist);
|
||||
* Get the current selected option as a string
|
||||
* @param ddlist pointer to ddlist object
|
||||
* @param buf pointer to an array to store the string
|
||||
* @param buf_size size of `buf` in bytes. 0: to ignore it.
|
||||
*/
|
||||
void lv_ddlist_get_selected_str(const lv_obj_t * ddlist, char * buf);
|
||||
|
||||
void lv_ddlist_get_selected_str(const lv_obj_t * ddlist, char * buf, uint16_t buf_size);
|
||||
|
||||
/**
|
||||
* Get the fix height value.
|
||||
|
||||
@@ -745,7 +745,7 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
||||
{
|
||||
/*If pressed/released etc by a KEYPAD or ENCODER delegate signal to the button*/
|
||||
lv_indev_t * indev = lv_indev_get_act();
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(indev);
|
||||
lv_indev_type_t indev_type = lv_indev_get_type(indev);
|
||||
if(indev_type == LV_INDEV_TYPE_KEYPAD ||
|
||||
(indev_type == LV_INDEV_TYPE_ENCODER && lv_group_get_editing(lv_obj_get_group(list))))
|
||||
{
|
||||
@@ -783,7 +783,7 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
||||
else if(sign == LV_SIGNAL_FOCUS) {
|
||||
|
||||
#if LV_USE_GROUP
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
/*With ENCODER select the first button only in edit mode*/
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER) {
|
||||
lv_group_t * g = lv_obj_get_group(list);
|
||||
|
||||
@@ -456,7 +456,7 @@ static lv_res_t lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
|
||||
if(sign == LV_SIGNAL_FOCUS) {
|
||||
#if LV_USE_GROUP
|
||||
lv_indev_t * indev = lv_indev_get_act();
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(indev);
|
||||
lv_indev_type_t indev_type = lv_indev_get_type(indev);
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER) {
|
||||
/*In navigation mode don't select any button but in edit mode select the fist*/
|
||||
lv_btnm_ext_t * btnm_ext = lv_obj_get_ext_attr(ext->btnm);
|
||||
|
||||
@@ -170,7 +170,7 @@ void lv_preload_set_style(lv_obj_t * preload, lv_preload_style_t type, lv_style_
|
||||
* @param preload pointer to pre loader object
|
||||
* @param type animation type of the preload
|
||||
* */
|
||||
void lv_preload_set_animation_type(lv_obj_t * preload, lv_preloader_type_t type)
|
||||
void lv_preload_set_animation_type(lv_obj_t * preload, lv_preload_type_t type)
|
||||
{
|
||||
#if LV_USE_ANIMATION
|
||||
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
|
||||
@@ -290,7 +290,7 @@ lv_style_t * lv_preload_get_style(const lv_obj_t * preload, lv_preload_style_t t
|
||||
* @param preload pointer to pre loader object
|
||||
* @return animation type
|
||||
* */
|
||||
lv_preloader_type_t lv_preload_get_animation_type(lv_obj_t * preload)
|
||||
lv_preload_type_t lv_preload_get_animation_type(lv_obj_t * preload)
|
||||
{
|
||||
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
|
||||
return ext->anim_type;
|
||||
|
||||
@@ -45,7 +45,7 @@ enum {
|
||||
LV_PRELOAD_TYPE_SPINNING_ARC,
|
||||
LV_PRELOAD_TYPE_FILLSPIN_ARC,
|
||||
};
|
||||
typedef uint8_t lv_preloader_type_t;
|
||||
typedef uint8_t lv_preload_type_t;
|
||||
|
||||
/*Data of pre loader*/
|
||||
typedef struct {
|
||||
@@ -53,7 +53,7 @@ typedef struct {
|
||||
/*New data for this type */
|
||||
uint16_t arc_length; /*Length of the spinning indicator in degree*/
|
||||
uint16_t time; /*Time of one round*/
|
||||
lv_preloader_type_t anim_type; /*Type of the arc animation*/
|
||||
lv_preload_type_t anim_type; /*Type of the arc animation*/
|
||||
} lv_preload_ext_t;
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ void lv_preload_set_style(lv_obj_t * preload, lv_preload_style_t type, lv_style_
|
||||
* @param preload pointer to pre loader object
|
||||
* @param type animation type of the preload
|
||||
* */
|
||||
void lv_preload_set_animation_type(lv_obj_t * preload, lv_preloader_type_t type);
|
||||
void lv_preload_set_animation_type(lv_obj_t * preload, lv_preload_type_t type);
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
@@ -141,7 +141,7 @@ lv_style_t * lv_preload_get_style(const lv_obj_t * preload, lv_preload_style_t t
|
||||
* @param preload pointer to pre loader object
|
||||
* @return animation type
|
||||
* */
|
||||
lv_preloader_type_t lv_preload_get_animation_type(lv_obj_t * preload);
|
||||
lv_preload_type_t lv_preload_get_animation_type(lv_obj_t * preload);
|
||||
|
||||
/*=====================
|
||||
* Other functions
|
||||
|
||||
@@ -244,16 +244,6 @@ uint16_t lv_roller_get_selected(const lv_obj_t *roller)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current selected option as a string
|
||||
* @param roller pointer to roller object
|
||||
* @param buf pointer to an array to store the string
|
||||
*/
|
||||
void lv_roller_get_selected_str(const lv_obj_t * roller, char * buf)
|
||||
{
|
||||
lv_ddlist_get_selected_str(roller, buf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the align attribute. Default alignment after _create is LV_LABEL_ALIGN_CENTER
|
||||
* @param roller pointer to a roller object
|
||||
@@ -432,7 +422,7 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
|
||||
#if LV_USE_GROUP
|
||||
lv_group_t * g = lv_obj_get_group(roller);
|
||||
bool editing = lv_group_get_editing(g);
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
|
||||
/*Encoders need special handling*/
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER) {
|
||||
|
||||
@@ -137,8 +137,12 @@ uint16_t lv_roller_get_selected(const lv_obj_t *roller);
|
||||
* Get the current selected option as a string
|
||||
* @param roller pointer to roller object
|
||||
* @param buf pointer to an array to store the string
|
||||
* @param buf_size size of `buf` in bytes. 0: to ignore it.
|
||||
*/
|
||||
void lv_roller_get_selected_str(const lv_obj_t * roller, char * buf);
|
||||
static inline void lv_roller_get_selected_str(const lv_obj_t * roller, char * buf, uint16_t buf_size)
|
||||
{
|
||||
lv_ddlist_get_selected_str(roller, buf, buf_size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the align attribute. Default alignment after _create is LV_LABEL_ALIGN_CENTER
|
||||
|
||||
@@ -490,7 +490,7 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
|
||||
/*Leave edit mode if released. (No need to wait for LONG_PRESS) */
|
||||
lv_group_t * g = lv_obj_get_group(slider);
|
||||
bool editing = lv_group_get_editing(g);
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER) {
|
||||
if(editing) lv_group_set_editing(g, false);
|
||||
}
|
||||
|
||||
@@ -358,7 +358,7 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * p
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_CONTROL) {
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
|
||||
uint32_t c = *((uint32_t *)param); /*uint32_t because can be UTF-8*/
|
||||
if(c == LV_GROUP_KEY_RIGHT) {
|
||||
|
||||
@@ -1307,7 +1307,7 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param)
|
||||
cur_type = lv_ta_get_cursor_type(ta);
|
||||
lv_group_t * g = lv_obj_get_group(ta);
|
||||
bool editing = lv_group_get_editing(g);
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
|
||||
/*Encoders need special handling*/
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER) {
|
||||
|
||||
@@ -596,7 +596,7 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p
|
||||
/*If released by a KEYPAD or ENCODER then really the tab buttons should be released.
|
||||
* So simulate a CLICK on the tab buttons*/
|
||||
lv_indev_t * indev = lv_indev_get_act();
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(indev);
|
||||
lv_indev_type_t indev_type = lv_indev_get_type(indev);
|
||||
if(indev_type == LV_INDEV_TYPE_KEYPAD ||
|
||||
(indev_type == LV_INDEV_TYPE_ENCODER && lv_group_get_editing(lv_obj_get_group(tabview))))
|
||||
{
|
||||
@@ -611,7 +611,7 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p
|
||||
}
|
||||
|
||||
if(sign == LV_SIGNAL_FOCUS) {
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
/*With ENCODER select the first button only in edit mode*/
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER) {
|
||||
#if LV_USE_GROUP
|
||||
|
||||
Reference in New Issue
Block a user