| 
 
新手上路 
 
	积分29金钱29 注册时间2020-4-8在线时间7 小时 | 
 
 发表于 2020-6-30 14:20:34
|
显示全部楼层 
| Keypad and encoder You can fully control the user interface without touchpad or mouse using a keypad or encoder(s). It works similar to the TAB key on the PC to select the element in an application or a web page.
 
 Groups
 The objects, you want to control with keypad or encoder, needs 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 the keys to only one group but, a group can receive data from more than one input device too.
 
 To create a group use lv_group_t * g = lv_group_create() and to add an object to the group use lv_group_add_obj(g, obj).
 
 The associate a group with an input device use lv_indev_set_group(indev, g), where indev is the return value of lv_indev_drv_register()
 
 Keys
 There are some predefined keys which have special meaning:
 
 LV_KEY_NEXT Focus on the next object
 
 LV_KEY_PREV Focus on the previous object
 
 LV_KEY_ENTER Triggers LV_EVENT_PRESSED/CLICKED/LONG_PRESSED etc. events
 
 LV_KEY_UP Increase value or move upwards
 
 LV_KEY_DOWN Decrease value or move downwards
 
 LV_KEY_RIGHT Increase value or move the the right
 
 LV_KEY_LEFT Decrease value or move the the left
 
 LV_KEY_ESC Close or exit (E.g. close a Drop down list)
 
 LV_KEY_DEL Delete (E.g. a character on the right in a Text area)
 
 LV_KEY_BACKSPACE Delete a character on the left (E.g. in a Text area)
 
 LV_KEY_HOME Go to the beginning/top (E.g. in a Text area)
 
 LV_KEY_END Go to the end (E.g. in a Text area))
 
 The most important special keys are LV_KEY_NEXT/PREV, LV_KEY_ENTER and LV_KEY_UP/DOWN/LEFT/RIGHT. In your read_cb function, you should translate some of your keys to these special keys to navigate in the group and interact with the selected object.
 
 Usually, it's enough to use only LV_KEY_LEFT/RIGHT because most of the objects can be fully controlled with them.
 
 With an encoder, you should use only LV_KEY_LEFT, LV_KEY_RIGHT, and LV_KEY_ENTER.
 
 Edit and navigate mode
 Since keypad has plenty of keys, it's easy to navigate between the objects and edit them using the keypad. But, the encoders have a limited number of "keys" hence, difficult to navigate using the default options. Navigate and Edit are created to avoid this problem with the encoders.
 
 In Navigate mode, the encoders LV_KEY_LEFT/RIGHT is translated to LV_KEY_NEXT/PREV. Therefore the next or previous object will be selected by turning the encoder. Pressing LV_KEY_ENTER will change to Edit mode.
 
 In Edit mode, LV_KEY_NEXT/PREV is usually used to edit the object. Depending on the object's type, a short or long press of LV_KEY_ENTER changes back to Navigate mode. Usually, an object which can not be pressed (like a Slider) leaves Edit mode on short click. But with object where short click has meaning (e.g. Button), long press is required.
 
 Styling
 If an object is focused either by clicking it via touchpad, or focused via an encoder or keypad it goes to LV_STATE_FOCUSED. Hence focused styles will be applied on it.
 
 If te object goes to edit mode it goes to LV_STATE_FOCUSED | LV_STATE_EDITED state so these style properties will be shown.
 
 For a moew detaild description read the Style section.
 
 https://docs.lvgl.io/latest/en/html/overview/indev.html
 
 上面官方教程可以看看,好像是要注册一个group的链表,之后把所有obj链接进去,之后才有按键功能,挺麻烦的,我觉得
 | 
 |