IO编程
在开发板的LCD屏上画圆
/****************************************************************************
*
* file name: 2024-05-10_colorCircle.c
* author : [email protected]
* date : 2024-05-10
* function : 在开发板上画圆
* note : None
* CopyRight (c) 2024 [email protected] Right Reseverd
*
****************************************************************************/
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main()
{
int color;
int lcd_fd = open("/dev/fb0", O_RDWR);//打开LCD屏的驱动文件
if (-1 == lcd_fd)
{
printf("open lcd error\n");
exit(-1);
}
int colorbuf[480][800] = {0};//定义一个二维数组,大小为开发板的分辨率
int x, y;
for (x = 0; x < 480; x++)
{
for (y = 0; y < 800; y++)
{
//如果满足圆的定义条件x*x+y*y=0;
if ((x - 240) * (x - 240) + (y - 400) * (y - 400) <= 100 * 100)
{
colorbuf[x][y] = 0x00000000;//黑色
continue;
}
else
{
colorbuf[x][y] = 0x00ff0000;//红色
}
}
}
write(lcd_fd, colorbuf, 800 * 480 * 4);
close(lcd_fd);
return 0;
}
标签:int,开发板,2024,lcd,画圆,include
From: https://www.cnblogs.com/little-mirror/p/18185408