diff --git a/LICENSE b/LICENSE deleted file mode 100644 index f059317..0000000 --- a/LICENSE +++ /dev/null @@ -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. diff --git a/TTGO-T-Display.ino b/TTGO-T-Display.ino index dab4527..bce8a02 100644 --- a/TTGO-T-Display.ino +++ b/TTGO-T-Display.ino @@ -20,8 +20,8 @@ #define TFT_DC 16 #define TFT_RST 23 -#define TFT_BL 4 // Display backlight control pin -#define ADC_EN 14 +#define TFT_BL 4 // Display backlight control pin +#define ADC_EN 14 //ADC_EN is the ADC detection enable port #define ADC_PIN 34 #define BUTTON_1 35 #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 void espDelay(int ms) -{ +{ 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(); } @@ -71,7 +71,11 @@ void button_init() tft.writecommand(TFT_DISPOFF); 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(); }); btn1.setPressedHandler([](Button2 & b) { @@ -129,18 +133,27 @@ void setup() { Serial.begin(115200); 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.setRotation(1); tft.fillScreen(TFT_BLACK); tft.setTextSize(2); - tft.setTextColor(TFT_WHITE); + tft.setTextColor(TFT_GREEN); tft.setCursor(0, 0); tft.setTextDatum(MC_DATUM); 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 - 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 + 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 } tft.setSwapBytes(true); @@ -148,15 +161,12 @@ void setup() espDelay(5000); tft.setRotation(0); - int i = 5; - while (i--) { - tft.fillScreen(TFT_RED); - espDelay(1000); - tft.fillScreen(TFT_BLUE); - espDelay(1000); - tft.fillScreen(TFT_GREEN); - espDelay(1000); - } + tft.fillScreen(TFT_RED); + espDelay(1000); + tft.fillScreen(TFT_BLUE); + espDelay(1000); + tft.fillScreen(TFT_GREEN); + espDelay(1000); button_init(); @@ -171,10 +181,18 @@ void setup() } else { 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() { if (btnCick) { diff --git a/firmware/LilyGo_T_Display_20200414.bin b/firmware/LilyGo_T_Display_20200414.bin new file mode 100644 index 0000000..f28f583 Binary files /dev/null and b/firmware/LilyGo_T_Display_20200414.bin differ diff --git a/firmware/README.MD b/firmware/README.MD new file mode 100644 index 0000000..ad7899a --- /dev/null +++ b/firmware/README.MD @@ -0,0 +1 @@ +![](SETTING.jpg) \ No newline at end of file diff --git a/firmware/SETTING.jpg b/firmware/SETTING.jpg new file mode 100644 index 0000000..30273e2 Binary files /dev/null and b/firmware/SETTING.jpg differ