TFT_eSPI_Scroll library adds text scroll functionality to the existing TFT_eSPI library. This library by default uses 1-bit color-depth which makes it perform very fast & flickerless with very minimum ram usages. The color-depth can be changed accordingly to match required performances. This library supports all the processors that TFT_eSPI library supports. Available in PlatformIO Registry and Arduino Library Manager.
- Open
platformio.ini
, a project configuration file located in the root of PlatformIO project. - Add the following line to the lib_deps option of [env:] section:
xunicatt/TFT_eSPI_Scroll@^1.0.1
- Build a project, PlatformIO will automatically install dependencies.
- Open the Arduino IDE.
- With the editor open, let's take a look at the left column. Here, we can see a couple of icons. Let's click the on the "library" icon.
- A list will now appear of all available libraries, search for
TFT_eSPI_Scroll
. - Select a version and Click Install.
TFT_eSPI_Scroll library provides the following header files that can be included in your project.
#include <TFT_eSPI_Scroll.h>
#include <TFT_eSPI.h>
#include <TFT_eSPI_Scroll.h>
TFT_eSPI tft;
TFT_eSPI_Scroll scroll;
Warning
Note it is important to initialize the "TFT_eSPI" library before using "TFT_eSPI_Scroll".
Using this method the "TFT_eSPI_Scroll" library initializes in 1-bit color-depth mode. Only black and white color is available in this color-depth. Though 1-bit color-depth is limited to B/W colors, it is not only fast but also memory efficient and renders without any flickering or glitches.
int textFont = 4;
void setup(){
tft.init();
if(scroll.init(&tft, textFont) != NO_ERROR){
// memory allocation failed
}
// rest of the code
}
To set other color-depths, intialize the library with:
// previous codes
int colorDepth = 4; // 4-bit color depth
if(scroll.init(&tft, textFont, colorDepth) != NO_ERROR){
// memory allocation failed
}
// rest of the code
int count = 0;
void loop(){
scroll.write("Count: " + String(count++));
}
Warning
Note in order to apply proper colors (excluding 1-Bit default), proper color-depth must be selected during initialization.
// bg & fg {8-bit}
scroll.setColor(TFT_BLUE, TFT_YELLOW);
// bg & fg {4-bit} COLOR_<name>_4B
scroll.setColor(COLOR_BLUE_4B, COLOR_YELLOW_4B);
// bg & fg {1-bit} COLOR_<name>_1B
scroll.setColor(COLOR_WHITE_1B, COLOR_BLACK_1B);
scroll.reset();
1.0.5