Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions drivers/display/ssd1306.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,33 +169,28 @@ static inline int ssd1306_set_charge_pump(const struct device *dev)
DT_INST_0_SOLOMON_SSD1306FB_BASE_ADDRESS);
}

int ssd1306_resume(const struct device *dev)
static int ssd1306_resume(const struct device *dev)
{
struct ssd1306_data *driver = dev->driver_data;
/* set display on */
return ssd1306_reg_write(driver, SSD1306_CONTROL_LAST_BYTE_CMD,
SSD1306_DISPLAY_ON);
}

int ssd1306_suspend(const struct device *dev)
static int ssd1306_suspend(const struct device *dev)
{
struct ssd1306_data *driver = dev->driver_data;
/* set display on */
return ssd1306_reg_write(driver, SSD1306_CONTROL_LAST_BYTE_CMD,
SSD1306_DISPLAY_OFF);
}

int ssd1306_write_page(const struct device *dev, u8_t page, void const *data,
size_t length)
#if defined(CONFIG_SSD1306_SH1106_COMPATIBLE)
static int ssd1306_write_page(const struct device *dev, u8_t page,
void const *data, size_t length)
{
struct ssd1306_data *driver = dev->driver_data;
u8_t cmd_buf[] = {
#ifdef OLED_PANEL_CONTROLLER_SSD1306
SSD1306_CONTROL_BYTE_CMD,
SSD1306_SET_MEM_ADDRESSING_MODE,
SSD1306_CONTROL_BYTE_CMD,
SSD1306_SET_MEM_ADDRESSING_PAGE,
#endif
SSD1306_CONTROL_BYTE_CMD,
SSD1306_SET_LOWER_COL_ADDRESS |
(DT_INST_0_SOLOMON_SSD1306FB_SEGMENT_OFFSET &
Expand Down Expand Up @@ -226,17 +221,21 @@ int ssd1306_write_page(const struct device *dev, u8_t page, void const *data,
SSD1306_CONTROL_LAST_BYTE_DATA,
data, length);
}
#endif

int ssd1306_write(const struct device *dev, const u16_t x, const u16_t y,
const struct display_buffer_descriptor *desc,
const void *buf)
static int ssd1306_write(const struct device *dev, const u16_t x, const u16_t y,
const struct display_buffer_descriptor *desc,
const void *buf)
{
size_t buf_len;

if (desc->pitch < desc->width) {
LOG_ERR("Pitch is smaller then width");
return -1;
}

if (buf == NULL || desc->buf_size == 0U) {
buf_len = MIN(desc->buf_size, desc->height * desc->width / 8);
if (buf == NULL || buf_len == 0U) {
LOG_ERR("Display buffer is not available");
return -1;
}
Expand Down Expand Up @@ -282,7 +281,7 @@ int ssd1306_write(const struct device *dev, const u16_t x, const u16_t y,
return i2c_burst_write(driver->i2c,
DT_INST_0_SOLOMON_SSD1306FB_BASE_ADDRESS,
SSD1306_CONTROL_LAST_BYTE_DATA,
(u8_t *)buf, desc->buf_size);
(u8_t *)buf, buf_len);

#elif defined(CONFIG_SSD1306_SH1106_COMPATIBLE)
if (x != 0U && y != 0U) {
Expand Down Expand Up @@ -329,7 +328,7 @@ static int ssd1306_set_brightness(const struct device *dev,
return -ENOTSUP;
}

int ssd1306_set_contrast(const struct device *dev, const u8_t contrast)
static int ssd1306_set_contrast(const struct device *dev, const u8_t contrast)
{
struct ssd1306_data *driver = dev->driver_data;
u8_t cmd_buf[] = {
Expand Down
6 changes: 4 additions & 2 deletions drivers/display/ssd16xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ static int ssd16xx_write(const struct device *dev, const u16_t x,
{
struct ssd16xx_data *driver = dev->driver_data;
int err;
size_t buf_len;
u16_t x_start;
u16_t x_end;
u16_t y_start;
Expand All @@ -241,7 +242,8 @@ static int ssd16xx_write(const struct device *dev, const u16_t x,
return -EINVAL;
}

if (buf == NULL || desc->buf_size == 0U) {
buf_len = MIN(desc->buf_size, desc->height * desc->width / 8);
if (buf == NULL || buf_len == 0U) {
LOG_ERR("Display buffer is not available");
return -EINVAL;
}
Expand Down Expand Up @@ -311,7 +313,7 @@ static int ssd16xx_write(const struct device *dev, const u16_t x,
}

err = ssd16xx_write_cmd(driver, SSD16XX_CMD_WRITE_RAM, (u8_t *)buf,
desc->buf_size);
buf_len);
if (err < 0) {
return err;
}
Expand Down