-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
155 lines (124 loc) · 2.53 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#include "main.h"
#include "functions.c"
int main(int argc,char **argv)
{
unsigned char* fbp;
if(usb() != 0)
{
fprintf(stdout,"Faile to mount USB.\n");
exit(1);
}
if(get_media_info(&my_usb_info) != 0)
{
fprintf(stdout,"%s:%d:Faled to get usb device information.\n ",__FILE__,__LINE__);
exit(1);
}
if((fbp =init_framebuff(&vinfo,&finfo)) ==NULL)
{
fprintf(stdout,"Failed to init framebuff.\n");
exit(1);
}
int code;
pthread_t pthread_key_ctr;
if((code = pthread_create(&pthread_key_ctr,NULL,key_ctr,NULL)) < 0)
{
fprintf(stderr,"Create thread failed:%s\n",strerror(errno));
exit(1);
}
chdir("./mountPos");
//int i;
//fprintf(stdout,"counter_p =%d\n",my_usb_info.counter_p);
//fprintf(stdout,"buff_media_picture[1] =%s\n",my_usb_info.buff_media_picture[1]);
while(1)
{
if(picture_mode == 1)
{
int i;
for(i = 0;i < my_usb_info.counter_p;i++)
{
memset(buffer,0,screensize);
picture_to_memory_copy(my_usb_info.buff_media_picture[i]);
//int line_size = vinfo.xres *vinfo.bits_per_pixel/8;
//for(j = 0;j <= vinfo.yres;j++)
//{
// memcpy(fbp + j * line_size,buffer,line_size);
// usleep(100);
//}
memset(fbp,0,screensize);
memcpy(fbp,buffer,screensize);
memset(buffer,0,screensize);
sleep(1);
if(quit_flag == 1)
{
break;
}
if(back_menu == 1)
{
back_menu = 0;
picture_mode = 0;
break;
}
}
}
else if(picture_mode == 2)
{
if(selects_flag == 1)
{
//fprintf(stdout,"%s:%d:Can'i go here?\n",__FILE__,__LINE__);
//fflush(stdout);
memset(buffer,0,screensize);
picture_to_memory_copy(my_usb_info.buff_media_picture[selects]);
//fprintf(stdout,"%s:%d:Can'i go here?\n",__FILE__,__LINE__);
//fflush(stdout);
//memset(fbp,0,screensize);
memcpy(fbp,buffer,screensize);
memset(buffer,0,screensize);
selects_flag = 0;
key_down_flag = 0;
while(1)
{
if(un_selects_flag == 1)
{
un_selects_flag = 0;
key_down_flag = 0;
break;
}
if(back_menu == 1)
{
back_menu = 0;
key_down_flag = 0;
break;
}
if(quit_flag == 1)
{
break;
}
}
}
show_pictures();
while(!key_down_flag)
{
un_selects_flag = 0;
}
if(back_menu == 1)
{
back_menu = 0;
picture_mode = 0;
continue;
}
if(quit_flag == 1)
{
break;
}
}
if(quit_flag == 1)
{
quit_flag = 0;
break;
}
}
chdir("..");
umount("./mountPos");
system("rm -r mountPos");
return 0;
}