diff --git a/README.md b/README.md index 3937f1b..330e48b 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,11 @@ A simple E-Paper display library with common base class and separate IO class fo ### for pin mapping suggestions see ConnectingHardware.md -### Version 3.0.6 +### Version 3.0.7 +- fix for incomplete download in GxEPD_WiFi_Example +- added missing powerDown() in base class GxEPD and class GxGDEW0154Z04 +- added missing getUTF8Width() for U8g2_for_Adafruit_GFX in GxFont_GFX +#### Version 3.0.6 - added GxGDEH0213B72, to support GDEH0213B72 2.13" b/w, replacement for GDE0213B1 #### Version 3.0.5 - added support for GDEW029T5 diff --git a/examples/GxEPD_WiFi_Example/GxEPD_WiFi_Example.ino b/examples/GxEPD_WiFi_Example/GxEPD_WiFi_Example.ino index 88e7c99..1dd4085 100644 --- a/examples/GxEPD_WiFi_Example/GxEPD_WiFi_Example.ino +++ b/examples/GxEPD_WiFi_Example/GxEPD_WiFi_Example.ino @@ -1,7 +1,7 @@ // GxEPD_WiFi_Example : Display Library example for SPI e-paper panels from Dalian Good Display and boards from Waveshare. // Requires HW SPI and Adafruit_GFX. Caution: these e-papers require 3.3V supply AND data lines! // -// Display Library based on Demo Example from Good Display: http://www.good-display.com/download_list/downloadcategoryid=34&isMode=false.html +// Display Library based on Demo Example from Good Display: http://www.e-paper-display.com/download_list/downloadcategoryid=34&isMode=false.html // // BMP handling code extracts taken from: https://github.com/prenticedavid/MCUFRIEND_kbv/tree/master/examples/showBMP_kbv_Uno // @@ -35,6 +35,13 @@ // BUSY -> 7, RST -> 9, DC -> 8, CS-> 10, CLK -> 13, DIN -> 11 // +// mapping suggestion for Arduino MEGA +// BUSY -> 7, RST -> 9, DC -> 8, CS-> 53, CLK -> 52, DIN -> 51 + +// mapping suggestion for Arduino DUE +// BUSY -> 7, RST -> 9, DC -> 8, CS-> 77, CLK -> 76, DIN -> 75 +// SPI pins are also on 6 pin 2x3 SPI header + // include library, include base class, make path known #include @@ -44,8 +51,10 @@ //#include // 1.54" b/w/r 152x152 //#include // 2.13" b/w 104x212 flexible //#include // 2.13" b/w +//#include // 2.13" b/w new panel //#include // 2.13" b/w/r //#include // 2.9" b/w +//#include // 2.9" b/w IL0373 //#include // 2.9" b/w/r //#include // 2.7" b/w/r //#include // 2.7" b/w @@ -253,7 +262,7 @@ void drawBitmapFrom_HTTP_ToBuffer(const char* host, const char* path, const char Serial.println(String("http://") + host + path + filename); client.print(String("GET ") + path + filename + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + - "User-Agent: GxEPD2_Spiffs_Loader\r\n" + + "User-Agent: GxEPD_WiFi_Example\r\n" + "Connection: close\r\n\r\n"); Serial.println("request sent"); while (client.connected()) @@ -342,7 +351,7 @@ void drawBitmapFrom_HTTP_ToBuffer(const char* host, const char* path, const char bytes_read += skip(client, rowPosition - bytes_read); for (uint16_t row = 0; row < h; row++, rowPosition += rowSize) // for each line { - if (!connection_ok || !client.connected()) break; + if (!connection_ok || !(client.connected() || client.available())) break; delay(1); // yield() to avoid WDT uint32_t in_remain = rowSize; uint32_t in_idx = 0; @@ -353,7 +362,7 @@ void drawBitmapFrom_HTTP_ToBuffer(const char* host, const char* path, const char for (uint16_t col = 0; col < w; col++) // for each pixel { yield(); - if (!connection_ok || !client.connected()) break; + if (!connection_ok || !(client.connected() || client.available())) break; // Time to read more pixel data? if (in_idx >= in_bytes) // ok, exact match for 24bit also (size IS multiple of 3) { @@ -495,7 +504,7 @@ void drawBitmapFrom_HTTPS_ToBuffer(const char* host, const char* path, const cha Serial.println(String("https://") + host + path + filename); client.print(String("GET ") + path + filename + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + - "User-Agent: GxEPD2_Spiffs_Loader\r\n" + + "User-Agent: GxEPD_WiFi_Example\r\n" + "Connection: close\r\n\r\n"); Serial.println("request sent"); while (client.connected()) @@ -584,7 +593,7 @@ void drawBitmapFrom_HTTPS_ToBuffer(const char* host, const char* path, const cha bytes_read += skip(client, rowPosition - bytes_read); for (uint16_t row = 0; row < h; row++, rowPosition += rowSize) // for each line { - if (!connection_ok || !client.connected()) break; + if (!connection_ok || !(client.connected() || client.available())) break; delay(1); // yield() to avoid WDT uint32_t in_remain = rowSize; uint32_t in_idx = 0; @@ -595,7 +604,7 @@ void drawBitmapFrom_HTTPS_ToBuffer(const char* host, const char* path, const cha for (uint16_t col = 0; col < w; col++) // for each pixel { yield(); - if (!connection_ok || !client.connected()) break; + if (!connection_ok || !(client.connected() || client.available())) break; // Time to read more pixel data? if (in_idx >= in_bytes) // ok, exact match for 24bit also (size IS multiple of 3) { @@ -760,7 +769,7 @@ uint32_t skip(WiFiClient& client, int32_t bytes) { int32_t remain = bytes; uint32_t start = millis(); - while (client.connected() && (remain > 0)) + while ((client.connected() || client.available()) && (remain > 0)) { if (client.available()) { @@ -777,7 +786,7 @@ uint32_t read(WiFiClient& client, uint8_t* buffer, int32_t bytes) { int32_t remain = bytes; uint32_t start = millis(); - while (client.connected() && (remain > 0)) + while ((client.connected() || client.available()) && (remain > 0)) { if (client.available()) { diff --git a/examples/GxFont_GFX_Example/GxFont_GFX_Example.ino b/examples/GxFont_GFX_Example/GxFont_GFX_Example.ino index b3fa8bd..0368a5c 100644 --- a/examples/GxFont_GFX_Example/GxFont_GFX_Example.ino +++ b/examples/GxFont_GFX_Example/GxFont_GFX_Example.ino @@ -51,6 +51,13 @@ // mapping suggestion for AVR, UNO, NANO etc. // BUSY -> 7, RST -> 9, DC -> 8, CS-> 10, CLK -> 13, DIN -> 11 +// mapping suggestion for Arduino MEGA +// BUSY -> 7, RST -> 9, DC -> 8, CS-> 53, CLK -> 52, DIN -> 51 + +// mapping suggestion for Arduino DUE +// BUSY -> 7, RST -> 9, DC -> 8, CS-> 77, CLK -> 76, DIN -> 75 +// SPI pins are also on 6 pin 2x3 SPI header + // include library, include base class, make path known #include @@ -62,7 +69,9 @@ //#include // 1.54" b/w //#include // 1.54" b/w/r 200x200 //#include // 1.54" b/w/r 152x152 +//#include // 2.13" b/w 104x212 flexible //#include // 2.13" b/w +//#include // 2.13" b/w new panel //#include // 2.13" b/w/r //#include // 2.9" b/w //#include // 2.9" b/w/r @@ -318,6 +327,3 @@ void showTextFont(const char name[], uint8_t f, uint8_t size) display.update(); } #endif - - - diff --git a/extras/Particle/examples/GxEPD_ParticleExample/project.properties b/extras/Particle/examples/GxEPD_ParticleExample/project.properties new file mode 100644 index 0000000..02b9b19 --- /dev/null +++ b/extras/Particle/examples/GxEPD_ParticleExample/project.properties @@ -0,0 +1,2 @@ +name=GxEPD_ParticleExample +dependencies.GxEPD=3.0.7 \ No newline at end of file diff --git a/extras/Particle/examples/GxEPD_ParticleExample/src/GxEPD_ParticleExample.ino b/extras/Particle/examples/GxEPD_ParticleExample/src/GxEPD_ParticleExample.ino new file mode 100644 index 0000000..0609186 --- /dev/null +++ b/extras/Particle/examples/GxEPD_ParticleExample/src/GxEPD_ParticleExample.ino @@ -0,0 +1,508 @@ +// GxEPD_Example : test example for e-Paper displays from Waveshare and from Dalian Good Display Inc. +// +// Created by Jean-Marc Zingg based on demo code from Good Display, +// available on http://www.e-paper-display.com/download_list/downloadcategoryid=34&isMode=false.html +// +// The e-paper displays are available from: +// +// https://www.aliexpress.com/store/product/Wholesale-1-54inch-E-Ink-display-module-with-embedded-controller-200x200-Communicate-via-SPI-interface-Supports/216233_32824535312.html +// +// http://www.buy-lcd.com/index.php?route=product/product&path=2897_8363&product_id=35120 +// or https://www.aliexpress.com/store/product/E001-1-54-inch-partial-refresh-Small-size-dot-matrix-e-paper-display/600281_32815089163.html +// +#include +#include + +// Supporting Arduino Forum Topics: +// Waveshare e-paper displays with SPI: http://forum.arduino.cc/index.php?topic=487007.0 +// Good Dispay ePaper for Arduino: https://forum.arduino.cc/index.php?topic=436411.0 + +// mapping suggestion from Waveshare SPI e-Paper to Particle Photon +// A5 MOSI +// A4 MISO +// A3 SCK +// A2 SS +// BUSY -> D4, RST -> A0, DC -> A1, CS -> A2, CLK -> A3, DIN -> A5, GND -> GND, 3.3V -> 3.3V +// NOTE: it looks like MISO can't be used as general input pin for BUSY. + +// select the display class to use, only one +//#include // 1.54" b/w +//#include // 1.54" b/w/r 200x200 +//#include // 1.54" b/w/r 152x152 +//#include // 2.13" b/w 104x212 flexible +//#include // 2.13" b/w +#include // 2.13" b/w new panel +//#include // 2.13" b/w/r +//#include // 2.9" b/w +//#include // 2.9" b/w IL0373 +//#include // 2.9" b/w/r +//#include // 2.7" b/w/r +//#include // 2.7" b/w +//#include // 4.2" b/w +//#include // 4.2" b/w/r +//#include // 5.83" b/w +//#include // 7.5" b/w +//#include // 7.5" b/w/r + +#include GxEPD_BitmapExamples + +// FreeFonts from Adafruit_GFX +#include +#include +#include +#include + + +#include +#include + +GxIO_Class io(SPI, /*CS=*/ SS, /*DC=*/ A1, /*RST=*/ A0); +GxEPD_Class display(io, /*RST=*/ A0, /*BUSY=*/ D4); + +void setup() +{ + Serial.begin(115200); + Serial.println(); + Serial.println("setup"); + + display.init(115200); // enable diagnostic output on Serial + + Serial.println("setup done"); +} + +void loop() +{ + showBitmapExample(); + delay(2000); +#if !defined(__AVR) + //drawCornerTest(); + showFont("FreeMonoBold9pt7b", &FreeMonoBold9pt7b); + showFont("FreeMonoBold12pt7b", &FreeMonoBold12pt7b); + //showFont("FreeMonoBold18pt7b", &FreeMonoBold18pt7b); + //showFont("FreeMonoBold24pt7b", &FreeMonoBold24pt7b); +#else + display.drawCornerTest(); + delay(2000); + display.drawPaged(showFontCallback); +#endif + delay(10000); +} + +#if defined(_GxGDEP015OC1_H_) +void showBitmapExample() +{ + display.drawExampleBitmap(BitmapExample1, sizeof(BitmapExample1)); + delay(2000); + display.drawExampleBitmap(BitmapExample2, sizeof(BitmapExample2)); + delay(5000); + display.fillScreen(GxEPD_WHITE); + display.drawExampleBitmap(BitmapExample1, 0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_BLACK); + display.update(); + delay(5000); + showBoat(); +} +#endif + +#if defined(_GxGDEW0154Z04_H_) +#define HAS_RED_COLOR +void showBitmapExample() +{ +#if !defined(__AVR) + display.drawPicture(BitmapWaveshare_black, BitmapWaveshare_red, sizeof(BitmapWaveshare_black), sizeof(BitmapWaveshare_red), GxEPD::bm_normal); + delay(5000); +#endif + display.drawExamplePicture(BitmapExample1, BitmapExample2, sizeof(BitmapExample1), sizeof(BitmapExample2)); + delay(5000); +} +#endif + +#if defined(_GxGDEW0154Z17_H_) +#define HAS_RED_COLOR +void showBitmapExample() +{ + display.drawExamplePicture(BitmapExample1, BitmapExample2, sizeof(BitmapExample1), sizeof(BitmapExample2)); + delay(5000); + display.drawExamplePicture(BitmapExample3, BitmapExample4, sizeof(BitmapExample1), sizeof(BitmapExample2)); + delay(5000); + //display.drawBitmap(BitmapExample2, sizeof(BitmapExample2)); +} +#endif + +#if defined(_GxGDE0213B1_H_) +void showBitmapExample() +{ + display.drawBitmap(BitmapExample1, sizeof(BitmapExample1)); + delay(2000); + display.drawBitmap(BitmapExample2, sizeof(BitmapExample2)); + delay(5000); +#if !defined(__AVR) + display.drawBitmap(first, sizeof(first)); + delay(5000); + display.drawBitmap(second, sizeof(second)); + delay(5000); + display.drawBitmap(third, sizeof(third)); + delay(5000); +#endif + display.fillScreen(GxEPD_WHITE); + display.drawExampleBitmap(BitmapExample1, 0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_BLACK); + display.update(); + delay(5000); + showBoat(); +} +#endif + +#if defined(_GxGDEH0213B72_H_) +void showBitmapExample() +{ + display.drawExampleBitmap(BitmapExample1, sizeof(BitmapExample1)); + delay(2000); + display.drawExampleBitmap(BitmapExample2, sizeof(BitmapExample2)); + delay(5000); +#if !defined(__AVR) + display.drawExampleBitmap(BitmapExample3, sizeof(BitmapExample3)); + delay(5000); + display.drawExampleBitmap(logo, sizeof(logo)); + delay(5000); + display.drawExampleBitmap(first, sizeof(first)); + delay(5000); + display.drawExampleBitmap(second, sizeof(second)); + delay(5000); + display.drawExampleBitmap(third, sizeof(third)); + delay(5000); +#endif + display.fillScreen(GxEPD_WHITE); + display.drawExampleBitmap(BitmapExample1, 0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_BLACK); + display.update(); + delay(5000); + showBoat(); +} +#endif + +#if defined(_GxGDEW0213I5F_H_) +void showBitmapExample() +{ + display.drawBitmap(BitmapExample1, sizeof(BitmapExample1), GxEPD::bm_invert); + delay(5000); + display.drawBitmap(BitmapExample2, sizeof(BitmapExample2)); + delay(5000); +#if !defined(__AVR) + display.drawBitmap(BitmapExample3, sizeof(BitmapExample3)); + delay(5000); + display.drawBitmap(BitmapExample4, sizeof(BitmapExample4)); + delay(5000); +#endif + display.fillScreen(GxEPD_WHITE); + display.drawBitmap(BitmapExample1, 0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_BLACK); + display.update(); + delay(5000); +} +#endif + +#if defined(_GxGDEW0213Z16_H_) +#define HAS_RED_COLOR +void showBitmapExample() +{ + display.drawPicture(BitmapWaveshare_black, BitmapWaveshare_red, sizeof(BitmapWaveshare_black), sizeof(BitmapWaveshare_red)); + delay(5000); + display.drawExamplePicture(BitmapExample1, BitmapExample2, sizeof(BitmapExample1), sizeof(BitmapExample2)); + delay(5000); +#if !defined(__AVR) + display.drawExamplePicture(BitmapExample3, BitmapExample4, sizeof(BitmapExample3), sizeof(BitmapExample4)); + delay(5000); +#endif + display.drawExampleBitmap(BitmapWaveshare_black, sizeof(BitmapWaveshare_black)); + delay(2000); + // example bitmaps for b/w/r are normal on b/w, but inverted on red + display.drawExampleBitmap(BitmapExample1, sizeof(BitmapExample1)); + delay(2000); + display.drawExampleBitmap(BitmapExample2, sizeof(BitmapExample2), GxEPD::bm_invert); + delay(2000); + display.drawExampleBitmap(BitmapExample1, 0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_BLACK); + display.update(); +} +#endif + +#if defined(_GxGDEH029A1_H_) +void showBitmapExample() +{ + display.drawExampleBitmap(BitmapExample1, sizeof(BitmapExample1)); + delay(2000); + display.drawExampleBitmap(BitmapExample2, sizeof(BitmapExample2)); + delay(5000); + display.fillScreen(GxEPD_WHITE); + display.drawExampleBitmap(BitmapExample1, 0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_BLACK); + display.update(); + delay(5000); + showBoat(); +} +#endif + +#if defined(_GxGDEW029T5_H_) +void showBitmapExample() +{ + display.drawExampleBitmap(BitmapExample1, sizeof(BitmapExample1)); + delay(2000); + display.drawExampleBitmap(BitmapExample2, sizeof(BitmapExample2)); + delay(5000); + display.drawExampleBitmap(BitmapExample3, sizeof(BitmapExample3)); + delay(5000); + display.fillScreen(GxEPD_WHITE); + display.drawExampleBitmap(BitmapExample1, 0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_BLACK); + display.update(); + delay(5000); +// showBoat(); +} +#endif + +#if defined(_GxGDEW029Z10_H_) +#define HAS_RED_COLOR +void showBitmapExample() +{ +#if defined(__AVR) + display.drawExamplePicture(BitmapExample1, BitmapExample2, sizeof(BitmapExample1), sizeof(BitmapExample2)); + delay(5000); +#else + display.drawPicture(BitmapWaveshare_black, BitmapWaveshare_red, sizeof(BitmapWaveshare_black), sizeof(BitmapWaveshare_red)); + delay(5000); + display.drawExamplePicture(BitmapExample1, BitmapExample2, sizeof(BitmapExample1), sizeof(BitmapExample2)); + delay(5000); + display.drawExamplePicture(BitmapExample3, BitmapExample4, sizeof(BitmapExample3), sizeof(BitmapExample4)); + delay(5000); + display.drawExampleBitmap(BitmapWaveshare_black, sizeof(BitmapWaveshare_black)); + delay(2000); + // example bitmaps for b/w/r are normal on b/w, but inverted on red + display.drawExampleBitmap(BitmapExample1, sizeof(BitmapExample1)); + delay(2000); + display.drawExampleBitmap(BitmapExample2, sizeof(BitmapExample2), GxEPD::bm_invert); + delay(2000); +#endif + display.drawExampleBitmap(BitmapExample1, 0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_BLACK); + display.update(); +} +#endif + +#if defined(_GxGDEW027C44_H_) +#define HAS_RED_COLOR +void showBitmapExample() +{ + // draw black and red bitmap + display.drawPicture(BitmapExample1, BitmapExample2, sizeof(BitmapExample1), sizeof(BitmapExample2)); + delay(5000); + return; + display.drawBitmap(BitmapExample1, sizeof(BitmapExample1)); + delay(2000); + display.fillScreen(GxEPD_WHITE); + display.drawBitmap(0, 0, BitmapExample1, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_BLACK); + display.update(); +} +#endif + +#if defined(_GxGDEW027W3_H_) +void showBitmapExample() +{ + display.drawExampleBitmap(BitmapExample1, sizeof(BitmapExample1)); + delay(2000); +#if !defined(__AVR) + display.drawExampleBitmap(BitmapExample2, sizeof(BitmapExample2)); + delay(2000); + display.drawExampleBitmap(BitmapExample3, sizeof(BitmapExample3)); + delay(2000); + display.drawExampleBitmap(BitmapExample4, sizeof(BitmapExample4)); + delay(2000); + display.drawExampleBitmap(BitmapExample5, sizeof(BitmapExample5)); + delay(2000); +#endif + display.drawExampleBitmap(BitmapWaveshare, sizeof(BitmapWaveshare)); + delay(5000); + display.fillScreen(GxEPD_WHITE); + display.drawExampleBitmap(BitmapExample1, 0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_BLACK); + display.update(); +} +#endif + +#if defined(_GxGDEW042T2_H_) || defined(_GxGDEW042T2_FPU_H_) +void showBitmapExample() +{ +#if defined(__AVR) + display.drawBitmap(BitmapExample1, sizeof(BitmapExample1)); +#else + display.drawExampleBitmap(BitmapExample1, sizeof(BitmapExample1)); + delay(2000); + display.drawExampleBitmap(BitmapExample2, sizeof(BitmapExample2)); + delay(5000); + display.fillScreen(GxEPD_WHITE); + display.drawExampleBitmap(BitmapExample1, 0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_BLACK); + display.update(); +#endif +} +#endif + +#if defined(_GxGDEW042Z15_H_) +#define HAS_RED_COLOR +void showBitmapExample() +{ +#if defined(__AVR) + display.drawBitmap(BitmapExample1, sizeof(BitmapExample1)); +#else + // draw black and red bitmap + display.drawPicture(BitmapExample1, BitmapExample2, sizeof(BitmapExample1), sizeof(BitmapExample2)); + delay(5000); + display.drawPicture(BitmapExample3, BitmapExample4, sizeof(BitmapExample3), sizeof(BitmapExample4)); + delay(5000); + display.drawPicture(BitmapWaveshare_black, BitmapWaveshare_red, sizeof(BitmapWaveshare_black), sizeof(BitmapWaveshare_red)); + delay(5000); + display.drawBitmap(BitmapExample1, sizeof(BitmapExample1)); + delay(2000); + display.drawExampleBitmap(BitmapExample1, 0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_BLACK); + display.update(); +#endif +} +#endif + +#if defined(_GxGDEW0583T7_H_) +void showBitmapExample() +{ +#if defined(__AVR) + //display.drawBitmap(BitmapExample1, sizeof(BitmapExample1)); +#else + display.drawExampleBitmap(BitmapExample1, sizeof(BitmapExample1)); + delay(2000); + display.fillScreen(GxEPD_WHITE); + display.drawExampleBitmap(BitmapExample1, 0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_BLACK); + display.update(); +#endif +} +#endif + +#if defined(_GxGDEW075T8_H_) +void showBitmapExample() +{ +#if defined(__AVR) + display.drawBitmap(BitmapExample1, sizeof(BitmapExample1)); +#else + display.drawExampleBitmap(BitmapExample1, sizeof(BitmapExample1)); + delay(2000); + display.drawExampleBitmap(BitmapExample2, sizeof(BitmapExample2)); + delay(5000); + display.fillScreen(GxEPD_WHITE); + display.drawExampleBitmap(BitmapExample1, 0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_BLACK); + display.update(); +#endif +} +#endif + +#if defined(_GxGDEW075Z09_H_) +#define HAS_RED_COLOR +void showBitmapExample() +{ +#if defined(__AVR) + display.drawBitmap(BitmapExample1, sizeof(BitmapExample1)); +#elif defined(ARDUINO_GENERIC_STM32F103C) + display.drawBitmap(BitmapExample1, sizeof(BitmapExample1)); +#elif defined(ARDUINO_GENERIC_STM32F103V) + display.drawExampleBitmap(BitmapExample1, sizeof(BitmapExample1)); + delay(2000); + display.drawExamplePicture_3C(BitmapPicture_3C, sizeof(BitmapPicture_3C)); +#else + display.drawExampleBitmap(BitmapExample1, sizeof(BitmapExample1)); + delay(2000); + display.drawExampleBitmap(BitmapExample2, sizeof(BitmapExample2)); + delay(5000); + display.drawExamplePicture_3C(BitmapPicture_3C, sizeof(BitmapPicture_3C)); +#endif +} +#endif + +void showFont(const char name[], const GFXfont* f) +{ + display.fillScreen(GxEPD_WHITE); + display.setTextColor(GxEPD_BLACK); + display.setFont(f); + display.setCursor(0, 0); + display.println(); + display.println(name); + display.println(" !\"#$%&'()*+,-./"); + display.println("0123456789:;<=>?"); + display.println("@ABCDEFGHIJKLMNO"); + display.println("PQRSTUVWXYZ[\\]^_"); +#if defined(HAS_RED_COLOR) + display.setTextColor(GxEPD_RED); +#endif + display.println("`abcdefghijklmno"); + display.println("pqrstuvwxyz{|}~ "); + display.update(); + delay(5000); +} + +void showFontCallback() +{ + const char* name = "FreeMonoBold9pt7b"; + const GFXfont* f = &FreeMonoBold9pt7b; + display.fillScreen(GxEPD_WHITE); + display.setTextColor(GxEPD_BLACK); + display.setFont(f); + display.setCursor(0, 0); + display.println(); + display.println(name); + display.println(" !\"#$%&'()*+,-./"); + display.println("0123456789:;<=>?"); + display.println("@ABCDEFGHIJKLMNO"); + display.println("PQRSTUVWXYZ[\\]^_"); +#if defined(HAS_RED_COLOR) + display.setTextColor(GxEPD_RED); +#endif + display.println("`abcdefghijklmno"); + display.println("pqrstuvwxyz{|}~ "); +} + +void drawCornerTest() +{ + display.drawCornerTest(); + delay(5000); + uint8_t rotation = display.getRotation(); + for (uint16_t r = 0; r < 4; r++) + { + display.setRotation(r); + display.fillScreen(GxEPD_WHITE); + display.fillRect(0, 0, 8, 8, GxEPD_BLACK); + display.fillRect(display.width() - 18, 0, 16, 16, GxEPD_BLACK); + display.fillRect(display.width() - 25, display.height() - 25, 24, 24, GxEPD_BLACK); + display.fillRect(0, display.height() - 33, 32, 32, GxEPD_BLACK); + display.update(); + delay(5000); + } + display.setRotation(rotation); // restore +} + +#if defined(_GxGDEP015OC1_H_) || defined(_GxGDE0213B1_H_) || defined(_GxGDEH0213B72_H_) || defined(_GxGDEH029A1_H_) +#include "IMG_0001.h" +void showBoat() +{ + // thanks to bytecrusher: http://forum.arduino.cc/index.php?topic=487007.msg3367378#msg3367378 + uint16_t x = (display.width() - 64) / 2; + uint16_t y = 5; + display.fillScreen(GxEPD_WHITE); + display.drawExampleBitmap(gImage_IMG_0001, x, y, 64, 180, GxEPD_BLACK); + display.update(); + delay(500); + uint16_t forward = GxEPD::bm_invert | GxEPD::bm_flip_x; + uint16_t reverse = GxEPD::bm_invert | GxEPD::bm_flip_x | GxEPD::bm_flip_y; + for (; y + 180 + 5 <= display.height(); y += 5) + { + display.fillScreen(GxEPD_WHITE); + display.drawExampleBitmap(gImage_IMG_0001, x, y, 64, 180, GxEPD_BLACK, forward); + display.updateWindow(0, 0, display.width(), display.height()); + delay(500); + } + delay(1000); + for (; y >= 5; y -= 5) + { + display.fillScreen(GxEPD_WHITE); + display.drawExampleBitmap(gImage_IMG_0001, x, y, 64, 180, GxEPD_BLACK, reverse); + display.updateWindow(0, 0, display.width(), display.height()); + delay(1000); + } + display.update(); + delay(1000); +} +#endif diff --git a/extras/Particle/examples/GxEPD_ParticleExample/src/IMG_0001.h b/extras/Particle/examples/GxEPD_ParticleExample/src/IMG_0001.h new file mode 100644 index 0000000..c7e34a4 --- /dev/null +++ b/extras/Particle/examples/GxEPD_ParticleExample/src/IMG_0001.h @@ -0,0 +1,104 @@ +#ifndef _GxBootExample_H_ +#define _GxBootExample_H_ + +#if defined(ESP8266) || defined(ESP32) +#include +#else +#include +#endif + +// 180 x 64 (Boot) +const unsigned char gImage_IMG_0001[1440] PROGMEM = { /* 0X01,0X01,0XB4,0X00,0X40,0X00, */ +0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, +0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0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,0XFF,0XFF,0XFF,0XFF,0XF8,0X38,0X60,0X7F,0XFF, +0XFF,0XFF,0XFF,0XFC,0X3C,0X20,0XFF,0XFF,0XFF,0XFF,0XFF,0XFC,0X1C,0X01,0XFF,0XFF, +0XFF,0XFF,0XFF,0XFE,0X18,0X03,0XFF,0XFF,0XFF,0XFF,0XFF,0XFE,0X18,0X03,0XFF,0XFF, +0XFF,0XFF,0XFF,0XFF,0X18,0X07,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X08,0X07,0XFF,0XFF, +0XFF,0XFF,0XFF,0XFF,0X08,0X0F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X00,0X1F,0XFF,0XFF, +0XFF,0XFF,0XFF,0XFF,0X80,0X3F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X80,0X7F,0XFF,0XFF, +0XFF,0XFF,0XFF,0XFF,0XF8,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, +0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, +0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, +0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, +0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, +}; +#endif + diff --git a/extras/Particle/examples/GxEPD_ParticleExample/src/src.ino b/extras/Particle/examples/GxEPD_ParticleExample/src/src.ino new file mode 100644 index 0000000..e69de29 diff --git a/extras/Particle/examples/GxEPD_ParticlePartialUpdateExample/project.properties b/extras/Particle/examples/GxEPD_ParticlePartialUpdateExample/project.properties new file mode 100644 index 0000000..98cb9b6 --- /dev/null +++ b/extras/Particle/examples/GxEPD_ParticlePartialUpdateExample/project.properties @@ -0,0 +1,2 @@ +name=GxEPD_ParticlePartialUpdateExample +dependencies.GxEPD=3.0.7 \ No newline at end of file diff --git a/extras/Particle/examples/GxEPD_ParticlePartialUpdateExample/src/GxEPD_ParticlePartialUpdateExample.ino b/extras/Particle/examples/GxEPD_ParticlePartialUpdateExample/src/GxEPD_ParticlePartialUpdateExample.ino new file mode 100644 index 0000000..95cdef3 --- /dev/null +++ b/extras/Particle/examples/GxEPD_ParticlePartialUpdateExample/src/GxEPD_ParticlePartialUpdateExample.ino @@ -0,0 +1,350 @@ +// PartialUpdateExample : example for Waveshare 1.54", 2.31" and 2.9" e-Paper and the same e-papers from Dalian Good Display Inc. +// +// Created by Jean-Marc Zingg based on demo code from Good Display for GDEP015OC1. +// +// The e-paper displays are available from: +// +// https://www.aliexpress.com/store/product/Wholesale-1-54inch-E-Ink-display-module-with-embedded-controller-200x200-Communicate-via-SPI-interface-Supports/216233_32824535312.html +// +// http://www.buy-lcd.com/index.php?route=product/product&path=2897_8363&product_id=35120 +// or https://www.aliexpress.com/store/product/E001-1-54-inch-partial-refresh-Small-size-dot-matrix-e-paper-display/600281_32815089163.html +// +#include +#include + +// Supporting Arduino Forum Topics: +// Waveshare e-paper displays with SPI: http://forum.arduino.cc/index.php?topic=487007.0 +// Good Dispay ePaper for Arduino: https://forum.arduino.cc/index.php?topic=436411.0 + +// mapping suggestion from Waveshare SPI e-Paper to Particle Photon +// A5 MOSI +// A4 MISO +// A3 SCK +// A2 SS +// BUSY -> D4, RST -> A0, DC -> A1, CS -> A2, CLK -> A3, DIN -> A5, GND -> GND, 3.3V -> 3.3V +// NOTE: it looks like MISO can't be used as general input pin for BUSY. + +// Supporting Arduino Forum Topics: +// Waveshare e-paper displays with SPI: http://forum.arduino.cc/index.php?topic=487007.0 +// Good Dispay ePaper for Arduino : https://forum.arduino.cc/index.php?topic=436411.0 + +// select the display class to use, only one +//#include // 1.54" b/w +//#include // 2.13" b/w 104x212 flexible +//#include // 2.13" b/w +#include // 2.13" b/w new panel +//#include // 2.9" b/w +//#include // 2.9" b/w IL0373 +//#include // 2.7" b/w +//#include // 4.2" b/w +// these displays do not fully support partial update +//#include // 1.54" b/w/r 152x152 +//#include // 2.13" b/w/r +//#include // 2.9" b/w/r +//#include // 2.7" b/w/r +//#include // 4.2" b/w/r +//#include // 5.83" b/w +//#include // 7.5" b/w +//#include // 7.5" b/w/r + +// FreeFonts from Adafruit_GFX +#include + +#include GxEPD_BitmapExamples + +#include +#include + +GxIO_Class io(SPI, /*CS=*/ SS, /*DC=*/ A1, /*RST=*/ A0); +GxEPD_Class display(io, /*RST=*/ A0, /*BUSY=*/ D4); + +//#define DEMO_DELAY 3*60 // seconds +//#define DEMO_DELAY 1*60 // seconds +#define DEMO_DELAY 30 + +void setup(void) +{ + Serial.begin(115200); + Serial.println(); + Serial.println("setup"); + display.init(115200); // enable diagnostic output on Serial + Serial.println("setup done"); +} + +void loop() +{ +#if defined(__AVR) || false + showPartialUpdatePaged(); +#elif defined(_GxGDEW075Z09_H_) && (defined(ESP8266) || defined(ARDUINO_ARCH_STM32F1)) + showPartialUpdatePaged(); +#elif defined(_GxGDEW075Z09_H_) + showPartialUpdate_75Z09(); +#else + showPartialUpdate(); +#endif + delay(DEMO_DELAY * 1000); +} + +#if !defined(__AVR) + +void showPartialUpdate() +{ + // use asymmetric values for test + uint16_t box_x = 10; + uint16_t box_y = 15; + uint16_t box_w = 70; + uint16_t box_h = 20; + uint16_t cursor_y = box_y + box_h - 6; + float value = 13.95; + display.setFont(&FreeMonoBold9pt7b); + display.setTextColor(GxEPD_BLACK); + display.setRotation(0); + // draw background + display.drawExampleBitmap(BitmapExample1, 0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_BLACK); + display.update(); + delay(2000); + + // partial update to full screen to preset for partial update of box window + // (this avoids strange background effects) + display.updateWindow(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, false); + + // show where the update box is + for (uint16_t r = 0; r < 4; r++) + { + display.setRotation(r); + display.fillRect(box_x, box_y, box_w, box_h, GxEPD_BLACK); + display.updateWindow(box_x, box_y, box_w, box_h, true); + delay(1000); + display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE); + display.updateWindow(box_x, box_y, box_w, box_h, true); + } + // show updates in the update box + for (uint16_t r = 0; r < 4; r++) + { + // reset the background + display.setRotation(0); + display.drawExampleBitmap(BitmapExample1, 0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_BLACK); + display.updateWindow(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, false); + display.setRotation(r); + for (uint16_t i = 1; i <= 10; i++) + { + display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE); + display.setCursor(box_x, cursor_y); + display.print(value * i, 2); + display.updateWindow(box_x, box_y, box_w, box_h, true); + delay(2000); + } + delay(2000); + display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE); + display.updateWindow(box_x, box_y, box_w, box_h, true); + } + // should have checked this, too + box_x = GxEPD_HEIGHT - box_x - box_w - 1; // not valid for all corners + // should show on right side of long side + // reset the background + display.setRotation(0); + display.drawExampleBitmap(BitmapExample1, 0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_BLACK); + display.updateWindow(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, false); + // show where the update box is + for (uint16_t r = 0; r < 4; r++) + { + display.setRotation(r); + display.fillRect(box_x, box_y, box_w, box_h, GxEPD_BLACK); + display.updateWindow(box_x, box_y, box_w, box_h, true); + delay(1000); + display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE); + display.updateWindow(box_x, box_y, box_w, box_h, true); + } + // show updates in the update box + for (uint16_t r = 0; r < 4; r++) + { + // reset the background + display.setRotation(0); + display.drawExampleBitmap(BitmapExample1, 0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_BLACK); + display.updateWindow(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, false); + display.setRotation(r); + if (box_x >= display.width()) continue; // avoid delay + for (uint16_t i = 1; i <= 10; i++) + { + display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE); + display.setCursor(box_x, cursor_y); + display.print(value * i, 2); + display.updateWindow(box_x, box_y, box_w, box_h, true); + delay(2000); + } + delay(2000); + display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE); + display.updateWindow(box_x, box_y, box_w, box_h, true); + } + display.setRotation(0); + display.powerDown(); +} + +#endif + +#if defined(_GxGDEW075Z09_H_) && !(defined(ESP8266) || defined(ARDUINO_ARCH_STM32F1)) + +void showPartialUpdate_75Z09() +{ + // use asymmetric values for test + uint16_t box_x = 10; + uint16_t box_y = 15; + uint16_t box_w = 70; + uint16_t box_h = 20; + uint16_t cursor_y = box_y + box_h - 6; + float value = 13.95; + display.setFont(&FreeMonoBold9pt7b); + display.setTextColor(GxEPD_BLACK); + display.setRotation(0); + // draw background, partial update to full screen to preset for partial update of box window + // (updateWindow() would clear display if partial update not set, to avoid strange background effect) + display.drawExamplePicture_3C(BitmapPicture_3C, sizeof(BitmapPicture_3C), GxEPD::bm_partial_update); + // show where the update box is + for (uint16_t r = 0; r < 4; r++) + { + display.setRotation(r); + display.fillRect(box_x, box_y, box_w, box_h, GxEPD_BLACK); + display.updateWindow(box_x, box_y, box_w, box_h, true); + delay(1000); + display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE); + display.updateWindow(box_x, box_y, box_w, box_h, true); + } + // show updates in the update box + for (uint16_t r = 0; r < 4; r++) + { + // reset the background + display.setRotation(0); + display.drawExamplePicture_3C(BitmapPicture_3C, sizeof(BitmapPicture_3C), GxEPD::bm_partial_update); + display.setRotation(r); + for (uint16_t i = 1; i <= 10; i++) + { + display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE); + display.setCursor(box_x, cursor_y); + display.print(value * i, 2); + display.updateWindow(box_x, box_y, box_w, box_h, true); + delay(2000); + } + delay(2000); + display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE); + display.updateWindow(box_x, box_y, box_w, box_h, true); + } + // should have checked this, too + box_x = GxEPD_HEIGHT - box_x - box_w - 1; // not valid for all corners + // should show on right side of long side + // reset the background + display.setRotation(0); + display.drawExamplePicture_3C(BitmapPicture_3C, sizeof(BitmapPicture_3C), GxEPD::bm_partial_update); + // show where the update box is + for (uint16_t r = 0; r < 4; r++) + { + display.setRotation(r); + display.fillRect(box_x, box_y, box_w, box_h, GxEPD_BLACK); + display.updateWindow(box_x, box_y, box_w, box_h, true); + delay(1000); + display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE); + display.updateWindow(box_x, box_y, box_w, box_h, true); + } + // show updates in the update box + for (uint16_t r = 0; r < 4; r++) + { + // reset the background + display.setRotation(0); + display.drawExamplePicture_3C(BitmapPicture_3C, sizeof(BitmapPicture_3C), GxEPD::bm_partial_update); + display.setRotation(r); + if (box_x >= display.width()) continue; // avoid delay + for (uint16_t i = 1; i <= 10; i++) + { + display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE); + display.setCursor(box_x, cursor_y); + display.print(value * i, 2); + display.updateWindow(box_x, box_y, box_w, box_h, true); + delay(2000); + } + delay(2000); + display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE); + display.updateWindow(box_x, box_y, box_w, box_h, true); + } + display.setRotation(0); + display.powerDown(); +} + +#endif + +#if defined(__AVR) || defined(_GxGDEW075Z09_H_) && (defined(ESP8266) || defined(ARDUINO_ARCH_STM32F1)) || false + +// modified to avoid float; reduces program size ~2k (for GxGDEW042T2) + +void showBlackBoxCallback(uint32_t v) +{ + uint16_t box_x = 10; + uint16_t box_y = 15; + uint16_t box_w = 70; + uint16_t box_h = 20; + display.fillRect(box_x, box_y, box_w, box_h, v); +} + +void showValueBoxCallback(const uint32_t v) +{ + uint16_t box_x = 10; + uint16_t box_y = 15; + uint16_t box_w = 70; + uint16_t box_h = 20; + uint16_t cursor_y = box_y + box_h - 6; + display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE); + display.setCursor(box_x, cursor_y); + display.print(v / 100); + display.print(v % 100 > 9 ? "." : ".0"); + display.print(v % 100); +} + +void showPartialUpdatePaged() +{ + uint16_t box_x = 10; + uint16_t box_y = 15; + uint16_t box_w = 70; + uint16_t box_h = 20; + uint16_t cursor_y = box_y + box_h - 6; + uint32_t value = 1395; + display.setFont(&FreeMonoBold9pt7b); + display.setTextColor(GxEPD_BLACK); + display.setRotation(0); + // draw background + display.drawExampleBitmap(BitmapExample1, sizeof(BitmapExample1)); + delay(2000); + + // partial update to full screen to preset for partial update of box window + // (this avoids strange background effects) + display.drawExampleBitmap(BitmapExample1, sizeof(BitmapExample1), GxEPD::bm_default | GxEPD::bm_partial_update); + delay(1000); + + // show where the update box is + for (uint16_t r = 0; r < 4; r++) + { + display.setRotation(r); + display.drawPagedToWindow(showBlackBoxCallback, box_x, box_y, box_w, box_h, GxEPD_BLACK); + delay(1000); + display.drawPagedToWindow(showBlackBoxCallback, box_x, box_y, box_w, box_h, GxEPD_WHITE); + } + + // show updates in the update box + for (uint16_t r = 0; r < 4; r++) + { + // reset the background + display.drawExampleBitmap(BitmapExample1, sizeof(BitmapExample1), GxEPD::bm_default | GxEPD::bm_partial_update); + display.setRotation(r); + for (uint16_t i = 1; i <= 10; i++) + { + uint32_t v = value * i; + display.drawPagedToWindow(showValueBoxCallback, box_x, box_y, box_w, box_h, v); + delay(500); + } + delay(1000); + display.drawPagedToWindow(showBlackBoxCallback, box_x, box_y, box_w, box_h, GxEPD_WHITE); + } + // reset the background + display.drawExampleBitmap(BitmapExample1, sizeof(BitmapExample1), GxEPD::bm_default | GxEPD::bm_partial_update); + display.setRotation(0); + display.powerDown(); +} + +#endif diff --git a/extras/Particle/examples/GxEPD_ParticlePartialUpdateExample/src/src.ino b/extras/Particle/examples/GxEPD_ParticlePartialUpdateExample/src/src.ino new file mode 100644 index 0000000..e69de29 diff --git a/library.properties b/library.properties index 0786d66..e8b687f 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=GxEPD -version=3.0.6 +version=3.0.7 author=Jean-Marc Zingg maintainer=Jean-Marc Zingg sentence=Display Library for SPI e-paper panels from Dalian Good Display and boards from Waveshare. @@ -7,3 +7,5 @@ paragraph=GxEPD2 is better suited for new users or new projects! category=Display url=https://github.com/ZinggJM/GxEPD architectures=* +#next line is for support of Particle development environment, ignored by Arduino IDE +dependencies.Adafruit_GFX_RK=1.3.5 diff --git a/src/GxEPD.h b/src/GxEPD.h index 2749631..9f7c741 100644 --- a/src/GxEPD.h +++ b/src/GxEPD.h @@ -78,6 +78,10 @@ class GxEPD : public GxFont_GFX virtual void eraseDisplay(bool using_partial_update = false) {}; // partial update of rectangle from buffer to screen, does not power off virtual void updateWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h, bool using_rotation = true) {}; + // partial update of rectangle at (xs,ys) from buffer to screen at (xd,yd), does not power off + virtual void updateToWindow(uint16_t xs, uint16_t ys, uint16_t xd, uint16_t yd, uint16_t w, uint16_t h, bool using_rotation = true) {}; + // terminate cleanly updateWindow or updateToWindow before removing power or long delays + virtual void powerDown() = 0; protected: void drawBitmapBM(const uint8_t *bitmap, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color, int16_t m); static inline uint16_t gx_uint16_min(uint16_t a, uint16_t b) {return (a < b ? a : b);}; @@ -85,4 +89,3 @@ class GxEPD : public GxFont_GFX }; #endif - diff --git a/src/GxFont_GFX.cpp b/src/GxFont_GFX.cpp index 90230b2..a0477bf 100644 --- a/src/GxFont_GFX.cpp +++ b/src/GxFont_GFX.cpp @@ -153,27 +153,27 @@ size_t GxFont_GFX::write(uint8_t v) { DIAG (Serial.write(v); Serial.println();) DIAG_UTF8(if (v > 127) Serial.println(v, HEX);) - switch (_font_gfx) - { - case Adafruit_GFX_font_gfx: - Adafruit_GFX::write(v); - break; + switch (_font_gfx) + { + case Adafruit_GFX_font_gfx: + Adafruit_GFX::write(v); + break; #if defined(U8g2_for_Adafruit_GFX_h) - case U8g2_for_Adafruit_GFX_font_gfx: - _U8G2_FONTS_GFX.write(v); - break; + case U8g2_for_Adafruit_GFX_font_gfx: + _U8G2_FONTS_GFX.write(v); + break; #endif #if defined(_ADAFRUIT_TF_GFX_H_) - case Adafruit_ftGFX_font_gfx: - _GxF_Adafruit_ftGFX.write(v); - break; + case Adafruit_ftGFX_font_gfx: + _GxF_Adafruit_ftGFX.write(v); + break; #endif #if defined(_GxFont_GFX_TFT_eSPI_H_) - case GxFont_GFX_TFT_eSPI_font_gfx: - _GxF_GxFont_GFX_TFT_eSPI.write(v); - break; + case GxFont_GFX_TFT_eSPI_font_gfx: + _GxF_GxFont_GFX_TFT_eSPI.write(v); + break; #endif - } + } } int16_t GxFont_GFX::getCursorX(void) const @@ -277,6 +277,11 @@ int16_t GxFont_GFX::drawUTF8(int16_t x, int16_t y, const char *str) return ((_font_gfx == U8g2_for_Adafruit_GFX_font_gfx) ? _U8G2_FONTS_GFX.drawUTF8(x, y, str) : 0); } +int16_t GxFont_GFX::getUTF8Width(const char *str) +{ + return ((_font_gfx == U8g2_for_Adafruit_GFX_font_gfx) ? _U8G2_FONTS_GFX.getUTF8Width(str) : 0); +} + uint16_t GxFont_GFX::utf8_next(uint8_t b) { return ((_font_gfx == U8g2_for_Adafruit_GFX_font_gfx) ? _U8G2_FONTS_GFX.utf8_next(b) : 0); @@ -436,4 +441,3 @@ int16_t GxFont_GFX::fontHeight(int16_t font) return ((_font_gfx == GxFont_GFX_TFT_eSPI_font_gfx) ? _GxF_GxFont_GFX_TFT_eSPI.fontHeight(font) : 0); } #endif - diff --git a/src/GxFont_GFX.h b/src/GxFont_GFX.h index 559dcb8..cb1b9ae 100644 --- a/src/GxFont_GFX.h +++ b/src/GxFont_GFX.h @@ -73,6 +73,7 @@ class GxFont_GFX : public Adafruit_GFX int16_t drawGlyph(int16_t x, int16_t y, uint16_t e); int16_t drawStr(int16_t x, int16_t y, const char *s); int16_t drawUTF8(int16_t x, int16_t y, const char *str); + int16_t getUTF8Width(const char *str); uint16_t utf8_next(uint8_t b); #endif #if defined(_ADAFRUIT_TF_GFX_H_) || defined(_GxFont_GFX_TFT_eSPI_H_) diff --git a/src/GxGDEW0154Z04/GxGDEW0154Z04.cpp b/src/GxGDEW0154Z04/GxGDEW0154Z04.cpp index 4c39f19..ced294c 100644 --- a/src/GxGDEW0154Z04/GxGDEW0154Z04.cpp +++ b/src/GxGDEW0154Z04/GxGDEW0154Z04.cpp @@ -1,7 +1,7 @@ -// class GxGDEW0154Z04 : Display class for GDEW0154Z04 e-Paper from Dalian Good Display Co., Ltd.: www.good-display.com +// class GxGDEW0154Z04 : Display class for GDEW0154Z04 e-Paper from Dalian Good Display Co., Ltd.: www.e-paper-display.com // -// based on Demo Example from Good Display, available here: http://www.good-display.com/download_detail/downloadsId=515.html -// Controller: IL0376F : http://www.good-display.com/download_detail/downloadsId=541.html +// based on Demo Example from Good Display, available here: http://www.e-paper-display.com/download_detail/downloadsId=515.html +// Controller: IL0376F : http://www.e-paper-display.com/download_detail/downloadsId=541.html // // Author : J-M Zingg // @@ -271,6 +271,11 @@ void GxGDEW0154Z04::eraseDisplay(bool using_partial_update) _sleep(); } +void GxGDEW0154Z04::powerDown() +{ + _sleep(); +} + void GxGDEW0154Z04::_writeCommand(uint8_t command) { IO.writeCommandTransaction(command); @@ -664,4 +669,3 @@ void GxGDEW0154Z04::drawCornerTest(uint8_t em) _waitWhileBusy("drawCornerTest"); _sleep(); } - diff --git a/src/GxGDEW0154Z04/GxGDEW0154Z04.h b/src/GxGDEW0154Z04/GxGDEW0154Z04.h index e919ca3..e194d1f 100644 --- a/src/GxGDEW0154Z04/GxGDEW0154Z04.h +++ b/src/GxGDEW0154Z04/GxGDEW0154Z04.h @@ -1,7 +1,7 @@ -// class GxGDEW0154Z04 : Display class for GDEW0154Z04 e-Paper from Dalian Good Display Co., Ltd.: www.good-display.com +// class GxGDEW0154Z04 : Display class for GDEW0154Z04 e-Paper from Dalian Good Display Co., Ltd.: www.e-paper-display.com // -// based on Demo Example from Good Display, available here: http://www.good-display.com/download_detail/downloadsId=515.html -// Controller: IL0376F : http://www.good-display.com/download_detail/downloadsId=541.html +// based on Demo Example from Good Display, available here: http://www.e-paper-display.com/download_detail/downloadsId=515.html +// Controller: IL0376F : http://www.e-paper-display.com/download_detail/downloadsId=541.html // // Author : J-M Zingg // @@ -50,6 +50,7 @@ class GxGDEW0154Z04 : public GxEPD // to full screen, filled with white if size is less, no update needed void drawBitmap(const uint8_t *bitmap, uint32_t size, int16_t mode = bm_normal); // only bm_normal, bm_invert mode implemented void eraseDisplay(bool using_partial_update = false); // parameter ignored + void powerDown(); // paged drawing, for limited RAM, drawCallback() is called GxGDEW0154Z04_PAGES times // each call of drawCallback() should draw the same void drawPaged(void (*drawCallback)(void)); @@ -112,4 +113,3 @@ class GxGDEW0154Z04 : public GxEPD #endif #endif - diff --git a/src/GxIO/GxIO_SPI/GxIO_SPI.cpp b/src/GxIO/GxIO_SPI/GxIO_SPI.cpp index 0254a05..9d1531f 100644 --- a/src/GxIO/GxIO_SPI/GxIO_SPI.cpp +++ b/src/GxIO/GxIO_SPI/GxIO_SPI.cpp @@ -5,6 +5,11 @@ #include "GxIO_SPI.h" +#if defined(PARTICLE) +// transfer16 is not used by GxEPD +#define transfer16 transfer +#endif + GxIO_SPI::GxIO_SPI(SPIClass& spi, int8_t cs, int8_t dc, int8_t rst, int8_t bl) : _spi(spi), _spi_settings(4000000, MSBFIRST, SPI_MODE0), _cs(cs), _dc(dc), _rst(rst), _bl(bl)