Reference   Language | Libraries | Comparison | Changes

TFTLibrary > TFT

TFT

Description

The base class for drawing to the Arduino TFT screen. Use this to create an named instance of the TFT class to refer to in your sketch.

if using the Arduino Explora, you do not need to call this, all references to the screen are handled through EsploraTFT.

Syntax

  • TFT(cs, dc, rst); for using hardware SPI
  • TFT(cs, dc, mosi, sclk, rst); for use on any pins

Parameters

  • cs : int, pin for chip select
  • dc : int, pin used for
  • rst : int, pin used for reset
  • mosi : int, pin used for MOSI communication when not using hardware SPI
  • sclk : int, pin used for the shared clock, when not using hardware SPI

Returns

none

Example

#include <SPI.h>
#include <TFT.h>            // Arduino LCD library

#define cs   10
#define dc   9
#define rst  8

TFT screen = TFT(cs, dc, rst);

void setup() {
  // initialize the screen
  screen.begin();

  // make the background black
  screen.background(0,0,0);

  // set the stroke color to white
  screen.stroke(255,255,255);

  // turn off fill coloring
  screen.noFill();

  // draw a rectangle in the center of screen
  screen.line(screen.width()/2-5, screen.height()/2-5, 10, 10);
}

void loop() {

}

See also

Reference Home

Corrections, suggestions, and new documentation should be posted to the Forum.

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.