Description
i want to contral button by keypad,when i press key,keypad_callback() can get act_key,But i can’t get key event in my ta_event_cb().would you give some guidance
What MCU/Processor/Board and compiler are you using?
What LVGL version are you using?
What do you want to achieve?
What have you tried so far?
Code to reproduce
Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.
The code block(s) should be formatted like:
static bool keypad_callback(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
{
uint last_key = 0;
/*Get whether the a key is pressed and save the pressed key*/
uint act_key = keypad_get_key();
if(act_key != KEY_NONE)
{
data->state = LV_INDEV_STATE_PR;
data->key=act_key;
TRACE(DBG_TRACE_LVL,"%s,act_key=%d\r\n",__FUNCTION__,act_key);
/*Translate the keys to LVGL control characters according to your key definitions*/
switch(act_key)
{
case KEY_DOWN:
act_key = LV_KEY_DOWN;
break;
case KEY_UP:
act_key = LV_KEY_UP;
break;
case KEY_CANCEL:
act_key = LV_KEY_END;
break;
case KEY_CONFIRM:
act_key = LV_KEY_ENTER;
break;
case KEY_DELETE:
act_key = LV_KEY_DEL;
break;
case KEY_POWER:
act_key = LV_KEY_HOME;
break;
default:
break;
}
last_key = act_key;
}
else
{
data->state = LV_INDEV_STATE_REL;
}
data->key = last_key;
/*Return `false` because we are not buffering and no more data to read*/
return false;
}
static void ta_event_cb(lv_obj_t * ta, lv_event_t event)
{
TRACE(DBG_TRACE_LVL,"%s-event=%d\r\n",__FUNCTION__,event);
if(event == LV_EVENT_CLICKED) {
/* Focus on the clicked text area */
if(kb != NULL)
lv_keyboard_set_textarea(kb, ta);
}
else if(event == LV_EVENT_INSERT) {
const char * str = lv_event_get_data();
if(str[0] == '\n') {
//printf("Ready\n");
}
}
}
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.