Hi All,
I am trying to understand why the LVGL Menu demo is not showing any indication of selection using an encoder with 5 buttons. I have tried creating a group, followed many of the examples in the forum, mostly they don’t compile due them referencing old LVGL versions. I am not sure what I am missing or overlooking. I want to first get the UP/DOWN/LEFT/RIGHT/SELECT buttons working before I get the Encoder part working, Currently I just want my display to indicate Item 1/Item 2/Item 3 in example 3 “selected” when I press UP/DOWN.
All I can see are these 3 labels displayed, no other activity.
Item 1 (Click me!)
Item 2 (Click me!)
Item 3 (Click me!)
Global declaration
static lv_obj_t * menu; //created in example_menu_3
static lv_group_t * menu_group;
static lv_indev_t * indev;
I have included lv_example_menu_3 (identical to the lvgl example) including what is listed below in my setup()
menu_group = lv_group_create();
indev = lv_indev_create();
lv_indev_set_type(indev, LV_INDEV_TYPE_KEYPAD);
lv_indev_set_read_cb(indev, ANO_Rotary_read);
lv_indev_set_group(indev, menu_group);
lv_example_menu_3();
lv_group_add_obj(menu_group, menu);
lv_group_set_default(menu_group);
The Callback works as I can see the Serial.println(…) in my Serial monitor, so when I press a button I set the UART message. The data->key and data->state is not being actioned.
void ANO_Rotary_read(lv_indev_t * indev, lv_indev_data_t*data) {
if (! ss.digitalRead(SS_SWITCH_UP)) {
data->key = LV_KEY_PREV;
data->state = LV_INDEV_STATE_PRESSED;
Serial.println("UP pressed!");
} else {
data->key = LV_KEY_PREV;
data->state = LV_INDEV_STATE_RELEASED;
}
if (! ss.digitalRead(SS_SWITCH_DOWN)) {
data->key = LV_KEY_NEXT;
data->state = LV_INDEV_STATE_PRESSED;
Serial.println("DOWN pressed!");
} else {
data->key = LV_KEY_NEXT;
data->state = LV_INDEV_STATE_RELEASED;
}
if (! ss.digitalRead(SS_SWITCH_SELECT)) {
data->key = LV_KEY_ENTER;
data->state = LV_INDEV_STATE_PRESSED;
Serial.println("SELECT pressed!");
} else {
data->key = LV_KEY_ENTER;
data->state = LV_INDEV_STATE_RELEASED;
}
if (! ss.digitalRead(SS_SWITCH_LEFT)) {
data->key = LV_KEY_LEFT;
data->state = LV_INDEV_STATE_PRESSED;
Serial.println("LEFT pressed!");
} else {
data->key = LV_KEY_LEFT;
data->state = LV_INDEV_STATE_RELEASED;
}
if (! ss.digitalRead(SS_SWITCH_RIGHT)) {
data->key = LV_KEY_RIGHT;
data->state = LV_INDEV_STATE_PRESSED;
Serial.println("RIGHT pressed!");
} else {
data->key = LV_KEY_RIGHT;
data->state = LV_INDEV_STATE_RELEASED;
}
}
What am I overlooking here? What have I not included/implemented?
Any assistance would be most appreciated.
Regards
Paul