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();
}
}