TFT
Update time:2018-04-13 Views:4512
ST7735S
Fireduino TFT adopt with traditional Arduino TFT belong to a series of LCD driver for ST7735S,with Fireduino through I8080 interface connection,refresh rate is faster than traditional way SPI of Arduino TFT.
TFT
Fireduino TFT Library is base on ST7735S driver and expansion Adafruit GFX library,Adafruit_gfx responsible for drawing graphics, ST7735S responsible for driving the LCD display, which is compatible with Adafruit GFX API, Fireduino after the TFT as shown below:
TFT API
TFT()
Description Create Object TFT Syntax TFT TFTscreen = TFT(); Parameter None Returns TFT objects
begin()
Description Initialization TFT, before using the TFT must be called to initialize the TFT. Syntax TFTscreen.begin(); Parameter None Returns None
setRotation(...)
Description Set the screen orientation. Syntax TFTscreen.setRotation(rota); Parameter rota: screen orientation (0-3) Returns None
backlight(...)
Description Set the screen backlight brightness. Syntax TFTscreen.backlight(light); Parameter light: the screen backlight brightness (0 to 100) Returns None
Adafruit GFX API
background(...)
Description Set the background color. Syntax TFTscreen.background(red, green, blue); Parameter red : int 0-255 green : int 0-255 blue : int 0-255 Returns None
stroke(...)
Description Set brush color drawing objects, draw objects before calling. Syntax TFTscreen.stroke(red, green, blue); TFTscreen.stroke( color); Parameter red : int 0-255 green : int 0-255 blue : int 0-255 color: Color objects Returns 无
fill(...)
Description Set the fill color of the object, typically used in an enclosed area before coloring call. Syntax TFTscreen.fill(red, green, blue); TFTscreen.fill( color); Parameter red : int 0-255 green : int 0-255 blue : int 0-255 color: Color objects Returns None
noFill()
noStroke()
Description These two functions are not set fill color and no color line, if at the same time to set these two do not have any diagram that displays the graph. Syntax TFTscreen.noFill(); TFTscreen.noStroke(); Parameter None Returns None
text(...)
Description Draw text characters specified coordinates. Syntax TFTscreen.text("Sensor Value :\n ",x , y); Parameter text:We need to draw text x:x-axis coordinate y:y-axis coordinate Returns None
setTextSize(...)
Description Set the font size. Syntax TFTscreen.setTextSize(size); Parameter size:font size Returns None
point(...)
Description A set point. Syntax TFTscreen..point(xPos, yPos); Parameter xPos :The horizontal coordinate yPos :Vertical coordinate Returns None
line(...)
Description Draw a straight line between two points. Syntax TFTscreen.line(xStart, yStart, xEnd, yEnd); Parameter xStart :The horizontal coordinate of the starting point yStart :The vertical coordinates of the starting point xEnd :The horizontal coordinate of the end point yEnd :The vertical coordinate of the end point Returns None
rect(...)
Description Draw a rectangle. Syntax TFTscreen.rect(xStart, yStart, width, height); Parameter xStart :Horizontal coordinate of start point yStart :Vertical coordinates of the starting point width :Width of the rectangle height :Height of the rectangle Returns None
circle(...)
Description Draw a circle. Syntax TFTscreen.circle(xPos, yPos, radius); Parameter xPos :Where the horizontal position of the center yPos :The center said in a vertical position radius : Radius of the circle Returns None
width()
Description return TFT screen width (in pixels) Syntax TFTscreen.width(); Parameter None Returns The width of the screen
height()
Description Returns the height of the TFT (in pixels) Syntax TFTscreen.height(); Parameter None Returns The height of the screen
TFT Example
#include <TFT.h> // Arduino LCD library // create an instance of the libraryTFT TFTscreen = TFT();// char array to print to the screenchar sensorPrintout[4];void setup() { // Put this line at the beginning of every sketch that uses the GLCD: delay(1); TFTscreen.begin(); delay(1); // clear the screen with a black background TFTscreen.background(0, 0, 0); // write the static text to the screen // set the font color to white TFTscreen.stroke(255, 255, 255); // set the font size TFTscreen.setTextSize(2); // write the text to the top left corner of the screen TFTscreen.text("Sensor Value :\n ", 0, 0); // ste the font size very large for the loop TFTscreen.setTextSize(5);}void loop() { // Read the value of the sensor on A0 String sensorVal = String(analogRead(A0)); // convert the reading to a char array sensorVal.toCharArray(sensorPrintout, 4); // set the font color TFTscreen.stroke(255, 255, 255); // print the sensor value TFTscreen.text(sensorPrintout, 0, 20); // wait for a moment delay(250); // erase the text you just wrote TFTscreen.stroke(0, 0, 0); TFTscreen.text(sensorPrintout, 0, 20);}