Skip to content

Fonts from external SPI Flash

The Commercial edition allows to use an external SPI Flash to store the fonts. Fonts are loaded by the application at run-time.

The EXT3 extension board includes a 8 Mbits = 1 MBytes x 8 SPI Flash memory, labelled U1. The corresponding chip select pin is numbered 8 on the EXT3 extension board.

The application note explains how to Upload fonts to external SPI Flash.

Configure

On the hV_Configuration.h file,

#define USE_FONT_FLASH 3 ///< Use fonts from external SPI Flash memory
#define FONT_MODE USE_FONT_HEADER ///< Selected option

FONT_MODE should be set to USE_FONT_FLASH.

const pins_t myBoard =
{
    // ...
    .flashCS = 18, ///< EXT3 pin 8 Violet
    // ...
};

The selected board should define flashCS, the chip select pin for the external SPI Flash.

On the hV_Font_DejaVu_Flash,

enum fontNumber_e
{
    Font_DejaVuMono12,
    Font_DejaVuMono12b,
    // ...
    Font_DejaVuMono64,
    Font_DejaVuMono64b,

    Font_DejaVuSans12,
    Font_DejaVuSans12b,
    // ...
    Font_DejaVuSans64,
    Font_DejaVuSans64b,

    Font_DejaVuSerif12,
    Font_DejaVuSerif12b,
    // ...
    Font_DejaVuSerif64,
    Font_DejaVuSerif64b,
};    

The fontNumber_e enumeration lists all the fonts available on Flash, generated by the hV_Fonts_Manager utility.

Use

uint8_t fontSans;
fontSans = Font_DejaVuSans20;

Font_DejaVuSans20 provides the index for the DejaVu font, Sans Serif, with size 20.

myScreen.selectFont(fontSans);

selectFont() selects the font based on its index, from range 0 ..fontMax() - 1.

Example

Please refer to the example for Text.