12864oled+51程序

jirun168 发布于 2016/05/06 14:26
阅读 1K+
收藏 0

收藏!数据建模最全知识体系解读!>>>

12864oled+51程序

OLED模块用的是SSD1305的芯片,12864oled显示屏的接口是并口或SPI和IIC 可以自由转换,下面是本人做的小程序和大家分享,欢迎拍砖!

//*********************************************
#include <reg52.h>

#define DBL P0
#define SWITCH_TIME 4000 //默认2s


unsigned char a;
unsigned int pic;
bit delayflag=0;
//*********************************************
void Initial(void);
void Write_Command(unsigned char RegisterName);
void Write_Data(unsigned char RegisterValue);
void fill(unsigned char dat1,unsigned char dat2);
void Delay(unsigned int count);
void pane();
void showpic();
void pictrue();
//************************************************
sbit CS =P2^4;
sbit DC =P2^7;
sbit W_R =P2^6;
sbit R_D =P2^5;
sbit RES =P2^3;


sbit SCLK = P0^0; // Serial Clock Input
sbit SDIN = P0^1; // Serial Data Input


sbit key_stop = P1^0;//按键,按下为0暂停循环,松开为1循环跑动
sbit key_mod = P1^1;//并串模式切换按键,为0串行模式,为1为并行模式,仅在程序开机时判断


bit mod_flag = 1;


//********************************************
void uDelay(unsigned char l)
{
while(l--);
}


void Delay(unsigned int count)
{
unsigned int i,j;
for(i=0;i<count;i++)
for(j=0;j<114;j++);
}


unsigned char code show[]=
{
//-- 宽度x 高度=128x64 --*
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
//吉润电子
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x08,0x48,0x48,0x48,0x48,0x48,0x7E,0x48,0x48,0x48,0x48,0x48,0x08,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x6C,0x0C,0x00,
0xF6,0x06,0x20,0x24,0xE4,0x24,0x24,0x04,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x90,0x90,0x90,0x90,0xFE,0x90,0x90,0x90,
0x90,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,
0x82,0x82,0x82,0x82,0x82,0xE2,0xF2,0xBA,0x9E,0x8E,0x82,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7E,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x7E,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x1E,0x07,0x00,
0x7F,0x00,0x08,0x09,0x0F,0x09,0x48,0x40,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x04,0x04,0x04,0x04,0x7F,0x64,0x44,0x44,
0x44,0x47,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x40,0x40,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
//TEL:13530309438
0x00,0x01,0x7F,0x01,0x01,0x00,0x00,0x00,0x00,0x7F,0x49,0x49,0x41,0x00,0x00,0x00,
0x00,0x7F,0x40,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x00,0x00,
0x00,0x42,0x7F,0x40,0x00,0x00,0x00,0x00,0x00,0x22,0x49,0x49,0x36,0x00,0x00,0x00,
0x00,0x4F,0x49,0x49,0x31,0x00,0x00,0x00,0x00,0x22,0x49,0x49,0x36,0x00,0x00,0x00,
0x00,0x3E,0x41,0x41,0x3E,0x00,0x00,0x00,0x00,0x22,0x49,0x49,0x36,0x00,0x00,0x00,
0x00,0x3E,0x41,0x41,0x3E,0x00,0x00,0x00,0x00,0x26,0x49,0x49,0x3E,0x00,0x00,0x00,
0x00,0x38,0x26,0x7F,0x20,0x00,0x00,0x00,0x00,0x22,0x49,0x49,0x36,0x00,0x00,0x00,
0x00,0x36,0x49,0x49,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  //QQ:1903025895
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0xA2,0xC2,0xFC,0x00,0x00,0x00,
0x00,0x7C,0xA2,0xC2,0xFC,0x00,0x00,0x00,0x00,0x00,0x48,0x00,0x00,0x00,0x00,0x00,
0x00,0x84,0xFE,0x80,0x00,0x00,0x00,0x00,0x00,0x4C,0x92,0x92,0x7C,0x00,0x00,0x00,
0x00,0x7C,0x82,0x82,0x7C,0x00,0x00,0x00,0x00,0x44,0x92,0x92,0x6C,0x00,0x00,0x00,
0x00,0x7C,0x82,0x82,0x7C,0x00,0x00,0x00,0x00,0xC4,0xA2,0x92,0x8C,0x00,0x00,0x00,
0x00,0x9E,0x92,0x92,0x62,0x00,0x00,0x00,0x00,0x6C,0x92,0x92,0x6C,0x00,0x00,0x00,
0x00,0x4C,0x92,0x92,0x7C,0x00,0x00,0x00,0x00,0x9E,0x92,0x92,0x62,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};


/*
unsigned char code show[]=
{
/*-- 宽度x高度=128x64 ---此代码是显示电话号码字符
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x60,0x10,0x10,0x10,0xF0,0x10,0x10,0x10,0x60,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x80,0x40,0x20,0x10,0x10,0x10,0x20,0x40,0x80,0x00,0x00,0x10,0xF0,0x10,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0xF0,0x10,0x10,0x10,0x10,0x10,0x30,
0x40,0x00,0x00,0x10,0xF0,0x10,0x10,0x10,0x10,0x20,0xC0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
0xF8,0x04,0x02,0x02,0x02,0x02,0x04,0xF8,0x00,0x00,0x00,0x02,0xFE,0x04,0x02,0x02,
0x02,0x02,0x04,0xF8,0x00,0x02,0x0E,0xF2,0x00,0xF2,0x0E,0xF2,0x00,0xFA,0x0E,0x02,
0x00,0x00,0x00,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0xFE,0x04,0x02,
0x02,0x02,0x02,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x7F,0x80,0x00,0x00,0x00,0x00,0x00,0x80,0x7F,0x00,0x00,0x00,0xFF,0x00,
0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0xFF,0x04,0x04,0x04,0x04,0x1F,0x00,
0x80,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0xC0,0x3F,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x03,0x02,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0x02,0x02,0x02,0x02,0x01,0x00,0x00,0x00,0x00,0x10,0x1F,0x11,0x02,0x02,
0x02,0x02,0x01,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
0x00,0x00,0x00,0x02,0x02,0x03,0x02,0x02,0x00,0x00,0x00,0x00,0x02,0x03,0x02,0x00,
0x00,0x00,0x02,0x03,0x02,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
0x00,0x00,0x00,0x00,0x01,0x02,0x02,0x02,0x01,0x00,0x00,0x00,0x00,0x02,0x03,0x02,
0x02,0x02,0x02,0x02,0x03,0x00,0x00,0x00,0x02,0x03,0x02,0x02,0x02,0x02,0x02,0x03,
0x00,0x00,0x00,0x02,0x03,0x02,0x02,0x02,0x02,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x03,0x41,0x7F,0x41,0x03,0x00,0x00,0x38,0x54,0x54,0x58,0x00,0x00,0x41,0x7F,0x40,
0x00,0x00,0x00,0x00,0x44,0x00,0x00,0x7C,0x82,0x82,0x7C,0x00,0x00,0x02,0xF2,0x0E,
0x02,0x00,0x00,0x4E,0x8A,0x8A,0x72,0x00,0x00,0x4E,0x8A,0x8A,0x72,0x00,0x08,0x08,
0x08,0x08,0x08,0x00,0x00,0x6C,0x92,0x92,0x6C,0x00,0x00,0x44,0x92,0x92,0x6C,0x00,
0x00,0x6C,0x92,0x92,0x6C,0x00,0x30,0x28,0x24,0xFF,0x20,0x00,0x00,0x0C,0x92,0x92,
0x7C,0x00,0x00,0x02,0xF2,0x0E,0x02,0x00,0x7C,0x92,0x92,0x92,0x60,0x00,0x00,0x7C,
0x82,0x82,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x08,0xF8,0x48,0xE8,0x18,0x00,0x40,0xA0,0xA0,0xC0,0x00,0x00,0x20,0x60,0xA0,0x60,
0x20,0x00,0x00,0x00,0x20,0x00,0x00,0xE0,0x10,0x10,0xE0,0x00,0x00,0x10,0x90,0x70,
0x10,0x00,0x00,0x70,0x50,0x50,0x90,0x00,0x00,0x70,0x50,0x50,0x90,0x00,0x40,0x40,
0x40,0x40,0x40,0x00,0x00,0x60,0x90,0x90,0x60,0x00,0x00,0x20,0x90,0x90,0x60,0x00,
0x00,0x60,0x90,0x90,0x60,0x00,0x80,0x40,0x20,0xF8,0x00,0x00,0x00,0x60,0x90,0x90,
0xE0,0x00,0x80,0x40,0x20,0xF8,0x00,0x00,0x00,0x60,0x90,0x90,0xE0,0x00,0x00,0x20,
0x10,0x90,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x02,0x03,0x02,0x00,0x00,0x00,0x01,0x02,0x02,0x03,0x02,0x00,0x02,0x03,0x02,0x03,
0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x03,0x04,0x04,0x03,0x00,0x00,0x00,0x07,0x00,
0x00,0x00,0x00,0x02,0x04,0x04,0x03,0x00,0x00,0x02,0x04,0x04,0x03,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x03,0x00,0x00,0x02,0x04,0x04,0x03,0x00,
0x00,0x03,0x04,0x04,0x03,0x00,0x01,0x01,0x01,0x07,0x01,0x00,0x00,0x00,0x04,0x04,
0x03,0x00,0x01,0x01,0x01,0x07,0x01,0x00,0x00,0x00,0x04,0x04,0x03,0x00,0x00,0x06,
0x05,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
*/
// 8-bit 80XX Parallel
void Write_Command_Para(unsigned char RegisterName)
{
CS=0;
DC=0;
DBL=RegisterName;
W_R=0;
W_R=1;
CS=1;
}
//**************************************
void Write_Data_Para(unsigned char RegisterValue)
{
CS=0;
DC=1;
DBL= (unsigned char)RegisterValue;
W_R=0;
W_R=1;
CS=1;
}


// 4-wire SPI
void Write_Command_SPI(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;
// uDelay(1);
SCLK=1;
// uDelay(1);
}
// SCLK=0;
DC=1;
CS=1;
}




void Write_Data_SPI(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;
// uDelay(1);
SCLK=1;
// uDelay(1);
}
// SCLK=0;
DC=1;
CS=1;
}


void Write_Command(unsigned char RegisterName)
{
if(mod_flag == 1)
{
Write_Command_Para(RegisterName);
}
else
{
Write_Command_SPI(RegisterName);
}
}
//**************************************
void Write_Data(unsigned char RegisterValue)
{
if(mod_flag == 1)
{
Write_Data_Para(RegisterValue);
}
else
{
Write_Data_SPI(RegisterValue);
}
}


//**************************************************
void Initial(void)
{
//unsigned int x,y;
Write_Command(0xae); /* set display off */
Write_Command(0x00); /* set lower column start address */
Write_Command(0x10); /* set higher column start address */
Write_Command(0x40); /* set display start line */
Write_Command(0x2E);
Write_Command(0x81); /* set contrast control */
Write_Command(0x32);
Write_Command(0x82);
Write_Command(0x80);
Write_Command(0xa1); /* set segment remap */
Write_Command(0xa6); /* set normal display */
Write_Command(0xa8); /* set multiplex ratio */
Write_Command(0x3f); /* 1/64 */
Write_Command(0xad); /* master configuration */
Write_Command(0x8e); /* external vcc supply */
Write_Command(0xc8); /* set com scan direction */
Write_Command(0xd3); /* set display offset */
Write_Command(0x40);
Write_Command(0xd5); /* set display clock divide/oscillator frequency */
Write_Command(0xf0);
Write_Command(0xD8); /*set area color mode off */
Write_Command(0x05);
Write_Command(0xD9);
Write_Command(0xF1);
Write_Command(0xda); /* set com pin configuartion */
Write_Command(0x12);
Write_Command(0x91);
Write_Command(0x3F);
Write_Command(0x3F);
Write_Command(0x3F);
Write_Command(0x3F);
Write_Command(0xaf); /* set display on */
}


void fill(unsigned char dat1,unsigned char dat2)
{
unsigned char x,y;
for(y=0;y<8;y++)
{
Write_Command(0xb0+y);
Write_Command(0x00);
Write_Command(0x10);
for(x=0;x<132;x++)
{
Write_Data(dat1);
Write_Data(dat2);
}
}
Delay(1);
}
void pane()
{
unsigned char x;//,y
unsigned int j;
/* page 1 */
Write_Command(0x00);
Write_Command(0x10);
Write_Command(0xb0);
Write_Data(0xff);
for(x=0;x<126;x++)
{
Write_Data(0x01);
}
Write_Data(0xff);
/* page 2--5 */
for(j=1;j<7;j++)
{
Write_Command(0x00);
Write_Command(0x10);
Write_Command(0xb0+j);
Write_Data(0xff);
for(x=0;x<126;x++)
{
Write_Data(0x00);
}
Write_Data(0xff);
}
/* page 6 */
Write_Command(0x00);
Write_Command(0x10);
Write_Command(0xb7);
Write_Data(0xff);
for(x=0;x<126;x++)
{
Write_Data(0x80);
}
Write_Data(0xff);
Delay(1);
}


void pictrue()
{
unsigned char x,y;
unsigned int i=0;
Write_Command(0x00);
Write_Command(0x10);
for(y=0;y<8;y++)
{
Write_Command(0xb0+y);
Write_Command(0x00);
Write_Command(0x10);
for(x=0;x<128;x++)
{
Write_Data(show[i++]);
}
}
}
//***************************************
void main(void)
{
key_stop = 1;
key_mod = 1;
Delay(5);
RES=0;
Delay(10);
RES=1;
Delay(10);
if(key_mod == 0) mod_flag = 0;//串行模式
if(key_mod == 1) mod_flag = 1;//并行模式
Initial();
while(1)
{
fill(0xff,0x00); Delay(SWITCH_TIME);
while(key_stop == 0);
fill(0x55,0x55); Delay(SWITCH_TIME);
while(key_stop == 0);
fill(0x55,0xaa); Delay(SWITCH_TIME);
while(key_stop == 0);
pane(); Delay(SWITCH_TIME);
while(key_stop == 0);
pictrue();Delay(SWITCH_TIME);
while(key_stop == 0);
}
}


加载中
返回顶部
顶部