SSD1306 AVR I2C | Display is bugging

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello!

I've been searching the web for an avr driver code for my ssd1306 128x64 oled i2c display, but I couldn't find anything just the damn arduino codes that are written in c++, but luckily I've found pieces of code on forums. Unfortunately there is a problem:

 

The code I'm using is this:

 

static void SD1306_Write_Cmd(uint8_t Cmd)
{
	uint8_t control = 0x00; // some use 0X00 other examples use 0X80. I tried both
	i2c_start(display_address);
	i2c_write(control); // This is Command
	i2c_write(Cmd);
	i2c_stop();
}


void display_init()
{
	SD1306_Write_Cmd(0xae); //--turn off oled panel
	SD1306_Write_Cmd(0x00); //--set low column address
	SD1306_Write_Cmd(0x10); //--set high column address
	SD1306_Write_Cmd(0x40); //--set start line address
	SD1306_Write_Cmd(0xb0); //--set page address
	SD1306_Write_Cmd(0x81); //--set contrast control register
	SD1306_Write_Cmd(0xff);
	SD1306_Write_Cmd(0xa1); //--set segment re-map 127 to 0   a0:0 to seg127
	SD1306_Write_Cmd(0xa6); //--set normal display
	SD1306_Write_Cmd(0xc9); //--set com(N-1)to com0  c0:com0 to com(N-1)
	SD1306_Write_Cmd(0xa8); //--set multiples ratio(1to64)
	SD1306_Write_Cmd(0x3f); //--1/64 duty
	SD1306_Write_Cmd(0xd3); //--set display offset
	SD1306_Write_Cmd(0x00); //--not offset
	SD1306_Write_Cmd(0xd5); //--set display clock divide ratio/oscillator frequency
	SD1306_Write_Cmd(0x80); //--set divide ratio
	SD1306_Write_Cmd(0xd9); //--set pre-charge period
	SD1306_Write_Cmd(0xf1);
	SD1306_Write_Cmd(0xda); //--set com pins hardware configuration
	SD1306_Write_Cmd(0x12);
	SD1306_Write_Cmd(0xdb); //--set vcomh
	SD1306_Write_Cmd(0x40);
	SD1306_Write_Cmd(0x8d); //--set chare pump enable/disable
	SD1306_Write_Cmd(0x14); //--set(0x10) disable
	SD1306_Write_Cmd(0xaf); //--turn on oled panel
	
}

I think other for the code is not needed, fcpu is 11059200, F_SCL 100000UL,prescaler 1 and TWBR_val ((((F_CPU / F_SCL) / Prescaler) - 16 ) / 2)

 

If there is any finished code that I can use to display pixels/text it would be very appreciated. Thank you very much!

Code is everything, code is life :D
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Heres a version that compiles with the imagecraft compiler, but it should be readable.

 

Attachment(s): 

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sweet man thanks! At first I got the init and the result was the same, all I had to do is do is clear the screen and after that everything worked. Many many thanks!

Code is everything, code is life :D
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

One small question, where did you get the hex data for the image? (What converter)

THanks!

Code is everything, code is life :D
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Image means picture, right? No pictures in that zip file. If you mean the 5x7 7x9 fonts, the source code is there. Its just a macro where you peck in 1s and 0s where you want pixels.

 

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No, I mean the usage of show_bitmap() function and you have 2 arrays logo1 and logo2, how did you get those hex values?

Thanks

Code is everything, code is life :D
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I copied the 1306 init stuff from crystalfonts, and those were in there. There are several 'image to c' converters. I'd say you could search here, but the search is iffy. I think newhavendisplays has one on their site.

 

Imagecraft compiler user