tg12232b.c
来自「STC51系列的源码」· C语言 代码 · 共 622 行 · 第 1/2 页
C
622 行
xpos%=20;
ypos%=4;
if( xpos>=10)
{ xpos-=10;
ypos+=4;
}
if( ypos>0x3)
{ chip=0x1;
}
else
{ chip=0x0;
}
LCDP_set_page(ypos%4);
LCDP_set_column(xpos*6);
for(i=0;i<6;i++)
{ LCDP_write_ram_data(chip,buffer[i]);
}
}
/********************************************************************************/
/* fun_name : LCDP_display_hz16x16() */
/* version : v1.00 */
/* created : xillinx */
/* descript : 汉字取模: 从左到右从上到下取模,低位在上,高位在下 */
/********************************************************************************/
void LCDP_display_hz16x16(
unsigned char xpos,
unsigned char ypos,
unsigned char *buffer)
{ unsigned char * mdata;
unsigned char i,wr;
if(ypos>0x1)
{ return;
}
mdata=buffer;
wr=(xpos<<0x4);
LCDP_set_page((ypos<<0x1)+0x0);
for(i=0x0;i<0x10;i++)
{ if(wr>=61)
{ LCDP_set_column(wr-61);
LCDP_write_ram_data(0x1,*mdata++);
}
else
{ LCDP_set_column(wr);
LCDP_write_ram_data(0x0,*mdata++);
}
wr++;
}
wr=(xpos<<0x4);
LCDP_set_page((ypos<<0x1)+0x1);
for(i=0x0;i<0x10;i++)
{ if(wr>=61)
{ LCDP_set_column(wr-61);
LCDP_write_ram_data(0x1,*mdata++);
}
else
{ LCDP_set_column(wr);
LCDP_write_ram_data(0x0,*mdata++);
}
wr++;
}
}
/********************************************************************************/
/* fun_name : LCDP_clear_display_buffer() */
/* version : v1.00 */
/* created : xillinx */
/* descript : 清除LCD的显示缓冲区 */
/********************************************************************************/
void LCDP_clear_display_buffer(void)
{ unsigned char i,bytes=80;
LCDP_set_page(0x00);
LCDP_set_column(0x00);
for(i=0x0;i<bytes;i++)
{ LCDP_write_ram_data(0x0,0x0);
LCDP_write_ram_data(0x1,0x0);
}
LCDP_set_page(0x01);
LCDP_set_column(0x00);
for(i=0x0;i<bytes;i++)
{ LCDP_write_ram_data(0x0,0x0);
LCDP_write_ram_data(0x1,0x0);
}
LCDP_set_page(0x02);
LCDP_set_column(0x00);
for(i=0x0;i<bytes;i++)
{ LCDP_write_ram_data(0x0,0x0);
LCDP_write_ram_data(0x1,0x0);
}
LCDP_set_page(0x03);
LCDP_set_column(0x00);
for(i=0x0;i<bytes;i++)
{ LCDP_write_ram_data(0x0,0x0);
LCDP_write_ram_data(0x1,0x0);
}
}
/********************************************************************************/
/* fun_name : LCDP_get_index() */
/* version : v1.00 */
/* created : xillinx */
/* descript : 获取字符的索引 */
/********************************************************************************/
unsigned char LCDP_get_index(unsigned char szText)
{ unsigned char i;
for(i=0;i<128;i++)
{ if( szText==lcd_table[i])
{ return i;
}
}
return 0x0;
}
/********************************************************************************/
/* fun_name : LCDP_get_text_font() */
/* version : v1.00 */
/* created : xillinx */
/* descript : 获取字符的点阵表数据 */
/********************************************************************************/
unsigned char * LCDP_get_text_font(unsigned char index)
{ static unsigned char Font[0x6];
unsigned char i;
for(i=0;i<0x6;i++)
{ Font[i]=lcd_ascii_txt[index][i];
}
return Font;
}
/********************************************************************************/
/* fun_name : LCDP_hard_reset() */
/* version : v1.00 */
/* created : xillinx */
/* descript : LCDP的硬件复位 */
/********************************************************************************/
void LCDP_hard_reset(void)
{ c51_U07_latch&=0x7F; //* LCD 硬复位
c51_hc138_cs_keyw[0x0]=c51_U07_latch;
LCDP_delay();
c51_U07_latch|=0x80;
c51_hc138_cs_keyw[0x0]=c51_U07_latch;
LCDP_delay();
}
/********************************************************************************/
/* fun_name : LCDP_LED_open() */
/* version : v1.00 */
/* created : xillinx */
/* descript : LCDP的背光打开 */
/********************************************************************************/
void LCDP_LED_open(void)
{ c51_U07_latch|=0x40; //* LCD背光打开
c51_hc138_cs_keyw[0x0]=c51_U07_latch;
}
/********************************************************************************/
/* fun_name : LCDP_LED_close() */
/* version : v1.00 */
/* created : xillinx */
/* descript : LCDP的背光关闭 */
/********************************************************************************/
#if 0
void LCDP_LED_close(void)
{ c51_U07_latch&=0xBF; //* LCD背光关闭
c51_hc138_cs_keyw[0x0]=c51_U07_latch;
}
#endif
/********************************************************************************/
/* fun_name : LCDP_module_initialize() */
/* version : v1.00 */
/* created : xillinx */
/* descript : LCDP模块初始化 */
/********************************************************************************/
void LCDP_module_initialize(void)
{ LCDP_hard_reset();
LCDP_LED_open();
LCDP_write_command(LCD_RESET);
LCDP_write_command(0xA0); //* 0xa0
LCDP_write_command(LCD_DUTY_32); //* 0xa9
LCDP_start_line(0x00); //* 0xc0+0x00
LCDP_write_command(LCD_DISP_ON); //* 0xaf
}
/********************************************************************************/
/* fun_name : LCDP_text_printf() */
/* version : v1.00 */
/* created : xillinx */
/* descript : 输出字符显示数据 */
/********************************************************************************/
void LCDP_text_printf(unsigned char x,unsigned char y,unsigned char * buffer)
{ unsigned char *Text;
while(*buffer)
{ Text=LCDP_get_text_font(LCDP_get_index(*buffer));
LCDP_display_text(x++,y,Text);
if( x==20)
{ break;
}
buffer++;
}
}
/********************************************************************************/
/* fun_name : LCDP_get_hz16_font() */
/* version : v1.00 */
/* created : xillinx */
/* descript : 获取汉字显示区的地址 */
/********************************************************************************/
unsigned char * LCDP_get_hz16_font(unsigned char * hz16)
{ unsigned char status;
unsigned char i;
for(i=0x0;i<0x10;i++)
{ status=memcmp(rongyi_hz[i].Index,hz16,0x2);
if( status==0x0)
{ break;
}
}
if( i>=0x10)
{ return NULL;
}
else
{ return rongyi_hz[i].Msk;
}
}
/********************************************************************************/
/* fun_name : LCDP_hz16_printf() */
/* version : v1.00 */
/* created : xillinx */
/* descript : 输出汉字显示数据 */
/********************************************************************************/
void LCDP_hz16_printf(unsigned char xpos,unsigned char ypos,unsigned char * buffer)
{ unsigned char * mdata;
unsigned char * text;
mdata=buffer;
while(*mdata)
{ text=LCDP_get_hz16_font(mdata);
LCDP_display_hz16x16(xpos++,ypos,text);
mdata+=0x2;
if( xpos==10)
{ break;
}
}
}
/********************************************************************************/
/* fun_name : LCDP_display_sheft_hz16x16() */
/* version : v1.00 */
/* created : xillinx */
/* descript : 汉字取模: 从左到右从上到下取模,低位在上,高位在下 */
/********************************************************************************/
void LCDP_display_sheft_hz16x16(
unsigned char sheft,
unsigned char xpos,
unsigned char ypos,
unsigned char *buffer)
{ unsigned char * mdata;
unsigned char i,wr;
if(ypos>0x1)
{ return;
}
mdata=buffer;
wr=(xpos<<0x4)+sheft;
LCDP_set_page((ypos<<0x1)+0x0);
for(i=0x0;i<0x10;i++)
{ if(wr>=61)
{ LCDP_set_column(wr-61);
LCDP_write_ram_data(0x1,*mdata++);
}
else
{ LCDP_set_column(wr);
LCDP_write_ram_data(0x0,*mdata++);
}
wr++;
}
wr=(xpos<<0x4)+sheft;
LCDP_set_page((ypos<<0x1)+0x1);
for(i=0x0;i<0x10;i++)
{ if(wr>=61)
{ LCDP_set_column(wr-61);
LCDP_write_ram_data(0x1,*mdata++);
}
else
{ LCDP_set_column(wr);
LCDP_write_ram_data(0x0,*mdata++);
}
wr++;
}
}
/********************************************************************************/
/* fun_name : LCDP_hz16_sheft_printf() */
/* version : v1.00 */
/* created : xillinx */
/* descript : 输出汉字显示数据 */
/********************************************************************************/
void LCDP_hz16_sheft_printf(unsigned char sheft,unsigned char xpos,unsigned char ypos,unsigned char * buffer)
{ unsigned char * mdata;
unsigned char * text;
mdata=buffer;
while(*mdata)
{ text=LCDP_get_hz16_font(mdata);
LCDP_display_sheft_hz16x16(sheft, xpos++,ypos,text);
mdata+=0x2;
if( xpos==10)
{ break;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?