/*
|------------------------------------------------------------------|
| Arduino project |
| |
| Scrolling Text on ADAFRUIT TFT Arduino Shield |
| |
| |
| |
| sketch uses Adafruit libraries - for more information- |
| http://learn.adafruit.com/adafruit-gfx-graphics-library?view=all |
| |
| |
| |
| a Renfrew Arduino 2014 project - public domain |
| (scroll routine thanks to Andrew Wendt) |
|__________________________________________________________________|
*/
// libraries
#include "SPI.h" // SPI display
#include "Adafruit_GFX.h" // Adafruit graphics
#include "Adafruit_ILI9341.h" // ILI9341 screen controller
// pin definitions
#define TFT_DC 9
#define TFT_CS 10
Adafruit_ILI9341 tft=Adafruit_ILI9341(TFT_CS, TFT_DC); // hardware SPI
void setup()
{
tft.begin();
tft.fillScreen(ILI9341_CYAN);
tft.fillScreen(ILI9341_BLUE);
tft.fillScreen(ILI9341_CYAN);
tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK); // White on black
tft.setTextWrap(false); // Don't wrap text to next line
tft.setTextSize(5); // large letters
tft.setRotation(0); // horizontal display
}
void loop()
{
String text = " . . Text scrolling on Adafruit TFT shield . ."; // sample text
const int width = 18; // width of the marquee display (in characters)
// Loop once through the string
for (int offset = 0; offset < text.length(); offset++)
{
// Construct the string to display for this iteration
String t = "";
for (int i = 0; i < width; i++)
t += text.charAt((offset + i) % text.length());
// Print the string for this iteration
tft.setCursor(0, tft.height()/2-10); // display will be halfway down screen
tft.print(t);
// Short delay so the text doesn't move too fast
delay(200);
}
}