Skip to content

Examples

All the examples share in common the following code, which is not mentioned in the pages of the elements.

The section below includes the SDK and the libraries, and defines the variables.

``` cpp // SDK and configuration

include “PDLS_Common.h”

// Set parameters

define DISPLAY_EXAMPLE 1

// Define variables and constants // Driver

include “Pervasive_Wide_Small.h”

Pervasive_Wide_Small myDriver(eScreen_EPD_271_KS_09, boardRaspberryPiPico_RP2040);

// Screen

include “PDLS_Basic.h”

Screen_EPD myScreen(&myDriver);

const uint8_t myOrientation = ORIENTATION_LANDSCAPE; uint8_t fontExtra, fontLarge, fontMedium, fontSmall; ```

The function below displays a count-down.

cpp // Utilities void wait(uint8_t second) { for (uint8_t i = second; i > 0; i--) { hV_HAL_delayMilliseconds(100); hV_HAL_Serial_printf(" > %i \r", i); hV_HAL_delayMilliseconds(900); } hV_HAL_Serial_printf(" \r"); }

The code below is specific to each example.

``` cpp // Functions

if (DISPLAY_EXAMPLE == 1)

void displayExample() { myScreen.selectFont(fontMedium);

myScreen.gText(4, 4, "Example");

myScreen.flush();

}

endif // DISPLAY_EXAMPLE

```

The main code initialises the screen, loads the fonts, then calls the example.

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

hV_HAL_Serial_crlf();
hV_HAL_log(LEVEL_INFO, __FILE__);
hV_HAL_log(LEVEL_INFO, __DATE__ " " __TIME__);
hV_HAL_Serial_crlf();

// Initialise screen
myScreen.begin();
hV_HAL_Serial_crlf();

// Fonts
fontSmall = Font_Terminal6x8;
fontMedium = Font_Terminal8x12;
fontLarge = Font_Terminal12x16;
fontVery = Font_Terminal16x24;

// Example

if (DISPLAY_EXAMPLE == 1)

hV_HAL_log(LEVEL_INFO, "DISPLAY_EXAMPLE... ");
myScreen.clear();
displayExample();
wait(8);

endif // DISPLAY_EXAMPLE

// Against possible ghosting
myScreen.regenerate();

hV_HAL_exit(RESULT_SUCCESS);

}

// Add loop code void loop() { hV_HAL_delayMilliseconds(1000); } ```