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);
}