Hello , i'm strunggling with my ePaper display to have a working code.
I tried on ESP 8266 (with success) and now must get it work on this board.
There is my code (tested with 150_BN & 154_D67 without success) :
#include <GxEPD2_BW.h> // Include the GxEPD2 library for black and white displays
#include <SPI.h> // Include the SPI library
SPIClass hspi(HSPI);
const int EPD_CS = 36;
const int EPD_DC = 40;
const int EPD_RST = 38;
const int EPD_BUSY = 39;
const int EPD_CLK = 41;
const int EPD_MOSI = 42;
#define GxEPD2_DEBUG
// Define the display class and pass the correct resolution and pin configurations
// GxEPD2_BW<GxEPD2_150_BN, GxEPD2_150_BN::HEIGHT> display(GxEPD2_150_BN(/*CS=D8*/ EPD_CS, /*DC=D3*/ EPD_DC, /*RST=D4*/ EPD_RST, /*BUSY=D2*/ EPD_BUSY));
GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display(GxEPD2_154_D67(/*CS=D8*/ EPD_CS, /*DC=D3*/ EPD_DC, /*RST=D4*/ EPD_RST, /*BUSY=D2*/ EPD_BUSY));
void test_display()
{
Serial.println("Testing display functions...");
// Reset the display
Serial.println("Resetting display...");
display.clearScreen();
delay(100);
// Set the display mode
Serial.println("Setting display mode...");
display.setRotation(1);
display.setFullWindow();
// Clear the display buffer
Serial.println("Clearing display buffer...");
display.fillScreen(GxEPD_WHITE);
// Draw a rectangle on the display buffer
Serial.println("Drawing rectangle...");
display.drawRect(10, 10, 50, 30, GxEPD_BLACK);
// Update the display with the buffer content
Serial.println("Updating display...");
display.display(true); // true parameter enables partial update
delay(2000);
Serial.println("Test complete.");
}
void setup()
{
hspi.begin(EPD_CLK, -1, EPD_MOSI, EPD_CS); // SCK, MISO, MOSI, CS
hspi.setFrequency(2000000); // Set the SPI clock frequency to 2 MHz
hspi.setDataMode(SPI_MODE0); // Set the SPI data mode to Mode 0
Serial.begin(115200); // Initialize the serial communication
display.init(115200, true, 2, false); // Initialize the display with the correct baud rate and SPI mode
display.setRotation(1); // Set the display rotation (optional)
Serial.println("Setup done");
}
void loop()
{
// Fill the display buffer with white
display.fillScreen(GxEPD_WHITE);
// Draw a test pattern on the display buffer
uint16_t width = display.width();
uint16_t height = display.height();
for (int16_t i = 0; i < width; i++)
{
for (int16_t j = 0; j < height; j++)
{
if (i < width / 2 && j < height / 2)
{
display.drawPixel(i, j, GxEPD_BLACK);
}
else if (i >= width / 2 && j >= height / 2)
{
display.drawPixel(i, j, GxEPD_BLACK);
}
}
}
// Update the display with the buffer content
display.display(false); // true parameter enables partial update
// Delay to avoid continuously refreshing the display
delay(2000);
// Fill the display buffer with white again to clear the previous content
display.fillScreen(GxEPD_WHITE);
Serial.println("Loop done");
}
Console logs :
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x44c
load:0x403c9700,len:0xbd8
load:0x403cc700,len:0x2a80
entry 0x403c98d0
[ 10Setup done
_PowerOn : 6
_Update_Full : 1
_Update_Full : 1
_PowerOff : 1
Loop done
_PowerOn : 1
_Update_Full : 1
_PowerOff : 1
Loop done
_PowerOn : 1000
_Update_Full : 1
_PowerOff : 1
Loop done
_PowerOn : 2000
_Update_Full : 1
_PowerOff : 1
Loop done
Thanks for help ! Have a good day
Reference :
Screen with modules (Waveshare ePaper 1.54inch V2 FPC-8101) : https://www.waveshare.com/1.54inch-e-paper-module.htm
Board Heltec ESP-32 Wifi Kit V3 : WiFi Kit 32 (V3) – Heltec Automation