lcd_app.c 1.3 KB

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