MsTS 发表于 2021-10-30 19:34:49

lvgl 键盘 或 编码器输入问题

我的设备有四个按键分别为:up、down、ok、cancel。看了lvgl输入设备的几种类型,发现编码器方式比较适合,于是我使用了Using buttons with Encoder logic这种方式(如图一所示)
/* Will be called by the library to read the mouse */
static bool keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
{
    uint8_t act_key = keypad_get_key();
    uint8_t last_diff = 0;
    data->key = act_key;
    if(act_key == LV_KEY_LEFT) data->enc_diff = -1 - last_diff;
    if(act_key == LV_KEY_RIGHT) data->enc_diff = 1 - last_diff;
    last_diff = data->enc_diff;
    /*Return `false` because we are not buffering and no more data to read*/
    return false;
}这是我的read_cb函数

因为我只有4个按键,所以我想用编码器的Edit and navigate这个特性。可是目前只有left/right起效了(LV_EVENT_FOCUSED / LV_EVENT_DEFOCUSED 事件),确认/取消却不响应(LV_EVENT_CLICKED / LV_EVENT_CANCEL 事件),不知道为什么?



阿里兄 发表于 2021-11-1 08:49:03

不好意思,我没用过这个,你有没有给到确认/取消到LVGL,你自己测试下了。
页: [1]
查看完整版本: lvgl 键盘 或 编码器输入问题