drivers: ssd16xx: rework function to clear panel buffer at init
Rework function to clear panel buffer to use less memory and propagate the errors. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
This commit is contained in:
parent
e36c2699e4
commit
75fb9ee143
1 changed files with 24 additions and 16 deletions
|
@ -378,7 +378,8 @@ static int ssd16xx_clear_cntlr_mem(const struct device *dev, uint8_t ram_cmd,
|
||||||
uint16_t panel_h = config->height / EPD_PANEL_NUMOF_ROWS_PER_PAGE;
|
uint16_t panel_h = config->height / EPD_PANEL_NUMOF_ROWS_PER_PAGE;
|
||||||
uint16_t last_gate = config->width - 1;
|
uint16_t last_gate = config->width - 1;
|
||||||
uint8_t scan_mode = SSD16XX_DATA_ENTRY_XIYDY;
|
uint8_t scan_mode = SSD16XX_DATA_ENTRY_XIYDY;
|
||||||
uint8_t clear_page[256]; /* User large array for now */
|
uint8_t clear_page[64];
|
||||||
|
int err;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Clear unusable memory area when the resolution of the panel is not
|
* Clear unusable memory area when the resolution of the panel is not
|
||||||
|
@ -388,28 +389,35 @@ static int ssd16xx_clear_cntlr_mem(const struct device *dev, uint8_t ram_cmd,
|
||||||
panel_h += 1;
|
panel_h += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ssd16xx_write_cmd(dev, SSD16XX_CMD_ENTRY_MODE, &scan_mode, 1)) {
|
err = ssd16xx_write_cmd(dev, SSD16XX_CMD_ENTRY_MODE, &scan_mode, 1);
|
||||||
return -EIO;
|
if (err < 0) {
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ssd16xx_set_ram_param(dev, SSD16XX_PANEL_FIRST_PAGE,
|
err = ssd16xx_set_ram_param(dev, SSD16XX_PANEL_FIRST_PAGE,
|
||||||
panel_h - 1,
|
panel_h - 1, last_gate,
|
||||||
last_gate,
|
SSD16XX_PANEL_FIRST_GATE);
|
||||||
SSD16XX_PANEL_FIRST_GATE)) {
|
if (err < 0) {
|
||||||
return -EIO;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ssd16xx_set_ram_ptr(dev, SSD16XX_PANEL_FIRST_PAGE,
|
err = ssd16xx_set_ram_ptr(dev, SSD16XX_PANEL_FIRST_PAGE, last_gate);
|
||||||
last_gate)) {
|
if (err < 0) {
|
||||||
return -EIO;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
memset(clear_page, 0xff, sizeof(clear_page));
|
memset(clear_page, 0xff, sizeof(clear_page));
|
||||||
for (int i = 0; i < panel_h; i++) {
|
for (int h = 0; h < panel_h; h++) {
|
||||||
if (ssd16xx_write_cmd(dev, ram_cmd, clear_page,
|
size_t x = config->width;
|
||||||
sizeof(clear_page))) {
|
|
||||||
return -EIO;
|
while (x) {
|
||||||
|
size_t l = MIN(x, sizeof(clear_page));
|
||||||
|
|
||||||
|
x -= l;
|
||||||
|
err = ssd16xx_write_cmd(dev, ram_cmd, clear_page, l);
|
||||||
|
if (err < 0) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue