ePaper Display Library

Description

Basic GUI library for ePaper Displays (EPD)

OVERVIEW

EPD_Abstract:
This library can be used to build a raw screen buffer that is ready to transfer with an ePaper Display. The screen buffer will hold one bit per pixel. The low-level communication functions with the ePaper Display (e.g. through SPI interface) are not part of this library.

Interfaces: Raw screen buffer

The library provides functions for building GUIs on ePaper Displays
  • Pixel, Line, Rectangle
  • Bitmap
  • Text with several fonts
  • EPD_How_to_use:
    // Display configuration const { DISPLAY_WIDTH = 152, DISPLAY_HEIGHT = 296, DISPLAY_BUFFER_SIZE = (DISPLAY_WIDTH * DISPLAY_HEIGHT) / 8, } // Display Buffer, 1bit per pixel static aDisplayBuffer{DISPLAY_BUFFER_SIZE}; // prepare ePaper Display library catch(EPD_ScreenInit(aDisplayBuffer, DISPLAY_WIDTH, DISPLAY_HEIGHT, EPD_FLAG_ROT_LEFT)); // begin drawing within screen buffer catch(EPD_DrawBegin()); // clear screen -> set background color WHITE catch(EPD_Clear(EPD_COLOR_WHITE)); // draw elements: line, rectangle, bitmaps, text, ... catch(EPD_DrawLine(DISPLAY_WIDTH/4, DISPLAY_HEIGHT/2, (DISPLAY_WIDTH*3)/4, DISPLAY_HEIGHT/2, EPD_COLOR_BLACK)); // flush screen buffer catch(EPD_DrawEnd()); /* transfer buffer (aDisplayBuffer) to display here * -> IO interface is not part of this library. */

    BASIC

    EPD_ScreenInit(screen{}, width, height, flags)

    Provide screen buffer and prepare library for use

    screen - Raw screen buffer
    The buffer size in byte must be at least (width * height) / 8, because 1 bit per pixel is used. 1 byte will hold 8 pixel.
    width : s32 - Screen: number of pixels
    width must be a multiple of 8, because 8 pixels are grouped as 1 byte in x direction.
    height : s32 - Screen: number of pixels
    flags : s32 - see EPD_FLAG definitions
    returns : s32
    OK - if successful
    ERROR - if one of the following errors occurs
  • screen buffer is too small
  • width is not a multiple of 8
  • EPD_FLAG:

    Flags for EPD_ScreenInit

    EPD_FLAG_OPAQUE - 0x01 | use background color as opaque
    This flag can be used to optimize the amount of drawn pixels.
    EPD_FLAG_ROT_LEFT - 0x02 | rotate screen left
    EPD_FLAG_ROT_RIGHT - 0x04 | rotate screen right
    EPD_DrawBegin()

    Begin drawing to screen buffer

    returns : s32
    OK - if successful
    ERROR - if one of the following errors occurs
  • Screen buffer not available (EPD_ScreenInit not called before)
  • EPD_DrawEnd()

    End drawing (flush screen buffer)

    returns : s32
    OK - if successful
    ERROR - if one of the following errors occurs
  • Screen buffer not available (EPD_ScreenInit not called before)
  • EPD_Clear(color)

    Clear screen with color

    color : s32 - Selected color, see EPD_COLOR definitions
    returns : s32
    OK - if successful
    ERROR - if one of the following errors occurs
  • Screen buffer not available (EPD_ScreenInit not called before)
  • EPD_COLOR:

    Supported screen colors

    EPD_COLOR_BLACK - 0
    EPD_COLOR_WHITE - 1

    GRAPHIC

    EPD_DrawPixel(x, y, color)

    Draw a pixel into the screen buffer

    x : s32 - pixel position on x axis
    y : s32 - pixel position on y axis
    color : s32 - see EPD_COLOR definitions
    returns : s32
    OK - if successful
    ERROR - if one of the following errors occurs
  • Screen buffer not available (EPD_ScreenInit not called before)
  • EPD_DrawLine(x1, y1, x2, y2, color)

    Draw a line into the screen buffer

    x1 : s32 - line begin: pixel position on x axis
    y1 : s32 - line begin: pixel position on y axis
    x2 : s32 - line end: pixel position on x axis
    y2 : s32 - line end: pixel position on y axis
    color : s32 - see EPD_COLOR definitions
    returns : s32
    OK - if successful
    ERROR - if one of the following errors occurs
  • Screen buffer not available (EPD_ScreenInit not called before)
  • EPD_DrawRect(x1, y1, x2, y2, color)

    Draw a rectangle into the screen buffer

    x1 : s32 - corner 1: pixel position on x axis
    y1 : s32 - corner 1: pixel position on y axis
    x2 : s32 - corner 2: pixel position on x axis
    y2 : s32 - corner 2: pixel position on y axis
    The real appearance depends on the display and its configuration (e.g. axis orientation). This is not part of this library.
    color : s32 - see EPD_COLOR definitions
    returns : s32
    OK - if successful
    ERROR - if one of the following errors occurs
  • Screen buffer not available (EPD_ScreenInit not called before)
  • EPD_DrawBitmap(bitmap{}, x, y, width, height, color)

    Draw a bitmap into the screen buffer

    bitmap : {} - Bitmap data buffer
    Only monochrome bitmaps (1 bit per pixel, black/white) are possible. Each pixel line has to be a multiple of 8bits. Buffer size in bytes must be at least (width * height) / 8.
    x : s32 - pixel position on y axis
    y : s32 - pixel position on y axis
    width : s32 - number of pixel
    height : s32 - number of pixel
    color : s32 - see EPD_COLOR definitions
    returns : s32
    OK - if successful
    ERROR - if one of the following errors occurs
  • Screen buffer not available (EPD_ScreenInit not called before)
  • TEXT

    Text_Abstract:
    Drawing text is based on fonts. The font must be selected before drawing text is possible.
    EPD_FONT:

    Font selection

    EPD_FONT_ARIAL_N24 - 1 | Arial Narrow 24
    Character height is 24 pixel, width is character depending.
    Supported Unicode characters:
  • U+0020 to U+007F - Basic Latin
  • U+00A0 to U+00FF - Latin-1 Supplement
  • EPD_FONT_ARIAL_N16 - 2 | Arial Narrow 16
    Character height is 16 pixel, width is character depending.
    Supported Unicode characters:
  • U+0020 to U+005F - Basic Latin Subset
  • U+00A0 to U+00BF - Latin-1 Subset
  • Currently only a subset of Basic Latin and Latin-1 characters are possible.
    EPD_FONT_ARIAL_M20 - 3 | Arial Monospaced 20
    Character height is 20 pixel, width is fixed to 16 pixel.
    Supported Unicode characters:
  • U+0020 to U+007F - Basic Latin
  • U+00A0 to U+00FF - Latin-1
  • All fonts except EPD_FONT_ARIAL_M20 are disabled by default to save memory. Every font must be enabled through a corresponding #define. It must set before the library itself is included (use dde/main.dde).
    // Example: Enable Arial Narrow 24 #define EPD_ENABLE_FONT_ARIAL_N24 (1)
    EPD_SelectFont(font)

    Select font for drawing text

    font : s32 - selected font, see EPD_FONT definitions
    returns : s32
    OK - if successful
    ERROR - if one of the following errors occurs
  • Screen buffer not available (EPD_ScreenInit not called before)
  • Unknown font
  • Font not available (not enabled through #define)
  • Font could not be loaded (not enough memory available)
  • EPD_DrawText(const text[], x, y, color)

    Draw text

    text : [] - Text buffer
    x : s32 - start pixel on x axis
    y : s32 - start pixel on y axis
    color : s32 - Selected color, see EPD_COLOR definitions
    returns : s32
    OK - if successful
    ERROR - if one of the following errors occurs
  • Screen buffer not available (EPD_ScreenInit not called before)
  • Font not selected (EPD_SelectFont not called before)
  • Text buffer not valid
  • EPD_GetTextExpanse(const text[], &width, &height)

    Calculates the size of a text using the current font

    text : [] - Text buffer
    width : s32 - will hold number of required width pixels (x) upon return
    height : s32 - will hold number of required height pixels (y) upon return
    returns : s32
    OK - if successful
    ERROR - if one of the following errors occurs
  • Screen buffer not available (EPD_ScreenInit not called before)
  • Font not selected (EPD_SelectFont not called before)
  • Text buffer not valid
  • EXPERT

    EPD_ScreenGetDrawArea(&x, &y, &width, &height)

    Get last drawn area of screen

    This function can be used for partial display update. Last drawn area information is reset if EPD_DrawBegin is called.
    x : s32 - will hold start pixel on x axis upon return
    y : s32 - will hold start pixel on y axis upon return
    width : s32 - will hold number of pixel on x axis upon return
    height : s32 - will hold number of pixel on y axis upon return
    returns : s32
    OK - if successful
    ERROR - if one of the following errors occurs
  • Screen buffer not available (EPD_ScreenInit not called before)
  • EPD_SetBkColor(color)

    Set current background color

    This function can be used in combination with EPD_FLAG_OPAQUE (EPD_ScreenInit) for optimized pixel drawing. Only pixels different to selected background color will be written.
    color : s32 - Selected color, see EPD_COLOR definitions
    returns : s32
    OK - if successful
    ERROR - if one of the following errors occurs
  • Screen buffer not available (EPD_ScreenInit not called before)
  • DEBUG

    BMP280_Debug_Config:
    To configure debug mode add the following macro to the main.dde file.
    /** * Use this macro to configure the debug mode: * * 0: No debugging * >0: debug outputs active */ #define EPD_DEBUG (1)

    On this page

    ePaper Display Library