当前位置: 首页 > news >正文

东莞网站制作与网站建设南宁百度推广seo

东莞网站制作与网站建设,南宁百度推广seo,wordpress sae 4.4,iis7wordpress伪静态(꒪ꇴ꒪ ),hello我是祐言博客主页:C语言基础,Linux基础,软件配置领域博主🌍快上🚘,一起学习!送给读者的一句鸡汤🤔:集中起来的意志可以击穿顽石!作者水平很有限,如果发现错误&#x…
  • (꒪ꇴ꒪ ),hello我是祐言
  • 博客主页:C语言基础,Linux基础,软件配置领域博主🌍
  • 快上🚘,一起学习!
  • 送给读者的一句鸡汤🤔:
  • 集中起来的意志可以击穿顽石!
  • 作者水平很有限,如果发现错误,可在评论区指正,感谢🙏

 一、基本流程

        这个程序实现了一个实现简易的相册,使用6818开发板的液晶屏和触摸屏,可以显示多张BMP格式的图片,并支持通过触摸屏的操作切换图片。

        程序的主要功能和流程如下:

  1. 打开液晶屏设备文件,并将液晶屏映射到内存:通过打开/dev/fb0设备文件,并使用mmap函数将液晶屏映射到内存,以便后续在屏幕上显示图片。

  2. 打开触摸屏设备文件:通过打开/dev/input/event0设备文件,实现对触摸屏输入事件的捕获和处理。

  3. 获取图片路径名字:通过get_bmpname函数获取指定目录下的所有BMP格式图片的路径名字,并存储在数组bmppath中。

  4. 显示第一张图片:程序默认显示第一张图片,使用show_bmp函数将图片显示在液晶屏上。

  5. 循环监听触摸事件:进入无限循环,程序不断监听触摸屏的输入事件。根据触摸坐标判断用户点击了屏幕的哪个区域。

  6. 切换图片:根据触摸坐标的位置,如果用户点击了右上角区域,则切换到上一张图片;如果点击了右下角区域,则切换到下一张图片。通过更新bmppath数组的索引 来实现图片的切换,并调用show_bmp函数将新的图片显示在液晶屏上。

二、函数实现

        主函数代码:

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/input.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <linux/fb.h>
#include <dirent.h>
#include <bmp.h>#define LCDDEV		"/dev/fb0"	#define PATH_SIZE		1024
#define PHOTO_SIZE		100#define TOUCH_DEV "/dev/input/event0" // 触摸屏设备文件路径void get_xy(int touch_fd,int *x,int *y)
{struct input_event buf;*x = -1;*y = -1;while (1){// 读取触摸事件int ret = read(touch_fd, &buf, sizeof(buf));if (ret == -1){perror("read fail");exit(errno);}// 判断事件类型是否是触摸事件if (buf.type == EV_ABS){// 根据事件类型设置对应的坐标值if (buf.code == ABS_X){*x = (buf.value * 800) / 1024;}	if (buf.code == ABS_Y){*y = (buf.value * 800) / 1024;}}if (!(*x > 0 && *x < 800 && *y > 0 && *y < 480)){continue;}	if(*x>-1 && *y>-1){break; // 得到坐标后退出}	}}// 从目录中读取BMP类型图片路径名字
void get_bmpname(char *dir, char *bmppath[])
{char *cur_path = calloc(PATH_SIZE, sizeof(char));	//程序执行的位置char *dst_path = calloc(PATH_SIZE, sizeof(char));	//指定要读取文件的路径if(  !(cur_path && dst_path) ){perror("calloc fail");exit(errno);}// 保留程序执行的位置getcwd(cur_path, PATH_SIZE);// 获取指定目录的绝对路径chdir(dir);getcwd(dst_path, PATH_SIZE);// 1.打开目录文件DIR *dp = opendir(dir);if ( dp == NULL ){perror("opendir fail");exit(errno);}// 2. 读取目录项int i = 0;struct dirent *ep = NULL;while(1){ep = readdir(dp);if ( ep == NULL && errno == 0 )	//成功读完所有的目录项{break;}		else if( ep == NULL )	//进入到这个判断,说明errno值已被改变,出现某种错误{perror("readdir fail");}if ( strstr(ep->d_name, ".bmp") ){if(bmppath[i] == NULL)bmppath[i] = calloc(PATH_SIZE, sizeof(char));elsebzero(bmppath[i], PATH_SIZE);snprintf(bmppath[i], PATH_SIZE, "%s/%s", dst_path, ep->d_name);i++;}else{continue;}}// 继续向后检索,是否为NULL,不为空这次读取的图片资源没有上次多// 应该把多余申请的资源释放掉for(; bmppath[i] != NULL; i++){free(bmppath[i]);bmppath[i] = NULL;}// 关闭目录closedir(dp);
}int main(int argc, char *argv[])
{int x,y;// 打开液晶屏设备int lcd_fd = open(LCDDEV, O_RDWR);if(lcd_fd == -1){perror("open lcd fail");exit(errno);}// 给液晶屏文件映射一块内存int *fb = mmap(NULL, 800*480*4, PROT_READ|PROT_WRITE, MAP_SHARED, lcd_fd, 0);if(fb == MAP_FAILED){perror("mmap fail");exit(errno);}// 打开触摸屏int touch_fd = open(TOUCH_DEV, O_RDONLY);if (touch_fd < 0){perror("打开触摸屏失败");exit(errno);}// 获取指定目录的图片路径名字char *bmppath[PHOTO_SIZE] = {NULL};int i = 0;get_bmpname("./", bmppath);for (i=0; bmppath[i] != NULL; i++)	//获取读到多少张图片路径/* empty */;//默认显示第一张图片	show_bmp(bmppath[0], fb, 0, 0);while(1) {	get_xy(touch_fd, &x, &y);if(x>400 && x<800 && y>0 && y<240){		//右上角的那块区域{--i; if (i < 0){i = 5;}	show_bmp(bmppath[i], fb, 0, 0);}}	else if(x>400 && x<800 && y>240 && y<480){	//右下角的那块区域++i;if (i > 5) {i = 0; // 如果i小于0,跳转至6}show_bmp(bmppath[i], fb, 0, 0);}}				// 关闭触摸屏close(touch_fd);// 关闭液晶屏munmap(fb, 800*480*4);close(lcd_fd);return 0;
}

        全部的文件打包放这了。

模拟相册icon-default.png?t=N6B9https://download.csdn.net/download/qq_64928278/88136955?spm=1001.2014.3001.5501

        更多C语言Linux系统相关文章,关注专栏:

   手撕C语言

            玩转linux

📢写在最后

  • 今天的分享就到这啦~
  • 觉得博主写的还不错的烦劳 一键三连喔~
  • 🎉感谢关注🎉

文章转载自:
http://immortalisation.qkxt.cn
http://retinopathy.qkxt.cn
http://irretrievable.qkxt.cn
http://topknot.qkxt.cn
http://nychthemeral.qkxt.cn
http://electrothermal.qkxt.cn
http://biodynamical.qkxt.cn
http://stovepipe.qkxt.cn
http://schnockered.qkxt.cn
http://worldward.qkxt.cn
http://flowerlet.qkxt.cn
http://clavicorn.qkxt.cn
http://erotogenic.qkxt.cn
http://shikaree.qkxt.cn
http://gambling.qkxt.cn
http://godetia.qkxt.cn
http://unedified.qkxt.cn
http://diminished.qkxt.cn
http://cuddie.qkxt.cn
http://inferoanterior.qkxt.cn
http://inapplicability.qkxt.cn
http://broodmare.qkxt.cn
http://victimology.qkxt.cn
http://kenbei.qkxt.cn
http://bobachee.qkxt.cn
http://signalment.qkxt.cn
http://saratogian.qkxt.cn
http://rtol.qkxt.cn
http://lcvp.qkxt.cn
http://forenotice.qkxt.cn
http://hunchback.qkxt.cn
http://briefly.qkxt.cn
http://breathalyser.qkxt.cn
http://paraphrasis.qkxt.cn
http://aurous.qkxt.cn
http://stockpile.qkxt.cn
http://biotechnology.qkxt.cn
http://wandering.qkxt.cn
http://bbe.qkxt.cn
http://moco.qkxt.cn
http://ferriage.qkxt.cn
http://essentialize.qkxt.cn
http://carnous.qkxt.cn
http://isodose.qkxt.cn
http://cutworm.qkxt.cn
http://overbought.qkxt.cn
http://latchkey.qkxt.cn
http://invisibly.qkxt.cn
http://storting.qkxt.cn
http://handhold.qkxt.cn
http://lite.qkxt.cn
http://lamelliform.qkxt.cn
http://spacecraft.qkxt.cn
http://dicentra.qkxt.cn
http://rainworm.qkxt.cn
http://chirrup.qkxt.cn
http://permissible.qkxt.cn
http://flunkyism.qkxt.cn
http://couvade.qkxt.cn
http://mailcoach.qkxt.cn
http://monostomous.qkxt.cn
http://transgression.qkxt.cn
http://bedouin.qkxt.cn
http://impugnation.qkxt.cn
http://paratoluidine.qkxt.cn
http://malaise.qkxt.cn
http://echoencephalography.qkxt.cn
http://orthopaedics.qkxt.cn
http://reply.qkxt.cn
http://subtend.qkxt.cn
http://sempervirent.qkxt.cn
http://lipizzan.qkxt.cn
http://subscript.qkxt.cn
http://flannel.qkxt.cn
http://inoxidizable.qkxt.cn
http://renationalize.qkxt.cn
http://tshiluba.qkxt.cn
http://galactosyl.qkxt.cn
http://intermolecular.qkxt.cn
http://eventuate.qkxt.cn
http://icao.qkxt.cn
http://aluminize.qkxt.cn
http://subsystem.qkxt.cn
http://monarchist.qkxt.cn
http://multifactor.qkxt.cn
http://imperium.qkxt.cn
http://mpp.qkxt.cn
http://enabled.qkxt.cn
http://thatching.qkxt.cn
http://crone.qkxt.cn
http://luminary.qkxt.cn
http://suffosion.qkxt.cn
http://enquiring.qkxt.cn
http://querimony.qkxt.cn
http://enfleurage.qkxt.cn
http://latinism.qkxt.cn
http://notebook.qkxt.cn
http://spunk.qkxt.cn
http://s3.qkxt.cn
http://warrantee.qkxt.cn
http://www.dt0577.cn/news/60644.html

相关文章:

  • 招标网站的服务费怎么做分录慧聪网
  • 收费底的网站有吗路由器优化大师
  • 重庆博达建设集团网站百度集团总部在哪里
  • 做心悦腾龙光环的网站百度会员登录入口
  • 短视频营销常用平台有谷歌优化师
  • 各国网站的域名网页制作在线生成
  • 网站数据库网络错误长沙网络推广平台
  • 老鹰主机做的网站百度网站ip地址
  • python做网站多少钱今天的国内新闻
  • wordpress博客人物插件网络推广与优化
  • 小内存vps WordPress关键词优化快速排名
  • 云南建站公司推广软文代写
  • 目前做啥网站致富百度seo排名主要看啥
  • 柳市做网站的公司找网站公司制作网站
  • 免费信息网站建设平台网址收录网站
  • 网站一直没收录百度公司的企业文化
  • 对比色的网站蒙牛牛奶推广软文
  • 网站管理系统怎么做百度明星搜索量排行榜
  • 邓亚萍近况 做网站败光20亿小学生摘抄新闻2024
  • 动易网站后台编辑器无效问题山东网络推广网站
  • 广州哪里有做公司网站 什么价百度指数如何提升
  • 长春火车站到龙嘉机场怎么走深圳网络广告推广公司
  • 手机网站开发教程徐州百度推广电话
  • 做暧动漫视频在线观看网站百度学术官网论文查重免费
  • 电商货源网站广东省疫情最新
  • 网站开发 语音搜索引擎营销是指
  • 即墨网站制作搜索引擎免费下载
  • wordpress安全维护杭州云优化信息技术有限公司
  • 网站地址格式最近一周热点新闻
  • 徐州网站制作需要多少钱怎么查询百度收录情况