Display on 1.54" 200x200 e-Paper (SSD1681) with Raspberry Pi Pico using GxEPD2 library, in Arduino framework.


To display on 1.54" 200x200 e-Paper (SSD1681 SPI) with Raspberry Pi Pico using GxEPD2 library, in Arduino framework. GxEPD2 library is needed, it can be installed in Arduino IDE Library Manager.


Connection between Raspberry Pi Pico and SSD1681
	SSD1681 e-Paper	Raspberry Pi Pico
	=================================
	BUSY		22
	CS		17
	DC		21
	RES		20
	SDA		19 (MOSI)
	SCL		18 (SCK)
	VCC		3V3
	GND		GND
Code:

Pico_GxEPD2_SSD1681_hello.ino, display text.
/*
 *Exercise run on Raspberry Pi Pico/RP2040
 *display on 1.54" 200x200 e-Paper with SSD1681 SPI driver,
 *using ZinggJM/GxEPD2 lib.
 *
 */

#include <GxEPD2_BW.h>
#include <Fonts/FreeMonoBold9pt7b.h>
#include <Fonts/FreeMono9pt7b.h>

#define EPD_CS     17
#define EPD_DC     21
#define SRAM_CS    -1
#define EPD_RESET  20
#define EPD_BUSY   22

GxEPD2_BW<GxEPD2_154_GDEY0154D67, GxEPD2_154_GDEY0154D67::HEIGHT> display(
  GxEPD2_154_GDEY0154D67(EPD_CS, EPD_DC, EPD_RESET, EPD_BUSY));

void setup()
{
  display.init();
  display.setRotation(0);
  
  display.firstPage();

  do
  {
    display.setRotation(0);
    display.fillScreen(GxEPD_WHITE);
    display.setTextColor(GxEPD_BLACK);

    display.drawRect(0, 0, display.width(), display.height(), GxEPD_BLACK);

    display.setFont(&FreeMonoBold9pt7b);
    display.setCursor(5, 20);
    display.print("coXXect");

    display.setRotation(1);
    display.setFont(&FreeMono9pt7b);
    display.setCursor(5, 40);
    display.print("1.54\" 200x200 e-Paper using ");

    display.setFont(&FreeMonoBold9pt7b);
    display.print("GxEPD2");

  }
  while (display.nextPage());
  
}

void loop() {
  };



Pico_GxEPD2_SSD1681_draw.ino, draw something. Notice the effect of setFullWindow() and setPartialWindow().
/*
 *Exercise run on Raspberry Pi Pico/RP2040
 *display on 1.54" 200x200 e-Paper with SSD1681 SPI driver,
 *using ZinggJM/GxEPD2 lib
 *
 */

#include <GxEPD2_BW.h>
#include <Fonts/FreeMonoBold9pt7b.h>
#include <Fonts/FreeMono9pt7b.h>

#define EPD_CS     17
#define EPD_DC     21
#define SRAM_CS    -1
#define EPD_RESET  20
#define EPD_BUSY   22

GxEPD2_BW<GxEPD2_154_GDEY0154D67, GxEPD2_154_GDEY0154D67::HEIGHT> display(
  GxEPD2_154_GDEY0154D67(EPD_CS, EPD_DC, EPD_RESET, EPD_BUSY));

const int DISP_WIDTH = display.width();
const int DISP_HEIGHT = display.height();
const int DISP_HALF_W = (int)DISP_WIDTH/2;
const int DISP_HALF_H = (int)DISP_HEIGHT/2;

void setup()
{
  delay(500);

  display.init();
  display.setRotation(0);
  
  drawScreen();
  drawQ1_FullWindow();
  drawQ4_PartialWindow();
  drawQ2_PartialWindow();
  drawQ3_PartialWindow();
  delay(1000);
  drawQ5_PartialWindow();

  delay(2000);
  display.powerOff();
  
}

void drawQ1_FullWindow(){
  display.setFullWindow();
  display.firstPage();
  do
  {
    display.fillRect(0, 0, DISP_HALF_W, DISP_HALF_H, GxEPD_BLACK);
  }
  while (display.nextPage());
}

void drawQ2_PartialWindow(){
  display.setPartialWindow(DISP_HALF_W, 0, DISP_HALF_W, DISP_HALF_H);

  int step = 10;
  int div_x = DISP_HALF_W/step;
  int div_y = DISP_HALF_H/step;

  display.firstPage();
  do
  {
    for(int i= 0; i<=step; i++){
      display.drawLine(DISP_HALF_W + i*div_x,
                       0,
                       DISP_HALF_W,
                       i*div_y,
                       GxEPD_BLACK);
      display.drawLine(DISP_HALF_W + i*div_x,
                       0,
                       DISP_WIDTH-1,
                       DISP_HALF_H - i*div_y,
                       GxEPD_BLACK);
    }
  }
  while (display.nextPage());
}

void drawQ3_PartialWindow(){
  display.setPartialWindow(0, DISP_HALF_H, DISP_HALF_W, DISP_HALF_H);

  int step = 10;
  int div_x = DISP_HALF_W/step;
  int div_y = DISP_HALF_H/step;

  display.firstPage();
  do
  {
    for(int i= 0; i<=step; i++){
      display.drawLine(DISP_HALF_W,
                       DISP_HALF_H + i*div_y,
                       i*div_x,
                       DISP_HALF_H,
                       GxEPD_BLACK);
      display.drawLine(0,
                       DISP_HALF_H + i*div_y,
                       i*div_x,
                       DISP_HEIGHT-1,
                       GxEPD_BLACK);
    }
  }
  while (display.nextPage());
}

void drawQ4_PartialWindow(){
  display.setPartialWindow(DISP_HALF_W, DISP_HALF_H, DISP_HALF_W, DISP_HALF_H);
  display.firstPage();
  do
  {
    
    display.fillRect(DISP_HALF_W, DISP_HALF_H, DISP_HALF_W, DISP_HALF_H, GxEPD_BLACK);
  }
  while (display.nextPage());
}

void drawQ5_PartialWindow(){
  display.setPartialWindow(DISP_WIDTH/4,DISP_WIDTH/4, 
                           DISP_HALF_W, DISP_HALF_H);

  int step = 20;
  int div_x = DISP_WIDTH/step;
  int div_y = DISP_HEIGHT/step;

  display.firstPage();
  do
  {
    for(int i= 0; i<=step; i++){
      display.drawCircle(i*div_x, DISP_HALF_H, 50, GxEPD_BLACK);
    }
  }
  while (display.nextPage());

  
}

void drawScreen()
{
  display.setFullWindow();

  display.firstPage();
  do
  {
    display.fillScreen(GxEPD_BLACK);
  }
  while (display.nextPage());
  delay(2000);

  display.setPartialWindow(0, 0, DISP_WIDTH, DISP_HEIGHT);
  display.firstPage();
  do
  {
    display.fillScreen(GxEPD_WHITE);
    display.drawRect(0, 0, DISP_WIDTH, DISP_HEIGHT, GxEPD_BLACK);
  }
  while (display.nextPage());
  delay(2000);

}

void loop() {
  };


more:
Generate QRCode with Raspberry Pi Pico (arduino framework), display on 1.54" 200x200 B&W e-Paper (SSD1681)




Comments

Popular posts from this blog

480x320 TFT/ILI9488 SPI wih EP32C3 (arduino-esp32) using Arduino_GFX Library

my dev.tools - FNIRSI 2C23T 3-in-1 Dual Channel Oscilloscope/Multimeter/Signal Generator