Description
I would to know the logic flow that start from when I press a Button using an input device and finish when the Button on the screen is selected.
What MCU/Processor/Board and compiler are you using?
Esp32
What do you want to achieve?
I want to use a custom input device to control my gui.
What have you tried so far?
I have tried to run the example that use the keyboard and the mouse (lv_demo_keypad_encoder). I have added my input drive to the example, but i’m not able to run all the functionalities that are in this example. In particular i have noticed that the events UP, DOWN, ENTER that I send using my input driver don’t are recognize proprerly from the rest of the example.
To run the enter button I have modified the msgbox_event_cb function as you can see in the code section. In this section I have copied my function that read the input data.
I don’t know if the use of the queue is a good idea, but i have created a task that read the input device (this is a 5 button shield that give me 5 events: UP, DOWN,LEFT,RIGHT and ENTER) and after the read, associate each of those events, with the lvgl input events, so I send to the GUI this events LV_KEY_ENTER, LV_KEY_UP e so on…
But unfortunately, seem to me that these events aren’t recognize properly.
Someone can help me to understand what are wrong in my code and how I control the objects in my GUI using an input device?
Code to reproduce
static void msgbox_event_cb(lv_obj_t * msgbox, lv_event_t e)
{
//printf("msgbox_event_cb: %d\n",e);
if(e == LV_EVENT_PRESSING/*LV_EVENT_CLICKED*/) {
uint16_t b = lv_msgbox_get_active_btn(msgbox);
if(b == 0 || b == 1) {
lv_obj_del(msgbox);
lv_obj_reset_style_list(lv_layer_top(), LV_OBJ_PART_MAIN);
lv_obj_set_click(lv_layer_top(), false);
lv_event_send(tv, LV_EVENT_REFRESH, NULL);
}
}
}
static bool keyboard_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
{
(void) indev_drv; /*Unused*/
// data->state = state;
// data->key = keycode_to_ascii(last_key);
//
uint32_t keyboard_event;
if(xQueueReceive(gui_input_evt_queue, &keyboard_event, portMAX_DELAY)){
data->state = LV_INDEV_STATE_PR;
data->key = keyboard_event;
//printf("key board event: %d\n",keyboard_event);
}
else{
data->state = LV_INDEV_STATE_REL;
}
return false;
}
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.