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_GRAPHICS_ELEMENT 1
// Define variables and constants
Screen_EPD_EXT3_Fast myScreen(eScreen_EPD_271_PS_09, boardRaspberryPiPico_RP2040);
// On the MSP430FR5994, use PLACE_IN_FRAM
// uint8_t frameBuffer[frameSize_EPD_271] PLACE_IN_FRAM;
// Screen_EPD_EXT3_Fast myScreen(eScreen_EPD_271_PS_09, boardLaunchPad, frameBuffer);
#include "hV_Graphics.h"
const uint8_t myOrientation = 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_Serial_printf(" > %i \r", i);
hV_HAL_delayMilliseconds(900);
}
hV_HAL_Serial_printf(" \r");
}
The code below is specific to each element.
// Functions
#if (DISPLAY_GRAPHICS_ELEMENT == 1)
void displayElement()
{
// Example for element
}
#endif // DISPLAY_GRAPHICS_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_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();
hV_HAL_Serial_crlf();
// 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;
#if (DISPLAY_GRAPHICS_ELEMENT == 1)
hV_HAL_log(LEVEL_INFO, "DISPLAY_GUI_ELEMENT... ");
myScreen.clear();
displayElement();
hV_HAL_log(LEVEL_INFO, "done");
hV_HAL_Serial_crlf();
wait(4);
#endif // DISPLAY_GRAPHICS_ELEMENT
// Against possible ghosting
myScreen.regenerate();
hV_HAL_exit(0);
}
// Add loop code
void loop()
{
hV_HAL_delayMilliseconds(1000);
}