CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Oled Display 128x64 i2c Driver

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
spilz



Joined: 30 Jan 2012
Posts: 220

View user's profile Send private message

Oled Display 128x64 i2c Driver
PostPosted: Wed Nov 13, 2013 6:59 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Nov 13, 2013 7:08 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Nov 16, 2013 1:45 am     Reply with quote

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: 220

View user's profile Send private message

PostPosted: Sat Nov 16, 2013 1:51 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Nov 16, 2013 5:33 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Nov 27, 2013 2:35 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group