文章详情

1602宽温字符OLED显示模块HCS1626测试程序

日期:2024-04-24 02:32
浏览次数:1352
摘要:HCS1626是字符型OLED显示模块工作温度-40~80℃,清达光电HCS1626完全兼容普通字符液晶,黑底黄字效果。

清达光电为您提供HCS1626宽温字符OLED显示屏,工作温度为-40~80℃,外形尺寸和定位尺寸兼容普通的1602字符液晶,指令集也兼容普通的字符1602液晶,下面为1602宽温字符OLED显示模块HCS1626测试程序(因篇幅限制,某些子程序未放入,可以咨询清达光电索取)

#include<reg51.h>

#include <string.h>

#include <intrins.h>

#include <math.h>

#define uchar unsigned char

#define uint unsigned int

#define P68

#define DATA P1

sbit CD = P3^3;  //并行接口;

sbit WR1 = P3^1;

sbit RD1 =   P3^0;

sbit SCL =P1^0; //I2C接口;

sbit SDA =P1^1;

sbit SCLK =P1^0; //SPI接口;

sbit SDIN =P1^1;

sbit SDOU =P1^2;


/******************************************************************

 初始化设置;

*****************************************************************/

void init(void)

{

     delay(50);

//  RES=1;delay(5);

//  RES=1;delay(5);

//  RES=1;delay(5);  

// 设置电源模式;

     wr_com(0x2a);

     wr_com(0x71);

     wr_data(0x00);  /* 设置为3.3V模式 */

     wr_com(0x28);

// 显示开关;

     wr_com(0x08);  /* 关显示 */

// 设置Fosc和DCLK;

     wr_com(0x2a);

     wr_com(0x79);

 wr_com(0xd5);

 wr_com(0x70);      /* Fosc=7 DCLK=1 */

 wr_com(0x78);

 wr_com(0x28);

// 设置显示模式;

     wr_com(0x2a);

     wr_com(0x08); /* 字宽=5   1/2行显示 */

 wr_com(0x28);

// 设置地图模式;

     wr_com(0x2a);

     wr_com(0x06);    /* BDC=1(C0-->C31)   BDS=0(S99-->S0) (已规定,客户不可自行修改) */

 wr_com(0x28);

// 选择内部ROM和CGRAM;

     wr_com(0x2a);

     wr_com(0x72);

 wr_data(0x00); /* ROM=A  CGRAM=8 */

 wr_com(0x28);

// 设置OLED特性;

     wr_com(0x2a);

     wr_com(0x79); /* 进入OLED设置 */

 wr_com(0xda);

 wr_com(0x10); /* SEG硬件结构  (已规定,客户不可自行修改) */

 wr_com(0xdc);

 wr_com(0x00);  /* 内部VSL  GPIO输出无效 */

 wr_com(0x81);

 wr_com(0x7f); /* 共256级对比度,选一半 */

 wr_com(0xd9);

 wr_com(0xf1); /* P2=15DCLK  P1=4DCLK */

 wr_com(0xdb);

 wr_com(0x30); /* Vcom=0.83Vcc  */

 wr_com(0x78);

 wr_com(0x28);     /* 退出OLED设置 */

//准备开显示;

 wr_com(0x01);    /*  清屏 */

 delay(5);

 wr_com(0x80); /*  设置DDRAM地址  */

 wr_com(0x0c); /*  开显示 */

}

/******************************************************************

 主程序;

*****************************************************************/

int main(void)

{

CD=0;

init();

CGR_SET(CGR);

while(1)

{

fill(0x00);delay(700);

fill(0x01);delay(700);

fill(0x02);delay(700);

fill(0x03);delay(700);

clear();

en_c_r(0,0,tab1);

en_c_r(0,1,tab2);delay(700);

}

}