mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-06-06 02:36:49 +08:00
add vscode/platformIO support
Update some libs
This commit is contained in:
parent
cc6e4ad3a4
commit
24a8acec8f
7
.gitignore
vendored
7
.gitignore
vendored
@ -1,4 +1,11 @@
|
||||
Thumbs.db
|
||||
.DS_Store
|
||||
*.orig
|
||||
embedded/node_modules
|
||||
embedded/dist
|
||||
.pio
|
||||
.pioenvs
|
||||
.piolibdeps
|
||||
.vscode/.browse.c_cpp.db*
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
||||
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "ESP3D-WEBUI"]
|
||||
path = ESP3D-WEBUI
|
||||
url = https://github.com/luc-github/ESP3D-WEBUI
|
7
.vscode/extensions.json
vendored
Normal file
7
.vscode/extensions.json
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||
// for the documentation about the extensions.json format
|
||||
"recommendations": [
|
||||
"platformio.platformio-ide"
|
||||
]
|
||||
}
|
13
.vscode/tasks.json
vendored
Normal file
13
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"type": "npm",
|
||||
"script": "install",
|
||||
"path": "embedded/",
|
||||
"problemMatcher": []
|
||||
}
|
||||
]
|
||||
}
|
@ -36,6 +36,7 @@ void setup() {
|
||||
SSDP.setModelURL("http://www.meethue.com");
|
||||
SSDP.setManufacturer("Royal Philips Electronics");
|
||||
SSDP.setManufacturerURL("http://www.philips.com");
|
||||
SSDP.setDeviceType("upnp:rootdevice"); //to appear as root device
|
||||
SSDP.begin();
|
||||
|
||||
Serial.printf("Ready!\n");
|
||||
|
@ -8,9 +8,18 @@
|
||||
|
||||
/***************************************************************************************
|
||||
** Function name: loadFont
|
||||
** Description: loads parameters from a new font vlw file stored in SPIFFS
|
||||
** Description: loads parameters from a new font vlw file
|
||||
*************************************************************************************x*/
|
||||
void TFT_eSPI::loadFont(String fontName)
|
||||
void TFT_eSPI::loadFont(String fontName, fs::FS &ffs)
|
||||
{
|
||||
fontFS = ffs;
|
||||
loadFont(fontName, false);
|
||||
}
|
||||
/***************************************************************************************
|
||||
** Function name: loadFont
|
||||
** Description: loads parameters from a new font vlw file
|
||||
*************************************************************************************x*/
|
||||
void TFT_eSPI::loadFont(String fontName, bool flash)
|
||||
{
|
||||
/*
|
||||
The vlw font format does not appear to be documented anywhere, so some reverse
|
||||
@ -74,15 +83,19 @@ void TFT_eSPI::loadFont(String fontName)
|
||||
|
||||
*/
|
||||
|
||||
unloadFont();
|
||||
|
||||
spiffs = flash;
|
||||
|
||||
if(spiffs) fontFS = SPIFFS;
|
||||
|
||||
unloadFont();
|
||||
|
||||
// Avoid a crash on the ESP32 if the file does not exist
|
||||
if (SPIFFS.exists("/" + fontName + ".vlw") == false) {
|
||||
if (fontFS.exists("/" + fontName + ".vlw") == false) {
|
||||
Serial.println("Font file " + fontName + " not found!");
|
||||
return;
|
||||
}
|
||||
|
||||
fontFile = SPIFFS.open( "/" + fontName + ".vlw", "r");
|
||||
fontFile = fontFS.open( "/" + fontName + ".vlw", "r");
|
||||
|
||||
if(!fontFile) return;
|
||||
|
||||
@ -120,13 +133,28 @@ void TFT_eSPI::loadMetrics(uint16_t gCount)
|
||||
uint32_t headerPtr = 24;
|
||||
uint32_t bitmapPtr = 24 + gCount * 28;
|
||||
|
||||
gUnicode = (uint16_t*)malloc( gCount * 2); // Unicode 16 bit Basic Multilingual Plane (0-FFFF)
|
||||
gHeight = (uint8_t*)malloc( gCount ); // Height of glyph
|
||||
gWidth = (uint8_t*)malloc( gCount ); // Width of glyph
|
||||
gxAdvance = (uint8_t*)malloc( gCount ); // xAdvance - to move x cursor
|
||||
gdY = (int16_t*)malloc( gCount * 2); // offset from bitmap top edge from lowest point in any character
|
||||
gdX = (int8_t*)malloc( gCount ); // offset for bitmap left edge relative to cursor X
|
||||
gBitmap = (uint32_t*)malloc( gCount * 4); // seek pointer to glyph bitmap in SPIFFS file
|
||||
#if defined (ESP32) && defined (CONFIG_SPIRAM_SUPPORT)
|
||||
if ( psramFound() )
|
||||
{
|
||||
gUnicode = (uint16_t*)ps_malloc( gCount * 2); // Unicode 16 bit Basic Multilingual Plane (0-FFFF)
|
||||
gHeight = (uint8_t*)ps_malloc( gCount ); // Height of glyph
|
||||
gWidth = (uint8_t*)ps_malloc( gCount ); // Width of glyph
|
||||
gxAdvance = (uint8_t*)ps_malloc( gCount ); // xAdvance - to move x cursor
|
||||
gdY = (int16_t*)ps_malloc( gCount * 2); // offset from bitmap top edge from lowest point in any character
|
||||
gdX = (int8_t*)ps_malloc( gCount ); // offset for bitmap left edge relative to cursor X
|
||||
gBitmap = (uint32_t*)ps_malloc( gCount * 4); // seek pointer to glyph bitmap in the file
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
gUnicode = (uint16_t*)malloc( gCount * 2); // Unicode 16 bit Basic Multilingual Plane (0-FFFF)
|
||||
gHeight = (uint8_t*)malloc( gCount ); // Height of glyph
|
||||
gWidth = (uint8_t*)malloc( gCount ); // Width of glyph
|
||||
gxAdvance = (uint8_t*)malloc( gCount ); // xAdvance - to move x cursor
|
||||
gdY = (int16_t*)malloc( gCount * 2); // offset from bitmap top edge from lowest point in any character
|
||||
gdX = (int8_t*)malloc( gCount ); // offset for bitmap left edge relative to cursor X
|
||||
gBitmap = (uint32_t*)malloc( gCount * 4); // seek pointer to glyph bitmap in the file
|
||||
}
|
||||
|
||||
#ifdef SHOW_ASCENT_DESCENT
|
||||
Serial.print("ascent = "); Serial.println(gFont.ascent);
|
||||
@ -456,7 +484,19 @@ void TFT_eSPI::drawGlyph(uint16_t code)
|
||||
|
||||
for (int y = 0; y < gHeight[gNum]; y++)
|
||||
{
|
||||
fontFile.read(pbuffer, gWidth[gNum]); //<//
|
||||
if (spiffs)
|
||||
{
|
||||
fontFile.read(pbuffer, gWidth[gNum]);
|
||||
//Serial.println("SPIFFS");
|
||||
}
|
||||
else
|
||||
{
|
||||
endWrite(); // Release SPI for SD card transaction
|
||||
fontFile.read(pbuffer, gWidth[gNum]);
|
||||
startWrite(); // Re-start SPI for TFT transaction
|
||||
//Serial.println("Not SPIFFS");
|
||||
}
|
||||
|
||||
for (int x = 0; x < gWidth[gNum]; x++)
|
||||
{
|
||||
uint8_t pixel = pbuffer[x]; //<//
|
||||
@ -486,6 +526,7 @@ void TFT_eSPI::drawGlyph(uint16_t code)
|
||||
}
|
||||
|
||||
cursor_x += gxAdvance[gNum];
|
||||
endWrite();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -493,8 +534,6 @@ void TFT_eSPI::drawGlyph(uint16_t code)
|
||||
drawRect(cursor_x, cursor_y + gFont.maxAscent - gFont.ascent, gFont.spaceWidth, gFont.ascent, fg);
|
||||
cursor_x += gFont.spaceWidth + 1;
|
||||
}
|
||||
|
||||
endWrite();
|
||||
}
|
||||
|
||||
/***************************************************************************************
|
||||
|
@ -4,7 +4,8 @@
|
||||
public:
|
||||
|
||||
// These are for the new antialiased fonts
|
||||
void loadFont(String fontName);
|
||||
void loadFont(String fontName, fs::FS &ffs);
|
||||
void loadFont(String fontName, bool flash = true);
|
||||
void unloadFont( void );
|
||||
bool getUnicodeIndex(uint16_t unicode, uint16_t *index);
|
||||
|
||||
@ -14,9 +15,7 @@
|
||||
|
||||
void showFont(uint32_t td);
|
||||
|
||||
fs::File fontFile;
|
||||
|
||||
// This is for the whole font
|
||||
// This is for the whole font
|
||||
typedef struct
|
||||
{
|
||||
uint16_t gCount; // Total number of characters
|
||||
@ -40,8 +39,12 @@ fontMetrics gFont = { 0, 0, 0, 0, 0, 0, 0 };
|
||||
uint32_t* gBitmap = NULL; //file pointer to greyscale bitmap
|
||||
|
||||
bool fontLoaded = false; // Flags when a anti-aliased font is loaded
|
||||
fs::File fontFile;
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
void loadMetrics(uint16_t gCount);
|
||||
uint32_t readInt32(void);
|
||||
|
||||
fs::FS &fontFS = SPIFFS;
|
||||
bool spiffs = true;
|
@ -1679,7 +1679,7 @@ int16_t TFT_eSprite::drawChar(uint16_t uniCode, int32_t x, int32_t y, uint8_t fo
|
||||
if ((font>2) && (font<9))
|
||||
{
|
||||
// This is slower than above but is more convenient for the RLE fonts
|
||||
flash_address = pgm_read_dword( pgm_read_dword( &(fontdata[font].chartbl ) ) + uniCode*sizeof(void *) );
|
||||
flash_address = pgm_read_dword( (const void*)pgm_read_dword( &(fontdata[font].chartbl ) ) + uniCode*sizeof(void *) );
|
||||
width = pgm_read_byte( (uint8_t *)pgm_read_dword( &(fontdata[font].widthtbl ) ) + uniCode );
|
||||
height= pgm_read_byte( &fontdata[font].height );
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ uint8_t TFT_eSPI::getTouch(uint16_t *x, uint16_t *y, uint16_t threshold){
|
||||
|
||||
convertRawXY(&x_tmp, &y_tmp);
|
||||
|
||||
if (x_tmp >= _width || y_tmp >= _height) return valid;
|
||||
if (x_tmp >= _width || y_tmp >= _height) return false;
|
||||
|
||||
_pressX = x_tmp;
|
||||
_pressY = y_tmp;
|
||||
|
143
libraries/TFT_eSPI/TFT_Drivers/ST7789_2_Defines.h
Normal file
143
libraries/TFT_eSPI/TFT_Drivers/ST7789_2_Defines.h
Normal file
@ -0,0 +1,143 @@
|
||||
// Change the width and height if required (defined in portrait mode)
|
||||
// or use the constructor to over-ride defaults
|
||||
#ifndef TFT_WIDTH
|
||||
#define TFT_WIDTH 240
|
||||
#endif
|
||||
#ifndef TFT_HEIGHT
|
||||
#define TFT_HEIGHT 320
|
||||
#endif
|
||||
|
||||
#if (TFT_HEIGHT == 240) && (TFT_WIDTH == 240)
|
||||
#define CGRAM_OFFSET
|
||||
#endif
|
||||
|
||||
// Delay between some initialisation commands
|
||||
#define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked
|
||||
|
||||
|
||||
// Generic commands used by TFT_eSPI.cpp
|
||||
#define TFT_NOP 0x00
|
||||
#define TFT_SWRST 0x01
|
||||
|
||||
#define TFT_SLPIN 0x10
|
||||
#define TFT_SLPOUT 0x11
|
||||
#define TFT_NORON 0x13
|
||||
|
||||
#define TFT_INVOFF 0x20
|
||||
#define TFT_INVON 0x21
|
||||
#define TFT_DISPOFF 0x28
|
||||
#define TFT_DISPON 0x29
|
||||
#define TFT_CASET 0x2A
|
||||
#define TFT_PASET 0x2B
|
||||
#define TFT_RAMWR 0x2C
|
||||
#define TFT_RAMRD 0x2E
|
||||
#define TFT_MADCTL 0x36
|
||||
#define TFT_COLMOD 0x3A
|
||||
|
||||
// Flags for TFT_MADCTL
|
||||
#define TFT_MAD_MY 0x80
|
||||
#define TFT_MAD_MX 0x40
|
||||
#define TFT_MAD_MV 0x20
|
||||
#define TFT_MAD_ML 0x10
|
||||
#define TFT_MAD_RGB 0x00
|
||||
#define TFT_MAD_BGR 0x08
|
||||
#define TFT_MAD_MH 0x04
|
||||
#define TFT_MAD_SS 0x02
|
||||
#define TFT_MAD_GS 0x01
|
||||
|
||||
#ifdef TFT_RGB_ORDER
|
||||
#if (TFT_RGB_ORDER == 1)
|
||||
#define TFT_MAD_COLOR_ORDER TFT_MAD_RGB
|
||||
#else
|
||||
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
|
||||
#endif
|
||||
#else
|
||||
#ifdef CGRAM_OFFSET
|
||||
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
|
||||
#else
|
||||
#define TFT_MAD_COLOR_ORDER TFT_MAD_RGB
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define TFT_IDXRD 0x00 // ILI9341 only, indexed control register read
|
||||
|
||||
#define ST_CMD_DELAY 0x80 // special signifier for command lists
|
||||
#define ST7789_240x240_XSTART 0
|
||||
#define ST7789_240x240_YSTART 0
|
||||
|
||||
// ST7789 specific commands used in init
|
||||
#define ST7789_NOP 0x00
|
||||
#define ST7789_SWRESET 0x01
|
||||
#define ST7789_RDDID 0x04
|
||||
#define ST7789_RDDST 0x09
|
||||
|
||||
#define ST7789_RDDPM 0x0A // Read display power mode
|
||||
#define ST7789_RDD_MADCTL 0x0B // Read display MADCTL
|
||||
#define ST7789_RDD_COLMOD 0x0C // Read display pixel format
|
||||
#define ST7789_RDDIM 0x0D // Read display image mode
|
||||
#define ST7789_RDDSM 0x0E // Read display signal mode
|
||||
#define ST7789_RDDSR 0x0F // Read display self-diagnostic result (ST7789V)
|
||||
|
||||
#define ST7789_SLPIN 0x10
|
||||
#define ST7789_SLPOUT 0x11
|
||||
#define ST7789_PTLON 0x12
|
||||
#define ST7789_NORON 0x13
|
||||
|
||||
#define ST7789_INVOFF 0x20
|
||||
#define ST7789_INVON 0x21
|
||||
#define ST7789_GAMSET 0x26 // Gamma set
|
||||
#define ST7789_DISPOFF 0x28
|
||||
#define ST7789_DISPON 0x29
|
||||
#define ST7789_CASET 0x2A
|
||||
#define ST7789_RASET 0x2B
|
||||
#define ST7789_RAMWR 0x2C
|
||||
#define ST7789_RGBSET 0x2D // Color setting for 4096, 64K and 262K colors
|
||||
#define ST7789_RAMRD 0x2E
|
||||
|
||||
#define ST7789_PTLAR 0x30
|
||||
#define ST7789_VSCRDEF 0x33 // Vertical scrolling definition (ST7789V)
|
||||
#define ST7789_TEOFF 0x34 // Tearing effect line off
|
||||
#define ST7789_TEON 0x35 // Tearing effect line on
|
||||
#define ST7789_MADCTL 0x36 // Memory data access control
|
||||
#define ST7789_IDMOFF 0x38 // Idle mode off
|
||||
#define ST7789_IDMON 0x39 // Idle mode on
|
||||
#define ST7789_RAMWRC 0x3C // Memory write continue (ST7789V)
|
||||
#define ST7789_RAMRDC 0x3E // Memory read continue (ST7789V)
|
||||
#define ST7789_COLMOD 0x3A
|
||||
|
||||
#define ST7789_RAMCTRL 0xB0 // RAM control
|
||||
#define ST7789_RGBCTRL 0xB1 // RGB control
|
||||
#define ST7789_PORCTRL 0xB2 // Porch control
|
||||
#define ST7789_FRCTRL1 0xB3 // Frame rate control
|
||||
#define ST7789_PARCTRL 0xB5 // Partial mode control
|
||||
#define ST7789_GCTRL 0xB7 // Gate control
|
||||
#define ST7789_GTADJ 0xB8 // Gate on timing adjustment
|
||||
#define ST7789_DGMEN 0xBA // Digital gamma enable
|
||||
#define ST7789_VCOMS 0xBB // VCOMS setting
|
||||
#define ST7789_LCMCTRL 0xC0 // LCM control
|
||||
#define ST7789_IDSET 0xC1 // ID setting
|
||||
#define ST7789_VDVVRHEN 0xC2 // VDV and VRH command enable
|
||||
#define ST7789_VRHS 0xC3 // VRH set
|
||||
#define ST7789_VDVSET 0xC4 // VDV setting
|
||||
#define ST7789_VCMOFSET 0xC5 // VCOMS offset set
|
||||
#define ST7789_FRCTR2 0xC6 // FR Control 2
|
||||
#define ST7789_CABCCTRL 0xC7 // CABC control
|
||||
#define ST7789_REGSEL1 0xC8 // Register value section 1
|
||||
#define ST7789_REGSEL2 0xCA // Register value section 2
|
||||
#define ST7789_PWMFRSEL 0xCC // PWM frequency selection
|
||||
#define ST7789_PWCTRL1 0xD0 // Power control 1
|
||||
#define ST7789_VAPVANEN 0xD2 // Enable VAP/VAN signal output
|
||||
#define ST7789_CMD2EN 0xDF // Command 2 enable
|
||||
#define ST7789_PVGAMCTRL 0xE0 // Positive voltage gamma control
|
||||
#define ST7789_NVGAMCTRL 0xE1 // Negative voltage gamma control
|
||||
#define ST7789_DGMLUTR 0xE2 // Digital gamma look-up table for red
|
||||
#define ST7789_DGMLUTB 0xE3 // Digital gamma look-up table for blue
|
||||
#define ST7789_GATECTRL 0xE4 // Gate control
|
||||
#define ST7789_SPI2EN 0xE7 // SPI2 enable
|
||||
#define ST7789_PWCTRL2 0xE8 // Power control 2
|
||||
#define ST7789_EQCTRL 0xE9 // Equalize time control
|
||||
#define ST7789_PROMCTRL 0xEC // Program control
|
||||
#define ST7789_PROMEN 0xFA // Program mode enable
|
||||
#define ST7789_NVMSET 0xFC // NVM setting
|
||||
#define ST7789_PROMACT 0xFE // Program action
|
||||
|
22
libraries/TFT_eSPI/TFT_Drivers/ST7789_2_Init.h
Normal file
22
libraries/TFT_eSPI/TFT_Drivers/ST7789_2_Init.h
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
// This is the command sequence that initialises the ST7789 driver
|
||||
|
||||
// Configure ST7789 display
|
||||
|
||||
{
|
||||
static const uint8_t PROGMEM
|
||||
st7789[] = {
|
||||
8,
|
||||
TFT_SLPOUT, TFT_INIT_DELAY, 255,
|
||||
TFT_COLMOD, 1+TFT_INIT_DELAY, 0x55, 10,
|
||||
TFT_MADCTL, 1, 0x00,
|
||||
TFT_CASET, 4, 0x00, 0x00, 0x00, 0xF0,
|
||||
TFT_PASET, 4, 0x00, 0x00, 0x00, 0xF0,
|
||||
TFT_INVON, TFT_INIT_DELAY, 10,
|
||||
TFT_NORON, TFT_INIT_DELAY, 10,
|
||||
TFT_DISPON, TFT_INIT_DELAY, 255
|
||||
};
|
||||
|
||||
commandList(st7789);
|
||||
}
|
||||
// End of ST7789 display configuration
|
48
libraries/TFT_eSPI/TFT_Drivers/ST7789_2_Rotation.h
Normal file
48
libraries/TFT_eSPI/TFT_Drivers/ST7789_2_Rotation.h
Normal file
@ -0,0 +1,48 @@
|
||||
// This is the command sequence that rotates the ST7789 driver coordinate frame
|
||||
|
||||
writecommand(TFT_MADCTL);
|
||||
rotation = m % 4;
|
||||
switch (rotation) {
|
||||
case 0: // Portrait
|
||||
#ifdef CGRAM_OFFSET
|
||||
colstart = 0;
|
||||
rowstart = 0;
|
||||
#endif
|
||||
writedata(TFT_MAD_COLOR_ORDER);
|
||||
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
break;
|
||||
|
||||
case 1: // Landscape (Portrait + 90)
|
||||
#ifdef CGRAM_OFFSET
|
||||
colstart = 0;
|
||||
rowstart = 0;
|
||||
#endif
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
|
||||
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
break;
|
||||
|
||||
case 2: // Inverter portrait
|
||||
#ifdef CGRAM_OFFSET
|
||||
colstart = 0;
|
||||
rowstart = 80;
|
||||
#endif
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
|
||||
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
break;
|
||||
case 3: // Inverted landscape
|
||||
#ifdef CGRAM_OFFSET
|
||||
colstart = 80;
|
||||
rowstart = 0;
|
||||
#endif
|
||||
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
|
||||
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
break;
|
||||
}
|
@ -23,6 +23,7 @@
|
||||
|
||||
writecommand(ST7789_COLMOD);
|
||||
writedata(0x55);
|
||||
delay(10);
|
||||
|
||||
//--------------------------------ST7789V Frame rate setting----------------------------------//
|
||||
writecommand(ST7789_PORCTRL);
|
||||
@ -92,7 +93,7 @@
|
||||
writedata(0x1b);
|
||||
writedata(0x1e);
|
||||
|
||||
writecommand(ST7789_INVOFF);
|
||||
writecommand(ST7789_INVON);
|
||||
|
||||
writecommand(ST7789_CASET); // Column address set
|
||||
writedata(0x00);
|
||||
@ -113,6 +114,7 @@
|
||||
spi_begin();
|
||||
|
||||
writecommand(ST7789_DISPON); //Display on
|
||||
delay(120);
|
||||
|
||||
#ifdef TFT_BL
|
||||
// Turn on the back-light LED
|
||||
|
@ -21,11 +21,11 @@
|
||||
#ifdef USE_HSPI_PORT
|
||||
SPIClass spi = SPIClass(HSPI);
|
||||
#else // use default VSPI port
|
||||
SPIClass spi = SPIClass(VSPI);
|
||||
SPIClass& spi = SPI;
|
||||
#endif
|
||||
#endif
|
||||
#else // ESP8266
|
||||
SPIClass spi = SPIClass();
|
||||
SPIClass& spi = SPI;
|
||||
#endif
|
||||
|
||||
// SUPPORT_TRANSACTIONS is mandatory for ESP32 so the hal mutex is toggled
|
||||
@ -228,6 +228,11 @@ TFT_eSPI::TFT_eSPI(int16_t w, int16_t h)
|
||||
_xpivot = 0;
|
||||
_ypivot = 0;
|
||||
|
||||
cspinmask = 0;
|
||||
dcpinmask = 0;
|
||||
wrpinmask = 0;
|
||||
sclkpinmask = 0;
|
||||
|
||||
#ifdef LOAD_GLCD
|
||||
fontsloaded = 0x0002; // Bit 1 set
|
||||
#endif
|
||||
@ -281,19 +286,19 @@ void TFT_eSPI::init(uint8_t tc)
|
||||
if (_booted)
|
||||
{
|
||||
#if !defined (ESP32)
|
||||
#ifdef TFT_CS
|
||||
#if defined (TFT_CS) && (TFT_CS >= 0)
|
||||
cspinmask = (uint32_t) digitalPinToBitMask(TFT_CS);
|
||||
#endif
|
||||
|
||||
#ifdef TFT_DC
|
||||
#if defined (TFT_DC) && (TFT_DC >= 0)
|
||||
dcpinmask = (uint32_t) digitalPinToBitMask(TFT_DC);
|
||||
#endif
|
||||
|
||||
#ifdef TFT_WR
|
||||
#if defined (TFT_WR) && (TFT_WR >= 0)
|
||||
wrpinmask = (uint32_t) digitalPinToBitMask(TFT_WR);
|
||||
#endif
|
||||
|
||||
#ifdef TFT_SCLK
|
||||
#if defined (TFT_SCLK) && (TFT_SCLK >= 0)
|
||||
sclkpinmask = (uint32_t) digitalPinToBitMask(TFT_SCLK);
|
||||
#endif
|
||||
|
||||
@ -407,6 +412,9 @@ void TFT_eSPI::init(uint8_t tc)
|
||||
#elif defined (R61581_DRIVER)
|
||||
#include "TFT_Drivers/R61581_Init.h"
|
||||
|
||||
#elif defined (ST7789_2_DRIVER)
|
||||
#include "TFT_Drivers/ST7789_2_Init.h"
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TFT_INVERSION_ON
|
||||
@ -477,6 +485,9 @@ void TFT_eSPI::setRotation(uint8_t m)
|
||||
#elif defined (R61581_DRIVER)
|
||||
#include "TFT_Drivers/R61581_Rotation.h"
|
||||
|
||||
#elif defined (ST7789_2_DRIVER)
|
||||
#include "TFT_Drivers/ST7789_2_Rotation.h"
|
||||
|
||||
#endif
|
||||
|
||||
delayMicroseconds(10);
|
||||
@ -1561,7 +1572,7 @@ void TFT_eSPI::drawCircle(int32_t x0, int32_t y0, int32_t r, uint32_t color)
|
||||
int32_t dy = r+r;
|
||||
int32_t p = -(r>>1);
|
||||
|
||||
spi_begin();
|
||||
//spi_begin(); // Sprite class can use this function, avoiding spi_begin()
|
||||
inTransaction = true;
|
||||
|
||||
// These are ordered to minimise coordinate changes in x or y
|
||||
@ -1598,7 +1609,7 @@ void TFT_eSPI::drawCircle(int32_t x0, int32_t y0, int32_t r, uint32_t color)
|
||||
}
|
||||
|
||||
inTransaction = false;
|
||||
spi_end();
|
||||
spi_end(); // Does nothing if Sprite class uses this function
|
||||
}
|
||||
|
||||
|
||||
@ -1654,7 +1665,7 @@ void TFT_eSPI::fillCircle(int32_t x0, int32_t y0, int32_t r, uint32_t color)
|
||||
int32_t dy = r+r;
|
||||
int32_t p = -(r>>1);
|
||||
|
||||
spi_begin();
|
||||
//spi_begin(); // Sprite class can use this function, avoiding spi_begin()
|
||||
inTransaction = true;
|
||||
|
||||
drawFastHLine(x0 - r, y0, dy+1, color);
|
||||
@ -1680,7 +1691,7 @@ void TFT_eSPI::fillCircle(int32_t x0, int32_t y0, int32_t r, uint32_t color)
|
||||
}
|
||||
|
||||
inTransaction = false;
|
||||
spi_end();
|
||||
spi_end(); // Does nothing if Sprite class uses this function
|
||||
}
|
||||
|
||||
|
||||
@ -1736,7 +1747,7 @@ void TFT_eSPI::drawEllipse(int16_t x0, int16_t y0, int32_t rx, int32_t ry, uint1
|
||||
int32_t fy2 = 4 * ry2;
|
||||
int32_t s;
|
||||
|
||||
spi_begin();
|
||||
//spi_begin(); // Sprite class can use this function, avoiding spi_begin()
|
||||
inTransaction = true;
|
||||
|
||||
for (x = 0, y = ry, s = 2*ry2+rx2*(1-2*ry); ry2*x <= rx2*y; x++)
|
||||
@ -1772,7 +1783,7 @@ void TFT_eSPI::drawEllipse(int16_t x0, int16_t y0, int32_t rx, int32_t ry, uint1
|
||||
}
|
||||
|
||||
inTransaction = false;
|
||||
spi_end();
|
||||
spi_end(); // Does nothing if Sprite class uses this function
|
||||
}
|
||||
|
||||
|
||||
@ -1791,7 +1802,7 @@ void TFT_eSPI::fillEllipse(int16_t x0, int16_t y0, int32_t rx, int32_t ry, uint1
|
||||
int32_t fy2 = 4 * ry2;
|
||||
int32_t s;
|
||||
|
||||
spi_begin();
|
||||
//spi_begin(); // Sprite class can use this function, avoiding spi_begin()
|
||||
inTransaction = true;
|
||||
|
||||
for (x = 0, y = ry, s = 2*ry2+rx2*(1-2*ry); ry2*x <= rx2*y; x++)
|
||||
@ -1821,7 +1832,7 @@ void TFT_eSPI::fillEllipse(int16_t x0, int16_t y0, int32_t rx, int32_t ry, uint1
|
||||
}
|
||||
|
||||
inTransaction = false;
|
||||
spi_end();
|
||||
spi_end(); // Does nothing if Sprite class uses this function
|
||||
}
|
||||
|
||||
|
||||
@ -1842,7 +1853,7 @@ void TFT_eSPI::fillScreen(uint32_t color)
|
||||
// Draw a rectangle
|
||||
void TFT_eSPI::drawRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color)
|
||||
{
|
||||
spi_begin();
|
||||
//spi_begin(); // Sprite class can use this function, avoiding spi_begin()
|
||||
inTransaction = true;
|
||||
|
||||
drawFastHLine(x, y, w, color);
|
||||
@ -1852,7 +1863,7 @@ void TFT_eSPI::drawRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t col
|
||||
drawFastVLine(x + w - 1, y+1, h-2, color);
|
||||
|
||||
inTransaction = false;
|
||||
spi_end();
|
||||
spi_end(); // Does nothing if Sprite class uses this function
|
||||
}
|
||||
|
||||
|
||||
@ -1863,7 +1874,7 @@ void TFT_eSPI::drawRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t col
|
||||
// Draw a rounded rectangle
|
||||
void TFT_eSPI::drawRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t r, uint32_t color)
|
||||
{
|
||||
spi_begin();
|
||||
//spi_begin(); // Sprite class can use this function, avoiding spi_begin()
|
||||
inTransaction = true;
|
||||
|
||||
// smarter version
|
||||
@ -1878,7 +1889,7 @@ void TFT_eSPI::drawRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t
|
||||
drawCircleHelper(x + r , y + h - r - 1, r, 8, color);
|
||||
|
||||
inTransaction = false;
|
||||
spi_end();
|
||||
spi_end(); // Does nothing if Sprite class uses this function
|
||||
}
|
||||
|
||||
|
||||
@ -1889,7 +1900,7 @@ void TFT_eSPI::drawRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t
|
||||
// Fill a rounded rectangle, changed to horizontal lines (faster in sprites)
|
||||
void TFT_eSPI::fillRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t r, uint32_t color)
|
||||
{
|
||||
spi_begin();
|
||||
//spi_begin(); // Sprite class can use this function, avoiding spi_begin()
|
||||
inTransaction = true;
|
||||
|
||||
// smarter version
|
||||
@ -1900,7 +1911,7 @@ void TFT_eSPI::fillRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t
|
||||
fillCircleHelper(x + r , y + r, r, 2, w - r - r - 1, color);
|
||||
|
||||
inTransaction = false;
|
||||
spi_end();
|
||||
spi_end(); // Does nothing if Sprite class uses this function
|
||||
}
|
||||
|
||||
|
||||
@ -1911,7 +1922,7 @@ void TFT_eSPI::fillRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t
|
||||
// Draw a triangle
|
||||
void TFT_eSPI::drawTriangle(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t x2, int32_t y2, uint32_t color)
|
||||
{
|
||||
spi_begin();
|
||||
//spi_begin(); // Sprite class can use this function, avoiding spi_begin()
|
||||
inTransaction = true;
|
||||
|
||||
drawLine(x0, y0, x1, y1, color);
|
||||
@ -1919,7 +1930,7 @@ void TFT_eSPI::drawTriangle(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int3
|
||||
drawLine(x2, y2, x0, y0, color);
|
||||
|
||||
inTransaction = false;
|
||||
spi_end();
|
||||
spi_end(); // Does nothing if Sprite class uses this function
|
||||
}
|
||||
|
||||
|
||||
@ -1953,7 +1964,7 @@ void TFT_eSPI::fillTriangle ( int32_t x0, int32_t y0, int32_t x1, int32_t y1, in
|
||||
return;
|
||||
}
|
||||
|
||||
spi_begin();
|
||||
//spi_begin(); // Sprite class can use this function, avoiding spi_begin()
|
||||
inTransaction = true;
|
||||
|
||||
int32_t
|
||||
@ -2000,7 +2011,7 @@ void TFT_eSPI::fillTriangle ( int32_t x0, int32_t y0, int32_t x1, int32_t y1, in
|
||||
}
|
||||
|
||||
inTransaction = false;
|
||||
spi_end();
|
||||
spi_end(); // Does nothing if Sprite class uses this function
|
||||
}
|
||||
|
||||
|
||||
@ -2010,7 +2021,7 @@ void TFT_eSPI::fillTriangle ( int32_t x0, int32_t y0, int32_t x1, int32_t y1, in
|
||||
***************************************************************************************/
|
||||
void TFT_eSPI::drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color)
|
||||
{
|
||||
spi_begin();
|
||||
//spi_begin(); // Sprite class can use this function, avoiding spi_begin()
|
||||
inTransaction = true;
|
||||
|
||||
int32_t i, j, byteWidth = (w + 7) / 8;
|
||||
@ -2024,7 +2035,7 @@ void TFT_eSPI::drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w
|
||||
}
|
||||
|
||||
inTransaction = false;
|
||||
spi_end();
|
||||
spi_end(); // Does nothing if Sprite class uses this function
|
||||
}
|
||||
|
||||
|
||||
@ -2034,7 +2045,7 @@ void TFT_eSPI::drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w
|
||||
***************************************************************************************/
|
||||
void TFT_eSPI::drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color)
|
||||
{
|
||||
spi_begin();
|
||||
//spi_begin(); // Sprite class can use this function, avoiding spi_begin()
|
||||
inTransaction = true;
|
||||
|
||||
int32_t i, j, byteWidth = (w + 7) / 8;
|
||||
@ -2048,7 +2059,7 @@ void TFT_eSPI::drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t
|
||||
}
|
||||
|
||||
inTransaction = false;
|
||||
spi_end();
|
||||
spi_end(); // Does nothing if Sprite class uses this function
|
||||
}
|
||||
|
||||
|
||||
@ -2058,7 +2069,7 @@ void TFT_eSPI::drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t
|
||||
***************************************************************************************/
|
||||
void TFT_eSPI::drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color, uint16_t bgcolor)
|
||||
{
|
||||
spi_begin();
|
||||
//spi_begin(); // Sprite class can use this function, avoiding spi_begin()
|
||||
inTransaction = true;
|
||||
|
||||
int32_t i, j, byteWidth = (w + 7) / 8;
|
||||
@ -2072,7 +2083,7 @@ void TFT_eSPI::drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t
|
||||
}
|
||||
|
||||
inTransaction = false;
|
||||
spi_end();
|
||||
spi_end(); // Does nothing if Sprite class uses this function
|
||||
}
|
||||
|
||||
|
||||
@ -2480,7 +2491,7 @@ void TFT_eSPI::drawChar(int32_t x, int32_t y, uint16_t c, uint32_t color, uint32
|
||||
}
|
||||
else
|
||||
{
|
||||
spi_begin();
|
||||
//spi_begin(); // Sprite class can use this function, avoiding spi_begin()
|
||||
inTransaction = true;
|
||||
for (int8_t i = 0; i < 6; i++ ) {
|
||||
uint8_t line;
|
||||
@ -2505,7 +2516,7 @@ void TFT_eSPI::drawChar(int32_t x, int32_t y, uint16_t c, uint32_t color, uint32
|
||||
}
|
||||
}
|
||||
inTransaction = false;
|
||||
spi_end();
|
||||
spi_end(); // Does nothing if Sprite class uses this function
|
||||
}
|
||||
|
||||
//>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
@ -2519,7 +2530,7 @@ void TFT_eSPI::drawChar(int32_t x, int32_t y, uint16_t c, uint32_t color, uint32
|
||||
// Filter out bad characters not present in font
|
||||
if ((c >= pgm_read_word(&gfxFont->first)) && (c <= pgm_read_word(&gfxFont->last )))
|
||||
{
|
||||
spi_begin();
|
||||
//spi_begin(); // Sprite class can use this function, avoiding spi_begin()
|
||||
inTransaction = true;
|
||||
//>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
|
||||
@ -2643,7 +2654,7 @@ void TFT_eSPI::drawChar(int32_t x, int32_t y, uint16_t c, uint32_t color, uint32
|
||||
}
|
||||
#endif
|
||||
inTransaction = false;
|
||||
spi_end();
|
||||
spi_end(); // Does nothing if Sprite class uses this function
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -3378,7 +3389,7 @@ void TFT_eSPI::pushColors(uint8_t *data, uint32_t len)
|
||||
while (len--) {tft_Write_8(*data); data++;}
|
||||
#elif defined (ILI9488_DRIVER)
|
||||
uint16_t color;
|
||||
while (len>1) {color = (*data++) | ((*data++)<<8); tft_Write_16(color); len-=2;}
|
||||
while (len>1) {color = (*data++); color |= ((*data++)<<8); tft_Write_16(color); len-=2;}
|
||||
#else
|
||||
#if (SPI_FREQUENCY == 80000000)
|
||||
while ( len >=64 ) {spi.writePattern(data, 64, 1); data += 64; len -= 64; }
|
||||
@ -3500,7 +3511,7 @@ void TFT_eSPI::pushColors(uint16_t *data, uint32_t len, bool swap)
|
||||
|
||||
void TFT_eSPI::drawLine(int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint32_t color)
|
||||
{
|
||||
spi_begin();
|
||||
//spi_begin(); // Sprite class can use this function, avoiding spi_begin()
|
||||
inTransaction = true;
|
||||
boolean steep = abs(y1 - y0) > abs(x1 - x0);
|
||||
if (steep) {
|
||||
@ -4259,7 +4270,7 @@ int16_t TFT_eSPI::drawChar(uint16_t uniCode, int32_t x, int32_t y, uint8_t font)
|
||||
{
|
||||
if ((font>2) && (font<9))
|
||||
{
|
||||
flash_address = pgm_read_dword( pgm_read_dword( &(fontdata[font].chartbl ) ) + uniCode*sizeof(void *) );
|
||||
flash_address = pgm_read_dword( (const void*)pgm_read_dword( &(fontdata[font].chartbl ) ) + uniCode*sizeof(void *) );
|
||||
width = pgm_read_byte( (uint8_t *)pgm_read_dword( &(fontdata[font].widthtbl ) ) + uniCode );
|
||||
height= pgm_read_byte( &fontdata[font].height );
|
||||
}
|
||||
@ -4278,7 +4289,7 @@ int16_t TFT_eSPI::drawChar(uint16_t uniCode, int32_t x, int32_t y, uint8_t font)
|
||||
if (x + width * textsize >= (int16_t)_width) return width * textsize ;
|
||||
|
||||
if (textcolor == textbgcolor || textsize != 1) {
|
||||
spi_begin();
|
||||
//spi_begin(); // Sprite class can use this function, avoiding spi_begin()
|
||||
inTransaction = true;
|
||||
|
||||
for (int32_t i = 0; i < height; i++)
|
||||
@ -5178,6 +5189,18 @@ void writeBlock(uint16_t color, uint32_t repeat)
|
||||
#endif
|
||||
|
||||
|
||||
/***************************************************************************************
|
||||
** Function name: getSPIinstance
|
||||
** Description: Get the instance of the SPI class (for ESP32 only)
|
||||
***************************************************************************************/
|
||||
#ifndef ESP32_PARALLEL
|
||||
SPIClass& TFT_eSPI::getSPIinstance(void)
|
||||
{
|
||||
return spi;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/***************************************************************************************
|
||||
** Function name: getSetup
|
||||
** Description: Get the setup details for diagnostic and sketch access
|
||||
|
@ -37,7 +37,7 @@
|
||||
#define SPI_READ_FREQUENCY SPI_FREQUENCY
|
||||
#endif
|
||||
|
||||
#ifdef ST7789_DRIVER
|
||||
#if defined(ST7789_DRIVER) || defined(ST7789_2_DRIVER)
|
||||
#define TFT_SPI_MODE SPI_MODE3
|
||||
#else
|
||||
#define TFT_SPI_MODE SPI_MODE0
|
||||
@ -334,7 +334,7 @@
|
||||
|
||||
// Convert swapped byte 16 bit colour to 18 bit and write in 3 bytes
|
||||
#define tft_Write_16S(C) spi.transfer(C & 0xF8); \
|
||||
spi.transfer((C & 0xE0)>>11 | (C & 0x07)<<5); \
|
||||
spi.transfer((C & 0xE000)>>11 | (C & 0x07)<<5); \
|
||||
spi.transfer((C & 0x1F00)>>5)
|
||||
// Write 32 bits to TFT
|
||||
#define tft_Write_32(C) spi.write32(C)
|
||||
@ -831,6 +831,8 @@ class TFT_eSPI : public Print {
|
||||
|
||||
void getSetup(setup_t& tft_settings); // Sketch provides the instance to populate
|
||||
|
||||
static SPIClass& getSPIinstance(void);
|
||||
|
||||
int32_t cursor_x, cursor_y, padX;
|
||||
uint32_t textcolor, textbgcolor;
|
||||
|
||||
|
@ -25,14 +25,15 @@
|
||||
//#define ILI9481_DRIVER
|
||||
//#define ILI9486_DRIVER
|
||||
//#define ILI9488_DRIVER // WARNING: Do not connect ILI9488 display SDO to MISO if other devices share the SPI bus (TFT SDO does NOT tristate when CS is high)
|
||||
//#define ST7789_DRIVER // Define additional parameters below for this display
|
||||
//#define ST7789_DRIVER // Full configuration option, define additional parameters below for this display
|
||||
//#define ST7789_2_DRIVER // Minimal configuration option, define additional parameters below for this display
|
||||
//#define R61581_DRIVER
|
||||
|
||||
// Some displays support SPI reads via the MISO pin, other displays have a single
|
||||
// bi-directional SDA pin and the library will try to read this via the MOSI line.
|
||||
// To use the SDA line for reading data from the TFT uncomment the following line:
|
||||
|
||||
// #define TFT_SDA_READ // This option if for ESP32 ONLY, tested with ST7789 display only
|
||||
// #define TFT_SDA_READ // This option is for ESP32 ONLY, tested with ST7789 display only
|
||||
|
||||
// For ST7789 ONLY, define the colour order IF the blue and red are swapped on your display
|
||||
// Try ONE option at a time to find the correct colour order for your display
|
||||
@ -123,9 +124,9 @@
|
||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR ESP8266 SETUP ######
|
||||
|
||||
// For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation
|
||||
//#define TFT_CS PIN_D8 // Chip select control pin D8
|
||||
//#define TFT_DC PIN_D3 // Data Command control pin
|
||||
//#define TFT_RST PIN_D4 // Reset pin (could connect to NodeMCU RST, see next line)
|
||||
#define TFT_CS PIN_D8 // Chip select control pin D8
|
||||
#define TFT_DC PIN_D3 // Data Command control pin
|
||||
#define TFT_RST PIN_D4 // Reset pin (could connect to NodeMCU RST, see next line)
|
||||
//#define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V
|
||||
|
||||
//#define TFT_BL PIN_D1 // LED back-light (only for ST7789 with backlight control pin)
|
||||
@ -156,17 +157,17 @@
|
||||
// For ESP32 Dev board (only tested with ILI9341 display)
|
||||
// The hardware SPI can be mapped to any pins
|
||||
|
||||
#define TFT_MISO 19
|
||||
#define TFT_MOSI 23
|
||||
#define TFT_SCLK 18
|
||||
#define TFT_CS 15 // Chip select control pin
|
||||
#define TFT_DC 2 // Data Command control pin
|
||||
//#define TFT_MISO 19
|
||||
//#define TFT_MOSI 23
|
||||
//#define TFT_SCLK 18
|
||||
//#define TFT_CS 15 // Chip select control pin
|
||||
//#define TFT_DC 2 // Data Command control pin
|
||||
//#define TFT_RST 4 // Reset pin (could connect to RST pin)
|
||||
#define TFT_RST -1 // Set TFT_RST to -1 if display RESET is connected to ESP32 board RST
|
||||
//#define TFT_RST -1 // Set TFT_RST to -1 if display RESET is connected to ESP32 board RST
|
||||
|
||||
//#define TFT_BL 32 // LED back-light (only for ST7789 with backlight control pin)
|
||||
|
||||
#define TOUCH_CS 21 // Chip select pin (T_CS) of touch screen
|
||||
//#define TOUCH_CS 21 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR 22 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
|
@ -39,13 +39,14 @@
|
||||
//#include <User_Setups/Setup15_HX8357D.h> // Setup file configured for HX8357D (untested)
|
||||
//#include <User_Setups/Setup16_ILI9488_Parallel.h> // Setup file for the ESP32 with parallel bus TFT
|
||||
//#include <User_Setups/Setup17_ePaper.h> // Setup file for any Waveshare ePaper display
|
||||
//#include <User_Setups/Setup18_ST7789.h> // Setup file configured for HX8357D (untested)
|
||||
//#include <User_Setups/Setup18_ST7789.h> // Setup file configured for ST7789
|
||||
|
||||
//#include <User_Setups/Setup20_ILI9488.h> // Setup file for ESP8266 and ILI9488 SPI bus TFT
|
||||
//#include <User_Setups/Setup21_ILI9488.h> // Setup file for ESP32 and ILI9488 SPI bus TFT
|
||||
|
||||
//#include <User_Setups/Setup22_TTGO_T4.h> // Setup file for ESP32 and TTGO T4 (BTC) ILI9341 SPI bus TFT
|
||||
//#include <User_Setups/Setup23_TTGO_TM.h> // Setup file for ESP32 and TTGO TM ST7789 SPI bus TFT
|
||||
//#include <User_Setups/Setup24_ST7789.h> // Setup file configured for ST7789 240 x 240
|
||||
|
||||
//#include <User_Setups/Setup43_ST7735.h> // Setup file configured for my ST7735S 80x160
|
||||
|
||||
@ -106,6 +107,9 @@
|
||||
#elif defined (R61581_DRIVER)
|
||||
#include "TFT_Drivers/R61581_Defines.h"
|
||||
#define TFT_DRIVER 0x6158
|
||||
#elif defined (ST7789_2_DRIVER)
|
||||
#include "TFT_Drivers/ST7789_2_Defines.h"
|
||||
#define TFT_DRIVER 0x778B
|
||||
#elif defined (XYZZY_DRIVER) // <<<<<<<<<<<<<<<<<<<<<<<< ADD NEW DRIVER HERE
|
||||
#include "TFT_Drivers/XYZZY_Defines.h"
|
||||
#define TFT_DRIVER 0x0000
|
||||
|
@ -23,7 +23,7 @@
|
||||
#define SMOOTH_FONT
|
||||
|
||||
|
||||
#define SPI_FREQUENCY 20000000
|
||||
#define SPI_FREQUENCY 16000000
|
||||
|
||||
#define SPI_TOUCH_FREQUENCY 2500000
|
||||
|
||||
|
@ -2,8 +2,17 @@
|
||||
|
||||
#define ST7789_DRIVER
|
||||
|
||||
// #define TFT_SDA_READ // This option is for ESP32 ONLY, tested with ST7789 display only
|
||||
|
||||
#define TFT_SDA_READ
|
||||
// If colours are inverted (white shows as black) then uncomment one of the next
|
||||
// 2 lines try both options, one of the options should correct the inversion.
|
||||
// #define TFT_INVERSION_ON
|
||||
// #define TFT_INVERSION_OFF
|
||||
|
||||
// For ST7789 ONLY, define the colour order IF the blue and red are swapped on your display
|
||||
// Try ONE option at a time to find the correct colour order for your display
|
||||
// #define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue
|
||||
// #define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red
|
||||
|
||||
|
||||
// My ST7789 display has TCT_CS wired permananently low so the pin is not defined here
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#define ILI9488_DRIVER
|
||||
|
||||
//#define TFT_INVERSION_OFF
|
||||
|
||||
#define TFT_MISO 19 // (leave TFT SDO disconnected if other SPI devices share MISO)
|
||||
#define TFT_MOSI 23
|
||||
@ -27,4 +28,7 @@
|
||||
// #define SPI_FREQUENCY 40000000
|
||||
// #define SPI_FREQUENCY 80000000
|
||||
|
||||
// Optional reduced SPI frequency for reading TFT
|
||||
#define SPI_READ_FREQUENCY 16000000
|
||||
|
||||
#define SPI_TOUCH_FREQUENCY 2500000
|
||||
|
53
libraries/TFT_eSPI/User_Setups/Setup24_ST7789.h
Normal file
53
libraries/TFT_eSPI/User_Setups/Setup24_ST7789.h
Normal file
@ -0,0 +1,53 @@
|
||||
// ST7789 240 x 240 display with no chip select line
|
||||
|
||||
#define ST7789_DRIVER // Configure all registers
|
||||
|
||||
#define TFT_WIDTH 240
|
||||
#define TFT_HEIGHT 240
|
||||
|
||||
//#define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue
|
||||
//#define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red
|
||||
|
||||
//#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 19
|
||||
//#define TFT_MOSI 23
|
||||
//#define TFT_SCLK 18
|
||||
//#define TFT_CS -1 // Not connected
|
||||
//#define TFT_DC 2
|
||||
//#define TFT_RST 4 // 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_D3 // Data Command control pin
|
||||
#define TFT_RST PIN_D4 // Reset pin (could connect to NodeMCU RST, see next line)
|
||||
|
||||
|
||||
#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_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
|
||||
#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
|
@ -25,7 +25,8 @@
|
||||
//#define ILI9481_DRIVER
|
||||
//#define ILI9486_DRIVER
|
||||
//#define ILI9488_DRIVER // WARNING: Do not connect ILI9488 display SDO to MISO if other devices share the SPI bus (TFT SDO does NOT tristate when CS is high)
|
||||
//#define ST7789_DRIVER // Define additional parameters below for this display
|
||||
//#define ST7789_DRIVER // Full configuration option, define additional parameters below for this display
|
||||
//#define ST7789_2_DRIVER // Minimal configuration option, define additional parameters below for this display
|
||||
//#define R61581_DRIVER
|
||||
|
||||
// Some displays support SPI reads via the MISO pin, other displays have a single
|
||||
@ -37,8 +38,8 @@
|
||||
// For ST7789 ONLY, define the colour order IF the blue and red are swapped on your display
|
||||
// Try ONE option at a time to find the correct colour order for your display
|
||||
|
||||
// #define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue
|
||||
// #define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red
|
||||
// #define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue
|
||||
// #define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red
|
||||
|
||||
// For M5Stack ESP32 module with integrated ILI9341 display ONLY, remove // in line below
|
||||
|
||||
|
@ -0,0 +1,174 @@
|
||||
/*
|
||||
Sketch to demonstrate using the print class with smooth fonts
|
||||
that are saved onto an SD Card accessed by the SD library.
|
||||
|
||||
For ESP32 only, GPIO 5 must be used for SD chip select.
|
||||
This method of storing the fonts is NOT compatible with the ESP8266.
|
||||
|
||||
Sketch is written for a 240 x 320 display
|
||||
|
||||
Load the font file onto the root directory of the SD Card. The font files
|
||||
used by this sketch can be found in the Data folder, press Ctrl+K to see it.
|
||||
|
||||
The library supports 16 bit unicode characters:
|
||||
https://en.wikipedia.org/wiki/Unicode_font
|
||||
|
||||
The characters supported are in the in the Basic Multilingal Plane:
|
||||
https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_Multilingual_Plane
|
||||
|
||||
Make sure all the display driver and pin connenctions are correct by
|
||||
editting the User_Setup.h file in the TFT_eSPI library folder.
|
||||
|
||||
#########################################################################
|
||||
###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
|
||||
#########################################################################
|
||||
*/
|
||||
|
||||
// Font file is stored on SD card
|
||||
#include <SD.h>
|
||||
|
||||
// Graphics and font library
|
||||
#include <TFT_eSPI.h>
|
||||
#include <SPI.h>
|
||||
|
||||
TFT_eSPI tft = TFT_eSPI(); // Invoke library
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Setup
|
||||
// -------------------------------------------------------------------------
|
||||
void setup(void) {
|
||||
Serial.begin(115200); // Used for messages
|
||||
|
||||
// Initialise the SD library before the TFT so the chip select is defined
|
||||
if (!SD.begin()) {
|
||||
Serial.println("Card Mount Failed");
|
||||
return;
|
||||
}
|
||||
uint8_t cardType = SD.cardType();
|
||||
|
||||
if (cardType == CARD_NONE) {
|
||||
Serial.println("No SD card attached");
|
||||
return;
|
||||
}
|
||||
|
||||
Serial.print("SD Card Type: ");
|
||||
if (cardType == CARD_MMC) {
|
||||
Serial.println("MMC");
|
||||
} else if (cardType == CARD_SD) {
|
||||
Serial.println("SDSC");
|
||||
} else if (cardType == CARD_SDHC) {
|
||||
Serial.println("SDHC");
|
||||
} else {
|
||||
Serial.println("UNKNOWN");
|
||||
}
|
||||
|
||||
uint64_t cardSize = SD.cardSize() / (1024 * 1024);
|
||||
Serial.printf("SD Card Size: %lluMB\n", cardSize);
|
||||
|
||||
// Initialise the TFT after the SD card!
|
||||
tft.init();
|
||||
tft.setRotation(1);
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
listDir(SD, "/", 0);
|
||||
|
||||
Serial.println("SD and TFT initialisation done.");
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Main loop
|
||||
// -------------------------------------------------------------------------
|
||||
void loop() {
|
||||
// Wrap test at right and bottom of screen
|
||||
tft.setTextWrap(true, true);
|
||||
|
||||
// Name of font file (library adds leading / and .vlw)
|
||||
String fileName = "Final-Frontier-28";
|
||||
|
||||
// Font and background colour, background colour is used for anti-alias blending
|
||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
|
||||
// Load the font
|
||||
tft.loadFont(fileName, SD); // Use font stored on SD
|
||||
|
||||
// Display all characters of the font
|
||||
tft.showFont(2000);
|
||||
|
||||
uint32_t dt = millis();
|
||||
|
||||
int count = 100;
|
||||
|
||||
while (count--)
|
||||
{
|
||||
// Set "cursor" at top left corner of display (0,0)
|
||||
// (cursor will move to next line automatically during printing with 'tft.println'
|
||||
// or stay on the line is there is room for the text with tft.print)
|
||||
tft.setCursor(0, 0);
|
||||
|
||||
// Set the font colour to be white with a black background, set text size multiplier to 1
|
||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
|
||||
// We can now plot text on screen using the "print" class
|
||||
tft.println("Hello World!");
|
||||
|
||||
// Set the font colour to be yellow
|
||||
tft.setTextColor(TFT_YELLOW, TFT_BLACK);
|
||||
tft.println(1234.56);
|
||||
|
||||
// Set the font colour to be red
|
||||
tft.setTextColor(TFT_RED, TFT_BLACK);
|
||||
tft.println((uint32_t)3735928559, HEX); // Should print DEADBEEF
|
||||
|
||||
// Set the font colour to be green with black background
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
||||
tft.println("Anti-aliased font!");
|
||||
tft.println("");
|
||||
|
||||
// Test some print formatting functions
|
||||
float fnumber = 123.45;
|
||||
|
||||
// Set the font colour to be blue
|
||||
tft.setTextColor(TFT_BLUE, TFT_BLACK);
|
||||
tft.print("Float = "); tft.println(fnumber); // Print floating point number
|
||||
tft.print("Binary = "); tft.println((int)fnumber, BIN); // Print as integer value in binary
|
||||
tft.print("Hexadecimal = "); tft.println((int)fnumber, HEX); // Print as integer number in Hexadecimal
|
||||
}
|
||||
|
||||
Serial.println(millis()-dt);
|
||||
|
||||
// Unload the font to recover used RAM
|
||||
tft.unloadFont();
|
||||
|
||||
delay(10000);
|
||||
}
|
||||
|
||||
void listDir(fs::FS &fs, const char * dirname, uint8_t levels){
|
||||
Serial.printf("Listing directory: %s\n", dirname);
|
||||
|
||||
File root = fs.open(dirname);
|
||||
if(!root){
|
||||
Serial.println("Failed to open directory");
|
||||
return;
|
||||
}
|
||||
if(!root.isDirectory()){
|
||||
Serial.println("Not a directory");
|
||||
return;
|
||||
}
|
||||
|
||||
File file = root.openNextFile();
|
||||
while(file){
|
||||
if(file.isDirectory()){
|
||||
Serial.print(" DIR : ");
|
||||
Serial.println(file.name());
|
||||
if(levels){
|
||||
listDir(fs, file.name(), levels -1);
|
||||
}
|
||||
} else {
|
||||
Serial.print(" FILE: ");
|
||||
Serial.print(file.name());
|
||||
Serial.print(" SIZE: ");
|
||||
Serial.println(file.size());
|
||||
}
|
||||
file = root.openNextFile();
|
||||
}
|
||||
}
|
Binary file not shown.
@ -78,7 +78,7 @@ void setup(void) {
|
||||
tft.setTextColor(TFT_BLUE, TFT_BLACK);
|
||||
tft.println("Blue text");
|
||||
|
||||
delay(10000);
|
||||
delay(5000);
|
||||
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ void loop() {
|
||||
tft.setTextColor(TFT_BLUE, TFT_BLACK);
|
||||
tft.println("Blue text");
|
||||
|
||||
delay(10000);
|
||||
delay(5000);
|
||||
|
||||
|
||||
// Binary inversion of colours
|
||||
@ -128,5 +128,5 @@ void loop() {
|
||||
tft.setTextColor(TFT_BLUE, TFT_BLACK);
|
||||
tft.println("Blue text");
|
||||
|
||||
delay(10000);
|
||||
delay(5000);
|
||||
}
|
||||
|
@ -149,5 +149,7 @@ int8_t getPinName(int8_t pin)
|
||||
if (pin == 1) return 10;
|
||||
if (pin == 9) return 11;
|
||||
if (pin == 10) return 12;
|
||||
|
||||
return -1; // Invalid pin
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "TFT_eSPI",
|
||||
"version": "1.4.8",
|
||||
"version": "1.4.11",
|
||||
"keywords": "tft, ePaper, display, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486, ST7789",
|
||||
"description": "A TFT and ePaper SPI graphics library for ESP8266 and ESP32",
|
||||
"repository":
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=TFT_eSPI
|
||||
version=1.4.8
|
||||
version=1.4.11
|
||||
author=Bodmer
|
||||
maintainer=Bodmer
|
||||
sentence=A fast TFT graphics library for ESP8266 and ESP32 processors for the Arduino IDE
|
||||
|
57
platformio.ini
Normal file
57
platformio.ini
Normal file
@ -0,0 +1,57 @@
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter
|
||||
; Upload options: custom upload port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
; Advanced options: extra scripting
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[platformio]
|
||||
src_dir = esp3d
|
||||
build_dir = .pioenvs
|
||||
lib_dir = libraries
|
||||
libdeps_dir = .piolibdeps
|
||||
data_dir = esp3d/data
|
||||
|
||||
[env:esp32dev]
|
||||
platform = espressif32
|
||||
;theboard
|
||||
board = esp32dev
|
||||
framework = arduino
|
||||
monitor_speed = 115200
|
||||
; set frequency to 240MHz
|
||||
board_build.f_cpu = 240000000L
|
||||
; set frequency to 80MHz
|
||||
board_build.f_flash = 80000000L
|
||||
board_build.flash_mode = qio
|
||||
; None
|
||||
build_flags = -DCORE_DEBUG_LEVEL=0
|
||||
board_build.partitions = min_spiffs.csv
|
||||
upload_speed = 115200
|
||||
lib_ignore =
|
||||
ESPAsyncTCP
|
||||
|
||||
[env:esp8266]
|
||||
platform = espressif8266
|
||||
board = esp12e
|
||||
framework = arduino
|
||||
monitor_speed = 115200
|
||||
; set frequency to 160MHz
|
||||
board_build.f_cpu = 160000000L
|
||||
; set frequency to 40MHz
|
||||
board_build.f_flash = 40000000L
|
||||
board_build.flash_mode = dio
|
||||
upload_resetmethod = ck
|
||||
build_flags =
|
||||
-Wl,-Teagle.flash.4m2m.ld
|
||||
-D PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
|
||||
-DNONOSDK221=1
|
||||
-DNDEBUG
|
||||
-DVTABLES_IN_FLASH
|
||||
upload_speed = 115200
|
||||
lib_ignore =
|
||||
AsyncTCP
|
||||
ESP32NetBIOS
|
||||
ESP32SSPD
|
Loading…
x
Reference in New Issue
Block a user