This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Porting SSD1306 for Oled

I need to port ssd1306 library for oled to nrf51822.

so i tested following code. but it's not worked.

main(){
    if (!twi_master_init())
    {
        return false;
     }
     ssd1306_init();
}
static bool ssd1306_lcd_set_instruction(uint8_t instr)
{
    nrf_delay_us(10000);
    data_buffer[0] = 0x00;
    data_buffer[1] = instr;
    return twi_master_transfer(SSD1306_SA << 1, data_buffer, 2, TWI_ISSUE_STOP);
}
bool ssd1306_init(void)
{
if (!ssd1306_lcd_set_instruction(0xAE)) <- not worked , returns false
    return false;
	if (!ssd1306_lcd_set_instruction(0x00)) 
    return false;
	if (!ssd1306_lcd_set_instruction(0x10)) 
    return false;
	if (!ssd1306_lcd_set_instruction(0x40))
    return false;
	if (!ssd1306_lcd_set_instruction(0x81)) 
    return false;
	if (!ssd1306_lcd_set_instruction(0xCF)) 
    return false;
	if (!ssd1306_lcd_set_instruction(0xA1)) 
    return false;
	if (!ssd1306_lcd_set_instruction(0xC8))
    return false;
	if (!ssd1306_lcd_set_instruction(0xA6))
    return false;
	if (!ssd1306_lcd_set_instruction(0xA8)) 
    return false;
	if (!ssd1306_lcd_set_instruction(0x3F)) 
    return false;
	if (!ssd1306_lcd_set_instruction(0xD3)) 
    return false;
	if (!ssd1306_lcd_set_instruction(0x00)) 
    return false;
	if (!ssd1306_lcd_set_instruction(0xD5)) 
    return false;
	if (!ssd1306_lcd_set_instruction(0x80)) 
    return false;
	if (!ssd1306_lcd_set_instruction(0xD9)) 
    return false;
	if (!ssd1306_lcd_set_instruction(0xF1)) 
    return false;
	if (!ssd1306_lcd_set_instruction(0xDA)) 
    return false;
	if (!ssd1306_lcd_set_instruction(0x12)) 
    return false;
	if (!ssd1306_lcd_set_instruction(0xDB)) 
    return false;
	if (!ssd1306_lcd_set_instruction(0x40)) 
    return false;
	if (!ssd1306_lcd_set_instruction(0x20)) 
    return false;
	if (!ssd1306_lcd_set_instruction(0x02)) 
    return false;
	if (!ssd1306_lcd_set_instruction(0x8D))
    return false;
	if (!ssd1306_lcd_set_instruction(0x14)) 
    return false;
	if (!ssd1306_lcd_set_instruction(0xA4)) 
    return false;
	if (!ssd1306_lcd_set_instruction(0xA6)) 
    return false;

return ssd1306_lcd_set_instruction(0xAF);               
}

Another question. How can I draw screen? Thank you all..

void ssd1306_fillscreen(uint8_t fill_Data)
 {
uint8_t m,n;
for(m=0;m<8;m++)
{
	ssd1306_lcd_set_instruction(0xb0+m);	//page0-page1
	ssd1306_lcd_set_instruction(0x00);		//low column start address
	ssd1306_lcd_set_instruction(0x10);		//high column start address
	
	nrf_delay_us(1000);
	data_buffer[0] = DATA_SET; // 0x40
	twi_master_transfer(SSD1306_SA << 1, data_buffer, 1, TWI_DONT_ISSUE_STOP);
	for(n=0;n<127;n++)
	{
		data_buffer[0] = fill_Data;
		twi_master_transfer(SSD1306_SA << 1, data_buffer, 1, TWI_DONT_ISSUE_STOP);
		//ssd1306_send_byte(fill_Data);
	}
	data_buffer[0] = fill_Data;
	twi_master_transfer(SSD1306_SA << 1, data_buffer, 1, TWI_ISSUE_STOP);
	
	//ssd1306_send_data_stop();
}
 }
Parents
  • Currently I'm using the SSD1306 in the vertical addressing mode, this seems to be the easiest mode to use, The hardware horizontal scrolling is farily useless. If you only have a 128x32 display you can do vertical scrolling by writing to the start line register. However the display I'm using for prototyping has a rather nasty bug: http://youtu.be/nIlNApuFGXo Writing the entire frame every frametime works just fine: http://youtu.be/KM-mhbYWSJ8

    The SSD1306 4 wire SPI interface has a command/data pin, chip select, clock and MOSI pins. I do one command transaction to configure the address mode, then a data transaction to clock the entire 512 byte frame buffer (128x32x1bpp) and then an optional transaction to update the start line (to reduce potential tearing). Once I queue up the transactions all the data motion and setting the cs/dc lines is handled by the SPI interrupt handler.

Reply
  • Currently I'm using the SSD1306 in the vertical addressing mode, this seems to be the easiest mode to use, The hardware horizontal scrolling is farily useless. If you only have a 128x32 display you can do vertical scrolling by writing to the start line register. However the display I'm using for prototyping has a rather nasty bug: http://youtu.be/nIlNApuFGXo Writing the entire frame every frametime works just fine: http://youtu.be/KM-mhbYWSJ8

    The SSD1306 4 wire SPI interface has a command/data pin, chip select, clock and MOSI pins. I do one command transaction to configure the address mode, then a data transaction to clock the entire 512 byte frame buffer (128x32x1bpp) and then an optional transaction to update the start line (to reduce potential tearing). Once I queue up the transactions all the data motion and setting the cs/dc lines is handled by the SPI interrupt handler.

Children
No Data
Related