#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <error.h>
#include <unistd.h>
#include <sys/mman.h>

int lcd_fd = -1;     //帧缓冲文件描述符
int * plcd = NULL;//帧缓冲设备

//屏幕初始化
void CH_init()
{
int fd = open("/dev/fb0",O_RDWR);
if(fd==-1)
{
perror("open pingmv shibai");
}
lcd_fd = fd;
plcd = mmap(NULL,800*480*4,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0);//映射到屏幕
}

//画点函数
void huadian(int x0, int y0, int color)
{
if (x0 >= 0 && x0 < 480&&y0 >= 0 && y0 < 800  )
    {
        *(plcd + x0 * 800 + y0) = color;
    }
}

//白屏
void chushihua()
{
    int color = 0xffffffff;
    for(int i = 0;i<480;i++)
    {
        for(int j = 0;j<800;j++)
        {
             huadian(i,j,color);
        }
    }
}
     
 
//画圆函数
void huayuan()
{
int color[800*480]={0};
for(int i=0;i<480;i++)
{
for(int j=0;j<800;j++)
    {
    if((i-480)*(i-480)+(j-400)*(j-400)>122500 &&
(i-480)*(i-480)+(j-400)*(j-400)<160000) 
        {
            huadian(i,j,0x0F0FFaa0);
        }
    if((i-480)*(i-480)+(j-400)*(j-400)>90000 &&
(i-480)*(i-480)+(j-400)*(j-400)<122500) 
        {
            huadian(i,j,0x0F0F0F00);
        }
    if((i-480)*(i-480)+(j-400)*(j-400)>62500 &&
(i-480)*(i-480)+(j-400)*(j-400)<90000) 
        {
            huadian(i,j,0x0F0FFFF0);
        }
    }
}
}

//关闭屏幕
void guanbi_init()
{
munmap(plcd,800*480*4);
plcd = NULL;
close(lcd_fd);
}

int main()
{
CH_init();
chushihua();
huayuan();
guanbi_init();
}

 

技术
下载桌面版
GitHub
百度网盘(提取码:draw)
Gitee
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:766591547
关注微信