在4核心8线程开发板上显示德国国旗
* name;GemanyColor
* function:德国国国旗
* parameter;
* ReValue;
* author;小北blog
* attention;none
* date;2024.05.25
* Copyright(c) 2024 huahuadebaby99@163.com GemanyColorAll rights Reserved
*************************************************************************/
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
int main()
{
// 1.打开文件
int lcd_fd = open("/dev/fb0", O_RDWR);
if (lcd_fd == -1)
{
perror("lcd open failed!");
}
// 2.写入颜色
int i = 0; // 把i循环条件写在外面下面的for可以不用写第一个条件
int color_buffer[800 * 480] = {0};
// 写入黑颜色
for (; i < 800 * 160; i++)
{
color_buffer[i] = 0x00000000;
}
// 写入红颜色
for (; i < 800 * 320; i++)
{
color_buffer[i] = 0x00FF0000;
}
// 写入黄色颜色
for (; i < 800 * 480; i++)
{
color_buffer[i] = 0x00FFFF00;
}
write(lcd_fd, color_buffer, 800 * 480 * 4); // 这第三个参数的单位是字节
// 3.关闭文件
close(lcd_fd);
return 0;
}
总结:
1.打开开发板的屏幕程序需要找到开发板系统目录下的dev/fb0
2.德国国旗三个颜色,写入颜色需要三个循环,或者一个循环里面三个判断,写法有这两种,为了可读性选择了三个循环