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.

// Screen
#include "PDLS_EXT3_Advanced_Fast_Small.h";

// SDK
#include "hV_HAL_Peripherals.h"

// Configuration
#include "hV_Configuration.h"

// Set parameters
#define DISPLAY_GUI_ELEMENT 1
#define DEFAULT_ORIENTATION 3

// Include application, user and local libraries
#include "hV_Utilities.h"

// Define variables and constants
Screen_EPD_EXT3_Fast myScreen(eScreen_EPD_EXT3_271_09, boardLaunchPad);

// On the MSP430FR5994, use PLACE_IN_FRAM
// uint8_t frameBuffer[frameSize_EPD_EXT3_271] PLACE_IN_FRAM;
// Screen_EPD_EXT3_Fast myScreen(eScreen_EPD_EXT3_271_09, boardLaunchPad, frameBuffer);

#include "hV_GUI.h"
GUI myGUI(&myScreen);

const uint8_t myOrientation = 3; // ORIENTATION_LANDSCAPE
uint8_t fontExtra, fontLarge, fontMedium, fontSmall;

The function below displays a count-down.

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

The code below displays the Next button on the top-right corner of the screen to exit the example.

// Next button
button myButtonNext;

void beginNext()
{
    myScreen.setOrientation(myOrientation);

    uint16_t x, y, dx, dy;

    x = myScreen.screenSizeX();
    y = myScreen.screenSizeY();
    dx = x / 5;
    dy = y / 6;

    myButtonNext.dDefine(x - dx, 0, dx, dy, setItem(0x00ff, "Next"), fontMedium);
    myButtonNext.setOption(optionStandard);
    myButtonNext.setState(stateEnabled);
}

void drawNext()
{
    myButtonNext.draw();
}

bool checkNext()
{
    hV_HAL_delayMilliseconds(10);
    return myButtonNext.check();
}

The code below is specifc to each element.

// Functions
#if (DISPLAY_GUI_ELEMENT == 1)

void displayElement()
{
    // Example for element
}

#endif // DISPLAY_GUI_ELEMENT

The main code initialises the screen and the GUI, then calls the example for the element.

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

    hV_HAL_Debug_begin(115200);
    hV_HAL_delayMilliseconds(500);
    hV_HAL_Debug_println("");
    hV_HAL_Debug_println("=== " __FILE__);
    hV_HAL_Debug_println("=== " __DATE__ " " __TIME__);
    hV_HAL_Debug_println("");

    hV_HAL_Debug_print("begin... ");
    myScreen.begin();
    hV_HAL_Debug_println("done");

    // Add fonts from header files
    fontSmall = myScreen.addFont(Font_DejaVuSans14b);
    fontSmall -= (fontSmall > 0) ? 1 : 0;
    fontMedium = myScreen.addFont(Font_DejaVuSans16);
    fontMedium -= (fontMedium > 0) ? 1 : 0;
    fontLarge = myScreen.addFont(Font_DejaVuSans20);
    fontLarge -= (fontLarge > 0) ? 1 : 0;
    fontExtra = myScreen.addFont(Font_DejaVuSans64b);
    fontExtra -= (fontExtra > 0) ? 1 : 0;

    // Prepare GUI
    myGUI.begin();
    myGUI.delegate(true);
    myGUI.setColours(myColours.black, myColours.white, myColours.grey);
    myGUI.setState(stateEnabled);

    beginNext(); // Prepare Next button

#if (DISPLAY_GUI_ELEMENT == 1)

    hV_HAL_Debug_print("DISPLAY_GUI_ELEMENT... ");
    myScreen.clear();
    displayElement();
    hV_HAL_Debug_println("done");

    wait(4);

#endif // DISPLAY_GUI_ELEMENT

    // Against possible ghosting
    myScreen.regenerate();

    hV_HAL_Debug_println("=== ");
    hV_HAL_exit(0);
}

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