LV_INDEV_TYPE_ENCODER working but not LV_INDEV_TYPE_KEYPAD (with Duppa NavKey input device)

First of all, congratulations for your amazing library !

I’m using LVGL v8.4 with a Makerfabs ESP32-S3 Parallel TFT with Touch 3.5’’ ILI9488 board
(https://www.makerfabs.com/esp32-s3-parallel-tft-with-touch-ili9488.html).

Display is working great, but I can’t make LVGL to work using LV_INDEV_TYPE_KEYPAD input device type with a Duppa I2C NavKey v2.1 controller (with neither the directional part of the controller, nor the rotary encoder part of the controller). Rotary encoder part of the NavKey work well, just by changing the input device type to LV_INDEV_TYPE_ENCODER (not changing anything else to the code), but the directional part still doesn’t work.

I’ve read the LVGL documentation over and over again, but I can’t find the issue.

Here is the input device read callback function :

void read_navkey(lv_indev_drv_t *indev, lv_indev_data_t *data)
{

    navkey.updateStatus();

    if (navkey.readStatus(i2cNavKey::CTRP))
    {
        data->state = LV_INDEV_STATE_PR;
        printf("Push\n");
    }
    else
    {
        data->state = LV_INDEV_STATE_REL;
        printf("Release\n");
    }

    int CounterValue = navkey.readCounterInt();
    if(CounterValue != 0)
    {
        data->enc_diff = CounterValue;
        printf("Diff: %d\n", data->enc_diff);

        // Reset the navkey rotary encoder to zero
        navkey.writeCounter(0);
    }

    if (navkey.readStatus(i2cNavKey::UPP))
    {
        // data->key = LV_KEY_UP;
        data->key = LV_KEY_PREV;

        printf("UP\n");
    }

    if (navkey.readStatus(i2cNavKey::DNP))
    {
        // data->key = LV_KEY_DOWN;
        data->key = LV_KEY_NEXT;
        printf("DOWN\n");
    }

    if (navkey.readStatus(i2cNavKey::RTP))
    {
        data->key = LV_KEY_RIGHT;
        printf("RIGHT\n");
    }

    if (navkey.readStatus(i2cNavKey::LTP))
    {
        data->key = LV_KEY_LEFT;
        printf("LEFT\n");
    }
}

I also have some questions :

  1. When using (for example) data->key = LV_KEY_PREV; as I do in the callback function, should it make the focus change to the previous object in the input device group (that I previously set) on the screen ?

  2. Should data->enc_diff = CounterValue; also work with LV_INDEV_TYPE_KEYPAD input device type set ?

  3. Should all data->key still work with LV_INDEV_TYPE_ENCODER input device type set ?

Thank you very much in advance for your help.

Anyone ? @kisvegabor maybe ? :pray:

Hi,

At first look read_navkey is fine.

Do you use groups in the UI? (It’s required for navigation with keys and encoder)

These are twp separete things:

  • data->enc_diff is for ENCODER only
  • data->key is for KEYPAD only

You can create 2 input devices for the 2 types without any issues.

I believe that you will need to create two separate Input devices @maventech: One being an Encoder to handle the Left/Right/Press and a second one being a KeyPad to handle LV_KEY_LEFT/RIGHT/UP/DOWN.

Once you have the two input devices you can then link both to the active group and the group will handle the input from both.