參考資訊:
https://stackoverflow.com/questions/32082248/how-to-display-something-on-screen-through-linux-framebuffer
main.c
#include <fcntl.h>
#include <linux/fb.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <unistd.h>
int main(int argc, char **argv)
{
int x = 0;
int y = 0;
int fd = 0;
uint16_t *fbp = 0;
uint32_t size = 0;
struct fb_var_screeninfo vinfo = {0};
struct fb_fix_screeninfo finfo = {0};
fd = open("/dev/fb0", O_RDWR);
ioctl(fd, FBIOGET_FSCREENINFO, &finfo);
ioctl(fd, FBIOGET_VSCREENINFO, &vinfo);
size = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;
fbp = (uint16_t*)mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
for (y = 0; y < 240; y++) {
for (x = 0; x < 320; x++) {
*fbp++ = 0xf800;
}
}
munmap(fbp, size);
close(fd);
return 0;
}