當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Arduino TFT - TFT用法及代碼示例

說明

用於繪製到 Arduino TFT 屏幕的基類。使用它來創建 TFT 類的命名實例以在您的草圖中引用。

如果使用 Arduino Explora,則不需要調用它,所有對屏幕的引用都通過 EsploraTFT 處理。

用法

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

參數

cs: int, 片選管腳 dc: int, rst 用管腳: int, 複位管腳 mosi: int, 不使用硬件時用於 MOSI 通信的管腳 SPI sclk: int, 不使用時用於共享時鍾管腳使用硬件 SPI

返回

示例

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

}

相關用法


注:本文由純淨天空篩選整理自arduino.cc大神的英文原創作品 TFT - TFT。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。