|
樓主用的i2c oled,也就是四腳oled,原來一直用的128x64圖片顯示來做東西玩,最近想做的東西用到的圖片是85x64格式,結(jié)果發(fā)現(xiàn)oled顯示出現(xiàn)問題,自己改了很多地方都沒法解決
右邊出現(xiàn)了亂碼,程序如下,是商家給的例程,請問哪個地方的問題,列地址這方面嗎?
51hei圖片_20200128165207.jpg (104.09 KB, 下載次數(shù): 34)
下載附件
2020-1-28 16:52 上傳
- #include "oled.h"
- #include "picture.h"
- /**********************************************
- //IIC Start
- **********************************************/
- void IIC_Start()
- {
- SCL = high;
- SDA = high;
- SDA = low;
- SCL = low;
- }
- /**********************************************
- //IIC Stop
- **********************************************/
- void IIC_Stop()
- {
- SCL = low;
- SDA = low;
- SCL = high;
- SDA = high;
- }
- /**********************************************
- // IIC Write byte
- **********************************************/
- void Write_IIC_Byte(unsigned char IIC_Byte)
- {
- unsigned char i;
- for(i=0;i<8;i++)
- {
- if(IIC_Byte & 0x80)
- SDA=high;
- else
- SDA=low;
- SCL=high;
- SCL=low;
- IIC_Byte<<=1;
- }
- SDA=1;
- SCL=1;
- SCL=0;
- }
- /**********************************************
- // IIC Write Command
- **********************************************/
- void Write_IIC_Command(unsigned char IIC_Command)
- {
- IIC_Start();
- Write_IIC_Byte(0x78); //Slave address,SA0=0
- Write_IIC_Byte(0x00); //write command
- Write_IIC_Byte(IIC_Command);
- IIC_Stop();
- }
- /**********************************************
- // IIC Write Data
- **********************************************/
- void Write_IIC_Data(unsigned char IIC_Data)
- {
- IIC_Start();
- Write_IIC_Byte(0x78); //D/C#=0; R/W#=0
- Write_IIC_Byte(0x40); //write data
- Write_IIC_Byte(IIC_Data);
- IIC_Stop();
- }
- /********************************************
- // fill_Picture
- ********************************************/
- void fill_picture(unsigned char fill_Data)
- {
- unsigned char m,n;
- for(m=0;m<8;m++)
- {
- Write_IIC_Command(0xb0+m); //page0-page1
- Write_IIC_Command(0x00); //low column start address
- Write_IIC_Command(0x10); //high column start address
- for(n=0;n<132;n++)
- {
- Write_IIC_Data(fill_Data);
- }
- }
- }
- /******************************************
- // picture用來顯示一個圖片
- ******************************************/
- void Picture()
- {
- unsigned char x,y;
- unsigned int i=0;
- for(y=0;y<8;y++)
- {
- Write_IIC_Command(0xb0+y);
- Write_IIC_Command(0x0);
- Write_IIC_Command(0x10);
- for(x=0;x<128;x++)
- {
- Write_IIC_Data(show[i++]);
- }
- }
- }
- /***********************Delay****************************************/
- void Delay_50ms(unsigned int Del_50ms)
- {
- unsigned int m;
- for(;Del_50ms>0;Del_50ms--)
- for(m=6245;m>0;m--);
- }
- void Delay_1ms(unsigned int Del_1ms)
- {
- unsigned char j;
- while(Del_1ms--)
- {
- for(j=0;j<123;j++);
- }
- }
- void Initial_M096128x64_ssd1306()
- {
- Write_IIC_Command(0xAE); //display off
- Write_IIC_Command(0x20); //Set Memory Addressing Mode
- Write_IIC_Command(0x10); //00,Horizontal Addressing Mode;01,Vertical Addressing Mode;10,Page Addressing Mode (RESET);11,Invalid
- Write_IIC_Command(0xb0); //Set Page Start Address for Page Addressing Mode,0-7
- Write_IIC_Command(0xc8); //Set COM Output Scan Direction
- Write_IIC_Command(0x00);//---set low column address
- Write_IIC_Command(0x10);//---set high column address
- Write_IIC_Command(0x40);//--set start line address
- Write_IIC_Command(0x81);//--set contrast control register
- Write_IIC_Command(0xdf);
- Write_IIC_Command(0xa1);//--set segment re-map 0 to 127
- Write_IIC_Command(0xa6);//--set normal display
- Write_IIC_Command(0xa8);//--set multiplex ratio(1 to 64)
- Write_IIC_Command(0x3F);//
- Write_IIC_Command(0xa4);//0xa4,Output follows RAM content;0xa5,Output ignores RAM content
- Write_IIC_Command(0xd3);//-set display offset
- Write_IIC_Command(0x00);//-not offset
- Write_IIC_Command(0xd5);//--set display clock divide ratio/oscillator frequency
- Write_IIC_Command(0xf0);//--set divide ratio
- Write_IIC_Command(0xd9);//--set pre-charge period
- Write_IIC_Command(0x22); //
- Write_IIC_Command(0xda);//--set com pins hardware configuration
- Write_IIC_Command(0x12);
- Write_IIC_Command(0xdb);//--set vcomh
- Write_IIC_Command(0x20);//0x20,0.77xVcc
- Write_IIC_Command(0x8d);//--set DC-DC enable
- Write_IIC_Command(0x14);//
- Write_IIC_Command(0xaf);//--turn on oled panel
- }
復(fù)制代碼
|
|