高中生
最后登录1970-1-1
在线时间 小时
注册时间2020-10-28
|
接手了一个OLED模块,用i2c通信。一直无法点亮。
程序源码 希望大佬帮忙
void Write_Cmd(uint8_t CMD)
{
i2c_Start();
i2c_SendByte(0x78);
i2c_WaitAck();
i2c_SendByte(0x00);
i2c_WaitAck();
i2c_SendByte(CMD);
i2c_WaitAck();
i2c_Stop();
}
void Write_Data(uint8_t DATA)
{
i2c_Start();
i2c_SendByte(0x78);
i2c_WaitAck();
i2c_SendByte(0x40);
i2c_WaitAck();
i2c_SendByte(DATA);
i2c_WaitAck();
i2c_Stop();
}
void OLED_Init(void)
{
delay_ms(20000);
Write_Cmd(0xAE );
Write_Cmd(0x40 );
Write_Cmd(0xB0 );
Write_Cmd(0xC8 );
Write_Cmd(0x81 );
Write_Cmd(0xff );
Write_Cmd(0xa1 );
Write_Cmd(0xa6 );
Write_Cmd(0xa8 );
Write_Cmd(0x1f );
Write_Cmd(0xd3 );
Write_Cmd(0x00 );
Write_Cmd(0xd5 );
Write_Cmd(0xf0 );
Write_Cmd(0xd9 );
Write_Cmd(0x22 );
Write_Cmd(0xda );
Write_Cmd(0x02 );
Write_Cmd(0xdb );
Write_Cmd(0x49 );
Write_Cmd(0x8d );
Write_Cmd(0x14 );
Write_Cmd(0xaf );
}
void OLED_Clear(void)
{
u8 i,n;
for(i=0;i<8;i++)
{
Write_Cmd (0xb0+i);
Write_Cmd (0x00);
Write_Cmd (0x10);
for(n=0;n<128;n++)Write_Data(0);
}
}
void OLED_ON(void)
{
Write_Cmd(0x8d);
Write_Cmd(0x14);
Write_Cmd(0xaf);
}
void OLED_DrawPoint(uint8_t x, uint8_t y, uint8_t t)
{
uint8_t page, row, point = 0;
if (x > 127 || y > 63)
return;
page = y / 8;
row = y % 8;
point = 1 << (7 - row);
if (t)
OLED_BUFFER[x] |
|