| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- #include "lcd_app.h"
- #include "io.h"
- #include <fcntl.h>
- #include <poll.h>
- #include <unistd.h>
- #include <string.h>
- #define KEY_UP_NUMBER 100
- int key_event_callback(void* arg)
- {
- /*对IO值进行poll侦听*/
- int fd=open("/sys/class/gpio/pioC2/value",O_RDONLY);
- if(fd<0)
- {
- printf("open '/sys/class/gpio/pioC2/value' failed!\n");
- return -1;
- }
- struct pollfd fds[1];
- fds[0].fd=fd;
- fds[0].events=POLLPRI;
- while(1)
- {
- if(poll(fds,1,0)==-1)
- {
- printf("poll failed!\n");
- return -1;
- }
- if(fds[0].revents&POLLPRI)
- {
- if(lseek(fd,0,SEEK_SET)==-1)
- {
- printf("lseek failed!\n");
- return -1;
- }
- char buffer[16];
- int len;
- if((len=read(fd,buffer,sizeof(buffer)))==-1)
- {
- printf("read failed!\n");
- return -1;
- }
- buffer[len]=0;
- printf("%s",buffer);
- }
- }
- }
- /// @brief 初始化LCD显示
- /// @return
- int lcd_app_init()
- {
- //初始化屏幕显示
- lcd_init();
- //初始化四个按键
- //初始化IO
- io_init(KEY_UP_NUMBER);
- //设置输入
- io_set_dir(KEY_UP_NUMBER,0);
- }
- void main_view_page(void)
- {
- }
|