
《智能家居系统》6
发布日期:2021-05-08 03:56:14
浏览次数:21
分类:精选文章
本文共 2632 字,大约阅读时间需要 8 分钟。
字库的使用与触摸屏滑屏算法
字库的使用
编译命令:
arm-linux-gcc showchar.c libfont.a -o showchar
函数介绍:
int Init_Font(void); // 初始化字体库void UnInit_Font(void); // 退出前清理字体库int Clean_Area(int X, int Y, int width, int height, unsigned long color); // 清理指定区域int Display_characterX(unsigned int x, unsigned int y, unsigned char *string, unsigned int color, int size); // 显示字符
注意事项:在使用 Notepad++ 编写代码时,确保设置为 GB2312 字码。
CRT 设置:如何进行中文设置:
Options -> Session options -> Appearance -> Character encoding (选择 ANSI/OEM-简体中文GBK)
触摸板的滑屏算法
#include#include #include #include #include #include int main(void) { struct input_event info; int x1, y1, x2, y2; int tsfd = open("/dev/input/event0", O_RDWR); if(tsfd == -1) { perror("open event0 error"); return -1; } while(1) { x1 = x2 = y1 = y2 = 0; while(1) { read(tsfd, &info, sizeof(info)); if(info.type == EV_ABS && info.code == ABS_X) x1 = info.value; if(info.type == EV_ABS && info.code == ABS_Y) y1 = info.value; if(x1 != 0 && y1 != 0) break; } while(1) { read(tsfd, &info, sizeof(info)); if(info.type == EV_ABS && info.code == ABS_X) x2 = info.value; if(info.type == EV_ABS && info.code == ABS_Y) y2 = info.value; if(info.type == EV_KEY && info.code == BTN_TOUCH && info.value == 0) break; } if(x2 - x1 > 50 && (y1 - y2 < 30 || y2 - y1 < 30)) printf("向右划屏\n"); if(x1 - x2 > 50 && (y1 - y2 < 30 || y2 - y1 < 30)) printf("向左划屏\n"); close(tsfd); return 0; }}
Linux 视频编程
1. 音视频编解码器 — mplayer
2. 下载与安装
cp mplayer /bin
3. 使用说明
mplayer -help
输出示例:
MPlayer 1.0rc2-4.5.1 © 2000-2007 MPlayer TeamCPU: ARM用法: mplayer [选项] [URL|路径/]文件名基本选项:...
基本控制键:
<- 或 -> 后退/快进 10 秒pgdown 或 pgup 后退/快进 1 分钟<- 或 -> 跳到播放列表中的前一个/后一个p 或 SPACE 暂停播放q 或 ESC 停止播放并退出程序+ 或 - 调整音频延迟增加/减少 0.1 秒o 循环 OSD 模式* 或 / 增加或减少 PCM 音量r 或 t 上/下调整字幕位置
4. 使用 slave命令控制视频
mplayer -slave -quiet -input file=/tmp/fifo -geometry 100:50 -zoom -x 600 -y 400 faded.avi &
摄像头编程
1. 摄像头格式
- JPG 格式
- YUV 格式(常见型号)
2. 摄像头工作原理
摄像头启动后,拍摄指定格式的图片并形成视频流。
3. 摄像头开发架构 — V4L2
#include
4. 摄像头初始化
linux_v4l2_yuyv_init("/dev/video7"); // 初始化摄像头
5. 摄像头操作
- 初始化摄像头
- 开始捕捉
- 获取图像数据
- 显示图像
- 退出摄像头
6. 相册实现
mkdir video_jpg
目录检索
1. 打开目录
#include#include DIR *opendir(const char *name);
2. 读取目录
struct dirent { unsigned char d_type; // 文件类型 char d_name[256]; // 文件名};struct dirent *readdir(DIR *dirp);
3. 关闭目录
int closedir(DIR *dirp);
GEC6818 空余空间使用
1. 格式化空余分区
mkfs.vfat /dev/mmcblk0p7
2. 挂载空余分区
mkdir mdatamount -t vfat /dev/mmcblk0p7 /mdata
3. 自动挂载配置
vi /etc/profile
在文件末尾添加:
mount -t vfat /dev/mmcblk0p7 /mdata
发表评论
最新留言
感谢大佬
[***.8.128.20]2025年04月23日 12时14分46秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
Kubernetes实战(三十三)-外部Etcd集群部署与调优(更安全的数据存储策略)
2023-01-29
Kubernetes实战(二十九)-集群资源管理(CPU & Memory)
2023-01-29
Kubernetes快速上手:部署、使用及核心概念解析
2023-01-29
lamp 一键安装
2023-01-30
laravel mix
2023-01-30
Laravel Passport
2023-01-30
laravel 之 Eloquent 模型修改器和序列化
2023-01-30
Laravel 使用 - artisan schedule使用
2023-01-30
Laravel 使用rdkafka
2023-01-30
Laravel 多环境配置
2023-01-30
laravel 学习之第二章
2023-01-30
Laravel 安装上传代码不完整的解决方法
2023-01-30
laravel 安装添加多站点
2023-01-30
Laravel 模型
2023-01-30
Laravel 深入理解路由和URL生成
2023-01-30
laravel 生命周期与框架精髓
2023-01-30
laravel 表单验证
2023-01-30
laravel 调试sql
2023-01-30