kopia lustrzana https://github.com/Xinyuan-LilyGO/TTGO-T-Display
Add firmware and fix deepslepp bug
rodzic
8cd9b78acf
commit
7d9561e308
21
LICENSE
21
LICENSE
|
@ -1,21 +0,0 @@
|
||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2020 Xinyuan-LilyGO
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
|
@ -20,8 +20,8 @@
|
||||||
#define TFT_DC 16
|
#define TFT_DC 16
|
||||||
#define TFT_RST 23
|
#define TFT_RST 23
|
||||||
|
|
||||||
#define TFT_BL 4 // Display backlight control pin
|
#define TFT_BL 4 // Display backlight control pin
|
||||||
#define ADC_EN 14
|
#define ADC_EN 14 //ADC_EN is the ADC detection enable port
|
||||||
#define ADC_PIN 34
|
#define ADC_PIN 34
|
||||||
#define BUTTON_1 35
|
#define BUTTON_1 35
|
||||||
#define BUTTON_2 0
|
#define BUTTON_2 0
|
||||||
|
@ -36,9 +36,9 @@ int btnCick = false;
|
||||||
|
|
||||||
//! Long time delay, it is recommended to use shallow sleep, which can effectively reduce the current consumption
|
//! Long time delay, it is recommended to use shallow sleep, which can effectively reduce the current consumption
|
||||||
void espDelay(int ms)
|
void espDelay(int ms)
|
||||||
{
|
{
|
||||||
esp_sleep_enable_timer_wakeup(ms * 1000);
|
esp_sleep_enable_timer_wakeup(ms * 1000);
|
||||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH,ESP_PD_OPTION_ON);
|
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
||||||
esp_light_sleep_start();
|
esp_light_sleep_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,11 @@ void button_init()
|
||||||
|
|
||||||
tft.writecommand(TFT_DISPOFF);
|
tft.writecommand(TFT_DISPOFF);
|
||||||
tft.writecommand(TFT_SLPIN);
|
tft.writecommand(TFT_SLPIN);
|
||||||
esp_sleep_enable_ext1_wakeup(GPIO_SEL_35, ESP_EXT1_WAKEUP_ALL_LOW);
|
//After using light sleep, you need to disable timer wake, because here use external IO port to wake up
|
||||||
|
esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_TIMER);
|
||||||
|
// esp_sleep_enable_ext1_wakeup(GPIO_SEL_35, ESP_EXT1_WAKEUP_ALL_LOW);
|
||||||
|
esp_sleep_enable_ext0_wakeup(GPIO_NUM_35, 0);
|
||||||
|
delay(200);
|
||||||
esp_deep_sleep_start();
|
esp_deep_sleep_start();
|
||||||
});
|
});
|
||||||
btn1.setPressedHandler([](Button2 & b) {
|
btn1.setPressedHandler([](Button2 & b) {
|
||||||
|
@ -129,18 +133,27 @@ void setup()
|
||||||
{
|
{
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
Serial.println("Start");
|
Serial.println("Start");
|
||||||
|
|
||||||
|
/*
|
||||||
|
ADC_EN is the ADC detection enable port
|
||||||
|
If the USB port is used for power supply, it is turned on by default.
|
||||||
|
If it is powered by battery, it needs to be set to high level
|
||||||
|
*/
|
||||||
|
pinMode(ADC_EN, OUTPUT);
|
||||||
|
digitalWrite(ADC_EN, HIGH);
|
||||||
|
|
||||||
tft.init();
|
tft.init();
|
||||||
tft.setRotation(1);
|
tft.setRotation(1);
|
||||||
tft.fillScreen(TFT_BLACK);
|
tft.fillScreen(TFT_BLACK);
|
||||||
tft.setTextSize(2);
|
tft.setTextSize(2);
|
||||||
tft.setTextColor(TFT_WHITE);
|
tft.setTextColor(TFT_GREEN);
|
||||||
tft.setCursor(0, 0);
|
tft.setCursor(0, 0);
|
||||||
tft.setTextDatum(MC_DATUM);
|
tft.setTextDatum(MC_DATUM);
|
||||||
tft.setTextSize(1);
|
tft.setTextSize(1);
|
||||||
|
|
||||||
if (TFT_BL > 0) { // TFT_BL has been set in the TFT_eSPI library in the User Setup file TTGO_T_Display.h
|
if (TFT_BL > 0) { // TFT_BL has been set in the TFT_eSPI library in the User Setup file TTGO_T_Display.h
|
||||||
pinMode(TFT_BL, OUTPUT); // Set backlight pin to output mode
|
pinMode(TFT_BL, OUTPUT); // Set backlight pin to output mode
|
||||||
digitalWrite(TFT_BL, TFT_BACKLIGHT_ON); // Turn backlight on. TFT_BACKLIGHT_ON has been set in the TFT_eSPI library in the User Setup file TTGO_T_Display.h
|
digitalWrite(TFT_BL, TFT_BACKLIGHT_ON); // Turn backlight on. TFT_BACKLIGHT_ON has been set in the TFT_eSPI library in the User Setup file TTGO_T_Display.h
|
||||||
}
|
}
|
||||||
|
|
||||||
tft.setSwapBytes(true);
|
tft.setSwapBytes(true);
|
||||||
|
@ -148,15 +161,12 @@ void setup()
|
||||||
espDelay(5000);
|
espDelay(5000);
|
||||||
|
|
||||||
tft.setRotation(0);
|
tft.setRotation(0);
|
||||||
int i = 5;
|
tft.fillScreen(TFT_RED);
|
||||||
while (i--) {
|
espDelay(1000);
|
||||||
tft.fillScreen(TFT_RED);
|
tft.fillScreen(TFT_BLUE);
|
||||||
espDelay(1000);
|
espDelay(1000);
|
||||||
tft.fillScreen(TFT_BLUE);
|
tft.fillScreen(TFT_GREEN);
|
||||||
espDelay(1000);
|
espDelay(1000);
|
||||||
tft.fillScreen(TFT_GREEN);
|
|
||||||
espDelay(1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
button_init();
|
button_init();
|
||||||
|
|
||||||
|
@ -171,10 +181,18 @@ void setup()
|
||||||
} else {
|
} else {
|
||||||
Serial.println("Default Vref: 1100mV");
|
Serial.println("Default Vref: 1100mV");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tft.fillScreen(TFT_BLACK);
|
||||||
|
tft.setTextDatum(MC_DATUM);
|
||||||
|
tft.drawString("LeftButton:", tft.width() / 2, tft.height() / 2 - 16);
|
||||||
|
tft.drawString("[WiFi Scan]", tft.width() / 2, tft.height() / 2 );
|
||||||
|
tft.drawString("RightButton:", tft.width() / 2, tft.height() / 2 + 16);
|
||||||
|
tft.drawString("[Voltage Monitor]", tft.width() / 2, tft.height() / 2 + 32 );
|
||||||
|
tft.drawString("RightButtonLongPress:", tft.width() / 2, tft.height() / 2 + 48);
|
||||||
|
tft.drawString("[Deep Sleep]", tft.width() / 2, tft.height() / 2 + 64 );
|
||||||
|
tft.setTextDatum(TL_DATUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
if (btnCick) {
|
if (btnCick) {
|
||||||
|
|
Plik binarny nie jest wyświetlany.
|
@ -0,0 +1 @@
|
||||||
|
![](SETTING.jpg)
|
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 70 KiB |
Ładowanie…
Reference in New Issue