|
@@ -16,7 +16,6 @@
|
|
|
GxEPD2_730c_GDEY073D46::GxEPD2_730c_GDEY073D46(int16_t cs, int16_t dc, int16_t rst, int16_t busy) :
|
|
GxEPD2_730c_GDEY073D46::GxEPD2_730c_GDEY073D46(int16_t cs, int16_t dc, int16_t rst, int16_t busy) :
|
|
|
GxEPD2_EPD(cs, dc, rst, busy, LOW, 60000000, WIDTH, HEIGHT, panel, hasColor, hasPartialUpdate, hasFastPartialUpdate)
|
|
GxEPD2_EPD(cs, dc, rst, busy, LOW, 60000000, WIDTH, HEIGHT, panel, hasColor, hasPartialUpdate, hasFastPartialUpdate)
|
|
|
{
|
|
{
|
|
|
- _paged = false;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void GxEPD2_730c_GDEY073D46::clearScreen(uint8_t value)
|
|
void GxEPD2_730c_GDEY073D46::clearScreen(uint8_t value)
|
|
@@ -54,13 +53,41 @@ void GxEPD2_730c_GDEY073D46::writeImage(const uint8_t bitmap[], int16_t x, int16
|
|
|
//Serial.print(w); Serial.print(", "); Serial.print(h); Serial.println(")");
|
|
//Serial.print(w); Serial.print(", "); Serial.print(h); Serial.println(")");
|
|
|
delay(1); // yield() to avoid WDT on ESP8266 and ESP32
|
|
delay(1); // yield() to avoid WDT on ESP8266 and ESP32
|
|
|
if (!_init_display_done) _InitDisplay();
|
|
if (!_init_display_done) _InitDisplay();
|
|
|
- if (_paged && (x == 0) && (w == int16_t(WIDTH)) && (h < int16_t(HEIGHT)))
|
|
|
|
|
|
|
+ if (_initial_write) writeScreenBuffer();
|
|
|
|
|
+ int16_t wb = (w + 7) / 8; // width bytes, bitmaps are padded
|
|
|
|
|
+ x -= x % 8; // byte boundary
|
|
|
|
|
+ w = wb * 8; // byte boundary
|
|
|
|
|
+ int16_t x1 = x < 0 ? 0 : x; // limit
|
|
|
|
|
+ int16_t y1 = y < 0 ? 0 : y; // limit
|
|
|
|
|
+ int16_t w1 = x + w < int16_t(WIDTH) ? w : int16_t(WIDTH) - x; // limit
|
|
|
|
|
+ int16_t h1 = y + h < int16_t(HEIGHT) ? h : int16_t(HEIGHT) - y; // limit
|
|
|
|
|
+ int16_t dx = x1 - x;
|
|
|
|
|
+ int16_t dy = y1 - y;
|
|
|
|
|
+ w1 -= dx;
|
|
|
|
|
+ h1 -= dy;
|
|
|
|
|
+ if ((w1 <= 0) || (h1 <= 0)) return;
|
|
|
|
|
+ _setPartialRamArea(x1, y1, w1, h1);
|
|
|
|
|
+ _writeCommand(0x10);
|
|
|
|
|
+ _startTransfer();
|
|
|
|
|
+ for (int16_t i = 0; i < h1; i++)
|
|
|
{
|
|
{
|
|
|
- //Serial.println("paged");
|
|
|
|
|
- _startTransfer();
|
|
|
|
|
- for (uint32_t i = 0; i < uint32_t(WIDTH) * uint32_t(h) / 8; i++)
|
|
|
|
|
|
|
+ for (int16_t j = 0; j < w1 / 8; j++)
|
|
|
{
|
|
{
|
|
|
- uint8_t data = bitmap[i];
|
|
|
|
|
|
|
+ uint8_t data;
|
|
|
|
|
+ // use wb, h of bitmap for index!
|
|
|
|
|
+ int16_t idx = mirror_y ? j + dx / 8 + ((h - 1 - (i + dy))) * wb : j + dx / 8 + (i + dy) * wb;
|
|
|
|
|
+ if (pgm)
|
|
|
|
|
+ {
|
|
|
|
|
+#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
|
|
|
|
|
+ data = pgm_read_byte(&bitmap[idx]);
|
|
|
|
|
+#else
|
|
|
|
|
+ data = bitmap[idx];
|
|
|
|
|
+#endif
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ data = bitmap[idx];
|
|
|
|
|
+ }
|
|
|
for (int16_t k = 0; k < 4; k++)
|
|
for (int16_t k = 0; k < 4; k++)
|
|
|
{
|
|
{
|
|
|
uint8_t data2 = (data & 0x80 ? 0x10 : 0x00) | (data & 0x40 ? 0x01 : 0x00);
|
|
uint8_t data2 = (data & 0x80 ? 0x10 : 0x00) | (data & 0x40 ? 0x01 : 0x00);
|
|
@@ -68,54 +95,8 @@ void GxEPD2_730c_GDEY073D46::writeImage(const uint8_t bitmap[], int16_t x, int16
|
|
|
_transfer(data2);
|
|
_transfer(data2);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- _endTransfer();
|
|
|
|
|
- if (y + h == HEIGHT) // last page
|
|
|
|
|
- {
|
|
|
|
|
- //Serial.println("paged ended");
|
|
|
|
|
- _paged = false;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- _paged = false;
|
|
|
|
|
- int16_t wb = (w + 7) / 8; // width bytes, bitmaps are padded
|
|
|
|
|
- x -= x % 8; // byte boundary
|
|
|
|
|
- w = wb * 8; // byte boundary
|
|
|
|
|
- if ((w <= 0) || (h <= 0)) return;
|
|
|
|
|
- _writeCommand(0x10);
|
|
|
|
|
- _startTransfer();
|
|
|
|
|
- for (int16_t i = 0; i < int16_t(HEIGHT); i++)
|
|
|
|
|
- {
|
|
|
|
|
- for (int16_t j = 0; j < int16_t(WIDTH); j += 8)
|
|
|
|
|
- {
|
|
|
|
|
- uint8_t data = 0xFF;
|
|
|
|
|
- if ((j >= x) && (j <= x + w) && (i >= y) && (i < y + h))
|
|
|
|
|
- {
|
|
|
|
|
- uint32_t idx = mirror_y ? (j - x) / 8 + uint32_t((h - 1 - (i - y))) * wb : (j - x) / 8 + uint32_t(i - y) * wb;
|
|
|
|
|
- if (pgm)
|
|
|
|
|
- {
|
|
|
|
|
-#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
|
|
|
|
|
- data = pgm_read_byte(&bitmap[idx]);
|
|
|
|
|
-#else
|
|
|
|
|
- data = bitmap[idx];
|
|
|
|
|
-#endif
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- data = bitmap[idx];
|
|
|
|
|
- }
|
|
|
|
|
- if (invert) data = ~data;
|
|
|
|
|
- }
|
|
|
|
|
- for (int16_t k = 0; k < 4; k++)
|
|
|
|
|
- {
|
|
|
|
|
- uint8_t data2 = (data & 0x80 ? 0x10 : 0x00) | (data & 0x40 ? 0x01 : 0x00);
|
|
|
|
|
- data <<= 2;
|
|
|
|
|
- _transfer(data2);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- _endTransfer();
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ _endTransfer();
|
|
|
delay(1); // yield() to avoid WDT on ESP8266 and ESP32
|
|
delay(1); // yield() to avoid WDT on ESP8266 and ESP32
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -123,18 +104,53 @@ void GxEPD2_730c_GDEY073D46::writeImage(const uint8_t* black, const uint8_t* col
|
|
|
{
|
|
{
|
|
|
if (!black && !color) return;
|
|
if (!black && !color) return;
|
|
|
if (!color) return writeImage(black, x, y, w, h, invert, mirror_y, pgm);
|
|
if (!color) return writeImage(black, x, y, w, h, invert, mirror_y, pgm);
|
|
|
- //Serial.print("writeImage("); Serial.print(x); Serial.print(", "); Serial.print(y); Serial.print(", ");
|
|
|
|
|
|
|
+ //Serial.print("writeImage_3c("); Serial.print(x); Serial.print(", "); Serial.print(y); Serial.print(", ");
|
|
|
//Serial.print(w); Serial.print(", "); Serial.print(h); Serial.println(")");
|
|
//Serial.print(w); Serial.print(", "); Serial.print(h); Serial.println(")");
|
|
|
delay(1); // yield() to avoid WDT on ESP8266 and ESP32
|
|
delay(1); // yield() to avoid WDT on ESP8266 and ESP32
|
|
|
if (!_init_display_done) _InitDisplay();
|
|
if (!_init_display_done) _InitDisplay();
|
|
|
- if (_paged && (x == 0) && (w == int16_t(WIDTH)) && (h < int16_t(HEIGHT)))
|
|
|
|
|
|
|
+ if (_initial_write) writeScreenBuffer();
|
|
|
|
|
+ int16_t wb = (w + 7) / 8; // width bytes, bitmaps are padded
|
|
|
|
|
+ x -= x % 8; // byte boundary
|
|
|
|
|
+ w = wb * 8; // byte boundary
|
|
|
|
|
+ int16_t x1 = x < 0 ? 0 : x; // limit
|
|
|
|
|
+ int16_t y1 = y < 0 ? 0 : y; // limit
|
|
|
|
|
+ int16_t w1 = x + w < int16_t(WIDTH) ? w : int16_t(WIDTH) - x; // limit
|
|
|
|
|
+ int16_t h1 = y + h < int16_t(HEIGHT) ? h : int16_t(HEIGHT) - y; // limit
|
|
|
|
|
+ int16_t dx = x1 - x;
|
|
|
|
|
+ int16_t dy = y1 - y;
|
|
|
|
|
+ w1 -= dx;
|
|
|
|
|
+ h1 -= dy;
|
|
|
|
|
+ if ((w1 <= 0) || (h1 <= 0)) return;
|
|
|
|
|
+ _setPartialRamArea(x1, y1, w1, h1);
|
|
|
|
|
+ _writeCommand(0x10);
|
|
|
|
|
+ _startTransfer();
|
|
|
|
|
+ for (int16_t i = 0; i < h1; i++)
|
|
|
{
|
|
{
|
|
|
- //Serial.println("paged");
|
|
|
|
|
- _startTransfer();
|
|
|
|
|
- for (uint32_t i = 0; i < uint32_t(WIDTH) * uint32_t(h) / 8; i++)
|
|
|
|
|
|
|
+ for (int16_t j = 0; j < w1 / 8; j++)
|
|
|
{
|
|
{
|
|
|
- uint8_t black_data = black[i];
|
|
|
|
|
- uint8_t color_data = color[i];
|
|
|
|
|
|
|
+ uint8_t black_data = 0xFF, color_data = 0xFF;
|
|
|
|
|
+ // use wb, h of bitmap for index!
|
|
|
|
|
+ uint32_t idx = mirror_y ? j + dx / 8 + uint32_t((h - 1 - (i + dy))) * wb : j + dx / 8 + uint32_t(i + dy) * wb;
|
|
|
|
|
+ if (pgm)
|
|
|
|
|
+ {
|
|
|
|
|
+#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
|
|
|
|
|
+ black_data = pgm_read_byte(&black[idx]);
|
|
|
|
|
+ color_data = pgm_read_byte(&color[idx]);
|
|
|
|
|
+#else
|
|
|
|
|
+ black_data = black[idx];
|
|
|
|
|
+ color_data = color[idx];
|
|
|
|
|
+#endif
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ black_data = black[idx];
|
|
|
|
|
+ color_data = color[idx];
|
|
|
|
|
+ }
|
|
|
|
|
+ if (invert)
|
|
|
|
|
+ {
|
|
|
|
|
+ black_data = ~black_data;
|
|
|
|
|
+ color_data = ~color_data;
|
|
|
|
|
+ }
|
|
|
for (int16_t k = 0; k < 4; k++)
|
|
for (int16_t k = 0; k < 4; k++)
|
|
|
{
|
|
{
|
|
|
uint8_t out_data = 0x00;
|
|
uint8_t out_data = 0x00;
|
|
@@ -149,75 +165,21 @@ void GxEPD2_730c_GDEY073D46::writeImage(const uint8_t* black, const uint8_t* col
|
|
|
_transfer(out_data);
|
|
_transfer(out_data);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- _endTransfer();
|
|
|
|
|
- if (y + h == HEIGHT) // last page
|
|
|
|
|
- {
|
|
|
|
|
- //Serial.println("paged ended");
|
|
|
|
|
- _paged = false;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- _paged = false;
|
|
|
|
|
- int16_t wb = (w + 7) / 8; // width bytes, bitmaps are padded
|
|
|
|
|
- x -= x % 8; // byte boundary
|
|
|
|
|
- w = wb * 8; // byte boundary
|
|
|
|
|
- if ((w <= 0) || (h <= 0)) return;
|
|
|
|
|
- _writeCommand(0x10);
|
|
|
|
|
- _startTransfer();
|
|
|
|
|
- for (int16_t i = 0; i < int16_t(HEIGHT); i++)
|
|
|
|
|
- {
|
|
|
|
|
- for (int16_t j = 0; j < int16_t(WIDTH); j += 8)
|
|
|
|
|
- {
|
|
|
|
|
- uint8_t black_data = 0xFF, color_data = 0xFF;
|
|
|
|
|
- if ((j >= x) && (j < x + w) && (i >= y) && (i < y + h))
|
|
|
|
|
- {
|
|
|
|
|
- uint32_t idx = mirror_y ? (j - x) / 8 + uint32_t((h - 1 - (i - y))) * wb : (j - x) / 8 + uint32_t(i - y) * wb;
|
|
|
|
|
- if (pgm)
|
|
|
|
|
- {
|
|
|
|
|
-#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
|
|
|
|
|
- black_data = pgm_read_byte(&black[idx]);
|
|
|
|
|
- color_data = pgm_read_byte(&color[idx]);
|
|
|
|
|
-#else
|
|
|
|
|
- black_data = black[idx];
|
|
|
|
|
- color_data = color[idx];
|
|
|
|
|
-#endif
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- black_data = black[idx];
|
|
|
|
|
- color_data = color[idx];
|
|
|
|
|
- }
|
|
|
|
|
- if (invert)
|
|
|
|
|
- {
|
|
|
|
|
- black_data = ~black_data;
|
|
|
|
|
- color_data = ~color_data;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- for (int16_t k = 0; k < 4; k++)
|
|
|
|
|
- {
|
|
|
|
|
- uint8_t out_data = 0x00;
|
|
|
|
|
- for (int16_t l = 0; l < 2; l++)
|
|
|
|
|
- {
|
|
|
|
|
- out_data <<= 4;
|
|
|
|
|
- if (!(color_data & 0x80)) out_data |= 0x04;
|
|
|
|
|
- else out_data |= black_data & 0x80 ? 0x01 : 0x00;
|
|
|
|
|
- black_data <<= 1;
|
|
|
|
|
- color_data <<= 1;
|
|
|
|
|
- }
|
|
|
|
|
- _transfer(out_data);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- _endTransfer();
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ _endTransfer();
|
|
|
delay(1); // yield() to avoid WDT on ESP8266 and ESP32
|
|
delay(1); // yield() to avoid WDT on ESP8266 and ESP32
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void GxEPD2_730c_GDEY073D46::writeImagePart(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
|
|
void GxEPD2_730c_GDEY073D46::writeImagePart(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
|
|
|
int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
|
|
int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
|
|
|
{
|
|
{
|
|
|
|
|
+ //Serial.print("writeImagePart("); Serial.print(x_part); Serial.print(", "); Serial.print(y_part); Serial.print(", ");
|
|
|
|
|
+ //Serial.print(w_bitmap); Serial.print(", "); Serial.print(h_bitmap); Serial.print(", ");
|
|
|
|
|
+ //Serial.print(x); Serial.print(", "); Serial.print(y); Serial.print(", ");
|
|
|
|
|
+ //Serial.print(w); Serial.print(", "); Serial.print(h); Serial.println(")");
|
|
|
delay(1); // yield() to avoid WDT on ESP8266 and ESP32
|
|
delay(1); // yield() to avoid WDT on ESP8266 and ESP32
|
|
|
|
|
+ if (!_init_display_done) _InitDisplay();
|
|
|
|
|
+ if (_initial_write) writeScreenBuffer();
|
|
|
if ((w_bitmap < 0) || (h_bitmap < 0) || (w < 0) || (h < 0)) return;
|
|
if ((w_bitmap < 0) || (h_bitmap < 0) || (w < 0) || (h < 0)) return;
|
|
|
if ((x_part < 0) || (x_part >= w_bitmap)) return;
|
|
if ((x_part < 0) || (x_part >= w_bitmap)) return;
|
|
|
if ((y_part < 0) || (y_part >= h_bitmap)) return;
|
|
if ((y_part < 0) || (y_part >= h_bitmap)) return;
|
|
@@ -225,7 +187,9 @@ void GxEPD2_730c_GDEY073D46::writeImagePart(const uint8_t bitmap[], int16_t x_pa
|
|
|
x_part -= x_part % 8; // byte boundary
|
|
x_part -= x_part % 8; // byte boundary
|
|
|
w = w_bitmap - x_part < w ? w_bitmap - x_part : w; // limit
|
|
w = w_bitmap - x_part < w ? w_bitmap - x_part : w; // limit
|
|
|
h = h_bitmap - y_part < h ? h_bitmap - y_part : h; // limit
|
|
h = h_bitmap - y_part < h ? h_bitmap - y_part : h; // limit
|
|
|
- x -= x % 8; // byte boundary
|
|
|
|
|
|
|
+ // make x, w multiple of 8
|
|
|
|
|
+ w += x % 8; // adjust for byte boundary of x
|
|
|
|
|
+ x -= x % 8; // byte boundary ox
|
|
|
w = 8 * ((w + 7) / 8); // byte boundary, bitmaps are padded
|
|
w = 8 * ((w + 7) / 8); // byte boundary, bitmaps are padded
|
|
|
int16_t x1 = x < 0 ? 0 : x; // limit
|
|
int16_t x1 = x < 0 ? 0 : x; // limit
|
|
|
int16_t y1 = y < 0 ? 0 : y; // limit
|
|
int16_t y1 = y < 0 ? 0 : y; // limit
|
|
@@ -236,32 +200,29 @@ void GxEPD2_730c_GDEY073D46::writeImagePart(const uint8_t bitmap[], int16_t x_pa
|
|
|
w1 -= dx;
|
|
w1 -= dx;
|
|
|
h1 -= dy;
|
|
h1 -= dy;
|
|
|
if ((w1 <= 0) || (h1 <= 0)) return;
|
|
if ((w1 <= 0) || (h1 <= 0)) return;
|
|
|
- if (!_init_display_done) _InitDisplay();
|
|
|
|
|
|
|
+ _setPartialRamArea(x1, y1, w1, h1);
|
|
|
_writeCommand(0x10);
|
|
_writeCommand(0x10);
|
|
|
_startTransfer();
|
|
_startTransfer();
|
|
|
- for (int16_t i = 0; i < int16_t(HEIGHT); i++)
|
|
|
|
|
|
|
+ for (int16_t i = 0; i < h1; i++)
|
|
|
{
|
|
{
|
|
|
- for (int16_t j = 0; j < int16_t(WIDTH); j += 8)
|
|
|
|
|
|
|
+ for (int16_t j = 0; j < w1 / 8; j++)
|
|
|
{
|
|
{
|
|
|
- uint8_t data = 0xFF;
|
|
|
|
|
- if ((j >= x1) && (j < x1 + w) && (i >= y1) && (i < y1 + h))
|
|
|
|
|
|
|
+ uint8_t data;
|
|
|
|
|
+ // use wb_bitmap, h_bitmap of bitmap for index!
|
|
|
|
|
+ uint32_t idx = mirror_y ? x_part / 8 + j + dx / 8 + uint32_t((h_bitmap - 1 - (y_part + i + dy))) * wb_bitmap : x_part / 8 + j + dx / 8 + uint32_t(y_part + i + dy) * wb_bitmap;
|
|
|
|
|
+ if (pgm)
|
|
|
{
|
|
{
|
|
|
- // use wb_bitmap, h_bitmap of bitmap for index!
|
|
|
|
|
- uint32_t idx = mirror_y ? (x_part + j - x1) / 8 + uint32_t((h_bitmap - 1 - (y_part + i - y1))) * wb_bitmap : (x_part + j - x1) / 8 + uint32_t(y_part + i - y1) * wb_bitmap;
|
|
|
|
|
- if (pgm)
|
|
|
|
|
- {
|
|
|
|
|
#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
|
|
#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
|
|
|
- data = pgm_read_byte(&bitmap[idx]);
|
|
|
|
|
|
|
+ data = pgm_read_byte(&bitmap[idx]);
|
|
|
#else
|
|
#else
|
|
|
- data = bitmap[idx];
|
|
|
|
|
|
|
+ data = bitmap[idx];
|
|
|
#endif
|
|
#endif
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- data = bitmap[idx];
|
|
|
|
|
- }
|
|
|
|
|
- if (invert) data = ~data;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ data = bitmap[idx];
|
|
|
|
|
+ }
|
|
|
|
|
+ if (invert) data = ~data;
|
|
|
for (int16_t k = 0; k < 4; k++)
|
|
for (int16_t k = 0; k < 4; k++)
|
|
|
{
|
|
{
|
|
|
uint8_t data2 = (data & 0x80 ? 0x10 : 0x00) | (data & 0x40 ? 0x01 : 0x00);
|
|
uint8_t data2 = (data & 0x80 ? 0x10 : 0x00) | (data & 0x40 ? 0x01 : 0x00);
|
|
@@ -277,12 +238,14 @@ void GxEPD2_730c_GDEY073D46::writeImagePart(const uint8_t bitmap[], int16_t x_pa
|
|
|
void GxEPD2_730c_GDEY073D46::writeImagePart(const uint8_t* black, const uint8_t* color, int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
|
|
void GxEPD2_730c_GDEY073D46::writeImagePart(const uint8_t* black, const uint8_t* color, int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
|
|
|
int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
|
|
int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
|
|
|
{
|
|
{
|
|
|
- //Serial.print("writeImagePart("); Serial.print(x_part); Serial.print(", "); Serial.print(y_part); Serial.print(", ");
|
|
|
|
|
|
|
+ //Serial.print("writeImagePart_3c("); Serial.print(x_part); Serial.print(", "); Serial.print(y_part); Serial.print(", ");
|
|
|
//Serial.print(w_bitmap); Serial.print(", "); Serial.print(h_bitmap); Serial.print(", ");
|
|
//Serial.print(w_bitmap); Serial.print(", "); Serial.print(h_bitmap); Serial.print(", ");
|
|
|
//Serial.print(x); Serial.print(", "); Serial.print(y); Serial.print(", ");
|
|
//Serial.print(x); Serial.print(", "); Serial.print(y); Serial.print(", ");
|
|
|
//Serial.print(w); Serial.print(", "); Serial.print(h); Serial.println(")");
|
|
//Serial.print(w); Serial.print(", "); Serial.print(h); Serial.println(")");
|
|
|
if (!black && !color) return;
|
|
if (!black && !color) return;
|
|
|
if (!color) return writeImagePart(black, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
|
|
if (!color) return writeImagePart(black, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
|
|
|
|
|
+ if (!_init_display_done) _InitDisplay();
|
|
|
|
|
+ if (_initial_write) writeScreenBuffer();
|
|
|
delay(1); // yield() to avoid WDT on ESP8266 and ESP32
|
|
delay(1); // yield() to avoid WDT on ESP8266 and ESP32
|
|
|
if ((w_bitmap < 0) || (h_bitmap < 0) || (w < 0) || (h < 0)) return;
|
|
if ((w_bitmap < 0) || (h_bitmap < 0) || (w < 0) || (h < 0)) return;
|
|
|
if ((x_part < 0) || (x_part >= w_bitmap)) return;
|
|
if ((x_part < 0) || (x_part >= w_bitmap)) return;
|
|
@@ -291,7 +254,9 @@ void GxEPD2_730c_GDEY073D46::writeImagePart(const uint8_t* black, const uint8_t*
|
|
|
x_part -= x_part % 8; // byte boundary
|
|
x_part -= x_part % 8; // byte boundary
|
|
|
w = w_bitmap - x_part < w ? w_bitmap - x_part : w; // limit
|
|
w = w_bitmap - x_part < w ? w_bitmap - x_part : w; // limit
|
|
|
h = h_bitmap - y_part < h ? h_bitmap - y_part : h; // limit
|
|
h = h_bitmap - y_part < h ? h_bitmap - y_part : h; // limit
|
|
|
- x -= x % 8; // byte boundary
|
|
|
|
|
|
|
+ // make x, w multiple of 8
|
|
|
|
|
+ w += x % 8; // adjust for byte boundary of x
|
|
|
|
|
+ x -= x % 8; // byte boundary ox
|
|
|
w = 8 * ((w + 7) / 8); // byte boundary, bitmaps are padded
|
|
w = 8 * ((w + 7) / 8); // byte boundary, bitmaps are padded
|
|
|
int16_t x1 = x < 0 ? 0 : x; // limit
|
|
int16_t x1 = x < 0 ? 0 : x; // limit
|
|
|
int16_t y1 = y < 0 ? 0 : y; // limit
|
|
int16_t y1 = y < 0 ? 0 : y; // limit
|
|
@@ -302,38 +267,35 @@ void GxEPD2_730c_GDEY073D46::writeImagePart(const uint8_t* black, const uint8_t*
|
|
|
w1 -= dx;
|
|
w1 -= dx;
|
|
|
h1 -= dy;
|
|
h1 -= dy;
|
|
|
if ((w1 <= 0) || (h1 <= 0)) return;
|
|
if ((w1 <= 0) || (h1 <= 0)) return;
|
|
|
- if (!_init_display_done) _InitDisplay();
|
|
|
|
|
|
|
+ _setPartialRamArea(x1, y1, w1, h1);
|
|
|
_writeCommand(0x10);
|
|
_writeCommand(0x10);
|
|
|
_startTransfer();
|
|
_startTransfer();
|
|
|
- for (int16_t i = 0; i < int16_t(HEIGHT); i++)
|
|
|
|
|
|
|
+ for (int16_t i = 0; i < h1; i++)
|
|
|
{
|
|
{
|
|
|
- for (int16_t j = 0; j < int16_t(WIDTH); j += 8)
|
|
|
|
|
|
|
+ for (int16_t j = 0; j < w1 / 8; j++)
|
|
|
{
|
|
{
|
|
|
uint8_t black_data = 0xFF, color_data = 0xFF;
|
|
uint8_t black_data = 0xFF, color_data = 0xFF;
|
|
|
- if ((j >= x1) && (j < x1 + w) && (i >= y1) && (i < y1 + h))
|
|
|
|
|
|
|
+ // use wb_bitmap, h_bitmap of bitmap for index!
|
|
|
|
|
+ uint32_t idx = mirror_y ? x_part / 8 + j + dx / 8 + uint32_t((h_bitmap - 1 - (y_part + i + dy))) * wb_bitmap : x_part / 8 + j + dx / 8 + uint32_t(y_part + i + dy) * wb_bitmap;
|
|
|
|
|
+ if (pgm)
|
|
|
{
|
|
{
|
|
|
- // use wb_bitmap, h_bitmap of bitmap for index!
|
|
|
|
|
- uint32_t idx = mirror_y ? (x_part + j - x1) / 8 + uint32_t((h_bitmap - 1 - (y_part + i - y1))) * wb_bitmap : (x_part + j - x1) / 8 + uint32_t(y_part + i - y1) * wb_bitmap;
|
|
|
|
|
- if (pgm)
|
|
|
|
|
- {
|
|
|
|
|
#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
|
|
#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
|
|
|
- black_data = pgm_read_byte(&black[idx]);
|
|
|
|
|
- color_data = pgm_read_byte(&color[idx]);
|
|
|
|
|
|
|
+ black_data = pgm_read_byte(&black[idx]);
|
|
|
|
|
+ color_data = pgm_read_byte(&color[idx]);
|
|
|
#else
|
|
#else
|
|
|
- black_data = black[idx];
|
|
|
|
|
- color_data = color[idx];
|
|
|
|
|
|
|
+ black_data = black[idx];
|
|
|
|
|
+ color_data = color[idx];
|
|
|
#endif
|
|
#endif
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- black_data = black[idx];
|
|
|
|
|
- color_data = color[idx];
|
|
|
|
|
- }
|
|
|
|
|
- if (invert)
|
|
|
|
|
- {
|
|
|
|
|
- black_data = ~black_data;
|
|
|
|
|
- color_data = ~color_data;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ black_data = black[idx];
|
|
|
|
|
+ color_data = color[idx];
|
|
|
|
|
+ }
|
|
|
|
|
+ if (invert)
|
|
|
|
|
+ {
|
|
|
|
|
+ black_data = ~black_data;
|
|
|
|
|
+ color_data = ~color_data;
|
|
|
}
|
|
}
|
|
|
for (int16_t k = 0; k < 4; k++)
|
|
for (int16_t k = 0; k < 4; k++)
|
|
|
{
|
|
{
|
|
@@ -356,80 +318,61 @@ void GxEPD2_730c_GDEY073D46::writeImagePart(const uint8_t* black, const uint8_t*
|
|
|
|
|
|
|
|
void GxEPD2_730c_GDEY073D46::writeNative(const uint8_t* data1, const uint8_t* data2, int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
|
|
void GxEPD2_730c_GDEY073D46::writeNative(const uint8_t* data1, const uint8_t* data2, int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
|
|
|
{
|
|
{
|
|
|
- if (data1)
|
|
|
|
|
|
|
+ if (!data1) return;
|
|
|
|
|
+ //Serial.print("writeNative("); Serial.print(x); Serial.print(", "); Serial.print(y); Serial.print(", ");
|
|
|
|
|
+ //Serial.print(w); Serial.print(", "); Serial.print(h); Serial.println(")");
|
|
|
|
|
+ delay(1); // yield() to avoid WDT on ESP8266 and ESP32
|
|
|
|
|
+ if (!_init_display_done) _InitDisplay();
|
|
|
|
|
+ if (_initial_write) writeScreenBuffer();
|
|
|
|
|
+ uint32_t wb = (w + 1) / 2; // width bytes, bitmaps are padded
|
|
|
|
|
+ x -= x % 2; // byte boundary
|
|
|
|
|
+ w = wb * 2; // byte boundary
|
|
|
|
|
+ int16_t x1 = x < 0 ? 0 : x; // limit
|
|
|
|
|
+ int16_t y1 = y < 0 ? 0 : y; // limit
|
|
|
|
|
+ int16_t w1 = x + w < int16_t(WIDTH) ? w : int16_t(WIDTH) - x; // limit
|
|
|
|
|
+ int16_t h1 = y + h < int16_t(HEIGHT) ? h : int16_t(HEIGHT) - y; // limit
|
|
|
|
|
+ int16_t dx = x1 - x;
|
|
|
|
|
+ int16_t dy = y1 - y;
|
|
|
|
|
+ w1 -= dx;
|
|
|
|
|
+ h1 -= dy;
|
|
|
|
|
+ if ((w1 <= 0) || (h1 <= 0)) return;
|
|
|
|
|
+ _setPartialRamArea(x1, y1, w1, h1);
|
|
|
|
|
+ _writeCommand(0x10);
|
|
|
|
|
+ _startTransfer();
|
|
|
|
|
+ for (int16_t i = 0; i < h1; i++)
|
|
|
{
|
|
{
|
|
|
- //Serial.print("writeNative("); Serial.print(x); Serial.print(", "); Serial.print(y); Serial.print(", ");
|
|
|
|
|
- //Serial.print(w); Serial.print(", "); Serial.print(h); Serial.println(")");
|
|
|
|
|
- delay(1); // yield() to avoid WDT on ESP8266 and ESP32
|
|
|
|
|
- if (!_init_display_done) _InitDisplay();
|
|
|
|
|
- if (_paged && (x == 0) && (w == int16_t(WIDTH)) && (h < int16_t(HEIGHT)))
|
|
|
|
|
- {
|
|
|
|
|
- //Serial.println("paged");
|
|
|
|
|
- _startTransfer();
|
|
|
|
|
- for (uint32_t i = 0; i < uint32_t(WIDTH) * uint32_t(h) / 2; i++)
|
|
|
|
|
- {
|
|
|
|
|
- uint8_t data = data1[i];
|
|
|
|
|
- _transfer(data);
|
|
|
|
|
- }
|
|
|
|
|
- _endTransfer();
|
|
|
|
|
- if (y + h == HEIGHT) // last page
|
|
|
|
|
- {
|
|
|
|
|
- //Serial.println("paged ended");
|
|
|
|
|
- _paged = false;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
|
|
+ for (int16_t j = 0; j < w1 / 2; j++)
|
|
|
{
|
|
{
|
|
|
- _paged = false;
|
|
|
|
|
- int16_t wb = (w + 1) / 2; // width bytes, bitmaps are padded
|
|
|
|
|
- x -= x % 2; // byte boundary
|
|
|
|
|
- w = wb * 2; // byte boundary
|
|
|
|
|
- if ((w <= 0) || (h <= 0)) return;
|
|
|
|
|
- _writeCommand(0x10);
|
|
|
|
|
- _startTransfer();
|
|
|
|
|
- for (int16_t i = 0; i < int16_t(HEIGHT); i++)
|
|
|
|
|
|
|
+ uint8_t data;
|
|
|
|
|
+ // use wb, h of bitmap for index!
|
|
|
|
|
+ uint32_t idx = mirror_y ? j + dx / 2 + uint32_t((h - 1 - (i + dy))) * wb : j + dx / 2 + uint32_t(i + dy) * wb;
|
|
|
|
|
+ if (pgm)
|
|
|
{
|
|
{
|
|
|
- for (int16_t j = 0; j < int16_t(WIDTH); j += 2)
|
|
|
|
|
- {
|
|
|
|
|
- uint8_t data = 0x11;
|
|
|
|
|
- if (data1)
|
|
|
|
|
- {
|
|
|
|
|
- if ((j >= x) && (j < x + w) && (i >= y) && (i < y + h))
|
|
|
|
|
- {
|
|
|
|
|
- uint32_t idx = mirror_y ? (j - x) / 2 + uint32_t((h - 1 - (i - y))) * wb : (j - x) / 2 + uint32_t(i - y) * wb;
|
|
|
|
|
- if (pgm)
|
|
|
|
|
- {
|
|
|
|
|
#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
|
|
#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
|
|
|
- data = pgm_read_byte(&data1[idx]);
|
|
|
|
|
|
|
+ data = pgm_read_byte(&data1[idx]);
|
|
|
#else
|
|
#else
|
|
|
- data = data1[idx];
|
|
|
|
|
|
|
+ data = data1[idx];
|
|
|
#endif
|
|
#endif
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- data = data1[idx];
|
|
|
|
|
- }
|
|
|
|
|
- if (invert) data = ~data;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- _transfer(data);
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
- _endTransfer();
|
|
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ data = data1[idx];
|
|
|
|
|
+ }
|
|
|
|
|
+ if (invert) data = ~data;
|
|
|
|
|
+ _transfer(data);
|
|
|
}
|
|
}
|
|
|
- delay(1); // yield() to avoid WDT on ESP8266 and ESP32
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ _endTransfer();
|
|
|
|
|
+ delay(1); // yield() to avoid WDT on ESP8266 and ESP32
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void GxEPD2_730c_GDEY073D46::writeNativePart(const uint8_t* data1, const uint8_t* data2, int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
|
|
void GxEPD2_730c_GDEY073D46::writeNativePart(const uint8_t* data1, const uint8_t* data2, int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
|
|
|
int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
|
|
int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
|
|
|
{
|
|
{
|
|
|
- //Serial.print("writeNativePart("); Serial.print(x_part); Serial.print(", "); Serial.print(y_part); Serial.print(", ");
|
|
|
|
|
- //Serial.print(w_bitmap); Serial.print(", "); Serial.print(h_bitmap); Serial.print(", ");
|
|
|
|
|
- //Serial.print(x); Serial.print(", "); Serial.print(y); Serial.print(", ");
|
|
|
|
|
- //Serial.print(w); Serial.print(", "); Serial.print(h); Serial.println(")");
|
|
|
|
|
if (!data1) return;
|
|
if (!data1) return;
|
|
|
delay(1); // yield() to avoid WDT on ESP8266 and ESP32
|
|
delay(1); // yield() to avoid WDT on ESP8266 and ESP32
|
|
|
|
|
+ if (!_init_display_done) _InitDisplay();
|
|
|
|
|
+ if (_initial_write) writeScreenBuffer();
|
|
|
if ((w_bitmap < 0) || (h_bitmap < 0) || (w < 0) || (h < 0)) return;
|
|
if ((w_bitmap < 0) || (h_bitmap < 0) || (w < 0) || (h < 0)) return;
|
|
|
if ((x_part < 0) || (x_part >= w_bitmap)) return;
|
|
if ((x_part < 0) || (x_part >= w_bitmap)) return;
|
|
|
if ((y_part < 0) || (y_part >= h_bitmap)) return;
|
|
if ((y_part < 0) || (y_part >= h_bitmap)) return;
|
|
@@ -437,6 +380,7 @@ void GxEPD2_730c_GDEY073D46::writeNativePart(const uint8_t* data1, const uint8_t
|
|
|
x_part -= x_part % 2; // byte boundary
|
|
x_part -= x_part % 2; // byte boundary
|
|
|
w = w_bitmap - x_part < w ? w_bitmap - x_part : w; // limit
|
|
w = w_bitmap - x_part < w ? w_bitmap - x_part : w; // limit
|
|
|
h = h_bitmap - y_part < h ? h_bitmap - y_part : h; // limit
|
|
h = h_bitmap - y_part < h ? h_bitmap - y_part : h; // limit
|
|
|
|
|
+ w += x % 2; // adjust for byte boundary of x
|
|
|
x -= x % 2; // byte boundary
|
|
x -= x % 2; // byte boundary
|
|
|
w = 2 * ((w + 1) / 2); // byte boundary, bitmaps are padded
|
|
w = 2 * ((w + 1) / 2); // byte boundary, bitmaps are padded
|
|
|
int16_t x1 = x < 0 ? 0 : x; // limit
|
|
int16_t x1 = x < 0 ? 0 : x; // limit
|
|
@@ -448,32 +392,29 @@ void GxEPD2_730c_GDEY073D46::writeNativePart(const uint8_t* data1, const uint8_t
|
|
|
w1 -= dx;
|
|
w1 -= dx;
|
|
|
h1 -= dy;
|
|
h1 -= dy;
|
|
|
if ((w1 <= 0) || (h1 <= 0)) return;
|
|
if ((w1 <= 0) || (h1 <= 0)) return;
|
|
|
- if (!_init_display_done) _InitDisplay();
|
|
|
|
|
|
|
+ _setPartialRamArea(x1, y1, w1, h1);
|
|
|
_writeCommand(0x10);
|
|
_writeCommand(0x10);
|
|
|
_startTransfer();
|
|
_startTransfer();
|
|
|
- for (int16_t i = 0; i < int16_t(HEIGHT); i++)
|
|
|
|
|
|
|
+ for (int16_t i = 0; i < h1; i++)
|
|
|
{
|
|
{
|
|
|
- for (int16_t j = 0; j < int16_t(WIDTH); j += 2)
|
|
|
|
|
|
|
+ for (int16_t j = 0; j < w1 / 2; j++)
|
|
|
{
|
|
{
|
|
|
- uint8_t data = 0x11;
|
|
|
|
|
- if ((j >= x1) && (j < x1 + w) && (i >= y1) && (i < y1 + h))
|
|
|
|
|
|
|
+ uint8_t data;
|
|
|
|
|
+ // use wb_bitmap, h_bitmap of bitmap for index!
|
|
|
|
|
+ uint32_t idx = mirror_y ? x_part / 2 + j + dx / 2 + uint32_t((h_bitmap - 1 - (y_part + i + dy))) * wb_bitmap : x_part / 2 + j + dx / 2 + uint32_t(y_part + i + dy) * wb_bitmap;
|
|
|
|
|
+ if (pgm)
|
|
|
{
|
|
{
|
|
|
- // use wb_bitmap, h_bitmap of bitmap for index!
|
|
|
|
|
- uint32_t idx = mirror_y ? (x_part + j - x1) / 2 + uint32_t((h_bitmap - 1 - (y_part + i - y1))) * wb_bitmap : (x_part + j - x1) / 2 + uint32_t(y_part + i - y1) * wb_bitmap;
|
|
|
|
|
- if (pgm)
|
|
|
|
|
- {
|
|
|
|
|
#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
|
|
#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
|
|
|
- data = pgm_read_byte(&data1[idx]);
|
|
|
|
|
|
|
+ data = pgm_read_byte(&data1[idx]);
|
|
|
#else
|
|
#else
|
|
|
- data = data1[idx];
|
|
|
|
|
|
|
+ data = data1[idx];
|
|
|
#endif
|
|
#endif
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- data = data1[idx];
|
|
|
|
|
- }
|
|
|
|
|
- if (invert) data = ~data;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ data = data1[idx];
|
|
|
|
|
+ }
|
|
|
|
|
+ if (invert) data = ~data;
|
|
|
_transfer(data);
|
|
_transfer(data);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -516,6 +457,9 @@ void GxEPD2_730c_GDEY073D46::drawNative(const uint8_t* data1, const uint8_t* dat
|
|
|
void GxEPD2_730c_GDEY073D46::refresh(bool partial_update_mode)
|
|
void GxEPD2_730c_GDEY073D46::refresh(bool partial_update_mode)
|
|
|
{
|
|
{
|
|
|
_PowerOn();
|
|
_PowerOn();
|
|
|
|
|
+ _setPartialRamArea(0, 0, WIDTH, HEIGHT);
|
|
|
|
|
+ _writeCommand(0x50);
|
|
|
|
|
+ _writeData(0x3F);
|
|
|
_writeCommand(0x12); // Display Refresh
|
|
_writeCommand(0x12); // Display Refresh
|
|
|
_writeData(0x00);
|
|
_writeData(0x00);
|
|
|
delay(1);
|
|
delay(1);
|
|
@@ -525,6 +469,10 @@ void GxEPD2_730c_GDEY073D46::refresh(bool partial_update_mode)
|
|
|
void GxEPD2_730c_GDEY073D46::refresh(int16_t x, int16_t y, int16_t w, int16_t h)
|
|
void GxEPD2_730c_GDEY073D46::refresh(int16_t x, int16_t y, int16_t w, int16_t h)
|
|
|
{
|
|
{
|
|
|
_PowerOn();
|
|
_PowerOn();
|
|
|
|
|
+ if (usePartialUpdate) _setPartialRamArea(x, y, w, h);
|
|
|
|
|
+ else _setPartialRamArea(0, 0, WIDTH, HEIGHT);
|
|
|
|
|
+ _writeCommand(0x50);
|
|
|
|
|
+ _writeData(0x3F); // border white, no floating?
|
|
|
_writeCommand(0x12); // Display Refresh
|
|
_writeCommand(0x12); // Display Refresh
|
|
|
_writeData(0x00);
|
|
_writeData(0x00);
|
|
|
delay(1);
|
|
delay(1);
|
|
@@ -548,11 +496,22 @@ void GxEPD2_730c_GDEY073D46::hibernate()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void GxEPD2_730c_GDEY073D46::setPaged()
|
|
|
|
|
|
|
+void GxEPD2_730c_GDEY073D46::_setPartialRamArea(uint16_t x, uint16_t y, uint16_t w, uint16_t h)
|
|
|
{
|
|
{
|
|
|
- _paged = true;
|
|
|
|
|
- if (!_init_display_done) _InitDisplay();
|
|
|
|
|
- _writeCommand(0x10);
|
|
|
|
|
|
|
+ //Serial.print("_setPartialRamArea("); Serial.print(x); Serial.print(", "); Serial.print(y); Serial.print(", ");
|
|
|
|
|
+ //Serial.print(w); Serial.print(", "); Serial.print(h); Serial.println(")");
|
|
|
|
|
+ uint16_t xe = x + w - 1;
|
|
|
|
|
+ uint16_t ye = y + h; // controller issue (one more)
|
|
|
|
|
+ _writeCommand(0x83); // partial window
|
|
|
|
|
+ _writeData(x / 256);
|
|
|
|
|
+ _writeData(x % 256);
|
|
|
|
|
+ _writeData(xe / 256);
|
|
|
|
|
+ _writeData(xe % 256);
|
|
|
|
|
+ _writeData(y / 256);
|
|
|
|
|
+ _writeData(y % 256);
|
|
|
|
|
+ _writeData(ye / 256);
|
|
|
|
|
+ _writeData(ye % 256);
|
|
|
|
|
+ _writeData(0x01);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void GxEPD2_730c_GDEY073D46::_PowerOn()
|
|
void GxEPD2_730c_GDEY073D46::_PowerOn()
|
|
@@ -662,17 +621,37 @@ void GxEPD2_730c_GDEY073D46::_InitDisplay()
|
|
|
_init_display_done = true;
|
|
_init_display_done = true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-uint8_t GxEPD2_730c_GDEY073D46::_colorOfDemoBitmap(uint8_t from)
|
|
|
|
|
|
|
+uint8_t GxEPD2_730c_GDEY073D46::_colorOfDemoBitmap(uint8_t from, int16_t mode)
|
|
|
{
|
|
{
|
|
|
- switch (from)
|
|
|
|
|
|
|
+ switch (mode)
|
|
|
{
|
|
{
|
|
|
- case 0xFF: return (0x01); // white;
|
|
|
|
|
- case 0xFC: return (0x05); // yellow;
|
|
|
|
|
- case 0xF1: return (0x06); // orange;
|
|
|
|
|
- case 0xE5: return (0x04); // red;
|
|
|
|
|
- case 0x4B: return (0x03); // blue;
|
|
|
|
|
- case 0x39: return (0x02); // green;
|
|
|
|
|
- case 0x00: return (0x00); // black;
|
|
|
|
|
|
|
+ case 0:
|
|
|
|
|
+ {
|
|
|
|
|
+ switch (from)
|
|
|
|
|
+ {
|
|
|
|
|
+ case 0xFF: return (0x01); // white;
|
|
|
|
|
+ case 0xFC: return (0x05); // yellow;
|
|
|
|
|
+ case 0xF1: return (0x06); // orange;
|
|
|
|
|
+ case 0xE5: return (0x04); // red;
|
|
|
|
|
+ case 0x4B: return (0x03); // blue;
|
|
|
|
|
+ case 0x39: return (0x02); // green;
|
|
|
|
|
+ case 0x00: return (0x00); // black;
|
|
|
|
|
+ default: return (0x01); // white;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ case 1:
|
|
|
|
|
+ {
|
|
|
|
|
+ switch (from)
|
|
|
|
|
+ {
|
|
|
|
|
+ case 0x00: return (0x00); // black;
|
|
|
|
|
+ case 0xff: return (0x01); // white;
|
|
|
|
|
+ case 0xfc: return (0x05); // yellow;
|
|
|
|
|
+ case 0xE0: return (0x04); // red;
|
|
|
|
|
+ case 0x03: return (0x03); // blue;
|
|
|
|
|
+ case 0x1c: return (0x02); // green;
|
|
|
|
|
+ default: return (0x01); // white;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
default: return (0x01); // white;
|
|
default: return (0x01); // white;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -680,51 +659,50 @@ uint8_t GxEPD2_730c_GDEY073D46::_colorOfDemoBitmap(uint8_t from)
|
|
|
void GxEPD2_730c_GDEY073D46::writeDemoBitmap(const uint8_t* data1, const uint8_t* data2, int16_t x, int16_t y, int16_t w, int16_t h, int16_t mode, bool mirror_y, bool pgm)
|
|
void GxEPD2_730c_GDEY073D46::writeDemoBitmap(const uint8_t* data1, const uint8_t* data2, int16_t x, int16_t y, int16_t w, int16_t h, int16_t mode, bool mirror_y, bool pgm)
|
|
|
{
|
|
{
|
|
|
(void) mode;
|
|
(void) mode;
|
|
|
- if (data1)
|
|
|
|
|
|
|
+ if (!data1) return;
|
|
|
|
|
+ //Serial.print("writeDemoBitmap("); Serial.print(x); Serial.print(", "); Serial.print(y); Serial.print(", ");
|
|
|
|
|
+ //Serial.print(w); Serial.print(", "); Serial.print(h); Serial.println(")");
|
|
|
|
|
+ delay(1); // yield() to avoid WDT on ESP8266 and ESP32
|
|
|
|
|
+ if (!_init_display_done) _InitDisplay();
|
|
|
|
|
+ if (_initial_write) writeScreenBuffer();
|
|
|
|
|
+ int16_t x1 = x < 0 ? 0 : x; // limit
|
|
|
|
|
+ int16_t y1 = y < 0 ? 0 : y; // limit
|
|
|
|
|
+ int16_t w1 = x + w < int16_t(WIDTH) ? w : int16_t(WIDTH) - x; // limit
|
|
|
|
|
+ int16_t h1 = y + h < int16_t(HEIGHT) ? h : int16_t(HEIGHT) - y; // limit
|
|
|
|
|
+ int16_t dx = x1 - x;
|
|
|
|
|
+ int16_t dy = y1 - y;
|
|
|
|
|
+ w1 -= dx;
|
|
|
|
|
+ h1 -= dy;
|
|
|
|
|
+ if ((w1 <= 0) || (h1 <= 0)) return;
|
|
|
|
|
+ _setPartialRamArea(x1, y1, w1, h1);
|
|
|
|
|
+ _writeCommand(0x10);
|
|
|
|
|
+ _startTransfer();
|
|
|
|
|
+ for (int16_t i = 0; i < h1; i++)
|
|
|
{
|
|
{
|
|
|
- //Serial.print("writeNative("); Serial.print(x); Serial.print(", "); Serial.print(y); Serial.print(", ");
|
|
|
|
|
- //Serial.print(w); Serial.print(", "); Serial.print(h); Serial.println(")");
|
|
|
|
|
- if (!_init_display_done) _InitDisplay();
|
|
|
|
|
- delay(1); // yield() to avoid WDT on ESP8266 and ESP32
|
|
|
|
|
|
|
+ for (int16_t j = 0; j < w1; j += 2)
|
|
|
{
|
|
{
|
|
|
- _paged = false;
|
|
|
|
|
- if ((w <= 0) || (h <= 0)) return;
|
|
|
|
|
- _writeCommand(0x10);
|
|
|
|
|
- _startTransfer();
|
|
|
|
|
- for (int16_t i = 0; i < int16_t(HEIGHT); i++)
|
|
|
|
|
|
|
+ uint8_t data = 0x11;
|
|
|
|
|
+ uint32_t idx = mirror_y ? j + dx + uint32_t((h - 1 - (i + dy))) * w : j + dx + uint32_t(i + dy) * w;
|
|
|
|
|
+ if (pgm)
|
|
|
{
|
|
{
|
|
|
- for (int16_t j = 0; j < int16_t(WIDTH); j += 2)
|
|
|
|
|
- {
|
|
|
|
|
- uint8_t data = 0x11;
|
|
|
|
|
- if (data1)
|
|
|
|
|
- {
|
|
|
|
|
- if ((j >= x) && (j < x + w) && (i >= y) && (i < y + h))
|
|
|
|
|
- {
|
|
|
|
|
- uint32_t idx = mirror_y ? (j - x) + uint32_t((h - 1 - (i - y))) * w : (j - x) + uint32_t(i - y) * w;
|
|
|
|
|
- if (pgm)
|
|
|
|
|
- {
|
|
|
|
|
#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
|
|
#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
|
|
|
- data = _colorOfDemoBitmap(pgm_read_byte(&data1[idx++])) << 4;
|
|
|
|
|
- data |= _colorOfDemoBitmap(pgm_read_byte(&data1[idx]));
|
|
|
|
|
|
|
+ data = _colorOfDemoBitmap(pgm_read_byte(&data1[idx++]), mode) << 4;
|
|
|
|
|
+ data |= _colorOfDemoBitmap(pgm_read_byte(&data1[idx]), mode);
|
|
|
#else
|
|
#else
|
|
|
- data = _colorOfDemoBitmap(data1[idx++]) << 4;
|
|
|
|
|
- data |= _colorOfDemoBitmap(data1[idx]);
|
|
|
|
|
|
|
+ data = _colorOfDemoBitmap(data1[idx++], mode) << 4;
|
|
|
|
|
+ data |= _colorOfDemoBitmap(data1[idx], mode);
|
|
|
#endif
|
|
#endif
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- data = _colorOfDemoBitmap(data1[idx++]) << 4;
|
|
|
|
|
- data |= _colorOfDemoBitmap(data1[idx]);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- _transfer(data);
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
- _endTransfer();
|
|
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ data = _colorOfDemoBitmap(data1[idx++], mode) << 4;
|
|
|
|
|
+ data |= _colorOfDemoBitmap(data1[idx], mode);
|
|
|
|
|
+ }
|
|
|
|
|
+ _transfer(data);
|
|
|
}
|
|
}
|
|
|
- delay(1); // yield() to avoid WDT on ESP8266 and ESP32
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ _endTransfer();
|
|
|
|
|
+ delay(1); // yield() to avoid WDT on ESP8266 and ESP32
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void GxEPD2_730c_GDEY073D46::drawDemoBitmap(const uint8_t* data1, const uint8_t* data2, int16_t x, int16_t y, int16_t w, int16_t h, int16_t mode, bool mirror_y, bool pgm)
|
|
void GxEPD2_730c_GDEY073D46::drawDemoBitmap(const uint8_t* data1, const uint8_t* data2, int16_t x, int16_t y, int16_t w, int16_t h, int16_t mode, bool mirror_y, bool pgm)
|