#include <GxEPD2_BW.h> // Include the library for e-paper display
#include <U8g2_for_Adafruit_GFX.h> // Include the library for fonts and graphics
#define MAX_DISPLAY_BUFFER_SIZE 800 // Define the maximum display buffer size
#define MAX_HEIGHT(EPD) (EPD::HEIGHT <= MAX_DISPLAY_BUFFER_SIZE / (EPD::WIDTH / 8) ? EPD::HEIGHT : MAX_DISPLAY_BUFFER_SIZE / (EPD::WIDTH / 8)) // Define the maximum height
GxEPD2_BW<GxEPD2_290, MAX_HEIGHT(GxEPD2_290)> display(GxEPD2_290(/*CS=*/ 10, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7)); // Create a display object with pin connections
U8G2_FOR_ADAFRUIT_GFX u8g2Fonts; // Create a font object
void setup() {
Serial.begin(9600); // Start serial communication
display.init(); // Initialize the display
u8g2Fonts.begin(display); // Connect the font object to the display object
u8g2Fonts.setFontMode(1); // Use transparent mode for the fonts
u8g2Fonts.setFontDirection(0); // Set the font direction to horizontal
u8g2Fonts.setForegroundColor(GxEPD_BLACK); // Set the font color to black
u8g2Fonts.setBackgroundColor(GxEPD_WHITE); // Set the background color to
}
void loop() {
//display.setFullWindow(); // Set the full window mode
//display.firstPage(); // Start the first page
//do {
// drawText(); // Draw the text on the display
//}
//while (display.nextPage()); // Update the display until all pages are done
//delay(10000); // Wait for 10 seconds
u8g2Fonts.setFont(u8g2_font_helvB18_tf); // Set the font to Helvetica Bold 18
u8g2Fonts.setCursor(0, 30); // Set the cursor to the top left corner
u8g2Fonts.println("asdf");
Serial.println("asdf");
}
void drawText() {
u8g2Fonts.setFont(u8g2_font_helvB18_tf); // Set the font to Helvetica Bold 18
u8g2Fonts.setCursor(0, 30); // Set the cursor to the top left corner
u8g2Fonts.println("Hello, world!"); // Print "Hello, world!" on the first line
u8g2Fonts.setFont(u8g2_font_helvB12_tf); // Set the font to Helvetica Bold 12
u8g2Fonts.setCursor(0, 60); // Set the cursor to the second line
u8g2Fonts.println("This is an e-paper display"); // Print "This is an e-paper display" on the second line
u8g2Fonts.setCursor(0, 90); // Set the cursor to the third line
u8g2Fonts.println("It can show black and white images"); // Print "It can show black and white images" on the third line
u8g2Fonts.setCursor(0, 120); // Set the cursor to the fourth line
u8g2Fonts.println("It has low power consumption"); // Print "It has low power consumption" on the fourth line
u8g2Fonts.setCursor(0, 150); // Set the cursor to the fifth line
u8g2Fonts.println("It can retain the image even without power"); // Print "It can retain the image even without power" on the fifth line
}
Loading
epaper-2in9
epaper-2in9