資源簡介
將ARM開發板與電腦網線相連,設置好IP地址,在ZOC
軟件里面配置好IP、文件地址,然后在Linux虛擬機里面將此c程序放在共享文件夾里編譯運行,之后在開發板上就能看到自動播放的不同圖片
代碼片段和文件信息
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
unsigned?short?RGB888toRGB565(unsigned?char?red?unsigned?char?green?unsigned?char?blue);
unsigned?long?RGB888toRGB32(unsigned?char?red?unsigned?char?green?unsigned?char?blue);
int?main(int?argc?char?*argv[])
{
///////////////////
??int?keys_fd;??
??char?ret[2];??
??struct?input_event?t;??
??
??keys_fd?=?open?(“/dev/input/event0“?O_RDONLY);??
??if?(keys_fd?<=?0)??
????{??
??????printf?(“open?/dev/input/event0?device?error!\n“);??
??????return?0;??
????}?
///////////////////
int?framebuffer_fd?=?0;
int?fb?=?0;
unsigned?int?x?y?i?;
struct?fb_var_screeninfo?vinfo;
struct?fb_fix_screeninfo?finfo;
long?int?screensize?=?0;
char?*fbp?=?0;
struct?jpeg_decompress_struct?cinfo;
struct?jpeg_error_mgr?jerr;
if(argc?!=?5)
{
printf(“insuffient?auguments“);
exit(-1);
}
framebuffer_fd?=?open(“/dev/fb0“O_RDWR);
if(framebuffer_fd<=0)
{
printf(“error:can?not?open?framebuffer?device.\n“);
return?-1;
}
printf(“the?framebuffer?device?was?opened?successfully.\n“);
if(ioctl(framebuffer_fd?FBIOGET_VSCREENINFO?&vinfo))
{
printf(“error?reading?variable?information.\n“);
return?-3;
}
if?(ioctl(framebuffer_fd?FBIOGET_FSCREENINFO?&finfo))
{
printf(“Error?reading?fixed?information.\n“);
exit(-3);
}
screensize?=?vinfo.xres*vinfo.yres*vinfo.bits_per_pixel/8;
fbp=(char*)mmap(0?screensizePROT_READ|PROT_WRITEMAP_SHAREDframebuffer_fd0);
if((int)fbp==-1)
{
printf(“error:failed?to?map?framebuffer?device?to?memory.\n“);
return?-4;
}
printf(“success?to?map?framebuffer?device?to?memory.\n“);
FILE?*infp;
unsigned?char?*buffer;
??while(1){
???????for(i=0;i<4;i++)
???{
if((infp=fopen(argv[1+i]“r“))?==?NULL)
{
printf(“Error:open?%s?failed?\n“argv[1]);
exit(0);
}
?
??
cinfo.err=jpeg_std_error(&jerr);
jpeg_create_decompress(&cinfo);//初始化cinfo
jpeg_stdio_src(&cinfo?infp);?//指定要解壓的文件
jpeg_read_header(&cinfo?TRUE);
jpeg_start_decompress(&cinfo);
if((cinfo.output_width?>?vinfo.xres)?||?(cinfo.output_height?
- 上一篇:dibazhang.sln
- 下一篇:利用DS1302實現單片機控制的電子萬年歷
評論
共有 條評論