/*************************************************************/
/* this programme for LCD of GMG12864-59D with ST7567 */
/* Company: New Future */
/* Programmer: windy */
/* phone: 13891912727 weixin same name */
/* Email: cjfwindy@163.com */
/* Time: 2021-07-28 10:03 */
/* Copyright(C) 2021 New Future All rights reserved */
/*************************************************************/
#include "global.h"
//#include "pic.h"
//#include "pic1.h"
//=================================================================================
struct DisCharacter
{
char Character;
BYTE DisCode;
};
const struct DisCharacter DisLib[10] =
{
{'0',0xF5},
{'1',0x05},
{'2',0xD3},
{'3',0x97},
{'4',0x27},
{'5',0xB6},
{'6',0xF6},
{'7',0x15},
{'8',0xF7},
{'9',0xB7},
};
TYPE_BYTE_IO _RAMLCD;
TYPE_BYTE_IO _RAMLCD2;
TYPE_BYTE_IO _RAMLCD3;
BYTE StartData,EndData;
BYTE DisplayData[15];
char* p;
BYTE ADr;
ulong fontaddr=0;
uchar bmp1[];
const uchar jiong1[]={//-- 文字: 囧 --
//-- 宋体12; 此字体下对应的点阵为:宽x 高=16x16 --
0x00,0xFE,0x82,0x42,0xA2,0x9E,0x8A,0x82,0x86,0x8A,0xB2,0x62,0x02,0xFE,0x00,0x00,
0x00,0x7F,0x40,0x40,0x7F,0x40,0x40,0x40,0x40,0x40,0x7F,0x40,0x40,0x7F,0x00,0x00};
const uchar lei1[]={//-- 文字: 畾 --
//-- 宋体12; 此字体下对应的点阵为:宽x 高=16x16 --
0x80,0x80,0x80,0xBF,0xA5,0xA5,0xA5,0x3F,0xA5,0xA5,0xA5,0xBF,0x80,0x80,0x80,0x00,
0x7F,0x24,0x24,0x3F,0x24,0x24,0x7F,0x00,0x7F,0x24,0x24,0x3F,0x24,0x24,0x7F,0x00};
//=================================================================================
// LCD 模块初始化
void Init_LCD(void)
{
lcd_reset=0; // 低电平复位
delay(100);
lcd_reset=1; // 复位完毕
delay(100);
transfer_command_lcd(0xe2); // 软复位
delay(5);
transfer_command_lcd(0x2c); // 升压步聚1
delay(50);
transfer_command_lcd(0x2e); // 升压步聚2
delay(50);
transfer_command_lcd(0x2f); // 升压步聚3
delay(5);
transfer_command_lcd(0x26); // 粗调对比度,可设置范围0x20~0x27
transfer_command_lcd(0x81); // 微调对比度
transfer_command_lcd(0x18); // 微调对比度的值,可设置范围0x00~0x3f
transfer_command_lcd(0xa2); // 1/9 偏压比(bias)
transfer_command_lcd(0xa1); // reverse direction
//transfer_command_lcd(0xc0); // 行扫描顺序:从上到下
transfer_command_lcd(0xc8); // 行扫描顺序:从下到上
transfer_command_lcd(0xa6); // 列扫描顺序:从左到右
transfer_command_lcd(0x40); // 起始行:第一行开始
//transfer_command_lcd(0xaf); // 开显示
clear_screen();
}
//-----------------------------------------------------------------
//全屏清屏
void clear_screen()
{
unsigned char i,j;
for(i=0;i<9;i++)
{
transfer_command_lcd(0xb0+i);
transfer_command_lcd(0x10);
transfer_command_lcd(0x00);
for(j=0;j<132;j++)
{
transfer_data_lcd(0x00);
}
}
}
//-----------------------------------------------------------------
void DisplayTest()
{
while(1)
{
Init_LCD();
clear_screen(); // clear all dots
//Display_Logo();
display_128x64(bmp1);
delay(2000);
display_GB2312_string(1,1,"12864,带中文字库"); // 在第1 页,第1 列,显示一串16x16 点阵汉字或8x16 的ASCII 字
display_GB2312_string(3,1,"16X16 简体汉字库,"); // 显示一串16x16 点阵汉字或8x16 的ASCII 字.以下雷同
display_GB2312_string(5,1,"或8X16 点阵ASCII,");
display_GB2312_string(7,1,"或5x8 点阵ASCII 码");
delay(3000);
clear_screen();
display_GB2312_string(1,1,"深圳市金逸晨电子");
display_GB2312_string(3,1," 欢 迎 您 ");
display_GB2312_string(5,1,"专业生产LCD模块 ");
display_GB2312_string(7,1,"优质服务品质保证");
delay(3000);
display_GB2312_string(1,1,"GB2312 简体字库及");
display_GB2312_string(3,1,"有图型功能,可自");
display_GB2312_string(5,1,"编大字、图像、生");
display_GB2312_string(7,1,"僻字等,例如: ");
display_graphic_16x16(7,97,jiong1); // 在第7页,第81列显示单个自编生僻汉字“囧”
display_graphic_16x16(7,113,lei1); // 显示单个自编生僻汉字"畾“
delay(3000);
clear_screen();
display_GB2312_string(1,1,"<!@#$%^&*()_-+]/"); // 在第1 页,第1 列,显示一串16x16 点阵汉字或8*16 的ASCII 字
display_string_5x8(3,1,"<!@#$%^&*()_-+]/;.,?["); // 在第3 页,第1 列,显示一串5x8 点阵的ASCII 字
display_string_5x8(4,1,"GM electronics Co.,"); // 显示一串5x8 点阵的ASCII 字
display_string_5x8(5,1,"Ltd.www.goldenmorning"); // 显示一串5x8 点阵的ASCII 字
display_string_5x8(6,1,"ss.com. China ShenZhen "); // 显示一串5x8 点阵的ASCII 字
display_string_5x8(7,1,"TEL:0755-29450035 "); // 显示一串5x8 点阵的ASCII 字
display_string_5x8(8,1,"FAX:0755-29450036 "); // 显示一串5x8 点阵的ASCII 字
delay(3000);
display_GB2312_string(1,1,"啊阿埃挨哎唉哀皑"); // 在第1 页,第1 列,显示一串16x16 点阵汉字或8x16 的ASCII 字
display_GB2312_string(3,1,"癌蔼矮艾碍爱隘鞍"); // 显示一串16x16 点阵汉字或8x16 的ASCII 字.以下雷同
display_GB2312_string(5,1,"氨安俺按暗岸胺案");
display_GB2312_string(7,1,"肮昂盎凹敖熬翱袄");
delay(3000);
display_GB2312_string(1,1,"鬟鬣麽麾縻麂麇麈");
display_GB2312_string(3,1,"麋麒鏖麝麟黛黜黝");
display_GB2312_string(5,1,"黠黟黢黩黧黥黪黯");
display_GB2312_string(7,1,"鼢鼬鼯鼹鼷鼽鼾齄");
delay(3000);
}
}
//=================================================================================
// Address 地址从0开始
void MyPrint(char DisplayChar[],BYTE Address)
{
p = DisplayChar;
ADr = Address;
}
//-----------------------------------------------------------------
//=================================================================================
void display_GB2312_string(uchar page,uchar column,uchar *text)
{
uchar i= 0;
while((text[i]>0x00))
{
if(((text[i]>=0xb0) &&(text[i]<=0xf7))&&(text[i+1]>=0xa1))
{
// 国标简体(GB2312)汉字在字库IC 中的地址由以下公式来计算:
// Address = ((MSB - 0xB0) * 94 + (LSB - 0xA1)+ 846)*32+ BaseAdd;BaseAdd=0
// 由于担心8 位单片机有乘法溢出问题,所以分三部取地址
fontaddr = (text[i]- 0xb0)*94;
fontaddr += (text[i+1]-0xa1)+846;
fontaddr = (ulong)(fontaddr*32);
get_and_write_16x16(fontaddr,page,column); // 从指定地址读出数据写到液晶屏指定(page,column)座标中
i+=2;
column+=16;
}
else if(((text[i]>=0xa1) &&(text[i]<=0xa3))&&(text[i+1]>=0xa1))
{
// 国标简体(GB2312)15x16 点的字符在字库IC 中的地址由以下公式来计算:
// Address = ((MSB - 0xa1) * 94 + (LSB - 0xA1))*32+ BaseAdd;BaseAdd=0
// 由于担心8 位单片机有乘法溢出问题,所以分三部取地址
fontaddr = (text[i]- 0xa1)*94;
fontaddr += (text[i+1]-0xa1);
fontaddr = (ulong)(fontaddr*32);
get_and_write_16x16(fontaddr,page,column); // 从指定地址读出数据写到液晶屏指定(page,column)座标中
i+=2;
column+=16;
}
else if((text[i]>=0x20) &&(text[i]<=0x7e))
{
fontaddr = (text[i]- 0x20);
fontaddr = (unsigned long)(fontaddr*16);
fontaddr = (unsigned long)(fontaddr+0x3cf80);
get_and_write_8x16(fontaddr,page,column); // 从指定地址读出数据写到液晶屏指定(page,column)座标中
i+=1;
column+=8;
}
else
i++;
}
}
//-----------------------------------------------------------------
void display_string_5x8(uchar page,uchar column,uchar *text)
{
unsigned char i= 0;
while((text[i]>0x00))
{
if((text[i]>=0x20) &&(text[i]<=0x7e))
{
fontaddr = (text[i]- 0x20);
fontaddr = (unsigned long)(fontaddr*8);
fontaddr = (unsigned long)(fontaddr+0x3bfc0);
get_and_write_5x8(fontaddr,page,column); //从指定地址读出数据写到液晶屏指定(page,column)座标中
i+=1;
column+=6;
}
else
i++;
}
}
//=================================================================================
//显示128x64 点阵图像
void display_128x64(uchar *dp)
{
uint i,j;
for(j=0;j<8;j++)
{
lcd_address(j+1,1);
for (i=0;i<128;i++)
{