天嵌二次封装库使用手册  V2.1.2
lib_fbraw.h
浏览该文件的文档.
1 
7 #ifndef LINUX_LIBV2_SOURCE_FBUTIL_LIB_FBUTIL_H_
8 #define LINUX_LIBV2_SOURCE_FBUTIL_LIB_FBUTIL_H_
9 
10 // Copyright 2024
11 
12 
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <string.h>
16 #include <unistd.h>
17 #include <fcntl.h>
18 #include <stdarg.h>
19 #include <sys/ioctl.h>
20 #include <sys/mman.h>
21 #include <sys/time.h>
22 #include <linux/vt.h>
23 #include <linux/kd.h>
24 #include <linux/fb.h>
25 #include <arpa/inet.h>
26 #include "font.h"
27 
28 
29 #ifdef __cplusplus
30 #define FBUTIL_API extern "C"
31 #else
32 #define FBUTIL_API
33 #endif
34 
39  char* fbdevice;
40  int fb_fd;
41  struct fb_fix_screeninfo fix;
42  struct fb_var_screeninfo var;
43  unsigned char *fbuffer;
44  unsigned char **line_addr;
46  unsigned int colormap [256];
47  };
48  #define XORMODE 0x80000000
49 
52  FBUTIL_API union multiptr
53  {
54  unsigned char *p8;
55  unsigned short *p16;
56  unsigned long *p32;
57  };
64  FBUTIL_API int open_framebuffer(const char *dev, struct fb_data *f_data);
65 
70  FBUTIL_API void close_framebuffer(struct fb_data *f_data);
71 
81  FBUTIL_API void line(struct fb_data *f_data, int x1, int y1, int x2, int y2, unsigned colidx);
82 
91  FBUTIL_API void put_string(struct fb_data *f_data, int x, int y, char *s, unsigned colidx);
92 
102  FBUTIL_API void rect(struct fb_data *f_data, int x1, int y1, int x2, int y2, unsigned colidx);
103 
113  FBUTIL_API void fillrect(struct fb_data *f_data, int x1, int y1, int x2, int y2, unsigned colidx);
114 
123  FBUTIL_API void put_string_center(struct fb_data *f_data, int x, int y, char *s, unsigned colidx);
124 
131  FBUTIL_API void setcolor(struct fb_data *f_data, unsigned colidx, unsigned value);
132 
140  FBUTIL_API void progress_bar(struct fb_data *f_data, int progress, const char *fmt, ...);
141 
149  FBUTIL_API void put_cross(struct fb_data *f_data, int x, int y, unsigned colidx);
150 
158  FBUTIL_API int show_bmp(const char *fbp, struct fb_var_screeninfo *scrinfo, const char *bmpname);
159 
166  FBUTIL_API void *get_framebuffer(const char *dev, int *size);
167 
173  FBUTIL_API void free_framebuffer(void *buff, int size);
174 
175 #endif
#define FBUTIL_API
Definition: lib_fbraw.h:32
int fb_fd
用来存取打开framebuffer后的文件描述符
Definition: lib_fbraw.h:40
FBUTIL_API void close_framebuffer(struct fb_data *f_data)
关闭framebuffer设备并释放掉相关内存
unsigned char * fbuffer
缓冲区首地址
Definition: lib_fbraw.h:43
FBUTIL_API void put_cross(struct fb_data *f_data, int x, int y, unsigned colidx)
画交叉线
FBUTIL_API void put_string(struct fb_data *f_data, int x, int y, char *s, unsigned colidx)
在屏幕上显示一个字符串
FBUTIL_API void * get_framebuffer(const char *dev, int *size)
获得framebuffer对象
unsigned char ** line_addr
屏幕中每行的首地址
Definition: lib_fbraw.h:44
unsigned int colormap[256]
颜色图谱
Definition: lib_fbraw.h:46
unsigned long * p32
4个字节
Definition: lib_fbraw.h:56
FBUTIL_API void put_string_center(struct fb_data *f_data, int x, int y, char *s, unsigned colidx)
在屏幕显示一个字符串
FBUTIL_API void rect(struct fb_data *f_data, int x1, int y1, int x2, int y2, unsigned colidx)
在屏幕上显示一个矩形
FBUTIL_API void line(struct fb_data *f_data, int x1, int y1, int x2, int y2, unsigned colidx)
在屏幕上化一条线
unsigned char * p8
1个字节
Definition: lib_fbraw.h:54
FBUTIL_API void fillrect(struct fb_data *f_data, int x1, int y1, int x2, int y2, unsigned colidx)
填充矩形颜色
FBUTIL_API void free_framebuffer(void *buff, int size)
释放framebuffer对象
unsigned short * p16
2个字节
Definition: lib_fbraw.h:55
int bytes_per_pixel
每像素的字节数
Definition: lib_fbraw.h:45
char * fbdevice
设备名
Definition: lib_fbraw.h:39
用来保存framebuffer设备相关数据
Definition: lib_fbraw.h:38
FBUTIL_API void setcolor(struct fb_data *f_data, unsigned colidx, unsigned value)
设置屏幕颜色
struct fb_fix_screeninfo fix
用来存取framebuffer的固定信息
Definition: lib_fbraw.h:41
FBUTIL_API int show_bmp(const char *fbp, struct fb_var_screeninfo *scrinfo, const char *bmpname)
显示bmp位图
struct fb_var_screeninfo var
用来存取framebuffer的可变信息
Definition: lib_fbraw.h:42
FBUTIL_API int open_framebuffer(const char *dev, struct fb_data *f_data)
打开framebuffer设备并用mmap建立内存映射
FBUTIL_API void progress_bar(struct fb_data *f_data, int progress, const char *fmt,...)
显示进度条