12864字库屏51移植-Arduino中文社区 - Powered by Discuz!

Arduino中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 4083|回复: 2

12864字库屏51移植

[复制链接]
发表于 2020-4-11 15:59 | 显示全部楼层 |阅读模式
手里有个晶联讯的JLX12864G-086-PC字库屏,Arduino没有现成能用的库。闲的没事直接把厂家的51例程移植过来,能正常显示汉字库。
迅读PDF截图20200411150720.png
IMG_20200411_150443.jpg
程序在下面
//液晶屏型号:JLX12864G-086-PC-3S
//接口:串行
//中文字库:带中文字库 IC:JLX-GB2312,竖置横排
//驱动 IC:UC1701X(与 ST7565R 兼容)
//单片机:UNO R3
//IDE版本:1.8.12

#define lcd_cs1   13 //接口定义:lcd_cs1 就是 LCD 的 CS1
#define lcd_reset 12 //接口定义:lcd_reset 就是 LCD 的 RESET
#define lcd_rs    11 //接口定义:lcd_rs 就是 LCD 的 RS,也叫“CD”
#define lcd_sid   10 //接口定义:lcd_sid 就是 LCD 的 SDA
#define lcd_sclk   9 //接口定义:lcd_sclk 就是 LCD 的 SCLK
//VDD    +5V
//VSS    GND
//LEDA   +5V
#define Rom_CS   8 //字库 IC 接口定义 Rom_CS 就是字库 IC 的 CS#
#define Rom_SCK  7 //字库 IC 接口定义:Rom_SCK 就是字库 IC 的 SCK
#define Rom_OUT  6 //字库 IC 接口定义:Rom_OUT 就是字库 IC 的 SO
#define Rom_IN   5 //字库 IC 接口定义:Rom_IN 就是字库 IC 的 SI

#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long

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};
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};
const uchar bmp1[] PROGMEM ={
//-- 调入了一幅图像:D:\我的文档\My Pictures\12864-555.bmp --
//-- 宽度 x 高度=128x64 --
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xE0,0x60,0xE0,0xE0,0xE0,0xE0,0x60,
0x60,0x60,0x60,0x60,0x60,0x60,0xE0,0xE0,0xE0,0xE0,0xC0,0xC0,0xC0,0xC0,0x80,0x80,
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,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,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,0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0x70,0x38,0x18,0x1C,0x0C,
0x0E,0x07,0x03,0x03,0x01,0x81,0xE0,0x78,0x1C,0x0E,0x07,0x03,0x01,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0E,0x1C,0x79,0xE1,0x83,
0x03,0x07,0x0E,0x0C,0x1C,0x18,0x38,0x70,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0xC0,0xC0,
0xC0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,
0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,
0xE0,0xE0,0xE0,0xC0,0xC0,0xC0,0xC0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x80,0xF0,0x78,0x1E,0x07,0x03,0x81,0x80,0xC0,0xC0,0xC0,0xE0,0x60,
0x60,0x60,0x70,0xF0,0xFE,0x3F,0x19,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x38,0x31,0x3F,
0xFE,0xF0,0x60,0x60,0xE0,0xC0,0xC0,0xC0,0x80,0x81,0x03,0x07,0x1E,0x78,0xF0,0x80,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xFC,0xFF,0x7F,0x07,0x0F,0x1F,0x3D,
0x79,0x71,0xF0,0xE0,0xC0,0x80,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,0x80,
0x80,0xC0,0xE0,0xF0,0x71,0x79,0x3D,0x1F,0x0F,0xFF,0xFE,0xFC,0x00,0x00,0x00,0x00,
0x00,0x80,0xFE,0xFF,0xF9,0x1C,0x0E,0x07,0x03,0x03,0x01,0x01,0x00,0x00,0x00,0x00,
0x00,0x00,0xFF,0xFF,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,
0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x01,0x01,0x03,0x03,0x07,0x0E,0x1C,0xF9,0xFF,
0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0x03,0x07,0x0F,0x0E,0x9E,0xFC,0xF8,0xF0,0xE0,0xC0,0xC0,0x80,
0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xC0,0xE0,0xF0,0xF8,0xF8,0xFC,0x9E,0x0F,0x07,
0x03,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,
0x00,0x00,0x3F,0xFF,0xDF,0x38,0x70,0xE0,0xC0,0xC0,0x80,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0xFF,0xFF,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,
0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0xC0,0xE0,0x70,0x38,0xDF,0xFF,
0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,
0x80,0xC0,0xE0,0xF0,0x78,0x3C,0x1E,0x0F,0x07,0x03,0x01,0x00,0x01,0x01,0x03,0x07,
0x0F,0x1E,0x1E,0x0E,0x0F,0x07,0x03,0x01,0x01,0x00,0x01,0x01,0x03,0x07,0x0F,0x1E,
0x3C,0x78,0xF0,0xE0,0xC0,0x80,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x07,0x0F,0x3C,0x70,0xE0,0xC1,0x81,0x03,0x03,0x03,0x07,0x06,
0x06,0x06,0x0E,0x0F,0x7F,0xFC,0x98,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x0C,0x8C,0xFC,
0x7F,0x0F,0x06,0x06,0x07,0x03,0x03,0x03,0x81,0xC1,0xE0,0x70,0x3C,0x0F,0x07,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x1F,0x3F,0x7C,0xFC,0xFE,0xEF,
0xE7,0xE3,0xE1,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,
0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,
0xE0,0xE0,0xE0,0xE1,0xE3,0xE7,0xEF,0xFE,0x7C,0x3F,0x1F,0x0F,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0E,0x0C,0x1C,0x18,
0x38,0x70,0x60,0xE0,0xC0,0xC1,0x87,0x9E,0xB8,0xF0,0xE0,0xC0,0x80,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0xF0,0xB8,0xDE,0xC7,0xE1,
0x60,0x70,0x38,0x18,0x1C,0x0C,0x0E,0x07,0x03,0x01,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,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,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,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x03,0x03,0x03,0x03,0x03,0x07,0x07,
0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x03,0x03,0x03,0x01,0x01,0x01,0x01,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,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,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,
};
unsigned char name0[] = {0x47,0x42,0x32,0x33,0x31,0x32,0xBC,0xF2,0xCC,0xE5,0xD7,0xD6,0xBF,0xE2,0xBC,0xB0};
unsigned char name1[] = {0xD3,0xD0,0xCD,0xBC,0xD0,0xCD,0xB9,0xA6,0xC4,0xDC,0xA3,0xAC,0xBF,0xC9,0xD7,0xD4};
unsigned char name2[] = {0xB1,0xE0,0xB4,0xF3,0xD7,0xD6,0xBB,0xF2,0xCD,0xBC,0xCF,0xF1,0xBB,0xF2,0xC9,0xFA};
unsigned char name3[] = {0xC6,0xA7,0xD7,0xD6,0xA3,0xAC,0xC0,0xFD,0xC8,0xE7,0xA3,0xBA};

void setup() {
pinMode(lcd_cs1, OUTPUT);
pinMode(lcd_reset, OUTPUT);
pinMode(lcd_rs, OUTPUT);
pinMode(lcd_sid, OUTPUT);
pinMode(lcd_sclk, OUTPUT);
pinMode(Rom_CS, OUTPUT);
pinMode(Rom_SCK, OUTPUT);
pinMode(Rom_IN, OUTPUT);
initial_lcd();
}

//写指令到 LCD 模块
void transfer_command_lcd(int data1)
{
digitalWrite(lcd_cs1, LOW);
digitalWrite(lcd_rs, LOW);
for(int i=0;i<8;i++)
{
digitalWrite(lcd_sclk, LOW);
if(data1&0x80) digitalWrite(lcd_sid, HIGH);
else digitalWrite(lcd_sid, LOW);
digitalWrite(lcd_sclk, HIGH);
data1=data1<<=1;
}
digitalWrite(lcd_cs1, HIGH);
}
//写数据到 LCD 模块
void transfer_data_lcd(int data1)
{
digitalWrite(lcd_cs1, LOW);
digitalWrite(lcd_rs, HIGH);
for(int i=0;i<8;i++)
{
digitalWrite(lcd_sclk, LOW);
if(data1&0x80) digitalWrite(lcd_sid, HIGH);
else digitalWrite(lcd_sid, LOW);
digitalWrite(lcd_sclk, HIGH);
data1=data1<<=1;
}
digitalWrite(lcd_cs1, HIGH);
}
//LCD 模块初始化
void initial_lcd()
{
digitalWrite(lcd_reset, LOW);//lcd_reset=0; //低电平复位
delay(100);
digitalWrite(lcd_reset, HIGH);//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(0x23); //粗调对比度,可设置范围 0x20~0x27
transfer_command_lcd(0x81); //微调对比度
transfer_command_lcd(0x28); //微调对比度的值,可设置范围 0x00~0x3f
transfer_command_lcd(0xa2); //1/9 偏压比(bias)
transfer_command_lcd(0xc8); //行扫描顺序:从上到下
transfer_command_lcd(0xa0); //列扫描顺序:从左到右
transfer_command_lcd(0x40); //起始行:第一行开始
transfer_command_lcd(0xaf); //开显示
}
void lcd_address(uint page,uint column)
{
column=column-0x01;
transfer_command_lcd(0xb0+page-1); //设置页地址,每 8 行为一页,全屏共 64 行,被分成 8 页
transfer_command_lcd(0x10+(column>>4&0x0f)); //设置列地址的高 4 位
transfer_command_lcd(column&0x0f); //设置列地址的低 4 位
}
//全屏清屏
void clear_screen()
{
for(int i=0;i<9;i++)
{
transfer_command_lcd(0xb0+i);
transfer_command_lcd(0x10);
transfer_command_lcd(0x00);
for(int j=0;j<132;j++)
{
transfer_data_lcd(0x00);
}
}
}
//显示 128x64 点阵图像
void display_128x64(uchar *dp)
{
for(int j=0;j<8;j++)
{
lcd_address(j+1,1);
for (int i=0;i<128;i++)
{
transfer_data_lcd(*dp); //写数据到 LCD,每写完一个 8 位的数据后列地址自动加 1
dp++;
}
}
}
//显示 16x16 点阵图像、汉字、生僻字或 16x16 点阵的其他图标
void display_graphic_16x16(uchar page,uchar column,uchar *dp)
{
for(int j=0;j<2;j++)
{
lcd_address(page+j,column);
for (int i=0;i<16;i++)
{
transfer_data_lcd(*dp); //写数据到 LCD,每写完一个 8 位的数据后列地址自动加 1
dp++;
}
}
}
//显示 8x16 点阵图像、ASCII, 或 8x16 点阵的自造字符、其他图标
void display_graphic_8x16(uchar page,uchar column,uchar *dp)
{
for(int j=0;j<2;j++)
{
lcd_address(page+j,column);
for (int i=0;i<8;i++)
{
transfer_data_lcd(*dp); //写数据到 LCD,每写完一个 8 位的数据后列地址自动加 1
dp++;
}
}
}
//显示 5X8 点阵图像、ASCII, 或 5x8 点阵的自造字符、其他图标
void display_graphic_5x8(uchar page,uchar column,uchar *dp)
{
lcd_address(page,column);
for (int i=0;i<6;i++)
{
transfer_data_lcd(*dp);
dp++;
}
}
//送指令到晶联讯字库 IC
void send_command_to_ROM( uchar datu )
{
for(int i=0;i<8;i++ )
{
digitalWrite(Rom_SCK, LOW);
if(datu&0x80) digitalWrite(Rom_IN, HIGH);
else digitalWrite(Rom_IN, LOW);
datu = datu<<1;
digitalWrite(Rom_SCK, HIGH);
}
}
//从晶联讯字库 IC 中取汉字或字符数据(1 个字节)
static uchar get_data_from_ROM( )
{
int ret_data=0;
for(int i=0;i<8;i++)
{
digitalWrite(Rom_SCK, LOW);
ret_data=ret_data<<1;
if( digitalRead(Rom_OUT) )
ret_data=ret_data+1;
else
ret_data=ret_data+0;
digitalWrite(Rom_SCK, HIGH);
}
return(ret_data);
}
//从指定地址读出数据写到液晶屏指定(page,column)座标中
void get_and_write_16x16(ulong fontaddr,uchar page,uchar column)
{
int disp_data;
digitalWrite(Rom_CS, LOW);
send_command_to_ROM(0x03);
send_command_to_ROM((fontaddr&0xff0000)>>16); //地址的高 8 位,共 24 位
send_command_to_ROM((fontaddr&0xff00)>>8); //地址的中 8 位,共 24 位
send_command_to_ROM(fontaddr&0xff); //地址的低 8 位,共 24 位
for(int j=0;j<2;j++)
{
lcd_address(page+j,column);
for(int i=0; i<16; i++ )
{
disp_data=get_data_from_ROM();
transfer_data_lcd(disp_data); //写数据到 LCD,每写完 1 字节的数据后列地址自动加 1
}
}
digitalWrite(Rom_CS, HIGH);
}
//从指定地址读出数据写到液晶屏指定(page,column)座标中
void get_and_write_8x16(ulong fontaddr,uchar page,uchar column)
{
int disp_data;
digitalWrite(Rom_CS, LOW);
send_command_to_ROM(0x03);
send_command_to_ROM((fontaddr&0xff0000)>>16); //地址的高 8 位,共 24 位
send_command_to_ROM((fontaddr&0xff00)>>8); //地址的中 8 位,共 24 位
send_command_to_ROM(fontaddr&0xff); //地址的低 8 位,共 24 位
for(int j=0;j<2;j++)
  {
lcd_address(page+j,column);
for(int i=0; i<8; i++ )
{
disp_data=get_data_from_ROM();
transfer_data_lcd(disp_data); //写数据到 LCD,每写完 1 字节的数据后列地址自动加 1
}
}
digitalWrite(Rom_CS, HIGH);
}
//从指定地址读出数据写到液晶屏指定(page,column)座标中
void get_and_write_5x8(ulong fontaddr,uchar page,uchar column)
{
int disp_data;
digitalWrite(Rom_CS, LOW);
send_command_to_ROM(0x03);
send_command_to_ROM((fontaddr&0xff0000)>>16); //地址的高 8 位,共 24 位
send_command_to_ROM((fontaddr&0xff00)>>8); //地址的中 8 位,共 24 位
send_command_to_ROM(fontaddr&0xff); //地址的低 8 位,共 24 位
lcd_address(page,column);
for(int i=0; i<5; i++ )
{
disp_data=get_data_from_ROM();
transfer_data_lcd(disp_data); //写数据到 LCD,每写完 1 字节的数据后列地址自动加 1
}
digitalWrite(Rom_CS, HIGH);
}
//****************************************************************
ulong fontaddr=0;
void display_GB2312_string(uchar page,uchar column,uchar *text,int Length)
{
int i= 0;
while((text>0x00) && (i<Length))
{
if(((text>=0xb0) &&(text<=0xf7)))
{
//国标简体(GB2312)汉字在晶联讯字库 IC 中的地址由以下公式来计算:
//Address = ((MSB - 0xB0) * 94 + (LSB - 0xA1)+ 846)*32+ BaseAdd;BaseAdd=0
//由于担心 8 位单片机有乘法溢出问题,所以分三部取地址
fontaddr = (text- 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>=0xa1) &&(text<=0xa3))&&(text[i+1]>=0xa1))
{
//国标简体(GB2312)15x16 点的字符在晶联讯字库 IC 中的地址由以下公式来计算:
//Address = ((MSB - 0xa1) * 94 + (LSB - 0xA1))*32+ BaseAdd;BaseAdd=0
//由于担心 8 位单片机有乘法溢出问题,所以分三部取地址
fontaddr = (text- 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>=0x20) &&(text<=0x7e))
  {
fontaddr = (text- 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)
{
int i= 0;
while((text>0x00))
{
if((text>=0x20) &&(text<=0x7e))
{
fontaddr = (text- 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++;
}
}

void loop()
{
clear_screen();
int i=sizeof(bmp1)/sizeof(bmp1[0]);
uchar bmp;
for (int k = 0; k < i; k++) bmp[k] = pgm_read_byte_near(bmp1 + k);
display_128x64(bmp);
delay(4000);
clear_screen();
display_GB2312_string(1,1,name0,16); //在第 1 页,第 1 列,显示一串 16x16 点阵汉字或 8x16 的 ASCII 字
display_GB2312_string(3,1,name1,16); //显示一串 16x16 点阵汉字或 8x16 的 ASCII 字.以下雷同
display_GB2312_string(5,1,name2,16);
display_GB2312_string(7,1,name3,12);
display_graphic_16x16(7,97,jiong1); //在第 7 页,第 81 列显示单个自编生僻汉字“囧”
display_graphic_16x16(7,113,lei1); //显示单个自编生僻汉字"畾“
delay(6000);
clear_screen();
display_GB2312_string(1,1,"<!@#$%^&*()_-+]/",16); //在第 1 页,第 1 列,显示一串 16x16 点阵汉字或 8*16 的 ASCII 字
display_string_5x8(3,1,"<!@#$%^&*()_-+]/;.,?[");//在第 3 页,第 1 列,显示一串 5x8 点阵的 ASCII 字
display_string_5x8(4,1,"JLX electronics Co., ");//显示一串 5x8 点阵的 ASCII 字
display_string_5x8(5,1,"Ltd. established at ");//显示一串 5x8 点阵的 ASCII 字
display_string_5x8(6,1,"year 2004.Focus LCM. ");//显示一串 5x8 点阵的 ASCII 字
display_string_5x8(7,1,"TEL:0755-29784961 ");//显示一串 5x8 点阵的 ASCII 字
display_string_5x8(8,1,"FAX:0755-29784964 ");//显示一串 5x8 点阵的 ASCII 字
delay(6000);
}


发表于 2020-9-21 20:50 | 显示全部楼层
U8G2库啊 可以使用的
发表于 2022-6-30 19:03 | 显示全部楼层
最近亦買了同樣的屏, 照抄樓主以上程序, 編繹不成功. 經查核發現錯漏處, text變數名之後, 部份漏了加上 [ ], 修改後就能完成編繹.

void display_GB2312_string(uchar page,uchar column,uchar *text,int Length)
{
int i= 0;
while((text>0x00) && (i<Length))
{
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|Archiver|手机版|Arduino中文社区

GMT+8, 2024-12-1 06:57 , Processed in 0.076476 second(s), 19 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表