微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 单片机GUI编程显示汉字

单片机GUI编程显示汉字

时间:11-26 来源:互联网 点击:
单片机GUI编程显示汉字

int8GetGB12_Address( int8 *ptr )

{

int8 addr;

for (addr=0;addr//查找定位

{

if (( *ptr == gb12Dot[addr].Index[0]) && ( *(ptr+1) == gb12Dot[addr].Index[1]))

{break;}

}

returnaddr;

}

GUI_PutHZ(x1,y1,(uint8*)gb12Dot[GetGB12_Address(ptr)].Msk,12, 12);

const typFNT_GB12gb12Dot[] = {

" ", 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,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,

0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

"敏", 0x41,0x00,0x7F,0x00,0x81,0xE0,0x7F,0x40,0x55,0x40,0xFF,0x40,0x55,0x40,0x54,0x80,

0x7E,0x80,0x05,0x40,0x1A,0x20,0x00,0x00,

"感", 0x01,0x40,0x7F,0xE0,0x41,0x00,0x7F,0x40,0x5D,0x40,0x54,0xA0,0x9D,0x60,0x82,0x20,

0x54,0x40,0x52,0xA0,0x9F,0x80,0x00,0x00,

"度", 0x02,0x00,0x7F,0xE0,0x48,0x80,0x7F,0xE0,0x48,0x80,0x4F,0x80,0x40,0x00,0x5F,0x80,

0x45,0x00,0x87,0x00,0xB8,0xE0,0x00,0x00

}

typedef struct//汉字字模数据结构

{

int8 Index[2];//汉字内码索引

int8 Msk[24];//点阵码数据

}typFNT_GB12;

voidGUI_PutHZ(uint32 x, uint32 y, uint8 *dat, uint8 hno, uint8 lno)

{uint8i;

for(i=0; i

{GUI_LoadLine(x, y, dat, hno);//输出一行数据

y++;//显示下一行

dat += (hno>>3);//计算下一行的数据

if( (hno&0x07)!=0 ) dat++;

}

}

uint8GUI_LoadLine(uint32 x, uint32 y, uint8 *dat, uint32 no)

{

uint8bit_dat;

uint8i;

TCOLORbakc;

if(x>=GUI_LCM_XMAX)

return(0);

if(y>=GUI_LCM_YMAX)

return(0);

for(i=0; i

{

if( (i%8)==0 ) bit_dat = *dat++;

if( (bit_dat&DCB2HEX_TAB[i&0x07])==0 )

GUI_CopyColor(&bakc, back_color);

else

GUI_CopyColor(&bakc, disp_color);

GUI_Point(x, y, bakc);

if( (++x)>=GUI_LCM_XMAX )

return(0);

}

return(1);

}

uint8GUI_Point(uint8 x, uint8 y, TCOLOR color)

{

if(x>=GUI_LCM_XMAX)

return(0);

if(y>=GUI_LCM_YMAX)

return(0);

if( (color&0x01) != 0 )

gui_disp_buf[y][x>>3] |=DCB_HEX_TAB[x&0x07];

else

gui_disp_buf[y][x>>3] &= (~DCB_HEX_TAB[x&0x07]);

LCD_UpdatePoint(x, y);

return(1);

}

uint8 constDCB_HEX_TAB[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};

TCOLORgui_disp_buf[GUI_LCM_YMAX][GUI_LCM_XMAX/8];

voidLCD_UpdatePoint(uint32 x, uint32 y)

{ // uint32addr;

uint32addr11;

uint32addr22;

//addr = y*(GUI_LCM_XMAX>>3) + (x>>3);

addr11 = y*32%6 + (x>>3);

addr22 =y*32/256;

//WriteCmd3(addr&0xFF, addr>>8,AddrSet);//置地址指针

WriteCmd3(addr11, addr22,AddrSet);//置地址指针

delay(10);

WriteCmd2(gui_disp_buf[y][x>>3],DataWAddrI);

delay(10);

}

uint8 ReadSdate(void)

{

uint8checkbusy;

//LCD_BUS = 0xff;

OutData(0xff);

//CD1=1;

SCD1();

//RD1=0;

CRD1();

//checkbusy=((IO0PIN&0x00ff0000)>>16);

checkbusy = (GPIOD->IDR&0x00ff);

//RD1=1;

SRD1();

return ( checkbusy );

}

void RWcheck(void)

{

uint8databusy;

do

{

databusy=ReadSdate();

}while( !(databusy&0x03) );

}

void AutoRcheck(void)

{

uint8databusy;

do

{

databusy=ReadSdate();

}while( !(databusy&0x04) );

}

void AutoWcheck(void)

{

uint8databusy;

do

{

databusy=ReadSdate();

}while( !(databusy&0x08) );

}

//写数据

voidWriteData(uint8 dat)

{

RWcheck();

//CD1=0;

CCD1();

//LCD_BUS=dat;

OutData(dat);

//WR1=0;

CWR1();

//WR1=1;

SWR1();

}

//写指令

voidWriteCmd1(unsigned char cmd)

{

RWcheck();;

//CD1=1;

SCD1();

//LCD_BUS=cmd;

OutData(cmd);

//WR1=0;

CWR1();

//WR1=1;

SWR1();

}

//先写数据再写指令

voidWriteCmd2(uint8 dat,uint8 cmd)

{

WriteData(dat);

WriteCmd1(cmd);

}

//先写2组数据再写1组指令

voidWriteCmd3(uint8 dat1,uint8 dat2,uint8 cmd)

{

WriteData(dat1);

WriteData(dat2);;

WriteCmd1(cmd);

}

//数据自动写

voidAutoWriteData( uint8 dat)

{

AutoWcheck();;

//CD1 = 0;

CCD1();

//LCD_BUS= dat;

OutData(dat);

//WR1=0;

CWR1();

//WR1=1;

SWR1();

}

#defineOutData(dat)GPIOD->BRR = 0xffBSRR = (dat&0xff)

#defineLCM_WR112

#defineSWR1()GPIOB->BSRR = 1

#defineCWR1()GPIOB->BRR= 1

#defineLCM_RD113

#defineSRD1()GPIOB->BSRR = 1

#defineCRD1()GPIOB->BRR= 1

#defineLCM_CE114

#defineSCE1()GPIOB->BSRR = 1

#define

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top