文章详情

低温-40℃工作的OLED模块HCS1624的应用实例

日期:2024-04-28 02:37
浏览次数:1804
摘要: 低温-40℃工作的OLED模块HCS1624的应用实例 摘要:本文介绍了清达光电HCS1624这款低温产品,并给出了其月8051单片机应用实例 1,OLED模块HCS1624的主要规格参数: 外形尺寸:80.0(W)×36.0(H)×7.5MAX.(T)mm 显示尺寸:58.22(W)×13.52(H) mm 有效视域:56.22(W)×11.52(H) mm 字符大小:2.97(W)×5.57 (H)mm 点大小:0.57(W)×0.67(H)mm 显示屏颜色:黄色字体,黑色底色 工作温度:-40 ℃~80℃ 2,显示屏显示效果图 ...

低温-40℃工作的OLED模块HCS1624的应用实例

摘要:本文介绍了清达光电HCS1624这款低温产品,并给出了其月8051单片机应用实例


1,OLED模块HCS1624的主要规格参数:

外形尺寸:80.0(W)×36.0(H)×7.5MAX.(T)mm

显示尺寸:58.22(W)×13.52(H) mm

有效视域:56.22(W)×11.52(H) mm

字符大小:2.97(W)×5.57 (H)mm

点大小:0.57(W)×0.67(H)mm

显示屏颜色:黄色字体,黑色底色

工作温度:-40 ℃~80℃


2,显示屏显示效果图


3,低温-40℃工作的OLED模块HCS1624的应用实例——8051单片机应用实例

应用程序如下:

#include<reg51.h>
#include <string.h>
#include <intrins.h>
#include <math.h>
#define uchar unsigned char
#define uint unsigned int
#define DATA P1

sbit CD     =    P3^3;  //并行接口;
sbit WR1    =    P3^1;
sbit RD1    =   P3^0;



uchar code tab1[]={"Tsingtek-OLED"};
uchar code tab2[]={"HCS1624-Y-EH-I2C"};
uchar code CGR[]={
                   0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,//隔列1
                   0x1f,0x00,0x1f,0x00,0x1f,0x00,0x1f,0x00,//隔行1
                   0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,//隔列2
                   0x00,0x1f,0x00,0x1f,0x00,0x1f,0x00,0x1f,//隔行2
                   0xff};
//此程序测试于 24M 晶震,51单片机;
//注意,关与 IS RE SD这3位,起始时是000,我们每次用完命令之后也复位成000;


/******************************************************************
      延时子程序   
*****************************************************************/

void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
   for(y=124;y>0;y--);
}
void delay_100us(uchar z)
{
z=z*16;
while(z--);
}



/****************************写指令程序*****************************************/

void wait(void)       // 忙等待;
{
RD1=0;                      _nop_();
CD=0;                    _nop_();                            
WR1=1;                     _nop_();                          
DATA=0xff;                   _nop_();                        
RD1=1;                    _nop_();                           
while(DATA&0x80);          _nop_();                                                        
RD1=0;                    _nop_();_nop_();
_nop_();_nop_();_nop_();
_nop_();_nop_();_nop_();
        
}
void wr_data(uchar b)    //写数据  ;
{
wait();                     _nop_();                        
CD=1;                    _nop_();                        
WR1=0;                    _nop_();                          
DATA=b;                    _nop_();
RD1=1;                    _nop_();                                                
RD1=0;                  _nop_();_nop_();            

_nop_();_nop_();_nop_();
_nop_();_nop_();_nop_();
}
void wr_com(uchar b)    //写命令;
{
wait();                     _nop_();                            
CD=0;                    _nop_();                        
WR1=0;                    _nop_();                        
DATA=b;                _nop_();
RD1=1;                    _nop_();                                                    
RD1=0;                  _nop_();_nop_();                

_nop_();_nop_();_nop_();
_nop_();_nop_();_nop_();

}
uchar rd_data(void) //读数据;
{
uchar temp;                                                    
wait();                     _nop_();                                
CD=1;                    _nop_();                                
WR1=1;                    _nop_();                                
DATA=0xff;                _nop_();                            
RD1=1;                  _nop_();                            
temp=DATA;                _nop_();                                                                                 
RD1=0;                  _nop_();_nop_();                                                                    

_nop_();_nop_();_nop_();
_nop_();_nop_();_nop_();
return temp;
}


/******************************************************************
   定位地址(一个地址对应5*8字符和)
   x--> 水平方向地址数(0~39)    ;y-->  垂直方向字符数(0~1);
*****************************************************************/

void  dot(uchar x,uchar y)
{
if(y) x|=0x40;
x|=0x80;
wr_com(x);
}

/******************************************************************
  清屏;
*****************************************************************/

void clear(void)
{
wr_com(0x01);delay(5);
}

/******************************************************************
  字符的输入(5*8)
x--> 水平方向地址数(0~39)    ;y-->  垂直方向字符数(0~1);s-->字符代码首地址;
*****************************************************************/
void en_c_r(uchar x,uchar y,uchar code  * s)   
{
  dot(x,y);
  while(*s>0&&x<20)
   {
   wr_data(*s);
   s++;
   x++;
   }
}

/******************************************************************
自定义字符形成;
*****************************************************************/
void CGR_SET(uchar code *s)
{
 uchar i=0;
 while(*s!=0xff)
  {
   wr_com(0x40+i);
   wr_data(*s);
   s++;
   i++;
  }
}    
/******************************************************************
  全屏;
*****************************************************************/
 void  fill(uchar z)                                //全屏    
 {
 uchar x,y ;
 for(y=0;y<2;y++)
    for(x=0;x<16;x++)
    {
    dot(x,y);
    wr_data(z);
    }
 }
/******************************************************************
  初始化设置;
*****************************************************************/

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);
    }
}