Hardware Reference
In-Depth Information
for storing a video buffer, once it sends commands to the chip, the Arduino's
memory is free for sketches and variables.
ST7735-based LCD screens are available from a large number of manufactur-
ers. SainSmart, Adafruit, and Arduino sell LCD screens based on this device.
The controller can handle a large number of colors, up to 252,000 discrete
values (though the library isn't capable of accessing all of them).
TFT Library
Arduino has its own TFT library capable of controlling small-factor TFT screens.
The TFT library is based on the hard work from Adafruit Industries. Adafruit
originally sold a board containing a TFT screen—the ST7735—and created two
libraries to accompany that device: one for the ST7735 and a graphical library
common to all its LCD TFT devices. The Arduino TFT library is based on the
ST7735 library and the Adafruit GFX library. The primary difference between
the Arduino and Adafruit libraries has to do with the way drawing commands
are called. The Arduino TFT library tries to emulate the processing program-
ming language for its commands. It “talks” via the SPI bus and is simple to use.
CROSS REFERENCE
SPI is presented in Chapter 7.
Initialization
To use the TFT library, you must i rst import it and the SPI library. As it relies
on SPI for communication, it is imperative. This can be done automatically by
importing the library from the Arduino IDE (go to the menu Sketch
Import
Library
TFT), or import the library manually:
#include <TFT.h>
Next, the TFT object needs to be initialized. For this, it requires some infor-
mation: the different pins used to communicate with the controller. It requires
at least three pins: CS, DC, and RESET. The DC pin is for Data/Command and
tells the controller if the information being sent is data or a command. CS is
for Chip Select and is used by the SPI bus. The last pin is the RESET pin and it
resets the TFT screen if necessary. This can also be placed onto the Arduino's
reset pin. The TFT object is initialized as follows:
#define TFT_CS 10
#define TFT_DC 9
#define TFT_RESET 8
TFT screen = TFT(TFT_CS, TFT_DC, TFT_RESET);
 
Search WWH ::




Custom Search