tg12232b.c

来自「STC51系列的源码」· C语言 代码 · 共 622 行 · 第 1/2 页

C
622
字号
/********************************************************************************/
/* filename : TG12232B.c                                                        */
/* created  : xillinx                                                           */
/* descript : 处理LCDP显示的部分                                                */
/********************************************************************************/
#include "../CPU/CPU.h"
#include "../TG12232B/TG12232B.h"

//*****************************************************************************/
//* 横向取模左高位,数据排列:从左到右从上到下
//*****************************************************************************/
st_type_gb_font code rongyi_hz[0x10]={  //* 数据表
"深",   0xFF,0xED,0xDB,0x73,0xFF,0x71,0x5D,0x6D,0x75,0x1D,0x75,0x6D,0x5D,0x71,0xFF,0xFF,
        0xFF,0xC3,0xFC,0xFF,0xF7,0xF7,0xFB,0xFD,0xFE,0xC0,0xFE,0xFD,0xFB,0xF7,0xFF,0xFF,
                                                                                        
"圳",   0xFF,0xDF,0xDF,0x01,0xDF,0xDF,0x01,0xFF,0xFF,0x03,0xFF,0xFF,0x01,0xFF,0xFF,0xFF,
        0xFF,0xFB,0xFB,0xF8,0xDD,0xE5,0xF8,0xFF,0xFF,0xF0,0xFF,0xFF,0xC0,0xFF,0xFF,0xFF,
                                                                                        
"融",   0xFF,0x7D,0x45,0x55,0x55,0x55,0x45,0x7D,0x0F,0xEF,0x01,0xEF,0x0F,0xFF,0xFF,0xFF,
        0xFF,0xC0,0xFB,0xF8,0xC3,0xF8,0xDB,0xC0,0xDE,0xDE,0xC0,0xDE,0xCE,0xDF,0xFF,0xFF,
                                                                                        
"益",   0xFF,0xF7,0x77,0x77,0xB5,0xD3,0xF7,0xF7,0xF7,0xD3,0xB5,0x77,0x77,0xF7,0xFF,0xFF,
        0xFF,0xDF,0xC1,0xDD,0xDD,0xC1,0xDD,0xDD,0xDD,0xC1,0xDD,0xDD,0xC1,0xDF,0xFF,0xFF,
                                                                                        
"通",   0xFF,0xBD,0x3B,0xF3,0xFF,0x0D,0xAD,0xA9,0x05,0xA5,0xA9,0x0D,0xFF,0xFF,0xFF,0xFF,
        0xFF,0xCF,0xF0,0xEF,0xDF,0xD0,0xDE,0xDE,0xD0,0xDE,0xD6,0xD0,0xDF,0xDF,0xFF,0xFF,
                                                                                        
"电",   0xFF,0x0F,0x6F,0x6F,0x6F,0x6F,0x01,0x6F,0x6F,0x6F,0x6F,0x0F,0xFF,0xFF,0xFF,0xFF,
        0xFF,0xF0,0xFB,0xFB,0xFB,0xFB,0xE0,0xDB,0xDB,0xDB,0xDB,0xD8,0xDF,0xE7,0xFF,0xFF,
                                                                                        
"子",   0xFF,0x7F,0x7D,0x7D,0x7D,0x7D,0x7D,0x1D,0x6D,0x75,0x79,0x7D,0x7F,0x7F,0xFF,0xFF,
        0xFF,0xFF,0xFF,0xFF,0xFF,0xEF,0xDF,0xE0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
                                                                                        
"开",   0xFF,0x7F,0x7D,0x7D,0x7D,0x01,0x7D,0x7D,0x7D,0x01,0x7D,0x7D,0x7D,0x7F,0xFF,0xFF,
        0xFF,0xFF,0xDF,0xEF,0xF3,0xFC,0xFF,0xFF,0xFF,0xC0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
                                                                                        
"发",   0xFF,0xFF,0xE7,0xE9,0xEF,0x6F,0x0F,0x61,0x6F,0x6F,0x6D,0x6B,0xEF,0xEF,0xFF,0xFF,
        0xFF,0xEF,0xF7,0xDB,0xDD,0xDE,0xEE,0xF5,0xFB,0xF5,0xEE,0xDF,0xDF,0xDF,0xFF,0xFF,
                                                                                        
"板",   0xFF,0xEF,0x2F,0x01,0x6F,0xEF,0x03,0x5B,0xDB,0xDB,0xDD,0x5D,0x9D,0xFF,0xFF,0xFF,
        0xFF,0xFC,0xFF,0xC0,0xDF,0xEE,0xD0,0xDF,0xEE,0xF5,0xF1,0xEE,0xDF,0xDF,0xFF,0xFF,
                                                                                        
"卡",   0xFF,0xBF,0xBF,0xBF,0xBF,0xBF,0x01,0xB7,0xB7,0xB7,0xB7,0xB7,0xBF,0xBF,0xFF,0xFF,
        0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0xFF,0xFE,0xFD,0xFB,0xF3,0xFF,0xFF,0xFF,0xFF,
                                                                                        
"设",   0xFF,0xBF,0xBD,0x33,0xFF,0xBF,0x5F,0x61,0x7D,0x7D,0x61,0x5F,0x5F,0xDF,0xFF,0xFF,
        0xFF,0xFF,0xFF,0xC0,0xEF,0xD7,0xDF,0xEE,0xF5,0xFB,0xF5,0xEE,0xDF,0xDF,0xFF,0xFF,
                                                                                        
"计",   0xFF,0xBF,0xBD,0x33,0xFF,0xBF,0xBF,0xBF,0xBF,0x01,0xBF,0xBF,0xBF,0xBF,0xFF,0xFF,
        0xFF,0xFF,0xFF,0xC0,0xEF,0xF7,0xFB,0xFF,0xFF,0xC0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
                                                                                        
"室",   0xFF,0xE3,0xDB,0xDB,0x5B,0x9B,0xDB,0xD9,0xDB,0xDB,0x5B,0xDB,0xDB,0xE3,0xFF,0xFF,
        0xFF,0xDF,0xDF,0xDA,0xDA,0xDA,0xDA,0xC0,0xDA,0xDA,0xDA,0xDA,0xDF,0xDF,0xFF,0xFF,
};

//*****************************************************************************/
//* fun_name : lcd_table()
//* version  : v1.00
//* created  : xillinx                                                        */
//*****************************************************************************/
unsigned char code lcd_table[]=
{   ' ','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R',
    'S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k',
    'l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','`','1','2','3',
    '4','5','6','7','8','9','0','-','=','\\','~','!','@','#','$','%','^','&',
    '*','(',')','_','+','|','[',']',';','\'',',','.','/','{','}',':','"','<',
    '>','?'
};

unsigned char code lcd_ascii_txt[][6]=
{   {0x00,0x00,0x00,0x00,0x00,0x00},    //* SPACE */
    {0x00,0x7e,0x21,0x21,0x21,0x7e},    //* A */
    {0x00,0x7f,0x49,0x49,0x49,0x36},    //* B */
    {0x00,0x3e,0x41,0x41,0x41,0x22},    //* C */
    {0x00,0x7f,0x41,0x41,0x22,0x1c},    //* D */
    {0x00,0x7f,0x49,0x49,0x49,0x49},    //* E */
    {0x00,0x7f,0x09,0x09,0x09,0x01},    //* F */
    {0x00,0x3e,0x41,0x49,0x49,0x7a},    //* G */
    {0x00,0x7f,0x08,0x08,0x08,0x7f},    //* H */
    {0x00,0x41,0x7f,0x41,0x00,0x00},    //* I */
    {0x00,0x20,0x40,0x41,0x3f,0x01},    //* J */
    {0x00,0x7f,0x08,0x14,0x22,0x41},    //* K */
    {0x00,0x7f,0x40,0x40,0x40,0x40},    //* L */
    {0x00,0x7f,0x02,0x0c,0x02,0x7f},    //* M */
    {0x00,0x7f,0x04,0x08,0x10,0x7f},    //* N */
    {0x00,0x3e,0x41,0x41,0x41,0x3e},    //* O */
    {0x00,0x7f,0x09,0x09,0x09,0x06},    //* P */
    {0x00,0x3e,0x41,0x41,0x41,0x3e},    //* Q */
    {0x00,0x7f,0x09,0x19,0x29,0x46},    //* R */
    {0x00,0x46,0x49,0x49,0x49,0x31},    //* S */
    {0x00,0x01,0x01,0x7f,0x01,0x01},    //* T */
    {0x00,0x3f,0x40,0x40,0x40,0x3f},    //* U */
    {0x00,0x1f,0x20,0x40,0x20,0x1f},    //* V */
    {0x00,0x3f,0x40,0x38,0x40,0x3f},    //* W */
    {0x00,0x63,0x14,0x08,0x14,0x63},    //* X */
    {0x00,0x07,0x08,0x70,0x08,0x07},    //* Y */
    {0x00,0x61,0x51,0x49,0x45,0x43},    //* Z */
    {0x00,0x20,0x54,0x54,0x54,0x7c},    //* a */
    {0x00,0x7f,0x48,0x44,0x44,0x38},    //* b */
    {0x00,0x38,0x44,0x44,0x44,0x20},    //* c */
    {0x00,0x38,0x44,0x44,0x48,0x7f},    //* d */
    {0x00,0x38,0x54,0x54,0x54,0x18},    //* e */
    {0x00,0x08,0x7e,0x09,0x01,0x02},    //* f */
    {0x00,0x0c,0x52,0x52,0x52,0x3e},    //* g */
    {0x00,0x7f,0x08,0x04,0x04,0x78},    //* h */
    {0x00,0x00,0x44,0x7d,0x40,0x00},    //* i */
    {0x00,0x40,0x40,0x44,0x3d,0x00},    //* j */
    {0x00,0x7f,0x10,0x28,0x44,0x00},    //* k */
    {0x00,0x00,0x41,0x7e,0x40,0x00},    //* l */
    {0x00,0x7c,0x04,0x18,0x04,0x78},    //* m */
    {0x00,0x7c,0x08,0x04,0x04,0x78},    //* n */
    {0x00,0x38,0x44,0x44,0x44,0x38},    //* o */
    {0x00,0x7c,0x14,0x14,0x14,0x08},    //* p */
    {0x00,0x08,0x14,0x14,0x14,0x7c},    //* q */
    {0x00,0x7c,0x08,0x04,0x04,0x08},    //* r */
    {0x00,0x48,0x54,0x54,0x54,0x20},    //* s */
    {0x00,0x04,0x3f,0x44,0x44,0x24},    //* t */
    {0x00,0x3c,0x40,0x40,0x20,0x7e},    //* u */
    {0x00,0x1d,0x20,0x40,0x20,0x1c},    //* v */
    {0x00,0x3c,0x40,0x30,0x40,0x3c},    //* w */
    {0x00,0x44,0x28,0x10,0x28,0x44},    //* x */
    {0x00,0x06,0x48,0x48,0x48,0x3e},    //* y */
    {0x00,0x44,0x64,0x54,0x4c,0x44},    //* z */
    {0x00,0x00,0x01,0x02,0x04,0x00},    //* ` */
    {0x00,0x00,0x42,0x7f,0x40,0x40},    //* 1 */
    {0x00,0x62,0x51,0x51,0x49,0x46},    //* 2 */
    {0x00,0x21,0x41,0x45,0x4b,0x31},    //* 3 */
    {0x00,0x18,0x14,0x12,0x7f,0x10},    //* 4 */
    {0x00,0x27,0x45,0x45,0x45,0x39},    //* 5 */
    {0x00,0x3c,0x4a,0x49,0x49,0x30},    //* 6 */
    {0x00,0x01,0x71,0x09,0x05,0x03},    //* 7 */
    {0x00,0x36,0x49,0x49,0x49,0x36},    //* 8 */
    {0x00,0x06,0x49,0x49,0x29,0x1e},    //* 9 */
    {0x00,0x3e,0x51,0x49,0x45,0x3e},    //* 0 */
    {0x00,0x08,0x08,0x08,0x08,0x08},    //* - */
    {0x00,0x14,0x14,0x14,0x14,0x14},    //* = */
    {0x00,0x01,0x02,0x08,0x10,0x20},    //* \ */
    {0x00,0x04,0x08,0x04,0x08,0x04},    //* ~ */
    {0x00,0x00,0x00,0x4f,0x00,0x00},    //* ! */
    {0x00,0x3e,0x59,0x55,0x79,0x3e},    //* @ */
    {0x00,0x14,0x7f,0x14,0x7f,0x14},    //* # */
    {0x00,0x24,0x2a,0x7f,0x2a,0x12},    //* $ */
    {0x00,0x23,0x13,0x08,0x62,0x61},    //* % */
    {0x00,0x04,0x02,0x01,0x02,0x04},    //* ^ */
    {0x00,0x36,0x49,0x55,0x22,0x50},    //* & */
    {0x00,0x14,0x08,0x3e,0x08,0x14},    //* * */
    {0x00,0x00,0x1c,0x22,0x41,0x00},    //* ( */
    {0x00,0x00,0x41,0x22,0x1c,0x00},    //* ) */
    {0x00,0x40,0x40,0x40,0x40,0x40},    //* _ */
    {0x00,0x08,0x08,0x3e,0x08,0x08},    //* + */
    {0x00,0x00,0x00,0x7e,0x00,0x00},    //* | */
    {0x00,0x00,0x7f,0x41,0x41,0x00},    //* [ */
    {0x00,0x00,0x41,0x41,0x7f,0x00},    //* ] */
    {0x00,0x00,0x56,0x36,0x00,0x00},    //* ; */
    {0x00,0x00,0x00,0x05,0x03,0x00},    //* ' */
    {0x00,0x00,0x00,0x28,0x18,0x00},    //* , */
    {0x00,0x00,0x00,0x60,0x60,0x00},    //* . */
    {0x00,0x20,0x10,0x08,0x04,0x02},    //* //*/
    {0x00,0x00,0x08,0x36,0x41,0x00},    //* { */
    {0x00,0x00,0x41,0x36,0x08,0x00},    //* } */
    {0x00,0x00,0x36,0x36,0x00,0x00},    //* : */
    {0x00,0x00,0x00,0x07,0x00,0x07},    //* " */
    {0x00,0x08,0x14,0x22,0x41,0x00},    //* < */
    {0x00,0x00,0x41,0x22,0x14,0x08},    //* > */
    {0x00,0x02,0x01,0x51,0x09,0x06}     //* ? */
};

/********************************************************************************/
/* function : LCDP_delay()                                                      */
/* recension: xillinx                                                           */
/* descript : LCDP的延时函数,根据CPU的时钟调整                                  */
/********************************************************************************/
void LCDP_delay(void)
{   _nop_();
    _nop_();
    _nop_();
    _nop_();
    _nop_();
    _nop_();
    _nop_();
    _nop_();
    _nop_();
    _nop_();
    _nop_();
    _nop_();
    _nop_();
    _nop_();
    _nop_();
    _nop_();
    _nop_();
    _nop_();
    _nop_();
    _nop_();
    _nop_();
    _nop_();
    _nop_();
    _nop_();
}

/********************************************************************************/
/* function : LCDP_sdelay()                                                     */
/* recension: xillinx                                                           */
/* descript : LCDP的延时函数,根据CPU的时钟调整                                  */
/********************************************************************************/
void LCDP_sdelay(void)
{   _nop_();
    _nop_();
    _nop_();
    _nop_();
}

/********************************************************************************/
/* fun_name : LCDP_write_wait_status()                                          */
/* version  : v1.00                                                             */
/* created  : xillinx                                                           */
/* descript : write a command to chip 1 and chip 2 of LCD module                */
/********************************************************************************/
void LCDP_write_wait_status(unsigned char chip)
{   if( chip==0x00)
    {   while(LCDP_rd_chip_1_cmd&0x80)
        {   LCDP_sdelay();
        }
    }
    else
    {   while(LCDP_rd_chip_2_cmd&0x80)
        {   LCDP_sdelay();
        }
    }
}
/********************************************************************************/
/* fun_name : LCDP_write_command()                                              */
/* version  : v1.00                                                             */
/* created  : xillinx                                                           */
/* descript : write a command to chip 1 and chip 2 of LCD module                */
/********************************************************************************/
void LCDP_write_command(unsigned char command)
{   LCDP_write_wait_status(0x00);
    LCDP_sdelay();
    LCDP_wr_chip_1_cmd=command;
    LCDP_sdelay();
    LCDP_write_wait_status(0x01);
    LCDP_sdelay();
    LCDP_wr_chip_2_cmd=command;
    LCDP_sdelay();
}

/********************************************************************************/
/* fun_name : LCDP_write_ram_data()                                             */
/* version  : v1.00                                                             */
/* created  : xillinx                                                           */
/* descript : write a data to chip x 's RAM                                     */
/********************************************************************************/
void LCDP_write_ram_data(unsigned char chip,unsigned char value)
{   if( chip==0x0)
    {   LCDP_write_wait_status(0x00);
        LCDP_sdelay();
        LCDP_wr_chip_1_data=value;
        LCDP_sdelay();
    }
    else
    {   LCDP_write_wait_status(0x01);
        LCDP_sdelay();
        LCDP_wr_chip_2_data=value;
        LCDP_sdelay();
    }
}

/********************************************************************************/
/* fun_name : LCDP_write_one_byte()                                             */
/* version  : v1.00                                                             */
/* created  : xillinx                                                           */
/* descript : write a one byte to chip 1 and chip 2 of LCD module               */
/********************************************************************************/
#if 0
void LCDP_write_one_byte(unsigned char page,unsigned char column,unsigned char value)
{   LCDP_set_page(page&0x03);
    LCDP_set_column(column);
    LCDP_write_ram_data(page>3,value);

}
#endif

/********************************************************************************/
/* fun_name : LCDP_write_one_page()                                             */
/* version  : v1.00                                                             */
/* created  : xillinx                                                           */
/* descript : write a one page data                                             */
/********************************************************************************/
#if 0
void LCDP_write_one_page(unsigned char page, unsigned char * buffer)
{   unsigned char i;
    unsigned char chip=0x0;
    LCDP_set_page(page&0x3);
    LCDP_set_column(0x0);
    if( page>0x3)
    {   chip=0x1;
    }
    for(i=0x0;i<61;i++)
    {   LCDP_write_ram_data(chip,buffer[i]);
    }
}
#endif
/********************************************************************************/
/* fun_name : LCDP_display_text()                                               */
/* version  : v1.00                                                             */
/* created  : xillinx                                                           */
/* descript : LCD dispaly operate                                               */
/********************************************************************************/
void LCDP_display_text(unsigned char xpos,unsigned char ypos,unsigned char * buffer)
{   unsigned char chip;
    unsigned char i;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?