-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGFX_FT3168_Image.ino
128 lines (104 loc) · 3.79 KB
/
GFX_FT3168_Image.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
* @Description: GFX显示+触摸切换图片测试
* @version: V1.0.0
* @Author: LILYGO_L
* @Date: 2023-09-06 10:58:19
* @LastEditors: LILYGO_L
* @LastEditTime: 2024-05-28 14:16:23
* @License: GPL 3.0
*/
#include <Arduino.h>
#include "Arduino_GFX_Library.h"
#include "Arduino_DriveBus_Library.h"
#include "pin_config.h"
#include "Material_16Bit_280x456px.h"
static uint8_t Image_Flag = 0;
Arduino_DataBus *bus = new Arduino_ESP32QSPI(
LCD_CS /* CS */, LCD_SCLK /* SCK */, LCD_SDIO0 /* SDIO0 */, LCD_SDIO1 /* SDIO1 */,
LCD_SDIO2 /* SDIO2 */, LCD_SDIO3 /* SDIO3 */);
Arduino_GFX *gfx = new Arduino_CO5300(bus, LCD_RST /* RST */,
0 /* rotation */, false /* IPS */, LCD_WIDTH, LCD_HEIGHT,
20 /* col offset 1 */, 0 /* row offset 1 */, 0 /* col_offset2 */, 0 /* row_offset2 */);
std::shared_ptr<Arduino_IIC_DriveBus> IIC_Bus =
std::make_shared<Arduino_HWIIC>(IIC_SDA, IIC_SCL, &Wire);
void Arduino_IIC_Touch_Interrupt(void);
std::unique_ptr<Arduino_IIC> FT3168(new Arduino_FT3x68(IIC_Bus, FT3168_DEVICE_ADDRESS,
TP_RST, TP_INT, Arduino_IIC_Touch_Interrupt));
void Arduino_IIC_Touch_Interrupt(void)
{
FT3168->IIC_Interrupt_Flag = true;
}
void setup()
{
Serial.begin(115200);
Serial.println("Ciallo");
pinMode(LCD_EN, OUTPUT);
digitalWrite(LCD_EN, HIGH);
while (FT3168->begin() == false)
{
Serial.println("FT3168 initialization fail");
delay(2000);
}
Serial.println("FT3168 initialization successfully");
gfx->begin();
gfx->fillScreen(PINK);
for (int i = 0; i <= 255; i++)
{
gfx->Display_Brightness(i);
delay(3);
}
gfx->setCursor(100, 100);
gfx->setTextSize(2);
gfx->printf("Ciallo");
Serial.printf("ID: %#X \n\n", (int32_t)FT3168->IIC_Read_Device_ID());
delay(1000);
}
void loop()
{
// Serial.printf("System running time: %d\n\n", (uint32_t)millis() / 1000);
if (FT3168->IIC_Interrupt_Flag == true)
{
FT3168->IIC_Interrupt_Flag = false;
int32_t touch_x = FT3168->IIC_Read_Device_Value(FT3168->Arduino_IIC_Touch::Value_Information::TOUCH_COORDINATE_X);
int32_t touch_y = FT3168->IIC_Read_Device_Value(FT3168->Arduino_IIC_Touch::Value_Information::TOUCH_COORDINATE_Y);
uint8_t fingers_number = FT3168->IIC_Read_Device_Value(FT3168->Arduino_IIC_Touch::Value_Information::TOUCH_FINGER_NUMBER);
if (fingers_number > 0)
{
switch (Image_Flag)
{
case 0:
gfx->draw16bitRGBBitmap(0, 0, (uint16_t *)gImage_1, LCD_WIDTH, LCD_HEIGHT); // RGB
break;
case 1:
gfx->draw16bitRGBBitmap(0, 0, (uint16_t *)gImage_2, LCD_WIDTH, LCD_HEIGHT); // RGB
break;
case 2:
gfx->fillScreen(PINK);
gfx->setCursor(100, 100);
gfx->setTextColor(YELLOW);
gfx->setTextSize(1);
gfx->println("Ciallo1~(L *##*L)^**");
gfx->setTextSize(2);
break;
case 3:
gfx->fillScreen(PINK);
gfx->setCursor(100, 100);
gfx->setTextColor(YELLOW);
gfx->setTextSize(2);
gfx->println("Ciallo1~(L *##*L)^**");
break;
default:
break;
}
Image_Flag++;
if (Image_Flag > 3)
{
Image_Flag = 0;
}
Serial.printf("[1] point x: %d point y: %d \r\n", touch_x, touch_y);
gfx->setCursor(touch_x, touch_y);
gfx->setTextColor(RED);
gfx->printf("[1] point x: %d point y: %d \r\n", touch_x, touch_y);
}
}
}