Advertisement

Linux高级应用第三部分通过LCD屏幕显示图像

阅读量:

一、C语言调用外部函数
1、通过extern关键字进行声明

lcd.c
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

int lcd_show_color(int color)
{
//1)初始化液晶屏设备
int fd_lcd;
fd_lcd = open("/dev/fb0", O_RDWR);
if(fd_lcd == -1)
{
perror("open lcd");
return -1;
}
//2)将数据写入液晶屏显示区域
int lcd_buf[800 _480];
for(int i=0;i<800_480;i++)
lcd_buf[i]=color;//绿色设置
write(fd_lcd,lcd_buf,sizeof(lcd_buf));//传输数据大小为800 480 4

复制代码
    //3)关闭液晶屏
    close(fd_lcd)
    return 0;
    
    
      
      
      
    

【}

main.c
#include <stdio.h>
#include <stdlib.h>

全部评论 (0)

还没有任何评论哟~