11// GxEPD_WiFi_Example : Display Library example for SPI e-paper panels from Dalian Good Display and boards from Waveshare.
22// Requires HW SPI and Adafruit_GFX. Caution: these e-papers require 3.3V supply AND data lines!
33//
4- // Display Library based on Demo Example from Good Display: http://www.good -display.com/download_list/downloadcategoryid=34&isMode=false.html
4+ // Display Library based on Demo Example from Good Display: http://www.e-paper -display.com/download_list/downloadcategoryid=34&isMode=false.html
55//
66// BMP handling code extracts taken from: https://github.com/prenticedavid/MCUFRIEND_kbv/tree/master/examples/showBMP_kbv_Uno
77//
3535// BUSY -> 7, RST -> 9, DC -> 8, CS-> 10, CLK -> 13, DIN -> 11
3636//
3737
38+ // mapping suggestion for Arduino MEGA
39+ // BUSY -> 7, RST -> 9, DC -> 8, CS-> 53, CLK -> 52, DIN -> 51
40+
41+ // mapping suggestion for Arduino DUE
42+ // BUSY -> 7, RST -> 9, DC -> 8, CS-> 77, CLK -> 76, DIN -> 75
43+ // SPI pins are also on 6 pin 2x3 SPI header
44+
3845// include library, include base class, make path known
3946#include < GxEPD.h>
4047
4451// #include <GxGDEW0154Z17/GxGDEW0154Z17.h> // 1.54" b/w/r 152x152
4552// #include <GxGDEW0213I5F/GxGDEW0213I5F.h> // 2.13" b/w 104x212 flexible
4653// #include <GxGDE0213B1/GxGDE0213B1.h> // 2.13" b/w
54+ // #include <GxGDEH0213B72/GxGDEH0213B72.h> // 2.13" b/w new panel
4755// #include <GxGDEW0213Z16/GxGDEW0213Z16.h> // 2.13" b/w/r
4856// #include <GxGDEH029A1/GxGDEH029A1.h> // 2.9" b/w
57+ // #include <GxGDEW029T5/GxGDEW029T5.h> // 2.9" b/w IL0373
4958// #include <GxGDEW029Z10/GxGDEW029Z10.h> // 2.9" b/w/r
5059// #include <GxGDEW027C44/GxGDEW027C44.h> // 2.7" b/w/r
5160// #include <GxGDEW027W3/GxGDEW027W3.h> // 2.7" b/w
@@ -253,7 +262,7 @@ void drawBitmapFrom_HTTP_ToBuffer(const char* host, const char* path, const char
253262 Serial.println (String (" http://" ) + host + path + filename);
254263 client.print (String (" GET " ) + path + filename + " HTTP/1.1\r\n " +
255264 " Host: " + host + " \r\n " +
256- " User-Agent: GxEPD2_Spiffs_Loader \r\n " +
265+ " User-Agent: GxEPD_WiFi_Example \r\n " +
257266 " Connection: close\r\n\r\n " );
258267 Serial.println (" request sent" );
259268 while (client.connected ())
@@ -342,7 +351,7 @@ void drawBitmapFrom_HTTP_ToBuffer(const char* host, const char* path, const char
342351 bytes_read += skip (client, rowPosition - bytes_read);
343352 for (uint16_t row = 0 ; row < h; row++, rowPosition += rowSize) // for each line
344353 {
345- if (!connection_ok || !client.connected ()) break ;
354+ if (!connection_ok || !( client.connected () || client. available () )) break ;
346355 delay (1 ); // yield() to avoid WDT
347356 uint32_t in_remain = rowSize;
348357 uint32_t in_idx = 0 ;
@@ -353,7 +362,7 @@ void drawBitmapFrom_HTTP_ToBuffer(const char* host, const char* path, const char
353362 for (uint16_t col = 0 ; col < w; col++) // for each pixel
354363 {
355364 yield ();
356- if (!connection_ok || !client.connected ()) break ;
365+ if (!connection_ok || !( client.connected () || client. available () )) break ;
357366 // Time to read more pixel data?
358367 if (in_idx >= in_bytes) // ok, exact match for 24bit also (size IS multiple of 3)
359368 {
@@ -495,7 +504,7 @@ void drawBitmapFrom_HTTPS_ToBuffer(const char* host, const char* path, const cha
495504 Serial.println (String (" https://" ) + host + path + filename);
496505 client.print (String (" GET " ) + path + filename + " HTTP/1.1\r\n " +
497506 " Host: " + host + " \r\n " +
498- " User-Agent: GxEPD2_Spiffs_Loader \r\n " +
507+ " User-Agent: GxEPD_WiFi_Example \r\n " +
499508 " Connection: close\r\n\r\n " );
500509 Serial.println (" request sent" );
501510 while (client.connected ())
@@ -584,7 +593,7 @@ void drawBitmapFrom_HTTPS_ToBuffer(const char* host, const char* path, const cha
584593 bytes_read += skip (client, rowPosition - bytes_read);
585594 for (uint16_t row = 0 ; row < h; row++, rowPosition += rowSize) // for each line
586595 {
587- if (!connection_ok || !client.connected ()) break ;
596+ if (!connection_ok || !( client.connected () || client. available () )) break ;
588597 delay (1 ); // yield() to avoid WDT
589598 uint32_t in_remain = rowSize;
590599 uint32_t in_idx = 0 ;
@@ -595,7 +604,7 @@ void drawBitmapFrom_HTTPS_ToBuffer(const char* host, const char* path, const cha
595604 for (uint16_t col = 0 ; col < w; col++) // for each pixel
596605 {
597606 yield ();
598- if (!connection_ok || !client.connected ()) break ;
607+ if (!connection_ok || !( client.connected () || client. available () )) break ;
599608 // Time to read more pixel data?
600609 if (in_idx >= in_bytes) // ok, exact match for 24bit also (size IS multiple of 3)
601610 {
@@ -760,7 +769,7 @@ uint32_t skip(WiFiClient& client, int32_t bytes)
760769{
761770 int32_t remain = bytes;
762771 uint32_t start = millis ();
763- while (client.connected () && (remain > 0 ))
772+ while (( client.connected () || client. available () ) && (remain > 0 ))
764773 {
765774 if (client.available ())
766775 {
@@ -777,7 +786,7 @@ uint32_t read(WiFiClient& client, uint8_t* buffer, int32_t bytes)
777786{
778787 int32_t remain = bytes;
779788 uint32_t start = millis ();
780- while (client.connected () && (remain > 0 ))
789+ while (( client.connected () || client. available () ) && (remain > 0 ))
781790 {
782791 if (client.available ())
783792 {
0 commit comments