-
Notifications
You must be signed in to change notification settings - Fork 1
/
Deep_Sleep_Wake_Up.ino
108 lines (86 loc) · 3.22 KB
/
Deep_Sleep_Wake_Up.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
/*
* @Description: Sleep
* @version: V1.0.0
* @Author: LILYGO_L
* @Date: 2024-03-11 10:05:32
* @LastEditors: LILYGO_L
* @LastEditTime: 2024-05-29 10:37:55
* @License: GPL 3.0
*/
#include "Arduino.h"
#include "pin_config.h"
#include "Arduino_GFX_Library.h"
#include "Arduino_DriveBus_Library.h"
#define SLEEP_WAKE_UP_INT GPIO_NUM_9
static size_t CycleTime = 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);
pinMode(SLEEP_WAKE_UP_INT, INPUT_PULLUP);
if (FT3168->begin() == false)
{
Serial.println("FT3168 initialization fail");
delay(2000);
}
else
{
Serial.println("FT3168 initialization successfully");
}
// // 激活模式
// FT3168->IIC_Write_Device_State(FT3168->Arduino_IIC_Touch::Device::TOUCH_POWER_MODE,
// FT3168->Arduino_IIC_Touch::Device_Mode::TOUCH_POWER_ACTIVE);
// // 触摸芯片是否自动进入Monitor模式
// FT3168->IIC_Write_Device_State(FT3168->Arduino_IIC_Touch::Device::TOUCH_AUTOMATICALLY_MONITOR_MODE,
// FT3168->Arduino_IIC_Touch::Device_State::TOUCH_DEVICE_ON);
// // 设定触摸芯片自动进入Monitor模式的时间为30秒
// FT3168->IIC_Write_Device_Value(FT3168->Arduino_IIC_Touch::Device_Value::TOUCH_AUTOMATICALLY_MONITOR_TIME,
// 10);
gfx->begin();
gfx->fillScreen(WHITE);
for (int i = 0; i <= 255; i++)
{
gfx->Display_Brightness(i);
delay(3);
}
gfx->setCursor(10, 100);
gfx->setTextSize(2);
gfx->setTextColor(RED);
gfx->println("Enter deep sleep in 5 seconds");
Serial.println("Enter deep sleep in 5 seconds");
CycleTime = millis() + 5000;
}
void loop()
{
if (millis() > CycleTime)
{
delay(300);
gfx->Display_Brightness(0);
gfx->displayOff();
digitalWrite(LCD_EN, LOW);
// 激活模式
FT3168->IIC_Write_Device_State(FT3168->Arduino_IIC_Touch::Device::TOUCH_POWER_MODE,
FT3168->Arduino_IIC_Touch::Device_Mode::TOUCH_POWER_MONITOR);
Serial.println("Enter deep sleep");
// gpio_hold_en(GPIO_NUM_0);
esp_sleep_enable_ext0_wakeup(SLEEP_WAKE_UP_INT, LOW);
esp_deep_sleep_start();
}
}