Hardware Reference
In-Depth Information
which case the screen is probably blank, or a warm boot (where the system was
reset but was already powered) in which case there may be text and graphics on
the screen. To clear the screen of any graphics, use the background() function:
screen.background(red, green, blue);
This function requires three parameters: the red, green, and blue components
of the color to be used. The red , green , and blue parameters are int variables
and contain 8-bit color levels (from 0 to 255). The screen does not display colors
with full 8-bit colors per channel. The red and blue values are scaled to 5 bits
(32 steps each), while the green is scaled to 6 bits (64 steps). The advantage of
scaling these values in the library means that the Arduino can read in graphics
data with 8-bit components without the need to modify them.
Te x t O p e rations
The Arduino TFT library has support for text operations enabling you to write
text directly onto the screen without having to do any complicated calculations.
Writing text is as simple as specifying the text and the coordinates. The TFT
library does the rest.
To write text to the screen, use text() .
screen.text(text, xPos, yPos);
The text parameter is the text to be written on the screen as a char array. The
xPos and yPos coordinates are integers and correspond to the top-left corner
of the text.
Computer screens use an x,y coordinate system, but unlike coordinates that
you see in mathematics, computer screens use a slightly different way. The ori-
gin or coordinate 0,0 is the top-left corner of a screen. The x -value increases the
further to the right it goes, and the y -value increases the further down it goes.
This is illustrated in Figure 13-1.
Figure 13-1: Computer screen coordinate system
 
Search WWH ::




Custom Search