lcd屏幕绘制国旗

/*************************************************
 *
 *   file name:color.c
 *   author   :miaowei023@163.com
 *   date     :2025/05/10
 *   brief    :向lcd屏幕输出德国国旗
 *   note     :None
 *
 *   CopyRight (c) 2025    miaowei023@163.com    All Right Reseverd
 *
 **************************************************/

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
int main(void)
{
    int lcd_fd = open("/dev/fb0", O_RDWR);
    if (-1 == lcd_fd)
    {
        printf("open lcd faild\n");
        return -1;
    }
    int colorbuf[800 * 480] = {0};
    for (int i = 0; i < 800 * 160; i++)
    {
        colorbuf[i] = 0x00000000;
    }
    for (int i = 800 * 160; i < 800 * 320; i++)
    {
        colorbuf[i] = 0x00ff0000;
    }
    for (int i = 800 * 320; i < 800 * 480; i++)
    {
        colorbuf[i] = 0x00ffff00;
    }
    write(lcd_fd, colorbuf, 800 * 480 * 4);
    return 0;
}

posted @ 2025-07-17 12:13  喵喵机023  阅读(13)  评论(0)    收藏  举报