#define OLED PB_ODR_ODR5
#define RES PB_ODR_ODR4
#define SCL PB_ODR_ODR3
#define SDA PB_ODR_ODR2
void delay(unsigned int t)
{
while(t>0)
{
t--;
}
}
void SSD1316ON()
{
OLED = 1;
delay(10000);
}
void SSD1316OFF()
{
OLED = 0;
}
void start()
{
SCL=1;
SDA=1;
delay(10);
SDA=0;
SCL=0;
delay(10);
}
void stop()
{
SCL=0;
SDA=0;
delay(10);
SDA=1;
SCL=1;
delay(10);
}
void write_w(unsigned char dat)
{
unsigned char m,da;
unsigned char j;
da=dat;
for(j=0;j<8;j++)
{
m=da;
SCL=0;
m=m&0x80;
if(m==0x80)
{
SDA=1;
}
else
{
SDA=0;
}
delay(10);
da=da<<1;
SCL=1;
delay(10);
}
SCL=0;
delay(10);
SCL=1;
delay(10);
}
void write_i(unsigned char ins)
{
start();
write_w(0x78);
write_w(0x00);
write_w(ins);
stop();
}
void write_d(unsigned char dat)
{
start();
write_w(0x78);
write_w(0x40);
write_w(dat);
stop();
}
void SSD1316()
{
RES=1;
delay(10000);
RES=0;
delay(10000);
RES=1;
delay(10000);
write_i(0xAE); /*display off*/
write_i(0x00); /*set lower column address*/
write_i(0x10); /*set higher column address*/
write_i(0x40); /*set display start line*/
write_i(0xb0); /*set page address*/
write_i(0x81); /*contract control*/
write_i(0x60); /*128*/
write_i(0xA1); /*set segment remap*/
write_i(0xA6); /*normal / reverse*/
write_i(0xA8); /*multiplex ratio*/
write_i(0x1F); /*duty = 1/32*/
write_i(0xC0); /*Com scan direction*/
write_i(0xD3); /*set display offset*/
write_i(0x00);
write_i(0xD5); /*set osc division*/
write_i(0x80);
write_i(0xD9); /*set pre-charge period*/
write_i(0x22);
write_i(0xDA); /*set COM pins*/
write_i(0x12);
write_i(0xdb); /*set vcomh*/
write_i(0x40);
write_i(0x8d); /*set charge pump enable*/
write_i(0x15);
write_i(0xAF); /*display ON*/
write_d(0xff);
}
上面是根据厂家提供的程序弄的,但驱动不起来,不知道有没有哪位大侠玩过,96 32的,0.86屏,不胜感激
一周热门 更多>