Go Down

Topic: ProFont_ST7735: Improved text rendering for ST7735 (Read 1 time) previous topic - next topic

tinic

https://github.com/tinic/ProFont_ST7735

ProFont_ST7735 is an extension to Adafruit_ST7735 which implements better text rendering support based on the ProFont font. ProFont is 6x12 bitmap font and includes all ANSI glyphs.

The main function ProFont_ST7735::drawString() takes UTF-8 strings as input.

Due to the fact that the underlying font bitmap is larger (3.5KB) than the available SRAM on the Arduino Uno (2KB) ProFont_ST7735 is implemented using a method to store user data in the .text section. This comes at the cost of overall code size. To store 1 byte of data you need to reserve 3-4 bytes in the .text section. Because of this ProFont_ST7735 consumes about 8KB of code. On the other hand the benefit is that it leaves the majority of SRAM open for other application data.

The avrdata2text (https://github.com/tinic/avrdata2text) tool allows to prepare arbitrary data so it can be stored in the .text section of your Arduino projects, the same way ProFont_ST7735 does. Very little SRAM is used to enable this. This is great for static data like sounds, logos etc.

Instructions for the use of avrdata2text:

1. Create a file with raw data you want to use in your Arduino project, for instance a file named mydata.raw.
2. Compile avrdata2text.cpp and run avrdata2text as such:

Code: [Select]
   
    > g++ avrdata2text.cpp -o avrdata2text
    > avrdata2text -o mydata.cpp -n GetMyData mydata.raw


3. Add the resulting mydata.cpp to your project and create a prototype to the access function in your main code:

Code: [Select]
   
    uint8_t GetMyData(uint16_t pos);


4. To access an arbitrary byte of your data call the GetMyData function where pos is the byte position. Example:

Code: [Select]
   
    for ( int32_t pos=0; pos<256; pos++ ) {
        Serial.println(GetMyData(pos),HEX);
    }


I hope you find this useful!

References:

https://github.com/adafruit/Adafruit-GFX-Library
https://github.com/adafruit/Adafruit-ST7735-Library
http://www.tobias-jung.de/seekingprofont/

Go Up