The TFT library is included with Arduino IDE 1.0.5 and later. This library enables an Arduino board to communicate with the Arduino Adafruit GFX, and Adafruit ST7735 libraries that it is based on. The GFX library is responsible for the drawing routines, while the ST7735 library is specific to the screen on the Arduino TFT. The Arduino specific additions were designed to work as similarly to the Processing API as possible. Onboard the screen is a SD card slot, which can be used through the SD library. The TFT library relies on the SPI library for communication with the screen and SD card, and needs to be included in all sketches. Using the libraryThe screen can be configured for use in two ways. One is to use an Arduino's hardware SPI interface. The other is to declare all the pins manually. There is no difference in the functionality of the screen between the two methods, but using hardware SPI is significantly faster. If you plan on using the SD card on the TFT module, you must use hardware SPI. All examples in the library are written for hardware SPI use. If using hardware SPI with the Uno, you only need to declare the CS, DC, and RESET pins, as MOSI (pin 11) and SCLK (pin 13) are already defined.#define CS 10
|
To use hardware SPI with the Leonardo, you declare the pins like so : #define CS 7#define DC 0 #define RESET 1 TFT myScreen = TFT(CS, DC, RESET) ; When not using hardware SPI, you can use any available pins, but you must declare the MOSI and SCLK pins in addition to CD, DC, and RESET. #define SCLK 4#define MOSI 5 #define CS 6 #define DC 7 #define RESET 8 TFT myScreen = TFT(CS, DC, MOSI, SCLK, RESET) ; When not using hardware SPI, you can use any available pins, but you must declare the MOSI and SCLK pins in addition to CD, DC, and RESET. When not using hardware SPI, you can use any available pins, but you must declare the MOSI and SCLK pins in addition to CD, DC, and RESET. Using the Arduino Esplora and the TFT libraryAs the Arduino Esplora has a socket designed for the TFT, and the pins for using the screen are fixed, an Esplora only object is created when targeting sketches for that board. You can reference the screen attached to an Esplora through
EsploraTFT .
Similarities to ProcessingProcessingProcessing is an open source software environment used by designers, artists, and students. The main output of Processing is a graphic window on a computer or browser. The Arduino TFT library has made the calls for drawing primitives and text to the screen as 'Processing-like' as possible to ensure a smooth transition between the two environments. ExamplesThere are two groups of examples for the TFT. There are examples specific to the Arduino Esplora, and examples that are designed for boards like the Uno or Leonardo. It should be easy to translate from one to the other once you've gotten a handle on the library and its functionality. Processing is an open source software environment used by designers, artists, and students. The main output of Processing is a graphic window on a computer or browser. The Arduino TFT library has made the calls for drawing primitives and text to the screen as 'Processing-like' as possible to ensure a smooth transition between the two environments. Read an image file from a micro-SD card and draw it at random locations. With three sensors, change the color of the TFT screen. Read the value of a sensor and print it on the screen. An Arduino version of the classic Etch-a-Sketch. Graph the values from a variable resistor to the TFT. An Arduino implementation of the classic game. ESPLORAUse the Esplora as a controller to play a kart racing game. Using the joystick and slider, change the color of the TFT screen. An Esplora implementation of the classic Etch-a-Sketch. Graph the values from the light sensor to the TFT. Draw an artificial horizon line based on the tilt from the accelerometer. A basic implementation of the classic game. Check the temperature with the onboard sensor and display it on screen. For additional information on the TFT screen, see the Getting Started page and the TFT |
The text of the Arduino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.