#include "user_lvgl_disp.h" void _epd_set_px_cb(lv_disp_drv_t *disp_drv, uint8_t *buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y, lv_color_t color, lv_opa_t opa) { depg0213_epd_t *epd = disp_drv->user_data; uint16_t byte_index; uint8_t bit_index; if(epd->direction == DEPG0213_HORIZONTAL) { byte_index = x + (y / 8) * buf_w; bit_index = y & 7; } else if(epd->direction == DEPG0213_HORIZONTAL_INVERSE) { byte_index = x + (y / 8) * buf_w; bit_index = 7 - (y & 7); } else { byte_index = y + (x / 8) * buf_w; bit_index = x & 7; } if(color.full) { buf[byte_index] |= 1U << bit_index; } else { buf[byte_index] &= ~(1U << bit_index); } } void _epd_rounder_cb(lv_disp_drv_t *disp_drv, lv_area_t *area) { depg0213_epd_t *epd = disp_drv->user_data; if(epd->direction == DEPG0213_HORIZONTAL || epd->direction == DEPG0213_HORIZONTAL_INVERSE) { area->y1 = (area->y1 / 8) * 8; area->y2 = (area->y2 / 8) * 8 + 7; } else { area->x1 = (area->x1 / 8) * 8; area->x2 = (area->x2 / 8) * 8 + 7; } } void _epd_flush_cb(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p) { depg0213_epd_t *epd = disp_drv->user_data; if(depg0213_epd_load(epd, color_p, color_p, area->x1, area->x2, area->y1, area->y2) != DEPG0213_OK) { return; } if(lv_disp_flush_is_last(disp_drv)) { if(depg0213_epd_update(epd) != DEPG0213_OK) return; } lv_disp_flush_ready(disp_drv); }