Hardware Reference
In-Depth Information
The ST7735 is an SPI device, and as such, it uses the SPI MOSI, MISO, and
CLK pins. These are already present on i xed pins on the Arduino, so it is not
necessary to dei ne them. If necessary, you can use software SPI, in which case,
you need to dei ne the MOSI and CLK pins. While hardware SPI is signii cantly
faster for drawing objects on the screen, sometimes you may have to use those
pins for other reasons. (MISO is not required for this controller.) Using software
SPI, you would be declare pins as follows:
#define TFT_SCLK 4
#define TFT_MOSI 5
#define TFT_CS 10
#define TFT_DC 9
#define TFT_RESET 8
TFT screen = TFT(CS, DC, MOSI, SCLK, RESET);
NOTE The Arduino Esplora has a socket that is designed specifi cally for TFT screens.
As such, it uses fi xed pins and is not initialized in the same way. For more information
on the Esplora, and how to use a TFT screen with the Esplora, see Chapter 21.
The last thing you need to do is to begin the TFT subsystem; to do this, use
the begin() function:
screen.begin();
This function does not take any parameters and does not return any data.
Screen Preparation
For most graphics to work, it is essential to know the screen's size, that is, its
resolution . The resolution is the number of pixels wide and the number of pixels
high. Not all screens are the same size, both in terms of physical screen size
and pixels. It is not always possible to know the physical screen size, but you
can ask the library the screen's resolution. There are two functions for this: one
that returns the screen height and one that reports the screen width. For this,
use width() and height() .
int scrwidth = screen.width();
int scrheight = screen.height();
Neither of these functions take any parameters, and both return int val-
ues—the size in pixels.
Before using the screen, it is often necessary to clear the screen of any text and
graphics. Performing a screen wipe is good practice when initializing an LCD
screen. It might be a cold boot (where the system was powered off before use) in
 
Search WWH ::




Custom Search