第六章:文件显示6.3汉字点阵显示修改lcd_put_chinese函数指定字符颜色。实现lcd_put_str函数,可输出中英文混合字符,如“Chinachina”,支持自动换行。效果:读取指定文件中英文数据到lcd显示文件:show_chinses.c#include#include#include#include#include#include#include#include#includeexternconstunsignedcharfontdata_8x16[];//fontdata_8x16单独在fontdata.cstaticintfd_fb=0;staticunsignedchar*fb_base=NULL;staticstructfb_var_screeninfovar={0};staticintscreen_size=0;staticintline_width=0;staticintpixel_width=0;staticintfd_hzk16;staticstructstathzk_stat={0};staticunsignedchar*hzkmem={0};voidlcd_put_pixel(intx,inty,unsignedintcolor){unsignedchar*pen_8=fb_base+y*line_width+x*pixel_width;无符号短*pen_16=(无符号短*)(pen_8);无符号整数*pen_32=(无符号整数*)(pen_8);无符号整数红色=0;无符号整型恩=0;无符号整数蓝色=0;switch(var.bits_per_pixel){案例8:*pen_8=颜色;休息;案例16:红色=(颜色>>16)&0xff;绿色=(颜色>>8)&0xff;蓝色=(颜色>>0)&0xff;颜色=((红色>>3)<<11)|((绿色>>2)<<5)|(蓝色>>3);*pen_16-颜色;休息;案例32:*pen_32=颜色;休息;默认值:printf("无法打开%dbpp\n",var.bits_per_pixel);休息;}}voidlcd_put_ascii(intx,inty,charc,unsignedintcolor){unsignedchar*dots=(unsignedchar*)(&fontdata_8x16[c*16]);诠释我=0;整数b=0;for(i=0;i<16;++i){for(b=7;b>=0;--b){if(dots[i]&(1<=0;--b){if(byte&(1<arm-linux-gnueabihf-gcc-fexec-charset=GB2312fontdata.cshow_chinese.cubutunCopyfile->cp./a.out~/nfs_rootfs/->cp。/source.txt~/nfs_rootfs/->cp./HZK16~/nfs_rootfs/开发板执行->./a.outsource.txtfile:source.txt[请保存为GB2312]如果可以,我一定会.如果可以,我一定会!愿你的生命中有足够多的云彩,成就美丽的夕阳。愿你的生命中有足够多的云彩,成就美丽的夕阳。想念一个人最糟糕的方式就是坐在他们身边,却知道你不能拥有他们。失去一个人最糟糕的事情是他们离得那么近,却又那么远。你必须始终相信你是谁!相信自己,坚持自己!最长的一天结束了。不要因为结束而哭泣,要为它发生而微笑。不要因为结束而哭泣,要为它发生而微笑。幸福是身体好,记性不好。幸福是身体好,记性不好。第七章:输入系统应用编程7.3不使用库的应用示例使用select函数获取LCD输入信息#include#include#include#include#include#include#include#include#include#includeintmain(intargc,char**argv){intfd=0;intlen=0;诠释我=0;intret=0;结构input_idid={0};结构input_event事件={0};无符号字符字节=0;无符号字符位=0;unsignedintevbit[2]={0};国际金融机构;fd_setreadfds;结构时间电视;constchar*ev_names[]={"EV_SYN","EV_KEY","EV_REL","EV_ABS","EV_MSC","EV_SW","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","EV_LED",“EV_SND”、“NULL”、“EV_REP”、“EV_FF”、“EV_PWR”、};if(argc<2){printf("用法:%s\n",argv[0]);返回-1;}fd=open(argv[1],O_RDWR|O_NONBLOCK);if(fd<0){printf("无法打开%s\n",argv[1]);返回-1;}if(!ioctl(fd,EVIOCGID,&id)){printf("bustype=0x%x\n",id.bustype);printf("供应商=0x%x\n",id.供应商);printf("产品=0x%x\n",id.产品);printf("版本=0x%x\n",id.version);}len=ioctl(fd,EVIOCGBIT(0,sizeof(evbit)),&evbit);if(len>0&&len<=sizeof(evbit)){printf("支持ev类型:");对于(i=0;i0){if(FD_ISSET(fd,&readfds))while(read(fd,&event,sizeof(event))==sizeof(event))printf("getevent:type=0x%x,code=0x%x,值=0x%x\n",event.type,event.code,event.value);}elseif(ret==0){printf("超时\n");}else{printf("选择错误\n");}}关闭(fd);返回0;}