Arduino Function: TFT Constructor

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

Examples

#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() {}


Based on the reference originally written by Arduino Community,  wiring.org.co and  arduino.cc