#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#define TFT_CS 15
#define TFT_RST -1 // RST can be set to -1 if you tie it to Arduino's reset
#define TFT_DC 33
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
void setup() {
Serial.begin(9600);
tft.begin();
tft.setRotation(3); // 調整顯示方向,根據需要更改旋轉值
}
void drawBoundary() {
tft.drawRect(10, 10, 25, 25, ILI9341_WHITE); // 繪製一個25x25的方形邊界
}
void displayImage() {
// 在顯示屏上顯示25x25的照片
// 假設您已經將照片儲存在一個名為"image"的數組中
for (int y = 0; y < 25; y++) {
for (int x = 0; x < 25; x++) {
tft.drawPixel(10 + x, 10 + y, image[y][x]);
}
}
}
void displayImageClockwise() {
for (int i = 0; i < 25; i++) {
// 上邊界
for (int x = 10; x < 35; x++) {
tft.drawPixel(x, 10, image[0][x - 10]);
delay(50); // 控制繪製速度
}
// 右邊界
for (int y = 10; y < 35; y++) {
tft.drawPixel(35, y, image[y - 10][24]);
delay(50);
}
// 下邊界
for (int x = 35; x >= 10; x--) {
tft.drawPixel(x, 35, image[24][35 - x]);
delay(50);
}
// 左邊界
for (int y = 35; y >= 10; y--) {
tft.drawPixel(10, y, image[35 - y][0]);
delay(50);
}
}
}