e paper

2.9inch E-Paper Modul, 296x128 Auflösung mit einem ESP32 oder Arduino-Micro ansteuern
-Ink-Display (ePaper) sind passive (nicht leuchtende) Anzeigen. Ein Elektrischen Feld sorgt für die Ausrichtung der Partikel, welche dann je nach Ausrichtung Weiß oder Schwarz darstellen. (Es gibt inzwischen auch Displays die mehrere Farben darstellen können). Diese Displays gibt es in vielen ausführen und Größen, mit und ohne Controller, als SPI oder I²C Version und es gibt diverse Arduino/ESP-Bibliotheken zur Benutzung.
ePaper am ESP32
In der ersten Version habe ich das ePaper an einen ESP32 angeschlossen. Der ESP32 hat ausreichend Speicher so dass sich auch Bilder und große Schriften problemlos anzeigen lassen.
Da das Display für einen Radiowecker genutzt werden sollte, der auch MP3 abspielt, stellte sicher heraus das der ESP32 mit beiden Aufgabe gleichzeitig etwas Überfordert ist.
Für andere Projekte die keine Rechenzeit-Kritischen aufgaben haben, ist ein ESP eine gute Wahl, da er auch WLAN & Blutooth mitbringt.
Anschluss:
ESP -> ePaper
4 -> BUSY
21 -> RST
22 -> DC
18 -> CLK
23 -> DIN
GND -> GND
3v3 -> VCC
ePaper am Arduino Micro
Wenn man keine Komplexen Darstellungen oder Bilder auf dem ePaper ausgeben möchte eignet sich ein Arduino durchaus für diese Aufgabe. Für die Zahlen-Anzeige verwende ich eine Schrift in 92 Punktgröße. Um Speicherplatz zu sparen werden hier nur die Zahlen verwendet. Für Textanzeigen habe ich zusätzliche eine kleine Schrift mit zahlen & Buchstaben importiert.
Arduino:
#define ENABLE_GxEPD2_GFX 0
#include <GxEPD2_BW.h>
#include <U8g2_for_Adafruit_GFX.h>


#define MAX_DISPLAY_BUFFER_SIZE 800 
#define MAX_HEIGHT(EPD) (EPD::HEIGHT <= MAX_DISPLAY_BUFFER_SIZE / (EPD::WIDTH / 8) ? EPD::HEIGHT : MAX_DISPLAY_BUFFER_SIZE / (EPD::WIDTH / 8))
GxEPD2_BW<GxEPD2_290_T94_V2, MAX_HEIGHT(GxEPD2_290_T94_V2)> display(GxEPD2_290_T94_V2(/*CS=10*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7));


U8G2_FOR_ADAFRUIT_GFX u8g2Fonts;


void setup()
{
  display.init();
  u8g2Fonts.begin(display); // connect u8g2 procedures to Adafruit GFX
  delay(1000);
}


void loop()
{
  display.fillScreen(GxEPD_WHITE);
  displayValues();
  delay(5000);  
}


void displayValues()
{
  float number; //A0 Value
  number = analogRead(A0);


  display.setRotation(1); // 0--> No rotation ,  1--> rotate 90 deg
  uint16_t bg = GxEPD_WHITE;
  uint16_t fg = GxEPD_BLACK;
  u8g2Fonts.setFontMode(1);                 // use u8g2 transparent mode (this is default)
  u8g2Fonts.setFontDirection(0);            // left to right (this is default)
  u8g2Fonts.setForegroundColor(fg);         // apply Adafruit GFX color
  u8g2Fonts.setBackgroundColor(bg);         // apply Adafruit GFX color
  u8g2Fonts.setFont(u8g2_font_helvR14_tf);  // fonts:  https://github.com/olikraus/u8g2/wiki/fntlistall
  u8g2Fonts.setFont(u8g2_font_logisoso92_tn);
  
  display.setPartialWindow(0, 0, display.width(), 296); 
  //this sets a window for the partial update, so the values can update without refreshing the entire screen.
  display.firstPage();
  do
  {
    display.fillScreen(bg);
    u8g2Fonts.setCursor(5, 20); 
    u8g2Fonts.setFont(u8g2_font_helvR14_tf);
    u8g2Fonts.print("A0 Value:");
    u8g2Fonts.setFont(u8g2_font_logisoso92_tn);
    u8g2Fonts.setCursor(20, 120);
    u8g2Fonts.println(number,1);
  }
  while (display.nextPage());
}
ESP32 Sourcecode
#include <GxEPD.h>

#include <GxGDEM029T94/GxGDEM029T94.h>      // 2.9" b/w
#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.h>
#include <GxIO/GxIO.h>

GxIO_Class io(SPI, SS, 22, 21);
GxEPD_Class display(io, 16, 4);
    
void setup () {
  Serial.begin(115200);
  delay(500);
  Serial.println("init");
  SPI.begin();
  display.init(115200);  
}

void loop() {

    display.fillScreen(GxEPD_WHITE);
    display.setTextColor(GxEPD_BLACK);
    display.setCursor(1, 1);
    display.print("Hello World!");
    display.update();

	delay(3000);

    display.fillScreen(GxEPD_WHITE);
    display.setTextColor(GxEPD_BLACK);
    display.drawExampleBitmap(BitmapExample2, sizeof(BitmapExample2));
    display.update();

  delay(3000);
  display.fillScreen(GxEPD_WHITE);
  display.drawExampleBitmap(BitmapExample1, 0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_BLACK);
  display.update();
  delay(5000);

}