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.
