#include "Printer_sys.h" #include "lvgl.h" #include "indev/evdev.h" void keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data); extern int Key_Matrix_fb; void keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) { static uint32_t last_key = 0; uint32_t act_key =0; /*Get whether the a key is pressed and save the pressed key*/ read(Key_Matrix_fb, &act_key, sizeof(act_key)); if(act_key != 0) { data->state = LV_INDEV_STATE_PR; /*Translate the keys to LittlevGL control characters according to your key definitions*/ switch(act_key) { case 0x01: act_key = LV_KEY_RIGHT; break; case 0x02: act_key = LV_KEY_UP; break; case 0x04: act_key = LV_KEY_ENTER; break; case 0x08: act_key = LV_KEY_DOWN; break; case 0x10: act_key = LV_KEY_LEFT; break; } last_key = act_key; printf("Key_Matrix_fb:0x%X\n",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; } /** ** 为了方便获得组和输入设备可以在这个编写返回函数 **/ // lv_indev_t * Get_indev(void) // { // return indev_keypad; // } // lv_group_t *Get_group(void) // { // return g; // }