Skip to content

Use two screens connected to the same host

This procedure explains how to use two screens connected to the same host.

Configure

Boards

Define two boards, one per screen.

  • The SPI signals, SCK, MOSI and MISO are shared.

  • The GPIOs for .panelBusy, .panelDC, .panelReset, .flashCS and .panelCS are specific to each screen.

  • The remaining GPIOs are set to NOT_CONNECTED.

const pins_t boardRaspberryPiPico_RP2040_0 =
{
    .panelBusy = 13, ///< EXT3 and EXT3.1 pin 3 Red -> GP13
    .panelDC = 12, ///< EXT3 and EXT3.1 pin 4 Orange -> GP12
    .panelReset = 11, ///< EXT3 and EXT3.1 pin 5 Yellow -> GP11
    .flashCS = 10, ///< EXT3 and EXT3.1 pin 8 Violet -> GP10
    .panelCS = 17, ///< EXT3 and EXT3.1 pin 9 Grey -> GP17
    .panelCSS = NOT_CONNECTED, ///< EXT3 and EXT3.1 pin 12 Grey2 -> GP14
    .flashCSS = NOT_CONNECTED, ///< EXT3 pin 20 or EXT3.1 pin 11 Black2 -> GP15
    .touchInt = NOT_CONNECTED, ///< EXT3-Touch pin 3 Red -> GP2
    .touchReset = NOT_CONNECTED, ///< EXT3-Touch pin 4 Orange -> GP3
    .panelPower = NOT_CONNECTED, ///< Optional power circuit
    .cardCS = NOT_CONNECTED, ///< Separate SD-card board
    .cardDetect = NOT_CONNECTED, ///< Separate SD-card board
};

const pins_t boardRaspberryPiPico_RP2040_1 =
{
    .panelBusy = 9, ///< EXT3 and EXT3.1 pin 3 Red -> GP13
    .panelDC = 8, ///< EXT3 and EXT3.1 pin 4 Orange -> GP12
    .panelReset = 7, ///< EXT3 and EXT3.1 pin 5 Yellow -> GP11
    .flashCS = 6, ///< EXT3 and EXT3.1 pin 8 Violet -> GP10
    .panelCS = 21, ///< EXT3 and EXT3.1 pin 9 Grey -> GP17
    .panelCSS = NOT_CONNECTED, ///< EXT3 and EXT3.1 pin 12 Grey2 -> GP14
    .flashCSS = NOT_CONNECTED, ///< EXT3 pin 20 or EXT3.1 pin 11 Black2 -> GP15
    .touchInt = NOT_CONNECTED, ///< EXT3-Touch pin 3 Red -> GP2
    .touchReset = NOT_CONNECTED, ///< EXT3-Touch pin 4 Orange -> GP3
    .panelPower = NOT_CONNECTED, ///< Optional power circuit
    .cardCS = NOT_CONNECTED, ///< Separate SD-card board
    .cardDetect = NOT_CONNECTED, ///< Separate SD-card board
};

Drivers

Define two drivers, one per screen.

  • When using screens with different films,
#include "Driver_EPD_Wide_Small.h"
Driver_EPD_Wide_Small myDriver_0(eScreen_EPD_266_KS_0C, boardRaspberryPiPico_RP2040_0);

#include "Driver_EPD_BWRY_Small.h"
Driver_EPD_Wide_Small myDriver_1(eScreen_EPD_266_QS_0F, boardRaspberryPiPico_RP2040_0);
  • When using multiple screens with the same film,
#include "Driver_EPD_Wide_Small.h"
Driver_EPD_Wide_Small myDriver_0(eScreen_EPD_266_KS_0C, boardRaspberryPiPico_RP2040_0);
Driver_EPD_Wide_Small myDriver_1(eScreen_EPD_266_KS_0C, boardRaspberryPiPico_RP2040_1);

Screens

Define two screens, one per screen.

#include "PDLS_Advanced.h"
Screen_EPD myScreen_0(&myDriver_0);
Screen_EPD myScreen_1(&myDriver_1);

Frame-buffers

Ensure the host provides enough RAM for the frame-buffers.

Each screen creates its own frame-buffer dynamically at run-time with

static uint8_t * _newFrameBuffer;
_newFrameBuffer = new uint8_t[u_pageColourSize * u_bufferDepth];
s_newImage = (uint8_t *) _newFrameBuffer;

If this solution raises an issue, create the frame-buffers statically at build-time and pass them on to the constructors as parameters.

#include "PDLS_Advanced.h"
uint8_t frameBuffer_0[frameSize_EPD_266];
Screen_EPD myScreen_0(&myDriver_0, frameBuffer_0);

uint8_t frameBuffer_1[frameSize_EPD_266];
Screen_EPD myScreen_1(&myDriver_1, frameBuffer_1);

Fonts

Each screen can have its own set of fonts. However, it is recommended to add the fonts in the same order for each screen.

fontSmall = myScreen_0.addFont(Font_DejaVuSans16);
fontSmall = myScreen_1.addFont(Font_DejaVuSans16);
fontSmall -= (fontSmall > 0) ? 1 : 0;

fontMedium = myScreen_0.addFont(Font_DejaVuSans24);
fontMedium = myScreen_1.addFont(Font_DejaVuSans24);
fontMedium -= (fontMedium > 0) ? 1 : 0;

fontLarge = myScreen_0.addFont(Font_DejaVuSans48);
fontLarge = myScreen_1.addFont(Font_DejaVuSans48);
fontLarge -= (fontLarge > 0) ? 1 : 0;

Use

Use the two screens normally.

Example

The example below helps to identify each screen.

// SDK and configuration
#include "PDLS_Common.h"

// Define variables and constants
// Boards
const pins_t boardRaspberryPiPico_RP2040_0 =
{
    .panelBusy = 13, ///< EXT3 and EXT3.1 pin 3 Red -> GP13
    .panelDC = 12, ///< EXT3 and EXT3.1 pin 4 Orange -> GP12
    .panelReset = 11, ///< EXT3 and EXT3.1 pin 5 Yellow -> GP11
    .flashCS = 10, ///< EXT3 and EXT3.1 pin 8 Violet -> GP10
    .panelCS = 17, ///< EXT3 and EXT3.1 pin 9 Grey -> GP17
    .panelCSS = NOT_CONNECTED, ///< EXT3 and EXT3.1 pin 12 Grey2 -> GP14
    .flashCSS = NOT_CONNECTED, ///< EXT3 pin 20 or EXT3.1 pin 11 Black2 -> GP15
    .touchInt = NOT_CONNECTED, ///< EXT3-Touch pin 3 Red -> GP2
    .touchReset = NOT_CONNECTED, ///< EXT3-Touch pin 4 Orange -> GP3
    .panelPower = NOT_CONNECTED, ///< Optional power circuit
    .cardCS = NOT_CONNECTED, ///< Separate SD-card board
    .cardDetect = NOT_CONNECTED, ///< Separate SD-card board
};

const pins_t boardRaspberryPiPico_RP2040_1 =
{
    .panelBusy = 9, ///< EXT3 and EXT3.1 pin 3 Red -> GP13
    .panelDC = 8, ///< EXT3 and EXT3.1 pin 4 Orange -> GP12
    .panelReset = 7, ///< EXT3 and EXT3.1 pin 5 Yellow -> GP11
    .flashCS = 6, ///< EXT3 and EXT3.1 pin 8 Violet -> GP10
    .panelCS = 21, ///< EXT3 and EXT3.1 pin 9 Grey -> GP17
    .panelCSS = NOT_CONNECTED, ///< EXT3 and EXT3.1 pin 12 Grey2 -> GP14
    .flashCSS = NOT_CONNECTED, ///< EXT3 pin 20 or EXT3.1 pin 11 Black2 -> GP15
    .touchInt = NOT_CONNECTED, ///< EXT3-Touch pin 3 Red -> GP2
    .touchReset = NOT_CONNECTED, ///< EXT3-Touch pin 4 Orange -> GP3
    .panelPower = NOT_CONNECTED, ///< Optional power circuit
    .cardCS = NOT_CONNECTED, ///< Separate SD-card board
    .cardDetect = NOT_CONNECTED, ///< Separate SD-card board
};

// Drivers
#include "Driver_EPD_Wide_Small.h"
Driver_EPD_Wide_Small myDriver_0(eScreen_EPD_266_KS_0C, boardRaspberryPiPico_RP2040_0);

#include "Driver_EPD_BWRY_Small.h"
Driver_EPD_Wide_Small myDriver_1(eScreen_EPD_266_QS_0F, boardRaspberryPiPico_RP2040_0);

// Screens
#include "PDLS_Advanced.h"
Screen_EPD myScreen_0(&myDriver_0);
Screen_EPD myScreen_1(&myDriver_1);

// Functions
void displayIdentity(Screen_EPD aScreen, uint8_t number)
{
    aScreen.clear();
    aScreen.setOrientation(myOrientation);
    aScreen.setPenSolid(false);

    aScreen.selectFont(fontLarge);
    aScreen.gTextLarge(0, 0 , formatString("%i", number));

    aScreen.flush();
}

// Add setup code
void setup()
{
    hV_HAL_begin();

    myScreen_0.begin();
    myScreen_1.begin();

    fontLarge = myScreen_0.addFont(Font_DejaVuMono48);
    fontLarge = myScreen_1.addFont(Font_DejaVuMono48);
    fontLarge -= (fontLarge > 0) ? 1 : 0;

    myScreen_0.setOrientation(myOrientation);
    myScreen_0.clear();

    myScreen_1.setOrientation(myOrientation);
    myScreen_1.clear();

    hV_HAL_log(LEVEL_DEBUG, "DISPLAY_IDENTITY");
    displayIdentity(myScreen_0, 0);
    displayIdentity(myScreen_1, 1);
    wait(8);

    hV_HAL_log(LEVEL_DEBUG, "Regenerate... ");
    myScreen_0.regenerate();
    myScreen_1.regenerate();

    hV_HAL_end();
}

void loop()
{
    delay(1000);
}