再看DXP原理图(+Bat为3.3V),LCD_Rst为硬件复位引脚,如不需要可直接设为高电平。BG_V/BG_G为背光端,单片机控制背光可使用三极管。
初始化流程
对比度调节
COG.c文件代码
#include "N76E003.h"
#include "SFR_Macro.h"
#include "Function_define.h"
#include "Common.h"
#include "Delay.h"
#include "intrins.h"
#include "COG.h"
#include "LCDFont.h"
#define Page0 0xb0 //第0页地址
#define Page_max 0xb8 //最大页地址,第8页
#define Column_h 0x10 //列地址(高位)
#define Column_l 0x00 //列地址(低位)
//--------------------------------------------------------- 4线SPI接口
sbit RSTB =P3^0;
sbit SDO =P1^4;//串行数据
sbit SCLK =P1^3;//串行时钟
sbit CS0 =P1^5;//片选信号
sbit CD =P1^0;//命令/数据切换
//--------------------------------------------------------------------------
//清屏函数
void clear_screen(uchar xx)
{
uchar i,j;
for(i=0;i<8;i++)
{
CS0=0;
Write_ST7567_COM(0xb0+i); //SET PAGE 0---8
Write_ST7567_COM(0x10); //SET COLUMN MSB
Write_ST7567_COM(0x00); //SET CLUMN LSB
for(j=0;j<128;j++)
{
Write_ST7567_DATA(xx);
}
}
}
//显示图片函数
void Display_pic1()
{
uint i,j,adressd=0;
for(i=0;i<8;i++)
{
CS0=0;
Write_ST7567_COM(0xb0+i);
Write_ST7567_COM(0x10);
Write_ST7567_COM(0x00);
for(j=0;j<96;j++)
{
Write_ST7567_DATA(graphic1[adressd]);
adressd++;
}
}
}
//写命令函数
void Write_ST7567_COM(uchar COMDADA_4SPI)
{
uchar bit8;
CD=0;
CS0=0;
for(bit8=0;bit8<8;bit8++)
{
SCLK=0;
if((COMDADA_4SPI&0x80)==0x80)
SDO=1;
else
SDO=0;
// SCL=0;
SCLK=1;
COMDADA_4SPI=(COMDADA_4SPI<<1);
}
// CS1=1;
}
//写数据函数
void Write_ST7567_DATA(uchar DATA_4SPI)
{
uchar bit8;
CD=1;
CS0=0;
for(bit8=0;bit8<8;bit8++)
{
SCLK=0;
if((DATA_4SPI&0x80)==0x80)
SDO=1;
else
SDO=0;
SCLK=1;
DATA_4SPI=(DATA_4SPI<<1);
}
// CS1=1;
}
//软件延时(不怎么准
void Delay_ms(unsigned long value)
{
uint i,j;
for (i=0;i } //硬件复位函数 void HDReset() { RSTB=0; Delay_ms(2); RSTB=1; Delay_ms(4); } ///****************************************************************************/ 函数名称:WRITE_STRING(uchar plat,uchar column,uchar xs,uchar chr, uchar c) 函数功能:显示字符 输入参数:plat 行地址 输入参数:column 列地址 输入参数:chr 显示数值 输入参数:fs 显示方式(0,反显,否则正常显示) 返 回 值:无 ///****************************************************************************/ void WRITE_STRING(uchar plat, uchar column, uchar chr, uchar fs) { uchar page,page1,col,col_h,col_l; uchar i,a,j=0; page1= plat*2; page=page1+Page0; col=column*8; col_h=((col>>4)|0xf0)&0x1f; col_l=col&0x0f; chr=chr-' ';//得到偏移后的值 for(a = 0; a <2; a++) { Write_ST7567_COM(col_h); Write_ST7567_COM(col_l); Write_ST7567_COM(page+a); for(i = 0; i <8; i ++ ) { if(fs == 0){Write_ST7567_DATA(s0[chr][j++]);} if(fs == 1){Write_ST7567_DATA(~(s0[chr][j++]));} } } } ///****************************************************************************/ 函数名称:Disp_Nub8X16(uchar Row,uchar Col,uchar Number,uchar fs) 函数功能:将数据显示出来 输入参数:low 行地址 输入参数:Col 列地址 输入参数:Number 显示数值 输入参数:fs 显示方式(0,反显,否则正常显示) 返 回 值:无 ///****************************************************************************/ void Disp_Nub8X16(uchar Row,uchar Col,uchar Number,uchar fs) { uchar page,page1,col,col_h,col_l,chr; uchar i,a,j=0; page1=Row*2; page=page1+Page0; col=Col*8; col_h=((col>>4)|0xf0)&0x1f; col_l=col&0x0f; if(Number<11)//十进制数据 { chr=Number+16; } else//十六进制数据 { chr=Number-32; } for(a = 0; a <2; a++) { Write_ST7567_COM(col_h); Write_ST7567_COM(col_l); Write_ST7567_COM(page+a); for(i = 0; i <8; i ++ ) { if(fs == 0){Write_ST7567_DATA(s0[chr][j++]);} if(fs == 1){Write_ST7567_DATA(~(s0[chr][j++]));} } } } //清屏函数 void Lcd12864_ClearScreen(void) { uchar i, j; for(i=0; i<8; i++) { Write_ST7567_COM(0xB0+i); Write_ST7567_COM(0x10); Write_ST7567_COM(0x00); for(j=0; j<128; j++) { Write_ST7567_DATA(0x00); } } } ///****************************************************************************/ 函数名称:Init_ST7567() 函数功能:初始化液晶屏 输入参数:无 返 回 值:无 TIPS:命令符见ST7567数据手册 ///****************************************************************************/ void Init_ST7567() { HDReset();//硬复位 Timer3_Delay100ms(1); Write_ST7567_COM(0xe2);//软复位 Write_ST7567_COM(0xaf);//0xaf显示器开 Write_ST7567_COM(0x2f);//0x2f升压电路,电压管理电路, Write_ST7567_COM(0x25);//0x20-0x27为V5电压内部电阻调整设置 Write_ST7567_COM(0x81);// SET EV 调对比度 Write_ST7567_COM(0x18);//0x01-0x3f电量寄存器设置模式 Write_ST7567_COM(0xa0);//0xa0为Segment正向,0xa1 为Segment反向 Write_ST7567_COM(0xc8);//0xc0正向扫描,0xc8反射扫描 Write_ST7567_COM(0xa6);//0xa6正向显示,0xa7反向显示 Write_ST7567_COM(0xa4);//0xa4正常显示,0xa5全屏点亮 Write_ST7567_COM(0xf8);//背压比设置 Write_ST7567_COM(0x00);//00--10 Lcd12864_ClearScreen();//清屏 } COG.h文件代码 #ifndef __COG_H #define __COG_H #define uint unsigned int #define uchar unsigned char void Init_ST7567(); void Write_ST7567_COM(uchar COMDADA_4SPI); void Write_ST7567_DATA(uchar DATA_4SPI); void HDReset(); void clear_screen(uchar xx); void Display_pic1(); void Delay_ms(unsigned long value); //plat x坐标; column y坐标;p数组位置;c是否反白显示 void WRITE_STRING(uchar plat, uchar column, uchar chr, uchar fs); void Lcd12864_ClearScreen(void); void Disp_Nub8X16(uchar Row,uchar Col,uchar Number,uchar fs); #endif 取模方式 LCDFont.h文件代码 #ifndef __LCDFONT_H #define __LCDFONT_H #define uint unsigned int #define uchar unsigned char //图像数组 uchar code graphic1[]={0}; uchar code s0[][16]= { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",0*/ 0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,/*"!",1*/ 0x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*""",2*/ 0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,/*"#",3*/ 0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,/*"$",4*/ 0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,/*"%",5*/ 0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,/*"&",6*/ 0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"'",7*/ 0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,/*"(",8*/ 0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,/*")",9*/ 0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,/*"*",10*/ 0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,/*"+",11*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,/*",",12*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,/*"-",13*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,/*".",14*/ 0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,/*"/",15*/ 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,/*"0",16*/ 0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,/*"1",17*/ 0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,/*"2",18*/ 0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,/*"3",19*/ 0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,/*"4",20*/ 0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,/*"5",21*/ 0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,/*"6",22*/ 0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,/*"7",23*/ 0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,/*"8",24*/ 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,/*"9",25*/ 0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,/*":",26*/ 0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00,/*";",27*/ 0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,/*"<",28*/ 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,/*"=",29*/ 0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,/*">",30*/ 0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,/*"?",31*/ 0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00,/*"@",32*/ 0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,/*"A",33*/ 0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,/*"B",34*/ 0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,/*"C",35*/ 0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,/*"D",36*/ 0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,/*"E",37*/ 0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,/*"F",38*/ 0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,/*"G",39*/
上一篇:N76E003 旋转编码器 EC11
下一篇:N76E003 BMP180
推荐阅读最新更新时间:2024-11-17 04:36
设计资源 培训 开发板 精华推荐
- AD9266-80EBZ,AD9266 评估板,单通道,16 位,80 MSPS 模数转换器
- OLED+ESP8266天气时钟显示
- 基于OneNET云平台的智能农业温室大棚监测系统——硬件设计
- LT3467IS6 5V 至 12V、270mA 升压转换器的典型应用
- 使用 ROHM Semiconductor 的 BA60BC0WT 的参考设计
- 使用 Cypress Semiconductor 的 MB3841 的参考设计
- DER-613 - 27 W USB PD 3.0,采用 3.3 V-11 V PPS 电源,使用 InnoSwitch3-Pro 和 Weltrend WT6635P 控制器(单板设计)
- AN54,采用 LTC1149 10-48V、12V/2A 高压降压转换器的应用电路
- #第四届立创大赛#伺候宝——时刻待命的小侍从
- LT3973HMSE-3.3 12V 降压转换器的典型应用