synchronized to the main branch

pull/18/head
lewis 2019-08-06 12:01:57 +08:00
rodzic c8b5a45c65
commit 7e4d011afd
3 zmienionych plików z 64 dodań i 40 usunięć

Wyświetl plik

@ -2,11 +2,8 @@
![image](https://github.com/Xinyuan-LilyGO/TTGO-T-Display/blob/master/image/pinmap.jpg)
## 1.Install the following dependency library files:
**The following two libraries are not original branches, they are my modified branches.**
- [TFT_eSPI](https://github.com/lewisxhe/TFT_eSPI)
- [Button2](https://github.com/lewisxhe/Button2)
- [TFT_eSPI](https://github.com/Bodmer/TFT_eSPI)
- [Button2](https://github.com/LennartHennigs/Button2)
## 2.TFT_eSPI settings
@ -31,3 +28,6 @@
| BUTTON1 | 35 |
| BUTTON2 | 0 |
| ADC Power | 14 |
2019/08/06:
* The TFT_eSPI and Button2 libraries have been synchronized to the main branch

Wyświetl plik

@ -4,9 +4,16 @@
#include <Wire.h>
#include <Button2.h>
#include "esp_adc_cal.h"
#include <Ticker.h>
#include "bmp.h"
#ifndef TFT_DISPOFF
#define TFT_DISPOFF 0x28
#endif
#ifndef TFT_SLPIN
#define TFT_SLPIN 0x10
#endif
#define TFT_MOSI 19
#define TFT_SCLK 18
#define TFT_CS 5
@ -18,16 +25,14 @@
#define ADC_PIN 34
#define BUTTON_1 35
#define BUTTON_2 0
#define BUTTONS_MAP {BUTTON_1,BUTTON_2}
TFT_eSPI tft = TFT_eSPI(135, 240); // Invoke custom library
Button2 btn1(BUTTON_1);
Button2 btn2(BUTTON_2);
Button2 *pBtns = nullptr;
uint8_t g_btns[] = BUTTONS_MAP;
char buff[512];
int vref = 1100;
int btnCick = false;
Ticker tick;
void showVoltage()
{
@ -46,11 +51,7 @@ void showVoltage()
void button_init()
{
uint8_t args = sizeof(g_btns) / sizeof(g_btns[0]);
pBtns = new Button2 [args];
pBtns[0] = Button2(g_btns[0]);
pBtns[1] = Button2(g_btns[1]);
pBtns[0].setLongClickHandler([](Button2 & b) {
btn1.setLongClickHandler([](Button2 & b) {
btnCick = false;
int r = digitalRead(TFT_BL);
tft.fillScreen(TFT_BLACK);
@ -59,17 +60,18 @@ void button_init()
tft.drawString("Press again to wake up", tft.width() / 2, tft.height() / 2 );
delay(6000);
digitalWrite(TFT_BL, !r);
tft.writecommand(TFT_DISPOFF);
tft.writecommand(TFT_SLPIN);
esp_sleep_enable_ext1_wakeup(GPIO_SEL_35, ESP_EXT1_WAKEUP_ALL_LOW);
esp_deep_sleep_start();
});
pBtns[0].setPressedHandler([](Button2 & b) {
btn1.setPressedHandler([](Button2 & b) {
Serial.println("Detect Voltage..");
btnCick = true;
});
pBtns[1].setPressedHandler([](Button2 & b) {
btn2.setPressedHandler([](Button2 & b) {
btnCick = false;
Serial.println("btn press wifi scan");
wifi_scan();
@ -78,9 +80,8 @@ void button_init()
void button_loop()
{
for (int i = 0; i < sizeof(g_btns) / sizeof(g_btns[0]); ++i) {
pBtns[i].loop();
}
btn1.loop();
btn2.loop();
}
void wifi_scan()
@ -123,23 +124,22 @@ void setup()
Serial.println("Start");
tft.init();
tft.setRotation(0);
tft.setRotation(1);
tft.fillScreen(TFT_BLACK);
tft.setTextSize(2);
tft.setTextColor(TFT_WHITE);
tft.setCursor(0, 0);
tft.setTextDatum(MC_DATUM);
tft.drawString("TTGO", tft.width() / 2, tft.height() / 2 );
tft.setTextSize(1);
if (TFT_BL > 0) {
pinMode(TFT_BL, OUTPUT);
digitalWrite(TFT_BL, HIGH);
}
tft.setRotation(1);
tft.setSwapBytes(true);
tft.pushImage(0, 0, 240, 135, ttgo);
delay(5000);
tft.setRotation(0);
int i = 5;
while (i--) {

Wyświetl plik

@ -1,25 +1,38 @@
// ST7789 135 x 240 display with no chip select line
#define ST7789_DRIVER // Configure all registers
#define TFT_WIDTH 135
#define TFT_HEIGHT 240
#define ST7789_DRIVER
#define CGRAM_OFFSET // Library will add offsets required
#define TFT_MISO -1
#define TFT_MOSI 19
#define TFT_SCLK 18
#define TFT_CS 5
#define TFT_DC 16
#define TFT_RST 23
// #define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue
//#define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red
// Non-standard screen, need to add XY coordinate offset
#define TTGO_114_INC_DISPLAY
//#define TFT_INVERSION_ON
//#define TFT_INVERSION_OFF
// DSTIKE stepup
//#define TFT_DC 23
//#define TFT_RST 32
//#define TFT_MOSI 26
//#define TFT_SCLK 27
// Generic ESP32 setup
#define TFT_MISO -1
#define TFT_MOSI 19
#define TFT_SCLK 18
#define TFT_CS 5 // Not connected
#define TFT_DC 16
#define TFT_RST 23 // Connect reset to ensure display initialises
// For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation
// #define TFT_CS -1 // Define as not used
// #define TFT_DC PIN_D1 // Data Command control pin
//#define TFT_RST PIN_D4 // TFT reset pin (could connect to NodeMCU RST, see next line)
// #define TFT_RST -1 // TFT reset pin connect to NodeMCU RST, must also then add 10K pull down to TFT SCK
// #define SPI_FREQUENCY 1000000
// #define SPI_FREQUENCY 5000000
// #define SPI_FREQUENCY 10000000
// #define SPI_FREQUENCY 20000000
// #define SPI_FREQUENCY 27000000 // Actually sets it to 26.67MHz = 80/3
// #define SPI_FREQUENCY 40000000 // Maximum to use SPIFFS
#define SPI_FREQUENCY 80000000
#define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
#define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
@ -27,6 +40,17 @@
#define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
#define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:.
#define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
//#define LOAD_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT
#define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts
#define SMOOTH_FONT
// #define SPI_FREQUENCY 27000000
#define SPI_FREQUENCY 40000000
#define SPI_READ_FREQUENCY 20000000
#define SPI_TOUCH_FREQUENCY 2500000
// #define SUPPORT_TRANSACTIONS