Skip to content

Commit

Permalink
Version 1.2.2
Browse files Browse the repository at this point in the history
- fixed BMP handling, e.g. for BMPs created by ImageMagick
  • Loading branch information
ZinggJM committed Oct 24, 2019
1 parent 5143643 commit 73c56e4
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 19 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@
#### other supported panels
- ED060SCT 6" grey levels, on Waveshare e-Paper IT8951 Driver HAT

### Version 1.2.1
### Version 1.2.2
- fixed BMP handling, e.g. for BMPs created by ImageMagick
- see also Arduino Forum Topic https://forum.arduino.cc/index.php?topic=642343.0
#### Version 1.2.1
- added support for GDEW075T7 7.5" b/w 800x480
- GDEW075T7 has differential update (1.6s) using a charge balancing waveform
- added optional SW SPI support, see /extras/sw_spi/README
Expand Down
5 changes: 3 additions & 2 deletions examples/GxEPD2_SD_AVR_Example/GxEPD2_SD_AVR_Example.ino
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ SdFat SD;
#define SD_CS 6 // adapt to your wiring
#define EPD_CS SS // adapt to your wiring
// select one and adapt to your mapping
GxEPD2_154 display(/*CS=10*/ EPD_CS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7);
//GxEPD2_154 display(/*CS=10*/ EPD_CS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7);
//GxEPD2_213 display(/*CS=10*/ EPD_CS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7);
//GxEPD2_290 display(/*CS=10*/ EPD_CS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7);
Expand Down Expand Up @@ -261,7 +262,8 @@ void drawBitmapFromSD(const char *filename, int16_t x, int16_t y, bool with_colo
if (depth <= 8)
{
if (depth < 8) bitmask >>= depth;
file.seekSet(54); //palette is always @ 54
//file.seekSet(54); //palette is always @ 54
file.seekSet(imageOffset - (4 << depth)); // 54 for regular, diff for colorsimportant
for (uint16_t pn = 0; pn < (1 << depth); pn++)
{
blue = file.read();
Expand Down Expand Up @@ -403,4 +405,3 @@ uint32_t read32(SdFile& f)
((uint8_t *)&result)[3] = f.read(); // MSB
return result;
}

26 changes: 22 additions & 4 deletions examples/GxEPD2_SD_Example/GxEPD2_SD_Example.ino
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,22 @@ void drawBitmaps_test()
delay(2000);
drawBitmapFromSD("bb4.bmp", 0, 0);
delay(2000);
drawBitmapFromSD("output5.bmp", 0, 0);
delay(2000);
drawBitmapFromSD("output6.bmp", 0, 0);
delay(2000);
drawBitmapFromSD("tractor_1.bmp", 0, 0);
delay(2000);
drawBitmapFromSD("tractor_4.bmp", 0, 0);
delay(2000);
drawBitmapFromSD("tractor_8.bmp", 0, 0);
delay(2000);
drawBitmapFromSD("tractor_11.bmp", 0, 0);
delay(2000);
drawBitmapFromSD("tractor_44.bmp", 0, 0);
delay(2000);
drawBitmapFromSD("tractor_88.bmp", 0, 0);
delay(2000);
}

void drawBitmapsBuffered_200x200()
Expand Down Expand Up @@ -338,7 +354,7 @@ void drawBitmapsBuffered_test()

static const uint16_t input_buffer_pixels = 20; // may affect performance

static const uint16_t max_row_width = 640; // for up to 7.5" display
static const uint16_t max_row_width = 800; // for up to 7.5" display 800x480
static const uint16_t max_palette_pixels = 256; // for depth <= 8

uint8_t input_buffer[3 * input_buffer_pixels]; // up to depth 24
Expand Down Expand Up @@ -417,13 +433,15 @@ void drawBitmapFromSD(const char *filename, int16_t x, int16_t y, bool with_colo
if (depth <= 8)
{
if (depth < 8) bitmask >>= depth;
file.seekSet(54); //palette is always @ 54
//file.seekSet(54); //palette is always @ 54
file.seekSet(imageOffset - (4 << depth)); // 54 for regular, diff for colorsimportant
for (uint16_t pn = 0; pn < (1 << depth); pn++)
{
blue = file.read();
green = file.read();
red = file.read();
file.read();
//Serial.print(red); Serial.print(" "); Serial.print(green); Serial.print(" "); Serial.println(blue);
whitish = with_color ? ((red > 0x80) && (green > 0x80) && (blue > 0x80)) : ((red + green + blue) > 3 * 0x80); // whitish
colored = (red > 0xF0) || ((green > 0xF0) && (blue > 0xF0)); // reddish or yellowish?
if (0 == pn % 8) mono_palette_buffer[pn / 8] = 0;
Expand Down Expand Up @@ -605,7 +623,8 @@ void drawBitmapFromSD_Buffered(const char *filename, int16_t x, int16_t y, bool
if (depth <= 8)
{
if (depth < 8) bitmask >>= depth;
file.seekSet(54); //palette is always @ 54
//file.seekSet(54); //palette is always @ 54
file.seekSet(imageOffset - (4 << depth)); //54 for regular, diff for colorsimportant
for (uint16_t pn = 0; pn < (1 << depth); pn++)
{
blue = file.read();
Expand Down Expand Up @@ -739,4 +758,3 @@ uint32_t read32(SdFile& f)
((uint8_t *)&result)[3] = f.read(); // MSB
return result;
}

32 changes: 27 additions & 5 deletions examples/GxEPD2_Spiffs_Example/GxEPD2_Spiffs_Example.ino
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ void setup()
{
drawBitmaps_200x200();
drawBitmaps_other();
//drawBitmaps_test();
}

Serial.println("GxEPD2_Spiffs_Example done");
Expand Down Expand Up @@ -195,6 +196,26 @@ void drawBitmaps_other()
delay(2000);
}

void drawBitmaps_test()
{
drawBitmapFromSpiffs("output5.bmp", 0, 0);
delay(2000);
drawBitmapFromSpiffs("output6.bmp", 0, 0);
delay(2000);
drawBitmapFromSpiffs("tractor_1.bmp", 0, 0);
delay(2000);
drawBitmapFromSpiffs("tractor_4.bmp", 0, 0);
delay(2000);
drawBitmapFromSpiffs("tractor_8.bmp", 0, 0);
delay(2000);
drawBitmapFromSpiffs("tractor_11.bmp", 0, 0);
delay(2000);
drawBitmapFromSpiffs("tractor_44.bmp", 0, 0);
delay(2000);
drawBitmapFromSpiffs("tractor_88.bmp", 0, 0);
delay(2000);
}

void drawBitmapsBuffered_200x200()
{
int16_t x = (display.width() - 200) / 2;
Expand Down Expand Up @@ -245,9 +266,9 @@ void drawBitmapsBuffered_other()
delay(2000);
}

static const uint16_t input_buffer_pixels = 640; // may affect performance
static const uint16_t input_buffer_pixels = 800; // may affect performance

static const uint16_t max_row_width = 640; // for up to 7.5" display
static const uint16_t max_row_width = 800; // for up to 7.5" display 800x480
static const uint16_t max_palette_pixels = 256; // for depth <= 8

uint8_t input_buffer[3 * input_buffer_pixels]; // up to depth 24
Expand Down Expand Up @@ -322,7 +343,8 @@ void drawBitmapFromSpiffs(const char *filename, int16_t x, int16_t y, bool with_
if (depth <= 8)
{
if (depth < 8) bitmask >>= depth;
file.seek(54); //palette is always @ 54
//file.seek(54); //palette is always @ 54
file.seek(imageOffset - (4 << depth)); // 54 for regular, diff for colorsimportant
for (uint16_t pn = 0; pn < (1 << depth); pn++)
{
blue = file.read();
Expand Down Expand Up @@ -506,7 +528,8 @@ void drawBitmapFromSpiffs_Buffered(const char *filename, int16_t x, int16_t y, b
if (depth <= 8)
{
if (depth < 8) bitmask >>= depth;
file.seek(54); //palette is always @ 54
//file.seek(54); //palette is always @ 54
file.seek(imageOffset - (4 << depth)); // 54 for regular, diff for colorsimportant
for (uint16_t pn = 0; pn < (1 << depth); pn++)
{
blue = file.read();
Expand Down Expand Up @@ -640,4 +663,3 @@ uint32_t read32(fs::File& f)
((uint8_t *)&result)[3] = f.read(); // MSB
return result;
}

13 changes: 13 additions & 0 deletions examples/GxEPD2_Spiffs_Loader/GxEPD2_Spiffs_Loader.ino
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ void setup()
//deleteFiles();
downloadBitmaps_200x200();
downloadBitmaps_other();
//downloadBitmaps_test();
listFiles();
}

Expand Down Expand Up @@ -135,6 +136,18 @@ void downloadBitmaps_other()
downloadFile_HTTPS(host_rawcontent, path_prenticedavid, "woof.bmp", fp_rawcontent, "woof.bmp");
}

void downloadBitmaps_test()
{
downloadFile_HTTPS(host_rawcontent, path_rawcontent, "output5.bmp", fp_rawcontent, "output5.bmp");
downloadFile_HTTPS(host_rawcontent, path_rawcontent, "output6.bmp", fp_rawcontent, "output6.bmp");
downloadFile_HTTPS(host_rawcontent, path_rawcontent, "tractor_1.bmp", fp_rawcontent, "tractor_1.bmp");
downloadFile_HTTPS(host_rawcontent, path_rawcontent, "tractor_4.bmp", fp_rawcontent, "tractor_4.bmp");
downloadFile_HTTPS(host_rawcontent, path_rawcontent, "tractor_8.bmp", fp_rawcontent, "tractor_8.bmp");
downloadFile_HTTPS(host_rawcontent, path_rawcontent, "tractor_11.bmp", fp_rawcontent, "tractor_11.bmp");
downloadFile_HTTPS(host_rawcontent, path_rawcontent, "tractor_44.bmp", fp_rawcontent, "tractor_44.bmp");
downloadFile_HTTPS(host_rawcontent, path_rawcontent, "tractor_88.bmp", fp_rawcontent, "tractor_88.bmp");
}

void deleteFiles()
{
SPIFFS.remove("logo200x200.bmp");
Expand Down
32 changes: 26 additions & 6 deletions examples/GxEPD2_WiFi_Example/GxEPD2_WiFi_Example.ino
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,22 @@ void drawBitmaps_test()
int16_t h2 = display.height() / 2;
showBitmapFrom_HTTPS(host_rawcontent, path_prenticedavid, "betty_4.bmp", fp_rawcontent, w2 - 102, h2 - 126);
delay(2000);
showBitmapFrom_HTTPS(host_rawcontent, path_rawcontent, "output5.bmp", fp_rawcontent, 0, 0);
delay(2000);
showBitmapFrom_HTTPS(host_rawcontent, path_rawcontent, "output6.bmp", fp_rawcontent, 0, 0);
delay(2000);
showBitmapFrom_HTTPS(host_rawcontent, path_rawcontent, "tractor_1.bmp", fp_rawcontent, 0, 0);
delay(2000);
showBitmapFrom_HTTPS(host_rawcontent, path_rawcontent, "tractor_4.bmp", fp_rawcontent, 0, 0);
delay(2000);
showBitmapFrom_HTTPS(host_rawcontent, path_rawcontent, "tractor_8.bmp", fp_rawcontent, 0, 0);
delay(2000);
showBitmapFrom_HTTPS(host_rawcontent, path_rawcontent, "tractor_11.bmp", fp_rawcontent, 0, 0);
delay(2000);
showBitmapFrom_HTTPS(host_rawcontent, path_rawcontent, "tractor_44.bmp", fp_rawcontent, 0, 0);
delay(2000);
showBitmapFrom_HTTPS(host_rawcontent, path_rawcontent, "tractor_88.bmp", fp_rawcontent, 0, 0);
delay(2000);
}

void drawBitmapsBuffered_200x200()
Expand Down Expand Up @@ -324,9 +340,9 @@ void drawBitmapsBuffered_test()
delay(2000);
}

static const uint16_t input_buffer_pixels = 640; // may affect performance
static const uint16_t input_buffer_pixels = 800; // may affect performance

static const uint16_t max_row_width = 640; // for up to 7.5" display
static const uint16_t max_row_width = 800; // for up to 7.5" display 800x480
static const uint16_t max_palette_pixels = 256; // for depth <= 8

uint8_t input_buffer[3 * input_buffer_pixels]; // up to depth 24
Expand Down Expand Up @@ -421,7 +437,8 @@ void showBitmapFrom_HTTP(const char* host, const char* path, const char* filenam
if (depth <= 8)
{
if (depth < 8) bitmask >>= depth;
bytes_read += skip(client, 54 - bytes_read); //palette is always @ 54
//bytes_read += skip(client, 54 - bytes_read); //palette is always @ 54
bytes_read += skip(client, imageOffset - (4 << depth) - bytes_read); // 54 for regular, diff for colorsimportant
for (uint16_t pn = 0; pn < (1 << depth); pn++)
{
blue = client.read();
Expand Down Expand Up @@ -647,7 +664,8 @@ void drawBitmapFrom_HTTP_ToBuffer(const char* host, const char* path, const char
if (depth <= 8)
{
if (depth < 8) bitmask >>= depth;
bytes_read += skip(client, 54 - bytes_read); //palette is always @ 54
//bytes_read += skip(client, 54 - bytes_read); //palette is always @ 54
bytes_read += skip(client, imageOffset - (4 << depth) - bytes_read); // 54 for regular, diff for colorsimportant
for (uint16_t pn = 0; pn < (1 << depth); pn++)
{
blue = client.read();
Expand Down Expand Up @@ -897,7 +915,8 @@ void showBitmapFrom_HTTPS(const char* host, const char* path, const char* filena
if (depth <= 8)
{
if (depth < 8) bitmask >>= depth;
bytes_read += skip(client, 54 - bytes_read); //palette is always @ 54
//bytes_read += skip(client, 54 - bytes_read); //palette is always @ 54
bytes_read += skip(client, imageOffset - (4 << depth) - bytes_read); // 54 for regular, diff for colorsimportant
for (uint16_t pn = 0; pn < (1 << depth); pn++)
{
blue = client.read();
Expand Down Expand Up @@ -1144,7 +1163,8 @@ void drawBitmapFrom_HTTPS_ToBuffer(const char* host, const char* path, const cha
if (depth <= 8)
{
if (depth < 8) bitmask >>= depth;
bytes_read += skip(client, 54 - bytes_read); //palette is always @ 54
//bytes_read += skip(client, 54 - bytes_read); //palette is always @ 54
bytes_read += skip(client, imageOffset - (4 << depth) - bytes_read); // 54 for regular, diff for colorsimportant
for (uint16_t pn = 0; pn < (1 << depth); pn++)
{
blue = client.read();
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=GxEPD2
version=1.2.1
version=1.2.2
author=Jean-Marc Zingg
maintainer=Jean-Marc Zingg
sentence=Arduino Display Library for SPI E-Paper displays from Dalian Good Display and Waveshare.
Expand Down

0 comments on commit 73c56e4

Please sign in to comment.