fb设为24位模式:

fbset -fb /dev/fb0 -g 800 600 800 600 24 -n

用r g b填充fb:

use-fb 255 0 0    //red

use-fb 0 255 0    //green

...

 

use-fb.c 代码:

/* use-fb.c*/

#include <stdio.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <sys/mman.h>
#include <stdlib.h>

struct fb_var_screeninfo vinfo;

int
main(int argc, char *argv[])
{
 int fbfd, fbsize, i;
 int red, green, blue;
 unsigned char *fbbuf;

 if (argc != 4) {
  printf("usage: use-fb red green blue/n");
  exit(0);
 }
 red = atoi(argv[1]);
 green = atoi(argv[2]);
 blue = atoi(argv[3]);
 
 /* Open video memory */
 if ((fbfd = open("/dev/fb0", O_RDWR)) < 0) {
  exit(1);
 } 
 /* Get variable display parameters */
 if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) {
  printf("Bad vscreeninfo ioctl/n");
  exit(2);
 }
 /* Size of frame buffer */
 fbsize = vinfo.xres*vinfo.yres*(vinfo.bits_per_pixel/8);
 /* Map video memory */
 if ((fbbuf = mmap(0, fbsize, PROT_READ | PROT_WRITE,
  MAP_SHARED, fbfd, 0)) == (void *) -1) {
  exit(3);
 }
 /* Clear the screen */ 
 for (i = 0; i < fbsize; i++) {
  *(fbbuf + i++) = red;
  *(fbbuf + i++) = green;
  *(fbbuf + i) = blue;
 }
  
 printf("clear screen with rgb:%s %s %s/n", argv[1], argv[2], argv[3]);
 munmap(fbbuf, fbsize);
 close(fbfd);
}

GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐