lcd_app.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #include "lcd_app.h"
  2. #include "io.h"
  3. #include <fcntl.h>
  4. #include <poll.h>
  5. #include <unistd.h>
  6. #include <string.h>
  7. #define KEY_UP_NUMBER 100
  8. int key_event_callback(void* arg)
  9. {
  10. /*对IO值进行poll侦听*/
  11. int fd=open("/sys/class/gpio/pioC2/value",O_RDONLY);
  12. if(fd<0)
  13. {
  14. printf("open '/sys/class/gpio/pioC2/value' failed!\n");
  15. return -1;
  16. }
  17. struct pollfd fds[1];
  18. fds[0].fd=fd;
  19. fds[0].events=POLLPRI;
  20. while(1)
  21. {
  22. if(poll(fds,1,0)==-1)
  23. {
  24. printf("poll failed!\n");
  25. return -1;
  26. }
  27. if(fds[0].revents&POLLPRI)
  28. {
  29. if(lseek(fd,0,SEEK_SET)==-1)
  30. {
  31. printf("lseek failed!\n");
  32. return -1;
  33. }
  34. char buffer[16];
  35. int len;
  36. if((len=read(fd,buffer,sizeof(buffer)))==-1)
  37. {
  38. printf("read failed!\n");
  39. return -1;
  40. }
  41. buffer[len]=0;
  42. printf("%s",buffer);
  43. }
  44. }
  45. }
  46. /// @brief 初始化LCD显示
  47. /// @return
  48. int lcd_app_init()
  49. {
  50. //初始化屏幕显示
  51. lcd_init();
  52. //初始化四个按键
  53. //初始化IO
  54. io_init(KEY_UP_NUMBER);
  55. //设置输入
  56. io_set_dir(KEY_UP_NUMBER,0);
  57. }
  58. void main_view_page(void)
  59. {
  60. }