OLED: update to I2C API

This commit is contained in:
King Kévin 2018-03-21 14:14:17 +01:00
parent 2fec5cf247
commit 6a35bdc263
1 changed files with 5 additions and 5 deletions

View File

@ -65,7 +65,7 @@ bool oled_ssd1306_setup(void)
// Addressing Setting
0x20, 0x00 // Set Memory Addressing Mode: Horizontal Addressing Mode
}; // command to initialize the display
return i2c_master_slave_write(OLED_SSD1306_I2C, OLED_SSD1306_SLAVE, false, oled_init, LENGTH(oled_init)); // send command to initialize display
return I2C_MASTER_RC_NONE==i2c_master_slave_write(OLED_SSD1306_I2C, OLED_SSD1306_SLAVE, false, oled_init, LENGTH(oled_init)); // send command to initialize display
}
void oled_ssd1306_on(void)
@ -117,19 +117,19 @@ void oled_ssd1306_display(const uint8_t* display_data, uint16_t display_length)
0x10 // Set Higher Column Start Address for Page Addressing Mode: 0
}; // command to set addressing mode
i2c_master_slave_write(OLED_SSD1306_I2C, OLED_SSD1306_SLAVE, false, oled_start_page, LENGTH(oled_start_page)); // send command to set addressing mode
if (!i2c_master_start(OLED_SSD1306_I2C)) { // send start condition
if (I2C_MASTER_RC_NONE!=i2c_master_start(OLED_SSD1306_I2C)) { // send start condition
return;
}
if (!i2c_master_select_slave(OLED_SSD1306_I2C, OLED_SSD1306_SLAVE, false, true)) { // select OLED display
if (I2C_MASTER_RC_NONE!=i2c_master_select_slave(OLED_SSD1306_I2C, OLED_SSD1306_SLAVE, false, true)) { // select OLED display
return;
}
const uint8_t oled_data[] = {
0x40, // control byte: continuous (multiple byes), data
};
if (!i2c_master_write(OLED_SSD1306_I2C, oled_data, LENGTH(oled_data))) { // send data header
if (I2C_MASTER_RC_NONE!=i2c_master_write(OLED_SSD1306_I2C, oled_data, LENGTH(oled_data))) { // send data header
return;
}
if (!i2c_master_write(OLED_SSD1306_I2C, display_data, display_length)) { // send template picture to display
if (I2C_MASTER_RC_NONE!=i2c_master_write(OLED_SSD1306_I2C, display_data, display_length)) { // send template picture to display
return;
}
i2c_master_stop(OLED_SSD1306_I2C); // send stop condition