Skip to content

Pixmap on serial console

The portable pixmap on serial console library prints the screen as a header file on the serial console.

The header file is added to the source code and included in the project of the application at build-time. Once the application is built, it loads the image into the frame-buffer, ready to be displayed at run-time.

Tip

This method is recommended for MCUs, as the management of the SD-card is rather slow and prone to interferences.

The pixmap on serial console library is available on the Evaluation and Commercial editions.

Danger

Because the file library manages windows, it requires it requires a screen of type Screen_EPD_EXT3_Fast provided by the PDLS_EXT3_Advanced_Fast or PDLS_EXT3_Advanced_Touch libraries.

Legacy version 5

On the legacy version 5, it requires a screen of type Screen_EPD_EXT3_Fast provided by the PDLS_EXT3_Advanced_Fast_Large, PDLS_EXT3_Advanced_Fast_Medium, PDLS_EXT3_Advanced_Fast_Small or PDLS_EXT3_Advanced_Fast_Touch libraries.

Configure

Warning

Ensure the screen is declared and initialised according to the configuration procedure.

#include "hV_Serial_P4.h"

The pre-processor statement includes the file library.

No external SD library is required, as the header file is sent to the serial console.

Serial_P4 myFile(&myScreen);

The constructor Serial_P4() sets the link to the screen.

As the header file is printed on the serial console, the SD-card doesn't need to be initialised.

Use

Generate

myFile.saveScreen("Head_P4");

saveScreen() prints the screen as a header file on the serial console.

The required parameter is

  • The first line provides the name of the file without the .h extension.

The printed header file contains the structure Pixmap_Head_P4.

Capture the content of the serial console and copy it into a header file, for example Head_P4.h.

External utilities can also be used to Generate header file from image.

Display

#include "HEAD_P4.h"

myFile.readScreen(Pixmap_Head_P4);
myScreen.fastFlush();

The application needs to include the header file previously generated.

readScreen() loads the image into the frame-buffer, ready to be displayed.

Example

This is the core of the code from example Serial_Print_Pixmap.ino.

void displayPrintSerial()
{
    // No SD-card

    myScreen.setOrientation(myOrientation);
    myScreen.selectFont(fontLarge);

    myScreen.clear();
    myScreen.gText(8, 8, "Header P4");
    myScreen.flushFast();

    // Print to serial console
    mySerialImage.saveScreen("Head_P4");
    wait(4);
}

The generated header file contains the pixmap as an array.

// Pixmap as header file generated by hV_Serial_P4

// SDK
#include "hV_HAL_Peripherals.h"

// Release
#ifndef HEAD_P4_RELEASE
#define HEAD_P4_RELEASE

static const uint8_t Pixmap_Head_P4[] = 
{
    0x50, 0x34, 0x0a, // P4 header
    0x31, 0x37, 0x36, 0x20, 0x32, 0x36, 0x34, 0x0a, // H x V = 176 264
    // size= 5808
    0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, // v= 0
    // ...
    0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, // v= 263
};

#endif // HEAD_P4_RELEASE    

This is the core of the code from example Header_Read_Pixmap.ino.

#include "HEAD_P4.h"

void displayReadHeader()
{
    myScreen.setOrientation(myOrientation);
    myScreen.clear();

    myScreen.selectFont(fontLarge);
    myScreen.gText(4, 4, "Reading the header back...");
    myScreen.flushFast();
    wait(4);

    myHeader.readScreen(Pixmap_Head_P4);
    myScreen.flushFast();
    wait(4);
}