Fireduino/Fireduino TFT paint

来自Firefly wiki
跳转至: 导航搜索

Fireduino TFT

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 SPI of Arduino TFT.

FireDuino TFT Library

FireDuino TFT library is based on ST7735S drive extended Adafruit GFX,Adafruit GFX is responsible for drawing graphics,ST7735S is responsible for drive LCD display,it is compatible with Adafruit GFX API,after Fireduino connect TFT,as show below:
LCD SCH.jpg

LCD Dchar.jpg

Fireduino TFT general graphics display

This example demonstrates how to draw general images on Fireduino TFT accessories,after reading A0 potential value displayed bar on the screen,forming a continuous block diagram.

Hardware requirements

1.Fireduino board
2.Fireduino TFT board
3.Potentiometer


Code

Before start

Use TFT screen,first of all have to contain TFT library header files.

#include <TFT.h>

Define your TFT screen,and create an instance object

TFT TFTscreen = TFT();


setup()

1.Initialize the serial port for print the information.
2.Initialize the screen.
3.Set the background color.

void setup() {
  // initialize the serial port
  Serial.begin(9600);
  // initialize the display
  delay(1);
  TFTscreen.begin();
  delay(1);
  // clear the screen with a pretty color
  TFTscreen.background(250, 16, 200);
}


loop()

1.Read the A0 potentiometer value,and convert the mapping to screen height ratio value.
2.Draw the column on the screen.
3.If the column have drawn full the screen width,after clearing the screen to continue.

void loop() {
  // read the sensor and map it to the screen height
  int sensor = analogRead(A0);
  int drawHeight = map(sensor, 0, 1023, 0, TFTscreen.height());
  // print out the height to the serial monitor
  Serial.println(drawHeight);
  // draw a line in a nice color
  TFTscreen.stroke(250, 180, 10);
  TFTscreen.line(xPos, TFTscreen.height() - drawHeight, xPos, TFTscreen.height());
  // if the graph has reached the screen edge
  // erase the screen and start again
  if (xPos >= 160) {
    xPos = 0;
    TFTscreen.background(250, 16, 200);
  } else {
    // increment the horizontal position:
    xPos++;
  }
  delay(16);
}

Example program -- TFT general graphics display

#include <TFT.h>  // Arduino LCD library
TFT TFTscreen = TFT();
// position of the line on screen
int xPos = 0;
void setup() {
  // initialize the serial port
  Serial.begin(9600);
  // initialize the display
  delay(1);
  TFTscreen.begin();
  delay(1);
  // clear the screen with a pretty color
  TFTscreen.background(250, 16, 200);
}
void loop() {
  // read the sensor and map it to the screen height
  int sensor = analogRead(A0);
  int drawHeight = map(sensor, 0, 1023, 0, TFTscreen.height());
  // print out the height to the serial monitor
  Serial.println(drawHeight);
  // draw a line in a nice color
  TFTscreen.stroke(250, 180, 10);
  TFTscreen.line(xPos, TFTscreen.height() - drawHeight, xPos, TFTscreen.height());
  // if the graph has reached the screen edge
  // erase the screen and start again
  if (xPos >= 160) {
    xPos = 0;
    TFTscreen.background(250, 16, 200);
  } else {
    // increment the horizontal position:
    xPos++;
  }
  delay(16);
}