kopia lustrzana https://github.com/Xinyuan-LilyGO/TTGO-T-Display
commit
6730c964a2
10
README.MD
10
README.MD
|
@ -1,8 +1,9 @@
|
||||||
# TTGO T-Display
|
# TTGO T-Display
|
||||||
|
|
||||||
|
![image](https://github.com/Xinyuan-LilyGO/TTGO-T-Display/blob/master/image/pinmap.jpg)
|
||||||
## 1.Install the following dependency library files:
|
## 1.Install the following dependency library files:
|
||||||
- [TFT_eSPI](https://github.com/lewisxhe/TFT_eSPI)
|
- [TFT_eSPI](https://github.com/Bodmer/TFT_eSPI)
|
||||||
- [Button2](https://github.com/lewisxhe/Button2)
|
- [Button2](https://github.com/LennartHennigs/Button2)
|
||||||
|
|
||||||
|
|
||||||
## 2.TFT_eSPI settings
|
## 2.TFT_eSPI settings
|
||||||
|
@ -26,4 +27,7 @@
|
||||||
| ADC_IN | 34 |
|
| ADC_IN | 34 |
|
||||||
| BUTTON1 | 35 |
|
| BUTTON1 | 35 |
|
||||||
| BUTTON2 | 0 |
|
| BUTTON2 | 0 |
|
||||||
| ADC Power | 14 |
|
| ADC Power | 14 |
|
||||||
|
|
||||||
|
2019/08/06:
|
||||||
|
* The TFT_eSPI and Button2 libraries have been synchronized to the main branch
|
|
@ -4,30 +4,35 @@
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include <Button2.h>
|
#include <Button2.h>
|
||||||
#include "esp_adc_cal.h"
|
#include "esp_adc_cal.h"
|
||||||
#include <Ticker.h>
|
|
||||||
#include "bmp.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_MOSI 19
|
||||||
#define TFT_SCLK 18
|
#define TFT_SCLK 18
|
||||||
#define TFT_CS 5
|
#define TFT_CS 5
|
||||||
#define TFT_DC 16
|
#define TFT_DC 16
|
||||||
#define TFT_RST 23
|
#define TFT_RST 23
|
||||||
|
|
||||||
#define TFT_BL 4 // Dispaly backlight control pin
|
#define TFT_BL 4 // Display backlight control pin
|
||||||
#define ADC_EN 14
|
#define ADC_EN 14
|
||||||
#define ADC_PIN 34
|
#define ADC_PIN 34
|
||||||
#define BUTTON_1 35
|
#define BUTTON_1 35
|
||||||
#define BUTTON_2 0
|
#define BUTTON_2 0
|
||||||
#define BUTTONS_MAP {BUTTON_1,BUTTON_2}
|
|
||||||
|
|
||||||
TFT_eSPI tft = TFT_eSPI(135, 240); // Invoke custom library
|
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];
|
char buff[512];
|
||||||
int vref = 1100;
|
int vref = 1100;
|
||||||
int btnCick = false;
|
int btnCick = false;
|
||||||
Ticker tick;
|
|
||||||
|
|
||||||
void showVoltage()
|
void showVoltage()
|
||||||
{
|
{
|
||||||
|
@ -46,11 +51,7 @@ void showVoltage()
|
||||||
|
|
||||||
void button_init()
|
void button_init()
|
||||||
{
|
{
|
||||||
uint8_t args = sizeof(g_btns) / sizeof(g_btns[0]);
|
btn1.setLongClickHandler([](Button2 & b) {
|
||||||
pBtns = new Button2 [args];
|
|
||||||
pBtns[0] = Button2(g_btns[0]);
|
|
||||||
pBtns[1] = Button2(g_btns[1]);
|
|
||||||
pBtns[0].setLongClickHandler([](Button2 & b) {
|
|
||||||
btnCick = false;
|
btnCick = false;
|
||||||
int r = digitalRead(TFT_BL);
|
int r = digitalRead(TFT_BL);
|
||||||
tft.fillScreen(TFT_BLACK);
|
tft.fillScreen(TFT_BLACK);
|
||||||
|
@ -59,17 +60,18 @@ void button_init()
|
||||||
tft.drawString("Press again to wake up", tft.width() / 2, tft.height() / 2 );
|
tft.drawString("Press again to wake up", tft.width() / 2, tft.height() / 2 );
|
||||||
delay(6000);
|
delay(6000);
|
||||||
digitalWrite(TFT_BL, !r);
|
digitalWrite(TFT_BL, !r);
|
||||||
|
|
||||||
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);
|
esp_sleep_enable_ext1_wakeup(GPIO_SEL_35, ESP_EXT1_WAKEUP_ALL_LOW);
|
||||||
esp_deep_sleep_start();
|
esp_deep_sleep_start();
|
||||||
});
|
});
|
||||||
pBtns[0].setPressedHandler([](Button2 & b) {
|
btn1.setPressedHandler([](Button2 & b) {
|
||||||
Serial.println("Detect Voltage..");
|
Serial.println("Detect Voltage..");
|
||||||
btnCick = true;
|
btnCick = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
pBtns[1].setPressedHandler([](Button2 & b) {
|
btn2.setPressedHandler([](Button2 & b) {
|
||||||
btnCick = false;
|
btnCick = false;
|
||||||
Serial.println("btn press wifi scan");
|
Serial.println("btn press wifi scan");
|
||||||
wifi_scan();
|
wifi_scan();
|
||||||
|
@ -78,9 +80,8 @@ void button_init()
|
||||||
|
|
||||||
void button_loop()
|
void button_loop()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < sizeof(g_btns) / sizeof(g_btns[0]); ++i) {
|
btn1.loop();
|
||||||
pBtns[i].loop();
|
btn2.loop();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wifi_scan()
|
void wifi_scan()
|
||||||
|
@ -103,7 +104,7 @@ void wifi_scan()
|
||||||
} else {
|
} else {
|
||||||
tft.setTextDatum(TL_DATUM);
|
tft.setTextDatum(TL_DATUM);
|
||||||
tft.setCursor(0, 0);
|
tft.setCursor(0, 0);
|
||||||
Serial.printf("Fount %d net\n", n);
|
Serial.printf("Found %d net\n", n);
|
||||||
for (int i = 0; i < n; ++i) {
|
for (int i = 0; i < n; ++i) {
|
||||||
sprintf(buff,
|
sprintf(buff,
|
||||||
"[%d]:%s(%d)",
|
"[%d]:%s(%d)",
|
||||||
|
@ -123,23 +124,22 @@ void setup()
|
||||||
|
|
||||||
Serial.println("Start");
|
Serial.println("Start");
|
||||||
tft.init();
|
tft.init();
|
||||||
tft.setRotation(0);
|
tft.setRotation(1);
|
||||||
tft.fillScreen(TFT_BLACK);
|
tft.fillScreen(TFT_BLACK);
|
||||||
tft.setTextSize(2);
|
tft.setTextSize(2);
|
||||||
tft.setTextColor(TFT_WHITE);
|
tft.setTextColor(TFT_WHITE);
|
||||||
tft.setCursor(0, 0);
|
tft.setCursor(0, 0);
|
||||||
tft.setTextDatum(MC_DATUM);
|
tft.setTextDatum(MC_DATUM);
|
||||||
tft.drawString("TTGO", tft.width() / 2, tft.height() / 2 );
|
|
||||||
tft.setTextSize(1);
|
tft.setTextSize(1);
|
||||||
|
|
||||||
if (TFT_BL > 0) {
|
if (TFT_BL > 0) {
|
||||||
pinMode(TFT_BL, OUTPUT);
|
pinMode(TFT_BL, OUTPUT);
|
||||||
digitalWrite(TFT_BL, HIGH);
|
digitalWrite(TFT_BL, HIGH);
|
||||||
}
|
}
|
||||||
|
tft.setSwapBytes(true);
|
||||||
tft.setRotation(1);
|
|
||||||
tft.pushImage(0, 0, 240, 135, ttgo);
|
tft.pushImage(0, 0, 240, 135, ttgo);
|
||||||
delay(5000);
|
delay(5000);
|
||||||
|
|
||||||
tft.setRotation(0);
|
tft.setRotation(0);
|
||||||
int i = 5;
|
int i = 5;
|
||||||
while (i--) {
|
while (i--) {
|
||||||
|
@ -174,4 +174,4 @@ void loop()
|
||||||
showVoltage();
|
showVoltage();
|
||||||
}
|
}
|
||||||
button_loop();
|
button_loop();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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_WIDTH 135
|
||||||
#define TFT_HEIGHT 240
|
#define TFT_HEIGHT 240
|
||||||
|
|
||||||
#define ST7789_DRIVER
|
#define CGRAM_OFFSET // Library will add offsets required
|
||||||
|
|
||||||
#define TFT_MISO -1
|
// #define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue
|
||||||
#define TFT_MOSI 19
|
//#define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red
|
||||||
#define TFT_SCLK 18
|
|
||||||
#define TFT_CS 5
|
|
||||||
#define TFT_DC 16
|
|
||||||
#define TFT_RST 23
|
|
||||||
|
|
||||||
// Non-standard screen, need to add XY coordinate offset
|
//#define TFT_INVERSION_ON
|
||||||
#define TTGO_114_INC_DISPLAY
|
//#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_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
|
#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_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_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_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 LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts
|
||||||
|
|
||||||
#define SMOOTH_FONT
|
#define SMOOTH_FONT
|
||||||
|
|
||||||
|
|
||||||
|
// #define SPI_FREQUENCY 27000000
|
||||||
|
#define SPI_FREQUENCY 40000000
|
||||||
|
|
||||||
|
#define SPI_READ_FREQUENCY 20000000
|
||||||
|
|
||||||
|
#define SPI_TOUCH_FREQUENCY 2500000
|
||||||
|
|
||||||
|
// #define SUPPORT_TRANSACTIONS
|
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 1.8 MiB |
Ładowanie…
Reference in New Issue