WhyCan Forum

人过留名,雁过留声,感谢各位朋友不离不弃地支持。 QQ: 516333132, 微信: whycan_cn (哇酷网/挖坑网/填坑网) admin@whycan.cn

您尚未登录。

#1 2018-04-13 16:41:08

晕哥
Administrator
注册时间: 2017-09-06
累计积分: 8,528

step by step 给ts_calibrate 触摸屏校正程序加上汉字显示.

QQ20180413164357.png

一个触摸屏校正程序,只能光秃秃显示几个英文字母,
不加几个汉字是不是没有一点民族自豪感?
捂脸.gif

那么下面我们step by step 给ts_calibrate.c 触摸屏校正程序加上汉字显示.

离线

#2 2018-04-13 16:42:05

晕哥
Administrator
注册时间: 2017-09-06
累计积分: 8,528

Re: step by step 给ts_calibrate 触摸屏校正程序加上汉字显示.

QQ20180413164128.png

QQ20180413164133.png

因为只需要显示几个离散汉字: 请点击十字光标校正触摸屏。
所以没有必要弄一个全字库.

下载链接: 字模软件下载

离线

#3 2018-04-13 16:45:24

晕哥
Administrator
注册时间: 2017-09-06
累计积分: 8,528

Re: step by step 给ts_calibrate 触摸屏校正程序加上汉字显示.

重新下载: zimoV2_2.rar

楼上的字库软件错了.

离线

#4 2018-04-13 16:45:26

晕哥
Administrator
注册时间: 2017-09-06
累计积分: 8,528

Re: step by step 给ts_calibrate 触摸屏校正程序加上汉字显示.

QQ20180413170153.png

还算顺利, 差不多搞定了。

离线

#5 2018-04-13 16:45:28

晕哥
Administrator
注册时间: 2017-09-06
累计积分: 8,528

Re: step by step 给ts_calibrate 触摸屏校正程序加上汉字显示.

QQ20180413170902.png

摆正一点

离线

#6 2018-04-13 16:45:30

晕哥
Administrator
注册时间: 2017-09-06
累计积分: 8,528

Re: step by step 给ts_calibrate 触摸屏校正程序加上汉字显示.

fbutils.c 添加:

void put_chinese_char(int x, int y, int c, int colidx)
{
    int i,j;
    uint16_t a = 0, b = 0;
    uint16_t bits;

    for (i = 0; i < font_vga_16x16.height*2; i++) {
        a = font_vga_16x16.data [c * 32 + i];
        i++;
        b = font_vga_16x16.data [c * 32 + i];
        bits = a<<8 | b;

        printf("a=0x%02x, b=0x%02x, bits = 0x%04x, font_vga_16x16.width=%d\n", a, b, bits, font_vga_16x16.width);

        for (j = 0; j < font_vga_16x16.width; j++, bits <<= 1)
        {
            if (bits & 0x8000)
                pixel (x + j, y + i/2, colidx);
        }
    }
}

字库文件 font_16x16.c:

#include "font.h"

#define FONTDATAMAX 4096*2

static unsigned char fontdata_16x16[FONTDATAMAX] = {
/*--  文字:  请  --*/
/*--  Franklin Gothic Medium12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x00,0x40,0x40,0x40,0x27,0xFC,0x20,0x40,0x03,0xF8,0x00,0x40,0xE7,0xFE,0x20,0x00,
0x23,0xF8,0x22,0x08,0x23,0xF8,0x22,0x08,0x2B,0xF8,0x32,0x08,0x22,0x28,0x02,0x10,

/*--  文字:  点  --*/
/*--  Franklin Gothic Medium12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x02,0x00,0x02,0x00,0x02,0x00,0x03,0xFC,0x02,0x00,0x02,0x00,0x3F,0xF0,0x20,0x10,
0x20,0x10,0x20,0x10,0x3F,0xF0,0x00,0x00,0x24,0x88,0x22,0x44,0x42,0x44,0x80,0x04,

/*--  文字:  击  --*/
/*--  Franklin Gothic Medium12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x01,0x00,0x01,0x00,0x01,0x00,0x3F,0xF8,0x01,0x00,0x01,0x00,0x01,0x00,0xFF,0xFE,
0x01,0x00,0x01,0x00,0x21,0x08,0x21,0x08,0x21,0x08,0x21,0x08,0x3F,0xF8,0x00,0x08,

/*--  文字:  十  --*/
/*--  Franklin Gothic Medium12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0xFF,0xFE,0x01,0x00,
0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,

/*--  文字:  字  --*/
/*--  Franklin Gothic Medium12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x02,0x00,0x01,0x00,0x7F,0xFE,0x40,0x02,0x80,0x04,0x1F,0xE0,0x00,0x40,0x00,0x80,
0x01,0x00,0xFF,0xFE,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x05,0x00,0x02,0x00,

/*--  文字:  光  --*/
/*--  Franklin Gothic Medium12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x01,0x00,0x21,0x08,0x11,0x08,0x09,0x10,0x09,0x20,0x01,0x00,0xFF,0xFE,0x04,0x40,
0x04,0x40,0x04,0x40,0x04,0x40,0x08,0x42,0x08,0x42,0x10,0x42,0x20,0x3E,0xC0,0x00,

/*--  文字:  标  --*/
/*--  Franklin Gothic Medium12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x10,0x00,0x11,0xFC,0x10,0x00,0x10,0x00,0xFC,0x00,0x13,0xFE,0x30,0x20,0x38,0x20,
0x55,0x28,0x55,0x24,0x92,0x24,0x12,0x22,0x14,0x22,0x10,0x20,0x10,0xA0,0x10,0x40,

/*--  文字:  校  --*/
/*--  Franklin Gothic Medium12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x10,0x40,0x10,0x20,0x10,0x20,0x11,0xFE,0xFC,0x00,0x10,0x88,0x31,0x04,0x3A,0x02,
0x54,0x88,0x50,0x88,0x90,0x50,0x10,0x50,0x10,0x20,0x10,0x50,0x10,0x88,0x13,0x06,

/*--  文字:  正  --*/
/*--  Franklin Gothic Medium12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x00,0x00,0x7F,0xFC,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x11,0x00,0x11,0xF8,
0x11,0x00,0x11,0x00,0x11,0x00,0x11,0x00,0x11,0x00,0x11,0x00,0xFF,0xFE,0x00,0x00,

/*--  文字:  触  --*/
/*--  Franklin Gothic Medium12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x20,0x20,0x20,0x20,0x78,0x20,0x49,0xFC,0x91,0x24,0x7D,0x24,0x55,0x24,0x55,0x24,
0x7D,0xFC,0x55,0x24,0x54,0x20,0x7C,0x28,0x54,0x24,0x57,0xFE,0x45,0x02,0x8C,0x00,

/*--  文字:  摸  --*/
/*--  Franklin Gothic Medium12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x11,0x10,0x11,0x10,0x17,0xFC,0x11,0x10,0xFC,0x00,0x13,0xF8,0x12,0x08,0x17,0xF8,
0x1A,0x08,0x33,0xF8,0xD0,0x40,0x17,0xFC,0x10,0xA0,0x11,0x10,0x52,0x08,0x24,0x06,

/*--  文字:  屏  --*/
/*--  Franklin Gothic Medium12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x00,0x00,0x3F,0xF8,0x20,0x08,0x20,0x08,0x3F,0xF8,0x24,0x10,0x22,0x20,0x2F,0xF8,
0x22,0x20,0x22,0x20,0x3F,0xFC,0x22,0x20,0x42,0x20,0x44,0x20,0x84,0x20,0x08,0x20,

/*--  文字:  。  --*/
/*--  Franklin Gothic Medium12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x18,0x00,0x24,0x00,0x24,0x00,0x18,0x00,0x00,0x00,0x00,0x00,


};


struct fbcon_font_desc font_vga_16x16 = {
    VGA16x16_IDX,
    "VGA16x16",
    16,
    16,
    fontdata_16x16,
    0
};

显示汉字:

	int xleft = 300;
	int ytop = yres / 4 + 50;
	put_chinese_char(xleft + 16*0, ytop + 0 ,0, 1);
	put_chinese_char(xleft + 16*1, ytop + 0 ,1, 1);
	put_chinese_char(xleft + 16*2, ytop + 0 ,2, 1);
	put_chinese_char(xleft + 16*3, ytop + 0 ,3, 1);
	put_chinese_char(xleft + 16*4, ytop + 0 ,4, 1);
	put_chinese_char(xleft + 16*5, ytop + 0 ,5, 1);
	put_chinese_char(xleft + 16*6, ytop + 0 ,6, 1);
	put_chinese_char(xleft + 16*7, ytop + 0 ,7, 1);
	put_chinese_char(xleft + 16*8, ytop + 0 ,8, 1);
	put_chinese_char(xleft + 16*9, ytop + 0 ,9, 1);

	put_chinese_char(xleft + 16*10, ytop + 0 ,10, 1);
	put_chinese_char(xleft + 16*11, ytop + 0 ,11, 1);
	put_chinese_char(xleft + 16*12, ytop + 0 ,12, 1);

就这样搞定!

离线

#7 2018-04-13 16:45:33

晕哥
Administrator
注册时间: 2017-09-06
累计积分: 8,528

Re: step by step 给ts_calibrate 触摸屏校正程序加上汉字显示.

QQ20180414093911.jpg

交叉编译到机器上面运行。

离线

#8 2018-04-13 17:10:39

晕哥
Administrator
注册时间: 2017-09-06
累计积分: 8,528

Re: step by step 给ts_calibrate 触摸屏校正程序加上汉字显示.

占位

离线

#9 2018-04-13 21:14:19

daydayup
会员
注册时间: 2017-10-09
累计积分: 308

Re: step by step 给ts_calibrate 触摸屏校正程序加上汉字显示.

厉害了大神,我是来学习的。

离线

#10 2018-04-14 08:56:47

小猪佩奇
会员
注册时间: 2018-03-19
累计积分: 59

Re: step by step 给ts_calibrate 触摸屏校正程序加上汉字显示.

厉害了

离线

#11 2018-04-21 10:16:44

kgp0213
会员
注册时间: 2018-01-15
累计积分: 149

Re: step by step 给ts_calibrate 触摸屏校正程序加上汉字显示.

厉害了,大神,就是把汉字的编码指向字库所在的位置

离线

#12 2018-04-26 06:14:06

xinxiaoci
会员
注册时间: 2018-04-18
累计积分: 71

Re: step by step 给ts_calibrate 触摸屏校正程序加上汉字显示.

厉害了晕哥,你这精力跟充沛啊!赶不上,只能膜拜

离线

#13 2018-07-06 15:54:49

BugActiveDaughter
Moderator
注册时间: 2017-10-17
累计积分: 77

Re: step by step 给ts_calibrate 触摸屏校正程序加上汉字显示.

厉害了晕哥

离线

#14 2018-07-06 22:08:21

arphone
会员
注册时间: 2017-11-03
累计积分: 65

Re: step by step 给ts_calibrate 触摸屏校正程序加上汉字显示.

厉害了

离线

#15 2019-12-02 20:33:13

win32prog
会员
注册时间: 2019-11-28
累计积分: 66

Re: step by step 给ts_calibrate 触摸屏校正程序加上汉字显示.

好帖好帖, mark学习

离线

页脚