码迷,mamicode.com
首页 > 其他好文 > 详细

十五、在屏幕上显示字符

时间:2019-02-15 15:57:49      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:clean   font   sleep   最好   obj   否则   while   cto   sizeof   

  显示字符需要先实现绘点功能,然后用取模工具对需要显示的字符取模,我用的取模工具为PCtoLCD2002,设置如下图:

技术图片

封装的函数最好比较容易使用,最好能选择字体,具体细节再此不详述,直接附上程序。

draw.c

  1 #include <stdio.h>
  2 #include <linux/fb.h>
  3 #include <sys/types.h>
  4 #include <sys/stat.h>
  5 #include <fcntl.h>
  6 #include <sys/mman.h>
  7 #include "draw.h"
  8 
  9 static struct fb_var_screeninfo __g_vinfo;    /* 显示信息 */
 10 static color_t *__gp_frame;                    /* 虚拟屏幕首地址 */
 11 static color_t __g_pen_color;                /* 画笔颜色 */
 12 static color_t __g_bk_color;                /* 背景颜色 */
 13 static font_size_t __g_font_size;            /* 当前字体大小 */
 14 
 15 /* 定义绘制不同字体的函数和字体大小 */
 16 extern int draw_one_char_fs16 (unsigned int x, unsigned int y, char dat);
 17 extern int draw_one_char_fs24 (unsigned int x, unsigned int y, char dat);
 18 extern int draw_one_char_fs32 (unsigned int x, unsigned int y, char dat);
 19 extern int draw_one_char_fs48 (unsigned int x, unsigned int y, char dat);
 20 extern int draw_one_char_fs64 (unsigned int x, unsigned int y, char dat);
 21     
 22 static struct struct_draw_font __g_draw_font_tab[] = {
 23     {draw_one_char_fs16, FONT_SIZE_16},
 24     {draw_one_char_fs24, FONT_SIZE_24},
 25     {draw_one_char_fs32, FONT_SIZE_32},
 26     {draw_one_char_fs48, FONT_SIZE_48},
 27     {draw_one_char_fs64, FONT_SIZE_64},
 28 };
 29 
 30 /**
 31  * \brief framebuffer初始化
 32  */
 33 int framebuffer_init (void)
 34 {
 35     int fd = 0;
 36 
 37     fd = open("/dev/fb0", O_RDWR);
 38     if (fd == -1) {
 39         perror("fail to open /dev/fb0\n");
 40         return -1;
 41     }
 42 
 43     ioctl(fd, FBIOGET_VSCREENINFO, &__g_vinfo);                    /* 获取显示信息 */
 44     printf("bits_per_pixel = %d\n", __g_vinfo.bits_per_pixel);    /* 得到一个像素点对应的位数 */
 45 
 46     __gp_frame = mmap(NULL,                             /* 映射区的开始地址,为NULL表示由系统决定映射区的起始地址 */
 47                       __g_vinfo.xres_virtual * __g_vinfo.yres_virtual * __g_vinfo.bits_per_pixel / 8,    /* 映射区大小 */
 48                       PROT_WRITE | PROT_READ,            /* 内存保护标志(可读可写) */
 49                       MAP_SHARED,                        /* 映射对象类型(与其他进程共享) */
 50                       fd,                                /* 有效的文件描述符 */
 51                       0);                                /* 被映射内容的偏移量 */
 52     if (__gp_frame == NULL) {
 53         perror("fail to mmap\n");
 54         return -1;
 55     }
 56 
 57     return 0;
 58 }
 59 
 60 /**
 61  * \brief 填充整屏
 62  */
 63 void full_screen (color_t color)
 64 {
 65     int i;
 66     color_t *p = __gp_frame;
 67 
 68     for (i = 0; i < __g_vinfo.xres_virtual * __g_vinfo.yres_virtual; i++) {
 69         *p++ = color;
 70     }
 71 }
 72 
 73 /**
 74  * \brief 设置画笔颜色
 75  */
 76 void set_pen_color (color_t color)
 77 {
 78     __g_pen_color = color;
 79 }
 80 
 81 /**
 82  * \brief 获得画笔颜色
 83  */
 84 color_t get_pen_color (void)
 85 {
 86     return __g_pen_color;
 87 }
 88 
 89 /**
 90  * \brief 设置背景颜色
 91  */
 92 void set_bk_color (color_t color)
 93 {
 94     __g_bk_color = color;
 95 }
 96 
 97 /**
 98  * \brief 获得画笔颜色
 99  */
100 color_t get_bk_color (void)
101 {
102     return __g_bk_color;
103 }
104 
105 /**
106  * \brief 绘制一个点
107  *
108  * \retval 成功返回0,失败返回-1
109  */
110 int draw_point (unsigned int x, unsigned int y)
111 {
112     color_t *p_color;
113 
114     if ((x > __g_vinfo.xres_virtual) || (y > __g_vinfo.yres_virtual)) {
115         return -1;
116     }
117 
118     p_color = __gp_frame + y * __g_vinfo.xres_virtual + x;
119     *p_color = __g_pen_color;
120 
121     return 0;
122 }
123 
124 /**
125  * \brief 绘制一个背景点
126  *
127  * \retval 成功返回0,失败返回-1
128  */
129 int draw_bk_point (unsigned int x, unsigned int y)
130 {
131     color_t *p_color;
132 
133     if ((x > __g_vinfo.xres_virtual) || (y > __g_vinfo.yres_virtual)) {
134         return -1;
135     }
136 
137     p_color = __gp_frame + y * __g_vinfo.xres_virtual + x;
138     *p_color = __g_bk_color;
139 
140     return 0;
141 }
142 
143 /**
144  * \brief 设置字体大小
145  *
146  * \retval 成功返回0,失败返回-1
147  */
148 int set_font_size (font_size_t font)
149 {
150     if (font >= MAX_FONT_SIZE) {
151         return -1;
152     }
153 
154     __g_font_size = font;
155 
156     return 0;
157 }
158 
159 /**
160  * \brief 获取字体大小
161  *
162  * \retval 字体大小
163  */
164 font_size_t get_font_size (void)
165 {
166     return __g_font_size;    
167 }
168 
169 /**
170  * \brief 绘制一个英文字符
171  *
172  * \retval 成功返回0,失败返回-1
173  */
174 int draw_one_char (unsigned int x, unsigned int y, char dat)
175 {
176     int i;
177 
178     for (i = 0; i < sizeof(__g_draw_font_tab) / sizeof(__g_draw_font_tab[0]); i++) {
179         if (__g_draw_font_tab[i].font_size == __g_font_size) {
180             return __g_draw_font_tab[i].draw_one_char_fn(x, y, dat);
181         }
182     }
183 
184     return -1;
185 }
186 
187 /**
188  * \brief 绘制一个字符串
189  *
190  * \retval 返回成功绘制的字符个数
191  */
192 int draw_str (unsigned int x, unsigned int y, char *p_str)
193 {
194     int ret = 0;
195     int char_num = 0;
196     font_size_t font_size;
197 
198     font_size = get_font_size();
199 
200     while (*p_str) {
201         if (0 == draw_one_char(x + char_num * font_size / 2, y, *p_str)) {
202             ret++;
203         }
204         char_num++;
205         p_str++;
206     }
207 
208     return ret;
209 }

draw.h

  1 typedef unsigned short color_t;                /* 定义颜色类型,根据实际情况修改,此处为unsigned short是565的屏 */
  2 
  3 /**< \brief 定义常用颜色 */
  4 #define LCD_BLACK    0x0000                    /* 黑色 */
  5 #define LCD_BLUE    0x001F                    /* 蓝色 */
  6 #define LCD_GREEN    0x07E0                    /* 绿色 */
  7 #define LCD_RED        0xF800                    /* 红色 */
  8 #define LCD_CYAN    (LCD_BLUE | LCD_GREEN)    /* 青色 */
  9 #define LCD_MAGENTA    (LCD_BLUE | LCD_RED)    /* 洋红 */
 10 #define LCD_YELLOW    (LCD_GREEN | LCD_RED)    /* 黄色 */
 11 #define LCD_WHITE    (LCD_CYAN | LCD_RED)    /* 白色 */
 12 
 13 /**< \brief 定义支持的字体类型 */
 14 typedef enum enum_font_size {
 15     FONT_SIZE_16 = 16,
 16     FONT_SIZE_24 = 24,
 17     FONT_SIZE_32 = 32,
 18     FONT_SIZE_48 = 48,
 19     FONT_SIZE_64 = 64,
 20 
 21     MAX_FONT_SIZE    /* 最大字体号,该项放在最后即可 */
 22 } font_size_t;
 23 
 24 /* 定义绘制字符的函数指针类型 */
 25 typedef int (* draw_one_char_t) (unsigned int x, unsigned int y, char dat);
 26 
 27 /* 定义绘制字体的函数和字体大小结构 */
 28 struct struct_draw_font {
 29     draw_one_char_t draw_one_char_fn;    /* 绘制函数 */
 30     font_size_t font_size;                /* 字体大小 */
 31 };
 32 
 33 /**
 34  * \brief framebuffer初始化
 35  */
 36 extern int framebuffer_init (void);
 37 
 38 /**
 39  * \brief 填充整屏
 40  */
 41 extern void full_screen (color_t color);
 42 
 43 /**
 44  * \brief 设置画笔颜色
 45  */
 46 extern void set_pen_color (color_t color);
 47 
 48 /**
 49  * \brief 获得画笔颜色
 50  */
 51 extern color_t get_pen_color (void);
 52 
 53 /**
 54  * \brief 设置背景颜色
 55  */
 56 extern void set_bk_color (color_t color);
 57 
 58 /**
 59  * \brief 获得背景颜色
 60  */
 61 extern color_t get_bk_color (void);
 62 
 63 /**
 64  * \brief 绘制一个点
 65  *
 66  * \retval 成功返回0,失败返回-1
 67  */
 68 extern int draw_point (unsigned int x, unsigned int y);
 69 
 70 /**
 71  * \brief 绘制一个背景点
 72  *
 73  * \retval 成功返回0,失败返回-1
 74  */
 75 extern int draw_bk_point (unsigned int x, unsigned int y);
 76 
 77 /**
 78  * \brief 设置字体大小
 79  *
 80  * \retval 成功返回0,失败返回-1
 81  */
 82 extern int set_font_size (font_size_t font);
 83 
 84 /**
 85  * \brief 获取字体大小
 86  *
 87  * \retval 字体大小
 88  */
 89 extern font_size_t get_font_size (void);
 90 
 91 /**
 92  * \brief 绘制一个英文字符
 93  *
 94  * \retval 成功返回0,失败返回-1
 95  */
 96 extern int draw_one_char (unsigned int x, unsigned int y, char dat);
 97 
 98 /**
 99  * \brief 绘制一个字符串
100  *
101  * \retval 返回成功绘制的字符个数
102  */
103 extern int draw_str (unsigned int x, unsigned int y, char *p_str);

font_size_16.c

 1 /* 支持的字符 */
 2 static const char char_fs16[] = {"0123456789:- "};
 3 
 4 /* 字模 */
 5 static const char font_size_16[][16] = {
 6 {0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18,0x00,0x00},/*"0",0*/
 7 {0x00,0x00,0x00,0x10,0x1C,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00},/*"1",1*/
 8 {0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x40,0x20,0x10,0x08,0x04,0x42,0x7E,0x00,0x00},/*"2",2*/
 9 {0x00,0x00,0x00,0x3C,0x42,0x42,0x40,0x20,0x18,0x20,0x40,0x42,0x42,0x3C,0x00,0x00},/*"3",3*/
10 {0x00,0x00,0x00,0x20,0x30,0x30,0x28,0x24,0x24,0x22,0xFE,0x20,0x20,0xF8,0x00,0x00},/*"4",4*/
11 {0x00,0x00,0x00,0x7E,0x02,0x02,0x02,0x1E,0x22,0x40,0x40,0x42,0x22,0x1C,0x00,0x00},/*"5",5*/
12 {0x00,0x00,0x00,0x18,0x24,0x02,0x02,0x3A,0x46,0x42,0x42,0x42,0x44,0x38,0x00,0x00},/*"6",6*/
13 {0x00,0x00,0x00,0x7E,0x42,0x20,0x20,0x10,0x10,0x08,0x08,0x08,0x08,0x08,0x00,0x00},/*"7",7*/
14 {0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x24,0x18,0x24,0x42,0x42,0x42,0x3C,0x00,0x00},/*"8",8*/
15 {0x00,0x00,0x00,0x1C,0x22,0x42,0x42,0x42,0x62,0x5C,0x40,0x40,0x24,0x18,0x00,0x00},/*"9",9*/
16 {0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00},/*":",10*/
17 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"-",11*/
18 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*" ",12*/
19 };
20 
21 /**
22  * \brief 通过输入的字符获取在字模表的偏移量
23  *
24  * \retval 字母表中有该字符则返回偏移量,否则返回-1
25  */
26 static int __get_tab_offset (char dat)
27 {
28     int i;
29 
30     for (i = 0; i < sizeof(char_fs16) - 1; i++) {
31         if (dat == char_fs16[i]) {
32             return i;
33         }
34     }
35 
36     return -1;
37 }
38 
39 /**
40  * \brief 绘制一个英文字符,16号字体
41  *
42  * \retval 成功返回0,失败返回-1
43  */
44 int draw_one_char_fs16 (unsigned int x, unsigned int y, char dat)
45 {
46     int offset = 0;
47     int i, j;
48     char tmp = 0;
49     
50     offset = __get_tab_offset(dat);
51     if (offset == -1) {
52         return -1;
53     }
54 
55     for (i = 0; i < 16; i++) {
56         tmp = font_size_16[offset][i];
57         for (j = 0 ; j < 8; j++) {
58             if (tmp & 0x01) {
59                 draw_point(x + j, y + i);
60             } else {
61                 draw_bk_point(x + j, y + i);
62             }
63     
64             tmp    >>= 1;
65         }
66     }
67     
68     return 0;
69 }

font_size_24.c

  1 /* 支持的字符 */
  2 static const char char_fs24[] = {"0123456789:- "};
  3 
  4 /* 字模 */
  5 static const char font_size_24[][48] = {
  6 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x98,0x01,0x0C,0x03,0x0C,0x03,0x06,0x06,0x06,0x06,0x06,0x06,
  7  0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0x03,0x0C,0x03,0x98,0x01,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"0",0*/
  8 
  9 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x7C,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,
 10  0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xFC,0x03,0x00,0x00,0x00,0x00,0x00,0x00},/*"1",1*/
 11 
 12 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x00,0x84,0x01,0x02,0x03,0x06,0x03,0x06,0x03,0x00,0x03,0x00,0x01,
 13  0x80,0x01,0xC0,0x00,0x60,0x00,0x20,0x00,0x10,0x00,0x08,0x02,0x04,0x02,0x06,0x02,0xFE,0x03,0x00,0x00,0x00,0x00,0x00,0x00},/*"2",2*/
 14 
 15 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0xC6,0x00,0x86,0x01,0x86,0x01,0x80,0x01,0x80,0x01,0xC0,0x00,
 16  0x70,0x00,0x80,0x01,0x00,0x01,0x00,0x03,0x00,0x03,0x06,0x03,0x06,0x03,0x86,0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"3",3*/
 17 
 18 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x01,0x80,0x01,0xC0,0x01,0xA0,0x01,0xA0,0x01,0x90,0x01,0x88,0x01,
 19  0x88,0x01,0x84,0x01,0x82,0x01,0xFE,0x0F,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0xE0,0x07,0x00,0x00,0x00,0x00,0x00,0x00},/*"4",4*/
 20 
 21 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x03,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0xF4,0x00,
 22  0x8C,0x01,0x04,0x03,0x00,0x03,0x00,0x03,0x06,0x03,0x06,0x03,0x82,0x01,0x84,0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"5",5*/
 23 
 24 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x01,0x18,0x03,0x0C,0x03,0x0C,0x00,0x04,0x00,0x06,0x00,0xE6,0x01,
 25  0x16,0x03,0x0E,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x04,0x06,0x0C,0x02,0x18,0x03,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"6",6*/
 26 
 27 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x07,0x0C,0x06,0x04,0x02,0x04,0x01,0x00,0x01,0x00,0x01,0x80,0x00,
 28  0x80,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"7",7*/
 29 
 30 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x01,0x0C,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0x02,0x1C,0x03,
 31  0xF0,0x00,0xC8,0x01,0x0C,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0x03,0xF0,0x01,0x00,0x00,0x00,0x00,0x00,0x00},/*"8",8*/
 32 
 33 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x0C,0x01,0x0C,0x03,0x06,0x02,0x06,0x06,0x06,0x06,0x06,0x06,
 34  0x06,0x07,0x8C,0x06,0x78,0x06,0x00,0x06,0x00,0x03,0x00,0x03,0x0C,0x01,0x8C,0x01,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"9",9*/
 35 
 36 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0xE0,0x00,
 37  0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*":",10*/
 38 
 39 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 40  0xFE,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"-",11*/
 41 
 42 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 43  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*" ",12*/
 44 };
 45 /**
 46  * \brief 通过输入的字符获取在字模表的偏移量
 47  *
 48  * \retval 字母表中有该字符则返回偏移量,否则返回-1
 49  */
 50 static int __get_tab_offset (char dat)
 51 {
 52     int i;
 53 
 54     for (i = 0; i < sizeof(char_fs24) - 1; i++) {
 55         if (dat == char_fs24[i]) {
 56             return i;
 57         }
 58     }
 59 
 60     return -1;
 61 }
 62 
 63 /**
 64  * \brief 绘制一个英文字符,24号字体
 65  *
 66  * \retval 成功返回0,失败返回-1
 67  */
 68 int draw_one_char_fs24 (unsigned int x, unsigned int y, char dat)
 69 {
 70     int offset = 0;
 71     int i, j;
 72     char tmp = 0;
 73     
 74     offset = __get_tab_offset(dat);
 75     if (offset == -1) {
 76         return -1;
 77     }
 78 
 79     for (i = 0; i < 24; i++) {
 80         tmp = font_size_24[offset][i * 2];
 81         for (j = 0 ; j < 8; j++) {
 82             if (tmp & 0x01) {
 83                 draw_point(x + j, y + i);
 84             } else {
 85                 draw_bk_point(x + j, y + i);
 86             }
 87     
 88             tmp    >>= 1;
 89         }
 90         
 91         tmp = font_size_24[offset][i * 2 + 1];
 92         for (; j < 12; j++) {
 93             if (tmp & 0x01) {
 94                 draw_point(x + j, y + i);
 95             } else {
 96                 draw_bk_point(x + j, y + i);
 97             }
 98     
 99             tmp    >>= 1;
100         }
101     }
102     
103     return 0;
104 }

font_size_32.c

  1 /* 支持的字符 */
  2 static const char char_fs32[] = {"0123456789:- "};
  3 
  4 /* 字模 */
  5 static const char font_size_32[][64] = {
  6 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x03,0x60,0x04,
  7  0x30,0x0C,0x18,0x18,0x18,0x18,0x18,0x10,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,
  8  0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x18,0x10,0x18,0x18,
  9  0x18,0x18,0x30,0x0C,0x60,0x04,0xC0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"0",0*/
 10 
 11 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x01,
 12  0xF8,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,
 13  0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,
 14  0x80,0x01,0x80,0x01,0xC0,0x03,0xF8,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"1",1*/
 15 
 16 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x07,0x10,0x1C,
 17  0x08,0x18,0x04,0x30,0x04,0x30,0x0C,0x30,0x0C,0x30,0x00,0x30,0x00,0x18,0x00,0x18,
 18  0x00,0x0C,0x00,0x06,0x00,0x03,0x80,0x01,0xC0,0x00,0x40,0x00,0x20,0x20,0x10,0x20,
 19  0x08,0x20,0x04,0x30,0xFC,0x1F,0xFC,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"2",2*/
 20 
 21 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x03,0x18,0x06,
 22  0x0C,0x0C,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x00,0x18,0x00,0x18,0x00,0x0C,0x00,0x06,
 23  0xC0,0x03,0x00,0x0E,0x00,0x18,0x00,0x10,0x00,0x30,0x00,0x30,0x0C,0x30,0x0C,0x30,
 24  0x0C,0x10,0x0C,0x18,0x18,0x0C,0xE0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"3",3*/
 25 
 26 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x06,
 27  0x00,0x07,0x00,0x07,0x80,0x06,0x80,0x06,0x40,0x06,0x20,0x06,0x20,0x06,0x10,0x06,
 28  0x10,0x06,0x08,0x06,0x0C,0x06,0x04,0x06,0x02,0x06,0xFE,0x3F,0x00,0x06,0x00,0x06,
 29  0x00,0x06,0x00,0x06,0x00,0x06,0xC0,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"4",4*/
 30 
 31 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x3F,0xF0,0x3F,
 32  0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0xC8,0x07,0x28,0x0C,
 33  0x18,0x18,0x08,0x10,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x0C,0x30,0x0C,0x30,
 34  0x04,0x18,0x04,0x18,0x18,0x0C,0xE0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"5",5*/
 35 
 36 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x07,0x60,0x18,
 37  0x30,0x18,0x10,0x18,0x18,0x00,0x08,0x00,0x08,0x00,0x0C,0x00,0xCC,0x07,0x6C,0x0C,
 38  0x1C,0x18,0x1C,0x10,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x18,0x30,
 39  0x18,0x10,0x30,0x18,0x70,0x0C,0xC0,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"6",6*/
 40 
 41 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x3F,0xF8,0x3F,
 42  0x08,0x10,0x0C,0x08,0x04,0x08,0x04,0x04,0x00,0x04,0x00,0x02,0x00,0x02,0x00,0x02,
 43  0x00,0x01,0x00,0x01,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0xC0,0x00,0xC0,0x00,
 44  0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"7",7*/
 45 
 46 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x07,0x30,0x0C,
 47  0x18,0x18,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x1C,0x30,0x1C,0x10,0x78,0x18,0xF0,0x04,
 48  0xE0,0x03,0x18,0x0F,0x0C,0x1E,0x0C,0x1C,0x06,0x38,0x06,0x30,0x06,0x30,0x06,0x30,
 49  0x06,0x30,0x0C,0x18,0x18,0x0C,0xE0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"8",8*/
 50 
 51 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x03,0x18,0x04,
 52  0x0C,0x08,0x0C,0x18,0x06,0x10,0x06,0x30,0x06,0x30,0x06,0x30,0x06,0x30,0x06,0x30,
 53  0x0E,0x38,0x0C,0x34,0x18,0x36,0xF0,0x31,0x00,0x30,0x00,0x18,0x00,0x18,0x00,0x08,
 54  0x0C,0x0C,0x0C,0x06,0x0C,0x03,0xF0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"9",9*/
 55 
 56 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 57  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x01,0xC0,0x03,0xC0,0x03,
 58  0x80,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 59  0x80,0x01,0xC0,0x03,0xC0,0x03,0x80,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*":",10*/
 60  
 61 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 62  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 63  0xFE,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 64  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"-",11*/
 65 
 66 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 67  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 68  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 69  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*" ",12*/
 70 };
 71 
 72 /**
 73  * \brief 通过输入的字符获取在字模表的偏移量
 74  *
 75  * \retval 字母表中有该字符则返回偏移量,否则返回-1
 76  */
 77 static int __get_tab_offset (char dat)
 78 {
 79     int i;
 80 
 81     for (i = 0; i < sizeof(char_fs32) - 1; i++) {
 82         if (dat == char_fs32[i]) {
 83             return i;
 84         }
 85     }
 86 
 87     return -1;
 88 }
 89 
 90 /**
 91  * \brief 绘制一个英文字符,32号字体
 92  *
 93  * \retval 成功返回0,失败返回-1
 94  */
 95 int draw_one_char_fs32 (unsigned int x, unsigned int y, char dat)
 96 {
 97     int offset = 0;
 98     int i, j;
 99     char tmp = 0;
100     
101     offset = __get_tab_offset(dat);
102     if (offset == -1) {
103         return -1;
104     }
105 
106     for (i = 0; i < 32; i++) {
107         tmp = font_size_32[offset][i * 2];
108         for (j = 0 ; j < 8; j++) {
109             if (tmp & 0x01) {
110                 draw_point(x + j, y + i);
111             } else {
112                 draw_bk_point(x + j, y + i);
113             }
114     
115             tmp    >>= 1;
116         }
117         
118         tmp = font_size_32[offset][i * 2 + 1];
119         for (; j < 16; j++) {
120             if (tmp & 0x01) {
121                 draw_point(x + j, y + i);
122             } else {
123                 draw_bk_point(x + j, y + i);
124             }
125     
126             tmp    >>= 1;
127         }
128     }
129     
130     return 0;
131 }

font_size_48.c

  1 /* 支持的字符 */
  2 static const char char_fs48[] = {"0123456789:- "};
  3 
  4 /* 字模 */
  5 static const char font_size_48[][16 * 9] = {
  6 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  7  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x80,0xC3,0x01,0xC0,0x01,
  8  0x03,0xC0,0x00,0x07,0x60,0x00,0x06,0x70,0x00,0x0E,0x30,0x00,0x0C,0x38,0x00,0x1C,
  9  0x38,0x00,0x1C,0x38,0x00,0x1C,0x18,0x00,0x38,0x1C,0x00,0x38,0x1C,0x00,0x38,0x1C,
 10  0x00,0x38,0x1C,0x00,0x38,0x1C,0x00,0x38,0x1C,0x00,0x38,0x1C,0x00,0x38,0x1C,0x00,
 11  0x38,0x1C,0x00,0x38,0x1C,0x00,0x38,0x1C,0x00,0x38,0x18,0x00,0x18,0x38,0x00,0x1C,
 12  0x38,0x00,0x1C,0x38,0x00,0x1C,0x30,0x00,0x0C,0x70,0x00,0x0E,0x60,0x00,0x06,0xC0,
 13  0x00,0x07,0xC0,0x01,0x03,0x00,0xC3,0x01,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,
 14  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"0",0*/
 15 
 16 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 17  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x30,0x00,0x00,0x38,
 18  0x00,0xC0,0x3F,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,
 19  0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,
 20  0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,
 21  0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,
 22  0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,
 23  0x38,0x00,0x00,0x38,0x00,0x00,0x7C,0x00,0xC0,0xFF,0x07,0x00,0x00,0x00,0x00,0x00,
 24  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"1",1*/
 25 
 26 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 27  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x80,0xC1,0x03,0x60,0x00,
 28  0x07,0x30,0x00,0x0E,0x30,0x00,0x0E,0x38,0x00,0x1C,0x38,0x00,0x1C,0x38,0x00,0x1C,
 29  0x78,0x00,0x1C,0x78,0x00,0x1C,0x70,0x00,0x1C,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,
 30  0x00,0x07,0x00,0x00,0x07,0x00,0x80,0x03,0x00,0xC0,0x01,0x00,0xE0,0x00,0x00,0x70,
 31  0x00,0x00,0x38,0x00,0x00,0x1C,0x00,0x00,0x0E,0x00,0x00,0x07,0x00,0x80,0x03,0x00,
 32  0xC0,0x01,0x00,0xE0,0x00,0x10,0x60,0x00,0x10,0x30,0x00,0x18,0x38,0x00,0x08,0x1C,
 33  0x00,0x0E,0xFC,0xFF,0x0F,0xFC,0xFF,0x0F,0xFC,0xFF,0x0F,0x00,0x00,0x00,0x00,0x00,
 34  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"2",2*/
 35 
 36 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 37  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x80,0xC1,0x01,0x40,0x80,
 38  0x03,0x20,0x00,0x07,0x30,0x00,0x07,0x30,0x00,0x0E,0x70,0x00,0x0E,0x70,0x00,0x0E,
 39  0x60,0x00,0x0E,0x00,0x00,0x0E,0x00,0x00,0x06,0x00,0x00,0x07,0x00,0x00,0x03,0x00,
 40  0x80,0x01,0x00,0xE0,0x00,0x00,0x3E,0x00,0x00,0xE0,0x00,0x00,0x80,0x03,0x00,0x00,
 41  0x07,0x00,0x00,0x0E,0x00,0x00,0x0C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,
 42  0x30,0x00,0x1C,0x78,0x00,0x1C,0x78,0x00,0x1C,0x78,0x00,0x0C,0x38,0x00,0x0E,0x30,
 43  0x00,0x06,0x60,0x00,0x03,0xC0,0xC0,0x01,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,
 44  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"3",3*/
 45 
 46 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 47  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x01,0x00,0xC0,0x01,0x00,0xC0,
 48  0x01,0x00,0xE0,0x01,0x00,0xF0,0x01,0x00,0xD0,0x01,0x00,0xC8,0x01,0x00,0xC8,0x01,
 49  0x00,0xC4,0x01,0x00,0xC6,0x01,0x00,0xC2,0x01,0x00,0xC3,0x01,0x00,0xC1,0x01,0x80,
 50  0xC0,0x01,0xC0,0xC0,0x01,0x40,0xC0,0x01,0x60,0xC0,0x01,0x20,0xC0,0x01,0x30,0xC0,
 51  0x01,0x18,0xC0,0x01,0x18,0xC0,0x01,0x0C,0xC0,0x01,0xFC,0xFF,0x3F,0x00,0xC0,0x01,
 52  0x00,0xC0,0x01,0x00,0xC0,0x01,0x00,0xC0,0x01,0x00,0xC0,0x01,0x00,0xC0,0x01,0x00,
 53  0xC0,0x01,0x00,0xC0,0x01,0x00,0xE0,0x03,0x00,0xFE,0x3F,0x00,0x00,0x00,0x00,0x00,
 54  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"4",4*/
 55 
 56 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 57  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xFF,0x0F,0xE0,0xFF,0x0F,0xE0,0xFF,
 58  0x0F,0x20,0x00,0x00,0x20,0x00,0x00,0x20,0x00,0x00,0x20,0x00,0x00,0x20,0x00,0x00,
 59  0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0xFE,0x00,0x30,
 60  0xFF,0x01,0xB0,0x81,0x07,0xF0,0x00,0x07,0x70,0x00,0x0E,0x30,0x00,0x0E,0x00,0x00,
 61  0x1E,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x30,0x00,0x1C,
 62  0x78,0x00,0x1C,0x78,0x00,0x1C,0x78,0x00,0x0C,0x38,0x00,0x0E,0x30,0x00,0x0E,0x30,
 63  0x00,0x07,0x60,0x00,0x03,0xC0,0xC1,0x01,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,
 64  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"5",5*/
 65 
 66 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 67  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x01,0x00,0x07,0x02,0x80,0x01,
 68  0x06,0xC0,0x00,0x0E,0x60,0x00,0x0E,0x60,0x00,0x0E,0x30,0x00,0x00,0x30,0x00,0x00,
 69  0x38,0x00,0x00,0x38,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x1C,0xFC,0x00,0x1C,
 70  0xFF,0x03,0x9C,0x83,0x07,0xDC,0x00,0x0E,0x7C,0x00,0x1C,0x3C,0x00,0x1C,0x3C,0x00,
 71  0x38,0x1C,0x00,0x38,0x1C,0x00,0x38,0x1C,0x00,0x38,0x1C,0x00,0x38,0x1C,0x00,0x38,
 72  0x18,0x00,0x38,0x38,0x00,0x38,0x38,0x00,0x18,0x30,0x00,0x1C,0x70,0x00,0x1C,0xE0,
 73  0x00,0x0C,0xC0,0x01,0x06,0x80,0x83,0x03,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,
 74  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"6",6*/
 75 
 76 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 77  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0xFF,0x1F,0xF0,0xFF,0x1F,0xF0,0xFF,
 78  0x0F,0x70,0x00,0x0C,0x30,0x00,0x04,0x18,0x00,0x02,0x18,0x00,0x03,0x08,0x00,0x01,
 79  0x00,0x80,0x01,0x00,0x80,0x00,0x00,0xC0,0x00,0x00,0x40,0x00,0x00,0x60,0x00,0x00,
 80  0x60,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,
 81  0x00,0x00,0x1C,0x00,0x00,0x0C,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,
 82  0x00,0x0E,0x00,0x00,0x0F,0x00,0x00,0x0F,0x00,0x00,0x0F,0x00,0x00,0x0F,0x00,0x00,
 83  0x0F,0x00,0x00,0x0F,0x00,0x00,0x0F,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,
 84  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"7",7*/
 85 
 86 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 87  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0xC0,0x81,0x03,0xE0,0x00,
 88  0x07,0x70,0x00,0x0E,0x70,0x00,0x0E,0x38,0x00,0x1C,0x38,0x00,0x1C,0x38,0x00,0x1C,
 89  0x38,0x00,0x1C,0x78,0x00,0x1C,0x78,0x00,0x0C,0xF0,0x00,0x0E,0xE0,0x03,0x07,0xE0,
 90  0x87,0x03,0x80,0xDF,0x01,0x00,0x7F,0x00,0xC0,0xFD,0x00,0xE0,0xF0,0x03,0x70,0xC0,
 91  0x07,0x30,0x80,0x07,0x38,0x00,0x0F,0x38,0x00,0x0E,0x1C,0x00,0x1E,0x1C,0x00,0x1C,
 92  0x1C,0x00,0x1C,0x1C,0x00,0x1C,0x1C,0x00,0x1C,0x18,0x00,0x0C,0x38,0x00,0x0E,0x30,
 93  0x00,0x06,0x60,0x00,0x03,0xC0,0x81,0x01,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,
 94  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"8",8*/
 95 
 96 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 97  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x00,0xC0,0xC1,0x00,0x60,0x80,
 98  0x01,0x70,0x00,0x03,0x38,0x00,0x06,0x38,0x00,0x06,0x18,0x00,0x0E,0x1C,0x00,0x0C,
 99  0x1C,0x00,0x0C,0x1C,0x00,0x1C,0x1C,0x00,0x1C,0x1C,0x00,0x1C,0x1C,0x00,0x1C,0x1C,
100  0x00,0x1C,0x3C,0x00,0x1E,0x38,0x00,0x1F,0x38,0x00,0x1D,0x78,0x80,0x1D,0xF0,0xE1,
101  0x1C,0xE0,0x7F,0x1C,0x80,0x1F,0x1C,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,0x00,0x0E,
102  0x00,0x00,0x0E,0x00,0x00,0x06,0x00,0x00,0x07,0x70,0x00,0x03,0x70,0x80,0x03,0x70,
103  0xC0,0x01,0x70,0xE0,0x00,0x60,0x70,0x00,0x80,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,
104  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"9",9*/
105 
106 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
107  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
108  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
109  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x00,0x00,0x3E,0x00,0x00,0x3E,0x00,0x00,
110  0x3E,0x00,0x00,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
111  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
112  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x00,0x00,
113  0x3E,0x00,0x00,0x3E,0x00,0x00,0x3E,0x00,0x00,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,
114  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*":",10*/
115 
116 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
117  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
118  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
119  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
120  0x00,0x00,0x00,0x00,0x00,0xFC,0xFF,0x3F,0xFC,0xFF,0x3F,0x00,0x00,0x00,0x00,0x00,
121  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
122  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
123  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
124  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"-",11*/
125 
126 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
127  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
128  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
129  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
130  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
131  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
132  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
133  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
134  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*" ",12*/
135 };
136 
137 /**
138  * \brief 通过输入的字符获取在字模表的偏移量
139  *
140  * \retval 字母表中有该字符则返回偏移量,否则返回-1
141  */
142 static int __get_tab_offset (char dat)
143 {
144     int i;
145 
146     for (i = 0; i < sizeof(char_fs48) - 1; i++) {
147         if (dat == char_fs48[i]) {
148             return i;
149         }
150     }
151 
152     return -1;
153 }
154 
155 /**
156  * \brief 绘制一个英文字符,48号字体
157  *
158  * \retval 成功返回0,失败返回-1
159  */
160 int draw_one_char_fs48 (unsigned int x, unsigned int y, char dat)
161 {
162     int offset = 0;
163     int i, j;
164     char tmp = 0;
165     
166     offset = __get_tab_offset(dat);
167     if (offset == -1) {
168         return -1;
169     }
170 
171     for (i = 0; i < 48; i++) {
172         tmp = font_size_48[offset][i * 3];
173         for (j = 0 ; j < 8; j++) {
174             if (tmp & 0x01) {
175                 draw_point(x + j, y + i);
176             } else {
177                 draw_bk_point(x + j, y + i);
178             }
179     
180             tmp    >>= 1;
181         }
182         
183         tmp = font_size_48[offset][i * 3 + 1];
184         for (; j < 16; j++) {
185             if (tmp & 0x01) {
186                 draw_point(x + j, y + i);
187             } else {
188                 draw_bk_point(x + j, y + i);
189             }
190     
191             tmp    >>= 1;
192         }
193         
194         tmp = font_size_48[offset][i * 3 + 2];
195         for (; j < 24; j++) {
196             if (tmp & 0x01) {
197                 draw_point(x + j, y + i);
198             } else {
199                 draw_bk_point(x + j, y + i);
200             }
201     
202             tmp    >>= 1;
203         }
204     }
205     
206     return 0;
207 }

font_size_64.c

  1 /* 支持的字符 */
  2 static const char char_fs64[] = {"0123456789:- "};
  3 
  4 /* 字模 */
  5 static const char font_size_64[][16 * 16] = {
  6 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  7  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  8  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x07,0x00,
  9  0x00,0xF8,0x1F,0x00,0x00,0x3C,0x78,0x00,0x00,0x0E,0xF0,0x00,0x00,0x07,0xE0,0x00,
 10  0x80,0x07,0xC0,0x01,0xC0,0x03,0xC0,0x03,0xC0,0x03,0x80,0x03,0xE0,0x01,0x80,0x07,
 11  0xE0,0x01,0x00,0x07,0xE0,0x00,0x00,0x07,0xF0,0x00,0x00,0x0F,0xF0,0x00,0x00,0x0F,
 12  0xF0,0x00,0x00,0x0F,0xF0,0x00,0x00,0x0E,0x78,0x00,0x00,0x1E,0x78,0x00,0x00,0x1E,
 13  0x78,0x00,0x00,0x1E,0x78,0x00,0x00,0x1E,0x78,0x00,0x00,0x1E,0x78,0x00,0x00,0x1E,
 14  0x78,0x00,0x00,0x1E,0x78,0x00,0x00,0x1E,0x78,0x00,0x00,0x1E,0x78,0x00,0x00,0x1E,
 15  0x78,0x00,0x00,0x1E,0x78,0x00,0x00,0x1E,0x78,0x00,0x00,0x1E,0x78,0x00,0x00,0x1E,
 16  0xF0,0x00,0x00,0x0E,0xF0,0x00,0x00,0x0F,0xF0,0x00,0x00,0x0F,0xF0,0x00,0x00,0x0F,
 17  0xE0,0x00,0x00,0x07,0xE0,0x01,0x80,0x07,0xE0,0x01,0x80,0x07,0xC0,0x03,0x80,0x03,
 18  0xC0,0x03,0xC0,0x03,0x80,0x07,0xC0,0x01,0x00,0x07,0xE0,0x00,0x00,0x0E,0xF0,0x00,
 19  0x00,0x3C,0x78,0x00,0x00,0xF8,0x1F,0x00,0x00,0xE0,0x07,0x00,0x00,0x00,0x00,0x00,
 20  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 21  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"0",0*/
 22 
 23 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 24  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 25  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,
 26  0x00,0x00,0x03,0x00,0x00,0x80,0x03,0x00,0x00,0xE0,0x03,0x00,0x80,0xFF,0x03,0x00,
 27  0x80,0xFF,0x03,0x00,0x00,0xE0,0x03,0x00,0x00,0xC0,0x03,0x00,0x00,0xC0,0x03,0x00,
 28  0x00,0xC0,0x03,0x00,0x00,0xC0,0x03,0x00,0x00,0xC0,0x03,0x00,0x00,0xC0,0x03,0x00,
 29  0x00,0xC0,0x03,0x00,0x00,0xC0,0x03,0x00,0x00,0xC0,0x03,0x00,0x00,0xC0,0x03,0x00,
 30  0x00,0xC0,0x03,0x00,0x00,0xC0,0x03,0x00,0x00,0xC0,0x03,0x00,0x00,0xC0,0x03,0x00,
 31  0x00,0xC0,0x03,0x00,0x00,0xC0,0x03,0x00,0x00,0xC0,0x03,0x00,0x00,0xC0,0x03,0x00,
 32  0x00,0xC0,0x03,0x00,0x00,0xC0,0x03,0x00,0x00,0xC0,0x03,0x00,0x00,0xC0,0x03,0x00,
 33  0x00,0xC0,0x03,0x00,0x00,0xC0,0x03,0x00,0x00,0xC0,0x03,0x00,0x00,0xC0,0x03,0x00,
 34  0x00,0xC0,0x03,0x00,0x00,0xC0,0x03,0x00,0x00,0xC0,0x03,0x00,0x00,0xC0,0x03,0x00,
 35  0x00,0xC0,0x03,0x00,0x00,0xC0,0x03,0x00,0x00,0xC0,0x03,0x00,0x00,0xE0,0x07,0x00,
 36  0x00,0xF0,0x0F,0x00,0x80,0xFF,0xFF,0x01,0x80,0xFF,0xFF,0x01,0x00,0x00,0x00,0x00,
 37  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 38  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"1",1*/
 39 
 40 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 41  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 42  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x0F,0x00,
 43  0x00,0xFC,0x7F,0x00,0x00,0x1F,0xF8,0x00,0x80,0x07,0xE0,0x01,0xC0,0x03,0xC0,0x03,
 44  0xE0,0x01,0x80,0x07,0xE0,0x00,0x80,0x07,0xE0,0x00,0x00,0x0F,0xF0,0x00,0x00,0x0F,
 45  0xF0,0x01,0x00,0x0F,0xF0,0x01,0x00,0x0F,0xF0,0x03,0x00,0x0F,0xF0,0x03,0x00,0x0F,
 46  0xF0,0x03,0x00,0x0F,0xE0,0x01,0x80,0x07,0x00,0x00,0x80,0x07,0x00,0x00,0x80,0x07,
 47  0x00,0x00,0xC0,0x03,0x00,0x00,0xC0,0x03,0x00,0x00,0xE0,0x01,0x00,0x00,0xF0,0x00,
 48  0x00,0x00,0x70,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x0E,0x00,
 49  0x00,0x00,0x07,0x00,0x00,0x80,0x03,0x00,0x00,0xC0,0x01,0x00,0x00,0xE0,0x00,0x00,
 50  0x00,0x70,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x0E,0x00,0x00,
 51  0x00,0x07,0x00,0x0C,0x80,0x03,0x00,0x0C,0xC0,0x01,0x00,0x0C,0xE0,0x01,0x00,0x0C,
 52  0xE0,0x00,0x00,0x06,0x70,0x00,0x00,0x07,0x38,0x00,0x80,0x07,0xF8,0xFF,0xFF,0x07,
 53  0xF8,0xFF,0xFF,0x07,0xF8,0xFF,0xFF,0x07,0xF8,0xFF,0xFF,0x07,0x00,0x00,0x00,0x00,
 54  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 55  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"2",2*/
 56 
 57 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 58  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 59  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x07,0x00,
 60  0x00,0xFE,0x1F,0x00,0x00,0x07,0x3E,0x00,0x80,0x01,0x78,0x00,0xC0,0x00,0xF0,0x00,
 61  0xC0,0x00,0xE0,0x01,0xE0,0x00,0xE0,0x01,0xE0,0x00,0xE0,0x03,0xE0,0x01,0xC0,0x03,
 62  0xE0,0x01,0xC0,0x03,0xE0,0x01,0xC0,0x03,0xC0,0x00,0xC0,0x03,0x00,0x00,0xC0,0x03,
 63  0x00,0x00,0xC0,0x03,0x00,0x00,0xE0,0x01,0x00,0x00,0xE0,0x01,0x00,0x00,0xF0,0x00,
 64  0x00,0x00,0x70,0x00,0x00,0x00,0x3C,0x00,0x00,0x00,0x1F,0x00,0x00,0xF0,0x07,0x00,
 65  0x00,0xF0,0x1F,0x00,0x00,0x00,0x3E,0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0xE0,0x01,
 66  0x00,0x00,0xC0,0x03,0x00,0x00,0x80,0x03,0x00,0x00,0x80,0x07,0x00,0x00,0x00,0x07,
 67  0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x0F,0xC0,0x01,0x00,0x0F,
 68  0xE0,0x03,0x00,0x0F,0xF0,0x03,0x00,0x0F,0xF0,0x03,0x00,0x0F,0xF0,0x03,0x80,0x07,
 69  0xF0,0x01,0x80,0x07,0xE0,0x01,0xC0,0x03,0xE0,0x01,0xC0,0x01,0xC0,0x03,0xE0,0x00,
 70  0x80,0x0F,0x78,0x00,0x00,0xFE,0x3F,0x00,0x00,0xF8,0x07,0x00,0x00,0x00,0x00,0x00,
 71  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 72  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"3",3*/
 73 
 74 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 75  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 76  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,
 77  0x00,0x00,0x70,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x7C,0x00,
 78  0x00,0x00,0x7E,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x7B,0x00,0x00,0x80,0x79,0x00,
 79  0x00,0xC0,0x79,0x00,0x00,0xC0,0x78,0x00,0x00,0xE0,0x78,0x00,0x00,0x60,0x78,0x00,
 80  0x00,0x30,0x78,0x00,0x00,0x38,0x78,0x00,0x00,0x18,0x78,0x00,0x00,0x0C,0x78,0x00,
 81  0x00,0x0E,0x78,0x00,0x00,0x06,0x78,0x00,0x00,0x03,0x78,0x00,0x80,0x03,0x78,0x00,
 82  0x80,0x01,0x78,0x00,0xC0,0x00,0x78,0x00,0xC0,0x00,0x78,0x00,0x60,0x00,0x78,0x00,
 83  0x70,0x00,0x78,0x00,0x30,0x00,0x78,0x00,0x18,0x00,0x78,0x00,0x1C,0x00,0x78,0x00,
 84  0xFC,0xFF,0xFF,0x3F,0xFC,0xFF,0xFF,0x3F,0x00,0x00,0x78,0x00,0x00,0x00,0x78,0x00,
 85  0x00,0x00,0x78,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x78,0x00,
 86  0x00,0x00,0x78,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x78,0x00,
 87  0x00,0x00,0xFC,0x00,0x00,0xF0,0xFF,0x1F,0x00,0xF0,0xFF,0x1F,0x00,0x00,0x00,0x00,
 88  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 89  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"4",4*/
 90 
 91 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 92  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 93  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xFF,0xFF,0x07,
 94  0x80,0xFF,0xFF,0x07,0x80,0xFF,0xFF,0x07,0x80,0xFF,0xFF,0x03,0x80,0x01,0x00,0x00,
 95  0x80,0x01,0x00,0x00,0x80,0x01,0x00,0x00,0x80,0x01,0x00,0x00,0x80,0x01,0x00,0x00,
 96  0x80,0x01,0x00,0x00,0x80,0x01,0x00,0x00,0x80,0x01,0x00,0x00,0x80,0x00,0x00,0x00,
 97  0x80,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0xC0,0xC0,0x1F,0x00,0xC0,0xF8,0x7F,0x00,
 98  0xC0,0xFC,0xFF,0x00,0xC0,0x1E,0xF8,0x01,0xC0,0x06,0xE0,0x03,0xC0,0x03,0xC0,0x03,
 99  0xC0,0x01,0xC0,0x07,0xC0,0x01,0x80,0x07,0x00,0x00,0x80,0x07,0x00,0x00,0x80,0x0F,
100  0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x0F,
101  0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x0F,0xC0,0x01,0x00,0x0F,0xE0,0x03,0x00,0x0F,
102  0xF0,0x03,0x00,0x0F,0xF0,0x03,0x00,0x07,0xF0,0x03,0x80,0x07,0xF0,0x01,0x80,0x07,
103  0xF0,0x01,0x80,0x03,0xE0,0x01,0xC0,0x03,0xC0,0x01,0xE0,0x01,0x80,0x03,0xF0,0x00,
104  0x00,0x0F,0x78,0x00,0x00,0xFE,0x3F,0x00,0x00,0xF0,0x07,0x00,0x00,0x00,0x00,0x00,
105  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
106  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"5",5*/
107 
108 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
109  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
110  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x3F,0x00,
111  0x00,0xE0,0xFF,0x00,0x00,0x78,0xE0,0x01,0x00,0x1C,0xC0,0x03,0x00,0x0E,0xC0,0x07,
112  0x00,0x07,0xC0,0x07,0x80,0x03,0xC0,0x07,0xC0,0x01,0xC0,0x07,0xC0,0x01,0x80,0x03,
113  0xE0,0x00,0x00,0x00,0xE0,0x00,0x00,0x00,0xE0,0x00,0x00,0x00,0xF0,0x00,0x00,0x00,
114  0xF0,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x70,0xC0,0x1F,0x00,
115  0x78,0xF0,0xFF,0x00,0x78,0xFC,0xFF,0x01,0x78,0x3E,0xF0,0x03,0x78,0x0F,0xC0,0x07,
116  0x78,0x07,0x80,0x07,0xF8,0x03,0x80,0x0F,0xF8,0x01,0x00,0x0F,0xF8,0x00,0x00,0x0F,
117  0xF8,0x00,0x00,0x1E,0x78,0x00,0x00,0x1E,0x78,0x00,0x00,0x1E,0x78,0x00,0x00,0x1E,
118  0x78,0x00,0x00,0x1E,0x78,0x00,0x00,0x1E,0x70,0x00,0x00,0x1E,0xF0,0x00,0x00,0x1E,
119  0xF0,0x00,0x00,0x1E,0xF0,0x00,0x00,0x0E,0xE0,0x00,0x00,0x0F,0xE0,0x01,0x00,0x0F,
120  0xC0,0x03,0x00,0x07,0xC0,0x03,0x80,0x07,0x80,0x07,0x80,0x03,0x00,0x0F,0xC0,0x01,
121  0x00,0x3E,0xF0,0x00,0x00,0xFC,0x7F,0x00,0x00,0xE0,0x0F,0x00,0x00,0x00,0x00,0x00,
122  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
123  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"6",6*/
124 
125 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
126  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
127  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xFF,0xFF,0x0F,
128  0xE0,0xFF,0xFF,0x0F,0xE0,0xFF,0xFF,0x0F,0xE0,0xFF,0xFF,0x07,0xE0,0x03,0x00,0x03,
129  0xE0,0x00,0x00,0x03,0x60,0x00,0x80,0x01,0x60,0x00,0x80,0x01,0x30,0x00,0xC0,0x00,
130  0x30,0x00,0xC0,0x00,0x30,0x00,0x60,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x30,0x00,
131  0x00,0x00,0x38,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x1C,0x00,
132  0x00,0x00,0x0C,0x00,0x00,0x00,0x0E,0x00,0x00,0x00,0x0E,0x00,0x00,0x00,0x07,0x00,
133  0x00,0x00,0x07,0x00,0x00,0x80,0x07,0x00,0x00,0x80,0x03,0x00,0x00,0xC0,0x03,0x00,
134  0x00,0xC0,0x03,0x00,0x00,0xC0,0x01,0x00,0x00,0xE0,0x01,0x00,0x00,0xE0,0x01,0x00,
135  0x00,0xE0,0x01,0x00,0x00,0xF0,0x01,0x00,0x00,0xF0,0x01,0x00,0x00,0xF0,0x01,0x00,
136  0x00,0xF0,0x01,0x00,0x00,0xF0,0x01,0x00,0x00,0xF8,0x01,0x00,0x00,0xF8,0x01,0x00,
137  0x00,0xF8,0x01,0x00,0x00,0xF8,0x01,0x00,0x00,0xF8,0x01,0x00,0x00,0xF8,0x01,0x00,
138  0x00,0xF8,0x01,0x00,0x00,0xF8,0x01,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
139  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
140  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"7",7*/
141 
142 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
143  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
144  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x0F,0x00,
145  0x00,0xFE,0x7F,0x00,0x00,0x1F,0xF8,0x00,0x80,0x07,0xE0,0x01,0xC0,0x03,0xC0,0x03,
146  0xE0,0x01,0x80,0x07,0xE0,0x01,0x80,0x07,0xF0,0x00,0x00,0x0F,0xF0,0x00,0x00,0x0F,
147  0xF0,0x00,0x00,0x0F,0xF0,0x00,0x00,0x0F,0xF0,0x00,0x00,0x0F,0xF0,0x01,0x00,0x0F,
148  0xF0,0x01,0x00,0x07,0xE0,0x03,0x80,0x07,0xE0,0x07,0x80,0x03,0xC0,0x0F,0xC0,0x03,
149  0x80,0x3F,0xE0,0x01,0x00,0xFF,0x70,0x00,0x00,0xFE,0x3B,0x00,0x00,0xF8,0x0F,0x00,
150  0x00,0xFC,0x1F,0x00,0x00,0x8F,0x7F,0x00,0x80,0x07,0xFE,0x00,0xC0,0x03,0xFC,0x01,
151  0xE0,0x01,0xF8,0x03,0xE0,0x01,0xE0,0x03,0xF0,0x00,0xC0,0x07,0xF0,0x00,0xC0,0x07,
152  0x78,0x00,0x80,0x0F,0x78,0x00,0x80,0x0F,0x78,0x00,0x00,0x0F,0x78,0x00,0x00,0x0F,
153  0x78,0x00,0x00,0x0F,0x78,0x00,0x00,0x0F,0x78,0x00,0x00,0x0F,0xF0,0x00,0x00,0x07,
154  0xF0,0x00,0x80,0x07,0xE0,0x01,0x80,0x03,0xE0,0x01,0xC0,0x03,0xC0,0x07,0xE0,0x01,
155  0x00,0x1F,0xF8,0x00,0x00,0xFE,0x3F,0x00,0x00,0xF0,0x0F,0x00,0x00,0x00,0x00,0x00,
156  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
157  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"8",8*/
158 
159 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
160  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
161  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x07,0x00,
162  0x00,0xFE,0x1F,0x00,0x00,0x0F,0x3C,0x00,0x80,0x07,0x70,0x00,0xC0,0x03,0xE0,0x00,
163  0xE0,0x01,0xC0,0x01,0xE0,0x00,0xC0,0x01,0xF0,0x00,0x80,0x03,0xF0,0x00,0x80,0x03,
164  0x70,0x00,0x80,0x07,0x78,0x00,0x00,0x07,0x78,0x00,0x00,0x07,0x78,0x00,0x00,0x07,
165  0x78,0x00,0x00,0x0F,0x78,0x00,0x00,0x0F,0x78,0x00,0x00,0x0F,0x78,0x00,0x00,0x0F,
166  0x78,0x00,0x00,0x0F,0x78,0x00,0x80,0x0F,0xF8,0x00,0x80,0x0F,0xF0,0x00,0xC0,0x0F,
167  0xF0,0x01,0x60,0x0F,0xF0,0x01,0x70,0x0F,0xE0,0x03,0x38,0x0F,0xC0,0x0F,0x3E,0x0F,
168  0x80,0xFF,0x1F,0x0F,0x00,0xFF,0x07,0x0F,0x00,0xFC,0x81,0x07,0x00,0x00,0x80,0x07,
169  0x00,0x00,0x80,0x07,0x00,0x00,0x80,0x07,0x00,0x00,0x80,0x03,0x00,0x00,0xC0,0x03,
170  0x00,0x00,0xC0,0x03,0x00,0x00,0xC0,0x01,0xC0,0x01,0xE0,0x01,0xE0,0x03,0xE0,0x00,
171  0xE0,0x03,0xF0,0x00,0xE0,0x03,0x70,0x00,0xE0,0x03,0x38,0x00,0xC0,0x03,0x1C,0x00,
172  0xC0,0x07,0x0F,0x00,0x80,0xFF,0x07,0x00,0x00,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,
173  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
174  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"9",9*/
175 
176 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
177  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
178  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
179  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
180  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
181  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
182  0x00,0xC0,0x01,0x00,0x00,0xE0,0x03,0x00,0x00,0xF0,0x07,0x00,0x00,0xF0,0x07,0x00,
183  0x00,0xF0,0x07,0x00,0x00,0xE0,0x03,0x00,0x00,0xC0,0x01,0x00,0x00,0x00,0x00,0x00,
184  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
185  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
186  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
187  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
188  0x00,0xC0,0x01,0x00,0x00,0xE0,0x03,0x00,0x00,0xF0,0x07,0x00,0x00,0xF0,0x07,0x00,
189  0x00,0xF0,0x07,0x00,0x00,0xE0,0x03,0x00,0x00,0xC0,0x01,0x00,0x00,0x00,0x00,0x00,
190  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
191  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*":",10*/
192 
193 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
194  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
195  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
196  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
197  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
198  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
199  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
200  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0xFF,0xFF,0x3F,0xFC,0xFF,0xFF,0x3F,
201  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
202  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
203  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
204  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
205  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
206  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
207  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
208  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"-",11*/
209 
210 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
211  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
212  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
213  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
214  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
215  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
216  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
217  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
218  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
219  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
220  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
221  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
222  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
223  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
224  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
225  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*" ",12*/
226 };
227 
228 /**
229  * \brief 通过输入的字符获取在字模表的偏移量
230  *
231  * \retval 字母表中有该字符则返回偏移量,否则返回-1
232  */
233 static int __get_tab_offset (char dat)
234 {
235     int i;
236 
237     for (i = 0; i < sizeof(char_fs64) - 1; i++) {
238         if (dat == char_fs64[i]) {
239             return i;
240         }
241     }
242 
243     return -1;
244 }
245 
246 /**
247  * \brief 绘制一个英文字符,64号字体
248  *
249  * \retval 成功返回0,失败返回-1
250  */
251 int draw_one_char_fs64 (unsigned int x, unsigned int y, char dat)
252 {
253     int offset = 0;
254     int i, j, k;
255     char tmp = 0;
256     
257     offset = __get_tab_offset(dat);
258     if (offset == -1) {
259         return -1;
260     }
261 
262     for (i = 0; i < 64; i++) {
263         for (k = 0; k < 4; k++) {
264             tmp = font_size_64[offset][i * 4 + k];
265             for (j = 0 ; j < 8; j++) {
266                 if (tmp & 0x01) {
267                     draw_point(x + 8 * k + j, y + i);
268                 } else {
269                     draw_bk_point(x + 8 * k + j, y + i);
270                 }
271         
272                 tmp    >>= 1;
273             }
274         }
275     }
276     
277     return 0;
278 }

main.c

 1 #include <stdio.h>
 2 #include "draw.h"
 3 
 4 int main(int argc, const char *argv[])
 5 {
 6     int i = 0;
 7 
 8     if (framebuffer_init()) {
 9         return 0;
10     }
11 
12     full_screen(LCD_YELLOW);
13     set_pen_color(LCD_RED);
14     set_bk_color(LCD_WHITE);
15 
16 #if 0
17     set_font_size(FONT_SIZE_16);
18 
19     if (-1 == draw_one_char(20, 30, 7)) {
20         printf("fail to draw_one_char\n");
21     }
22 
23     draw_str(150, 150, "13-24-5:8");
24 #endif
25     set_font_size(FONT_SIZE_64);
26     draw_str(10, 100, "0123456789- :");
27 
28     while (1) {
29         sleep(5);
30     }
31 
32     return 0;
33 }

Makefile

 1 CC = arm-none-linux-gnueabi-
 2 OBJS = main.o draw.o font_size_16.o font_size_24.o font_size_32.o  3        font_size_48.o font_size_64.o
 4 OBJ = a.out
 5 $(OBJ):$(OBJS)
 6     $(CC)gcc $^ -o $@
 7 
 8 %.o:%.c
 9     $(CC)gcc -c $< -o $@
10 
11 .PHONY: 
12 clean:
13     rm $(OBJ) *.o
14 
15 cp:
16     sudo cp $(OBJ) ../../rootfs/ho

附上显示效果:

技术图片

我在程序中实现了16,24,32,48,64这5种字体,支持的字符为“0123456789-: ”这13个字符,因为只要显示时间,所以就只实现了这13个字符,需要实现其他字符的话只需要修改对应的字体文件就可以了。需要支持其他字体也很方便,在draw.c第20行后面声明新字体的绘制函数,并在__g_draw_font_tab数组中将绘制字体的函数与相应字体大小关联起来。在draw.h第15行中的枚举类型中加入字体大小,需要注意的是字体大小一定要是偶数。

十五、在屏幕上显示字符

标签:clean   font   sleep   最好   obj   否则   while   cto   sizeof   

原文地址:https://www.cnblogs.com/Suzkfly/p/10373733.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!