## 页首HTML代码 ```html

在开发板上画圆

IO编程

在开发板的LCD屏上画圆

/****************************************************************************
 *
 * file name: 2024-05-10_colorCircle.c
 * author   : tongyaqi1110@163.com
 * date     : 2024-05-10
 * function : 在开发板上画圆  
 * note     : None
 * CopyRight (c)   2024  tongyaqi1110@163.com   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;
}
posted @ 2024-05-10 22:32  一面小镜子  阅读(20)  评论(0编辑  收藏  举报