lcd_app.c 1.3 KB

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