【51单片机快速入门指南】6.2:SPI 、八线、四线控制 LCD12864 屏幕及Proteus的仿真(支持中文汉字)

目录

  • 硬知识
    • LCD12864简介
      • 主控芯片ST7920的功能是:
      • 驱动芯片ST7921的功能是:
    • 引脚功能
    • 时序
      • 并行通信
      • 串行通信
    • 指令
    • 存储结构
    • 操作
    • 取模软件的配置
  • 示例程序
    • st7920.c
    • st7920.h
    • 测试程序
      • 显示图片
        • 图片1
          • 实验现象
        • 图片2
          • 实验现象
      • 显示字符
        • 英文
          • 实验现象
        • 中文
          • 实验现象
  • Proteus的仿真

普中51-单核-A2
STC89C52
Windows 10 20H2
Proteus 8 Frofessional v8.9 SP2
Keil uVision V5.29.0.0
PK51 Prof.Developers Kit Version:9.60.0.0


       移植自发布一个ST7920的LCD12864 Proteus仿真模型,支持串口和4bit模式通讯 —— cdhigh
       参考资料:《LCD12864液晶显示模块数据手册(带字库)》

硬知识

LCD12864简介

       LCD12864液晶屏,背面3个COB牛屎堆,一个主控芯片ST7920,另外两个是移位芯片ST7921.

主控芯片ST7920的功能是:

  1. 与我们的单片机并行通信。
  2. 字库ROM、CGROM,DDRAM等。
  3. 行扫描COM0 ~ COM31…
  4. 列扫描SEG0 ~ SEG63…
  5. 串行方式发送数据到两片ST7921驱动芯片。

驱动芯片ST7921的功能是:

  1. 接收来自ST7920的串行信号,转化成并口驱动电压。
  2. 根据信号要求,两片芯片分别驱动SEG64~ SEG159,SEG160~ SEG255

       LCD12864它本质上是256x32点的矩阵屏,32行扫描是COM0-COM31,列字节是SEG0-SEG255总共32字节,每个字节8bit,总共256位。.
       原本左右拼接的256x32点,变成了上下拼接的128x64点。如下图所示:
在这里插入图片描述

引脚功能

在这里插入图片描述

时序

并行通信

在这里插入图片描述

串行通信

如图,所用SPI应为模式0,其中RW口为MOSI,E口为SCLK,RS口为CS,PSB应接地。
在这里插入图片描述

指令

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

存储结构

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

操作

在这里插入图片描述

在这里插入图片描述

uint8_t code LCD12864_Write_CGRAM[]=
{
0x60,0x00,0x91,0xF4,0x96,0x0C,0x6C,0x04,
0x08,0x04,0x18,0x00,0x18,0x00,0x18,0x00,
0x18,0x00,0x18,0x00,0x18,0x00,0x08,0x00,
0x0C,0x04,0x06,0x08,0x01,0xF0,0x00,0x00
};//温度符号的 32 个字节字模

在这里插入图片描述

取模软件的配置

在这里插入图片描述

示例程序

VSS		——	GND
VDD		——	VCC(5V or 3.3V)
V0			亮度调节 
CS(RS)	——	接VCC,持续高电平,一直选通。
MOSI(R/W)——	接MOSI
SCLK(E)	——	接SCLK
PSB		——	接GND  串行模式
BLA		——	VCC(5V or 3.3V)
BLK		——	接GND			
剩余引脚不接,留空

       stdint.h见【51单片机快速入门指南】1:基础知识和工程创建
       软件SPI程序见【51单片机快速入门指南】5:软件SPI
       SPI选择模式0。
在这里插入图片描述
根据电路修改Soft_SPI.h
在这里插入图片描述

模式选择在st7920.h
在这里插入图片描述

st7920.c

//ST7920 LCD 驱动
#include "st7920.h"
#include "./Soft_SPI/Soft_SPI.h"void delay_ms(int i);void st7920_delay()
{}void LCD12864_CS_H()	//若SPI总线上只有屏幕,则可接VCC
{LCD12864_CS = 1;
}void LCD12864_CS_L()
{LCD12864_CS = 0;
}void LCD12864_PSB_L()	//接GND或给低电平以实现SPI通讯
{LCD12864_PSB = 0;
}void LCD12864_RS_H()
{RS_Pin = 1;
}void LCD12864_RS_L()
{RS_Pin = 0;
}void LCD12864_WR_H()
{WR_Pin = 1;
}void LCD12864_WR_L()
{WR_Pin = 0;
}void LCD12864_EN_H()
{EN_Pin = 1;
}void LCD12864_EN_L()
{EN_Pin = 0;
}uint8_t LCD12864_Port_Read()
{return LCD12864_Port;
}//并口模式下写八位
void LCD12864_Port_Write_8B(uint8_t Data)
{LCD12864_Port = Data;
}//4位模式下写半个字节(高4位)
void LCD12864_Port_Write_4B(uint8_t Data)
{LCD12864_Port &= 0x0F;LCD12864_Port |= Data;
}//初始化
void LCD_init(void)
{
#if LCD_INTERFACE == MODE_SPILCD12864_PSB_L();
#endifdelay_ms(50);LCD_write_command(0x33);delay_ms(1);LCD_write_command(0x32);delay_ms(1);
#if LCD_INTERFACE == MODE_4BITLCD_write_command(0x28);delay_ms(1);LCD_write_command(0x28);delay_ms(1);
#endifLCD_write_command(0x08);  //显示关delay_ms(1);             //大于100uS的延时程序LCD_write_command(0x10);  //光标设置delay_ms(1);             //大于100uS的延时程序LCD_write_command(0x0C);  //显示开delay_ms(1);             //大于100uS的延时程序LCD_write_command(0x01);  //Display Cleardelay_ms(10);            //大于10mS的延时程序LCD_write_command(0x06);  //光标从右向左加1位移动delay_ms(10);            //大于10mS的延时程序
}//写命令
void LCD_write_command(unsigned char command)
{
#if LCD_INTERFACE == MODE_SPILCD2_spi_write_byte(0xf8);st7920_delay();LCD2_spi_write_byte_standard(command);
#elseLCD12864_RS_L();   //RS=0LCD_write_byte(command);delay_ms(1);
#endif
}//写数据
void LCD_write_data(unsigned char Data)
{
#if LCD_INTERFACE == MODE_SPILCD2_spi_write_byte(0xfa);st7920_delay();LCD2_spi_write_byte_standard(Data);
#elseLCD12864_RS_H();    //RS=1LCD_write_byte(Data);
#endif
}//并口模式写一个字节到控制器
void LCD_write_byte(unsigned char Data)
{
#if LCD_INTERFACE == MODE_4BITLCD_write_half_byte(Data);Data <<= 4;LCD_write_half_byte(Data);
#elseLCD12864_Port_Write_8B(Data);LCD12864_WR_L();LCD12864_EN_H();     //EN端产生一个由低电平变高电平,写LCDst7920_delay();LCD12864_EN_L();      //EN端产生一个由高电平变低电平,写LCDst7920_delay();LCD12864_WR_H();
#endif
}//4位模式下写半个字节(高4位)
void LCD_write_half_byte(unsigned char half_byte)
{LCD12864_Port_Write_4B(half_byte);LCD12864_WR_L();LCD12864_EN_H();         //EN端产生一个由低电平变高电平,写LCDst7920_delay();LCD12864_EN_L();          //EN端产生一个由高电平变低电平,写LCDst7920_delay(); LCD12864_WR_H();
}//串行模式下写一个字节
void LCD2_spi_write_byte(unsigned char Data)
{LCD12864_CS_H();SOFT_SPI_RW_MODE0(Data);LCD12864_CS_L();
}//标准处理,一个字节要拆成两个字节发送
void LCD2_spi_write_byte_standard(unsigned char Data)
{LCD2_spi_write_byte(Data & 0xf0);LCD2_spi_write_byte((Data << 4) & 0xf0);
}//并口模式下读数据
unsigned char LCD_read_data(void)
{unsigned char Data;LCD12864_RS_H();Data = LCD_read_byte();#if LCD_INTERFACE == MODE_4BITData = (Data & 0xf0) | ((LCD_read_byte() >> 4) & 0x0f);
#endifreturn Data;
}//并口模式下读状态
unsigned char LCD_read_status(void)
{unsigned char Data;LCD12864_RS_L();Data = LCD_read_byte();
#if LCD_INTERFACE == MODE_4BITData = (Data & 0xf0) | ((LCD_read_byte() >> 4) & 0x0f);
#endifreturn Data;
}//并口模式下读一个字节,如果是4bit模式,则只有高4位是有效的
unsigned char LCD_read_byte(void)
{unsigned char Data;LCD12864_WR_H();LCD12864_EN_L();         //EN端产生上升沿,ST7920开始输出数据st7920_delay();LCD12864_EN_H();st7920_delay();Data = LCD12864_Port_Read();LCD12864_EN_L();return Data;
}//设置字符模式的地址
//第一行首地址:0x80
//第二行首地址:0x80+0x10 (0x90)
//第三行首地址:0x80+0x08 (0x88)
//第四行首地址:0x80+0x10+0x08 (0x98)
void LCD_set_text_address(unsigned int rowCol)
{unsigned char start = 0x80;unsigned char row = (rowCol >> 8) & 0xff;unsigned char col = rowCol & 0xff;if (row == 1) {start = 0x90;}if (row == 2) {start = 0x88;}if (row == 3) {start = 0x98;}LCD_write_command(start + col);
}//将字符模式的行列号转换为内部的XY坐标,返回的高字节为X,低字节为Y
//row (HIGH_BYTE(rowCol)): 行号,0-3
//col (LOW_BYTE(rowCol)): 列号,0-7
unsigned int LCD_rowCol_to_inter_Xy(unsigned int rowCol)
{unsigned char row = (rowCol >> 8) & 0x03;unsigned char col = rowCol & 0x07;unsigned char x = col + 8 * (unsigned char)(row / 2);unsigned char y = (row * 16) & 0x1f;return (x << 8) | y;
}//设置绘图模式的地址
//x: 0-127 (注意x必须为16的整数倍)
//y:0-63
void LCD_set_graphic_address(unsigned char x, unsigned char y)
{unsigned char xWord, downPage, yInter;x &= 0x7f;y &= 0x3f;xWord = x / 16;           //内部X地址,一个地址管16位downPage = y / 32;        //0:上半屏 1:下半屏yInter = y & 0x1f;        //内部Y坐标LCD_write_command(0x80 + yInter); //先设置Y地址LCD_write_command(0x80 + xWord + 8 * downPage);
}//显示清屏函数
void LCD_clear(void)
{unsigned char x, y;LCD_write_command(0x08);  //避免清屏过程中闪烁,先关显示st7920_delay();LCD_write_command(0x01);  //清DDRAM//清GDRAM,12864仅用了一半的GDRAM,清一半即可//如果没有使用到绘图GDRAM,也可以不清GDRAM,省点时间和代码空间LCD_startGraphic();for (y = 0; y < 32; y++){LCD_write_command(0x80 + y); //yLCD_write_command(0x80 + 0); //xfor (x = 0; x < 16; x++){LCD_write_data(0x00);LCD_write_data(0x00);}}LCD_endGraphic();LCD_write_command(0x0C);  //显示开delay_ms(10);
}//开启扩展命令的绘图指令
void LCD_startGraphic(void)
{
#if LCD_INTERFACE == MODE_4BITLCD_write_command(0x24);          //扩展指令集LCD_write_command(0x26);          //绘图命令开启
#elseLCD_write_command(0x34);          //扩展指令集LCD_write_command(0x36);          //绘图命令开启
#endif
}//结束扩展命令的绘图指令(可选)
void LCD_endGraphic(void)
{
#if LCD_INTERFACE == MODE_4BITLCD_write_command(0x26); //绘图命令关闭LCD_write_command(0x20); //回到基本指令
#elseLCD_write_command(0x36); //绘图命令关闭LCD_write_command(0x30); //回到基本指令
#endif
}//反白或取消反白对应16X16区域,一般用于菜单选择
//row (HIGH_BYTE(rowCol)): 行号,0-3
//col (LOW_BYTE(rowCol)): 列号,0-7
//charNum: 要反白的字符数量,注意不要超过行末
//ST7920内置的反白作用不大,它只能整行反白,而且反白第一行,第三行也会一起反白
//所以此函数使用另外的方法实现:绘图区对应的位全部写0xff,异或后即可反白
void LCD_Inverse_16X16(unsigned int rowCol, unsigned char charNum, unsigned char reverse)
{unsigned char i, ch;unsigned int xy = LCD_rowCol_to_inter_Xy(rowCol);unsigned char x = (xy >> 8) & 0xff;unsigned char y = xy & 0x3f;LCD_startGraphic();for (i = 0; i < 16; i++) //把对应字符的GDRAM全部写成0xff,异或后就是反白{LCD_write_command(0x80 + y + i);   //先写垂直地址yLCD_write_command(0x80 + x);       //xfor (ch = 0; ch < charNum; ch++){LCD_write_data(reverse ? 0xff : 0x00);LCD_write_data(reverse ? 0xff : 0x00);}}LCD_endGraphic();
}//显示一个字符,12864可以显示4行,每行8个汉字或每行16个字母
//col: 列号,0-15
//row: 行号,0-3
//字符编码:小于0x80的为ASCII,否则为汉字,汉字编码高字节在左边
void LCD_write_char(unsigned int rowCol, unsigned int Code)
{unsigned char high = (Code >> 8) & 0xff;unsigned char low = Code & 0xff;LCD_set_text_address(rowCol);if (Code > 0x80){LCD_write_data(high);}LCD_write_data(low);
}//显示一个字符串,注意不要超过一行的长度(8个汉字或16个字母)
//rowCol: 左8位为行(0-3),右8位为列(0-15)
void LCD_write_string(unsigned int rowCol, const char * p)
{LCD_set_text_address(rowCol);while (*p != 0){LCD_write_data(*p);p++;}
}void LCD_Draw_Bmp(unsigned char *pImage, unsigned char col, unsigned char row, unsigned char x0, unsigned char y0)
{unsigned char i, y;LCD_startGraphic();for (y = y0; y < row + y0; y++){LCD_set_graphic_address(x0, y);for (i = 0; i < col/8; i++){LCD_write_data(*pImage);pImage++;}}LCD_endGraphic();
}//只有并行接口能读ST7920,如果串行接口需要打点,则需要开辟RAM缓冲区
#if LCD_INTERFACE != MODE_SPI
//在对应X/Y位置显示一个点
void LCD_write_dot(unsigned char x, unsigned char y)
{unsigned char xBit, high, low;xBit = x & 0x0f;LCD_startGraphic();LCD_set_graphic_address(x, y);LCD_read_data();    //根据手册,设置完地址后的第一次读操作返回的数据无效high = LCD_read_data();low = LCD_read_data();//回写LCD_set_graphic_address(x, y);if (xBit < 8)   //低8位{LCD_write_data(high | (0x01 << (7 - xBit)));LCD_write_data(low);}else{LCD_write_data(high);LCD_write_data(low | (0x01 << (15 - xBit)));}LCD_endGraphic();
}
#endif

st7920.h

//ST7920 LCD 驱动
//Author: cdhigh <2021-09-22>
//ST7920的绘图结构:左上角为坐标原点,写入的字节表示从某个坐标开始的8个横向像素,
//每行 128/8=16 个字节,每个字节左边为最低位,右边为最高位,纵向64行。
//DDRAM地址
//0x80  0x81  0x82  0x83  0x84  0x85  0x86  0x87    //第一行汉字位置
//0x90  0x91  0x92  0x93  0x94  0x95  0x96  0x97    //第二行汉字位置
//0x88  0x89  0x8a  0x8b  0x8c  0x8d  0x8e  0x8f     //第三行汉字位置
//0x98  0x99  0x9a  0x9b  0x9c  0x9d  0x9e  0x9f     //第四行汉字位置
#ifndef __ST7290_H_
#define __ST7290_H_#include <STC89C5xRC.H>#define LCD12864_Port P0sbit LCD12864_CS  = P2^6;
sbit LCD12864_PSB = P3^2;
sbit RS_Pin = P2 ^ 6;			//寄存器选择位,RS位
sbit WR_Pin = P2 ^ 5;			//读写选择位,RW
sbit EN_Pin = P2 ^ 7;			//使能信号位,E位#define MODE_8BIT       8  //8bit并行模式 
#define MODE_4BIT       4  //4bit并行模式
#define MODE_SPI     	1  //串行-PSB接地//定义使用的接口模式,MODE_8BIT, MODE_4BIT, MODE_SPI
#define LCD_INTERFACE   MODE_SPIvoid LCD_clear(void);
void LCD_init(void);
void LCD_write_command(unsigned char command);
void LCD_write_data(unsigned char Data);
void LCD_write_byte(unsigned char byte);
void LCD_write_half_byte(unsigned char half_byte);
void LCD2_spi_write_byte(unsigned char Data);
void LCD2_spi_write_byte_standard(unsigned char Data);
unsigned char LCD_read_data(void);
unsigned char LCD_read_status(void);
unsigned char LCD_read_byte(void);
void LCD_startGraphic(void);
void LCD_endGraphic(void);
void LCD_Inverse_16X16(unsigned int rowCol, unsigned char charNum, unsigned char reverse);
unsigned int LCD_rowCol_to_inter_Xy(unsigned int rowCol);
void LCD_set_text_address(unsigned int rowCol);
void LCD_set_graphic_address(unsigned char x, unsigned char y);
void LCD_write_char(unsigned int rowCol, unsigned int Code);
void LCD_write_string(unsigned int rowCol, const char * p);
void LCD_Draw_Bmp(unsigned char *pImage, unsigned char col, unsigned char row, unsigned char x0, unsigned char y0);#if LCD_INTERFACE != MODE_SPI
void LCD_write_dot(unsigned char x, unsigned char y);
#endif#define BYTE_BIT(bitno) (1 << (bitno))
#define TEST_BIT(value, bitno) ((1 << (bitno)) & (value))
#define SET_BIT(value, bitno)  ((value) |= (1 << (bitno)))
#define CLR_BIT(value, bitno)  ((value) &= ~(1 << (bitno)))//两个字节凑成行列整型
//为了更好的区分使用X/Y和ROW/COL,使用ROW/COL的都是一个整型参数,X/Y为两个字节参数
#define ROW_COL(r, c) (((r) << 8) | (c & 0xff))#endif

测试程序

显示图片

图片1

#include <STC89C5xRC.H>
#include "intrins.h"
#include "stdint.h"
#include "st7920.h"void Delay1ms()		//@11.0592MHz
{unsigned char i, j;_nop_();i = 2;j = 199;do{while (--j);} while (--i);
}void delay_ms(int i)
{while(i--)Delay1ms();
}code uint8_t LCD12864_Pic[] =
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xF0,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x00,0x1F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x0D,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xE0,0x00,0x04,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xB0,0x00,0x02,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x60,0x00,0x02,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x40,0x00,0x01,0x07,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x40,0x00,0x01,0x05,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x34,0x80,0x00,0x00,0x82,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x64,0x80,0x00,0x00,0x82,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x80,0x00,0x00,0x02,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x61,0x81,0x80,0x00,0x41,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x61,0x03,0xE0,0x00,0x01,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x61,0x07,0xF0,0x00,0x21,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x61,0x0C,0x3C,0x00,0x20,0xB0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x61,0x11,0xDE,0x00,0x10,0xB0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x21,0x12,0x1F,0x00,0x10,0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x25,0x24,0xC3,0x80,0x08,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x35,0x29,0x01,0xC0,0x08,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x35,0x28,0x00,0xE0,0x04,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x3F,0xFF,0xF0,0x04,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0xF8,0x00,0x3C,0x02,0x2C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x00,0x1C,0x02,0x2C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x0E,0x01,0x16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x07,0x01,0x97,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x32,0x00,0x00,0x03,0x80,0x8B,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x32,0x00,0x00,0x01,0xC0,0x41,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0xC0,0x32,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x60,0x1D,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x30,0x07,0xDC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x10,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x08,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x80,0x00,0x00,0x0C,0x00,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0xC0,0x00,0x00,0x06,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x7C,0x00,0x00,0x7F,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x61,0xE4,0x00,0x00,0xC8,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0xEC,0x00,0x00,0xCE,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0xFC,0x00,0x00,0xFE,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xE0,0x7C,0x00,0x00,0xF8,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x60,0x38,0x00,0x00,0x78,0x1B,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x60,0x58,0x00,0x00,0x48,0x19,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x60,0x00,0x00,0x00,0x00,0x19,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x60,0x00,0x00,0x00,0x00,0x19,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x20,0x1F,0xFF,0xFF,0xE0,0x19,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x20,0x10,0x41,0x04,0x20,0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x30,0x1C,0x41,0x04,0x60,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xF0,0x0C,0x41,0x02,0x40,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xF0,0x0C,0x01,0x02,0xC0,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x06,0x81,0x03,0x80,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x03,0x81,0x03,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x01,0xE1,0x0E,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x7F,0xF8,0x01,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x00,0x00,0x80,0x03,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x80,0x00,0x00,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xC0,0x00,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x07,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};void main(void)
{LCD_init();LCD_clear();LCD_Draw_Bmp(LCD12864_Pic, 128, 64, 0, 0);while(1){	}
}
实验现象

       图片打印较慢,请耐心等待。
在这里插入图片描述

图片2

//liberty.bmp
//48x64
code unsigned char bmpData[] = 
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x01,0xE0,0x00,0x00,0x00,0x00,0x01,0x20,0x00,0x00,0x00,0x00,0x03,0xE0,0x00,0x00,0x00,0x00,0x03,0xF0,0x00,0x00,0x00,0x00,0x01,0xE0,0x00,0x00,0x00,0x00,0x01,0xC0,0x00,0x00,0x00,0x00,0x01,0xE0,0x00,0x00,0x00,0x00,0x01,0xE1,0x80,0x00,0x00,0x00,0x01,0xF1,0x84,0x00,0x00,0x00,0x01,0xF9,0x9C,0x00,0x00,0x00,0x00,0xFF,0xB8,0x00,0x00,0x00,0x00,0xBF,0xFF,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0xDF,0xFC,0x00,0x00,0x00,0x00,0xDF,0xFF,0x80,0x00,0x00,0x00,0xDC,0x7F,0x00,0x00,0x00,0x00,0xDE,0xFC,0x00,0x00,0x00,0x00,0xDC,0xF0,0x00,0x00,0x00,0x01,0xFF,0x70,0x00,0x00,0x00,0x01,0xE7,0xD8,0x00,0x00,0x00,0x01,0xB3,0xD8,0x00,0x00,0x00,0x00,0xE1,0xF0,0x00,0x00,0x00,0x00,0xC1,0xF8,0x00,0x00,0x00,0x00,0x47,0xB8,0x00,0x00,0x00,0x00,0x4F,0xBC,0x00,0x00,0x00,0x00,0x4B,0x1D,0xC0,0x00,0x00,0x00,0x7A,0x7F,0xE0,0x00,0x00,0x00,0x36,0x6E,0x70,0x00,0x00,0x00,0x6C,0x6C,0xE0,0x00,0x00,0x00,0x6C,0x4C,0xE0,0x00,0x00,0x00,0xD8,0xCC,0xC0,0x00,0x00,0x00,0xD8,0xC5,0xC0,0x00,0x00,0x00,0x70,0xC7,0xC0,0x00,0x00,0x00,0x3C,0xC7,0x80,0x00,0x00,0x00,0x38,0xC7,0x80,0x00,0x00,0x00,0x78,0xC7,0x00,0x00,0x00,0x00,0x70,0xC6,0x00,0x00,0x00,0x00,0x70,0xC6,0x00,0x00,0x00,0x00,0x70,0xC6,0x00,0x00,0x00,0x00,0x30,0xC2,0x00,0x00,0x00,0x00,0x20,0xC2,0x00,0x00,0x00,0x00,0x60,0xC2,0x00,0x00,0x00,0x00,0x60,0xC6,0x00,0x00,0x00,0x00,0x60,0xFE,0x00,0x00,0x00,0x00,0x60,0xFE,0x00,0x00,0x00,0x00,0x60,0x7E,0x00,0x00,0x00,0x00,0x60,0x7E,0x00,0x00,0x00,0x00,0x60,0xFE,0x00,0x00,0x00,0x00,0x63,0xFE,0x00,0x00,0x00,0x00,0x67,0x7E,0x00,0x00,0x00,0x00,0x7F,0xFE,0x00,0x00,0x00,0x00,0x7F,0xFE,0x00,0x00,0x00,0x00,0x7F,0xDF,0x00,0x00,0x00,0x00,0x5F,0xDF,0x00,0x00,0x00,0x01,0xFF,0xFF,0x00,0x00,0x00,0x01,0x80,0x01,0x00,0x00,0x00,0x07,0xFF,0xFF,0xC0,0x00,0x00,0x06,0xFF,0xFE,0xE0,0x00,0x00,0x04,0x00,0x00,0x60,0x00,0x00,0x07,0xFF,0xFF,0xE0,0x00,0x00,0x07,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};void main(void)
{LCD_init();LCD_clear();LCD_Draw_Bmp(bmpData, 48, 64, 32, 0);while(1){	}
}
实验现象

在这里插入图片描述

显示字符

英文

void main(void)
{LCD_init();LCD_clear();LCD_write_string(0x0000, "0123456789abcdef");LCD_write_string(0x0100, "~`!@#$%^&*()_-+=");LCD_write_string(0x0200, "ABCDEFGHIJKLMNOP");LCD_write_string(0x0300, "QRSTUVWXYZ");while(1){	}
}
实验现象

在这里插入图片描述

中文

void main(void)
{LCD_init();LCD_clear();LCD_write_string(0x0000, "祥瑞不在凤凰麒麟");LCD_write_string(0x0100, "太平须得边将忠臣");LCD_write_string(0x0200, "仁得百僚师长肝胆");LCD_write_string(0x0300, "不用三\xfd军罗绮金银");while(1){	}
}
实验现象

在这里插入图片描述

Proteus的仿真

       需添加LCD12864的模型:发布一个ST7920的LCD12864 Proteus仿真模型,支持串口和4bit模式通讯 —— cdhigh
       下载后将LIBRARY、MODELS文件夹与Proteus安装目录下DATA文件夹内的同名文件夹合并
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/400352.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【51单片机快速入门指南】仿真实例:幅值可调、频率可调的函数发生器(方波、三角波、正弦波)(1~10kHz)

目录效果设计思路STC89C52 Windows 10 20H2 Proteus 8 Frofessional v8.9 SP2 Keil uVision V5.29.0.0 PK51 Prof.Developers Kit Version:9.60.0.0 51函数发生器&#xff0c;附工程源码和Proteus仿真文件 效果 0 ~ 5V &#xff0c;50Hz的正弦波&#xff1a; 1 ~ 4V&…

VisualSvn Server介绍

1 、VisualSvn Server VisualSvn Server是免费的&#xff0c;而VisualSvn是收费的。VisualSvn是Svn的客户端&#xff0c;和Visual Studio集成在一起&#xff0c;但是不免费&#xff0c;使用AnkhSvn&#xff08;VS2008插件&#xff09;来代替VisualSvn。使用 VisualSvn Server是…

【51单片机快速入门指南】6.3:DS18B20 单总线数字温度计的多路读取

目录硬知识DS18B20介绍时序初始化时序写时序读时序命令ROM 操作命令ROM 搜索举例存贮器操作命令示例程序DS18B20.cDS18B20.h测试程序定时器中断服务函数单传感器时ID的获取 main.c单传感器读取温度和读取特定ID传感器的温度多路传感器读取普中51-单核-A2 STC89C52 Keil uVisio…

SQL多行转多列

--★转换结果如上图 1、首先创建表&#xff1a; CREATE TABLE [成绩表]( [编号] [int]IDENTITY(1,1) NOT NULL, [姓名] [varchar](50)NULL, [语文] [numeric](5, 2)NULL, [数学] [numeric](5, 2)NULL, [英语] [numeric](5, 2)NULL ) ON [PRIMARY] 2、插入测试数据 INSERT INTO …

C#通过FFmpeg获得视频文件参数

C#通过FFmpeg获得视频参数 FFmpeg简介 FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video&#xff08;录制、转换 、音/视频&#xff0c;并可将其转换为音/视频流的完整的&#xff0c;跨平台的j解决方案&#xff09;.FFmpeg的开发…

【51单片机快速入门指南】6.3.1:使用1-WIRE搜索算法搜索单总线上所有DS18B20的ID(基于二叉树)

目录源码OWSearch.c测试程序实验现象Proteus仿真实机测试普中51-单核-A2 STC89C52 Keil uVision V5.29.0.0 PK51 Prof.Developers Kit Version:9.60.0.0 移植自1-WIRE搜索算法 串口部分见【51单片机快速入门指南】3.3&#xff1a;USART 串口通信 DS18B20驱动程序见【5…

卡拉丁发布第四代车用空调滤清器

5月15日&#xff0c;卡拉丁“全澄行动”第四代车用空调滤清器产品发布会在京举行&#xff0c;据悉&#xff0c;该车用空调滤清器PM2.5过滤效率可高达99%。经国家权威检测机构广东省微生物分析检测中心检测&#xff0c;卡拉丁第四代车用空调滤清器对大肠杆菌、金***葡萄球菌抗菌…

【 Grey Hack 】大数四则运算

目录效果加减乘除乘方源码版本&#xff1a;Grey Hack v0.7.3619 - Alpha 在Gs中&#xff0c;位数大于15的整数将以科学计数法显示&#xff0c;故这里提供一种基于字符串加法的四则大数运算算法。由于位数大于10的字符串无法用to_int方法转化为整数&#xff0c;因此本示例中以长…

uniapp打包小程序上传测试后,使用有的插件显示空白页面,问题解决方【有效 / 最新】

目录 问题1图在微信开发者平台正常能使用 打包上传微信小程序测试问题2图在微信开发者平台正常能使用 打包上传微信小程序测试解决步骤一1.2.3. 解决步骤二打开微信小程序官网看图跨域网址 最后 问题1图 在微信开发者平台正常能使用 未上传小程序&#xff0c;开发过程中&…

django加载本地html

django加载本地html from django.shortcuts import renderfrom django.http import HttpResponse from django.shortcuts import render,render_to_response # Create your views here. def hello(request): return render_to_response("hello.html") 传递数据到htm…

Java知多少(68)面向字符的输出流

面向字符的输出流都是类 Writer 的子类&#xff0c;其类层次结构如图 10-5 所示。 图10-5 Writer的类层次结构图表 10-3 列出了 Writer 的主要子类及说明。 表 10-3 Writer 的主要子类类名功能说明CharArrayWriter写到字符数组的输出流BufferedWriter缓冲输出字符流PipedWriter…

Linux虚拟机的替代品:Docker与WSL2上手笔记

目录安装Docker可能出现的问题内核需更新Linux 内核更新包将 WSL 2 设置为默认版本An error occurred安装镜像使用Microsoft Store安装所选的 Linux 分发手动安装镜像及文件夹的共享Docker run 命令Windows Terminal的安装在Windows Terminal中直接运行已有的容器Windows 10 20…

flask需求文件requirements.txt的创建及使用

1.简介 Python项目中必须包含一个 requirements.txt 文件&#xff0c;用于记录所有依赖包及其精确的版本号用以新环境部署。 2.进入虚拟环境然后输入pip freeze > requirements.txt 每次安装或者升级了包之后最好也一并使用这个命令更新这个文件。 需求文件的内容示例…

【联盛德W806上手笔记】一、开发环境和烧录程序

目录简介芯片外观MCU 特性安全特性低功耗模式芯片结构管脚定义极限参数开发环境SDK的获取从官网获取从Q群获取iosetting大佬 维护的wm-sdk-w806打开工程编译固件烧录现象Windows 10 20H2 HLK-W806-V1.0-KIT WM_SDK_W806_v0.6.0 引自《W80X_MCU_快速入门V0.2》、《W806 MCU 芯片…

Mac os + Flask + PyCharm python开发环境集成

1. 打开mac自带终端安装virtualenv 执行 sudo easy_install virtualenv / sudo pip install virtualenv 2.安装完 virtualenv &#xff0c;打开一个 shell &#xff0c;创建自己的环境。 $ mkdir myapp $ cd myapp $ virtualenv venv New python executable in env/bin/py…

zookeeper注意几点

为什么80%的码农都做不了架构师&#xff1f;>>> Zookeeper 作为一个分布式的服务框架&#xff0c;主要用来解决分布式集群中应用系统的一致性问题&#xff0c;它能提供基于类似于文件系统的目录节点树方式的数据存储&#xff0c;但是 Zookeeper 并不是用来专门存储…

【51单片机快速入门指南】7:片上EEPROM

目录硬知识IAP及EEPROM新增特殊功能寄存器介绍EEPROM空间大小及地址小常识大建议常见问题示例程序EEPROM.cEEPROM.h测试程序main.c普中51-单核-A2 STC89C52 Keil uVision V5.29.0.0 PK51 Prof.Developers Kit Version:9.60.0.0 硬知识 摘自《STC89C52系列单片机器件手册》 ST…

wndows系统命令总结

window8系统下 打开运行窗口----------鼠标放到任务栏的windows图标下&#xff0c;右击&#xff0c;弹出菜单中如上图或者 打开运行窗口---------按“WINR”键&#xff0c; cmd-------打开命令窗口 services.msc--------打开服务命令 calc-----------启动计算器 dvdplay-------…

【RK3399Pro学习笔记】三、Debian 9 安装 ROS (Thinker Edge R)

目录配置源设置 Key安装初始化rosdep环境配置测试安装rosinstall卸载平台&#xff1a;华硕 Thinker Edge R 瑞芯微 RK3399Pro 固件版本&#xff1a;Tinker_Edge_R-Debian-Stretch-V1.0.4-20200615 参考资料&#xff1a; RK3399(Debian9 - stretch) 安装 ROS Lunar —— WB893…

perl学习(二)

2019独角兽企业重金招聘Python工程师标准>>> 在perl中又两个必须搞清楚&#xff0c;就是标量值和标量变量&#xff0c;列表和数组。 直接量就是数值在perl程序代码中的表现方式&#xff0c;就是直接写在程序里的数据&#xff0c;是标量值。如12&a…