testmatrixbutton.c

来自「矩阵button驱动」· C语言 代码 · 共 49 行

C
49
字号
#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include "btnIO.h"int main(){    int fd=-1;    unsigned char positon[2]={0};    unsigned char ch=0;    fd=open("/dev/matrix_button",O_RDWR);    if(fd<0)    {        printf("open matrix_button failure\n");        return fd;    }    else    {        printf("open matrix_button successfully\n");    }    while(1)    {        //read(fd,&ch,1);        ch = btnRead(fd);        /*        if( positon[0] && (positon[0] & ~0x80) )        {            printf("position(%x,%x)\n",positon[0],positon[1]);        }        */        printf("button :::%c\n",ch);        ch=0;        //sleep(1);    }    close(fd);    printf("close matrix_button successfully\n");        return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?