Skip to content

Commit

Permalink
drivers: ssd1306: Write data from any coordinate
Browse files Browse the repository at this point in the history
Support write data from any coordinate.
ssd1306 can work with lvgl

Signed-off-by: Frank Li <lgl88911@163.com>
  • Loading branch information
lgl88911 authored and carlescufi committed Sep 7, 2019
1 parent a28eba9 commit a55620e
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions drivers/display/ssd1306.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,14 @@ int ssd1306_write(const struct device *dev, const u16_t x, const u16_t y,
return -1;
}

if (x != 0U && y != 0U) {
#if defined(CONFIG_SSD1306_DEFAULT)
struct ssd1306_data *driver = dev->driver_data;

if ((y & 0x7) != 0U) {
LOG_ERR("Unsupported origin");
return -1;
}

#if defined(CONFIG_SSD1306_DEFAULT)
struct ssd1306_data *driver = dev->driver_data;

u8_t cmd_buf[] = {
SSD1306_CONTROL_BYTE_CMD,
SSD1306_SET_MEM_ADDRESSING_MODE,
Expand All @@ -254,15 +254,15 @@ int ssd1306_write(const struct device *dev, const u16_t x, const u16_t y,
SSD1306_CONTROL_BYTE_CMD,
SSD1306_SET_COLUMN_ADDRESS,
SSD1306_CONTROL_BYTE_CMD,
0,
x,
SSD1306_CONTROL_BYTE_CMD,
(SSD1306_PANEL_NUMOF_COLUMS - 1),
(x + desc->width - 1),
SSD1306_CONTROL_BYTE_CMD,
SSD1306_SET_PAGE_ADDRESS,
SSD1306_CONTROL_BYTE_CMD,
0,
y/8,
SSD1306_CONTROL_LAST_BYTE_CMD,
(SSD1306_PANEL_NUMOF_PAGES - 1)
((y + desc->height)/8 - 1)
};

if (i2c_write(driver->i2c, cmd_buf, sizeof(cmd_buf),
Expand All @@ -276,6 +276,11 @@ int ssd1306_write(const struct device *dev, const u16_t x, const u16_t y,
(u8_t *)buf, desc->buf_size);

#elif defined(CONFIG_SSD1306_SH1106_COMPATIBLE)
if (x != 0U && y != 0U) {
LOG_ERR("Unsupported origin");
return -1;
}

if (desc->buf_size !=
(SSD1306_PANEL_NUMOF_PAGES * DT_INST_0_SOLOMON_SSD1306FB_WIDTH)) {
return -1;
Expand Down

0 comments on commit a55620e

Please sign in to comment.