/*
==================================================
EPD 2.9" DISPLAY DEMO FOR ARDUINO IDE
SIMULATES E-PAPER GRAPHICS
BY ARVIND
==================================================
HARDWARE:
Arduino UNO / NANO
Waveshare 2.9" EPD
LIBRARIES:
GxEPD2
Adafruit GFX
INSTALL:
Arduino IDE ->
Library Manager ->
Install:
- GxEPD2
- Adafruit GFX
==================================================
CONNECTIONS
==================================================
EPD MODULE ARDUINO UNO
VCC -------> 3.3V
GND -------> GND
DIN -------> D11
CLK -------> D13
CS -------> D10
DC -------> D9
RST -------> D8
BUSY -------> D7
==================================================
*/
#include <GxEPD2_BW.h>
#include <Adafruit_GFX.h>
#include <Fonts/FreeMonoBold12pt7b.h>
// ------------------------------------------------
// DISPLAY DRIVER
// ------------------------------------------------
// 2.9 inch 296x128 display
GxEPD2_BW<GxEPD2_290, GxEPD2_290::HEIGHT> display(
GxEPD2_290(
10, // CS
9, // DC
8, // RST
7 // BUSY
)
);
// ------------------------------------------------
// VARIABLES
// ------------------------------------------------
unsigned long lastChange = 0;
int screenIndex = 0;
// ------------------------------------------------
// SCREEN 1
// ------------------------------------------------
void screen1()
{
display.setFullWindow();
display.firstPage();
do
{
display.fillScreen(GxEPD_WHITE);
display.setTextColor(GxEPD_BLACK);
display.setFont(&FreeMonoBold12pt7b);
display.setCursor(20, 35);
display.println("HELLO");
display.setCursor(20, 70);
display.println("ARVIND");
display.drawLine(10, 85, 280, 85, GxEPD_BLACK);
display.setCursor(20, 115);
display.println("EPD 2.9 DEMO");
} while (display.nextPage());
}
// ------------------------------------------------
// SCREEN 2
// ------------------------------------------------
void screen2()
{
display.setFullWindow();
display.firstPage();
do
{
display.fillScreen(GxEPD_WHITE);
display.drawRect(20, 20, 100, 60, GxEPD_BLACK);
display.drawCircle(220, 50, 30, GxEPD_BLACK);
display.fillCircle(220, 50, 10, GxEPD_BLACK);
display.setCursor(30, 110);
display.println("GRAPHICS TEST");
} while (display.nextPage());
}
// ------------------------------------------------
// SCREEN 3
// ------------------------------------------------
void screen3()
{
display.setFullWindow();
display.firstPage();
do
{
display.fillScreen(GxEPD_WHITE);
for (int i = 0; i < 296; i += 20)
{
display.drawLine(i, 0, 296 - i, 127, GxEPD_BLACK);
}
display.setCursor(25, 65);
display.println("ARDUINO");
display.setCursor(25, 95);
display.println("+ EPD");
} while (display.nextPage());
}
// ------------------------------------------------
// SCREEN 4
// ------------------------------------------------
void screen4()
{
display.setFullWindow();
display.firstPage();
do
{
display.fillScreen(GxEPD_WHITE);
display.setCursor(20, 30);
display.println("TEMP : 28C");
display.setCursor(20, 65);
display.println("HUM : 65%");
display.setCursor(20, 100);
display.println("STATUS OK");
// Battery Icon
display.drawRect(220, 20, 45, 20, GxEPD_BLACK);
display.fillRect(265, 26, 5, 8, GxEPD_BLACK);
display.fillRect(225, 25, 30, 10, GxEPD_BLACK);
} while (display.nextPage());
}
// ------------------------------------------------
// SETUP
// ------------------------------------------------
void setup()
{
Serial.begin(115200);
display.init();
display.setRotation(1);
screen1();
lastChange = millis();
}
// ------------------------------------------------
// LOOP
// ------------------------------------------------
void loop()
{
if (millis() - lastChange > 5000)
{
screenIndex++;
if (screenIndex > 3)
screenIndex = 0;
switch (screenIndex)
{
case 0:
screen1();
break;
case 1:
screen2();
break;
case 2:
screen3();
break;
case 3:
screen4();
break;
}
lastChange = millis();
}
}Loading
epaper-2in9
epaper-2in9