TFT
描述
實作控制 Arduino TFT LCD 的類別。使用 TFT 類別的建構函式創建 TFT 物件,藉以在程式中控制 Arduino TFT LCD。
語法
TFT(cs, dc, rst); // 使用硬體 SPI
TFT(cs, dc, mosi, sclk, rst); // 使用軟體 SPI
參數
cs:作為 chip select 的腳位,型態為 int
dc:作為 D/C 的腳位,型態為 int
rst:作為 rst 的腳位,型態為 int
mosi:作為 MOSI 的腳位,只有要使用軟體 SPI 時需要提供,型態為 int
sclk:作為 clock 的腳位,只有要使用軟體 SPI 時需要提供,型態為 int
回傳
無回傳值
範例
#include <SPI.h>
#include <TFT.h>
#define cs 10
#define dc 9
#define rst 8
TFT screen = TFT(cs, dc, rst);
void setup() {
// 初始化 TFT 物件
screen.begin();
// 設定背景色為黑色
screen.background(0,0,0);
// 設定線段的顏色為白色
screen.stroke(255,255,255);
// 設定文字與圖形不要填滿,形成中空
screen.noFill();
// 在正中央畫一個長方形
screen.line(screen.width()/2-5, screen.height()/2-5, 10, 10);
}
void loop() {
}
See also
- noStroke()
- stroke()
- point()
The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.
