写点什么

嵌入式 Linux 下完成 LCD 屏文字显示 (帧缓冲框架)

作者:DS小龙哥
  • 2022 年 4 月 22 日
  • 本文字数:7828 字

    阅读完需:约 26 分钟

1.前言

帧缓冲框架是 Linux 下专门为显示类设备设计的接口,目的是将硬件和软件层分离开,方便应用层的编程,也方便应用层程序移植。帧缓冲框架向驱动层和应用层分别提供了一套标准接口,驱动层按照框架编写驱动,应用层按照框架编写应用程序。帧缓冲在/dev 目录下生成的标准节点是 fb,比如:/dev/fb0,/dev/fb1 等等。


这篇文章就介绍在应用层 如何利用帧缓冲框架接口封装 LCD 屏的画点函数,获取 LCD 屏的硬件信息,完成对 LCD 屏编程,实现文字、数字显示。当期的文字采用点阵方式取模来完成显示,比较简单,与单片机上的 LCD 编程思路一样,可以更方便快速学习帧缓冲编程。后续正常开发中一般采用矢量字库完成字体显示,大小调整方便,字体更换方法,在前面文章有介绍过嵌入式 Linux 如何交叉编译 freetype 库。


2. 编程思路

下面是帧缓冲框架图:




帧缓冲设备是标准的字符设备,通过 open 函数打开设备,再通过 ioctl 接口获取 LCD 屏的一些硬件参数信息,在利用 mmap 函数映射 LCD 屏的地址到应用层。映射的这个地址就相当于是 LCD 屏的显存地址,对这个地址里写入数据就可以在 LCD 屏硬件上实时显示出来。


int fd=open("/dev/fb0",O_RDWR);  if(fd<0)  {    perror("设备文件打开失败");    return 0;  }    /*1. 获取LCD屏的可变形参*/  ioctl(fd,FBIOGET_VSCREENINFO,&var);  printf("分辨率:%d*%d\n",var.xres,var.yres);  printf("像素点位数:%d\n",var.bits_per_pixel);    /*2. 获取LCD屏的固定形参*/  ioctl(fd,FBIOGET_FSCREENINFO,&fix);  printf("映射的长度:%d\n",fix.smem_len);  printf("一行的字节数:%d\n",fix.line_length);    /*3. 映射LCD缓冲区地址到进程空间*/  fb_mem=mmap(NULL,fix.smem_len,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0);  if(fb_mem==NULL)  {    perror("空间映射失败!\n");    return 0;  }
复制代码


在应用 mmap 函数将驱动的 DMA 缓冲区地址映射到进程空间之后,如何控制 LCD 呢?为了方便对 LCD 屏进行操作,需要封装一个画点函数。然后后续的图片显示,文字显示,其他图形显示都基于这个画点函数来完成,程序就很好设计。


当前采用的 LCD 屏是 800*480 分辨率,24 位像素,通过这些参数就可以编写一个公式,封装画点函数。



下面是封装好的函数原型:fb_mem 是 LCD 屏映射的地址,后面的参数是获取的 LCD 屏硬件参数信息。


/*函数功能: 画点*/void Show_Pixel(int x,int y,int color){  unsigned int *lcd=(unsigned int *)(fb_mem+y*var.xres*var.bits_per_pixel/8+x*var.bits_per_pixel/8);  *lcd=color; //颜色赋值}
复制代码


有了画点函数,就可以封装中文显示函数: 下面这个函数是针对横向取模的点阵字模进行描点的,其他取模方式根据情况修改即可。


/*函数功能: 显示中文说明:  取模的字体是按照横向取模进行取点阵码。       取模的字体宽度是8的倍数。*/void ShowFont(int x,int y,int size,unsigned char *data){  int i,j,x0=x;  unsigned char tmp;  for(i=0;i<size/8*size;i++)  {    tmp=data[i];    for(j=0;j<8;j++)    {      if(tmp&0x80)Show_Pixel(x0,y,0xFF0033);      //else 画背景色      x0++;      tmp<<=1;    }    if(x0-x==size)    {      y++;      x0=x;    }  }}
复制代码


中文可以显示,照着思路再封装一个字母数字的显示接口:


/*函数功能:  显示一个ASCII码。“空格开始 到  ~ 结束” !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
说明: ASCII码取模 宽度和高度必须是8的倍数,传入的size(高) */void ShowASCII(int x,int y,int size,unsigned char c_data){ int i,j,x0=x; unsigned char data; int cnt; if(c_data<' ' || c_data > '~')return; cnt=c_data-' '; for(i=0;i<size/2/8*size;i++) { switch(size) { case 16: break; case 32: data=ASCII_16_32[cnt][i]; break; } for(j=0;j<8;j++) { if(data&0x80)Show_Pixel(x0,y,0xFF0033); x0++; data<<=1; } if(x0-x==size/2) { x0=x; y++; } }}
复制代码

3. 完整示例代码

3.1 中文显示

下面这份代码是单个汉字取模进行显示的,代码较少,整体比较简单。


#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <sys/ioctl.h>#include <linux/fb.h>#include <sys/ioctl.h>#include <sys/mman.h>#include <string.h>
struct fb_var_screeninfo var; //可变参数struct fb_fix_screeninfo fix; //固定参数unsigned char *fb_mem=NULL; //LCD屏的首地址extern unsigned char font[];
/*函数功能: 画点*/void Show_Pixel(int x,int y,int color){ unsigned int *lcd=(unsigned int *)(fb_mem+y*var.xres*var.bits_per_pixel/8+x*var.bits_per_pixel/8); *lcd=color; //颜色赋值}
/*函数功能: 显示中文说明: 取模的字体是按照横向取模进行取点阵码。 取模的字体宽度是8的倍数。*/void ShowFont(int x,int y,int size,unsigned char *data){ int i,j,x0=x; unsigned char tmp; for(i=0;i<size/8*size;i++) { tmp=data[i]; for(j=0;j<8;j++) { if(tmp&0x80)Show_Pixel(x0,y,0xFF0033); //else 画背景色 x0++; tmp<<=1; } if(x0-x==size) { y++; x0=x; } }}

int main(int argc,char **argv){ int fd=open("/dev/fb0",O_RDWR); if(fd<0) { perror("设备文件打开失败"); return 0; } /*1. 获取LCD屏的可变形参*/ ioctl(fd,FBIOGET_VSCREENINFO,&var); printf("分辨率:%d*%d\n",var.xres,var.yres); printf("像素点位数:%d\n",var.bits_per_pixel); /*2. 获取LCD屏的固定形参*/ ioctl(fd,FBIOGET_FSCREENINFO,&fix); printf("映射的长度:%d\n",fix.smem_len); printf("一行的字节数:%d\n",fix.line_length); /*3. 映射LCD缓冲区地址到进程空间*/ fb_mem=mmap(NULL,fix.smem_len,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0); if(fb_mem==NULL) { perror("空间映射失败!\n"); return 0; } /*4. 控制显示屏*/ memset(fb_mem,0xFFFFFF,fix.smem_len); //将屏幕清屏为白色 ShowFont(100+0*56,100,56,font); ShowFont(100+1*56,100,56,font+7*56*1); ShowFont(100+2*56,100,56,font+7*56*2); munmap(fb_mem,fix.smem_len); close(fd); return 0;}

unsigned char font[]={ /*-- 文字: 嵌 --*//*-- 幼圆42; 此字体下对应的点阵为:宽x高=56x56 --*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x03,0x80,0x00,0x7C,0x00,0x03,0x80,0x07,0xC0,0x00,0x7C,0x00,0x03,0xC0,0x07,0xC0,0x00,0x7C,0x00,0x03,0xC0,0x07,0xC0,0x00,0x7C,0x00,0x03,0xC0,0x07,0xC0,0x00,0x7C,0x00,0x03,0xC0,0x07,0xC0,0x00,0x7C,0x00,0x03,0xC0,0x07,0xC0,0x00,0x7C,0x00,0x03,0xC0,0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0xE0,0x07,0x00,0xF0,0x00,0x00,0x01,0xE0,0x0F,0x01,0xF0,0x00,0x00,0x01,0xE0,0x0F,0x01,0xF0,0x00,0x00,0x01,0xE0,0x0F,0x01,0xE0,0x00,0x00,0x01,0xE0,0x0F,0x01,0xE0,0x00,0x00,0x1F,0xFF,0xFF,0xF3,0xFF,0xFF,0xF0,0x3F,0xFF,0xFF,0xFB,0xFF,0xFF,0xF8,0x3F,0xFF,0xFF,0xFB,0xFF,0xFF,0xF8,0x1F,0xFF,0xFF,0xE7,0xC3,0x80,0x7C,0x01,0xE0,0x0F,0x07,0x87,0x80,0x7C,0x01,0xE0,0x0F,0x0F,0x87,0x80,0x7C,0x01,0xE0,0x0F,0x0F,0x87,0x80,0x78,0x01,0xE0,0x0F,0x1F,0x07,0x80,0x78,0x01,0xE0,0x0F,0x1F,0x07,0x80,0xF8,0x01,0xE0,0x0F,0x3E,0x07,0x80,0xF8,0x01,0xE0,0x0F,0x3E,0x07,0x80,0xF0,0x01,0xE0,0x0F,0x3C,0x07,0x81,0xF0,0x01,0xE0,0x0F,0x3C,0x07,0x81,0xE0,0x01,0xE0,0x0F,0x00,0x07,0x83,0xE0,0x01,0xFF,0xFF,0x00,0x07,0xC3,0xC0,0x01,0xFF,0xFF,0x00,0x07,0xC0,0x00,0x01,0xFF,0xFF,0x00,0x0F,0xE0,0x00,0x01,0xFF,0xFF,0x00,0x0F,0xE0,0x00,0x01,0xE0,0x0F,0x00,0x0F,0xF0,0x00,0x01,0xE0,0x0F,0x00,0x1E,0xF0,0x00,0x01,0xE0,0x0F,0x00,0x1E,0xF8,0x00,0x01,0xE0,0x0F,0x00,0x3E,0x78,0x00,0x01,0xE0,0x0F,0x00,0x7C,0x7C,0x00,0x01,0xE0,0x0F,0x00,0x78,0x3E,0x00,0x01,0xE0,0x0F,0x00,0xF8,0x1E,0x00,0x01,0xE0,0x0F,0x01,0xF0,0x1F,0x00,0x01,0xE0,0x0F,0x03,0xE0,0x0F,0x80,0x01,0xE0,0x0F,0x07,0xE0,0x07,0xC0,0x01,0xE0,0x0F,0x0F,0xC0,0x03,0xE0,0x01,0xE0,0x0F,0x1F,0x80,0x01,0xF0,0x01,0xFF,0xFF,0x3F,0x00,0x01,0xF8,0x00,0xFF,0xFF,0x7E,0x00,0x00,0xFC,0x00,0x7F,0xFE,0x78,0x00,0x00,0x3C,0x00,0x00,0x00,0x70,0x00,0x00,0x18,
/*-- 文字: 入 --*//*-- 幼圆42; 此字体下对应的点阵为:宽x高=56x56 --*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xC0,0x00,0x00,0x00,0x00,0x00,0x0F,0xE0,0x00,0x00,0x00,0x00,0x00,0x07,0xF0,0x00,0x00,0x00,0x00,0x00,0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x80,0x00,0x00,0x00,0x00,0x00,0x3F,0x80,0x00,0x00,0x00,0x00,0x00,0x7F,0xC0,0x00,0x00,0x00,0x00,0x00,0x7F,0xC0,0x00,0x00,0x00,0x00,0x00,0x7B,0xC0,0x00,0x00,0x00,0x00,0x00,0xFB,0xE0,0x00,0x00,0x00,0x00,0x00,0xF1,0xE0,0x00,0x00,0x00,0x00,0x00,0xF1,0xE0,0x00,0x00,0x00,0x00,0x01,0xF1,0xF0,0x00,0x00,0x00,0x00,0x01,0xE0,0xF0,0x00,0x00,0x00,0x00,0x03,0xE0,0xF8,0x00,0x00,0x00,0x00,0x03,0xC0,0xF8,0x00,0x00,0x00,0x00,0x07,0xC0,0x7C,0x00,0x00,0x00,0x00,0x07,0x80,0x7C,0x00,0x00,0x00,0x00,0x0F,0x80,0x3C,0x00,0x00,0x00,0x00,0x0F,0x00,0x3E,0x00,0x00,0x00,0x00,0x1F,0x00,0x1E,0x00,0x00,0x00,0x00,0x1E,0x00,0x1F,0x00,0x00,0x00,0x00,0x3E,0x00,0x0F,0x00,0x00,0x00,0x00,0x7C,0x00,0x0F,0x80,0x00,0x00,0x00,0x7C,0x00,0x07,0xC0,0x00,0x00,0x00,0xF8,0x00,0x07,0xC0,0x00,0x00,0x01,0xF0,0x00,0x03,0xE0,0x00,0x00,0x01,0xE0,0x00,0x01,0xE0,0x00,0x00,0x03,0xE0,0x00,0x01,0xF0,0x00,0x00,0x07,0xC0,0x00,0x00,0xF8,0x00,0x00,0x0F,0x80,0x00,0x00,0xF8,0x00,0x00,0x1F,0x00,0x00,0x00,0x7C,0x00,0x00,0x1F,0x00,0x00,0x00,0x3E,0x00,0x00,0x3E,0x00,0x00,0x00,0x3E,0x00,0x00,0x7C,0x00,0x00,0x00,0x1F,0x00,0x00,0xF8,0x00,0x00,0x00,0x0F,0x80,0x01,0xF0,0x00,0x00,0x00,0x07,0xC0,0x03,0xE0,0x00,0x00,0x00,0x03,0xE0,0x07,0xC0,0x00,0x00,0x00,0x03,0xF0,0x0F,0x80,0x00,0x00,0x00,0x01,0xF8,0x1F,0x00,0x00,0x00,0x00,0x00,0xFC,0x1E,0x00,0x00,0x00,0x00,0x00,0x7C,0x1C,0x00,0x00,0x00,0x00,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/*-- 文字: 式 --*//*-- 幼圆42; 此字体下对应的点阵为:宽x高=56x56 --*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xEF,0x80,0x00,0x00,0x00,0x00,0x01,0xEF,0xE0,0x00,0x00,0x00,0x00,0x01,0xEF,0xF0,0x00,0x00,0x00,0x00,0x01,0xE3,0xFC,0x00,0x00,0x00,0x00,0x01,0xE0,0xFF,0x00,0x00,0x00,0x00,0x01,0xF0,0x7F,0x80,0x00,0x00,0x00,0x01,0xF0,0x1F,0xC0,0x00,0x00,0x00,0x00,0xF0,0x07,0xC0,0x00,0x00,0x00,0x00,0xF0,0x03,0xC0,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x0F,0xFF,0xFF,0xFE,0x3C,0x00,0x00,0x0F,0xFF,0xFF,0xFE,0x3C,0x00,0x00,0x0F,0xFF,0xFF,0xFE,0x3C,0x00,0x00,0x00,0x00,0xF0,0x00,0x3C,0x00,0x00,0x00,0x00,0xF0,0x00,0x3E,0x00,0x00,0x00,0x00,0xF0,0x00,0x3E,0x00,0x00,0x00,0x00,0xF0,0x00,0x1E,0x00,0x00,0x00,0x00,0xF0,0x00,0x1E,0x00,0x00,0x00,0x00,0xF0,0x00,0x1E,0x00,0x00,0x00,0x00,0xF0,0x00,0x1F,0x00,0x00,0x00,0x00,0xF0,0x00,0x0F,0x00,0x00,0x00,0x00,0xF0,0x00,0x0F,0x00,0x00,0x00,0x00,0xF0,0x00,0x0F,0x80,0x00,0x00,0x00,0xF0,0x00,0x0F,0x80,0x18,0x00,0x00,0xF0,0x00,0x07,0x80,0x3C,0x00,0x00,0xF0,0x00,0x07,0x80,0x3C,0x00,0x00,0xF0,0x00,0x07,0xC0,0x3C,0x00,0x00,0xF0,0x00,0x03,0xC0,0x3C,0x00,0x00,0xF0,0x03,0xC3,0xE0,0x3C,0x00,0x00,0xF0,0x1F,0xC1,0xE0,0x3C,0x00,0x00,0xF1,0xFF,0xC1,0xF0,0x3C,0x00,0x00,0xFF,0xFF,0x01,0xF0,0x3C,0x00,0x01,0xFF,0xF8,0x00,0xF8,0x3C,0x00,0x0F,0xFF,0x80,0x00,0xF8,0x7C,0x01,0xFF,0xFC,0x00,0x00,0x7C,0x7C,0x1F,0xFF,0xC0,0x00,0x00,0x3F,0x78,0x3F,0xFC,0x00,0x00,0x00,0x1F,0xF8,0x3F,0xC0,0x00,0x00,0x00,0x1F,0xF0,0x00,0x00,0x00,0x00,0x00,0x07,0xF0,0x00,0x00,0x00,0x00,0x00,0x01,0xE0};
复制代码

3.2 调用字库显示

单个汉字取模太麻烦,可以使用点阵字库取模软件,然后程序里打开字库,读取字模进行绘制,下面的示例代码就是采用字库读取字模完成汉字显示。


#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <sys/ioctl.h>#include <linux/fb.h>#include <sys/ioctl.h>#include <sys/mman.h>#include <string.h>#include <sys/types.h>#include <sys/stat.h>#include <unistd.h>
struct fb_var_screeninfo var; //可变参数struct fb_fix_screeninfo fix; //固定参数unsigned char *fb_mem=NULL; //LCD屏的首地址unsigned char *fb_GBK=NULL; //GBK字库的首地址extern unsigned char font[];extern const unsigned char ASCII_16_32[95][64];
/*函数功能: 画点*/void Show_Pixel(int x,int y,int color){ unsigned int *lcd=(unsigned int *)(fb_mem+y*var.xres*var.bits_per_pixel/8+x*var.bits_per_pixel/8); *lcd=color; //颜色赋值}
/*函数功能: 显示中文说明: 取模的字体是按照横向取模进行取点阵码。 取模的字体宽度是8的倍数。*/void ShowFont(int x,int y,int size,unsigned char *font){ unsigned char L,H; unsigned int Addr; unsigned int font_size=size*size/8; //得到该字节的总字节大小 unsigned char FontData[128]; //最大可以存放32*32尺寸字体点阵码 unsigned char *GBK_p; //存放汉字点阵码首地址 /*计算该汉字在字库里的地址偏移量*/ L=*(font+1); //低字节 H=*font; //高字节 if(L<0x7f)L=L-0x40; else L=L-0x41; H=H-0x81; Addr=(190*H+L)*font_size; //得到当前汉字在字库里的偏移量 GBK_p=(unsigned char *)(Addr+fb_GBK); //得到汉字点阵码在字库里首地址 int i,j,x0=x; unsigned char tmp; for(i=0;i<size/8*size;i++) { tmp=GBK_p[i]; for(j=0;j<8;j++) { if(tmp&0x80)Show_Pixel(x0,y,0xFF0033); //else 画背景色 x0++; tmp<<=1; } if(x0-x==size) { y++; x0=x; } }}
/*函数功能: 显示一个ASCII码。“空格开始 到 ~ 结束” !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
说明: ASCII码取模 宽度和高度必须是8的倍数,传入的size(高) */void ShowASCII(int x,int y,int size,unsigned char c_data){ int i,j,x0=x; unsigned char data; int cnt; if(c_data<' ' || c_data > '~')return; cnt=c_data-' '; for(i=0;i<size/2/8*size;i++) { switch(size) { case 16: break; case 32: data=ASCII_16_32[cnt][i]; break; } for(j=0;j<8;j++) { if(data&0x80)Show_Pixel(x0,y,0xFF0033); x0++; data<<=1; } if(x0-x==size/2) { x0=x; y++; } }}

int main(int argc,char **argv){ if(argc!=2) { printf("./app <GBK字库文件>\n"); return 0; } int fd=open("/dev/fb0",O_RDWR); if(fd<0) { perror("设备文件打开失败"); return 0; } /*1. 获取LCD屏的可变形参*/ ioctl(fd,FBIOGET_VSCREENINFO,&var); printf("分辨率:%d*%d\n",var.xres,var.yres); printf("像素点位数:%d\n",var.bits_per_pixel); /*2. 获取LCD屏的固定形参*/ ioctl(fd,FBIOGET_FSCREENINFO,&fix); printf("映射的长度:%d\n",fix.smem_len); printf("一行的字节数:%d\n",fix.line_length); /*3. 映射LCD缓冲区地址到进程空间*/ fb_mem=mmap(NULL,fix.smem_len,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0); if(fb_mem==NULL) { perror("空间映射失败!\n"); return 0; } /*4. 映射GBK字库文件到进程空间*/ int gbk_fb; struct stat gbk_buf; gbk_fb=open(argv[1],2); if(gbk_fb<0) { perror("GBK字库文件打开失败!"); return 0; } stat(argv[1],&gbk_buf); printf("GBK字库文件大小=%d\n",gbk_buf.st_size); fb_GBK=mmap(NULL,gbk_buf.st_size,PROT_READ,MAP_SHARED,gbk_fb,0); if(fb_GBK==NULL) { perror("空间映射失败!\n"); return 0; } /*4. 控制显示屏*/ memset(fb_mem,0xFFFFFF,fix.smem_len); //将屏幕清屏为白色 ShowFont(100+0*32,100,32,"嵌"); ShowFont(100+1*32,100,32,"入"); ShowFont(100+2*32,100,32,"式"); ShowFont(100+3*32,100,32,"开"); ShowFont(100+4*32,100,32,"发"); ShowASCII(100+0*16,200,32,'A'); ShowASCII(100+1*16,200,32,'C'); ShowASCII(100+2*16,200,32,'B'); munmap(fb_mem,fix.smem_len); close(fd); return 0;}
复制代码


发布于: 刚刚阅读数: 3
用户头像

DS小龙哥

关注

之所以觉得累,是因为说的比做的多。 2022.01.06 加入

熟悉C/C++、51单片机、STM32、Linux应用开发、Linux驱动开发、音视频开发、QT开发. 目前已经完成的项目涉及音视频、物联网、智能家居、工业控制领域

评论

发布
暂无评论
嵌入式Linux下完成LCD屏文字显示(帧缓冲框架)_4月月更_DS小龙哥_InfoQ写作社区