add full partial and full refresh

This commit is contained in:
gemu2015 2021-04-11 07:49:13 +02:00
parent be236472fe
commit b9110f602f
3 changed files with 30 additions and 9 deletions

View File

@ -44,10 +44,14 @@
extern uint8_t *buffer;
int temperature;
int temperature = 25;
EpdiyHighlevelState hl;
uint16_t Epd47::GetColorFromIndex(uint8_t index) {
return index & 0xf;
}
Epd47::Epd47(int16_t dwidth, int16_t dheight) : Renderer(dwidth, dheight) {
width = dwidth;
height = dheight;
@ -63,11 +67,27 @@ int32_t Epd47::Init(void) {
void Epd47::DisplayInit(int8_t p, int8_t size, int8_t rot, int8_t font) {
if (p == DISPLAY_INIT_FULL) {
if (p == DISPLAY_INIT_MODE) {
epd_poweron();
epd_clear();
epd_poweroff();
}
if (p == DISPLAY_INIT_FULL) {
memset(hl.back_fb, 0xff, width * height / 2);
epd_poweron();
epd_clear();
epd_hl_update_screen(&hl, MODE_GC16, temperature);
epd_poweroff();
return;
}
if (p == DISPLAY_INIT_PARTIAL) {
memset(hl.back_fb, 0xff, width * height / 2);
epd_poweron();
epd_hl_update_screen(&hl, MODE_GL16, temperature);
epd_poweroff();
return;
}
setRotation(rot);
setTextWrap(false);
cp437(true);
@ -94,6 +114,7 @@ void Epd47::fillScreen(uint16_t color) {
void Epd47::drawPixel(int16_t x, int16_t y, uint16_t color) {
uint16_t xp = x;
uint16_t yp = y;
uint8_t *buf_ptr;
switch (getRotation()) {
case 1:
@ -107,14 +128,13 @@ uint16_t yp = y;
case 3:
_swap(xp, yp);
yp = height - yp - 1;
break;
}
uint32_t maxsize = width * height / 2;
uint8_t *buf_ptr = &buffer[yp * width / 2 + xp / 2];
if ((uint32_t)buf_ptr >= (uint32_t)buffer + maxsize) {
return;
}
if (xp >= width) return;
if (yp >= height) return;
buf_ptr = &buffer[yp * width / 2 + xp / 2];
if (xp % 2) {
*buf_ptr = (*buf_ptr & 0x0F) | (color << 4);

View File

@ -51,6 +51,7 @@ public:
void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
void setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
void pushColors(uint16_t *data, uint16_t len, boolean first);
uint16_t GetColorFromIndex(uint8_t index);
private:
uint16_t width;
uint16_t height;

View File

@ -53,7 +53,7 @@ void EpdInitDriver47(void) {
epd47->Init();
renderer = epd47;
renderer->DisplayInit(DISPLAY_INIT_FULL, Settings.display_size, Settings.display_rotate, Settings.display_font);
renderer->DisplayInit(DISPLAY_INIT_MODE, Settings.display_size, Settings.display_rotate, Settings.display_font);
renderer->setTextColor(EPD47_BLACK, EPD47_WHITE);
#ifdef SHOW_SPLASH