其他分享
首页 > 其他分享> > 在arm开发板上画日本国旗

在arm开发板上画日本国旗

作者:互联网

1.开发环境:ubuntu,arm-linux-gcc

2.园的公式 (x-a)*(x-a)+(y-b)*(y-b)=r*r

3.日本国旗的是比是3:2

代码:

#include<stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
int main()
{  
    //打开lcd
    int fd_lcd;
    fd_lcd=open("/dev/fb0",O_RDWR);
    if(fd_lcd<0)
    {
        printf("open fd0 fail\namespace");
        return -1;
    }
    
    int *addr;
    addr=mmap(NULL,800*480*4,PROT_READ|PROT_WRITE,MAP_SHARED,fd_lcd,0);
    if(addr==NULL)
    {
        printf("mmap fail\n");
        return -1;
    }

    int x;//lcd x坐标
    int y;//lcd y坐标
    int red=0x00ff0000;
    int grenn=0x0000ff00;
    int blue=0x000000ff;
    int black=0x00000000;
    int gold=0x00FFD700;
    int white=0x00ffffff;
    int a,b;

    for(y=0;y<480;y++)
    {
        for(x=0;x<800;x++)
        {
            if((a*a+b*b)<((800/3)*(480/4)))
            {
                *(addr+y*800+x)=red;
            }
            else 
            {
                *(addr+y*800+x)=white;
            }
            a=y-480/2,b=x-800/2;
        }
    }

    munmap(addr,800*480*4);
    close(fd_lcd);

    return 0;
}

 

标签:800,addr,上画,int,开发板,lcd,fd,include,arm
来源: https://blog.csdn.net/weixin_46020777/article/details/121592116