有时候做一个简单东西,上GUI又不合适,以按每个词条做字库,可是显示的时候麻烦,做词条也麻烦
最近找个一个方法
做英文字库
uint8_t const yin_ziku_6x12[][12]=
{
{0xF8,0x04,0x04,0x04,0xF8,0x00,0x07,0x08,0x08,0x08,0x07,0x00},//"0"
{0x00,0x08,0xFC,0x00,0x00,0x00,0x00,0x08,0x0F,0x08,0x00,0x00},//"1"
{0x18,0x04,0x04,0x84,0x78,0x00,0x0C,0x0A,0x09,0x08,0x08,0x00},//"2"
{0x08,0x44,0x44,0x44,0xB8,0x00,0x04,0x08,0x08,0x08,0x07,0x00},//"3"
{0x80,0x60,0x18,0xFC,0x00,0x00,0x01,0x01,0x01,0x0F,0x01,0x00},//"4"
{0x7C,0x44,0x44,0x44,0x84,0x00,0x04,0x08,0x08,0x08,0x07,0x00},//"5"
{0xF0,0x48,0x44,0x44,0x80,0x00,0x07,0x08,0x08,0x08,0x07,0x00},//"6"
{0x04,0x04,0x84,0x64,0x1C,0x00,0x00,0x00,0x0F,0x00,0x00,0x00},//"7"
{0xB8,0x44,0x44,0x44,0xB8,0x00,0x07,0x08,0x08,0x08,0x07,0x00},//"8"
{0x78,0x84,0x84,0x84,0xF8,0x00,0x00,0x08,0x08,0x04,0x03,0x00},//"9"
...
}
typedef struct
{
uint8_t *const hz_n_sting;
uint8_t const hz_n_sting_p[24];
}hz_dis_find_t;
做中文字库 ,用列编辑很方便做
hz_dis_find_t const hz_dis_find[]=
{
{{"自"},{ 0x00,0xFC,0x24,0x24,0x26,0x25,0x24,0x24,0x24,0xFC,0x00,0x00,0x00,0x0F,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x0F,0x00,0x00}},///*"自",0*/
{{"动"},{ 0x10,0xD2,0x32,0x92,0x10,0x00,0x08,0xFF,0x08,0x08,0xF8,0x00,0x03,0x02,0x02,0x02,0x03,0x08,0x06,0x01,0x08,0x08,0x07,0x00}},///*"动",1*/
{{"执"},{ 0x88,0xFF,0x48,0x00,0x48,0xFF,0x08,0x08,0xF8,0x00,0x00,0x00,0x08,0x0F,0x08,0x04,0x03,0x00,0x03,0x00,0x03,0x04,0x0E,0x00}},///*"执",2*/
....
{{0},{ 0x88,0xFF,0x48,0x00,0x48,0xFF,0x08,0x08,0xF8,0x00,0x00,0x00,0x08,0x0F,0x08,0x04,0x03,0x00,0x03,0x00,0x03,0x04,0x0E,0x00}},///*0,2*/
}
显示 功能
uint8_t const *GetGBKCode(uint8_t * c)
{
hz_dis_find_t const *hz_dis_find_p;
hz_dis_find_p=hz_dis_find;
while( hz_dis_find_p->hz_n_sting!=0 )
{
if(( hz_dis_find_p->hz_n_sting[0] == c[0])
&&( hz_dis_find_p->hz_n_sting[1] == c[1]))
{
return hz_dis_find_p->hz_n_sting_p;
}
hz_dis_find_p++;
}
return (uint8_t *)0;
}
void dis_string( uint8_t * char_string, uint8_t x0, uint8_t y0 )
{ uint8_t const *hz_p;
while (*char_string)
{
if (*char_string<128)
{
dis_yin_6x14(*char_string,x0,y0);
x0+=6;
char_string++;
}
else
{
hz_p=GetGBKCode(char_string);
if(hz_p!=0)
{
dis_hz_12x14(hz_p,x0,y0);
x0+=12;
}
char_string+=2;
}
}
}
void dis_yin_6x14(uint8_t C,x0,y0)
{ 英文显示,根据字符查字库
}
void dis_hz_12x14(uint8_t const *c_p,uint8_t x0,uint8_t y0)
{//中文显示,传过来就是字库指针
}
例 :
dis_string(“你好 World”,10,10);
一周热门 更多>