文章详情

清达光电25664OLED模块SSD1322测试程序,示例代码

日期:2024-11-26 16:35
浏览次数:8467
摘要:

清达光电25664OLED模块SSD1322测试程序,示例代码:

清达光电为您提供显示模块,并提供高质量的技术服务

OLED模块SSD1322控制器的屏主要是HGS256641,HGS256642,HGS256643,HGS256128等产品。

主要示例代码(更详细的代码请QQ 453189731或者13701081790索取)
/*************************************************************
//杭州清达光电OLED演示程序
//2009-08-01
*************************************************************/
#define DATA_BUS  P1
sbit REST=P3^4;    // Reset
sbit CS=P3^3;    // Chip Select
sbit DC=P3^2;    // Data/Command Control
sbit SCLK=P3^0;    // Serial Clock Input
sbit SDIN=P3^1;    // Serial Data Input

void Fill_RAM(unsigned char Data) ;

uchar code tab1616[]={
/* 点阵:16x16
   提取点阵方向:横向(先左->右, 再上->下)
   字节掉转:否
   字节方式:C语言 */
0x00,0x40,0x40,0x48,0x37,0xFC,0x10,0x40,    // 清
0x83,0xF8,0x60,0x40,0x2F,0xFE,0x08,0x08,
0x13,0xFC,0x22,0x08,0xE3,0xF8,0x22,0x08,
0x23,0xF8,0x22,0x08,0x22,0x28,0x22,0x10,

0x00,0x80,0x40,0x80,0x20,0x80,0x20,0x80,    // 达
0x00,0x88,0x0F,0xFC,0xE0,0x80,0x21,0x00,
0x21,0x40,0x22,0x20,0x22,0x10,0x24,0x18,
0x28,0x08,0x50,0x06,0x8F,0xFC,0x00,0x00,

0x01,0x00,0x21,0x08,0x11,0x0C,0x09,0x10,    // 光
0x09,0x20,0x01,0x04,0xFF,0xFE,0x04,0x40,
0x04,0x40,0x04,0x40,0x04,0x40,0x08,0x40,
0x08,0x42,0x10,0x42,0x20,0x3E,0x40,0x00,

0x02,0x00,0x02,0x00,0x02,0x10,0x7F,0xF8,    // 电
0x42,0x10,0x42,0x10,0x7F,0xF0,0x42,0x10,
0x42,0x10,0x7F,0xF0,0x42,0x10,0x02,0x00,
0x02,0x04,0x02,0x04,0x01,0xFC,0x00,0x00,

0x04,0x10,0x0E,0x10,0xF8,0x90,0x08,0x50,    // 科
0x08,0x10,0xFE,0x90,0x08,0x50,0x1C,0x14,
0x1A,0x1E,0x29,0xF0,0x28,0x10,0x48,0x10,
0x88,0x10,0x08,0x10,0x08,0x10,0x08,0x10,

0x10,0x40,0x10,0x40,0x10,0x48,0x13,0xFC,    // 技
0xFC,0x40,0x10,0x40,0x10,0x40,0x13,0xF8,
0x1A,0x08,0x31,0x10,0xD1,0x10,0x10,0xA0,
0x10,0x40,0x10,0xB0,0x51,0x0E,0x26,0x04,

0x02,0x00,0x02,0x04,0xFF,0xFE,0x04,0x00,    // 有
0x04,0x10,0x0F,0xF8,0x08,0x10,0x18,0x10,
0x2F,0xF0,0x48,0x10,0x88,0x10,0x0F,0xF0,
0x08,0x10,0x08,0x10,0x08,0x50,0x08,0x20,

0x00,0x08,0x7D,0xFC,0x45,0x08,0x49,0x08,    // 限
0x49,0xF8,0x51,0x08,0x49,0x08,0x49,0xF8,
0x45,0x04,0x45,0x88,0x45,0x50,0x69,0x20,
0x51,0x10,0x41,0x4E,0x41,0x84,0x41,0x00,

0x00,0x00,0x00,0x80,0x04,0x80,0x04,0x40,    // 公
0x08,0x40,0x08,0x20,0x11,0x10,0x21,0x0E,
0xC2,0x04,0x02,0x00,0x04,0x00,0x08,0x40,
0x10,0x20,0x1F,0xF0,0x00,0x10,0x00,0x00,

0x00,0x08,0x3F,0xFC,0x00,0x08,0x00,0x48,    // 司
0xFF,0xE8,0x00,0x08,0x00,0x88,0x3F,0xC8,
0x20,0x88,0x20,0x88,0x20,0x88,0x20,0x88,
0x3F,0x88,0x20,0x88,0x00,0x28,0x00,0x10,


};

// 4-wire SPI
void Write_cmd(unsigned char Data)
{
unsigned char i;

 CS=0;
 DC=0;
 for (i=0; i<8; i++)
 {
  SCLK=0;
  SDIN=(Data&0x80)>>7;
  Data = Data << 1;
  SCLK=1;
 }
 DC=1;
 CS=1;
}


void Write_dat(unsigned char Data)
{
unsigned char i;

 CS=0;
 DC=1;
 for (i=0; i<8; i++)
 {
  SCLK=0;
  SDIN=(Data&0x80)>>7;
  Data = Data << 1;
  SCLK=1;
 }
 DC=1;
 CS=1;
}

/********************************************
行,列,起始地址设定,写入命令定义 一个像素对应4位
********************************************/
void Set_Column_Address(unsigned char a, unsigned char b)
{
 Write_cmd(0x15);   // Set Column Address
 Write_dat(a);    //   Default => 0x00
 Write_dat(b);    //   Default => 0x77
}


void Set_Row_Address(unsigned char a, unsigned char b)
{
 Write_cmd(0x75);   // Set Row Address
 Write_dat(a);    //   Default => 0x00
 Write_dat(b);    //   Default => 0x7F
}

void Set_Write_RAM()
{
 Write_cmd(0x5C);   // Enable MCU to Write into RAM
}

void Set_Remap_Format(unsigned char d)
{
 Write_cmd(0xA0);   // Set Re-Map / Dual COM Line Mode
 Write_dat(d);    //   Default => 0x40
 Write_dat(0x11);   //   Default => 0x01 (Disable Dual COM Mode)
}

/* ***********************************
//初始化程序
***************************************/
void Initial (void)
{
    REST=0;
 delayms(100);
 REST=1;
    delayms(100);
 Write_cmd(0xFD);
  Write_dat(0x12);  //打开MCU通信

 Set_Column_Address(0x1c,0x5b);    //256列
 Set_Row_Address(0x00,0x3f);   //64行

 Write_cmd(0xAE);  //开休眠

 Write_cmd(0xB3);  ///驱动和振荡时钟
 Write_dat(0x91);

 Write_cmd(0xCA); ///设定MUX占空比
 Write_dat(0x3F);

 Write_cmd(0xA2);
 Write_dat(0x00); //卷动地址

 Write_cmd(0xA1);
 Write_dat(0x00); //起始行

    Write_cmd(0xA6);   //正常显示

 Write_cmd(0xA0);
  Write_dat(0x14);
 Write_dat(0x11);  //扫描方向

 Write_cmd(0xB5); ///set gpio
 Write_dat(0x00);

 Write_cmd(0xAB);
 Write_dat(0x01); //内部调节电压

 Write_cmd(0xB4); ///加深显示Display Enhancement a
 Write_dat(0xA0);
 Write_dat(0xfd);   //0xb5
                                                //C1C7调节对比度
 Write_cmd(0xC1); ///Set Contrast Current
 Write_dat(0xaf); //9f

 Write_cmd(0xC7);  //Master Contrast Current Control
 Write_dat(0x0F);

 Write_cmd(0xb8);  //灰模
 Write_dat(0x0c);
 Write_dat(0x18);
 Write_dat(0x24);
 Write_dat(0x30);
 Write_dat(0x3c);
 Write_dat(0x48);
 Write_dat(0x54);
 Write_dat(0x60);
  Write_dat(0x6c);
 Write_dat(0x78);
 Write_dat(0x84);
 Write_dat(0x90);
 Write_dat(0x9c);
 Write_dat(0xa8);
 Write_dat(0xb4);

 Write_cmd(0x00);
 Write_cmd(0xB1); //Set Phase Length驱动波形
 Write_dat(0xE2);

 Write_cmd(0xD1); //Display Enhancement B
 Write_dat(0xa2);
 Write_dat(0x20);//反显

 Write_cmd(0xBB);
 Write_dat(0x1F);

 Write_cmd(0xB6);
 Write_dat(0x08);

  Write_cmd(0xBE);
 Write_dat(0x07);//0.86VCC

  Write_cmd(0xA6);//正常显示
 Write_cmd(0xA9);//退部分显示
 Write_cmd(0x5c);
 Fill_RAM(0x00);
            Write_cmd(0xAF);  //关休眠
}

/***************************************
主函数
**************************************/
void main(void)
{

Initial ();

while(1)
{

Fill_RAM(0xff);
delay(2);
Fill_RAM(0xf0);
delay(2);
Fill_RAM(0x0f);
delay(2);
gedot(0xf0);
delay(2);
gedot(0x0f);
delay(2);
hang(0xff);
delay(2);
hang(0x00);
delay(2);

Fill_RAM(0x00);

biank();
hzwrite_oled(14,5,0x00);
hzwrite_oled(22,5,0x01);
hzwrite_oled(30,5,0x02);
hzwrite_oled(38,5,0x03);

stinghz(4,25,10) ;

string816(14,45,10);

delay(5);
}}