View previous topic :: View next topic |
Author |
Message |
spilz
Joined: 30 Jan 2012 Posts: 219
|
Oled Display 128x64 i2c Driver |
Posted: Wed Nov 13, 2013 6:59 am |
|
|
hello,
I'm trying to write a driver to control an Oled display 128x64 via i2c.
The display is used for "multiwii" card with arduino and you can find it on ebay.com : "Crius OLED Display"
There is a library for Aduino here:
http://www.wide.hk/download/i2c_OLED.rar
I'm trying to translate the library from Arduino to PICC CCS but I'm only able to have full screen black or full screen white, I'm not able to change only one pixel :(
my code :
Code: | #ifndef i2c_SDA
#define i2c_SDA PIN_B0
#define i2c_SCL PIN_B1
#endif
#use i2c(master, sda=i2c_SDA, scl=i2c_SCL)
#define OLED_address 0b01111000
void sendcommand(int com)
{
i2c_start();
i2c_write(OLED_address);
i2c_write(0x80);
i2c_write(com);
i2c_stop();
}
void Senddata(int data)
{
i2c_start();
i2c_write(OLED_address);
i2c_write(0x40);
i2c_write(data);
i2c_stop();
}
void clear_display(void)
{
int i,k;
for(k=0;k<8;k++)
{
setXY(k,0);
{
for(i=0;i<128;i++) //clear all COL
{
Senddata(0); //clear all COL
//delay(10);
}
}
}
}
void setXY(int row,int col)
{
sendcommand(0xb0+row); //set page address
sendcommand(0x00+(8*col&0x0f)); //set low col address
sendcommand(0x10+((8*col>>4)&0x0f)); //set high col address
}
void init_OLED(void)
{
sendcommand(0xae); //display off
delay_ms(50);
//----------------------------REVERSE comments-----------------------
// sendcommand(0xa0); //seg re-map 0->127(default)
// sendcommand(0xa1); //seg re-map 127->0
// sendcommand(0xc8);
// delay(1000);
//----------------------------REVERSE comments-----------------------
sendcommand(0xaf); //display on
delay_ms(50);
}
|
and in main.c :
Code: | init_OLED();
delay_ms(10);
clear_display();
delay_ms(50);
setXY(1,1);
Senddata(0xF0); // to have 4 pixels different |
Does anyone already use this screen?
Does anyone know what is wrong with my code?
Thanks for your help
Spilz |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Nov 13, 2013 7:08 pm |
|
|
Quote: | I'm trying to write a driver to control an Oled display 128x64 via i2c.
The display is used for "multiwii" card with arduino and you can find it on
ebay.com : "Crius OLED Display" |
Post a link to the data sheet for the OLED display. I want to see the
i2c protocol used, and also the i2c slave address for the device.
Also, post a link to the schematic for the OLED board. Does the board
have pull-up resistors on it ?
Also, post your PIC and your CCS compiler version.
And post a link to the OLED board that you actually bought.
There are many of them on EBay that have the description that you gave. |
|
|
MikeW
Joined: 15 Sep 2003 Posts: 184 Location: Warrington UK
|
|
Posted: Sat Nov 16, 2013 1:45 am |
|
|
for what it's worth, I spent months trying to get these to work.
I succeeded in writing text, and getting it up and running, but havent managed to get anymore done.
The BIG problem is that the display controller is probably an SSD1306 or use similar.
the only way to drive them is in page mode, where basically you have 8 lines across, each line being 8 pixels wide.
Ardinuo's use Atmel AVR's and they all have enough ram ( >2K ) so the driver sets up a ram buffer, the line/circle/text routines write to ram.
Then, the ram is written as a block of 8 pages to the display.
its almost impossible to write to the display in "pixel by pixel" mode
Last edited by MikeW on Sat Nov 16, 2013 5:26 am; edited 1 time in total |
|
|
spilz
Joined: 30 Jan 2012 Posts: 219
|
|
Posted: Sat Nov 16, 2013 1:51 am |
|
|
I agree with that, you can not write pixel by pixel, but I hope be able to read 8 pixels with i2c and change the one I want...
Can you Help me/us to write text, it's a good start.
Thanks for your help.
@PCM programmer:
I don't have a lot of information about this board :(
I'm trying to find a link for datasheet. |
|
|
MikeW
Joined: 15 Sep 2003 Posts: 184 Location: Warrington UK
|
|
Posted: Sat Nov 16, 2013 5:33 am |
|
|
I dont think you can read back, only write.
I will try to find my code of several months ago, but it will take me a few days. I had many weeks trying I2C/SPI, so I must get the hardware out and get it up and running before I send it to you. |
|
|
danvica
Joined: 22 Nov 2013 Posts: 4
|
|
Posted: Wed Nov 27, 2013 2:35 pm |
|
|
I did a test device using an Oled display. You can see it at http://www.edaboard.com/thread263663.html#post1128778
I don't remember the controller but tomorrow I can send you some info... it would be really good having a standard driver...i remember i spent several days trying to improve speed....
Daniele |
|
|
|