#include "systerm.h"
// ------------------ 汉字字模的数据结构定义 ------------------------ //
typedef struct typFNT_GB16 // 汉字字模数据结构
{
signed char Index[2]; // 汉字内码索引
char Msk[32]; // 点阵码数据
};
// ------------------ 汉字字模的数据结构定义 ------------------------ //
typedef struct typFNT_GB12 // 汉字字模数据结构
{
signed char Index[2]; // 汉字内码索引
char Msk[24]; // 点阵码数据
};
/////////////////////////////////////////////////////////////////////////
// 汉字字模表 //
// 汉字库: 宋体16.dot 纵向取模下高位,数据排列:从左到右从上到下 //
/////////////////////////////////////////////////////////////////////////
struct typFNT_GB16 code GB_16[] = // 数据表
{
"我", 0x20,0x24,0x24,0x24,0xFE,0x23,0x22,0x20,0xFF,0x20,0x22,0xAC,0x20,0x30,0x20,0x00,
0x00,0x08,0x48,0x84,0x7F,0x02,0x21,0x10,0x09,0x06,0x1A,0x61,0x80,0xE0,0x00,0x00,
"心", 0x00,0x00,0xC0,0x00,0xF0,0x00,0x01,0x02,0x1C,0x08,0x00,0x00,0x40,0x80,0x00,0x00,
0x04,0x02,0x01,0x00,0x3F,0x40,0x40,0x40,0x40,0x40,0x40,0x70,0x00,0x00,0x07,0x00,
"永", 0x00,0x40,0x40,0x48,0x48,0xC8,0x09,0xFA,0x40,0x80,0x40,0x20,0x30,0x00,0x00,0x00,
0x00,0x20,0x10,0x08,0x06,0x41,0x80,0x7F,0x00,0x01,0x06,0x08,0x10,0x30,0x10,0x00,
"恒", 0x80,0x70,0x00,0xFF,0x10,0x22,0xF2,0x92,0x92,0x92,0x92,0x92,0xFB,0x12,0x00,0x00,
0x00,0x00,0x00,0xFF,0x20,0x20,0x27,0x24,0x24,0x24,0x24,0x24,0x27,0x30,0x20,0x00,
"之", 0x00,0x10,0x10,0x10,0x10,0x10,0x11,0x16,0x10,0x90,0x50,0x30,0x10,0x00,0x00,0x00,
0x00,0x20,0x10,0x10,0x28,0x48,0x44,0x42,0x41,0x40,0x40,0x40,0x40,0x60,0x20,0x00,
"★", 0x00,0x20,0x60,0xE0,0xE0,0xE0,0xF0,0xFC,0xFF,0xFC,0xF0,0xE0,0xE0,0xE0,0x60,0x20,
0x00,0x00,0x40,0x30,0x3D,0x1F,0x1F,0x0F,0x07,0x0F,0x1F,0x1F,0x3D,0x30,0x40,0x00
};
// 汉字表:
// 我心永恒★
/////////////////////////////////////////////////////////////////////////
// 汉字字模表 //
// 汉字库: 宋体12.dot 纵向取模下高位,数据排列:从左到右从上到下 //
/////////////////////////////////////////////////////////////////////////
struct typFNT_GB12 code GB_12[] = // 数据表
{
"哈", 0xFC,0x84,0x84,0xFC,0x10,0xA8,0xA4,0xA3,
0xA4,0xA8,0xB0,0x10,0x01,0x00,0x00,0x00,
0x00,0x0F,0x04,0x04,0x04,0x04,0x0F,0x00,
"当", 0x00,0x20,0xA4,0xA8,0xA0,0xBF,0xA0,0xB0,
0xA8,0xA6,0xF0,0x20,0x00,0x04,0x04,0x04,
0x04,0x04,0x04,0x04,0x04,0x04,0x0F,0x00,
"前", 0x04,0xF4,0x54,0x55,0x56,0xF4,0x04,0xF6,
0x05,0x04,0xF6,0x04,0x00,0x0F,0x01,0x01,
0x09,0x0F,0x00,0x03,0x04,0x08,0x07,0x00,
"电", 0x00,0xFC,0x24,0x24,0x24,0xFF,0x24,0x24,
0x24,0xFE,0x04,0x00,0x00,0x01,0x01,0x01,
0x01,0x07,0x09,0x09,0x09,0x09,0x08,0x0E,
"量", 0x08,0x08,0xEF,0xA9,0xA9,0xEB,0xAD,0xA9,
0xA9,0xEF,0x08,0x08,0x08,0x08,0x0B,0x0A,
0x0A,0x0F,0x0A,0x0A,0x0A,0x0B,0x08,0x08,
"时", 0xFC,0x24,0x24,0x24,0xFC,0x08,0x28,0xC8,
0x08,0xFF,0x08,0x08,0x03,0x01,0x01,0x01,
0x03,0x00,0x00,0x04,0x08,0x0F,0x00,0x00,
"间", 0x00,0xFC,0x01,0x02,0xF8,0x2A,0x2A,0xFA,
0x02,0x02,0xFF,0x02,0x00,0x0F,0x00,0x00,
0x03,0x01,0x01,0x01,0x04,0x08,0x0F,0x00,
"闹", 0x00,0xFC,0x01,0xEA,0x28,0xFE,0x2A,0x2A,
0xEA,0x02,0xFF,0x02,0x00,0x0F,0x00,0x03,
0x00,0x07,0x00,0x02,0x03,0x08,0x0F,0x00,
"钟", 0x50,0x5C,0xF7,0x54,0x54,0xF8,0x48,0x48,
0xFF,0x48,0x48,0xF8,0x00,0x00,0x0F,0x04,
0x02,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,
"状", 0x04,0x98,0x40,0xFF,0x10,0x10,0x10,0xFF,
0x90,0x12,0x14,0x10,0x01,0x00,0x00,0x0F,
0x08,0x04,0x03,0x00,0x00,0x03,0x04,0x08,
"态", 0x04,0x44,0x44,0x24,0x1C,0xA7,0x4C,0x14,
0x24,0x44,0x46,0x44,0x04,0x03,0x00,0x07,
0x08,0x08,0x0B,0x08,0x08,0x0C,0x01,0x06,
"确", 0x42,0xF2,0x2E,0xE2,0x12,0xF8,0xAC,0xAB,
0xFA,0xAE,0xAA,0xF8,0x00,0x07,0x02,0x07,
0x08,0x07,0x00,0x00,0x0F,0x04,0x08,0x07,
"认", 0x10,0x11,0xF2,0x04,0x80,0x00,0xC0,0x3F,
0xC0,0x00,0x00,0x00,0x00,0x00,0x0B,0x09,
0x04,0x02,0x01,0x00,0x01,0x02,0x04,0x08,
"返", 0x20,0x21,0xE6,0x00,0x80,0x7E,0x2A,0x4A,
0x89,0x69,0x19,0x00,0x08,0x04,0x03,0x05,
0x08,0x0A,0x0A,0x09,0x08,0x09,0x0A,0x08,
"回", 0x00,0xFE,0x02,0x02,0xFA,0x8A,0x8A,0xFA,
0x02,0x02,0xFF,0x02,0x00,0x0F,0x04,0x04,
0x04,0x04,0x04,0x04,0x04,0x04,0x0F,0x00
};
// 汉字表:
// 哈当前电量时间闹钟状态确认返回
/*--------------------------------------------------------------*/
//12*12汉字显示缓冲区
//为了节省52可怜的RAM,使用软件实现显示
//占用RAM:168字节(呵呵,51就不能用咯,52可以)
//如果你的RAM够大的话,建议直接用504字节的RAM,方便多咯
unsigned char idata HZ_buffer[2][84];
/*--------------------------------------------------------------*/
//写入一个字节(数据或指令)
//wbyte: 待写入的数据
//dat_cmd: 1-数据, 0-指令
void LCD_write_byte(unsigned char wbyte, unsigned char dat_cmd)
{
unsigned char i;
LCD_CS = 0; //使能
LCD_DC = dat_cmd; //1-数据 //0-指令
for(i = 8; i; i--) //8位数据, 先高后低
{
if(wbyte & 0x80) {LCD_DIN = 1;}
else {LCD_DIN = 0;}
LCD_CLK = 0;
wbyte <<= 1; //移位(延时)
LCD_CLK = 1; //上升沿写入
}
LCD_CS = 1; //禁止
}
/*--------------------------------------------------------------*/
//写入n个字节(数据)(ROM)
//*wbyte: 待写入的数据指针
//num: 待写入的数据个数
/*void LCD_write_nbyte(unsigned char code *wbyte, unsigned char num)
{
unsigned char i, j;
unsigned char temp;
LCD_CS = 0; //使能
LCD_DC = 1; //数据
for(j = 0; j < num; j++)//num个数据
{
temp = wbyte[j];
for(i = 8; i; i--) //8位数据, 先高后低
{
if(temp & 0x80) {LCD_DIN = 1;}
else {LCD_DIN = 0;}
LCD_CLK = 0;
temp <<= 1; //移位(延时)
LCD_CLK = 1; //上升沿写入
}
}
LCD_CS = 1; //禁止
}
/*--------------------------------------------------------------*/
//显示清屏(清DDRAM)
void LCD_clr_scr(void)
{
unsigned int i;
LCD_write_cmd(X_Col_Addr);
LCD_write_cmd(Y_Page_Addr);
for(i = 504; i; i--) LCD_write_dat(0x00);
CLR_buffer(); //清缓冲区
}
/*--------------------------------------------------------------*/
//显示清行
//num: 0 - 5
void LCD_clr_row(unsigned char num)
{
unsigned char i;
LCD_pos_byte(0, num);
for(i = 84; i; i--) LCD_write_dat(0x00);
}
/*--------------------------------------------------------------*/
//液晶字节定位(1*1)
//液晶规划:
//x: 0 - 83
//y: 0 - 5
void LCD_pos_byte(unsigned char x, unsigned char y)
{
x |= X_Col_Addr;
y |= Y_Page_Addr;
LCD_write_cmd(x); //列地址
LCD_write_cmd(y); //页地址
}
/*--------------------------------------------------------------*/
//液晶字符输出(6*8字体)
//x: 0 - 13
//y: 0 - 5
void LCD_printc(unsigned char x, unsigned char y, unsigned char c_dat)
{
unsigned char i;
c_dat -= 32; //查表
x *= 6; //宽6
LCD_pos_byte(x, y); //坐标
for(i = 0; i < 6; i++) LCD_write_dat(Font_code[c_dat][i]);
}
/*--------------------------------------------------------------*/
//液晶字符串输出(6*8字体)
//x: 0 - 13
//y: 0 - 5
void LCD_prints(unsigned char x, unsigned char y, unsigned char *s_dat)
{
LCD_clr_row(y);
while(*s_dat && x < 14) {LCD_printc(x++, y, *s_dat); s_dat++;}
}
/*--------------------------------------------------------------*/
//液晶字符串输出,自动换行(6*8字体)
//x: 0 - 13
//y: 0 - 5
void LCD_printsl(unsigned char x, unsigned char y, unsigned char *s_dat)
{
while(*s_dat)
{
LCD_printc(x++, y, *s_dat);
s_dat++;
if(x == 14) {x = 0; y++;}
if(y == 6) {y = 0;}
}
}
/*--------------------------------------------------------------*/
//液晶汉字输出(16*16字体)
//取码规则: 低位在前, 列行扫描, 阴码(1-亮, 0-灭)
//x: 0 - 4
//y: 0 - 2
void LCD_printch(unsigned char x