refactor(display): Move clear to unblank for EPD driver.
This commit is contained in:
parent
c4a47c08de
commit
e3efffa9a8
1 changed files with 53 additions and 57 deletions
|
@ -115,28 +115,6 @@ static int il0323_update_display(const struct device *dev) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int il0323_blanking_off(const struct device *dev) {
|
|
||||||
struct il0323_data *driver = dev->data;
|
|
||||||
|
|
||||||
if (blanking_on) {
|
|
||||||
/* Update EPD pannel in normal mode */
|
|
||||||
il0323_busy_wait(driver);
|
|
||||||
if (il0323_update_display(dev)) {
|
|
||||||
return -EIO;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
blanking_on = false;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int il0323_blanking_on(const struct device *dev) {
|
|
||||||
blanking_on = true;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int il0323_write(const struct device *dev, const uint16_t x, const uint16_t y,
|
static int il0323_write(const struct device *dev, const uint16_t x, const uint16_t y,
|
||||||
const struct display_buffer_descriptor *desc, const void *buf) {
|
const struct display_buffer_descriptor *desc, const void *buf) {
|
||||||
struct il0323_data *driver = dev->data;
|
struct il0323_data *driver = dev->data;
|
||||||
|
@ -208,6 +186,58 @@ static int il0323_read(const struct device *dev, const uint16_t x, const uint16_
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int il0323_clear_and_write_buffer(const struct device *dev, uint8_t pattern, bool update) {
|
||||||
|
struct display_buffer_descriptor desc = {
|
||||||
|
.buf_size = IL0323_NUMOF_PAGES,
|
||||||
|
.width = EPD_PANEL_WIDTH,
|
||||||
|
.height = 1,
|
||||||
|
.pitch = EPD_PANEL_WIDTH,
|
||||||
|
};
|
||||||
|
uint8_t *line;
|
||||||
|
|
||||||
|
line = k_malloc(IL0323_NUMOF_PAGES);
|
||||||
|
if (line == NULL) {
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(line, pattern, IL0323_NUMOF_PAGES);
|
||||||
|
for (int i = 0; i < EPD_PANEL_HEIGHT; i++) {
|
||||||
|
il0323_write(dev, 0, i, &desc, line);
|
||||||
|
}
|
||||||
|
|
||||||
|
k_free(line);
|
||||||
|
|
||||||
|
if (update == true) {
|
||||||
|
if (il0323_update_display(dev)) {
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int il0323_blanking_off(const struct device *dev) {
|
||||||
|
struct il0323_data *driver = dev->data;
|
||||||
|
|
||||||
|
if (blanking_on) {
|
||||||
|
/* Update EPD pannel in normal mode */
|
||||||
|
il0323_busy_wait(driver);
|
||||||
|
if (il0323_clear_and_write_buffer(dev, 0xff, true)) {
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
blanking_on = false;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int il0323_blanking_on(const struct device *dev) {
|
||||||
|
blanking_on = true;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void *il0323_get_framebuffer(const struct device *dev) {
|
static void *il0323_get_framebuffer(const struct device *dev) {
|
||||||
LOG_ERR("not supported");
|
LOG_ERR("not supported");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -247,36 +277,6 @@ static int il0323_set_pixel_format(const struct device *dev, const enum display_
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int il0323_clear_and_write_buffer(const struct device *dev, uint8_t pattern, bool update) {
|
|
||||||
struct display_buffer_descriptor desc = {
|
|
||||||
.buf_size = IL0323_NUMOF_PAGES,
|
|
||||||
.width = EPD_PANEL_WIDTH,
|
|
||||||
.height = 1,
|
|
||||||
.pitch = EPD_PANEL_WIDTH,
|
|
||||||
};
|
|
||||||
uint8_t *line;
|
|
||||||
|
|
||||||
line = k_malloc(IL0323_NUMOF_PAGES);
|
|
||||||
if (line == NULL) {
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(line, pattern, IL0323_NUMOF_PAGES);
|
|
||||||
for (int i = 0; i < EPD_PANEL_HEIGHT; i++) {
|
|
||||||
il0323_write(dev, 0, i, &desc, line);
|
|
||||||
}
|
|
||||||
|
|
||||||
k_free(line);
|
|
||||||
|
|
||||||
if (update == true) {
|
|
||||||
if (il0323_update_display(dev)) {
|
|
||||||
return -EIO;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int il0323_controller_init(const struct device *dev) {
|
static int il0323_controller_init(const struct device *dev) {
|
||||||
struct il0323_data *driver = dev->data;
|
struct il0323_data *driver = dev->data;
|
||||||
uint8_t tmp[IL0323_TRES_REG_LENGTH];
|
uint8_t tmp[IL0323_TRES_REG_LENGTH];
|
||||||
|
@ -350,10 +350,6 @@ static int il0323_controller_init(const struct device *dev) {
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (il0323_clear_and_write_buffer(dev, 0xff, false)) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue