Feedback-"Click"?

Hello,

according to https://docs.lvgl.io/latest/en/html/porting/indev.html, I’m trying to install a feedback-callback which gives me a “Click” whenever the touchpad is touched:

    /* initialize input device */
    lv_indev_drv_init (&touch_indev_drv);
    touch_indev_drv.type = LV_INDEV_TYPE_POINTER;
    touch_indev_drv.read_cb = LVGL_Touch_Read_Callback;
    touch_indev_drv.feedback_cb = audio_play_click;

    touch_indev = lv_indev_drv_register (&touch_indev_drv);

But the callback is never called at all.

What am I missing here?

Try:

/* initialize input device */
    lv_indev_drv_t touch_indev_drv;
    lv_indev_drv_init (&touch_indev_drv);
    touch_indev_drv.type = LV_INDEV_TYPE_POINTER;
    touch_indev_drv.read_cb = LVGL_Touch_Read_Callback;
    touch_indev_drv.feedback_cb = audio_play_click;

    lv_indev_t * touch_indev = lv_indev_drv_register(&touch_indev_drv);

Are you trying to click a blank screen, or a button? Feedback is triggered when an object receives an input-related event, so if there is no object getting input events, I am pretty sure feedback_cb will not be called.

1 Like

OK, I see.

my feedback currently looks like this:

void audio_click (struct _lv_indev_drv_t *drv, uint8_t event)
{
    switch (event) {
    case LV_EVENT_CLICKED: /* FALL THRU */
    case LV_EVENT_LONG_PRESSED_REPEAT:
        audio_play (sound_sinus2000hz_100ms);
        break;
    }
}

Now I have some buttons which should act like the buttons on an old-fashiones PC-keyboard. That is: when the button is touched for a long time, the first click (and the first callback) should be invoked immediately. After an initial delay, the callback and clicks should be called repeatedly.

For some reason, the first (initial) click/callback is not invoked?

@Miguel_0101, I’m confused… What’s the difference?

CLICKED gets fired when the button gets released. You probably want to use PRESSED instead.

Try using LONG_PRESSED.

Long pressed is sent after the long press threshold has passed, which will lead to the initial click sound happening noticeably late.

Try:

static void audio_click (struct _lv_indev_drv_t *drv, lv_event_t event)
{
  if (event == LV_EVENT_PRESSED) {
    audio_play (sound_sinus2000hz_100ms);
  }
}