Add firmware and fix deepslepp bug

pull/29/head
lewis he 2020-04-14 10:52:30 +08:00
rodzic 8cd9b78acf
commit 7d9561e308
5 zmienionych plików z 38 dodań i 40 usunięć

21
LICENSE
Wyświetl plik

@ -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.

Wyświetl plik

@ -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) {

Plik binarny nie jest wyświetlany.

Wyświetl plik

@ -0,0 +1 @@
![](SETTING.jpg)

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 70 KiB