Instantly share code, notes, and snippets.

Embed
What would you like to do?
1.54" b/w/r 200x200 Waveshare SPI e-Paper connected to ESP8266/WeMoS
// mapping suggestion from Waveshare SPI e-Paper to Wemos D1 mini
// BUSY -> D2, RST -> D4, DC -> D3, CS -> D8, CLK -> D5, DIN -> D7, GND -> GND, 3.3V -> 3.3V
#include <GxEPD.h>
// select the display class to use, only one
#include <GxGDEW0154Z04/GxGDEW0154Z04.cpp> // 1.54" b/w/r 200x200
#include GxEPD_BitmapExamples
// FreeFonts from Adafruit_GFX
#include <Fonts/FreeMonoBold9pt7b.h>
#include <Fonts/FreeMonoBold12pt7b.h>
#include <Fonts/FreeMonoBold18pt7b.h>
#include <Fonts/FreeMonoBold24pt7b.h>
#include <GxIO/GxIO_SPI/GxIO_SPI.cpp>
#include <GxIO/GxIO.cpp>
GxIO_Class io(SPI, /*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2); // arbitrary selection of D3(=0), D4(=2), selected for default of GxEPD_Class
GxEPD_Class display(io /*RST=D4*/ /*BUSY=D2*/); // default selection of D4(=2), D2(=4)
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);
// drawCornerTest();
showFont("FreeMonoBold9pt7b", &FreeMonoBold9pt7b);
showFont("FreeMonoBold12pt7b", &FreeMonoBold12pt7b);
//showFont("FreeMonoBold18pt7b", &FreeMonoBold18pt7b);
//showFont("FreeMonoBold24pt7b", &FreeMonoBold24pt7b);
delay(2000);
}
void showBitmapExample()
{
display.drawPicture(BitmapWaveshare_black, BitmapWaveshare_red, sizeof(BitmapWaveshare_black), sizeof(BitmapWaveshare_red), GxEPD::bm_normal);
delay(5000);
display.drawExamplePicture(BitmapExample1, BitmapExample2, sizeof(BitmapExample1), sizeof(BitmapExample2));
delay(5000);
}
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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment