App:Library:LVGL:docs:Overview:Input devices
https://docs.lvgl.io/8.2/overview/indev.html
Input devices
英文 | 自動翻訳 |
---|---|
An input device usually means:
Important |
Pointers
Cursor
英文 | 自動翻訳 |
---|---|
Pointer input devices (like a mouse) can have a cursor. ...
lv_indev_t * mouse_indev = lv_indev_drv_register(&indev_drv);
LV_IMG_DECLARE(mouse_cursor_icon); /*Declare the image source.*/
lv_obj_t * cursor_obj = lv_img_create(lv_scr_act()); /*Create an image object for the cursor */
lv_img_set_src(cursor_obj, &mouse_cursor_icon); /*Set the image source*/
lv_indev_set_cursor(mouse_indev, cursor_obj); /*Connect the image object to the driver*/
Note that the cursor object should have |
Gestures
英文 | 自動翻訳 |
---|---|
Pointer input devices can detect basic gestures. By default, most of the widgets send the gestures to its parent, so finally the gestures can be detected on the screen object in a form of an void my_event(lv_event_t * e)
{
lv_obj_t * screen = lv_event_get_current_target(e);
lv_dir_t dir = lv_indev_get_gesture_dir(lv_indev_act());
switch(dir) {
case LV_DIR_LEFT:
...
break;
case LV_DIR_RIGHT:
...
break;
case LV_DIR_TOP:
...
break;
case LV_DIR_BOTTOM:
...
break;
}
}
...
lv_obj_add_event_cb(screen1, my_event, LV_EVENT_GESTURE, NULL);
To prevent passing the gesture event to the parent from an object use Note that, gestures are not triggered if an object is being scrolled. |
Keypad and encoder
英文 | 自動翻訳 |
---|---|
You can fully control the user interface without a touchpad or mouse by using a keypad or encoder(s). It works similar to the TAB key on the PC to select an element in an application or a web page. |
Groups
英文 | 自動翻訳 |
---|---|
Objects you want to control with a keypad or encoder need to be added to a Group. In every group there is exactly one focused object which receives the pressed keys or the encoder actions. For example, if a Text area is focused and you press some letter on a keyboard, the keys will be sent and inserted into the text area. Similarly, if a Slider is focused and you press the left or right arrows, the slider's value will be changed. You need to associate an input device with a group. An input device can send key events to only one group but a group can receive data from more than one input device. To create a group use To associate a group with an input device use |
Keys
英文 | 自動翻訳 |
---|---|
There are some predefined keys which have special meaning:
The most important special keys are Usually, it's enough to use only With an encoder you should use only |
英文 | 自動翻訳 |
---|---|
Since a keypad has plenty of keys, it's easy to navigate between objects and edit them using the keypad. But encoders have a limited number of "keys" and hence it is difficult to navigate using the default options. Navigate and Edit modes are used to avoid this problem with encoders. In Navigate mode, an encoder's In Edit mode, |
Default group
英文 | 自動翻訳 |
---|---|
Interactive widgets - such as buttons, checkboxes, sliders, etc. - can be automatically added to a default group. Just create a group with Don't forget to assign one or more input devices to the default group with |
Styling
英文 | 自動翻訳 |
---|---|
If an object is focused either by clicking it via touchpad or focused via an encoder or keypad it goes to the If an object switches to edit mode it enters the For a more detailed description read the Style section. |
API
Input device
英文 | 自動翻訳 |
---|---|
Functions void lv_indev_read_timer_cb(lv_timer_t *timer)
void lv_indev_enable(lv_indev_t *indev, bool en) lv_indev_t *lv_indev_get_act(void)
lv_indev_type_t lv_indev_get_type(const lv_indev_t *indev)
void lv_indev_reset(lv_indev_t *indev, lv_obj_t *obj)
void lv_indev_reset_long_press(lv_indev_t *indev)
void lv_indev_set_cursor(lv_indev_t *indev, lv_obj_t *cur_obj)
void lv_indev_set_group(lv_indev_t *indev, lv_group_t *group)
void lv_indev_set_button_points(lv_indev_t *indev, const lv_point_t points[])
void lv_indev_get_point(const lv_indev_t *indev, lv_point_t *point)
lv_dir_t lv_indev_get_gesture_dir(const lv_indev_t *indev)
uint32_t lv_indev_get_key(const lv_indev_t *indev)
lv_dir_t lv_indev_get_scroll_dir(const lv_indev_t *indev)
lv_obj_t *lv_indev_get_scroll_obj(const lv_indev_t *indev)
void lv_indev_get_vect(const lv_indev_t *indev, lv_point_t *point)
void lv_indev_wait_release(lv_indev_t *indev)
lv_obj_t *lv_indev_get_obj_act(void)
lv_timer_t *lv_indev_get_read_timer(lv_disp_t *indev)
lv_obj_t *lv_indev_search_obj(lv_obj_t *obj, lv_point_t *point)
|
Groups
英文 | 自動翻訳 |
---|---|
Typedefs typedef uint8_t lv_key_t typedef void (*lv_group_focus_cb_t)(struct _lv_group_t*) typedef struct _lv_group_t lv_group_t
Enums enum [anonymous]
enum lv_group_refocus_policy_t
Functions void _lv_group_init(void)
lv_group_t *lv_group_create(void)
void lv_group_del(lv_group_t *group)
void lv_group_set_default(lv_group_t *group)
lv_group_t *lv_group_get_default(void)
void lv_group_add_obj(lv_group_t *group, struct _lv_obj_t *obj)
void lv_group_swap_obj(struct _lv_obj_t *obj1, struct _lv_obj_t *obj2)
void lv_group_remove_obj(struct _lv_obj_t *obj)
void lv_group_remove_all_objs(lv_group_t *group)
void lv_group_focus_obj(struct _lv_obj_t *obj)
void lv_group_focus_next(lv_group_t *group)
void lv_group_focus_prev(lv_group_t *group)
void lv_group_focus_freeze(lv_group_t *group, bool en)
lv_res_t lv_group_send_data(lv_group_t *group, uint32_t c)
void lv_group_set_focus_cb(lv_group_t *group, lv_group_focus_cb_t focus_cb)
void lv_group_set_refocus_policy(lv_group_t *group, lv_group_refocus_policy_t policy)
void lv_group_set_editing(lv_group_t *group, bool edit)
void lv_group_set_wrap(lv_group_t *group, bool en)
struct _lv_obj_t *lv_group_get_focused(const lv_group_t *group)
lv_group_focus_cb_t lv_group_get_focus_cb(const lv_group_t *group)
bool lv_group_get_editing(const lv_group_t *group)
bool lv_group_get_wrap(lv_group_t *group)
uint32_t lv_group_get_obj_count(lv_group_t *group)
struct _lv_group_t
|