聯(lián)系人:劉小姐,李小姐,王小姐
Tel:010-62000662,62051209
Fax:010-82036512
Mobile:13701081790
Email:bjqingda@126.com
Web:www.tsingtek.com
QQ:453189731
微信:13701081790
地址:北京市海淀區(qū)花園東路32號花園公寓A402室低溫OLED模塊HGS128321測試程序
低溫OLED模塊HGS128321是清達光電的產(chǎn)品,工作溫度-40~70攝氏度,完全適合通用工業(yè)環(huán)境現(xiàn)場,這款低溫OLED顯示模塊有黑底黃字/黑底綠字/黑底籃字的,供電電壓為3.3V,也可以定制5V的;另外這款是不帶字庫的款式也有帶字庫的款式。這款寬溫OLED模塊接口有8080并口,6800并口,SPI串口,I2C串口可選。
#include <reg52.h>
#include <intrins.h>
#include <math.h>
#include <stdio.h>
#define lcddata P1
#define uchar unsigned char
#define uint unsigned char
#define I80
sbit RW=P3^1;
sbit E=P3^3;
sbit _WR=P3^1;
sbit _RD=P3^3;
sbit CS=P3^4;
sbit DC=P3^0;
sbit RES=P3^5;
sbit SCLK=P1^0;
sbit SDIN=P1^1;
void INT()
{
RES=0;
uDelay(20);
RES=1;
uDelay(20);
Writecom(0xae);/////////關(guān)顯示
Writecom(0xd5);/////////設(shè)定顯示頻率
Writecom(0xa0);
Writecom(0xa8);/////設(shè)定占空比 1/32
Writecom(0x1f);
Writecom(0xd3);////////設(shè)定顯示范圍 COM
Writecom(0x00);
Writecom(0x40);///////起始行
Writecom(0x00);
Writecom(0xad);/////內(nèi)部dc-dc
Writecom(0x8e);
Writecom(0x20);/////接口方式 頁方式
Writecom(0x02);
Writecom(0xa1);/////seg方向 132-0
Writecom(0xc8);/////com方向 63-0
Writecom(0xda);////Set COM Pins Hardware Configuration
Writecom(0x12);///
Writecom(0x81);////////////對比度調(diào)節(jié)
Writecom(0xbf);/////////////對比度為中
Writecom(0xdb);////////////倍壓調(diào)節(jié)
Writecom(0x08);///////////
Writecom(0xa4);////////////Entire Display ON
Writecom(0xa6);////////////Normal display
clear(0x00);
Writecom(0xaf);////////////開顯示
}
void display88(uchar x,uchar y,uchar coder)
{
uchar i;
for(i=0;i<8;i++)
{
startpage(y);
startcolumn(x);
Writedata(tab8[coder][i]);x++;}
}
void display_8(uchar x,uchar y)
{
uchar i;
for(i=0;i<16;i++)
{display88(x,y,i);x=x+8;}
}
void display16(uchar x,uchar y,uchar coder)
{
uint j,i;
uchar n;
n=x;
i=0;
loop:
for(j=i;j<i+16;j++)
{
startpage(y);
startcolumn(x);
Writedata(tab16[coder][j]);x++;}
if(i==0)
{i=16;
y++;
x=n;
if(y==4)
return;
else goto loop;}
}
void display_16(uchar x,uchar y)
{
uchar i;
for(i=0;i<8;i++)
{display16(x,y,i);x=x+16;}
}
/****************************************************
豎直卷動
a=0x00,向上卷動 a=0x01,向下卷動
// b: Set Top Fixed Area
// c: Set Vertical Scroll Area
// d: Set Numbers of Row Scroll per Step
// e: Set Time Interval between Each Scroll Step
**************************************************/
void Vertical_Scroll(unsigned char a, unsigned char b, unsigned char c, unsigned char d, unsigned char e)
{
unsigned int i,j;
Writecom(0xA3); // Set Vertical Scroll Area
Writecom(b); // Default => 0x00 (Top Fixed Area)
Writecom(c); // Default => 0x40 (Vertical Scroll Area)
switch(a)
{
case 0:
for(i=0;i<c;i+=d)
{
startline(i);
for(j=0;j<e;j++)
{
uDelay(200);
}
}
break;
case 1:
for(i=0;i<c;i+=d)
{
startline(c-i);
for(j=0;j<e;j++)
{
uDelay(200);
}
}
break;
}
startline(0x00);
}
/************************************************************
水平卷動
a=0x00,向右卷動 a=0x01,向左卷動
// b: Set Numbers of Column Scroll per Step
// c: Define Start Page Address
// d: Define End Page Address
// e: Set Time Interval between Each Scroll Step in Terms of Frame Frequency
// f: Delay Time
*************************************************************/
void Horizontal_Scroll(unsigned char a, unsigned char b, unsigned char c, unsigned char d, unsigned char e, unsigned char f)
{
Writecom(0x26|a); // Horizontal Scroll Setup
Writecom(b);
Writecom(c);
Writecom(e);
Writecom(d);
Writecom(0x2F); // Activate Scrolling
delay(f);
}
/**********************
主程序
************************/
void main(void)
{
INT();
clear(0xff);
delay(1);
clear(0x55);
delay(1);
clear(0xaa);
delay(1);
reset(0x55);
delay(1);
reset(0xaa);
delay(1);
clear(0x00);
display_8(0,2);
display_8(0,3);
display_16(0,0);
while(1);
}