#include <stdio.h>
#include<stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include<sys/mman.h>
#include <linux/input.h>
#include <sys/types.h>
#include <string.h>
#include <pthread.h>
#include "list.h"
#include "file_operations.h"
#include "showjpg.h"
#include "showbmp.h"
#include "video.h"
#include "show_font.h"
#include "login.h"
// void *user_login(void * arg){
// // printf("%d\n",ts);
// int ts = *(int *)arg;
// int x = 0, y = 0, m = 0,n = 0;
// // int login_flag =0;
// show_photo("/six/audio/login.bmp",0,0);
// while (1)
// {
// printf("111\n");
// get_xy(ts, &x, &y);
// printf("222\n");
// printf("x=%d,y=%d\n",x,y);
// if(x>240&&x<330&&y>130&&y<190){
// n=n*10+1;
// m=m+1;
// }
// else if(x>350&&x<440&&y>130&&y<190){
// n=n*10+2;
// m=m+1;
// }
// else if(x>460&&x<550&&y>130&&y<190){
// n=n*10+3;
// m=m+1;
// }
// else if(x>240&&x<330&&y>205&&y<265){
// n=n*10+4;
// m=m+1;
// }
// else if(x>350&&x<440&&y>205&&y<265){
// n=n*10+5;
// m=m+1;
// }
// else if(x>460&&x<550&&y>205&&y<265){
// n=n*10+6;
// m=m+1;
// }
// else if(x>240&&x<330&&y>280&&y<340){
// n=n*10+7;
// m=m+1;
// }
// else if(x>350&&x<440&&y>280&&y<340){
// n=n*10+8;
// m=m+1;
// }
// else if(x>460&&x<550&&y>280&&y<340){
// n=n*10+9;
// m=m+1;
// }
// else if(x>350&&x<440&&y>355&&y<415){
// n=n*10;
// m=m+1;
// }
// else if(x>460&&x<550&&y>355&&y<415){
// n=n/10;
// m=m-1;
// }
// else if(m==6&&n==123456){
// login_flag = 1;
// break;
// }
// printf("%d\n",n);
// }
// pthread_exit(NULL);
// }
int flag = 0;
int i,j;
void *auto_exit(void *arg){
i =0;
j =0;
int ts =*(int *)arg;
get_xy(ts, &i, &j);
if(i!=0||j!=0){
flag = 1;
pthread_exit(NULL);
}
}
int main()
{
int ts = open("/dev/input/event0", O_RDONLY);
if (ts == -1)
{
printf("Error opening touchscreen\n");
return -1;
}
// printf("%d\n",ts);
// pthread_t loginID;
// pthread_create(&loginID,NULL,user_login,(void *)&ts);
// pthread_join(loginID,NULL);
int login_flag = user_login(ts);
if (login_flag == 1)
{
plist head = init_list();
if (head == NULL)
{
printf("Head node application failed!");
return -1;
}
int photo_num = get_mulu(head);
printf("photo number is: %d\n", photo_num);
while (1)
{
// struct input_event info;
show_photo("/mnt/udisk/index2.bmp", 0, 0);
int x = 0, y = 0, num = 0;
get_xy(ts, &x, &y);
if (x > 190 && x < 280 && y > 80 && y < 150)
{ // 自动播放
pthread_t xcID;
pthread_create(&xcID,NULL,auto_exit,(void *)&ts);
plist p = head->next;
while (1)
{
qingping();
if(strstr(p->a,".bmp") !=NULL)
{
show_photo(p->a, 0, 0);
}
else if(strstr(p->a,".jpg") !=NULL)
{
showjpg(p->a,0,0);
}
char str[20];
char* startPtr = p->a + 26;
strcpy(str, startPtr);
show_font(str);
// printf("%s\n", p->a);
p = p->next;
num++;
sleep(2);
if (num == photo_num || flag == 1)
{
flag = 0;
break;
}
// void *thread_result;
// if (pthread_join(xcID, &thread_result) == 0) {
// if (*(int *)thread_result != 0) {
// flag = 1; // 设置标志位为1,表示需要终止循环
// }
// }
}
}
else if (x > 603 && x < 800 && y > 216 && y < 366)
{ // 手动播放
plist p = head->next;
qingping();
if(strstr(p->a,".bmp") !=NULL)
{
show_photo(p->a, 0, 0);
}else if(strstr(p->a,".jpg") !=NULL)
{
showjpg(p->a,0,0);
}
show_caozuo();
// printf("%s\n", p->a);
char str[20];
char* startPtr = p->a + 26;
strcpy(str, startPtr);
show_font(str);
while (1)
{
int i = 0, j = 0;
get_xy(ts, &i, &j);
if (i > 20 && i < 170 && j > 190 && j < 290)
{ // 上一张图
p = p->prev;
if (p == head)
{
p = p->prev;
}
qingping();
if(strstr(p->a,".bmp") !=NULL)
{
show_photo(p->a, 0, 0);
}else if(strstr(p->a,".jpg") !=NULL)
{
showjpg(p->a,0,0);
}
show_caozuo();
// printf("%s\n", p->a);
char str[20];
char* startPtr = p->a + 26;
strcpy(str, startPtr);
show_font(str);
}
else if (i > 620 && i < 770 && j > 190 && j < 290)
{ // 下一张图
p = p->next;
if (p == head) {
p = p->next;
}
qingping();
if(strstr(p->a,".bmp") !=NULL){
show_photo(p->a, 0, 0);
}else if(strstr(p->a,".jpg") !=NULL)
{
showjpg(p->a,0,0);
}
// printf("111\n");
show_caozuo();
// printf("222\n");
// printf("%s\n", p->a);
char str[20];
char* startPtr = p->a + 26;
strcpy(str, startPtr);
show_font(str);
// printf("221\n");
}
else if (i > 20 && i < 95 && j > 20 && j < 95)
{ // 返回
break;
}
else if (i > 700 && i < 750 && j > 20 && j < 70)
{ // 删除
int res = del_mulu(p->a);
if (res == 0)
{
printf("delete photo successfully!\n");
plist current = p;
p = p->next;
plist prev = p->prev;
prev->next = current;
current->prev = prev;
free(current);
photo_num = get_mulu(head);
break;
}
}
else if (i > 350 && i < 450 && j > 400 && j < 450)
{ // 重命名
基于GEC6818开发板的电子相册程序
需积分: 5 198 浏览量
2023-09-20
16:47:04
上传
评论 1
收藏 76.17MB RAR 举报
风灵丶无畏
- 粉丝: 20
- 资源: 5
最新资源
- pta题库答案c语言之排序4统计工龄.zip
- pta题库答案c语言之树结构7堆中的路径.zip
- pta题库答案c语言之树结构3TreeTraversalsAgain.zip
- pta题库答案c语言之树结构2ListLeaves.zip
- pta题库答案c语言之树结构1树的同构.zip
- 基于C++实现民航飞行与地图简易管理系统可执行程序+说明+详细注释.zip
- pta题库答案c语言之复杂度1最大子列和问题.zip
- 三维装箱问题(Three-Dimensional Bin Packing Problem,3D-BPP)是一个经典的组合优化问题
- 以下是一些关于Linux线程同步的基本概念和方法.txt
- 以下是一个简化的示例,它使用pygame库来模拟烟花动画的框架.txt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈