Hardware Reference
In-Depth Information
Unlike in serial consoles, text written to the TFT screen does not wrap auto-
matically. That is to say, if the length of the text written to the screen is wider
than the screen's width, it is not automatically put onto the next line. You must
be sure not to write too much data. Text written outside the screen is ignored.
Text can be printed in several sizes; for this, use
setTextSize()
:
screen.setTextSize(size);
The
size
parameter is an
int
between 1 and 5. It corresponds to the height
of the text in pixels divided by 10: text size 1 is 10-pixels high, text size 2 is
20-pixels high, and so on. The size can go up to 5 for text that is 50-pixels high.
By default, text size is set to 1. This function does not change any text already
present on the screen but sets the size for all future calls to the
text()
function.
Basic Graphics
The Arduino TFT library also has functions for graphical operations: drawing
lines, circles, and dots. It is with these simple tools that you can create advanced
graphics, graphs, and interfaces.
The most basic of all drawing functions is the point. This simply places one
pixel at the specii ed coordinates:
screen.point(xPos, yPos);
The
xPos
and
yPos
parameters are
int
values and represent the location of
the pixel to be drawn on screen.
The next drawing function is the line, which connects a pair of coordinates
to each other. It is called like this:
screen.line(xStart, yStart, xEnd, yEnd);
The
xStart
and
yStart
parameters are
int
values and specify the start coor-
dinates. The
xEnd
and
yEnd
parameters are also
int
values and specify the end
coordinates. A solid line is drawn between these two points.
You can create a rectangle with four lines, but Arduino offers a way to do
this automatically using
rect()
.
screen.rect(xStart, yStart, width, height);
Just like
line()
, this function takes a pair of coordinates as
int
values that
corresponds to the top-left corner of a rectangle. The
width
and
height
param-
eters correspond to the width and height of the rectangle, in pixels. The lines
will be drawn parallel to the screen edges. All four angles will be right angles.
To draw circles, use
circle()
:
screen.circle(xPos, yPos, radius);
Search WWH ::
Custom Search