commit
9f222ba895
|
|
@ -0,0 +1,76 @@
|
|||
/***************************************************************************************
|
||||
** Code for the GFX button UI element
|
||||
** Grabbed from Adafruit_GFX library and enhanced to handle any label font
|
||||
***************************************************************************************/
|
||||
TFT_eSPI_Button::TFT_eSPI_Button(void) {
|
||||
_gfx = 0;
|
||||
}
|
||||
|
||||
// Classic initButton() function: pass center & size
|
||||
void TFT_eSPI_Button::initButton(
|
||||
TFT_eSPI *gfx, int16_t x, int16_t y, uint16_t w, uint16_t h,
|
||||
uint16_t outline, uint16_t fill, uint16_t textcolor,
|
||||
char *label, uint8_t textsize)
|
||||
{
|
||||
// Tweak arguments and pass to the newer initButtonUL() function...
|
||||
initButtonUL(gfx, x - (w / 2), y - (h / 2), w, h, outline, fill,
|
||||
textcolor, label, textsize);
|
||||
}
|
||||
|
||||
// Newer function instead accepts upper-left corner & size
|
||||
void TFT_eSPI_Button::initButtonUL(
|
||||
TFT_eSPI *gfx, int16_t x1, int16_t y1, uint16_t w, uint16_t h,
|
||||
uint16_t outline, uint16_t fill, uint16_t textcolor,
|
||||
char *label, uint8_t textsize)
|
||||
{
|
||||
_x1 = x1;
|
||||
_y1 = y1;
|
||||
_w = w;
|
||||
_h = h;
|
||||
_outlinecolor = outline;
|
||||
_fillcolor = fill;
|
||||
_textcolor = textcolor;
|
||||
_textsize = textsize;
|
||||
_gfx = gfx;
|
||||
strncpy(_label, label, 9);
|
||||
}
|
||||
|
||||
void TFT_eSPI_Button::drawButton(boolean inverted) {
|
||||
uint16_t fill, outline, text;
|
||||
|
||||
if(!inverted) {
|
||||
fill = _fillcolor;
|
||||
outline = _outlinecolor;
|
||||
text = _textcolor;
|
||||
} else {
|
||||
fill = _textcolor;
|
||||
outline = _outlinecolor;
|
||||
text = _fillcolor;
|
||||
}
|
||||
|
||||
uint8_t r = min(_w, _h) / 4; // Corner radius
|
||||
_gfx->fillRoundRect(_x1, _y1, _w, _h, r, fill);
|
||||
_gfx->drawRoundRect(_x1, _y1, _w, _h, r, outline);
|
||||
|
||||
_gfx->setTextColor(text);
|
||||
_gfx->setTextSize(_textsize);
|
||||
|
||||
uint8_t tempdatum = _gfx->getTextDatum();
|
||||
_gfx->setTextDatum(MC_DATUM);
|
||||
_gfx->drawString(_label, _x1 + (_w/2), _y1 + (_h/2));
|
||||
_gfx->setTextDatum(tempdatum);
|
||||
}
|
||||
|
||||
boolean TFT_eSPI_Button::contains(int16_t x, int16_t y) {
|
||||
return ((x >= _x1) && (x < (_x1 + _w)) &&
|
||||
(y >= _y1) && (y < (_y1 + _h)));
|
||||
}
|
||||
|
||||
void TFT_eSPI_Button::press(boolean p) {
|
||||
laststate = currstate;
|
||||
currstate = p;
|
||||
}
|
||||
|
||||
boolean TFT_eSPI_Button::isPressed() { return currstate; }
|
||||
boolean TFT_eSPI_Button::justPressed() { return (currstate && !laststate); }
|
||||
boolean TFT_eSPI_Button::justReleased() { return (!currstate && laststate); }
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/***************************************************************************************
|
||||
// The following button class has been ported over from the Adafruit_GFX library so
|
||||
// should be compatible.
|
||||
// A slightly different implementation in this TFT_eSPI library allows the button
|
||||
// legends to be in any font
|
||||
***************************************************************************************/
|
||||
|
||||
class TFT_eSPI_Button {
|
||||
|
||||
public:
|
||||
TFT_eSPI_Button(void);
|
||||
// "Classic" initButton() uses center & size
|
||||
void initButton(TFT_eSPI *gfx, int16_t x, int16_t y,
|
||||
uint16_t w, uint16_t h, uint16_t outline, uint16_t fill,
|
||||
uint16_t textcolor, char *label, uint8_t textsize);
|
||||
|
||||
// New/alt initButton() uses upper-left corner & size
|
||||
void initButtonUL(TFT_eSPI *gfx, int16_t x1, int16_t y1,
|
||||
uint16_t w, uint16_t h, uint16_t outline, uint16_t fill,
|
||||
uint16_t textcolor, char *label, uint8_t textsize);
|
||||
void drawButton(boolean inverted = false);
|
||||
boolean contains(int16_t x, int16_t y);
|
||||
|
||||
void press(boolean p);
|
||||
boolean isPressed();
|
||||
boolean justPressed();
|
||||
boolean justReleased();
|
||||
|
||||
private:
|
||||
TFT_eSPI *_gfx;
|
||||
int16_t _x1, _y1; // Coordinates of top-left corner
|
||||
uint16_t _w, _h;
|
||||
uint8_t _textsize;
|
||||
uint16_t _outlinecolor, _fillcolor, _textcolor;
|
||||
char _label[10];
|
||||
|
||||
boolean currstate, laststate;
|
||||
};
|
||||
|
|
@ -0,0 +1,520 @@
|
|||
// Coded by Bodmer 10/2/18, see license in root directory.
|
||||
// This is part of the TFT_eSPI class and is associated with anti-aliased font functions
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
// New anti-aliased (smoothed) font functions added below
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/***************************************************************************************
|
||||
** Function name: loadFont
|
||||
** Description: loads parameters from a new font vlw file stored in SPIFFS
|
||||
*************************************************************************************x*/
|
||||
void TFT_eSPI::loadFont(String fontName)
|
||||
{
|
||||
/*
|
||||
The vlw font format does not appear to be documented anywhere, so some reverse
|
||||
engineering has been applied!
|
||||
|
||||
Header of vlw file comprises 6 uint32_t parameters (24 bytes total):
|
||||
1. The gCount (number of character glyphs)
|
||||
2. A version number (0xB = 11 for the one I am using)
|
||||
3. The font size (in points, not pixels)
|
||||
4. Deprecated mboxY parameter (typically set to 0)
|
||||
5. Ascent in pixels from baseline to top of "d"
|
||||
6. Descent in pixels from baseline to bottom of "p"
|
||||
|
||||
Next are gCount sets of values for each glyph, each set comprises 7 int32t parameters (28 bytes):
|
||||
1. Glyph Unicode stored as a 32 bit value
|
||||
2. Height of bitmap bounding box
|
||||
3. Width of bitmap bounding box
|
||||
4. gxAdvance for cursor (setWidth in Processing)
|
||||
5. dY = distance from cursor baseline to top of glyph bitmap (signed value +ve = up)
|
||||
6. dX = distance from cursor to left side of glyph bitmap (signed value -ve = left)
|
||||
7. padding value, typically 0
|
||||
|
||||
The bitmaps start next at 24 + (28 * gCount) bytes from the start of the file.
|
||||
Each pixel is 1 byte, an 8 bit Alpha value which represents the transparency from
|
||||
0xFF foreground colour, 0x00 background. The sketch uses a linear interpolation
|
||||
between the foreground and background RGB component colours. e.g.
|
||||
pixelRed = ((fgRed * alpha) + (bgRed * (255 - alpha))/255
|
||||
To gain a performance advantage fixed point arithmetic is used with rounding and
|
||||
division by 256 (shift right 8 bits is faster).
|
||||
|
||||
After the bitmaps is:
|
||||
1 byte for font name string length (excludes null)
|
||||
a zero terminated character string giving the font name
|
||||
1 byte for Postscript name string length
|
||||
a zero/one terminated character string giving the font name
|
||||
last byte is 0 for non-anti-aliased and 1 for anti-aliased (smoothed)
|
||||
|
||||
Then the font name seen by Java when it's created
|
||||
Then the postscript name of the font
|
||||
Then a boolean to tell if smoothing is on or not.
|
||||
|
||||
Glyph bitmap example is:
|
||||
// Cursor coordinate positions for this and next character are marked by 'C'
|
||||
// C<------- gxAdvance ------->C gxAdvance is how far to move cursor for next glyph cursor position
|
||||
// | |
|
||||
// | | ascent is top of "d", descent is bottom of "p"
|
||||
// +-- gdX --+ ascent
|
||||
// | +-- gWidth--+ | gdX is offset to left edge of glyph bitmap
|
||||
// | + x@.........@x + | gdX may be negative e.g. italic "y" tail extending to left of
|
||||
// | | @@.........@@ | | cursor position, plot top left corner of bitmap at (cursorX + gdX)
|
||||
// | | @@.........@@ gdY | gWidth and gHeight are glyph bitmap dimensions
|
||||
// | | .@@@.....@@@@ | |
|
||||
// | gHeight ....@@@@@..@@ + + <-- baseline
|
||||
// | | ...........@@ |
|
||||
// | | ...........@@ | gdY is the offset to the top edge of the bitmap
|
||||
// | | .@@.......@@. descent plot top edge of bitmap at (cursorY + yAdvance - gdY)
|
||||
// | + x..@@@@@@@..x | x marks the corner pixels of the bitmap
|
||||
// | |
|
||||
// +---------------------------+ yAdvance is y delta for the next line, font size or (ascent + descent)
|
||||
// some fonts can overlay in y direction so may need a user adjust value
|
||||
|
||||
*/
|
||||
|
||||
unloadFont();
|
||||
|
||||
_gFontFilename = "/" + fontName + ".vlw";
|
||||
|
||||
fontFile = SPIFFS.open( _gFontFilename, "r");
|
||||
|
||||
if(!fontFile) return;
|
||||
|
||||
fontFile.seek(0, fs::SeekSet);
|
||||
|
||||
gFont.gCount = (uint16_t)readInt32(); // glyph count in file
|
||||
readInt32(); // vlw encoder version - discard
|
||||
gFont.yAdvance = (uint16_t)readInt32(); // Font size in points, not pixels
|
||||
readInt32(); // discard
|
||||
gFont.ascent = (uint16_t)readInt32(); // top of "d"
|
||||
gFont.descent = (uint16_t)readInt32(); // bottom of "p"
|
||||
|
||||
// These next gFont values will be updated when the Metrics are fetched
|
||||
gFont.maxAscent = gFont.ascent; // Determined from metrics
|
||||
gFont.maxDescent = gFont.descent; // Determined from metrics
|
||||
gFont.yAdvance = gFont.ascent + gFont.descent;
|
||||
gFont.spaceWidth = gFont.yAdvance / 4; // Guess at space width
|
||||
|
||||
fontLoaded = true;
|
||||
|
||||
// Fetch the metrics for each glyph
|
||||
loadMetrics(gFont.gCount);
|
||||
|
||||
//fontFile.close();
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************************
|
||||
** Function name: loadMetrics
|
||||
** Description: Get the metrics for each glyph and store in RAM
|
||||
*************************************************************************************x*/
|
||||
//#define SHOW_ASCENT_DESCENT
|
||||
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 = (int8_t*)malloc( gCount ); // 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
|
||||
|
||||
#ifdef SHOW_ASCENT_DESCENT
|
||||
Serial.print("ascent = "); Serial.println(gFont.ascent);
|
||||
Serial.print("descent = "); Serial.println(gFont.descent);
|
||||
#endif
|
||||
|
||||
uint16_t gNum = 0;
|
||||
fontFile.seek(headerPtr, fs::SeekSet);
|
||||
while (gNum < gCount)
|
||||
{
|
||||
gUnicode[gNum] = (uint16_t)readInt32(); // Unicode code point value
|
||||
gHeight[gNum] = (uint8_t)readInt32(); // Height of glyph
|
||||
gWidth[gNum] = (uint8_t)readInt32(); // Width of glyph
|
||||
gxAdvance[gNum] = (uint8_t)readInt32(); // xAdvance - to move x cursor
|
||||
gdY[gNum] = (int8_t)readInt32(); // y delta from baseline
|
||||
gdX[gNum] = (int8_t)readInt32(); // x delta from cursor
|
||||
readInt32(); // ignored
|
||||
|
||||
// Different glyph sets have different ascent values not always based on "d", so get maximum glyph ascent
|
||||
if (gdY[gNum] > gFont.maxAscent)
|
||||
{
|
||||
// Avoid UTF coding values and characters that tend to give duff values
|
||||
if (((gUnicode[gNum] > 0x20) && (gUnicode[gNum] < 0xA0) && (gUnicode[gNum] != 0x7F)) || (gUnicode[gNum] > 0xFF))
|
||||
{
|
||||
gFont.maxAscent = gdY[gNum];
|
||||
#ifdef SHOW_ASCENT_DESCENT
|
||||
Serial.print("Unicode = 0x"); Serial.print(gUnicode[gNum], HEX); Serial.print(", maxAscent = "); Serial.println(gFont.maxAscent);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// Different glyph sets have different descent values not always based on "p", so get maximum glyph descent
|
||||
if (((int16_t)gHeight[gNum] - (int16_t)gdY[gNum]) > gFont.maxDescent)
|
||||
{
|
||||
// Avoid UTF coding values and characters that tend to give duff values
|
||||
if (((gUnicode[gNum] > 0x20) && (gUnicode[gNum] < 0xA0) && (gUnicode[gNum] != 0x7F)) || (gUnicode[gNum] > 0xFF))
|
||||
{
|
||||
gFont.maxDescent = gHeight[gNum] - gdY[gNum];
|
||||
#ifdef SHOW_ASCENT_DESCENT
|
||||
Serial.print("Unicode = 0x"); Serial.print(gUnicode[gNum], HEX); Serial.print(", maxDescent = "); Serial.println(gHeight[gNum] - gdY[gNum]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
gBitmap[gNum] = bitmapPtr;
|
||||
|
||||
headerPtr += 28;
|
||||
|
||||
bitmapPtr += gWidth[gNum] * gHeight[gNum];
|
||||
|
||||
gNum++;
|
||||
yield();
|
||||
}
|
||||
|
||||
gFont.yAdvance = gFont.maxAscent + gFont.maxDescent;
|
||||
|
||||
gFont.spaceWidth = (gFont.ascent + gFont.descent) * 2/7; // Guess at space width
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************************
|
||||
** Function name: deleteMetrics
|
||||
** Description: Delete the old glyph metrics and free up the memory
|
||||
*************************************************************************************x*/
|
||||
void TFT_eSPI::unloadFont( void )
|
||||
{
|
||||
if (gUnicode)
|
||||
{
|
||||
free(gUnicode);
|
||||
gUnicode = NULL;
|
||||
}
|
||||
|
||||
if (gHeight)
|
||||
{
|
||||
free(gHeight);
|
||||
gHeight = NULL;
|
||||
}
|
||||
|
||||
if (gWidth)
|
||||
{
|
||||
free(gWidth);
|
||||
gWidth = NULL;
|
||||
}
|
||||
|
||||
if (gxAdvance)
|
||||
{
|
||||
free(gxAdvance);
|
||||
gxAdvance = NULL;
|
||||
}
|
||||
|
||||
if (gdY)
|
||||
{
|
||||
free(gdY);
|
||||
gdY = NULL;
|
||||
}
|
||||
|
||||
if (gdX)
|
||||
{
|
||||
free(gdX);
|
||||
gdX = NULL;
|
||||
}
|
||||
|
||||
if (gBitmap)
|
||||
{
|
||||
free(gBitmap);
|
||||
gBitmap = NULL;
|
||||
}
|
||||
|
||||
if(fontFile) fontFile.close();
|
||||
fontLoaded = false;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************************
|
||||
** Function name: decodeUTF8
|
||||
** Description: Line buffer UTF-8 decoder with fall-back to extended ASCII
|
||||
*************************************************************************************x*/
|
||||
#define DECODE_UTF8
|
||||
uint16_t TFT_eSPI::decodeUTF8(uint8_t *buf, uint16_t *index, uint16_t remaining)
|
||||
{
|
||||
byte c = buf[(*index)++];
|
||||
//Serial.print("Byte from string = 0x"); Serial.println(c, HEX);
|
||||
|
||||
#ifdef DECODE_UTF8
|
||||
// 7 bit Unicode
|
||||
if ((c & 0x80) == 0x00) return c;
|
||||
|
||||
// 11 bit Unicode
|
||||
if (((c & 0xE0) == 0xC0) && (remaining > 1))
|
||||
return ((c & 0x1F)<<6) | (buf[(*index)++]&0x3F);
|
||||
|
||||
// 16 bit Unicode
|
||||
if (((c & 0xF0) == 0xE0) && (remaining > 2))
|
||||
return ((c & 0x0F)<<12) | ((buf[(*index)++]&0x3F)<<6) | ((buf[(*index)++]&0x3F));
|
||||
|
||||
// 21 bit Unicode not supported so fall-back to extended ASCII
|
||||
// if ((c & 0xF8) == 0xF0) return c;
|
||||
#endif
|
||||
|
||||
return c; // fall-back to extended ASCII
|
||||
}
|
||||
|
||||
/***************************************************************************************
|
||||
** Function name: decodeUTF8
|
||||
** Description: Serial UTF-8 decoder with fall-back to extended ASCII
|
||||
*************************************************************************************x*/
|
||||
uint16_t TFT_eSPI::decodeUTF8(uint8_t c)
|
||||
{
|
||||
|
||||
#ifdef DECODE_UTF8
|
||||
if (decoderState == 0)
|
||||
{
|
||||
// 7 bit Unicode
|
||||
if ((c & 0x80) == 0x00) return (uint16_t)c;
|
||||
|
||||
// 11 bit Unicode
|
||||
if ((c & 0xE0) == 0xC0)
|
||||
{
|
||||
decoderBuffer = ((c & 0x1F)<<6);
|
||||
decoderState = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 16 bit Unicode
|
||||
if ((c & 0xF0) == 0xE0)
|
||||
{
|
||||
decoderBuffer = ((c & 0x0F)<<12);
|
||||
decoderState = 2;
|
||||
return 0;
|
||||
}
|
||||
// 21 bit Unicode not supported so fall-back to extended ASCII
|
||||
if ((c & 0xF8) == 0xF0) return (uint16_t)c;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (decoderState == 2)
|
||||
{
|
||||
decoderBuffer |= ((c & 0x3F)<<6);
|
||||
decoderState--;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
decoderBuffer |= (c & 0x3F);
|
||||
decoderState = 0;
|
||||
return decoderBuffer;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return (uint16_t)c; // fall-back to extended ASCII
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************************
|
||||
** Function name: alphaBlend
|
||||
** Description: Blend foreground and background and return new colour
|
||||
*************************************************************************************x*/
|
||||
uint16_t TFT_eSPI::alphaBlend(uint8_t alpha, uint16_t fgc, uint16_t bgc)
|
||||
{
|
||||
// For speed use fixed point maths and rounding to permit a power of 2 division
|
||||
uint16_t fgR = ((fgc >> 10) & 0x3E) + 1;
|
||||
uint16_t fgG = ((fgc >> 4) & 0x7E) + 1;
|
||||
uint16_t fgB = ((fgc << 1) & 0x3E) + 1;
|
||||
|
||||
uint16_t bgR = ((bgc >> 10) & 0x3E) + 1;
|
||||
uint16_t bgG = ((bgc >> 4) & 0x7E) + 1;
|
||||
uint16_t bgB = ((bgc << 1) & 0x3E) + 1;
|
||||
|
||||
// Shift right 1 to drop rounding bit and shift right 8 to divide by 256
|
||||
uint16_t r = (((fgR * alpha) + (bgR * (255 - alpha))) >> 9);
|
||||
uint16_t g = (((fgG * alpha) + (bgG * (255 - alpha))) >> 9);
|
||||
uint16_t b = (((fgB * alpha) + (bgB * (255 - alpha))) >> 9);
|
||||
|
||||
// Combine RGB565 colours into 16 bits
|
||||
//return ((r&0x18) << 11) | ((g&0x30) << 5) | ((b&0x18) << 0); // 2 bit greyscale
|
||||
//return ((r&0x1E) << 11) | ((g&0x3C) << 5) | ((b&0x1E) << 0); // 4 bit greyscale
|
||||
return (r << 11) | (g << 5) | (b << 0);
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************************
|
||||
** Function name: readInt32
|
||||
** Description: Get a 32 bit integer from the font file
|
||||
*************************************************************************************x*/
|
||||
uint32_t TFT_eSPI::readInt32(void)
|
||||
{
|
||||
uint32_t val = 0;
|
||||
val |= fontFile.read() << 24;
|
||||
val |= fontFile.read() << 16;
|
||||
val |= fontFile.read() << 8;
|
||||
val |= fontFile.read();
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************************
|
||||
** Function name: getUnicodeIndex
|
||||
** Description: Get the font file index of a Unicode character
|
||||
*************************************************************************************x*/
|
||||
bool TFT_eSPI::getUnicodeIndex(uint16_t unicode, uint16_t *index)
|
||||
{
|
||||
for (uint16_t i = 0; i < gFont.gCount; i++)
|
||||
{
|
||||
if (gUnicode[i] == unicode)
|
||||
{
|
||||
*index = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************************
|
||||
** Function name: drawGlyph
|
||||
** Description: Write a character to the TFT cursor position
|
||||
*************************************************************************************x*/
|
||||
// Expects file to be open
|
||||
void TFT_eSPI::drawGlyph(uint16_t code)
|
||||
{
|
||||
if (code < 0x21)
|
||||
{
|
||||
if (code == 0x20) {
|
||||
cursor_x += gFont.spaceWidth;
|
||||
return;
|
||||
}
|
||||
|
||||
if (code == '\n') {
|
||||
cursor_x = 0;
|
||||
cursor_y += gFont.yAdvance;
|
||||
if (cursor_y >= _height) cursor_y = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t gNum = 0;
|
||||
bool found = getUnicodeIndex(code, &gNum);
|
||||
|
||||
uint16_t fg = textcolor;
|
||||
uint16_t bg = textbgcolor;
|
||||
|
||||
if (found)
|
||||
{
|
||||
|
||||
if (textwrapX && (cursor_x + gWidth[gNum] + gdX[gNum] > _width))
|
||||
{
|
||||
cursor_y += gFont.yAdvance;
|
||||
cursor_x = 0;
|
||||
}
|
||||
if (textwrapY && ((cursor_y + gFont.yAdvance) >= _height)) cursor_y = 0;
|
||||
if (cursor_x == 0) cursor_x -= gdX[gNum];
|
||||
|
||||
fontFile.seek(gBitmap[gNum], fs::SeekSet); // This is taking >30ms for a significant position shift
|
||||
|
||||
uint8_t pbuffer[gWidth[gNum]];
|
||||
|
||||
uint16_t xs = 0;
|
||||
uint32_t dl = 0;
|
||||
|
||||
int16_t cy = cursor_y + gFont.maxAscent - gdY[gNum];
|
||||
int16_t cx = cursor_x + gdX[gNum];
|
||||
|
||||
for (int y = 0; y < gHeight[gNum]; y++)
|
||||
{
|
||||
fontFile.read(pbuffer, gWidth[gNum]); //<//
|
||||
for (int x = 0; x < gWidth[gNum]; x++)
|
||||
{
|
||||
uint8_t pixel = pbuffer[x]; //<//
|
||||
if (pixel)
|
||||
{
|
||||
if (pixel != 0xFF)
|
||||
{
|
||||
if (dl) {
|
||||
if (dl==1) drawPixel(xs, y + cy, fg);
|
||||
else drawFastHLine( xs, y + cy, dl, fg);
|
||||
dl = 0;
|
||||
}
|
||||
drawPixel(x + cx, y + cy, alphaBlend(pixel, fg, bg));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dl==0) xs = x + cx;
|
||||
dl++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dl) { drawFastHLine( xs, y + cy, dl, fg); dl = 0; }
|
||||
}
|
||||
}
|
||||
if (dl) { drawFastHLine( xs, y + cy, dl, fg); dl = 0; }
|
||||
}
|
||||
|
||||
cursor_x += gxAdvance[gNum];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not a Unicode in font so draw a rectangle and move on cursor
|
||||
drawRect(cursor_x, cursor_y + gFont.maxAscent - gFont.ascent, gFont.spaceWidth, gFont.ascent, fg);
|
||||
cursor_x += gFont.spaceWidth + 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/***************************************************************************************
|
||||
** Function name: showFont
|
||||
** Description: Page through all characters in font, td ms between screens
|
||||
*************************************************************************************x*/
|
||||
void TFT_eSPI::showFont(uint32_t td)
|
||||
{
|
||||
if(!fontLoaded) return;
|
||||
// fontFile = SPIFFS.open( _gFontFilename, "r" );
|
||||
|
||||
if(!fontFile)
|
||||
{
|
||||
fontLoaded = false;
|
||||
return;
|
||||
}
|
||||
|
||||
int16_t cursorX = width(); // Force start of new page to initialise cursor
|
||||
int16_t cursorY = height();// for the first character
|
||||
uint32_t timeDelay = 0; // No delay before first page
|
||||
|
||||
fillScreen(textbgcolor);
|
||||
|
||||
for (uint16_t i = 0; i < gFont.gCount; i++)
|
||||
{
|
||||
// Check if this will need a new screen
|
||||
if (cursorX + gdX[i] + gWidth[i] >= width()) {
|
||||
cursorX = -gdX[i];
|
||||
|
||||
cursorY += gFont.yAdvance;
|
||||
if (cursorY + gFont.maxAscent + gFont.descent >= height()) {
|
||||
cursorX = -gdX[i];
|
||||
cursorY = 0;
|
||||
delay(timeDelay);
|
||||
timeDelay = td;
|
||||
fillScreen(textbgcolor);
|
||||
}
|
||||
}
|
||||
|
||||
setCursor(cursorX, cursorY);
|
||||
drawGlyph(gUnicode[i]);
|
||||
cursorX += gxAdvance[i];
|
||||
//cursorX += printToSprite( cursorX, cursorY, i );
|
||||
yield();
|
||||
}
|
||||
|
||||
delay(timeDelay);
|
||||
fillScreen(textbgcolor);
|
||||
//fontFile.close();
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
// Coded by Bodmer 10/2/18, see license in root directory.
|
||||
// This is part of the TFT_eSPI class and is associated with anti-aliased font functions
|
||||
|
||||
public:
|
||||
|
||||
// These are for the new antialiased fonts
|
||||
void loadFont(String fontName);
|
||||
void unloadFont( void );
|
||||
bool getUnicodeIndex(uint16_t unicode, uint16_t *index);
|
||||
|
||||
uint16_t decodeUTF8(uint8_t *buf, uint16_t *index, uint16_t remaining);
|
||||
uint16_t decodeUTF8(uint8_t c);
|
||||
|
||||
uint16_t alphaBlend(uint8_t alpha, uint16_t fgc, uint16_t bgc);
|
||||
|
||||
void drawGlyph(uint16_t code);
|
||||
void showFont(uint32_t td);
|
||||
|
||||
fs::File fontFile;
|
||||
|
||||
// This is for the whole font
|
||||
typedef struct
|
||||
{
|
||||
uint16_t gCount; // Total number of characters
|
||||
uint16_t yAdvance; // Line advance
|
||||
uint16_t spaceWidth; // Width of a space character
|
||||
int16_t ascent; // Height of top of 'd' above baseline, other characters may be taller
|
||||
int16_t descent; // Offset to bottom of 'p', other characters may have a larger descent
|
||||
uint16_t maxAscent; // Maximum ascent found in font
|
||||
uint16_t maxDescent; // Maximum descent found in font
|
||||
} fontMetrics;
|
||||
|
||||
fontMetrics gFont = { 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
// These are for the metrics for each individual glyph (so we don't need to seek this in file and waste time)
|
||||
uint16_t* gUnicode = NULL; //UTF-16 code, the codes are searched so do not need to be sequential
|
||||
uint8_t* gHeight = NULL; //cheight
|
||||
uint8_t* gWidth = NULL; //cwidth
|
||||
uint8_t* gxAdvance = NULL; //setWidth
|
||||
int8_t* gdY = NULL; //topExtent
|
||||
int8_t* gdX = NULL; //leftExtent
|
||||
uint32_t* gBitmap = NULL; //file pointer to greyscale bitmap
|
||||
|
||||
String _gFontFilename;
|
||||
|
||||
uint8_t decoderState = 0; // UTF8 decoder state
|
||||
uint16_t decoderBuffer; // Unicode code-point buffer
|
||||
|
||||
bool fontLoaded = false; // Flags when a anti-aliased font is loaded
|
||||
|
||||
private:
|
||||
|
||||
void loadMetrics(uint16_t gCount);
|
||||
uint32_t readInt32(void);
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,125 @@
|
|||
/***************************************************************************************
|
||||
// The following class creates Sprites in RAM, graphics can then be drawn in the Sprite
|
||||
// and rendered quickly onto the TFT screen. The class inherits the graphics functions
|
||||
// from the TFT_eSPI class. Some functions are overridden by this class so that the
|
||||
// graphics are written to the Sprite rather than the TFT.
|
||||
***************************************************************************************/
|
||||
|
||||
class TFT_eSprite : public TFT_eSPI {
|
||||
|
||||
public:
|
||||
|
||||
TFT_eSprite(TFT_eSPI *tft);
|
||||
|
||||
// Create a sprite of width x height pixels, return a pointer to the RAM area
|
||||
// Sketch can cast returned value to (uint16_t*) for 16 bit depth if needed
|
||||
// RAM required is 1 byte per pixel for 8 bit colour depth, 2 bytes for 16 bit
|
||||
void* createSprite(int16_t width, int16_t height, uint8_t frames = 1);
|
||||
|
||||
// Delete the sprite to free up the RAM
|
||||
void deleteSprite(void);
|
||||
|
||||
// Select the frame buffer for graphics
|
||||
void* frameBuffer(int8_t f);
|
||||
|
||||
// Set the colour depth to 8 or 16 bits. Can be used to change depth an existing
|
||||
// sprite, but clears it to black, returns a new pointer if sprite is re-created.
|
||||
void* setColorDepth(int8_t b);
|
||||
|
||||
void setBitmapColor(uint16_t c, uint16_t b);
|
||||
|
||||
void drawPixel(uint32_t x, uint32_t y, uint32_t color);
|
||||
|
||||
void drawChar(int32_t x, int32_t y, unsigned char c, uint32_t color, uint32_t bg, uint8_t size),
|
||||
|
||||
fillSprite(uint32_t color),
|
||||
|
||||
// Define a window to push 16 bit colour pixels into is a raster order
|
||||
// Colours are converted to 8 bit if depth is set to 8
|
||||
setWindow(int32_t x0, int32_t y0, int32_t x1, int32_t y1),
|
||||
pushColor(uint32_t color),
|
||||
pushColor(uint32_t color, uint16_t len),
|
||||
// Push a pixel preformatted as a 8 or 16 bit colour (avoids conversion overhead)
|
||||
writeColor(uint16_t color),
|
||||
|
||||
// Set the scroll zone, top left corner at x,y with defined width and height
|
||||
// The colour (optional, black is default) is used to fill the gap after the scroll
|
||||
setScrollRect(int32_t x, int32_t y, uint32_t w, uint32_t h, uint16_t color = TFT_BLACK),
|
||||
// Scroll the defined zone dx,dy pixels. Negative values left,up, positive right,down
|
||||
// dy is optional (default is then no up/down scroll).
|
||||
// The sprite coordinate frame does not move because pixels are moved
|
||||
scroll(int16_t dx, int16_t dy = 0),
|
||||
|
||||
drawLine(int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint32_t color),
|
||||
drawFastVLine(int32_t x, int32_t y, int32_t h, uint32_t color),
|
||||
drawFastHLine(int32_t x, int32_t y, int32_t w, uint32_t color),
|
||||
|
||||
fillRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color);
|
||||
|
||||
// Set the sprite text cursor position for print class (does not change the TFT screen cursor)
|
||||
//setCursor(int16_t x, int16_t y);
|
||||
|
||||
void setRotation(uint8_t rotation);
|
||||
uint8_t getRotation(void);
|
||||
|
||||
// Read the colour of a pixel at x,y and return value in 565 format
|
||||
uint16_t readPixel(int32_t x0, int32_t y0);
|
||||
|
||||
// Write an image (colour bitmap) to the sprite
|
||||
void pushImage(int32_t x0, int32_t y0, uint32_t w, uint32_t h, uint16_t *data);
|
||||
void pushImage(int32_t x0, int32_t y0, uint32_t w, uint32_t h, const uint16_t *data);
|
||||
|
||||
// Swap the byte order for pushImage() - corrects different image endianness
|
||||
void setSwapBytes(bool swap);
|
||||
bool getSwapBytes(void);
|
||||
|
||||
// Push the sprite to the TFT screen, this fn calls pushImage() in the TFT class.
|
||||
// Optionally a "transparent" colour can be defined, pixels of that colour will not be rendered
|
||||
void pushSprite(int32_t x, int32_t y);
|
||||
void pushSprite(int32_t x, int32_t y, uint16_t transparent);
|
||||
|
||||
int16_t drawChar(unsigned int uniCode, int x, int y, int font),
|
||||
drawChar(unsigned int uniCode, int x, int y);
|
||||
|
||||
// Return the width and height of the sprite
|
||||
int16_t width(void),
|
||||
height(void);
|
||||
|
||||
// Used by print class to print text to cursor position
|
||||
size_t write(uint8_t);
|
||||
|
||||
// Functions associated with anti-aliased fonts
|
||||
void drawGlyph(uint16_t code);
|
||||
void printToSprite(String string);
|
||||
void printToSprite(char *cbuffer, int len);
|
||||
int16_t printToSprite(int16_t x, int16_t y, uint16_t index);
|
||||
|
||||
private:
|
||||
|
||||
TFT_eSPI *_tft;
|
||||
|
||||
protected:
|
||||
|
||||
uint8_t _bpp;
|
||||
uint16_t *_img; // pointer to 16 bit sprite
|
||||
uint8_t *_img8; // pointer to 8 bit sprite
|
||||
uint8_t *_img8_1; // pointer to frame 1
|
||||
uint8_t *_img8_2; // pointer to frame 2
|
||||
|
||||
bool _created; // created and bits per pixel depth flags
|
||||
bool _gFont = false;
|
||||
|
||||
// int32_t _icursor_x, _icursor_y;
|
||||
uint8_t _rotation = 0;
|
||||
int32_t _xs, _ys, _xe, _ye, _xptr, _yptr; // for setWindow
|
||||
int32_t _sx, _sy; // x,y for scroll zone
|
||||
uint32_t _sw, _sh; // w,h for scroll zone
|
||||
uint32_t _scolor; // gap fill colour for scroll zone
|
||||
|
||||
boolean _iswapBytes; // Swap the byte order for Sprite pushImage()
|
||||
|
||||
int32_t _iwidth, _iheight; // Sprite memory image bit width and height (swapped during rotations)
|
||||
int32_t _dwidth, _dheight; // Real display width and height (for <8bpp Sprites)
|
||||
int32_t _bitwidth; // Sprite image bit width for drawPixel (for <8bpp Sprites, not swapped)
|
||||
|
||||
};
|
||||
|
|
@ -0,0 +1,289 @@
|
|||
// The following touch screen support code by maxpautsch was merged 1/10/17
|
||||
// https://github.com/maxpautsch
|
||||
|
||||
// Define TOUCH_CS is the user setup file to enable this code
|
||||
|
||||
// A demo is provided in examples Generic folder
|
||||
|
||||
// Additions by Bodmer to double sample, use Z value to improve detection reliability
|
||||
// and to correct rotation handling
|
||||
|
||||
// See license in root directory.
|
||||
|
||||
/***************************************************************************************
|
||||
** Function name: getTouchRaw
|
||||
** Description: read raw touch position. Return false if not pressed.
|
||||
***************************************************************************************/
|
||||
uint8_t TFT_eSPI::getTouchRaw(uint16_t *x, uint16_t *y){
|
||||
uint16_t tmp;
|
||||
CS_H;
|
||||
|
||||
spi_begin_touch();
|
||||
|
||||
T_CS_L;
|
||||
|
||||
// Start bit + YP sample request for x position
|
||||
tmp = SPI.transfer(0xd0);
|
||||
tmp = SPI.transfer(0);
|
||||
tmp = tmp <<5;
|
||||
tmp |= 0x1f & (SPI.transfer(0)>>3);
|
||||
|
||||
*x = tmp;
|
||||
|
||||
// Start bit + XP sample request for y position
|
||||
SPI.transfer(0x90);
|
||||
tmp = SPI.transfer(0);
|
||||
tmp = tmp <<5;
|
||||
tmp |= 0x1f & (SPI.transfer(0)>>3);
|
||||
|
||||
*y = tmp;
|
||||
|
||||
T_CS_H;
|
||||
|
||||
spi_end_touch();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/***************************************************************************************
|
||||
** Function name: getTouchRawZ
|
||||
** Description: read raw pressure on touchpad and return Z value.
|
||||
***************************************************************************************/
|
||||
uint16_t TFT_eSPI::getTouchRawZ(void){
|
||||
CS_H;
|
||||
|
||||
spi_begin_touch();
|
||||
|
||||
T_CS_L;
|
||||
|
||||
// Z sample request
|
||||
int16_t tz = 0xFFF;
|
||||
SPI.transfer(0xb1);
|
||||
tz += SPI.transfer16(0xc1) >> 3;
|
||||
tz -= SPI.transfer16(0x91) >> 3;
|
||||
|
||||
T_CS_H;
|
||||
|
||||
spi_end_touch();
|
||||
|
||||
return (uint16_t)tz;
|
||||
}
|
||||
|
||||
/***************************************************************************************
|
||||
** Function name: validTouch
|
||||
** Description: read validated position. Return false if not pressed.
|
||||
***************************************************************************************/
|
||||
#define _RAWERR 10 // Deadband in position samples
|
||||
uint8_t TFT_eSPI::validTouch(uint16_t *x, uint16_t *y, uint16_t threshold){
|
||||
uint16_t x_tmp, y_tmp, x_tmp2, y_tmp2;
|
||||
|
||||
// Wait until pressure stops increasing
|
||||
uint16_t z1 = 1;
|
||||
uint16_t z2 = 0;
|
||||
while (z1 > z2)
|
||||
{
|
||||
z2 = z1;
|
||||
z1 = getTouchRawZ();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
// Serial.print("Z = ");Serial.println(z1);
|
||||
|
||||
if (z1 <= threshold) return false;
|
||||
|
||||
getTouchRaw(&x_tmp,&y_tmp);
|
||||
|
||||
// Serial.print("Sample 1 x,y = "); Serial.print(x_tmp);Serial.print(",");Serial.print(y_tmp);
|
||||
// Serial.print(", Z = ");Serial.println(z1);
|
||||
|
||||
delay(1); // Small delay to the next sample
|
||||
if (getTouchRawZ() <= threshold) return false;
|
||||
|
||||
delay(2); // Small delay to the next sample
|
||||
getTouchRaw(&x_tmp2,&y_tmp2);
|
||||
|
||||
// Serial.print("Sample 2 x,y = "); Serial.print(x_tmp2);Serial.print(",");Serial.println(y_tmp2);
|
||||
// Serial.print("Sample difference = ");Serial.print(abs(x_tmp - x_tmp2));Serial.print(",");Serial.println(abs(y_tmp - y_tmp2));
|
||||
|
||||
if (abs(x_tmp - x_tmp2) > _RAWERR) return false;
|
||||
if (abs(y_tmp - y_tmp2) > _RAWERR) return false;
|
||||
|
||||
*x = x_tmp;
|
||||
*y = y_tmp;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/***************************************************************************************
|
||||
** Function name: getTouch
|
||||
** Description: read callibrated position. Return false if not pressed.
|
||||
***************************************************************************************/
|
||||
#define Z_THRESHOLD 350 // Touch pressure threshold for validating touches
|
||||
uint8_t TFT_eSPI::getTouch(uint16_t *x, uint16_t *y, uint16_t threshold){
|
||||
uint16_t x_tmp, y_tmp, xx, yy;
|
||||
|
||||
if (threshold<20) threshold = 20;
|
||||
if (_pressTime > millis()) threshold=20;
|
||||
|
||||
uint8_t n = 5;
|
||||
uint8_t valid = 0;
|
||||
while (n--)
|
||||
{
|
||||
if (validTouch(&x_tmp, &y_tmp, threshold)) valid++;;
|
||||
}
|
||||
|
||||
if (valid<1) { _pressTime = 0; return false; }
|
||||
|
||||
_pressTime = millis() + 50;
|
||||
|
||||
if(!touchCalibration_rotate){
|
||||
xx=(x_tmp-touchCalibration_x0)*_width/touchCalibration_x1;
|
||||
yy=(y_tmp-touchCalibration_y0)*_height/touchCalibration_y1;
|
||||
if(touchCalibration_invert_x)
|
||||
xx = _width - xx;
|
||||
if(touchCalibration_invert_y)
|
||||
yy = _height - yy;
|
||||
} else {
|
||||
xx=(y_tmp-touchCalibration_x0)*_width/touchCalibration_x1;
|
||||
yy=(x_tmp-touchCalibration_y0)*_height/touchCalibration_y1;
|
||||
if(touchCalibration_invert_x)
|
||||
xx = _width - xx;
|
||||
if(touchCalibration_invert_y)
|
||||
yy = _height - yy;
|
||||
}
|
||||
|
||||
if (xx >= _width || yy >= _height) return valid;
|
||||
|
||||
_pressX = xx;
|
||||
_pressY = yy;
|
||||
*x = _pressX;
|
||||
*y = _pressY;
|
||||
return valid;
|
||||
}
|
||||
|
||||
/***************************************************************************************
|
||||
** Function name: calibrateTouch
|
||||
** Description: generates calibration parameters for touchscreen.
|
||||
***************************************************************************************/
|
||||
void TFT_eSPI::calibrateTouch(uint16_t *parameters, uint32_t color_fg, uint32_t color_bg, uint8_t size){
|
||||
int16_t values[] = {0,0,0,0,0,0,0,0};
|
||||
uint16_t x_tmp, y_tmp;
|
||||
|
||||
|
||||
|
||||
for(uint8_t i = 0; i<4; i++){
|
||||
fillRect(0, 0, size+1, size+1, color_bg);
|
||||
fillRect(0, _height-size-1, size+1, size+1, color_bg);
|
||||
fillRect(_width-size-1, 0, size+1, size+1, color_bg);
|
||||
fillRect(_width-size-1, _height-size-1, size+1, size+1, color_bg);
|
||||
|
||||
if (i == 5) break; // used to clear the arrows
|
||||
|
||||
switch (i) {
|
||||
case 0: // up left
|
||||
drawLine(0, 0, 0, size, color_fg);
|
||||
drawLine(0, 0, size, 0, color_fg);
|
||||
drawLine(0, 0, size , size, color_fg);
|
||||
break;
|
||||
case 1: // bot left
|
||||
drawLine(0, _height-size-1, 0, _height-1, color_fg);
|
||||
drawLine(0, _height-1, size, _height-1, color_fg);
|
||||
drawLine(size, _height-size-1, 0, _height-1 , color_fg);
|
||||
break;
|
||||
case 2: // up right
|
||||
drawLine(_width-size-1, 0, _width-1, 0, color_fg);
|
||||
drawLine(_width-size-1, size, _width-1, 0, color_fg);
|
||||
drawLine(_width-1, size, _width-1, 0, color_fg);
|
||||
break;
|
||||
case 3: // bot right
|
||||
drawLine(_width-size-1, _height-size-1, _width-1, _height-1, color_fg);
|
||||
drawLine(_width-1, _height-1-size, _width-1, _height-1, color_fg);
|
||||
drawLine(_width-1-size, _height-1, _width-1, _height-1, color_fg);
|
||||
break;
|
||||
}
|
||||
|
||||
// user has to get the chance to release
|
||||
if(i>0) delay(1000);
|
||||
|
||||
for(uint8_t j= 0; j<8; j++){
|
||||
// Use a lower detect threshold as corners tend to be less sensitive
|
||||
while(!validTouch(&x_tmp, &y_tmp, Z_THRESHOLD/2));
|
||||
values[i*2 ] += x_tmp;
|
||||
values[i*2+1] += y_tmp;
|
||||
}
|
||||
values[i*2 ] /= 8;
|
||||
values[i*2+1] /= 8;
|
||||
}
|
||||
|
||||
|
||||
// from case 0 to case 1, the y value changed.
|
||||
// If the measured delta of the touch x axis is bigger than the delta of the y axis, the touch and TFT axes are switched.
|
||||
touchCalibration_rotate = false;
|
||||
if(abs(values[0]-values[2]) > abs(values[1]-values[3])){
|
||||
touchCalibration_rotate = true;
|
||||
touchCalibration_x0 = (values[1] + values[3])/2; // calc min x
|
||||
touchCalibration_x1 = (values[5] + values[7])/2; // calc max x
|
||||
touchCalibration_y0 = (values[0] + values[4])/2; // calc min y
|
||||
touchCalibration_y1 = (values[2] + values[6])/2; // calc max y
|
||||
} else {
|
||||
touchCalibration_x0 = (values[0] + values[2])/2; // calc min x
|
||||
touchCalibration_x1 = (values[4] + values[6])/2; // calc max x
|
||||
touchCalibration_y0 = (values[1] + values[5])/2; // calc min y
|
||||
touchCalibration_y1 = (values[3] + values[7])/2; // calc max y
|
||||
}
|
||||
|
||||
// in addition, the touch screen axis could be in the opposite direction of the TFT axis
|
||||
touchCalibration_invert_x = false;
|
||||
if(touchCalibration_x0 > touchCalibration_x1){
|
||||
values[0]=touchCalibration_x0;
|
||||
touchCalibration_x0 = touchCalibration_x1;
|
||||
touchCalibration_x1 = values[0];
|
||||
touchCalibration_invert_x = true;
|
||||
}
|
||||
touchCalibration_invert_y = false;
|
||||
if(touchCalibration_y0 > touchCalibration_y1){
|
||||
values[0]=touchCalibration_y0;
|
||||
touchCalibration_y0 = touchCalibration_y1;
|
||||
touchCalibration_y1 = values[0];
|
||||
touchCalibration_invert_y = true;
|
||||
}
|
||||
|
||||
// pre calculate
|
||||
touchCalibration_x1 -= touchCalibration_x0;
|
||||
touchCalibration_y1 -= touchCalibration_y0;
|
||||
|
||||
if(touchCalibration_x0 == 0) touchCalibration_x0 = 1;
|
||||
if(touchCalibration_x1 == 0) touchCalibration_x1 = 1;
|
||||
if(touchCalibration_y0 == 0) touchCalibration_y0 = 1;
|
||||
if(touchCalibration_y1 == 0) touchCalibration_y1 = 1;
|
||||
|
||||
// export parameters, if pointer valid
|
||||
if(parameters != NULL){
|
||||
parameters[0] = touchCalibration_x0;
|
||||
parameters[1] = touchCalibration_x1;
|
||||
parameters[2] = touchCalibration_y0;
|
||||
parameters[3] = touchCalibration_y1;
|
||||
parameters[4] = touchCalibration_rotate | (touchCalibration_invert_x <<1) | (touchCalibration_invert_y <<2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************************
|
||||
** Function name: setTouch
|
||||
** Description: imports calibration parameters for touchscreen.
|
||||
***************************************************************************************/
|
||||
void TFT_eSPI::setTouch(uint16_t *parameters){
|
||||
touchCalibration_x0 = parameters[0];
|
||||
touchCalibration_x1 = parameters[1];
|
||||
touchCalibration_y0 = parameters[2];
|
||||
touchCalibration_y1 = parameters[3];
|
||||
|
||||
if(touchCalibration_x0 == 0) touchCalibration_x0 = 1;
|
||||
if(touchCalibration_x1 == 0) touchCalibration_x1 = 1;
|
||||
if(touchCalibration_y0 == 0) touchCalibration_y0 = 1;
|
||||
if(touchCalibration_y1 == 0) touchCalibration_y1 = 1;
|
||||
|
||||
touchCalibration_rotate = parameters[4] & 0x01;
|
||||
touchCalibration_invert_x = parameters[4] & 0x02;
|
||||
touchCalibration_invert_y = parameters[4] & 0x04;
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
// Coded by Bodmer 10/2/18, see license in root directory.
|
||||
// This is part of the TFT_eSPI class and is associated with the Touch Screen handlers
|
||||
|
||||
public:
|
||||
|
||||
uint8_t getTouchRaw(uint16_t *x, uint16_t *y);
|
||||
uint16_t getTouchRawZ(void);
|
||||
uint8_t getTouch(uint16_t *x, uint16_t *y, uint16_t threshold = 600);
|
||||
|
||||
void calibrateTouch(uint16_t *data, uint32_t color_fg, uint32_t color_bg, uint8_t size);
|
||||
void setTouch(uint16_t *data);
|
||||
|
||||
private:
|
||||
|
||||
inline void spi_begin_touch() __attribute__((always_inline));
|
||||
inline void spi_end_touch() __attribute__((always_inline));
|
||||
|
||||
// These are associated with the Touch Screen handlers
|
||||
uint8_t validTouch(uint16_t *x, uint16_t *y, uint16_t threshold = 600);
|
||||
// Initialise with example calibration values so processor does not crash if setTouch() not called in setup()
|
||||
uint16_t touchCalibration_x0 = 300, touchCalibration_x1 = 3600, touchCalibration_y0 = 300, touchCalibration_y1 = 3600;
|
||||
uint8_t touchCalibration_rotate = 1, touchCalibration_invert_x = 2, touchCalibration_invert_y = 0;
|
||||
uint32_t _pressTime;
|
||||
uint16_t _pressX, _pressY;
|
||||
|
|
@ -0,0 +1,247 @@
|
|||
// Font 8
|
||||
//
|
||||
// This font has been 8 bit Run Length Encoded to save FLASH space
|
||||
//
|
||||
// It is a Arial 75 pixel height font intended to display large numbers
|
||||
// Width for numerals reduced from 55 to 53 (to fit in 160 pixel screens)
|
||||
// This font only contains characters [space] 0 1 2 3 4 5 6 7 8 9 0 : - .
|
||||
// All other characters print as a space
|
||||
|
||||
#include <pgmspace.h>
|
||||
|
||||
|
||||
PROGMEM const unsigned char widtbl_f72[96] = // character width table
|
||||
{
|
||||
29, 29, 29, 29, 29, 29, 29, 29, // char 32 - 39
|
||||
29, 29, 29, 29, 29, 29, 29, 29, // char 40 - 47
|
||||
53, 53, 53, 53, 53, 53, 53, 53, // char 48 - 55
|
||||
53, 53, 29, 29, 29, 29, 29, 29, // char 56 - 63
|
||||
29, 29, 29, 29, 29, 29, 29, 29, // char 64 - 71
|
||||
29, 29, 29, 29, 29, 29, 29, 29, // char 72 - 79
|
||||
29, 29, 29, 29, 29, 29, 29, 29, // char 80 - 87
|
||||
29, 29, 29, 29, 29, 29, 29, 29, // char 88 - 95
|
||||
29, 29, 29, 29, 29, 29, 29, 29, // char 96 - 103
|
||||
29, 29, 29, 29, 29, 29, 29, 29, // char 104 - 111
|
||||
29, 29, 29, 29, 29, 29, 29, 29, // char 112 - 119
|
||||
29, 29, 29, 29, 29, 29, 29, 29 // char 120 - 127
|
||||
};
|
||||
|
||||
// Row format, MSB left
|
||||
|
||||
PROGMEM const unsigned char chr_f72_20[] =
|
||||
{
|
||||
0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,
|
||||
0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,
|
||||
0x7E
|
||||
};
|
||||
|
||||
PROGMEM const unsigned char chr_f72_2D[] =
|
||||
{
|
||||
0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,
|
||||
0x36, 0x91, 0x0A, 0x91, 0x0A, 0x91, 0x0A, 0x91,
|
||||
0x0A, 0x91, 0x0A, 0x91, 0x0A, 0x91, 0x7F, 0x7F,
|
||||
0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x07
|
||||
};
|
||||
|
||||
PROGMEM const unsigned char chr_f72_2E[] =
|
||||
{
|
||||
0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,
|
||||
0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x48, 0x88,
|
||||
0x13, 0x88, 0x13, 0x88, 0x13, 0x88, 0x13, 0x88,
|
||||
0x13, 0x88, 0x13, 0x88, 0x13, 0x88, 0x13, 0x88,
|
||||
0x44
|
||||
};
|
||||
|
||||
PROGMEM const unsigned char chr_f72_30[] =
|
||||
{
|
||||
0x7F, 0x68, 0x8A, 0x26, 0x90, 0x21, 0x94, 0x1D, 0x98, 0x1A, 0x9A, 0x18, 0x9C, 0x16, 0x9E, 0x14,
|
||||
0xA0, 0x13, 0x8C, 0x06, 0x8C, 0x12, 0x8B, 0x0A, 0x8B, 0x10, 0x8A, 0x0E, 0x89, 0x10, 0x89, 0x10,
|
||||
0x89, 0x0F, 0x88, 0x12, 0x88, 0x0E, 0x89, 0x12, 0x89, 0x0D, 0x88, 0x14, 0x88, 0x0C, 0x89, 0x14,
|
||||
0x88, 0x0C, 0x88, 0x16, 0x88, 0x0B, 0x88, 0x16, 0x88, 0x0B, 0x88, 0x16, 0x88, 0x0A, 0x88, 0x18,
|
||||
0x88, 0x09, 0x88, 0x18, 0x88, 0x09, 0x88, 0x18, 0x88, 0x09, 0x88, 0x18, 0x88, 0x09, 0x88, 0x18,
|
||||
0x88, 0x09, 0x88, 0x18, 0x88, 0x08, 0x88, 0x1A, 0x88, 0x07, 0x88, 0x1A, 0x88, 0x07, 0x88, 0x1A,
|
||||
0x88, 0x07, 0x88, 0x1A, 0x88, 0x07, 0x88, 0x1A, 0x88, 0x07, 0x88, 0x1A, 0x88, 0x07, 0x88, 0x1A,
|
||||
0x88, 0x07, 0x88, 0x1A, 0x88, 0x07, 0x88, 0x1A, 0x88, 0x07, 0x88, 0x1A, 0x88, 0x07, 0x88, 0x1A,
|
||||
0x88, 0x07, 0x88, 0x1A, 0x88, 0x07, 0x88, 0x1A, 0x88, 0x07, 0x88, 0x1A, 0x88, 0x07, 0x88, 0x1A,
|
||||
0x88, 0x07, 0x88, 0x1A, 0x88, 0x07, 0x88, 0x1A, 0x88, 0x07, 0x88, 0x1A, 0x88, 0x07, 0x88, 0x1A,
|
||||
0x88, 0x07, 0x88, 0x1A, 0x88, 0x08, 0x88, 0x18, 0x88, 0x09, 0x88, 0x18, 0x88, 0x09, 0x88, 0x18,
|
||||
0x88, 0x09, 0x88, 0x18, 0x88, 0x09, 0x88, 0x18, 0x88, 0x09, 0x88, 0x18, 0x88, 0x0A, 0x88, 0x16,
|
||||
0x88, 0x0B, 0x88, 0x16, 0x88, 0x0B, 0x88, 0x16, 0x88, 0x0B, 0x89, 0x14, 0x89, 0x0C, 0x88, 0x14,
|
||||
0x88, 0x0D, 0x89, 0x12, 0x89, 0x0E, 0x88, 0x12, 0x88, 0x0F, 0x89, 0x10, 0x89, 0x0F, 0x8A, 0x0E,
|
||||
0x8A, 0x10, 0x8B, 0x0A, 0x8B, 0x12, 0x8C, 0x06, 0x8C, 0x13, 0xA0, 0x14, 0x9E, 0x16, 0x9C, 0x18,
|
||||
0x9A, 0x1A, 0x98, 0x1D, 0x94, 0x21, 0x90, 0x26, 0x8A, 0x49
|
||||
};
|
||||
|
||||
PROGMEM const unsigned char chr_f72_31[] =
|
||||
{
|
||||
0x7F, 0x70, 0x85, 0x2D, 0x86, 0x2D, 0x86, 0x2C, 0x87, 0x2B, 0x88, 0x2B, 0x88, 0x2A, 0x89, 0x29,
|
||||
0x8A, 0x28, 0x8B, 0x27, 0x8C, 0x25, 0x8E, 0x24, 0x8F, 0x23, 0x90, 0x22, 0x91, 0x20, 0x93, 0x1E,
|
||||
0x95, 0x1C, 0x8D, 0x00, 0x88, 0x1B, 0x8C, 0x02, 0x88, 0x1B, 0x8B, 0x03, 0x88, 0x1B, 0x8A, 0x04,
|
||||
0x88, 0x1B, 0x88, 0x06, 0x88, 0x1B, 0x87, 0x07, 0x88, 0x1B, 0x85, 0x09, 0x88, 0x1B, 0x83, 0x0B,
|
||||
0x88, 0x1B, 0x81, 0x0D, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B,
|
||||
0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B,
|
||||
0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B,
|
||||
0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B,
|
||||
0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B,
|
||||
0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x7B
|
||||
};
|
||||
|
||||
PROGMEM const unsigned char chr_f72_32[] =
|
||||
{
|
||||
0x7F, 0x67, 0x8A, 0x25, 0x92, 0x1F, 0x96, 0x1B, 0x9A, 0x18, 0x9C, 0x16, 0x9E, 0x14, 0xA0, 0x12,
|
||||
0xA2, 0x10, 0x8E, 0x07, 0x8D, 0x0F, 0x8B, 0x0C, 0x8C, 0x0D, 0x8A, 0x10, 0x8A, 0x0D, 0x89, 0x12,
|
||||
0x8A, 0x0B, 0x89, 0x14, 0x89, 0x0B, 0x89, 0x14, 0x89, 0x0B, 0x88, 0x16, 0x89, 0x0A, 0x88, 0x16,
|
||||
0x89, 0x09, 0x88, 0x18, 0x88, 0x09, 0x88, 0x18, 0x88, 0x09, 0x88, 0x18, 0x88, 0x0D, 0x84, 0x18,
|
||||
0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2A, 0x89, 0x2A, 0x88, 0x2A, 0x89, 0x2A, 0x89, 0x29,
|
||||
0x89, 0x2A, 0x89, 0x29, 0x89, 0x29, 0x8A, 0x28, 0x8A, 0x28, 0x8B, 0x27, 0x8B, 0x27, 0x8B, 0x27,
|
||||
0x8B, 0x27, 0x8B, 0x27, 0x8C, 0x26, 0x8C, 0x26, 0x8C, 0x26, 0x8C, 0x26, 0x8C, 0x25, 0x8C, 0x26,
|
||||
0x8C, 0x26, 0x8C, 0x26, 0x8C, 0x26, 0x8C, 0x25, 0x8D, 0x25, 0x8D, 0x25, 0x8C, 0x26, 0x8C, 0x26,
|
||||
0x8C, 0x27, 0x8B, 0x27, 0x8B, 0x27, 0x8A, 0x28, 0x8A, 0x29, 0x89, 0x29, 0x8A, 0x29, 0x89, 0x29,
|
||||
0x89, 0x2A, 0xAA, 0x08, 0xAB, 0x08, 0xAB, 0x08, 0xAB, 0x07, 0xAC, 0x07, 0xAC, 0x07, 0xAC, 0x07,
|
||||
0xAC, 0x07, 0xAC, 0x6E
|
||||
};
|
||||
|
||||
PROGMEM const unsigned char chr_f72_33[] =
|
||||
{
|
||||
0x7F, 0x67, 0x89, 0x27, 0x90, 0x21, 0x94, 0x1D, 0x97, 0x1B, 0x9A, 0x18, 0x9C, 0x16, 0x9E, 0x14,
|
||||
0xA0, 0x13, 0x8C, 0x06, 0x8C, 0x12, 0x8B, 0x0A, 0x8B, 0x10, 0x8A, 0x0E, 0x89, 0x10, 0x89, 0x10,
|
||||
0x89, 0x0F, 0x88, 0x12, 0x88, 0x0E, 0x89, 0x12, 0x89, 0x0D, 0x88, 0x14, 0x88, 0x0D, 0x88, 0x14,
|
||||
0x88, 0x0C, 0x89, 0x14, 0x88, 0x0C, 0x88, 0x15, 0x88, 0x10, 0x84, 0x15, 0x88, 0x2B, 0x88, 0x2B,
|
||||
0x88, 0x2A, 0x88, 0x2B, 0x88, 0x2A, 0x89, 0x29, 0x89, 0x29, 0x89, 0x28, 0x8B, 0x26, 0x8C, 0x21,
|
||||
0x91, 0x22, 0x8F, 0x24, 0x8D, 0x26, 0x8F, 0x23, 0x92, 0x21, 0x94, 0x1F, 0x95, 0x1E, 0x81, 0x07,
|
||||
0x8C, 0x29, 0x8B, 0x2A, 0x8A, 0x2A, 0x89, 0x2B, 0x89, 0x2B, 0x89, 0x2A, 0x89, 0x2B, 0x88, 0x2B,
|
||||
0x89, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x0B, 0x84, 0x1A,
|
||||
0x88, 0x07, 0x88, 0x1A, 0x88, 0x07, 0x89, 0x18, 0x89, 0x07, 0x89, 0x18, 0x88, 0x09, 0x88, 0x18,
|
||||
0x88, 0x09, 0x89, 0x16, 0x89, 0x09, 0x89, 0x15, 0x89, 0x0B, 0x89, 0x14, 0x89, 0x0B, 0x8A, 0x12,
|
||||
0x89, 0x0D, 0x8A, 0x10, 0x8A, 0x0D, 0x8B, 0x0D, 0x8B, 0x0F, 0x8D, 0x07, 0x8D, 0x11, 0xA2, 0x12,
|
||||
0xA0, 0x14, 0x9D, 0x17, 0x9B, 0x19, 0x99, 0x1C, 0x95, 0x20, 0x91, 0x26, 0x89, 0x4A
|
||||
};
|
||||
|
||||
PROGMEM const unsigned char chr_f72_34[] =
|
||||
{
|
||||
0x7F, 0x7F, 0x2A, 0x86, 0x2C, 0x87, 0x2B, 0x88, 0x2A, 0x89, 0x2A, 0x89, 0x29, 0x8A, 0x28, 0x8B,
|
||||
0x27, 0x8C, 0x26, 0x8D, 0x26, 0x8D, 0x25, 0x8E, 0x24, 0x8F, 0x23, 0x90, 0x23, 0x90, 0x22, 0x91,
|
||||
0x21, 0x92, 0x20, 0x93, 0x20, 0x93, 0x1F, 0x8A, 0x00, 0x88, 0x1E, 0x8A, 0x01, 0x88, 0x1D, 0x8A,
|
||||
0x02, 0x88, 0x1C, 0x8B, 0x02, 0x88, 0x1C, 0x8A, 0x03, 0x88, 0x1B, 0x8A, 0x04, 0x88, 0x1A, 0x8A,
|
||||
0x05, 0x88, 0x19, 0x8A, 0x06, 0x88, 0x19, 0x8A, 0x06, 0x88, 0x18, 0x8A, 0x07, 0x88, 0x17, 0x8A,
|
||||
0x08, 0x88, 0x16, 0x8A, 0x09, 0x88, 0x16, 0x8A, 0x09, 0x88, 0x15, 0x8A, 0x0A, 0x88, 0x14, 0x8A,
|
||||
0x0B, 0x88, 0x13, 0x8A, 0x0C, 0x88, 0x13, 0x8A, 0x0C, 0x88, 0x12, 0x8A, 0x0D, 0x88, 0x11, 0x8A,
|
||||
0x0E, 0x88, 0x10, 0x8A, 0x0F, 0x88, 0x0F, 0x8B, 0x0F, 0x88, 0x0F, 0x8A, 0x10, 0x88, 0x0E, 0x8A,
|
||||
0x11, 0x88, 0x0D, 0x8A, 0x12, 0x88, 0x0C, 0x8A, 0x13, 0x88, 0x0C, 0xAF, 0x04, 0xAF, 0x04, 0xAF,
|
||||
0x04, 0xAF, 0x04, 0xAF, 0x04, 0xAF, 0x04, 0xAF, 0x04, 0xAF, 0x04, 0xAF, 0x23, 0x88, 0x2B, 0x88,
|
||||
0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88,
|
||||
0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x75
|
||||
};
|
||||
|
||||
PROGMEM const unsigned char chr_f72_35[] =
|
||||
{
|
||||
0x7F, 0x7F, 0x14, 0xA0, 0x13, 0xA0, 0x12, 0xA1, 0x12, 0xA1, 0x12, 0xA1, 0x12, 0xA1, 0x12, 0xA1,
|
||||
0x11, 0xA2, 0x11, 0xA2, 0x11, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2A, 0x89, 0x2A, 0x88, 0x2B, 0x88,
|
||||
0x2B, 0x88, 0x2B, 0x88, 0x2A, 0x89, 0x2A, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2A, 0x89,
|
||||
0x06, 0x88, 0x1A, 0x89, 0x03, 0x8E, 0x17, 0x88, 0x02, 0x92, 0x15, 0x88, 0x00, 0x96, 0x13, 0xA1,
|
||||
0x11, 0xA3, 0x10, 0xA4, 0x0F, 0xA5, 0x0E, 0x8F, 0x07, 0x8E, 0x0D, 0x8C, 0x0D, 0x8C, 0x0B, 0x8B,
|
||||
0x11, 0x8A, 0x0B, 0x8A, 0x13, 0x8A, 0x0A, 0x89, 0x15, 0x89, 0x0E, 0x84, 0x17, 0x89, 0x2A, 0x89,
|
||||
0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x89, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88,
|
||||
0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x0B, 0x84, 0x1A, 0x88, 0x07, 0x88, 0x19, 0x88,
|
||||
0x08, 0x89, 0x18, 0x88, 0x08, 0x89, 0x18, 0x88, 0x09, 0x88, 0x17, 0x89, 0x09, 0x89, 0x16, 0x88,
|
||||
0x0A, 0x89, 0x15, 0x89, 0x0B, 0x89, 0x13, 0x89, 0x0C, 0x8A, 0x11, 0x8A, 0x0C, 0x8B, 0x0F, 0x8A,
|
||||
0x0E, 0x8B, 0x0D, 0x8A, 0x10, 0x8D, 0x07, 0x8D, 0x10, 0xA2, 0x12, 0xA0, 0x14, 0x9E, 0x17, 0x9B,
|
||||
0x19, 0x98, 0x1D, 0x95, 0x20, 0x90, 0x26, 0x8A, 0x4A
|
||||
};
|
||||
|
||||
PROGMEM const unsigned char chr_f72_36[] =
|
||||
{
|
||||
0x7F, 0x6A, 0x89, 0x26, 0x90, 0x21, 0x95, 0x1C, 0x98, 0x1A, 0x9A, 0x18, 0x9C, 0x16, 0x9E, 0x14,
|
||||
0xA0, 0x12, 0x8D, 0x06, 0x8D, 0x10, 0x8B, 0x0B, 0x8B, 0x10, 0x8A, 0x0E, 0x8A, 0x0E, 0x89, 0x11,
|
||||
0x89, 0x0D, 0x8A, 0x12, 0x89, 0x0C, 0x89, 0x13, 0x89, 0x0C, 0x88, 0x15, 0x88, 0x0B, 0x89, 0x15,
|
||||
0x89, 0x0A, 0x88, 0x16, 0x89, 0x09, 0x89, 0x17, 0x88, 0x09, 0x88, 0x18, 0x84, 0x0D, 0x88, 0x2B,
|
||||
0x87, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x0A, 0x88, 0x17, 0x87, 0x08, 0x8E, 0x14,
|
||||
0x87, 0x06, 0x92, 0x11, 0x88, 0x04, 0x96, 0x0F, 0x88, 0x03, 0x98, 0x0E, 0x88, 0x02, 0x9A, 0x0D,
|
||||
0x88, 0x01, 0x9C, 0x0C, 0x88, 0x00, 0x9E, 0x0B, 0x92, 0x07, 0x8E, 0x0A, 0x90, 0x0C, 0x8C, 0x09,
|
||||
0x8E, 0x10, 0x8A, 0x09, 0x8D, 0x12, 0x8A, 0x08, 0x8C, 0x14, 0x89, 0x08, 0x8B, 0x16, 0x89, 0x07,
|
||||
0x8A, 0x17, 0x89, 0x07, 0x89, 0x19, 0x88, 0x07, 0x89, 0x19, 0x88, 0x07, 0x89, 0x19, 0x89, 0x06,
|
||||
0x88, 0x1B, 0x88, 0x06, 0x88, 0x1B, 0x88, 0x06, 0x88, 0x1B, 0x88, 0x06, 0x88, 0x1B, 0x88, 0x07,
|
||||
0x87, 0x1B, 0x88, 0x07, 0x87, 0x1B, 0x88, 0x07, 0x87, 0x1B, 0x88, 0x07, 0x87, 0x1B, 0x88, 0x07,
|
||||
0x88, 0x1A, 0x88, 0x08, 0x87, 0x19, 0x89, 0x08, 0x87, 0x19, 0x88, 0x09, 0x88, 0x18, 0x88, 0x09,
|
||||
0x88, 0x17, 0x89, 0x0A, 0x88, 0x16, 0x88, 0x0B, 0x88, 0x15, 0x89, 0x0C, 0x88, 0x14, 0x89, 0x0C,
|
||||
0x89, 0x12, 0x89, 0x0E, 0x89, 0x10, 0x8A, 0x0E, 0x8B, 0x0C, 0x8B, 0x10, 0x8C, 0x07, 0x8D, 0x12,
|
||||
0xA1, 0x13, 0x9F, 0x15, 0x9D, 0x17, 0x9B, 0x1A, 0x97, 0x1D, 0x95, 0x21, 0x8F, 0x27, 0x89, 0x49
|
||||
|
||||
};
|
||||
|
||||
PROGMEM const unsigned char chr_f72_37[] =
|
||||
{
|
||||
0x7F, 0x7F, 0x0D, 0xAB, 0x08, 0xAB, 0x08, 0xAB, 0x08, 0xAB, 0x08, 0xAB, 0x08, 0xAB, 0x08, 0xAB,
|
||||
0x08, 0xAB, 0x08, 0xAA, 0x2C, 0x86, 0x2C, 0x86, 0x2C, 0x87, 0x2B, 0x87, 0x2B, 0x87, 0x2B, 0x87,
|
||||
0x2C, 0x87, 0x2B, 0x87, 0x2B, 0x87, 0x2C, 0x87, 0x2B, 0x87, 0x2B, 0x88, 0x2B, 0x87, 0x2B, 0x87,
|
||||
0x2B, 0x88, 0x2B, 0x87, 0x2B, 0x88, 0x2B, 0x87, 0x2B, 0x88, 0x2A, 0x88, 0x2B, 0x88, 0x2A, 0x88,
|
||||
0x2B, 0x88, 0x2A, 0x88, 0x2B, 0x88, 0x2A, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2A, 0x88, 0x2B, 0x88,
|
||||
0x2A, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2A, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2A, 0x88, 0x2B, 0x88,
|
||||
0x2B, 0x88, 0x2A, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2A, 0x88, 0x2B, 0x88, 0x2B, 0x88,
|
||||
0x2B, 0x88, 0x2A, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2A, 0x89,
|
||||
0x2A, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x7F, 0x06
|
||||
};
|
||||
|
||||
PROGMEM const unsigned char chr_f72_38[] =
|
||||
{
|
||||
0x7F, 0x68, 0x89, 0x26, 0x91, 0x20, 0x95, 0x1C, 0x99, 0x19, 0x9B, 0x17, 0x9D, 0x15, 0x9F, 0x13,
|
||||
0xA1, 0x11, 0x8D, 0x07, 0x8C, 0x11, 0x8B, 0x0B, 0x8B, 0x0F, 0x8A, 0x0F, 0x8A, 0x0E, 0x89, 0x11,
|
||||
0x89, 0x0E, 0x88, 0x13, 0x88, 0x0D, 0x89, 0x13, 0x89, 0x0C, 0x88, 0x15, 0x88, 0x0C, 0x88, 0x15,
|
||||
0x88, 0x0C, 0x88, 0x15, 0x88, 0x0C, 0x88, 0x15, 0x88, 0x0C, 0x88, 0x15, 0x88, 0x0C, 0x88, 0x15,
|
||||
0x88, 0x0C, 0x88, 0x15, 0x88, 0x0D, 0x88, 0x13, 0x88, 0x0E, 0x88, 0x13, 0x88, 0x0E, 0x89, 0x11,
|
||||
0x89, 0x0F, 0x89, 0x0F, 0x89, 0x11, 0x89, 0x0D, 0x89, 0x13, 0x8B, 0x07, 0x8C, 0x14, 0x9D, 0x17,
|
||||
0x9B, 0x1A, 0x97, 0x1E, 0x93, 0x1E, 0x96, 0x1B, 0x9A, 0x18, 0x9D, 0x15, 0x9F, 0x13, 0x8C, 0x07,
|
||||
0x8C, 0x11, 0x8A, 0x0C, 0x8B, 0x0F, 0x8A, 0x0F, 0x8A, 0x0D, 0x8A, 0x11, 0x89, 0x0D, 0x89, 0x13,
|
||||
0x89, 0x0B, 0x89, 0x15, 0x88, 0x0B, 0x89, 0x15, 0x89, 0x0A, 0x88, 0x17, 0x88, 0x0A, 0x88, 0x17,
|
||||
0x88, 0x09, 0x88, 0x19, 0x88, 0x08, 0x88, 0x19, 0x88, 0x08, 0x88, 0x19, 0x88, 0x08, 0x88, 0x19,
|
||||
0x88, 0x08, 0x88, 0x19, 0x88, 0x08, 0x88, 0x19, 0x88, 0x08, 0x88, 0x19, 0x88, 0x08, 0x88, 0x19,
|
||||
0x88, 0x08, 0x88, 0x19, 0x88, 0x08, 0x89, 0x17, 0x89, 0x09, 0x88, 0x17, 0x88, 0x0A, 0x89, 0x15,
|
||||
0x89, 0x0A, 0x89, 0x15, 0x89, 0x0B, 0x89, 0x13, 0x89, 0x0C, 0x8A, 0x11, 0x8A, 0x0D, 0x8A, 0x0F,
|
||||
0x8A, 0x0E, 0x8C, 0x0C, 0x8B, 0x0F, 0x8D, 0x07, 0x8D, 0x11, 0xA1, 0x13, 0x9F, 0x15, 0x9D, 0x17,
|
||||
0x9B, 0x19, 0x99, 0x1C, 0x95, 0x20, 0x91, 0x26, 0x89, 0x4A
|
||||
};
|
||||
|
||||
PROGMEM const unsigned char chr_f72_39[] =
|
||||
{
|
||||
0x7F, 0x68, 0x88, 0x27, 0x90, 0x21, 0x94, 0x1E, 0x97, 0x1A, 0x9A, 0x18, 0x9C, 0x16, 0x9E, 0x14,
|
||||
0xA0, 0x12, 0x8E, 0x07, 0x8B, 0x11, 0x8C, 0x0B, 0x8A, 0x0F, 0x8B, 0x0F, 0x88, 0x0F, 0x8A, 0x11,
|
||||
0x88, 0x0D, 0x8A, 0x13, 0x88, 0x0C, 0x89, 0x14, 0x88, 0x0B, 0x89, 0x16, 0x87, 0x0B, 0x89, 0x17,
|
||||
0x87, 0x0A, 0x88, 0x18, 0x87, 0x0A, 0x88, 0x18, 0x87, 0x09, 0x89, 0x19, 0x87, 0x08, 0x88, 0x1A,
|
||||
0x87, 0x08, 0x88, 0x1A, 0x87, 0x08, 0x88, 0x1A, 0x87, 0x08, 0x88, 0x1A, 0x87, 0x08, 0x88, 0x1A,
|
||||
0x87, 0x08, 0x88, 0x1A, 0x88, 0x07, 0x88, 0x1A, 0x88, 0x07, 0x88, 0x1A, 0x88, 0x07, 0x88, 0x1A,
|
||||
0x88, 0x07, 0x89, 0x18, 0x89, 0x08, 0x88, 0x18, 0x89, 0x08, 0x88, 0x18, 0x89, 0x08, 0x89, 0x16,
|
||||
0x8A, 0x08, 0x89, 0x16, 0x8A, 0x09, 0x89, 0x14, 0x8B, 0x09, 0x8A, 0x12, 0x8C, 0x0A, 0x8A, 0x10,
|
||||
0x8D, 0x0A, 0x8C, 0x0C, 0x8F, 0x0B, 0x8E, 0x07, 0x91, 0x0C, 0x9D, 0x00, 0x88, 0x0D, 0x9B, 0x01,
|
||||
0x88, 0x0E, 0x99, 0x02, 0x88, 0x0F, 0x97, 0x03, 0x88, 0x10, 0x95, 0x04, 0x88, 0x11, 0x92, 0x06,
|
||||
0x87, 0x14, 0x8E, 0x08, 0x87, 0x17, 0x88, 0x0A, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B, 0x88, 0x2B,
|
||||
0x87, 0x2B, 0x88, 0x0E, 0x84, 0x17, 0x88, 0x0A, 0x88, 0x17, 0x88, 0x0A, 0x89, 0x15, 0x88, 0x0B,
|
||||
0x89, 0x15, 0x88, 0x0C, 0x88, 0x14, 0x89, 0x0C, 0x89, 0x13, 0x88, 0x0D, 0x89, 0x12, 0x89, 0x0E,
|
||||
0x89, 0x10, 0x89, 0x0F, 0x8A, 0x0E, 0x8A, 0x0F, 0x8B, 0x0B, 0x8B, 0x11, 0x8C, 0x07, 0x8C, 0x13,
|
||||
0x9F, 0x14, 0x9E, 0x16, 0x9C, 0x18, 0x9A, 0x1B, 0x97, 0x1D, 0x94, 0x21, 0x90, 0x26, 0x89, 0x4C
|
||||
};
|
||||
|
||||
PROGMEM const unsigned char chr_f72_3A[] =
|
||||
{
|
||||
0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x23, 0x88, 0x13,
|
||||
0x88, 0x13, 0x88, 0x13, 0x88, 0x13, 0x88, 0x13,
|
||||
0x88, 0x13, 0x88, 0x13, 0x88, 0x13, 0x88, 0x7F,
|
||||
0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x33, 0x88,
|
||||
0x13, 0x88, 0x13, 0x88, 0x13, 0x88, 0x13, 0x88,
|
||||
0x13, 0x88, 0x13, 0x88, 0x13, 0x88, 0x13, 0x88,
|
||||
0x44
|
||||
};
|
||||
PROGMEM const unsigned char * const chrtbl_f72[96] = // character pointer table
|
||||
{
|
||||
chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20,
|
||||
chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_2D, chr_f72_2E, chr_f72_20,
|
||||
chr_f72_30, chr_f72_31, chr_f72_32, chr_f72_33, chr_f72_34, chr_f72_35, chr_f72_36, chr_f72_37,
|
||||
chr_f72_38, chr_f72_39, chr_f72_3A, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20,
|
||||
chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20,
|
||||
chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20,
|
||||
chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20,
|
||||
chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20,
|
||||
chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20,
|
||||
chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20,
|
||||
chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20,
|
||||
chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20
|
||||
};
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
#include <Fonts/Font72x53rle.c>
|
||||
|
||||
#define nr_chrs_f72 96
|
||||
#define chr_hgt_f72 75
|
||||
#define baseline_f72 73
|
||||
#define data_size_f72 8
|
||||
#define firstchr_f72 32
|
||||
|
||||
extern const unsigned char widtbl_f72[96];
|
||||
extern const unsigned char* const chrtbl_f72[96];
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
PROGMEM const unsigned char widtbl_f7s[96] = // character width table
|
||||
{
|
||||
12, 12, 12, 12, 12, 12, 12, 12, // char 32 - 39
|
||||
12, 12, 12, 12, 12, 17, 12, 12, // char 40 - 47
|
||||
12, 12, 12, 12, 12, 32, 12, 12, // char 40 - 47
|
||||
32, 32, 32, 32, 32, 32, 32, 32, // char 48 - 55
|
||||
32, 32, 12, 12, 12, 12, 12, 12, // char 56 - 63
|
||||
12, 12, 12, 12, 12, 12, 12, 12, // char 64 - 71
|
||||
|
|
@ -32,10 +32,12 @@ PROGMEM const unsigned char chr_f7s_20[] =
|
|||
0x7F, 0x7F, 0x7F, 0x7F, 0x3F
|
||||
};
|
||||
|
||||
// Make - sign look like a segment
|
||||
PROGMEM const unsigned char chr_f7s_2D[] =
|
||||
{
|
||||
0x7F, 0x7F, 0x45, 0x8A, 0x05, 0x8A, 0x05, 0x8A,
|
||||
0x05, 0x8A, 0x7F, 0x7F, 0x7F, 0x2B
|
||||
0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x27, 0x8E, 0x0E,
|
||||
0x92, 0x0A, 0x96, 0x09, 0x94, 0x0C, 0x90, 0x7F,
|
||||
0x7F, 0x7F, 0x7F, 0x7F, 0x47
|
||||
};
|
||||
|
||||
PROGMEM const unsigned char chr_f7s_2E[] =
|
||||
|
|
|
|||
75
README.md
75
README.md
|
|
@ -1,17 +1,78 @@
|
|||
# TFT_eSPI
|
||||
|
||||
In addition to the original library, this library supports the XPT2046 touch screen controller, which is part of many RPi displays. The SPI is shared with the TFT and only an additional chip select line is needed.
|
||||
An Arduino IDE compatible graphics and fonts library for ESP8266 and ESP32 processors with a driver for ILI9341, ILI9163, ST7735, S6D02A1, ILI9481, ILI9486, HX8357D and ST7789 based TFT displays that support SPI.
|
||||
|
||||
8 bit parallel interface TFTs (e.g. UNO format mcufriend shields) can used with an ESP32. The ILI9488 is supported in 8 bit parallel mode.
|
||||
|
||||
The library supports TFT displays designed for the Raspberry Pi that are based on a ILI9486 driver chip with a 480 x 320 pixel screen. This display must be of the Waveshare design and use a 16 bit serial interface based on the 74HC04, 74HC4040 and 2 x 74HC4094 logic chips. A modification to these displays is possible (see mod image in Tools folder) to make many graphics functions much faster (e.g. 23ms to clear the screen, 1.2ms to draw a 72 pixel high numeral).
|
||||
|
||||
Support has been added recently for Waveshare 2 and 3 colour ePaper displays using full frame buffers. This addition is currently relatively immature and thus only one example has been provided. Further examples will be added soon.
|
||||
|
||||
The library includes a "Sprite" class, this enables flicker free updates of complex graphics. Direct writes to the TFT with graphics functions are still available, so existing sketches do not need to be changed.
|
||||
|
||||
A Sprite is notionally an invisible graphics screen that is kept in the processors RAM. Graphics can be drawn into the Sprite just as they can be drawn directly to the screen. Once the Sprite is completed it can be plotted onto the screen in any position. If there is sufficient RAM then the Sprite can be the same size as the screen and used as a frame buffer. Sprites by default use 16 bit colours, the bit depth can be set to 8 bits (256 colours) , or 1 bit (any 2 colours) to reduce the RAM needed. On an ESP8266 the largest 16 bit colour Sprite that can be created is about 160x128 pixels, this consumes 40Kbytes of RAM. On an ESP32 the workspace RAM is more limited than the datsheet implies so a 16 bit colour Sprite is limited to about 200x200 pixels (~80Kbytes), an 8 bit sprite to 320x240 pixels (~76kbytes). A 1 bit per pixel Sprite requires only 9600 bytes for a full 320 x 240 screen buffer, this is ideal for supporting use with 2 colour bitmap fonts.
|
||||
|
||||
One or more sprites can be created, a sprite can be any pixel width and height, limited only by available RAM. The RAM needed for a 16 bit colour depth Sprite is (2 x width x height) bytes, for a Sprite with 8 bit colour depth the RAM needed is (width x height) bytes. Sprites can be created and deleted dynamically as needed in the sketch, this means RAM can be freed up after the Sprite has been plotted on the screen, more RAM intensive WiFi based code can then be run and normal graphics operations still work.
|
||||
|
||||
Drawing graphics into a sprite is very fast, for those familiar with the Adafruit "graphicstest" example, this whole test completes in 18ms in a 160x128 sprite. Examples of sprite use can be found in the "examples/Sprite" folder.
|
||||
|
||||
Sprites can be plotted to the TFT with one colour being specified as "transparent", see Transparent_Sprite_Demo example.
|
||||
|
||||
The XPT2046 touch screen controller is supported. The SPI bus for the touch controller is shared with the TFT and only an additional chip select line is needed.
|
||||
|
||||
The Button class from Adafruit_GFX is incorporated, with the enhancement that the button labels can be in any font.
|
||||
|
||||
The library supports SPI overlap on the ESP8266 so the TFT screen can share MOSI, MISO and SCLK pins with the program FLASH, this frees up GPIO pins for other uses.
|
||||
|
||||
The library contains proportional fonts, different sizes can be enabled/disabled at compile time to optimise the use of FLASH memory. Anti-alased (smooth) font files in vlw format stored in SPIFFS are supported and in the case any 16 bit Unicode character can be included and rendered, this means many language specific characters can be rendered to the screen.
|
||||
|
||||
The library is based on the Adafruit GFX and Adafruit driver libraries and the aim is to retain compatibility. Significant additions have been made to the library to boost the speed for ESP8266/ESP32 processors (it is typically 3 to 10 times faster) and to add new features. The new graphics functions include different size proportional fonts and formatting features. There are lots of example sketches to demonstrate the different features and included functions.
|
||||
|
||||
Configuration of the library font selections, pins used to interface with the TFT and other features is made by editting the User_Setup.h file in the library folder, or by selecting a configuration in the library "User_Setup_Selet,h" file. Fonts and features can easily be disabled by commenting out lines.
|
||||
|
||||
|
||||
An Arduino IDE compatible graphics and fonts library for ESP8266 and ESP32 processors with a driver for ILI9341, ILI9163, ST7735 and S6D02A1 based TFT displays that support SPI.
|
||||
# Anti-aliased Fonts
|
||||
|
||||
The library also supports TFT displays designed for the Raspberry Pi that are based on a ILI9486 driver chip with a 480 x 320 pixel screen. This display must be of the Waveshare design and use a 16 bit serial interface based on the 74HC04, 74HC4040 and 2 x 74HC4094 logic chips. A modification to these displays is possible (see mod image in Tools folder) to make many graphics functions much faster (e.g. 23ms to clear the screen, 1.2ms to draw a 72 pixel high numeral).
|
||||
Anti-aliased (smooth) font files in "vlw" format are generated by the free [Processing IDE](https://processing.org/) using a sketch included in the library Tools folder. This sketch with the Processing IDE can be used to generate font files from your computer's font set or any TrueType (.ttf) font, the font file can include **any** combination of 16 bit Unicode characters. This means Greek, Japanese and any other UCS-2 glyphs can be used. Character arrays and Strings in UTF-8 format are supported.
|
||||
|
||||
The library supports SPI overlap so the TFT screen can share MOSI, MISO and SCLK pins with the program FLASH.
|
||||
Here is the Adafruit_GFX "FreeSans12pt" bitmap font compared to the same font drawn as anti-aliased:
|
||||
|
||||
The library contains proportional fonts, different sizes can be enabled/disabled at compile time to optimise the use of FLASH memory. The library has been tested with the NodeMCU (ESP8266 based) and an ESP32 demo board.
|
||||

|
||||
|
||||
The library is based on the Adafruit GFX and Adafruit driver libraries and the aim is to retain compatibility. Significant additions have been made to the library to boost the speed for ESP8266/ESP32 processors (it is typically 3 to 10 times faster) and to add new features. The new graphics functions include different size proportional fonts and formatting features. There are a significant number of example sketches to demonstrate the different features.
|
||||
The smooth font example displays the following screen:
|
||||
|
||||
Configuration of the library font selections, pins used to interface with the TFT and other features is made by editting the User_Setup.h file in the library folder. Fonts and features can easily be disabled by commenting out lines.
|
||||

|
||||
|
||||
It would be possible to compress the vlw font files but the rendering performance to a TFT is still good when storing the font file(s) in SPIFFS.
|
||||
|
||||
Here is an example screenshot showing the anti-aliased Hiragana character Unicode block (0x3041 to 0x309F) in 24pt from the Microsoft Yahei font:
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
# ESP32 with 8 bit Mcufriend UNO shields
|
||||
|
||||
The ESP32 board I have been using for testing has the following pinout:
|
||||
|
||||

|
||||
|
||||
UNO style boards with a Wemos R32(ESP32) label are also available at low cost with the same pin-out.
|
||||
|
||||
Unfortunately the typical UNO/mcufriend TFT display board maps LCD_RD, LCD_CS and LCD_RST signals to the ESP32 analogue pins 35, 34 and 36 which are input only. To solve this I linked in the 3 spare pins IO15, IO33 and IO32 by adding wires to the bottom of the board as follows:
|
||||
|
||||
IO15 wired to IO35
|
||||
|
||||
IO33 wired to IO34
|
||||
|
||||
IO32 wired to IO36
|
||||
|
||||

|
||||
|
||||
|
||||
# ePaper displays
|
||||
|
||||
The library was intended to support only TFT displays but using a Sprite as a 1 bit per pixel screen buffer permits support for the Waveshare 2 and 3 colour SPI ePaper displays. This addition to the library is experimental and only one example is provided. Further examples will be added.
|
||||
|
||||

|
||||
|
||||
|
|
|
|||
|
|
@ -10,5 +10,9 @@ older. Use the latest version.
|
|||
New functions have been added in particular it contains proportional fonts
|
||||
in addition to the original Adafruit font.
|
||||
|
||||
Note: This version of the library might not be fully compatible with the original.
|
||||
A sprite class has been added to aid the generation of flicker free complex
|
||||
graphics.
|
||||
|
||||
Note: This version of the library might not be fully compatible with the
|
||||
original.
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
// Null set for ePaper
|
||||
#define TFT_WIDTH 1000
|
||||
#define TFT_HEIGHT 1000
|
||||
|
||||
#define TFT_INIT_DELAY 0
|
||||
|
||||
#define TFT_NOP 0x00
|
||||
#define TFT_SWRST 0x00
|
||||
|
||||
#define TFT_CASET 0x00
|
||||
#define TFT_PASET 0x00
|
||||
#define TFT_RAMWR 0x00
|
||||
|
||||
#define TFT_RAMRD 0x00
|
||||
#define TFT_IDXRD 0x00
|
||||
|
||||
#define TFT_MADCTL 0x00
|
||||
#define TFT_MAD_MY 0x00
|
||||
#define TFT_MAD_MX 0x00
|
||||
#define TFT_MAD_MV 0x00
|
||||
#define TFT_MAD_ML 0x00
|
||||
#define TFT_MAD_BGR 0x00
|
||||
#define TFT_MAD_MH 0x00
|
||||
#define TFT_MAD_RGB 0x00
|
||||
|
||||
#define TFT_INVOFF 0x00
|
||||
#define TFT_INVON 0x00
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
// Change the width and height if required (defined in portrait mode)
|
||||
// or use the constructor to over-ride defaults
|
||||
#define TFT_WIDTH 320
|
||||
#define TFT_HEIGHT 480
|
||||
|
||||
|
||||
// Delay between some initialisation commands
|
||||
#define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked
|
||||
|
||||
|
||||
// Generic commands used by TFT_eSPar.cpp
|
||||
#define TFT_NOP 0x00
|
||||
#define TFT_SWRST 0x01
|
||||
|
||||
#define TFT_SLPIN 0x10
|
||||
#define TFT_SLPOUT 0x11
|
||||
|
||||
#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_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
|
||||
|
||||
#define TFT_IDXRD 0x00 // ILI9341 only, indexed control register read
|
||||
|
||||
|
||||
#define HX8357_NOP 0x00
|
||||
#define HX8357_SWRESET 0x01
|
||||
#define HX8357_RDDID 0x04
|
||||
#define HX8357_RDDST 0x09
|
||||
|
||||
#define HX8357_RDPOWMODE 0x0A
|
||||
#define HX8357_RDMADCTL 0x0B
|
||||
#define HX8357_RDCOLMOD 0x0C
|
||||
#define HX8357_RDDIM 0x0D
|
||||
#define HX8357_RDDSDR 0x0F
|
||||
|
||||
#define HX8357_SLPIN 0x10
|
||||
#define HX8357_SLPOUT 0x11
|
||||
|
||||
#define HX8357_INVOFF 0x20
|
||||
#define HX8357_INVON 0x21
|
||||
#define HX8357_DISPOFF 0x28
|
||||
#define HX8357_DISPON 0x29
|
||||
|
||||
#define HX8357_CASET 0x2A
|
||||
#define HX8357_PASET 0x2B
|
||||
#define HX8357_RAMWR 0x2C
|
||||
#define HX8357_RAMRD 0x2E
|
||||
|
||||
#define HX8357_TEON 0x35
|
||||
#define HX8357_TEARLINE 0x44
|
||||
#define HX8357_MADCTL 0x36
|
||||
#define HX8357_COLMOD 0x3A
|
||||
|
||||
#define HX8357_SETOSC 0xB0
|
||||
#define HX8357_SETPWR1 0xB1
|
||||
#define HX8357_SETRGB 0xB3
|
||||
#define HX8357D_SETCOM 0xB6
|
||||
|
||||
#define HX8357D_SETCYC 0xB4
|
||||
#define HX8357D_SETC 0xB9
|
||||
|
||||
#define HX8357D_SETSTBA 0xC0
|
||||
|
||||
#define HX8357_SETPANEL 0xCC
|
||||
|
||||
#define HX8357D_SETGAMMA 0xE0
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
|
||||
// This is the command sequence that initialises the HX8357D driver
|
||||
//
|
||||
// This setup information uses simple 8 bit SPI writecommand() and writedata() functions
|
||||
//
|
||||
// See ST7735_Setup.h file for an alternative format
|
||||
|
||||
|
||||
// Configure HX8357D display
|
||||
|
||||
// setextc
|
||||
writecommand(HX8357D_SETC);
|
||||
writedata(0xFF);
|
||||
writedata(0x83);
|
||||
writedata(0x57);
|
||||
delay(300);
|
||||
|
||||
// setRGB which also enables SDO
|
||||
writecommand(HX8357_SETRGB);
|
||||
writedata(0x80); //enable SDO pin!
|
||||
// writedata(0x00); //disable SDO pin!
|
||||
writedata(0x0);
|
||||
writedata(0x06);
|
||||
writedata(0x06);
|
||||
|
||||
writecommand(HX8357D_SETCOM);
|
||||
writedata(0x25); // -1.52V
|
||||
|
||||
writecommand(HX8357_SETOSC);
|
||||
writedata(0x68); // Normal mode 70Hz, Idle mode 55 Hz
|
||||
|
||||
writecommand(HX8357_SETPANEL); //Set Panel
|
||||
writedata(0x05); // BGR, Gate direction swapped
|
||||
|
||||
writecommand(HX8357_SETPWR1);
|
||||
writedata(0x00); // Not deep standby
|
||||
writedata(0x15); //BT
|
||||
writedata(0x1C); //VSPR
|
||||
writedata(0x1C); //VSNR
|
||||
writedata(0x83); //AP
|
||||
writedata(0xAA); //FS
|
||||
|
||||
writecommand(HX8357D_SETSTBA);
|
||||
writedata(0x50); //OPON normal
|
||||
writedata(0x50); //OPON idle
|
||||
writedata(0x01); //STBA
|
||||
writedata(0x3C); //STBA
|
||||
writedata(0x1E); //STBA
|
||||
writedata(0x08); //GEN
|
||||
|
||||
writecommand(HX8357D_SETCYC);
|
||||
writedata(0x02); //NW 0x02
|
||||
writedata(0x40); //RTN
|
||||
writedata(0x00); //DIV
|
||||
writedata(0x2A); //DUM
|
||||
writedata(0x2A); //DUM
|
||||
writedata(0x0D); //GDON
|
||||
writedata(0x78); //GDOFF
|
||||
|
||||
writecommand(HX8357D_SETGAMMA);
|
||||
writedata(0x02);
|
||||
writedata(0x0A);
|
||||
writedata(0x11);
|
||||
writedata(0x1d);
|
||||
writedata(0x23);
|
||||
writedata(0x35);
|
||||
writedata(0x41);
|
||||
writedata(0x4b);
|
||||
writedata(0x4b);
|
||||
writedata(0x42);
|
||||
writedata(0x3A);
|
||||
writedata(0x27);
|
||||
writedata(0x1B);
|
||||
writedata(0x08);
|
||||
writedata(0x09);
|
||||
writedata(0x03);
|
||||
writedata(0x02);
|
||||
writedata(0x0A);
|
||||
writedata(0x11);
|
||||
writedata(0x1d);
|
||||
writedata(0x23);
|
||||
writedata(0x35);
|
||||
writedata(0x41);
|
||||
writedata(0x4b);
|
||||
writedata(0x4b);
|
||||
writedata(0x42);
|
||||
writedata(0x3A);
|
||||
writedata(0x27);
|
||||
writedata(0x1B);
|
||||
writedata(0x08);
|
||||
writedata(0x09);
|
||||
writedata(0x03);
|
||||
writedata(0x00);
|
||||
writedata(0x01);
|
||||
|
||||
writecommand(HX8357_COLMOD);
|
||||
writedata(0x55); // 16 bit
|
||||
|
||||
writecommand(HX8357_MADCTL);
|
||||
writedata(0xC0);
|
||||
|
||||
writecommand(HX8357_TEON); // TE off
|
||||
writedata(0x00);
|
||||
|
||||
writecommand(HX8357_TEARLINE); // tear line
|
||||
writedata(0x00);
|
||||
writedata(0x02);
|
||||
|
||||
writecommand(HX8357_SLPOUT); //Exit Sleep
|
||||
delay(150);
|
||||
|
||||
writecommand(HX8357_DISPON); // display on
|
||||
delay(50);
|
||||
|
||||
// End of HX8357D display configuration
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
// This is the command sequence that rotates the ILI9481 driver coordinate frame
|
||||
|
||||
writecommand(TFT_MADCTL);
|
||||
rotation = m % 4;
|
||||
switch (rotation) {
|
||||
case 0: // Portrait
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_RGB);
|
||||
_width = TFT_WIDTH;
|
||||
_height = TFT_HEIGHT;
|
||||
break;
|
||||
case 1: // Landscape (Portrait + 90)
|
||||
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_RGB);
|
||||
_width = TFT_HEIGHT;
|
||||
_height = TFT_WIDTH;
|
||||
break;
|
||||
case 2: // Inverter portrait
|
||||
writedata(TFT_MAD_RGB);
|
||||
_width = TFT_WIDTH;
|
||||
_height = TFT_HEIGHT;
|
||||
break;
|
||||
case 3: // Inverted landscape
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_RGB);
|
||||
_width = TFT_HEIGHT;
|
||||
_height = TFT_WIDTH;
|
||||
break;
|
||||
}
|
||||
|
|
@ -7,8 +7,8 @@
|
|||
switch (rotation) {
|
||||
case 0:
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR);
|
||||
_width = TFT_WIDTH;
|
||||
_height = TFT_HEIGHT;
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
#ifdef CGRAM_OFFSET
|
||||
colstart = 0;
|
||||
rowstart = 0;
|
||||
|
|
@ -16,8 +16,8 @@
|
|||
break;
|
||||
case 1:
|
||||
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_BGR);
|
||||
_width = TFT_HEIGHT;
|
||||
_height = TFT_WIDTH;
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
#ifdef CGRAM_OFFSET
|
||||
colstart = 0;
|
||||
rowstart = 0;
|
||||
|
|
@ -25,8 +25,8 @@
|
|||
break;
|
||||
case 2:
|
||||
writedata(TFT_MAD_BGR);
|
||||
_width = TFT_WIDTH;
|
||||
_height = TFT_HEIGHT;
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
#ifdef CGRAM_OFFSET
|
||||
colstart = 0;
|
||||
rowstart = 32;
|
||||
|
|
@ -34,8 +34,8 @@
|
|||
break;
|
||||
case 3:
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR);
|
||||
_width = TFT_HEIGHT;
|
||||
_height = TFT_WIDTH;
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
#ifdef CGRAM_OFFSET
|
||||
colstart = 32;
|
||||
rowstart = 0;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,11 @@
|
|||
writedata(0x86); //--
|
||||
|
||||
writecommand(ILI9341_MADCTL); // Memory Access Control
|
||||
writedata(0x48);
|
||||
#ifdef M5STACK
|
||||
writedata(0xA8); // Rotation 0 (portrait mode)
|
||||
#else
|
||||
writedata(0x48); // Rotation 0 (portrait mode)
|
||||
#endif
|
||||
|
||||
writecommand(ILI9341_PIXFMT);
|
||||
writedata(0x55);
|
||||
|
|
@ -116,4 +120,11 @@
|
|||
spi_begin();
|
||||
|
||||
writecommand(ILI9341_DISPON); //Display on
|
||||
|
||||
#ifdef M5STACK
|
||||
// Turn on the back-light LED
|
||||
digitalWrite(TFT_BL, HIGH);
|
||||
pinMode(TFT_BL, OUTPUT);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
@ -6,45 +6,77 @@
|
|||
writecommand(TFT_MADCTL);
|
||||
switch (rotation) {
|
||||
case 0:
|
||||
#ifdef M5STACK
|
||||
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR);
|
||||
#else
|
||||
writedata(TFT_MAD_MX | TFT_MAD_BGR);
|
||||
_width = TFT_WIDTH;
|
||||
_height = TFT_HEIGHT;
|
||||
#endif
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
break;
|
||||
case 1:
|
||||
#ifdef M5STACK
|
||||
writedata(TFT_MAD_BGR);
|
||||
#else
|
||||
writedata(TFT_MAD_MV | TFT_MAD_BGR);
|
||||
_width = TFT_HEIGHT;
|
||||
_height = TFT_WIDTH;
|
||||
#endif
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
break;
|
||||
case 2:
|
||||
#ifdef M5STACK
|
||||
writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_BGR);
|
||||
#else
|
||||
writedata(TFT_MAD_MY | TFT_MAD_BGR);
|
||||
_width = TFT_WIDTH;
|
||||
_height = TFT_HEIGHT;
|
||||
#endif
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
break;
|
||||
case 3:
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR);
|
||||
_width = TFT_HEIGHT;
|
||||
_height = TFT_WIDTH;
|
||||
break;
|
||||
// These next rotations are for bottum up BMP drawing
|
||||
case 4:
|
||||
#ifdef M5STACK
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR);
|
||||
_width = TFT_WIDTH;
|
||||
_height = TFT_HEIGHT;
|
||||
#else
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR);
|
||||
#endif
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
break;
|
||||
// These next rotations are for bottom up BMP drawing
|
||||
case 4:
|
||||
#ifdef M5STACK
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR);
|
||||
#else
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR);
|
||||
#endif
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
break;
|
||||
case 5:
|
||||
#ifdef M5STACK
|
||||
writedata(TFT_MAD_MY | TFT_MAD_BGR);
|
||||
#else
|
||||
writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_BGR);
|
||||
_width = TFT_HEIGHT;
|
||||
_height = TFT_WIDTH;
|
||||
#endif
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
break;
|
||||
case 6:
|
||||
#ifdef M5STACK
|
||||
writedata(TFT_MAD_MV | TFT_MAD_BGR);
|
||||
#else
|
||||
writedata(TFT_MAD_BGR);
|
||||
_width = TFT_WIDTH;
|
||||
_height = TFT_HEIGHT;
|
||||
#endif
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
break;
|
||||
case 7:
|
||||
#ifdef M5STACK
|
||||
writedata(TFT_MAD_MX | TFT_MAD_BGR);
|
||||
#else
|
||||
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR);
|
||||
_width = TFT_HEIGHT;
|
||||
_height = TFT_WIDTH;
|
||||
#endif
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
// Change the width and height if required (defined in portrait mode)
|
||||
// or use the constructor to over-ride defaults
|
||||
#define TFT_WIDTH 320
|
||||
#define TFT_HEIGHT 480
|
||||
|
||||
|
||||
// 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_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_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
|
||||
|
||||
#define TFT_IDXRD 0x00 // ILI9341 only, indexed control register read
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
|
||||
// This is the command sequence that initialises the ILI9481 driver
|
||||
//
|
||||
// This setup information uses simple 8 bit SPI writecommand() and writedata() functions
|
||||
//
|
||||
// See ST7735_Setup.h file for an alternative format
|
||||
|
||||
|
||||
// Configure ILI9481 display
|
||||
|
||||
writecommand(TFT_SLPOUT);
|
||||
delay(20);
|
||||
|
||||
writecommand(0xD0);
|
||||
writedata(0x07);
|
||||
writedata(0x42);
|
||||
writedata(0x18);
|
||||
|
||||
writecommand(0xD1);
|
||||
writedata(0x00);
|
||||
writedata(0x07);
|
||||
writedata(0x10);
|
||||
|
||||
writecommand(0xD2);
|
||||
writedata(0x01);
|
||||
writedata(0x02);
|
||||
|
||||
writecommand(0xC0);
|
||||
writedata(0x10);
|
||||
writedata(0x3B);
|
||||
writedata(0x00);
|
||||
writedata(0x02);
|
||||
writedata(0x11);
|
||||
|
||||
writecommand(0xC5);
|
||||
writedata(0x03);
|
||||
|
||||
writecommand(0xC8);
|
||||
writedata(0x00);
|
||||
writedata(0x32);
|
||||
writedata(0x36);
|
||||
writedata(0x45);
|
||||
writedata(0x06);
|
||||
writedata(0x16);
|
||||
writedata(0x37);
|
||||
writedata(0x75);
|
||||
writedata(0x77);
|
||||
writedata(0x54);
|
||||
writedata(0x0C);
|
||||
writedata(0x00);
|
||||
|
||||
writecommand(TFT_MADCTL);
|
||||
writedata(0x0A);
|
||||
|
||||
writecommand(0x3A);
|
||||
writedata(0x55);
|
||||
|
||||
writecommand(TFT_CASET);
|
||||
writedata(0x00);
|
||||
writedata(0x00);
|
||||
writedata(0x01);
|
||||
writedata(0x3F);
|
||||
|
||||
writecommand(TFT_PASET);
|
||||
writedata(0x00);
|
||||
writedata(0x00);
|
||||
writedata(0x01);
|
||||
writedata(0xDF);
|
||||
|
||||
delay(120);
|
||||
writecommand(TFT_DISPON);
|
||||
|
||||
delay(25);
|
||||
// End of ILI9481 display configuration
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
// This is the command sequence that rotates the ILI9481 driver coordinate frame
|
||||
|
||||
writecommand(TFT_MADCTL);
|
||||
rotation = m % 4;
|
||||
switch (rotation) {
|
||||
case 0: // Portrait
|
||||
writedata(TFT_MAD_BGR | TFT_MAD_SS);
|
||||
_width = TFT_WIDTH;
|
||||
_height = TFT_HEIGHT;
|
||||
break;
|
||||
case 1: // Landscape (Portrait + 90)
|
||||
writedata(TFT_MAD_MV | TFT_MAD_BGR);
|
||||
_width = TFT_HEIGHT;
|
||||
_height = TFT_WIDTH;
|
||||
break;
|
||||
case 2: // Inverter portrait
|
||||
writedata(TFT_MAD_BGR | TFT_MAD_GS);
|
||||
_width = TFT_WIDTH;
|
||||
_height = TFT_HEIGHT;
|
||||
break;
|
||||
case 3: // Inverted landscape
|
||||
writedata(TFT_MAD_MV | TFT_MAD_BGR | TFT_MAD_SS | TFT_MAD_GS);
|
||||
_width = TFT_HEIGHT;
|
||||
_height = TFT_WIDTH;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
// Change the width and height if required (defined in portrait mode)
|
||||
// or use the constructor to over-ride defaults
|
||||
#define TFT_WIDTH 320
|
||||
#define TFT_HEIGHT 480
|
||||
|
||||
|
||||
// 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_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_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
|
||||
|
||||
#define TFT_IDXRD 0x00 // ILI9341 only, indexed control register read
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
|
||||
// This is the command sequence that initialises the ILI9488 driver
|
||||
//
|
||||
// This setup information uses simple 8 bit SPI writecommand() and writedata() functions
|
||||
//
|
||||
// See ST7735_Setup.h file for an alternative format
|
||||
|
||||
|
||||
// Configure ILI9488 display
|
||||
|
||||
writecommand(0x3A); // Pixel Interface Format (16 bit colour)
|
||||
writedata(0x55);
|
||||
|
||||
writecommand(0xB0); // Interface Mode Control
|
||||
writedata(0x00);
|
||||
|
||||
writecommand(0xB1); // Frame Rate Control
|
||||
writedata(0xB0);
|
||||
writedata(0x11);
|
||||
|
||||
writecommand(0xB4); // Display Inversion Control
|
||||
writedata(0x02);
|
||||
|
||||
writecommand(0xB6); // Display Function Control
|
||||
writedata(0x02);
|
||||
writedata(0x02);
|
||||
writedata(0x3B);
|
||||
|
||||
writecommand(0xB7); // Entry Mode Set
|
||||
writedata(0xC6);
|
||||
|
||||
writecommand(0XC0); // Power Control 1
|
||||
writedata(0x10);
|
||||
writedata(0x10);
|
||||
|
||||
writecommand(0xC1); // Power Control 2
|
||||
writedata(0x41);
|
||||
|
||||
writecommand(0xC5); // VCOM Control
|
||||
writedata(0x00);
|
||||
writedata(0x22);
|
||||
writedata(0x80);
|
||||
writedata(0x40);
|
||||
|
||||
writecommand(0xE0); // Positive Gamma Control
|
||||
writedata(0x00);
|
||||
writedata(0x03);
|
||||
writedata(0x09);
|
||||
writedata(0x08);
|
||||
writedata(0x16);
|
||||
writedata(0x0A);
|
||||
writedata(0x3F);
|
||||
writedata(0x78);
|
||||
writedata(0x4C);
|
||||
writedata(0x09);
|
||||
writedata(0x0A);
|
||||
writedata(0x08);
|
||||
writedata(0x16);
|
||||
writedata(0x1A);
|
||||
writedata(0x0F);
|
||||
|
||||
writecommand(0XE1); // Negative Gamma Control
|
||||
writedata(0x00);
|
||||
writedata(0x16);
|
||||
writedata(0x19);
|
||||
writedata(0x03);
|
||||
writedata(0x0F);
|
||||
writedata(0x05);
|
||||
writedata(0x32);
|
||||
writedata(0x45);
|
||||
writedata(0x46);
|
||||
writedata(0x04);
|
||||
writedata(0x0E);
|
||||
writedata(0x0D);
|
||||
writedata(0x35);
|
||||
writedata(0x37);
|
||||
writedata(0x0F);
|
||||
|
||||
writecommand(0xF7); // Adjust Control 3
|
||||
writedata(0xA9);
|
||||
writedata(0x51);
|
||||
writedata(0x2C);
|
||||
writedata(0x02);
|
||||
|
||||
writecommand(TFT_MADCTL); // Memory Access Control
|
||||
writedata(0x48); // MX, BGR
|
||||
|
||||
writecommand(TFT_SLPOUT); //Exit Sleep
|
||||
delay(120);
|
||||
|
||||
writecommand(TFT_DISPON); //Display on
|
||||
delay(25);
|
||||
|
||||
// End of ILI9488 display configuration
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
// This is the command sequence that rotates the ILI9488 driver coordinate frame
|
||||
|
||||
writecommand(TFT_MADCTL);
|
||||
rotation = m % 4;
|
||||
switch (rotation) {
|
||||
case 0: // Portrait
|
||||
writedata(TFT_MAD_MX | TFT_MAD_BGR);
|
||||
_width = TFT_WIDTH;
|
||||
_height = TFT_HEIGHT;
|
||||
break;
|
||||
case 1: // Landscape (Portrait + 90)
|
||||
writedata(TFT_MAD_MV | TFT_MAD_BGR);
|
||||
_width = TFT_HEIGHT;
|
||||
_height = TFT_WIDTH;
|
||||
break;
|
||||
case 2: // Inverter portrait
|
||||
writedata(TFT_MAD_MY | TFT_MAD_BGR);
|
||||
_width = TFT_WIDTH;
|
||||
_height = TFT_HEIGHT;
|
||||
break;
|
||||
case 3: // Inverted landscape
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR);
|
||||
_width = TFT_HEIGHT;
|
||||
_height = TFT_WIDTH;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -5,43 +5,43 @@
|
|||
switch (rotation) {
|
||||
case 0: // Portrait
|
||||
writedata(TFT_MAD_BGR | TFT_MAD_MX);
|
||||
_width = TFT_WIDTH;
|
||||
_height = TFT_HEIGHT;
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
break;
|
||||
case 1: // Landscape (Portrait + 90)
|
||||
writedata(TFT_MAD_BGR | TFT_MAD_MV);
|
||||
_width = TFT_HEIGHT;
|
||||
_height = TFT_WIDTH;
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
break;
|
||||
case 2: // Inverter portrait
|
||||
writedata( TFT_MAD_BGR | TFT_MAD_MY);
|
||||
_width = TFT_WIDTH;
|
||||
_height = TFT_HEIGHT;
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
break;
|
||||
case 3: // Inverted landscape
|
||||
writedata(TFT_MAD_BGR | TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_MY);
|
||||
_width = TFT_HEIGHT;
|
||||
_height = TFT_WIDTH;
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
break;
|
||||
case 4: // Portrait
|
||||
writedata(TFT_MAD_BGR | TFT_MAD_MX | TFT_MAD_MY);
|
||||
_width = TFT_WIDTH;
|
||||
_height = TFT_HEIGHT;
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
break;
|
||||
case 5: // Landscape (Portrait + 90)
|
||||
writedata(TFT_MAD_BGR | TFT_MAD_MV | TFT_MAD_MX);
|
||||
_width = TFT_HEIGHT;
|
||||
_height = TFT_WIDTH;
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
break;
|
||||
case 6: // Inverter portrait
|
||||
writedata( TFT_MAD_BGR);
|
||||
_width = TFT_WIDTH;
|
||||
_height = TFT_HEIGHT;
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
break;
|
||||
case 7: // Inverted landscape
|
||||
writedata(TFT_MAD_BGR | TFT_MAD_MV | TFT_MAD_MY);
|
||||
_width = TFT_HEIGHT;
|
||||
_height = TFT_WIDTH;
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,22 +7,22 @@
|
|||
switch (rotation) {
|
||||
case 0:
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR);
|
||||
_width = TFT_WIDTH;
|
||||
_height = TFT_HEIGHT;
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
break;
|
||||
case 1:
|
||||
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_BGR);
|
||||
_width = TFT_HEIGHT;
|
||||
_height = TFT_WIDTH;
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
break;
|
||||
case 2:
|
||||
writedata(TFT_MAD_BGR);
|
||||
_width = TFT_WIDTH;
|
||||
_height = TFT_HEIGHT;
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
break;
|
||||
case 3:
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR);
|
||||
_width = TFT_HEIGHT;
|
||||
_height = TFT_WIDTH;
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
0x03, // 3 lines back porch
|
||||
10, // 10 ms delay
|
||||
ST7735_MADCTL , 1 , // 5: Memory access ctrl (directions), 1 arg:
|
||||
0x08, // Row addr/col addr, bottom to top refresh
|
||||
0x40, // Row addr/col addr, bottom to top refresh
|
||||
ST7735_DISSET5, 2 , // 6: Display settings #5, 2 args, no delay:
|
||||
0x15, // 1 clk cycle nonoverlap, 2 cycle gate
|
||||
// rise, 3 cycle osc equalize
|
||||
|
|
@ -140,8 +140,6 @@
|
|||
ST7735_DISPON , TFT_INIT_DELAY, // 4: Main screen turn on, no args w/delay
|
||||
100 }; // 100 ms delay
|
||||
|
||||
tabcolor = TAB_COLOUR;
|
||||
|
||||
if (tabcolor == INITB)
|
||||
{
|
||||
commandList(Bcmd);
|
||||
|
|
|
|||
|
|
@ -20,11 +20,13 @@
|
|||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MH | TFT_MAD_BGR);
|
||||
colstart = 0;
|
||||
rowstart = 32;
|
||||
} else {
|
||||
} else if(tabcolor == INITB) {
|
||||
writedata(TFT_MAD_MX | TFT_MAD_RGB);
|
||||
} else {
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR);
|
||||
}
|
||||
_width = TFT_WIDTH;
|
||||
_height = TFT_HEIGHT;
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
break;
|
||||
case 1:
|
||||
if (tabcolor == INITR_BLACKTAB) {
|
||||
|
|
@ -41,11 +43,13 @@
|
|||
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_BGR);
|
||||
colstart = 32;
|
||||
rowstart = 0;
|
||||
} else {
|
||||
} else if(tabcolor == INITB) {
|
||||
writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_RGB);
|
||||
} else {
|
||||
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR);
|
||||
}
|
||||
_width = TFT_HEIGHT;
|
||||
_height = TFT_WIDTH;
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
break;
|
||||
case 2:
|
||||
if (tabcolor == INITR_BLACKTAB) {
|
||||
|
|
@ -62,11 +66,13 @@
|
|||
writedata(TFT_MAD_BGR);
|
||||
colstart = 0;
|
||||
rowstart = 0;
|
||||
} else {
|
||||
} else if(tabcolor == INITB) {
|
||||
writedata(TFT_MAD_MY | TFT_MAD_RGB);
|
||||
} else {
|
||||
writedata(TFT_MAD_BGR);
|
||||
}
|
||||
_width = TFT_WIDTH;
|
||||
_height = TFT_HEIGHT;
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
break;
|
||||
case 3:
|
||||
if (tabcolor == INITR_BLACKTAB) {
|
||||
|
|
@ -83,33 +89,35 @@
|
|||
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR);
|
||||
colstart = 0;
|
||||
rowstart = 0;
|
||||
} else {
|
||||
} else if(tabcolor == INITB) {
|
||||
writedata(TFT_MAD_MV | TFT_MAD_RGB);
|
||||
} else {
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR);
|
||||
}
|
||||
_width = TFT_HEIGHT;
|
||||
_height = TFT_WIDTH;
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
break;
|
||||
|
||||
// These next rotations are for bottum up BMP drawing
|
||||
/* case 4:
|
||||
writedata(ST7735_TFT_MAD_MX | ST7735_TFT_MAD_MY | ST7735_TFT_MAD_BGR);
|
||||
_width = TFT_WIDTH;
|
||||
_height = TFT_HEIGHT;
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
break;
|
||||
case 5:
|
||||
writedata(ST7735_TFT_MAD_MV | ST7735_TFT_MAD_MX | ST7735_TFT_MAD_BGR);
|
||||
_width = TFT_HEIGHT;
|
||||
_height = TFT_WIDTH;
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
break;
|
||||
case 6:
|
||||
writedata(ST7735_TFT_MAD_BGR);
|
||||
_width = TFT_WIDTH;
|
||||
_height = TFT_HEIGHT;
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
break;
|
||||
case 7:
|
||||
writedata(ST7735_TFT_MAD_MY | ST7735_TFT_MAD_MV | ST7735_TFT_MAD_BGR);
|
||||
_width = TFT_HEIGHT;
|
||||
_height = TFT_WIDTH;
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
break;
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
// Change the width and height if required (defined in portrait mode)
|
||||
// or use the constructor to over-ride defaults
|
||||
#define TFT_WIDTH 240
|
||||
#define TFT_HEIGHT 240
|
||||
|
||||
|
||||
// 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
|
||||
|
||||
#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
|
||||
|
||||
#define TFT_IDXRD 0x00 // ILI9341 only, indexed control register read
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
// This is the command sequence that initialises the ST7789 driver
|
||||
|
||||
// Configure ST7789 display
|
||||
{
|
||||
static const uint8_t PROGMEM
|
||||
st7789[] = {
|
||||
9,
|
||||
TFT_SWRST, TFT_INIT_DELAY, 150,
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
// This is the command sequence that rotates the ST7789 driver coordinate frame
|
||||
|
||||
writecommand(TFT_MADCTL);
|
||||
rotation = m % 4;
|
||||
switch (rotation) {
|
||||
case 0: // Portrait
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_RGB);
|
||||
_width = TFT_WIDTH;
|
||||
_height = TFT_HEIGHT;
|
||||
break;
|
||||
case 1: // Landscape (Portrait + 90)
|
||||
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_RGB);
|
||||
_width = TFT_HEIGHT;
|
||||
_height = TFT_WIDTH;
|
||||
break;
|
||||
case 2: // Inverter portrait
|
||||
writedata(TFT_MAD_RGB);
|
||||
_width = TFT_WIDTH;
|
||||
_height = TFT_HEIGHT;
|
||||
break;
|
||||
case 3: // Inverted landscape
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_RGB);
|
||||
_width = TFT_HEIGHT;
|
||||
_height = TFT_WIDTH;
|
||||
break;
|
||||
}
|
||||
2439
TFT_eSPI.cpp
2439
TFT_eSPI.cpp
File diff suppressed because it is too large
Load Diff
452
TFT_eSPI.h
452
TFT_eSPI.h
|
|
@ -1,13 +1,9 @@
|
|||
/***************************************************
|
||||
Arduino TFT graphics library targetted at ESP8266
|
||||
based boards. (ESP32 support is planned!)
|
||||
|
||||
This library has been derived from the Adafruit_GFX
|
||||
library and the associated driver library. See text
|
||||
at the end of this file.
|
||||
Arduino TFT graphics library targeted at ESP8266
|
||||
and ESP32 based boards.
|
||||
|
||||
This is a standalone library that contains the
|
||||
hardware driver, the graphics funtions and the
|
||||
hardware driver, the graphics functions and the
|
||||
proportional fonts.
|
||||
|
||||
The larger fonts are Run Length Encoded to reduce
|
||||
|
|
@ -25,11 +21,28 @@
|
|||
// available and the pins to be used
|
||||
#include <User_Setup_Select.h>
|
||||
|
||||
#ifndef TAB_COLOUR
|
||||
#define TAB_COLOUR 0
|
||||
#endif
|
||||
|
||||
// If the frequency is not defined, set a default
|
||||
#ifndef SPI_FREQUENCY
|
||||
#define SPI_FREQUENCY 20000000
|
||||
#endif
|
||||
|
||||
// If the frequency is not defined, set a default
|
||||
#ifndef SPI_TOUCH_FREQUENCY
|
||||
#define SPI_TOUCH_FREQUENCY 2500000
|
||||
#endif
|
||||
|
||||
// Use GLCD font in error case where user requests a smooth font file
|
||||
// that does not exist (this is a temporary fix to stop ESP32 reboot)
|
||||
#ifdef SMOOTH_FONT
|
||||
#ifndef LOAD_GLCD
|
||||
#define LOAD_GLCD
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Only load the fonts defined in User_Setup.h (to save space)
|
||||
// Set flag so RLE rendering code is optionally compiled
|
||||
#ifdef LOAD_GLCD
|
||||
|
|
@ -64,6 +77,12 @@
|
|||
#ifndef LOAD_RLE
|
||||
#define LOAD_RLE
|
||||
#endif
|
||||
#elif defined LOAD_FONT8N
|
||||
#define LOAD_FONT8
|
||||
#include <Fonts/Font72x53rle.h>
|
||||
#ifndef LOAD_RLE
|
||||
#define LOAD_RLE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <Arduino.h>
|
||||
|
|
@ -73,17 +92,50 @@
|
|||
|
||||
#include <SPI.h>
|
||||
|
||||
#if defined (ESP8266) && defined (D0_USED_FOR_DC)
|
||||
#define DC_C digitalWrite(TFT_DC, LOW)
|
||||
#define DC_D digitalWrite(TFT_DC, HIGH)
|
||||
#elif defined (ESP32)
|
||||
//#define DC_C digitalWrite(TFT_DC, HIGH); GPIO.out_w1tc = (1 << TFT_DC)//digitalWrite(TFT_DC, LOW)
|
||||
//#define DC_D digitalWrite(TFT_DC, LOW); GPIO.out_w1ts = (1 << TFT_DC)//digitalWrite(TFT_DC, HIGH)
|
||||
#define DC_C GPIO.out_w1ts = (1 << TFT_DC); GPIO.out_w1ts = (1 << TFT_DC); GPIO.out_w1tc = (1 << TFT_DC)
|
||||
#define DC_D GPIO.out_w1tc = (1 << TFT_DC); GPIO.out_w1ts = (1 << TFT_DC)
|
||||
#ifdef SMOOTH_FONT
|
||||
// Call up the SPIFFS FLASH filing system for the anti-aliased fonts
|
||||
#define FS_NO_GLOBALS
|
||||
#include <FS.h>
|
||||
|
||||
#ifdef ESP32
|
||||
#include "SPIFFS.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef TFT_DC
|
||||
#define DC_C // No macro allocated so it generates no code
|
||||
#define DC_D // No macro allocated so it generates no code
|
||||
#else
|
||||
#define DC_C GPOC=dcpinmask
|
||||
#define DC_D GPOS=dcpinmask
|
||||
#if defined (ESP8266) && defined (D0_USED_FOR_DC)
|
||||
#define DC_C digitalWrite(TFT_DC, LOW)
|
||||
#define DC_D digitalWrite(TFT_DC, HIGH)
|
||||
#elif defined (ESP32)
|
||||
#if defined (ESP32_PARALLEL)
|
||||
#define DC_C GPIO.out_w1tc = (1 << TFT_DC)
|
||||
#define DC_D GPIO.out_w1ts = (1 << TFT_DC)
|
||||
|
||||
#else
|
||||
#if TFT_DC >= 32
|
||||
#define DC_C GPIO.out1_w1ts.val = (1 << (TFT_DC - 32)); \
|
||||
GPIO.out1_w1tc.val = (1 << (TFT_DC - 32))
|
||||
#define DC_D GPIO.out1_w1tc.val = (1 << (TFT_DC - 32)); \
|
||||
GPIO.out1_w1ts.val = (1 << (TFT_DC - 32))
|
||||
#else
|
||||
#if TFT_DC >= 0
|
||||
#define DC_C GPIO.out_w1ts = (1 << TFT_DC); \
|
||||
GPIO.out_w1tc = (1 << TFT_DC)
|
||||
#define DC_D GPIO.out_w1tc = (1 << TFT_DC); \
|
||||
GPIO.out_w1ts = (1 << TFT_DC)
|
||||
#else
|
||||
#define DC_C
|
||||
#define DC_D
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#define DC_C GPOC=dcpinmask
|
||||
#define DC_D GPOS=dcpinmask
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (TFT_SPI_OVERLAP)
|
||||
|
|
@ -98,10 +150,25 @@
|
|||
#define CS_L digitalWrite(TFT_CS, LOW)
|
||||
#define CS_H digitalWrite(TFT_CS, HIGH)
|
||||
#elif defined (ESP32)
|
||||
//#define CS_L digitalWrite(TFT_CS, HIGH); GPIO.out_w1tc = (1 << TFT_CS)//digitalWrite(TFT_CS, LOW)
|
||||
//#define CS_H digitalWrite(TFT_CS, LOW); GPIO.out_w1ts = (1 << TFT_CS)//digitalWrite(TFT_CS, HIGH)
|
||||
#define CS_L GPIO.out_w1ts = (1 << TFT_CS);GPIO.out_w1tc = (1 << TFT_CS)
|
||||
#define CS_H GPIO.out_w1ts = (1 << TFT_CS)
|
||||
#if defined (ESP32_PARALLEL)
|
||||
#define CS_L // The TFT CS is set permanently low during init()
|
||||
#define CS_H
|
||||
#else
|
||||
#if TFT_CS >= 32
|
||||
#define CS_L GPIO.out1_w1ts.val = (1 << (TFT_CS - 32)); \
|
||||
GPIO.out1_w1tc.val = (1 << (TFT_CS - 32))
|
||||
#define CS_H GPIO.out1_w1tc.val = (1 << (TFT_CS - 32)); \
|
||||
GPIO.out1_w1ts.val = (1 << (TFT_CS - 32))
|
||||
#else
|
||||
#if TFT_CS >= 0
|
||||
#define CS_L GPIO.out_w1ts = (1 << TFT_CS);GPIO.out_w1tc = (1 << TFT_CS)
|
||||
#define CS_H GPIO.out_w1tc = (1 << TFT_CS);GPIO.out_w1ts = (1 << TFT_CS)
|
||||
#else
|
||||
#define CS_L
|
||||
#define CS_H
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#define CS_L GPOC=cspinmask
|
||||
#define CS_H GPOS=cspinmask
|
||||
|
|
@ -113,23 +180,76 @@
|
|||
#define T_CS_L // No macro allocated so it generates no code
|
||||
#define T_CS_H // No macro allocated so it generates no code
|
||||
#else
|
||||
#define T_CS_L digitalWrite(TOUCH_CS, LOW)
|
||||
#define T_CS_H digitalWrite(TOUCH_CS, HIGH)
|
||||
#define T_CS_L digitalWrite(TOUCH_CS, LOW)
|
||||
#define T_CS_H digitalWrite(TOUCH_CS, HIGH)
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef TFT_WR
|
||||
#if defined (ESP32)
|
||||
#define WR_L GPIO.out_w1tc = (1 << TFT_WR)
|
||||
//digitalWrite(TFT_WR, LOW)
|
||||
#define WR_H GPIO.out_w1ts = (1 << TFT_WR)
|
||||
//digitalWrite(TFT_WR, HIGH)
|
||||
#else
|
||||
#define WR_L GPOC=wrpinmask
|
||||
#define WR_H GPOS=wrpinmask
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined (ESP32) && defined (ESP32_PARALLEL)
|
||||
// Mask for the 8 data bits to set pin directions
|
||||
#define dir_mask ((1 << TFT_D0) | (1 << TFT_D1) | (1 << TFT_D2) | (1 << TFT_D3) | (1 << TFT_D4) | (1 << TFT_D5) | (1 << TFT_D6) | (1 << TFT_D7))
|
||||
|
||||
// Data bits and the write line are cleared to 0 in one step
|
||||
#define clr_mask (dir_mask | (1 << TFT_WR))
|
||||
|
||||
// A lookup table is used to set the different bit patterns, this uses 1kByte of RAM
|
||||
#define set_mask(C) xset_mask[C] // 63fps Sprite rendering test 33% faster, graphicstest only 1.8% faster than shifting in real time
|
||||
|
||||
// Real-time shifting alternative to above to save 1KByte RAM, 47 fps Sprite rendering test
|
||||
//#define set_mask(C) ((C&0x80)>>7)<<TFT_D7 | ((C&0x40)>>6)<<TFT_D6 | ((C&0x20)>>5)<<TFT_D5 | ((C&0x10)>>4)<<TFT_D4 | \
|
||||
((C&0x08)>>3)<<TFT_D3 | ((C&0x04)>>2)<<TFT_D2 | ((C&0x02)>>1)<<TFT_D1 | ((C&0x01)>>0)<<TFT_D0
|
||||
|
||||
// Write 8 bits to TFT
|
||||
#define tft_Write_8(C) GPIO.out_w1tc = clr_mask; GPIO.out_w1ts = set_mask((uint8_t)C); WR_H
|
||||
|
||||
// Write 16 bits to TFT
|
||||
#ifdef PSEUDO_8_BIT
|
||||
#define tft_Write_16(C) WR_L;GPIO.out_w1tc = clr_mask; GPIO.out_w1ts = set_mask((uint8_t)(C >> 0)); WR_H
|
||||
#else
|
||||
#define tft_Write_16(C) GPIO.out_w1tc = clr_mask; GPIO.out_w1ts = set_mask((uint8_t)(C >> 8)); WR_H; \
|
||||
GPIO.out_w1tc = clr_mask; GPIO.out_w1ts = set_mask((uint8_t)(C >> 0)); WR_H
|
||||
#endif
|
||||
|
||||
// 16 bit write with swapped bytes
|
||||
#define tft_Write_16S(C) GPIO.out_w1tc = clr_mask; GPIO.out_w1ts = set_mask((uint8_t) (C >> 0)); WR_H; \
|
||||
GPIO.out_w1tc = clr_mask; GPIO.out_w1ts = set_mask((uint8_t) (C >> 8)); WR_H
|
||||
|
||||
// Write 32 bits to TFT
|
||||
#define tft_Write_32(C) GPIO.out_w1tc = clr_mask; GPIO.out_w1ts = set_mask((uint8_t) (C >> 24)); WR_H; \
|
||||
GPIO.out_w1tc = clr_mask; GPIO.out_w1ts = set_mask((uint8_t) (C >> 16)); WR_H; \
|
||||
GPIO.out_w1tc = clr_mask; GPIO.out_w1ts = set_mask((uint8_t) (C >> 8)); WR_H; \
|
||||
GPIO.out_w1tc = clr_mask; GPIO.out_w1ts = set_mask((uint8_t) (C >> 0)); WR_H
|
||||
|
||||
#ifdef TFT_RD
|
||||
#define RD_L GPIO.out_w1tc = (1 << TFT_RD)
|
||||
//#define RD_L digitalWrite(TFT_WR, LOW)
|
||||
#define RD_H GPIO.out_w1ts = (1 << TFT_RD)
|
||||
//#define RD_H digitalWrite(TFT_WR, HIGH)
|
||||
#endif
|
||||
|
||||
#elif defined (RPI_ILI9486_DRIVER)
|
||||
#define tft_Write_8(C) SPI.transfer(0); SPI.transfer(C)
|
||||
#define tft_Write_16(C) SPI.write16(C)
|
||||
#define tft_Write_32(C) SPI.write32(C)
|
||||
|
||||
#else
|
||||
#define tft_Write_8(C) SPI.transfer(C)
|
||||
#define tft_Write_16(C) SPI.write16(C)
|
||||
#define tft_Write_32(C) SPI.write32(C)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef LOAD_GFXFF
|
||||
// We can include all the free fonts and they will only be built into
|
||||
// the sketch if they are used
|
||||
|
|
@ -241,18 +361,78 @@
|
|||
#define TFT_MAGENTA 0xF81F /* 255, 0, 255 */
|
||||
#define TFT_YELLOW 0xFFE0 /* 255, 255, 0 */
|
||||
#define TFT_WHITE 0xFFFF /* 255, 255, 255 */
|
||||
#define TFT_ORANGE 0xFD20 /* 255, 165, 0 */
|
||||
#define TFT_GREENYELLOW 0xAFE5 /* 173, 255, 47 */
|
||||
#define TFT_PINK 0xF81F
|
||||
#define TFT_ORANGE 0xFDA0 /* 255, 180, 0 */
|
||||
#define TFT_GREENYELLOW 0xB7E0 /* 180, 255, 0 */
|
||||
#define TFT_PINK 0xFC9F
|
||||
|
||||
// Next is a special 16 bit colour value that encodes to 8 bits
|
||||
// and will then decode back to the same 16 bit value.
|
||||
// Convenient for 8 bit and 16 bit transparent sprites.
|
||||
#define TFT_TRANSPARENT 0x0120
|
||||
|
||||
// Swap any type
|
||||
template <typename T> static inline void
|
||||
swap_coord(T& a, T& b) { T t = a; a = b; b = t; }
|
||||
|
||||
// This is a structure to conveniently hold infomation on the default fonts
|
||||
#ifndef min
|
||||
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
// This structure allows sketches to retrieve the user setup parameters at runtime
|
||||
// by calling getSetup(), zero impact on code size unless used, mainly for diagnostics
|
||||
typedef struct
|
||||
{
|
||||
int16_t esp;
|
||||
uint8_t trans;
|
||||
uint8_t serial;
|
||||
uint8_t overlap;
|
||||
|
||||
uint16_t tft_driver; // Hexadecimal code
|
||||
uint16_t tft_width; // Rotation 0 width and height
|
||||
uint16_t tft_height;
|
||||
|
||||
uint8_t r0_x_offset; // Offsets, not all used yet
|
||||
uint8_t r0_y_offset;
|
||||
uint8_t r1_x_offset;
|
||||
uint8_t r1_y_offset;
|
||||
uint8_t r2_x_offset;
|
||||
uint8_t r2_y_offset;
|
||||
uint8_t r3_x_offset;
|
||||
uint8_t r3_y_offset;
|
||||
|
||||
int8_t pin_tft_mosi;
|
||||
int8_t pin_tft_miso;
|
||||
int8_t pin_tft_clk;
|
||||
int8_t pin_tft_cs;
|
||||
|
||||
int8_t pin_tft_dc;
|
||||
int8_t pin_tft_rd;
|
||||
int8_t pin_tft_wr;
|
||||
int8_t pin_tft_rst;
|
||||
|
||||
int8_t pin_tft_d0;
|
||||
int8_t pin_tft_d1;
|
||||
int8_t pin_tft_d2;
|
||||
int8_t pin_tft_d3;
|
||||
int8_t pin_tft_d4;
|
||||
int8_t pin_tft_d5;
|
||||
int8_t pin_tft_d6;
|
||||
int8_t pin_tft_d7;
|
||||
|
||||
int8_t pin_tch_cs;
|
||||
|
||||
int16_t tft_spi_freq;
|
||||
int16_t tch_spi_freq;
|
||||
} setup_t;
|
||||
|
||||
// This is a structure to conveniently hold information on the default fonts
|
||||
// Stores pointer to font character image address table, width table and height
|
||||
|
||||
// Create a null set in case some fonts not used (to prevent crash)
|
||||
const uint8_t widtbl_null[1] = {0};
|
||||
PROGMEM const uint8_t chr_null[1] = {0};
|
||||
PROGMEM const uint8_t* const chrtbl_null[1] = {chr_null};
|
||||
|
||||
typedef struct {
|
||||
const uint8_t *chartbl;
|
||||
const uint8_t *widthtbl;
|
||||
|
|
@ -262,50 +442,52 @@ typedef struct {
|
|||
|
||||
// Now fill the structure
|
||||
const PROGMEM fontinfo fontdata [] = {
|
||||
{ 0, 0, 0, 0 },
|
||||
|
||||
#ifdef LOAD_GLCD
|
||||
{ (const uint8_t *)font, widtbl_null, 0, 0 },
|
||||
#else
|
||||
{ (const uint8_t *)chrtbl_null, widtbl_null, 0, 0 },
|
||||
#endif
|
||||
// GLCD font (Font 1) does not have all parameters
|
||||
{ 0, 0, 8, 7 },
|
||||
{ (const uint8_t *)chrtbl_null, widtbl_null, 8, 7 },
|
||||
|
||||
#ifdef LOAD_FONT2
|
||||
{ (const uint8_t *)chrtbl_f16, widtbl_f16, chr_hgt_f16, baseline_f16},
|
||||
#else
|
||||
{ 0, 0, 0, 0 },
|
||||
{ (const uint8_t *)chrtbl_null, widtbl_null, 0, 0 },
|
||||
#endif
|
||||
|
||||
// Font 3 current unused
|
||||
{ 0, 0, 0, 0 },
|
||||
{ (const uint8_t *)chrtbl_null, widtbl_null, 0, 0 },
|
||||
|
||||
#ifdef LOAD_FONT4
|
||||
{ (const uint8_t *)chrtbl_f32, widtbl_f32, chr_hgt_f32, baseline_f32},
|
||||
#else
|
||||
{ 0, 0, 0, 0 },
|
||||
{ (const uint8_t *)chrtbl_null, widtbl_null, 0, 0 },
|
||||
#endif
|
||||
|
||||
// Font 5 current unused
|
||||
{ 0, 0, 0, 0 },
|
||||
{ (const uint8_t *)chrtbl_null, widtbl_null, 0, 0 },
|
||||
|
||||
#ifdef LOAD_FONT6
|
||||
{ (const uint8_t *)chrtbl_f64, widtbl_f64, chr_hgt_f64, baseline_f64},
|
||||
#else
|
||||
{ 0, 0, 0, 0 },
|
||||
{ (const uint8_t *)chrtbl_null, widtbl_null, 0, 0 },
|
||||
#endif
|
||||
|
||||
#ifdef LOAD_FONT7
|
||||
{ (const uint8_t *)chrtbl_f7s, widtbl_f7s, chr_hgt_f7s, baseline_f7s},
|
||||
#else
|
||||
{ 0, 0, 0, 0 },
|
||||
{ (const uint8_t *)chrtbl_null, widtbl_null, 0, 0 },
|
||||
#endif
|
||||
|
||||
#ifdef LOAD_FONT8
|
||||
{ (const uint8_t *)chrtbl_f72, widtbl_f72, chr_hgt_f72, baseline_f72}
|
||||
#else
|
||||
{ 0, 0, 0, 0 }
|
||||
{ (const uint8_t *)chrtbl_null, widtbl_null, 0, 0 }
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Class functions and variables
|
||||
class TFT_eSPI : public Print {
|
||||
|
||||
|
|
@ -313,27 +495,31 @@ class TFT_eSPI : public Print {
|
|||
|
||||
TFT_eSPI(int16_t _W = TFT_WIDTH, int16_t _H = TFT_HEIGHT);
|
||||
|
||||
void init(void), begin(void); // Same - begin included for backwards compatibility
|
||||
void init(uint8_t tc = TAB_COLOUR), begin(uint8_t tc = TAB_COLOUR); // Same - begin included for backwards compatibility
|
||||
|
||||
void drawPixel(uint32_t x, uint32_t y, uint32_t color);
|
||||
// These are virtual so the TFT_eSprite class can override them with sprite specific functions
|
||||
virtual void drawPixel(uint32_t x, uint32_t y, uint32_t color),
|
||||
drawChar(int32_t x, int32_t y, unsigned char c, uint32_t color, uint32_t bg, uint8_t size),
|
||||
drawLine(int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint32_t color),
|
||||
drawFastVLine(int32_t x, int32_t y, int32_t h, uint32_t color),
|
||||
drawFastHLine(int32_t x, int32_t y, int32_t w, uint32_t color),
|
||||
fillRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color);
|
||||
|
||||
void drawChar(int32_t x, int32_t y, unsigned char c, uint32_t color, uint32_t bg, uint8_t font),
|
||||
setWindow(int16_t x0, int16_t y0, int16_t x1, int16_t y1),
|
||||
virtual int16_t drawChar(unsigned int uniCode, int x, int y, int font),
|
||||
drawChar(unsigned int uniCode, int x, int y),
|
||||
height(void),
|
||||
width(void);
|
||||
|
||||
// The TFT_eSprite class inherits the following functions
|
||||
void setWindow(int16_t x0, int16_t y0, int16_t x1, int16_t y1),
|
||||
pushColor(uint16_t color),
|
||||
pushColor(uint16_t color, uint16_t len),
|
||||
|
||||
pushColors(uint16_t *data, uint8_t len),
|
||||
pushColors(uint16_t *data, uint32_t len, bool swap = true), // With byte swap option
|
||||
pushColors(uint8_t *data, uint32_t len),
|
||||
|
||||
fillScreen(uint32_t color),
|
||||
fillScreen(uint32_t color);
|
||||
|
||||
drawLine(int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint32_t color),
|
||||
drawFastVLine(int32_t x, int32_t y, int32_t h, uint32_t color),
|
||||
drawFastHLine(int32_t x, int32_t y, int32_t w, uint32_t color),
|
||||
|
||||
drawRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color),
|
||||
fillRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color),
|
||||
void drawRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color),
|
||||
drawRoundRect(int32_t x0, int32_t y0, int32_t w, int32_t h, int32_t radius, uint32_t color),
|
||||
fillRoundRect(int32_t x0, int32_t y0, int32_t w, int32_t h, int32_t radius, uint32_t color),
|
||||
|
||||
|
|
@ -352,6 +538,9 @@ class TFT_eSPI : public Print {
|
|||
fillTriangle(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t x2, int32_t y2, uint32_t color),
|
||||
|
||||
drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color),
|
||||
drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color),
|
||||
drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t fgcolor, uint16_t bgcolor),
|
||||
setBitmapColor(uint16_t c, uint16_t b), // For 1bpp sprites
|
||||
|
||||
setCursor(int16_t x, int16_t y),
|
||||
setCursor(int16_t x, int16_t y, uint8_t font),
|
||||
|
|
@ -359,7 +548,7 @@ class TFT_eSPI : public Print {
|
|||
setTextColor(uint16_t fgcolor, uint16_t bgcolor),
|
||||
setTextSize(uint8_t size),
|
||||
|
||||
setTextWrap(boolean wrap),
|
||||
setTextWrap(boolean wrapX, boolean wrapY = false),
|
||||
setTextDatum(uint8_t datum),
|
||||
setTextPadding(uint16_t x_width),
|
||||
|
||||
|
|
@ -373,6 +562,7 @@ class TFT_eSPI : public Print {
|
|||
spiwrite(uint8_t),
|
||||
writecommand(uint8_t c),
|
||||
writedata(uint8_t d),
|
||||
|
||||
commandList(const uint8_t *addr);
|
||||
|
||||
uint8_t readcommand8(uint8_t cmd_function, uint8_t index);
|
||||
|
|
@ -388,23 +578,43 @@ class TFT_eSPI : public Print {
|
|||
// Write a block of pixels to the screen
|
||||
void pushRect(uint32_t x0, uint32_t y0, uint32_t w, uint32_t h, uint16_t *data);
|
||||
|
||||
// These are used to render images or sprites stored in RAM arrays
|
||||
void pushImage(int32_t x0, int32_t y0, uint32_t w, uint32_t h, uint16_t *data);
|
||||
void pushImage(int32_t x0, int32_t y0, uint32_t w, uint32_t h, uint16_t *data, uint16_t transparent);
|
||||
|
||||
// These are used to render images stored in FLASH (PROGMEM)
|
||||
void pushImage(int32_t x0, int32_t y0, uint32_t w, uint32_t h, const uint16_t *data, uint16_t transparent);
|
||||
void pushImage(int32_t x0, int32_t y0, uint32_t w, uint32_t h, const uint16_t *data);
|
||||
|
||||
// These are used by pushSprite for 1 and 8 bit colours
|
||||
void pushImage(int32_t x0, int32_t y0, uint32_t w, uint32_t h, uint8_t *data, bool bpp8 = true);
|
||||
void pushImage(int32_t x0, int32_t y0, uint32_t w, uint32_t h, uint8_t *data, uint8_t transparent, bool bpp8 = true);
|
||||
|
||||
// Swap the byte order for pushImage() - corrects endianness
|
||||
void setSwapBytes(bool swap);
|
||||
bool getSwapBytes(void);
|
||||
|
||||
// This next function has been used successfully to dump the TFT screen to a PC for documentation purposes
|
||||
// It reads a screen area and returns the RGB 8 bit colour values of each pixel
|
||||
// Set w and h to 1 to read 1 pixel's colour. The data buffer must be at least w * h * 3 bytes
|
||||
void readRectRGB(int32_t x0, int32_t y0, int32_t w, int32_t h, uint8_t *data);
|
||||
|
||||
uint8_t getRotation(void);
|
||||
uint8_t getRotation(void),
|
||||
getTextDatum(void),
|
||||
color16to8(uint16_t color565); // Convert 16 bit colour to 8 bits
|
||||
|
||||
int16_t getCursorX(void),
|
||||
getCursorY(void);
|
||||
|
||||
uint16_t fontsLoaded(void),
|
||||
color565(uint8_t r, uint8_t g, uint8_t b);
|
||||
color565(uint8_t r, uint8_t g, uint8_t b),
|
||||
color8to16(uint8_t color332); // Convert 8 bit colour to 16 bits
|
||||
|
||||
int16_t drawChar(unsigned int uniCode, int x, int y, int font),
|
||||
drawChar(unsigned int uniCode, int x, int y),
|
||||
drawNumber(long long_num,int poX, int poY, int font),
|
||||
int16_t drawNumber(long long_num,int poX, int poY, int font),
|
||||
drawNumber(long long_num,int poX, int poY),
|
||||
drawFloat(float floatNumber,int decimal,int poX, int poY, int font),
|
||||
drawFloat(float floatNumber,int decimal,int poX, int poY),
|
||||
|
||||
|
||||
// Handle char arrays
|
||||
drawString(const char *string, int poX, int poY, int font),
|
||||
drawString(const char *string, int poX, int poY),
|
||||
|
|
@ -416,90 +626,90 @@ class TFT_eSPI : public Print {
|
|||
drawString(const String& string, int poX, int poY),
|
||||
drawCentreString(const String& string, int dX, int poY, int font), // Deprecated, use setTextDatum() and drawString()
|
||||
drawRightString(const String& string, int dX, int poY, int font); // Deprecated, use setTextDatum() and drawString()
|
||||
|
||||
int16_t height(void),
|
||||
width(void),
|
||||
textWidth(const char *string, int font),
|
||||
|
||||
int16_t textWidth(const char *string, int font),
|
||||
textWidth(const char *string),
|
||||
textWidth(const String& string, int font),
|
||||
textWidth(const String& string),
|
||||
fontHeight(int16_t font);
|
||||
|
||||
void setAddrWindow(int32_t xs, int32_t ys, int32_t xe, int32_t ye);
|
||||
void setAddrWindow(int32_t xs, int32_t ys, int32_t xe, int32_t ye);
|
||||
|
||||
#ifdef TOUCH_CS
|
||||
uint8_t getTouch(uint16_t *x, uint16_t *y);
|
||||
uint8_t getTouchRaw(uint16_t *x, uint16_t *y);
|
||||
uint8_t calibrateTouch(uint16_t *data, uint32_t color_bg, uint32_t color_fg, uint8_t size);
|
||||
void setTouch(uint16_t *data);
|
||||
#endif
|
||||
|
||||
virtual size_t write(uint8_t);
|
||||
size_t write(uint8_t);
|
||||
|
||||
private:
|
||||
void getSetup(setup_t& tft_settings); // Sketch provides the instance to populate
|
||||
|
||||
inline void spi_begin() __attribute__((always_inline));
|
||||
inline void spi_end() __attribute__((always_inline));
|
||||
int32_t cursor_x, cursor_y, padX;
|
||||
uint32_t textcolor, textbgcolor;
|
||||
|
||||
void readAddrWindow(int32_t xs, int32_t ys, int32_t xe, int32_t ye);
|
||||
|
||||
uint8_t tabcolor,
|
||||
colstart = 0, rowstart = 0; // some ST7735 displays need this changed
|
||||
uint32_t bitmap_fg, bitmap_bg;
|
||||
|
||||
volatile uint32_t *dcport, *csport;//, *mosiport, *clkport, *rsport;
|
||||
|
||||
uint32_t cspinmask, dcpinmask, wrpinmask;//, mosipinmask, clkpinmask;
|
||||
|
||||
uint32_t lastColor = 0xFFFF;
|
||||
|
||||
#ifdef TOUCH_CS
|
||||
uint16_t touchCalibration_x0, touchCalibration_x1, touchCalibration_y0, touchCalibration_y1;
|
||||
uint8_t touchCalibration_rotate, touchCalibration_invert_x, touchCalibration_invert_y;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
int32_t cursor_x, cursor_y, win_xe, win_ye, padX;
|
||||
|
||||
uint32_t _width, _height; // Display w/h as modified by current rotation
|
||||
uint32_t textcolor, textbgcolor, fontsloaded, addr_row, addr_col;
|
||||
|
||||
uint8_t glyph_ab, // glyph height above baseline
|
||||
glyph_bb, // glyph height below baseline
|
||||
textfont, // Current selected font
|
||||
uint8_t textfont, // Current selected font
|
||||
textsize, // Current font size multiplier
|
||||
textdatum, // Text reference datum
|
||||
rotation; // Display rotation (0-3)
|
||||
|
||||
boolean textwrap; // If set, 'wrap' text at right edge of display
|
||||
private:
|
||||
|
||||
boolean locked, inTransaction; // Transaction and mutex lock flags for ESP32
|
||||
inline void spi_begin() __attribute__((always_inline));
|
||||
inline void spi_end() __attribute__((always_inline));
|
||||
|
||||
void readAddrWindow(int32_t xs, int32_t ys, int32_t xe, int32_t ye);
|
||||
|
||||
uint8_t tabcolor,
|
||||
colstart = 0, rowstart = 0; // some ST7735 displays need this changed
|
||||
|
||||
volatile uint32_t *dcport, *csport;
|
||||
|
||||
uint32_t cspinmask, dcpinmask, wrpinmask;
|
||||
|
||||
#if defined(ESP32_PARALLEL)
|
||||
uint32_t xclr_mask, xdir_mask, xset_mask[256];
|
||||
#endif
|
||||
|
||||
uint32_t lastColor = 0xFFFF;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
int32_t win_xe, win_ye;
|
||||
|
||||
uint32_t _init_width, _init_height; // Display w/h as input, used by setRotation()
|
||||
uint32_t _width, _height; // Display w/h as modified by current rotation
|
||||
uint32_t addr_row, addr_col;
|
||||
|
||||
uint32_t fontsloaded;
|
||||
|
||||
uint8_t glyph_ab, // glyph height above baseline
|
||||
glyph_bb; // glyph height below baseline
|
||||
|
||||
bool textwrapX, textwrapY; // If set, 'wrap' text at right and optionally bottom edge of display
|
||||
bool _swapBytes; // Swap the byte order for TFT pushImage()
|
||||
bool locked, inTransaction; // Transaction and mutex lock flags for ESP32
|
||||
|
||||
int32_t _lastColor;
|
||||
|
||||
#ifdef LOAD_GFXFF
|
||||
GFXfont
|
||||
*gfxFont;
|
||||
GFXfont *gfxFont;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
// Load the Touch extension
|
||||
#ifdef TOUCH_CS
|
||||
#include "Extensions/Touch.h"
|
||||
#endif
|
||||
|
||||
/***************************************************
|
||||
// Load the Anti-aliased font extension
|
||||
#ifdef SMOOTH_FONT
|
||||
#include "Extensions/Smooth_font.h"
|
||||
#endif
|
||||
|
||||
ORIGINAL LIBRARY HEADER
|
||||
}; // End of class TFT_eSPI
|
||||
|
||||
This is our library for the Adafruit ILI9341 Breakout and Shield
|
||||
----> http://www.adafruit.com/products/1651
|
||||
// Load the Button Class
|
||||
#include "Extensions/Button.h"
|
||||
|
||||
Check out the links above for our tutorials and wiring diagrams
|
||||
These displays use SPI to communicate, 4 or 5 pins are required to
|
||||
interface (RST is optional)
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
// Load the Sprite Class
|
||||
#include "Extensions/Sprite.h"
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
MIT license, all text above must be included in any redistribution
|
||||
|
||||
Updated with new functions by Bodmer 14/4/15
|
||||
****************************************************/
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -0,0 +1,489 @@
|
|||
// This is a Processing sketch, see https://processing.org/ to download the IDE
|
||||
|
||||
// Select the character range in the user configure section starting at line 100
|
||||
|
||||
/*
|
||||
Software License Agreement (FreeBSD License)
|
||||
|
||||
Copyright (c) 2018 Bodmer (https://github.com/Bodmer)
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation are those
|
||||
of the authors and should not be interpreted as representing official policies,
|
||||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// This is a processing sketch to create font files for the TFT_eSPI library:
|
||||
|
||||
// https://github.com/Bodmer/TFT_eSPI
|
||||
|
||||
// Coded by Bodmer January 2018
|
||||
|
||||
// See comments below in code for specifying the font parameters
|
||||
// (point size, unicode blocks to include etc). Ranges of characers or
|
||||
// specific individual unicodes can be included in the created font file/
|
||||
|
||||
// Created fonts are saved in the sketches "FontFiles" folder. Press Ctrl+K to
|
||||
// see that folder.
|
||||
|
||||
// 16 bit unicodes in the range 0x0000 - 0xFFFF are supported.
|
||||
|
||||
// The sketch will convert True Type (a .ttf or .otf file) file stored in the
|
||||
// sketches "Data" folder as well as your computers system fonts.
|
||||
|
||||
// To maximise rendering performance only include the characters you will use.
|
||||
// Characters at the start of the file will render faster than those at the end.
|
||||
|
||||
// Once created the files must be loaded into the ESP32 or ESP8266 SPIFFS memory
|
||||
// using the Arduino IDE plugin detailed here:
|
||||
// https://github.com/esp8266/arduino-esp8266fs-plugin
|
||||
// https://github.com/me-no-dev/arduino-esp32fs-plugin
|
||||
|
||||
// The sketch list all the available PC fonts to the console, you may need to increase
|
||||
// console line count (in preferences.txt) to stop some fonts scrolling out of view.
|
||||
// See link in File>Preferences to locate "preferences.txt" file. You must close
|
||||
// Processing then edit the file lines. If Processing is not closed first then the
|
||||
// edits will be overwritten by defaults! Edit "preferences.txt" as follows for
|
||||
// 1000 lines, then save, then run Processing again:
|
||||
|
||||
/*
|
||||
console.length=1000 // Line 4 in file
|
||||
console.scrollback.lines=1000 // Line 7 in file
|
||||
*/
|
||||
|
||||
// Useful links:
|
||||
/*
|
||||
|
||||
https://en.wikipedia.org/wiki/Unicode_font
|
||||
|
||||
https://www.gnu.org/software/freefont/
|
||||
https://www.gnu.org/software/freefont/sources/
|
||||
https://www.gnu.org/software/freefont/ranges/
|
||||
http://savannah.gnu.org/projects/freefont/
|
||||
|
||||
http://www.google.com/get/noto/
|
||||
|
||||
https://github.com/Bodmer/TFT_eSPI
|
||||
https://github.com/esp8266/arduino-esp8266fs-plugin
|
||||
https://github.com/me-no-dev/arduino-esp32fs-plugin
|
||||
|
||||
*/
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
import java.awt.Desktop;
|
||||
|
||||
// >>>>>>>>>> USER CONFIGURED PARAMETERS START HERE <<<<<<<<<<
|
||||
|
||||
|
||||
// Use font name for ttf files placed in the "Data" folder or the font number seen in IDE Console for system fonts
|
||||
// the font numbers are listed when the sketch is run.
|
||||
// | 1 2 | Maximum filename size for SPIFFS is 32 including leading /
|
||||
// 1234567890123456789012345 and added point size and .vlw extension, so max is 25
|
||||
String fontName = "Final-Frontier"; //Manually crop the filename length later after creation if needed
|
||||
|
||||
String fontType = ".ttf"; //SPIFFS does not accept underscore in filename!
|
||||
//String fontType = ".otf";
|
||||
|
||||
// Use font number instead of name, -1 means use name above, or a value >=0 means use system font number from list.
|
||||
int fontNumber = -1; // << Use [Number] in brackets from the fonts listed in console window
|
||||
|
||||
// Define the font size in points for the created font file
|
||||
int fontSize = 28;
|
||||
|
||||
// Font size to use in the Processing sketch display window that pops up (can be different to above)
|
||||
int displayFontSize = 28;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Next we specify which unicode blocks from the the Basic Multilingual Plane (BMP) are included in the final font file. //
|
||||
// Note: The ttf/otf font file MAY NOT contain all possible Unicode characters, refer to the fonts online documentation. //
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static final int[] unicodeBlocks = {
|
||||
// The list below has been created from the table here: https://en.wikipedia.org/wiki/Unicode_block
|
||||
// Remove // at start of lines below to include that unicode block, different code ranges can also be specified by
|
||||
// editting the start and end of range values. Multiple lines from the list below can be included, limited only by
|
||||
// the final font file size!
|
||||
|
||||
// Block range, //Block name, Code points, Assigned characters, Scripts
|
||||
// First, last, //Range is inclusive of first and last codes
|
||||
0x0021, 0x007E, //Basic Latin, 128, 128, Latin (52 characters), Common (76 characters)
|
||||
//0x0080, 0x00FF, //Latin-1 Supplement, 128, 128, Latin (64 characters), Common (64 characters)
|
||||
//0x0100, 0x017F, //Latin Extended-A, 128, 128, Latin
|
||||
//0x0180, 0x024F, //Latin Extended-B, 208, 208, Latin
|
||||
//0x0250, 0x02AF, //IPA Extensions, 96, 96, Latin
|
||||
//0x02B0, 0x02FF, //Spacing Modifier Letters, 80, 80, Bopomofo (2 characters), Latin (14 characters), Common (64 characters)
|
||||
//0x0300, 0x036F, //Combining Diacritical Marks, 112, 112, Inherited
|
||||
//0x0370, 0x03FF, //Greek and Coptic, 144, 135, Coptic (14 characters), Greek (117 characters), Common (4 characters)
|
||||
//0x0400, 0x04FF, //Cyrillic, 256, 256, Cyrillic (254 characters), Inherited (2 characters)
|
||||
//0x0500, 0x052F, //Cyrillic Supplement, 48, 48, Cyrillic
|
||||
//0x0530, 0x058F, //Armenian, 96, 89, Armenian (88 characters), Common (1 character)
|
||||
//0x0590, 0x05FF, //Hebrew, 112, 87, Hebrew
|
||||
//0x0600, 0x06FF, //Arabic, 256, 255, Arabic (237 characters), Common (6 characters), Inherited (12 characters)
|
||||
//0x0700, 0x074F, //Syriac, 80, 77, Syriac
|
||||
//0x0750, 0x077F, //Arabic Supplement, 48, 48, Arabic
|
||||
//0x0780, 0x07BF, //Thaana, 64, 50, Thaana
|
||||
//0x07C0, 0x07FF, //NKo, 64, 59, Nko
|
||||
//0x0800, 0x083F, //Samaritan, 64, 61, Samaritan
|
||||
//0x0840, 0x085F, //Mandaic, 32, 29, Mandaic
|
||||
//0x0860, 0x086F, //Syriac Supplement, 16, 11, Syriac
|
||||
//0x08A0, 0x08FF, //Arabic Extended-A, 96, 73, Arabic (72 characters), Common (1 character)
|
||||
//0x0900, 0x097F, //Devanagari, 128, 128, Devanagari (124 characters), Common (2 characters), Inherited (2 characters)
|
||||
//0x0980, 0x09FF, //Bengali, 128, 95, Bengali
|
||||
//0x0A00, 0x0A7F, //Gurmukhi, 128, 79, Gurmukhi
|
||||
//0x0A80, 0x0AFF, //Gujarati, 128, 91, Gujarati
|
||||
//0x0B00, 0x0B7F, //Oriya, 128, 90, Oriya
|
||||
//0x0B80, 0x0BFF, //Tamil, 128, 72, Tamil
|
||||
//0x0C00, 0x0C7F, //Telugu, 128, 96, Telugu
|
||||
//0x0C80, 0x0CFF, //Kannada, 128, 88, Kannada
|
||||
//0x0D00, 0x0D7F, //Malayalam, 128, 117, Malayalam
|
||||
//0x0D80, 0x0DFF, //Sinhala, 128, 90, Sinhala
|
||||
//0x0E00, 0x0E7F, //Thai, 128, 87, Thai (86 characters), Common (1 character)
|
||||
//0x0E80, 0x0EFF, //Lao, 128, 67, Lao
|
||||
//0x0F00, 0x0FFF, //Tibetan, 256, 211, Tibetan (207 characters), Common (4 characters)
|
||||
//0x1000, 0x109F, //Myanmar, 160, 160, Myanmar
|
||||
//0x10A0, 0x10FF, //Georgian, 96, 88, Georgian (87 characters), Common (1 character)
|
||||
//0x1100, 0x11FF, //Hangul Jamo, 256, 256, Hangul
|
||||
//0x1200, 0x137F, //Ethiopic, 384, 358, Ethiopic
|
||||
//0x1380, 0x139F, //Ethiopic Supplement, 32, 26, Ethiopic
|
||||
//0x13A0, 0x13FF, //Cherokee, 96, 92, Cherokee
|
||||
//0x1400, 0x167F, //Unified Canadian Aboriginal Syllabics, 640, 640, Canadian Aboriginal
|
||||
//0x1680, 0x169F, //Ogham, 32, 29, Ogham
|
||||
//0x16A0, 0x16FF, //Runic, 96, 89, Runic (86 characters), Common (3 characters)
|
||||
//0x1700, 0x171F, //Tagalog, 32, 20, Tagalog
|
||||
//0x1720, 0x173F, //Hanunoo, 32, 23, Hanunoo (21 characters), Common (2 characters)
|
||||
//0x1740, 0x175F, //Buhid, 32, 20, Buhid
|
||||
//0x1760, 0x177F, //Tagbanwa, 32, 18, Tagbanwa
|
||||
//0x1780, 0x17FF, //Khmer, 128, 114, Khmer
|
||||
//0x1800, 0x18AF, //Mongolian, 176, 156, Mongolian (153 characters), Common (3 characters)
|
||||
//0x18B0, 0x18FF, //Unified Canadian Aboriginal Syllabics Extended, 80, 70, Canadian Aboriginal
|
||||
//0x1900, 0x194F, //Limbu, 80, 68, Limbu
|
||||
//0x1950, 0x197F, //Tai Le, 48, 35, Tai Le
|
||||
//0x1980, 0x19DF, //New Tai Lue, 96, 83, New Tai Lue
|
||||
//0x19E0, 0x19FF, //Khmer Symbols, 32, 32, Khmer
|
||||
//0x1A00, 0x1A1F, //Buginese, 32, 30, Buginese
|
||||
//0x1A20, 0x1AAF, //Tai Tham, 144, 127, Tai Tham
|
||||
//0x1AB0, 0x1AFF, //Combining Diacritical Marks Extended, 80, 15, Inherited
|
||||
//0x1B00, 0x1B7F, //Balinese, 128, 121, Balinese
|
||||
//0x1B80, 0x1BBF, //Sundanese, 64, 64, Sundanese
|
||||
//0x1BC0, 0x1BFF, //Batak, 64, 56, Batak
|
||||
//0x1C00, 0x1C4F, //Lepcha, 80, 74, Lepcha
|
||||
//0x1C50, 0x1C7F, //Ol Chiki, 48, 48, Ol Chiki
|
||||
//0x1C80, 0x1C8F, //Cyrillic Extended-C, 16, 9, Cyrillic
|
||||
//0x1CC0, 0x1CCF, //Sundanese Supplement, 16, 8, Sundanese
|
||||
//0x1CD0, 0x1CFF, //Vedic Extensions, 48, 42, Common (15 characters), Inherited (27 characters)
|
||||
//0x1D00, 0x1D7F, //Phonetic Extensions, 128, 128, Cyrillic (2 characters), Greek (15 characters), Latin (111 characters)
|
||||
//0x1D80, 0x1DBF, //Phonetic Extensions Supplement, 64, 64, Greek (1 character), Latin (63 characters)
|
||||
//0x1DC0, 0x1DFF, //Combining Diacritical Marks Supplement, 64, 63, Inherited
|
||||
//0x1E00, 0x1EFF, //Latin Extended Additional, 256, 256, Latin
|
||||
//0x1F00, 0x1FFF, //Greek Extended, 256, 233, Greek
|
||||
//0x2000, 0x206F, //General Punctuation, 112, 111, Common (109 characters), Inherited (2 characters)
|
||||
//0x2070, 0x209F, //Superscripts and Subscripts, 48, 42, Latin (15 characters), Common (27 characters)
|
||||
//0x20A0, 0x20CF, //Currency Symbols, 48, 32, Common
|
||||
//0x20D0, 0x20FF, //Combining Diacritical Marks for Symbols, 48, 33, Inherited
|
||||
//0x2100, 0x214F, //Letterlike Symbols, 80, 80, Greek (1 character), Latin (4 characters), Common (75 characters)
|
||||
//0x2150, 0x218F, //Number Forms, 64, 60, Latin (41 characters), Common (19 characters)
|
||||
//0x2190, 0x21FF, //Arrows, 112, 112, Common
|
||||
//0x2200, 0x22FF, //Mathematical Operators, 256, 256, Common
|
||||
//0x2300, 0x23FF, //Miscellaneous Technical, 256, 256, Common
|
||||
//0x2400, 0x243F, //Control Pictures, 64, 39, Common
|
||||
//0x2440, 0x245F, //Optical Character Recognition, 32, 11, Common
|
||||
//0x2460, 0x24FF, //Enclosed Alphanumerics, 160, 160, Common
|
||||
//0x2500, 0x257F, //Box Drawing, 128, 128, Common
|
||||
//0x2580, 0x259F, //Block Elements, 32, 32, Common
|
||||
//0x25A0, 0x25FF, //Geometric Shapes, 96, 96, Common
|
||||
//0x2600, 0x26FF, //Miscellaneous Symbols, 256, 256, Common
|
||||
//0x2700, 0x27BF, //Dingbats, 192, 192, Common
|
||||
//0x27C0, 0x27EF, //Miscellaneous Mathematical Symbols-A, 48, 48, Common
|
||||
//0x27F0, 0x27FF, //Supplemental Arrows-A, 16, 16, Common
|
||||
//0x2800, 0x28FF, //Braille Patterns, 256, 256, Braille
|
||||
//0x2900, 0x297F, //Supplemental Arrows-B, 128, 128, Common
|
||||
//0x2980, 0x29FF, //Miscellaneous Mathematical Symbols-B, 128, 128, Common
|
||||
//0x2A00, 0x2AFF, //Supplemental Mathematical Operators, 256, 256, Common
|
||||
//0x2B00, 0x2BFF, //Miscellaneous Symbols and Arrows, 256, 207, Common
|
||||
//0x2C00, 0x2C5F, //Glagolitic, 96, 94, Glagolitic
|
||||
//0x2C60, 0x2C7F, //Latin Extended-C, 32, 32, Latin
|
||||
//0x2C80, 0x2CFF, //Coptic, 128, 123, Coptic
|
||||
//0x2D00, 0x2D2F, //Georgian Supplement, 48, 40, Georgian
|
||||
//0x2D30, 0x2D7F, //Tifinagh, 80, 59, Tifinagh
|
||||
//0x2D80, 0x2DDF, //Ethiopic Extended, 96, 79, Ethiopic
|
||||
//0x2DE0, 0x2DFF, //Cyrillic Extended-A, 32, 32, Cyrillic
|
||||
//0x2E00, 0x2E7F, //Supplemental Punctuation, 128, 74, Common
|
||||
//0x2E80, 0x2EFF, //CJK Radicals Supplement, 128, 115, Han
|
||||
//0x2F00, 0x2FDF, //Kangxi Radicals, 224, 214, Han
|
||||
//0x2FF0, 0x2FFF, //Ideographic Description Characters, 16, 12, Common
|
||||
//0x3000, 0x303F, //CJK Symbols and Punctuation, 64, 64, Han (15 characters), Hangul (2 characters), Common (43 characters), Inherited (4 characters)
|
||||
//0x3040, 0x309F, //Hiragana, 96, 93, Hiragana (89 characters), Common (2 characters), Inherited (2 characters)
|
||||
//0x30A0, 0x30FF, //Katakana, 96, 96, Katakana (93 characters), Common (3 characters)
|
||||
//0x3100, 0x312F, //Bopomofo, 48, 42, Bopomofo
|
||||
//0x3130, 0x318F, //Hangul Compatibility Jamo, 96, 94, Hangul
|
||||
//0x3190, 0x319F, //Kanbun, 16, 16, Common
|
||||
//0x31A0, 0x31BF, //Bopomofo Extended, 32, 27, Bopomofo
|
||||
//0x31C0, 0x31EF, //CJK Strokes, 48, 36, Common
|
||||
//0x31F0, 0x31FF, //Katakana Phonetic Extensions, 16, 16, Katakana
|
||||
//0x3200, 0x32FF, //Enclosed CJK Letters and Months, 256, 254, Hangul (62 characters), Katakana (47 characters), Common (145 characters)
|
||||
//0x3300, 0x33FF, //CJK Compatibility, 256, 256, Katakana (88 characters), Common (168 characters)
|
||||
//0x3400, 0x4DBF, //CJK Unified Ideographs Extension A, 6,592, 6,582, Han
|
||||
//0x4DC0, 0x4DFF, //Yijing Hexagram Symbols, 64, 64, Common
|
||||
//0x4E00, 0x9FFF, //CJK Unified Ideographs, 20,992, 20,971, Han
|
||||
//0xA000, 0xA48F, //Yi Syllables, 1,168, 1,165, Yi
|
||||
//0xA490, 0xA4CF, //Yi Radicals, 64, 55, Yi
|
||||
//0xA4D0, 0xA4FF, //Lisu, 48, 48, Lisu
|
||||
//0xA500, 0xA63F, //Vai, 320, 300, Vai
|
||||
//0xA640, 0xA69F, //Cyrillic Extended-B, 96, 96, Cyrillic
|
||||
//0xA6A0, 0xA6FF, //Bamum, 96, 88, Bamum
|
||||
//0xA700, 0xA71F, //Modifier Tone Letters, 32, 32, Common
|
||||
//0xA720, 0xA7FF, //Latin Extended-D, 224, 160, Latin (155 characters), Common (5 characters)
|
||||
//0xA800, 0xA82F, //Syloti Nagri, 48, 44, Syloti Nagri
|
||||
//0xA830, 0xA83F, //Common Indic Number Forms, 16, 10, Common
|
||||
//0xA840, 0xA87F, //Phags-pa, 64, 56, Phags Pa
|
||||
//0xA880, 0xA8DF, //Saurashtra, 96, 82, Saurashtra
|
||||
//0xA8E0, 0xA8FF, //Devanagari Extended, 32, 30, Devanagari
|
||||
//0xA900, 0xA92F, //Kayah Li, 48, 48, Kayah Li (47 characters), Common (1 character)
|
||||
//0xA930, 0xA95F, //Rejang, 48, 37, Rejang
|
||||
//0xA960, 0xA97F, //Hangul Jamo Extended-A, 32, 29, Hangul
|
||||
//0xA980, 0xA9DF, //Javanese, 96, 91, Javanese (90 characters), Common (1 character)
|
||||
//0xA9E0, 0xA9FF, //Myanmar Extended-B, 32, 31, Myanmar
|
||||
//0xAA00, 0xAA5F, //Cham, 96, 83, Cham
|
||||
//0xAA60, 0xAA7F, //Myanmar Extended-A, 32, 32, Myanmar
|
||||
//0xAA80, 0xAADF, //Tai Viet, 96, 72, Tai Viet
|
||||
//0xAAE0, 0xAAFF, //Meetei Mayek Extensions, 32, 23, Meetei Mayek
|
||||
//0xAB00, 0xAB2F, //Ethiopic Extended-A, 48, 32, Ethiopic
|
||||
//0xAB30, 0xAB6F, //Latin Extended-E, 64, 54, Latin (52 characters), Greek (1 character), Common (1 character)
|
||||
//0xAB70, 0xABBF, //Cherokee Supplement, 80, 80, Cherokee
|
||||
//0xABC0, 0xABFF, //Meetei Mayek, 64, 56, Meetei Mayek
|
||||
//0xAC00, 0xD7AF, //Hangul Syllables, 11,184, 11,172, Hangul
|
||||
//0xD7B0, 0xD7FF, //Hangul Jamo Extended-B, 80, 72, Hangul
|
||||
//0xD800, 0xDB7F, //High Surrogates, 896, 0, Unknown
|
||||
//0xDB80, 0xDBFF, //High Private Use Surrogates, 128, 0, Unknown
|
||||
//0xDC00, 0xDFFF, //Low Surrogates, 1,024, 0, Unknown
|
||||
//0xE000, 0xF8FF, //Private Use Area, 6,400, 6,400, Unknown
|
||||
//0xF900, 0xFAFF, //CJK Compatibility Ideographs, 512, 472, Han
|
||||
//0xFB00, 0xFB4F, //Alphabetic Presentation Forms, 80, 58, Armenian (5 characters), Hebrew (46 characters), Latin (7 characters)
|
||||
//0xFB50, 0xFDFF, //Arabic Presentation Forms-A, 688, 611, Arabic (609 characters), Common (2 characters)
|
||||
//0xFE00, 0xFE0F, //Variation Selectors, 16, 16, Inherited
|
||||
//0xFE10, 0xFE1F, //Vertical Forms, 16, 10, Common
|
||||
//0xFE20, 0xFE2F, //Combining Half Marks, 16, 16, Cyrillic (2 characters), Inherited (14 characters)
|
||||
//0xFE30, 0xFE4F, //CJK Compatibility Forms, 32, 32, Common
|
||||
//0xFE50, 0xFE6F, //Small Form Variants, 32, 26, Common
|
||||
//0xFE70, 0xFEFF, //Arabic Presentation Forms-B, 144, 141, Arabic (140 characters), Common (1 character)
|
||||
//0xFF00, 0xFFEF, //Halfwidth and Fullwidth Forms, 240, 225, Hangul (52 characters), Katakana (55 characters), Latin (52 characters), Common (66 characters)
|
||||
//0xFFF0, 0xFFFF, //Specials, 16, 5, Common
|
||||
|
||||
//0x0030, 0x0039, //Example custom range (numbers 0-9)
|
||||
//0x0041, 0x005A, //Example custom range (Upper case A-Z)
|
||||
//0x0061, 0x007A, //Example custom range (Lower case a-z)
|
||||
};
|
||||
|
||||
// Here we specify specific individual Unicodes to be included (appended at end of selected range)
|
||||
static final int[] specificUnicodes = {
|
||||
|
||||
// Commonly used codes, add or remove // in next line
|
||||
// 0x00A3, 0x00B0, 0x00B5, 0x03A9, 0x20AC, // £ ° µ Ω €
|
||||
|
||||
// Numbers and characters for showing time, change next line to //* to use
|
||||
/*
|
||||
0x002B, 0x002D, 0x002E, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, // - + . 0 1 2 3 4
|
||||
0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x0061, 0x006D, // 5 6 7 8 9 : a m
|
||||
0x0070, // p
|
||||
//*/
|
||||
|
||||
// More characters, change next line to //* to use
|
||||
/*
|
||||
0x0102, 0x0103, 0x0104, 0x0105, 0x0106, 0x0107, 0x010C, 0x010D,
|
||||
0x010E, 0x010F, 0x0110, 0x0111, 0x0118, 0x0119, 0x011A, 0x011B,
|
||||
|
||||
0x0131, 0x0139, 0x013A, 0x013D, 0x013E, 0x0141, 0x0142, 0x0143,
|
||||
0x0144, 0x0147, 0x0148, 0x0150, 0x0151, 0x0152, 0x0153, 0x0154,
|
||||
0x0155, 0x0158, 0x0159, 0x015A, 0x015B, 0x015E, 0x015F, 0x0160,
|
||||
0x0161, 0x0162, 0x0163, 0x0164, 0x0165, 0x016E, 0x016F, 0x0170,
|
||||
0x0171, 0x0178, 0x0179, 0x017A, 0x017B, 0x017C, 0x017D, 0x017E,
|
||||
0x0192,
|
||||
|
||||
0x02C6, 0x02C7, 0x02D8, 0x02D9, 0x02DA, 0x02DB, 0x02DC, 0x02DD,
|
||||
0x03A9, 0x03C0, 0x2013, 0x2014, 0x2018, 0x2019, 0x201A, 0x201C,
|
||||
0x201D, 0x201E, 0x2020, 0x2021, 0x2022, 0x2026, 0x2030, 0x2039,
|
||||
0x203A, 0x2044, 0x20AC,
|
||||
|
||||
0x2122, 0x2202, 0x2206, 0x220F,
|
||||
|
||||
0x2211, 0x221A, 0x221E, 0x222B, 0x2248, 0x2260, 0x2264, 0x2265,
|
||||
0x25CA,
|
||||
|
||||
0xF8FF, 0xFB01, 0xFB02,
|
||||
//*/
|
||||
};
|
||||
|
||||
|
||||
// >>>>>>>>>> USER CONFIGURED PARAMETERS END HERE <<<<<<<<<<
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Variable to hold the inclusive Unicode range (16 bit values only for this sketch)
|
||||
int firstUnicode = 0;
|
||||
int lastUnicode = 0;
|
||||
|
||||
PFont myFont;
|
||||
|
||||
void setup() {
|
||||
|
||||
size(1000, 800);
|
||||
|
||||
// Print the available fonts to the console as a list:
|
||||
String[] fontList = PFont.list();
|
||||
printArray(fontList);
|
||||
|
||||
// Set the fontName from the array number or the defined fontName
|
||||
if (fontNumber >= 0)
|
||||
{
|
||||
fontName = fontList[fontNumber];
|
||||
fontType = "";
|
||||
}
|
||||
|
||||
char[] charset;
|
||||
int index = 0, count = 0;
|
||||
|
||||
int blockCount = unicodeBlocks.length;
|
||||
|
||||
for (int i = 0; i < blockCount; i+=2) {
|
||||
firstUnicode = unicodeBlocks[i];
|
||||
lastUnicode = unicodeBlocks[i+1];
|
||||
if (lastUnicode < firstUnicode) {
|
||||
delay(100);
|
||||
System.err.println("ERROR: Bad Unicode range secified, last < first!");
|
||||
System.err.print("first in range = 0x" + hex(firstUnicode, 4));
|
||||
System.err.println(", last in range = 0x" + hex(lastUnicode, 4));
|
||||
while (true);
|
||||
}
|
||||
// calculate the number of characters
|
||||
count += (lastUnicode - firstUnicode + 1);
|
||||
}
|
||||
|
||||
count += specificUnicodes.length;
|
||||
|
||||
println();
|
||||
println("=====================");
|
||||
println("Creating font file...");
|
||||
println("Unicode blocks included = " + (blockCount/2));
|
||||
println("Specific unicodes included = " + specificUnicodes.length);
|
||||
println("Total number of characters = " + count);
|
||||
|
||||
if (count == 0) {
|
||||
delay(100);
|
||||
System.err.println("ERROR: No Unicode range or specific codes have been defined!");
|
||||
while (true);
|
||||
}
|
||||
|
||||
// allocate memory
|
||||
charset = new char[count];
|
||||
|
||||
for (int i = 0; i < blockCount; i+=2) {
|
||||
firstUnicode = unicodeBlocks[i];
|
||||
lastUnicode = unicodeBlocks[i+1];
|
||||
|
||||
// loading the range specified
|
||||
for (int code = firstUnicode; code <= lastUnicode; code++) {
|
||||
charset[index] = Character.toChars(code)[0];
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
// loading the range specified
|
||||
for (int i = 0; i < specificUnicodes.length; i++) {
|
||||
charset[index] = Character.toChars(specificUnicodes[i])[0];
|
||||
index++;
|
||||
}
|
||||
|
||||
// Make font smooth
|
||||
boolean smooth = true;
|
||||
|
||||
// Create the font in memory
|
||||
myFont = createFont(fontName+fontType, displayFontSize, smooth, charset);
|
||||
|
||||
// Print a few characters to the sketch window
|
||||
fill(0, 0, 0);
|
||||
textFont(myFont);
|
||||
|
||||
// Set the left and top margin
|
||||
int margin = displayFontSize;
|
||||
translate(margin/2, margin);
|
||||
|
||||
int gapx = displayFontSize*10/8;
|
||||
int gapy = displayFontSize*10/8;
|
||||
index = 0;
|
||||
fill(0);
|
||||
|
||||
textSize(displayFontSize);
|
||||
|
||||
for (int y = 0; y < height-gapy; y += gapy) {
|
||||
int x = 0;
|
||||
while (x < width) {
|
||||
|
||||
int unicode = charset[index];
|
||||
float cwidth = textWidth((char)unicode) + 2;
|
||||
if ( (x + cwidth) > (width - gapx) ) break;
|
||||
|
||||
// Draw the letter to the screen
|
||||
text(new String(Character.toChars(unicode)), x, y);
|
||||
|
||||
// Move cursor
|
||||
x += cwidth;
|
||||
// Increment the counter
|
||||
index++;
|
||||
if (index >= count) break;
|
||||
}
|
||||
if (index >= count) break;
|
||||
}
|
||||
|
||||
|
||||
// creating font
|
||||
PFont font;
|
||||
|
||||
font = createFont(fontName+fontType, fontSize, smooth, charset);
|
||||
|
||||
println("Created font " + fontName + str(fontSize) + ".vlw");
|
||||
|
||||
// creating file
|
||||
try {
|
||||
print("Saving to sketch FontFiles folder... ");
|
||||
|
||||
OutputStream output = createOutput("FontFiles/" + fontName + str(fontSize) + ".vlw");
|
||||
font.save(output);
|
||||
output.close();
|
||||
|
||||
println("OK!");
|
||||
|
||||
delay(100);
|
||||
|
||||
// Open up the FontFiles folder to access the saved file
|
||||
String path = sketchPath();
|
||||
Desktop.getDesktop().open(new File(path+"/FontFiles"));
|
||||
|
||||
System.err.println("All done! Note: Rectangles are displayed for non-existant characters.");
|
||||
}
|
||||
catch(IOException e) {
|
||||
println("Doh! Failed to create the file");
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 135 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 126 KiB |
|
|
@ -0,0 +1,33 @@
|
|||
PlatformIO User notes:
|
||||
|
||||
It is possible to load settings from the calling program rather than modifying
|
||||
the library for each project by modifying the "platformio.ini" file.
|
||||
|
||||
The User_Setup_Select.h file will not load the user setting header files if
|
||||
USER_SETUP_LOADED is defined.
|
||||
|
||||
Instead of using #define, use the -D prefix, for example:
|
||||
|
||||
[env:esp32dev]
|
||||
platform = https://github.com/platformio/platform-espressif32.git#feature/stage
|
||||
board = esp32dev
|
||||
framework = arduino
|
||||
upload_port = ESP32-Test-2481CE9C.local
|
||||
|
||||
build_flags =
|
||||
-Os
|
||||
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
|
||||
-DUSER_SETUP_LOADED=1
|
||||
-DILI9163_DRIVER=1
|
||||
-DTFT_WIDTH=128
|
||||
-DTFT_HEIGHT=160
|
||||
-DTFT_MISO=19
|
||||
-DTFT_MOSI=23
|
||||
-DTFT_SCLK=18
|
||||
-DTFT_CS=5
|
||||
-DTFT_DC=19
|
||||
-DTFT_RST=-1
|
||||
-DLOAD_GLCD=1
|
||||
-DSPI_FREQUENCY=27000000
|
||||
|
||||
lib_extra_dirs = B:\Projects\ESP32\ESP32Lib
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 385 KiB After Width: | Height: | Size: 381 KiB |
156
User_Setup.h
156
User_Setup.h
|
|
@ -4,8 +4,9 @@
|
|||
// See the User_Setup_Select.h file if you wish to be able to define multiple
|
||||
// setups and then easily select which setup file is used by the compiler.
|
||||
//
|
||||
// If this file is editted correctly then all the library example sketches should
|
||||
// If this file is edited correctly then all the library example sketches should
|
||||
// run without the need to make any more changes for a particular hardware setup!
|
||||
// Note that some sketches are designed for a particular TFT pixel width/height
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
|
|
@ -14,11 +15,23 @@
|
|||
// ##################################################################################
|
||||
|
||||
// Only define one driver, the other ones must be commented out
|
||||
//#define ILI9341_DRIVER
|
||||
#define ILI9341_DRIVER
|
||||
//#define ST7735_DRIVER
|
||||
//#define ILI9163_DRIVER
|
||||
//#define S6D02A1_DRIVER
|
||||
#define RPI_ILI9486_DRIVER // 20MHz maximum SPI
|
||||
//#define RPI_ILI9486_DRIVER // 20MHz maximum SPI
|
||||
//#define HX8357D_DRIVER
|
||||
//#define ILI9481_DRIVER
|
||||
//#define ILI9488_DRIVER
|
||||
//#define ST7789_DRIVER
|
||||
|
||||
// For M5Stack ESP32 module with integrated display ONLY, remove // in line below
|
||||
//#define M5STACK
|
||||
|
||||
// For ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
|
||||
//#define TFT_WIDTH 128
|
||||
//#define TFT_HEIGHT 160
|
||||
//#define TFT_HEIGHT 128
|
||||
|
||||
// For ST7735 ONLY, define the type of display, originally this was based on the
|
||||
// colour of the tab on the screen protector film but this is not always true, so try
|
||||
|
|
@ -31,14 +44,10 @@
|
|||
//#define ST7735_GREENTAB
|
||||
//#define ST7735_GREENTAB2
|
||||
//#define ST7735_GREENTAB3
|
||||
//#define ST7735_GREENTAB128 // For 128 x 128 display
|
||||
//#define ST7735_REDTAB
|
||||
//#define ST7735_BLACKTAB
|
||||
|
||||
// For ST7735 ONLY, define the pixel width and height in portrait orientation
|
||||
//#define TFT_WIDTH 128
|
||||
//#define TFT_HEIGHT 160
|
||||
//#define TFT_HEIGHT 128
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 1. Define the pins that are used to interface with the display here
|
||||
|
|
@ -46,13 +55,13 @@
|
|||
// ##################################################################################
|
||||
|
||||
// We must use hardware SPI, a minimum of 3 GPIO pins is needed.
|
||||
// Typical setup for NodeMCU ESP-12 is :
|
||||
// Typical setup for ESP8266 NodeMCU ESP-12 is :
|
||||
//
|
||||
// Display SDO/MISO to NodeMCU pin D6 (or leave disconnected if not reading TFT)
|
||||
// Display LED to NodeMCU pin VIN (or 5V, see below)
|
||||
// Display SCK to NodeMCU pin D5
|
||||
// Display SDI/MOSI to NodeMCU pin D7
|
||||
// Display DC (or AO)to NodeMCU pin D3
|
||||
// Display DC (RS/AO)to NodeMCU pin D3
|
||||
// Display RESET to NodeMCU pin D4 (or RST, see below)
|
||||
// Display CS to NodeMCU pin D8 (or GND, see below)
|
||||
// Display GND to NodeMCU pin GND (0V)
|
||||
|
|
@ -60,8 +69,10 @@
|
|||
//
|
||||
// The TFT RESET pin can be connected to the NodeMCU RST pin or 3.3V to free up a control pin
|
||||
//
|
||||
// The DC (Data Command) pin may be labeled AO or RS (Register Select)
|
||||
//
|
||||
// With some displays such as the ILI9341 the TFT CS pin can be connected to GND if no more
|
||||
// SPI deivces (e.g. an SD Card) are connected, in this case comment out the #define TFT_CS
|
||||
// SPI devices (e.g. an SD Card) are connected, in this case comment out the #define TFT_CS
|
||||
// line below so it is NOT defined. Other displays such at the ST7735 require the TFT CS pin
|
||||
// to be toggled during setup, so in these cases the TFT_CS line must be defined and connected.
|
||||
//
|
||||
|
|
@ -73,26 +84,93 @@
|
|||
// If 5V is not available at a pin you can use 3.3V but backlight brightness
|
||||
// will be lower.
|
||||
|
||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR SETUP ######
|
||||
|
||||
// ModeMCU
|
||||
// ###### 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_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V
|
||||
|
||||
//#define TOUCH_CS PIN_D2 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR PIN_D2 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
|
||||
// ###### FOR ESP8266 OVERLAP MODE EDIT THE PIN NUMBERS IN THE FOLLOWING LINES ######
|
||||
|
||||
// Overlap mode shares the ESP8266 FLASH SPI bus with the TFT so has a performance impact
|
||||
// but saves pins for other functions.
|
||||
// Use NodeMCU SD0=MISO, SD1=MOSI, CLK=SCLK to connect to TFT in overlap mode
|
||||
|
||||
// In ESP8266 overlap mode the TFT chip select MUST connect to pin D3
|
||||
//#define TFT_CS PIN_D3
|
||||
//#define TFT_DC PIN_D5 // 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 TOUCH_CS D4 // Chip select pin (T_CS) of touch screen
|
||||
//#define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V
|
||||
|
||||
//#define TFT_WR PIN_D2 // Write strobe for modified Raspberry Pi TFT only
|
||||
// In ESP8266 overlap mode the following must be defined
|
||||
//#define TFT_SPI_OVERLAP
|
||||
|
||||
// ESP32 Dev board (planned, not supported yet)
|
||||
//#define TFT_CS 5 // Chip select control pin
|
||||
//#define TFT_DC 2 // Data Command control pin
|
||||
//#define TFT_RST 4 // Reset pin (could connect to Arduino RESET pin)
|
||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR ESP32 SETUP ######
|
||||
|
||||
// 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_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
|
||||
|
||||
// For the M5Stack module use these #define lines
|
||||
//#define TFT_MISO 19
|
||||
//#define TFT_MOSI 23
|
||||
//#define TFT_SCLK 18
|
||||
//#define TFT_CS 14 // Chip select control pin
|
||||
//#define TFT_DC 27 // Data Command control pin
|
||||
//#define TFT_RST 33 // Reset pin (could connect to Arduino RESET pin)
|
||||
//#define TFT_BL 32 // LED back-light
|
||||
|
||||
//#define TOUCH_CS 21 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR 22 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
// ###### EDIT THE PINs BELOW TO SUIT YOUR ESP32 PARALLEL TFT SETUP ######
|
||||
|
||||
// The library supports 8 bit parallel TFTs with the ESP32, the pin
|
||||
// selection below is compatible with ESP32 boards in UNO format.
|
||||
// Wemos D32 boards need to be modified, see diagram in Tools folder.
|
||||
// Only ILI9481 and ILI9341 based displays have been tested!
|
||||
|
||||
// Parallel bus is only supported on ESP32
|
||||
// Uncomment line below to use ESP32 Parallel interface instead of SPI
|
||||
|
||||
//#define ESP32_PARALLEL
|
||||
|
||||
// The ESP32 and TFT the pins used for testing are:
|
||||
//#define TFT_CS 33 // Chip select control pin (library pulls permanently low
|
||||
//#define TFT_DC 15 // Data Command control pin - use a pin in the range 0-31
|
||||
//#define TFT_RST 32 // Reset pin, toggles on startup
|
||||
|
||||
//#define TFT_WR 4 // Write strobe control pin - use a pin in the range 0-31
|
||||
//#define TFT_RD 2 // Read strobe control pin - use a pin in the range 0-31
|
||||
|
||||
//#define TFT_D0 12 // Must use pins in the range 0-31 for the data bus
|
||||
//#define TFT_D1 13 // so a single register write sets/clears all bits.
|
||||
//#define TFT_D2 26 // Pins can be randomly assigned, this does not affect
|
||||
//#define TFT_D3 25 // TFT screen update performance.
|
||||
//#define TFT_D4 17
|
||||
//#define TFT_D5 16
|
||||
//#define TFT_D6 27
|
||||
//#define TFT_D7 14
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 2. Define the way the DC and/or CS lines are driven
|
||||
// Section 2. Define the way the DC and/or CS lines are driven (ESP8266 only)
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
|
|
@ -112,18 +190,23 @@
|
|||
// ##################################################################################
|
||||
|
||||
// Comment out the #defines below with // to stop that font being loaded
|
||||
// The ESP8366 had plenty of memory so commenting out fonts is not normally necessary
|
||||
// If all fonts are loaded the extra FLASH space required is about 17Kbytes...
|
||||
// To save FLASH space only enable the fonts you need!
|
||||
// The ESP8366 and ESP32 have plenty of memory so commenting out fonts is not
|
||||
// normally necessary. If all fonts are loaded the extra FLASH space required is
|
||||
// about 17Kbytes. To save FLASH space only enable the fonts you need!
|
||||
|
||||
#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_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
|
||||
|
||||
// Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded
|
||||
// this will save ~20kbytes of FLASH
|
||||
#define SMOOTH_FONT
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 4. Not used
|
||||
|
|
@ -137,26 +220,33 @@
|
|||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Define the SPI clock frequency
|
||||
// Define the SPI clock frequency, this affects the graphics rendering speed. Too
|
||||
// fast and the TFT driver will not keep up and display corruption appears.
|
||||
// With an ILI9341 display 40MHz works OK, 80MHz sometimes fails
|
||||
// With a ST7735 display more than 27MHz may not work (spurious pixels and lines)
|
||||
// With an ILI9163 display TBD MHz works OK,
|
||||
// With an ILI9163 display 27 MHz works OK.
|
||||
// The RPi typically only works at 20MHz maximum.
|
||||
|
||||
// #define SPI_FREQUENCY 1000000
|
||||
// #define SPI_FREQUENCY 5000000
|
||||
#define SPI_FREQUENCY 10000000
|
||||
// #define SPI_FREQUENCY 10000000
|
||||
// #define SPI_FREQUENCY 20000000
|
||||
// #define SPI_FREQUENCY 27000000 // Actually sets it to 26.67MHz = 80/3
|
||||
#define SPI_FREQUENCY 27000000 // Actually sets it to 26.67MHz = 80/3
|
||||
// #define SPI_FREQUENCY 40000000 // Maximum to use SPIFFS
|
||||
// #define SPI_FREQUENCY 80000000
|
||||
|
||||
// The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here:
|
||||
#define SPI_TOUCH_FREQUENCY 2500000
|
||||
|
||||
|
||||
// Comment out the following #define if "SPI Transactions" do not need to be
|
||||
// supported. Tranaction support is required if other SPI devices are connected.
|
||||
// When commented out the code size will be smaller and sketches will
|
||||
// supported. When commented out the code size will be smaller and sketches will
|
||||
// run slightly faster, so leave it commented out unless you need it!
|
||||
// Transaction support is needed to work with SD library but not needed with TFT_SdFat
|
||||
|
||||
// #define SUPPORT_TRANSACTIONS
|
||||
// Transaction support is needed to work with SD library but not needed with TFT_SdFat
|
||||
// Transaction support is required if other SPI devices are connected.
|
||||
|
||||
// Transactions are automatically enabled by the library for an ESP32 (to use HAL mutex)
|
||||
// so changing it here has no effect
|
||||
|
||||
//#define SUPPORT_TRANSACTIONS
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// This header file contains a list of user setup files and defines which one the
|
||||
// compliler uses when the IDE performs a Verify/Compile or Upload.
|
||||
// compiler uses when the IDE performs a Verify/Compile or Upload.
|
||||
//
|
||||
// Users can create configurations for different Espressiff boards and TFT displays.
|
||||
// Users can create configurations for different Espressif boards and TFT displays.
|
||||
// This makes selecting between hardware setups easy by "uncommenting" one line.
|
||||
|
||||
// The advantage of this hardware configuration method is that the examples provided
|
||||
|
|
@ -9,12 +9,15 @@
|
|||
// changes being needed. It also improves the portability of users sketches to other
|
||||
// hardware configurations and compatible libraries.
|
||||
//
|
||||
// Create a shortcut to this file on your desktop to permit quick access for editting.
|
||||
// Create a shortcut to this file on your desktop to permit quick access for editing.
|
||||
// Re-compile and upload after making and saving any changes to this file.
|
||||
|
||||
// Customised User_Setup files are stored in the "User_Setups" folder.
|
||||
|
||||
// Only ONE line should be uncommented. Add extra lines and files as needed.
|
||||
#ifndef USER_SETUP_LOADED // Lets PlatformIO users define settings in
|
||||
// platformio.ini, see notes in "Tools" folder.
|
||||
|
||||
// Only ONE line below should be uncommented. Add extra lines and files as needed.
|
||||
|
||||
#include <User_Setup.h> // Default setup is root library folder
|
||||
|
||||
|
|
@ -27,8 +30,20 @@
|
|||
//#include <User_Setups/Setup7_ST7735_128x128.h> // Setup file configured for my ST7735 128x128 display
|
||||
//#include <User_Setups/Setup8_ILI9163_128x128.h> // Setup file configured for my ILI9163 128x128 display
|
||||
//#include <User_Setups/Setup9_ST7735_Overlap.h> // Setup file configured for my ST7735
|
||||
//#include <User_Setups/Setup10_RPi_touch_ILI9486.h> // Setup file configured for ESP8266 and RPi TFT with touch
|
||||
//#include <User_Setups/Setup11_RPi_touch_ILI9486.h> // Setup file configured for ESP32 and RPi TFT with touch
|
||||
//#include <User_Setups/Setup12_M5Stack.h> // Setup file for the ESP32 based M5Stack
|
||||
//#include <User_Setups/Setup13_ILI9481_Parallel.h> // Setup file for the ESP32 with parallel bus TFT
|
||||
//#include <User_Setups/Setup14_ILI9341_Parallel.h> // Setup file for the ESP32 with parallel bus TFT
|
||||
//#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/SetupX_Template.h> // Setup file template for copying/editting
|
||||
//#include <User_Setups/SetupX_Template.h>
|
||||
|
||||
|
||||
#endif // USER_SETUP_LOADED
|
||||
|
||||
|
||||
|
||||
|
|
@ -43,33 +58,59 @@
|
|||
// Load the right driver definition - do not tinker here !
|
||||
#if defined (ILI9341_DRIVER)
|
||||
#include <TFT_Drivers/ILI9341_Defines.h>
|
||||
#define TFT_DRIVER 0x9341
|
||||
#elif defined (ST7735_DRIVER)
|
||||
#include <TFT_Drivers/ST7735_Defines.h>
|
||||
#define TFT_DRIVER 0x7735
|
||||
#elif defined (ILI9163_DRIVER)
|
||||
#include <TFT_Drivers/ILI9163_Defines.h>
|
||||
#define TFT_DRIVER 0x9163
|
||||
#elif defined (S6D02A1_DRIVER)
|
||||
#include <TFT_Drivers/S6D02A1_Defines.h>
|
||||
#define TFT_DRIVER 0x6D02
|
||||
#elif defined (RPI_ILI9486_DRIVER)
|
||||
#include <TFT_Drivers/RPI_ILI9486_Defines.h>
|
||||
#define TFT_DRIVER 0x9486
|
||||
#elif defined (ILI9481_DRIVER)
|
||||
#include <TFT_Drivers/ILI9481_Defines.h>
|
||||
#define TFT_DRIVER 0x9481
|
||||
#elif defined (ILI9488_DRIVER)
|
||||
#include <TFT_Drivers/ILI9488_Defines.h>
|
||||
#define TFT_DRIVER 0x9488
|
||||
#elif defined (HX8357D_DRIVER)
|
||||
#include "TFT_Drivers/HX8357D_Defines.h"
|
||||
#define TFT_DRIVER 0x8357
|
||||
#elif defined (EPD_DRIVER)
|
||||
#include "TFT_Drivers/EPD_Defines.h"
|
||||
#define TFT_DRIVER 0xE9D
|
||||
#elif defined (ST7789_DRIVER)
|
||||
#include "TFT_Drivers/ST7789_Defines.h"
|
||||
#define TFT_DRIVER 0x7789
|
||||
#elif defined (XYZZY_DRIVER) // <<<<<<<<<<<<<<<<<<<<<<<< ADD NEW DRIVER HERE
|
||||
#include "TFT_Drivers/XYZZY_Defines.h"
|
||||
#define TFT_DRIVER 0x0000
|
||||
#else
|
||||
#define TFT_DRIVER 0x0000
|
||||
#endif
|
||||
|
||||
// These are the pins for all ESP8266 boards
|
||||
#define PIN_D0 16
|
||||
#define PIN_D1 5
|
||||
#define PIN_D2 4
|
||||
#define PIN_D3 0
|
||||
#define PIN_D4 2
|
||||
#define PIN_D5 14
|
||||
#define PIN_D6 12
|
||||
#define PIN_D7 13
|
||||
#define PIN_D8 15
|
||||
#define PIN_D9 3
|
||||
#define PIN_D10 1
|
||||
// Name GPIO Function
|
||||
#define PIN_D0 16 // WAKE
|
||||
#define PIN_D1 5 // User purpose
|
||||
#define PIN_D2 4 // User purpose
|
||||
#define PIN_D3 0 // FLASH mode at boot time
|
||||
#define PIN_D4 2 // TXD1 (Note: low on boot means go to FLASH mode)
|
||||
#define PIN_D5 14 // HSCLK
|
||||
#define PIN_D6 12 // HMISO
|
||||
#define PIN_D7 13 // HMOSI RXD2
|
||||
#define PIN_D8 15 // HCS TXD0
|
||||
#define PIN_D9 3 // RXD0
|
||||
#define PIN_D10 1 // TXD0
|
||||
|
||||
#define PIN_MOSI 8
|
||||
#define PIN_MISO 7
|
||||
#define PIN_SCLK 6
|
||||
#define PIN_HWCS 0
|
||||
#define PIN_MOSI 8 // SD1
|
||||
#define PIN_MISO 7 // SD0
|
||||
#define PIN_SCLK 6 // CLK
|
||||
#define PIN_HWCS 0 // D3
|
||||
|
||||
#define PIN_D11 9
|
||||
#define PIN_D12 10
|
||||
#define PIN_D11 9 // SD2
|
||||
#define PIN_D12 10 // SD4
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
// See the User_Setup_Select.h file if you wish to be able to define multiple
|
||||
// setups and then easily select which setup file is used by the compiler.
|
||||
//
|
||||
// If this file is editted correctly then all the library example sketches should
|
||||
// If this file is edited correctly then all the library example sketches should
|
||||
// run without the need to make any more changes for a particular hardware setup!
|
||||
|
||||
// ##################################################################################
|
||||
|
|
@ -19,7 +19,14 @@
|
|||
//#define ILI9163_DRIVER
|
||||
//#define S6D02A1_DRIVER
|
||||
#define RPI_ILI9486_DRIVER // 20MHz maximum SPI
|
||||
// to enable XPT2046 touch controller, define TOUCH_CS
|
||||
|
||||
// For M5Stack ESP32 module with integrated display ONLY, remove // in line below
|
||||
//#define M5STACK
|
||||
|
||||
// For ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
|
||||
//#define TFT_WIDTH 128
|
||||
//#define TFT_HEIGHT 160
|
||||
//#define TFT_HEIGHT 128
|
||||
|
||||
// For ST7735 ONLY, define the type of display, originally this was based on the
|
||||
// colour of the tab on the screen protector film but this is not always true, so try
|
||||
|
|
@ -32,14 +39,10 @@
|
|||
//#define ST7735_GREENTAB
|
||||
//#define ST7735_GREENTAB2
|
||||
//#define ST7735_GREENTAB3
|
||||
//#define ST7735_GREENTAB128 // For 128 x 128 display
|
||||
//#define ST7735_REDTAB
|
||||
//#define ST7735_BLACKTAB
|
||||
|
||||
// For ST7735 ONLY, define the pixel width and height in portrait orientation
|
||||
//#define TFT_WIDTH 128
|
||||
//#define TFT_HEIGHT 160
|
||||
//#define TFT_HEIGHT 128
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 1. Define the pins that are used to interface with the display here
|
||||
|
|
@ -47,13 +50,13 @@
|
|||
// ##################################################################################
|
||||
|
||||
// We must use hardware SPI, a minimum of 3 GPIO pins is needed.
|
||||
// Typical setup for NodeMCU ESP-12 is :
|
||||
// Typical setup for ESP8266 NodeMCU ESP-12 is :
|
||||
//
|
||||
// Display SDO/MISO to NodeMCU pin D6 (or leave disconnected if not reading TFT)
|
||||
// Display LED to NodeMCU pin VIN (or 5V, see below)
|
||||
// Display SCK to NodeMCU pin D5
|
||||
// Display SDI/MOSI to NodeMCU pin D7
|
||||
// Display DC (or AO)to NodeMCU pin D3
|
||||
// Display DC (RS/AO)to NodeMCU pin D3
|
||||
// Display RESET to NodeMCU pin D4 (or RST, see below)
|
||||
// Display CS to NodeMCU pin D8 (or GND, see below)
|
||||
// Display GND to NodeMCU pin GND (0V)
|
||||
|
|
@ -61,8 +64,10 @@
|
|||
//
|
||||
// The TFT RESET pin can be connected to the NodeMCU RST pin or 3.3V to free up a control pin
|
||||
//
|
||||
// The DC (Data Command) pin may be labeled AO or RS (Register Select)
|
||||
//
|
||||
// With some displays such as the ILI9341 the TFT CS pin can be connected to GND if no more
|
||||
// SPI deivces (e.g. an SD Card) are connected, in this case comment out the #define TFT_CS
|
||||
// SPI devices (e.g. an SD Card) are connected, in this case comment out the #define TFT_CS
|
||||
// line below so it is NOT defined. Other displays such at the ST7735 require the TFT CS pin
|
||||
// to be toggled during setup, so in these cases the TFT_CS line must be defined and connected.
|
||||
//
|
||||
|
|
@ -74,26 +79,64 @@
|
|||
// If 5V is not available at a pin you can use 3.3V but backlight brightness
|
||||
// will be lower.
|
||||
|
||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR SETUP ######
|
||||
|
||||
// ModeMCU
|
||||
// ###### 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_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V
|
||||
|
||||
#define TOUCH_CS PIN_D1 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR PIN_D2 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
|
||||
// ###### FOR ESP8266 OVERLAP MODE EDIT THE PIN NUMBERS IN THE FOLLOWING LINES ######
|
||||
|
||||
// Overlap mode shares the ESP8266 FLASH SPI bus with the TFT so has a performance impact
|
||||
// but saves pins for other functions.
|
||||
// Use NodeMCU SD0=MISO, SD1=MOSI, CLK=SCLK to connect to TFT in overlap mode
|
||||
|
||||
// In ESP8266 overlap mode the TFT chip select MUST connect to pin D3
|
||||
//#define TFT_CS PIN_D3
|
||||
//#define TFT_DC PIN_D5 // 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 TOUCH_CS D4 // Chip select pin (T_CS) of touch screen controller XPT2046
|
||||
//#define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V
|
||||
|
||||
//#define TFT_WR PIN_D2 // Write strobe for modified Raspberry Pi TFT only
|
||||
// In ESP8266 overlap mode the following must be defined
|
||||
//#define TFT_SPI_OVERLAP
|
||||
|
||||
// ESP32 Dev board (planned, not supported yet)
|
||||
//#define TFT_CS 5 // Chip select control pin
|
||||
//#define TFT_DC 2 // Data Command control pin
|
||||
//#define TFT_RST 4 // Reset pin (could connect to Arduino RESET pin)
|
||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR ESP32 SETUP ######
|
||||
|
||||
// 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_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 TOUCH_CS 21 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR 22 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
// For the M5Stack module use these #define lines
|
||||
//#define TFT_MISO 19
|
||||
//#define TFT_MOSI 23
|
||||
//#define TFT_SCLK 18
|
||||
//#define TFT_CS 14 // Chip select control pin
|
||||
//#define TFT_DC 27 // Data Command control pin
|
||||
//#define TFT_RST 33 // Reset pin (could connect to Arduino RESET pin)
|
||||
//#define TFT_BL 32 // LED back-light
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 2. Define the way the DC and/or CS lines are driven
|
||||
// Section 2. Define the way the DC and/or CS lines are driven (ESP8266 only)
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
|
|
@ -113,9 +156,9 @@
|
|||
// ##################################################################################
|
||||
|
||||
// Comment out the #defines below with // to stop that font being loaded
|
||||
// The ESP8366 had plenty of memory so commenting out fonts is not normally necessary
|
||||
// If all fonts are loaded the extra FLASH space required is about 17Kbytes...
|
||||
// To save FLASH space only enable the fonts you need!
|
||||
// The ESP8366 and ESP32 have plenty of memory so commenting out fonts is not
|
||||
// normally necessary. If all fonts are loaded the extra FLASH space required is
|
||||
// about 17Kbytes. To save FLASH space only enable the fonts you need!
|
||||
|
||||
#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
|
||||
|
|
@ -123,8 +166,13 @@
|
|||
#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
|
||||
|
||||
// Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded
|
||||
// this will save ~20kbytes of FLASH
|
||||
#define SMOOTH_FONT
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 4. Not used
|
||||
|
|
@ -138,26 +186,33 @@
|
|||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Define the SPI clock frequency
|
||||
// Define the SPI clock frequency, this affects the graphics rendering speed. Too
|
||||
// fast and the TFT driver will not keep up and display corruption appears.
|
||||
// With an ILI9341 display 40MHz works OK, 80MHz sometimes fails
|
||||
// With a ST7735 display more than 27MHz may not work (spurious pixels and lines)
|
||||
// With an ILI9163 display TBD MHz works OK,
|
||||
// With an ILI9163 display 27 MHz works OK.
|
||||
// The RPi typically only works at 20MHz maximum.
|
||||
|
||||
// #define SPI_FREQUENCY 1000000
|
||||
// #define SPI_FREQUENCY 5000000
|
||||
#define SPI_FREQUENCY 10000000
|
||||
// #define SPI_FREQUENCY 20000000
|
||||
// #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
|
||||
|
||||
// The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here:
|
||||
#define SPI_TOUCH_FREQUENCY 2500000
|
||||
|
||||
|
||||
// Comment out the following #define if "SPI Transactions" do not need to be
|
||||
// supported. Tranaction support is required if other SPI devices are connected.
|
||||
// When commented out the code size will be smaller and sketches will
|
||||
// supported. When commented out the code size will be smaller and sketches will
|
||||
// run slightly faster, so leave it commented out unless you need it!
|
||||
|
||||
// Transaction support is needed to work with SD library but not needed with TFT_SdFat
|
||||
// Transaction support is required if other SPI devices are connected.
|
||||
|
||||
// Transactions are automatically enabled by the library for an ESP32 (to use HAL mutex)
|
||||
// so changing it here has no effect
|
||||
|
||||
// #define SUPPORT_TRANSACTIONS
|
||||
|
|
|
|||
|
|
@ -0,0 +1,219 @@
|
|||
// USER DEFINED SETTINGS
|
||||
// Set driver type, fonts to be loaded, pins used and SPI control method etc
|
||||
//
|
||||
// See the User_Setup_Select.h file if you wish to be able to define multiple
|
||||
// setups and then easily select which setup file is used by the compiler.
|
||||
//
|
||||
// If this file is edited correctly then all the library example sketches should
|
||||
// run without the need to make any more changes for a particular hardware setup!
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 0. Call up the right driver file and any options for it
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Only define one driver, the other ones must be commented out
|
||||
//#define ILI9341_DRIVER
|
||||
//#define ST7735_DRIVER
|
||||
//#define ILI9163_DRIVER
|
||||
//#define S6D02A1_DRIVER
|
||||
#define RPI_ILI9486_DRIVER // 20MHz maximum SPI
|
||||
|
||||
// For M5Stack ESP32 module with integrated display ONLY, remove // in line below
|
||||
//#define M5STACK
|
||||
|
||||
// For ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
|
||||
//#define TFT_WIDTH 128
|
||||
//#define TFT_HEIGHT 160
|
||||
//#define TFT_HEIGHT 128
|
||||
|
||||
// For ST7735 ONLY, define the type of display, originally this was based on the
|
||||
// colour of the tab on the screen protector film but this is not always true, so try
|
||||
// out the different options below if the screen does not display graphics correctly,
|
||||
// e.g. colours wrong, mirror images, or tray pixels at the edges.
|
||||
// Comment out ALL BUT ONE of these options for a ST7735 display driver, save this
|
||||
// this User_Setup file, then rebuild and upload the sketch to the board again:
|
||||
|
||||
//#define ST7735_INITB
|
||||
//#define ST7735_GREENTAB
|
||||
//#define ST7735_GREENTAB2
|
||||
//#define ST7735_GREENTAB3
|
||||
//#define ST7735_GREENTAB128 // For 128 x 128 display
|
||||
//#define ST7735_REDTAB
|
||||
//#define ST7735_BLACKTAB
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 1. Define the pins that are used to interface with the display here
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// We must use hardware SPI, a minimum of 3 GPIO pins is needed.
|
||||
// Typical setup for ESP8266 NodeMCU ESP-12 is :
|
||||
//
|
||||
// Display SDO/MISO to NodeMCU pin D6 (or leave disconnected if not reading TFT)
|
||||
// Display LED to NodeMCU pin VIN (or 5V, see below)
|
||||
// Display SCK to NodeMCU pin D5
|
||||
// Display SDI/MOSI to NodeMCU pin D7
|
||||
// Display DC (RS/AO)to NodeMCU pin D3
|
||||
// Display RESET to NodeMCU pin D4 (or RST, see below)
|
||||
// Display CS to NodeMCU pin D8 (or GND, see below)
|
||||
// Display GND to NodeMCU pin GND (0V)
|
||||
// Display VCC to NodeMCU 5V or 3.3V
|
||||
//
|
||||
// The TFT RESET pin can be connected to the NodeMCU RST pin or 3.3V to free up a control pin
|
||||
//
|
||||
// The DC (Data Command) pin may be labeled AO or RS (Register Select)
|
||||
//
|
||||
// With some displays such as the ILI9341 the TFT CS pin can be connected to GND if no more
|
||||
// SPI devices (e.g. an SD Card) are connected, in this case comment out the #define TFT_CS
|
||||
// line below so it is NOT defined. Other displays such at the ST7735 require the TFT CS pin
|
||||
// to be toggled during setup, so in these cases the TFT_CS line must be defined and connected.
|
||||
//
|
||||
// The NodeMCU D0 pin can be used for RST
|
||||
//
|
||||
// See Section 2. below if DC or CS is connected to D0
|
||||
//
|
||||
// Note: only some versions of the NodeMCU provide the USB 5V on the VIN pin
|
||||
// If 5V is not available at a pin you can use 3.3V but backlight brightness
|
||||
// will be lower.
|
||||
|
||||
|
||||
// ###### 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_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V
|
||||
|
||||
//#define TOUCH_CS PIN_D1 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR PIN_D2 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
|
||||
// ###### FOR ESP8266 OVERLAP MODE EDIT THE PIN NUMBERS IN THE FOLLOWING LINES ######
|
||||
|
||||
// Overlap mode shares the ESP8266 FLASH SPI bus with the TFT so has a performance impact
|
||||
// but saves pins for other functions.
|
||||
// Use NodeMCU SD0=MISO, SD1=MOSI, CLK=SCLK to connect to TFT in overlap mode
|
||||
|
||||
// In ESP8266 overlap mode the TFT chip select MUST connect to pin D3
|
||||
//#define TFT_CS PIN_D3
|
||||
//#define TFT_DC PIN_D5 // 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
|
||||
|
||||
// In ESP8266 overlap mode the following must be defined
|
||||
//#define TFT_SPI_OVERLAP
|
||||
|
||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR ESP32 SETUP ######
|
||||
|
||||
// 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_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 TOUCH_CS 22 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR 21 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
// For the M5Stack module use these #define lines
|
||||
//#define TFT_MISO 19
|
||||
//#define TFT_MOSI 23
|
||||
//#define TFT_SCLK 18
|
||||
//#define TFT_CS 14 // Chip select control pin
|
||||
//#define TFT_DC 27 // Data Command control pin
|
||||
//#define TFT_RST 33 // Reset pin (could connect to Arduino RESET pin)
|
||||
//#define TFT_BL 32 // LED back-light
|
||||
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 2. Define the way the DC and/or CS lines are driven (ESP8266 only)
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Normally the library uses direct register access for the DC and CS lines for speed
|
||||
// If D0 (GPIO16) is used for CS or DC then a different slower method must be used
|
||||
// Uncomment one line if D0 is used for DC or CS
|
||||
// DC on D0 = 6% performance penalty at 40MHz SPI running graphics test
|
||||
// CS on D0 = 2% performance penalty at 40MHz SPI running graphics test
|
||||
|
||||
// #define D0_USED_FOR_DC
|
||||
// #define D0_USED_FOR_CS
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 3. Define the fonts that are to be used here
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Comment out the #defines below with // to stop that font being loaded
|
||||
// The ESP8366 and ESP32 have plenty of memory so commenting out fonts is not
|
||||
// normally necessary. If all fonts are loaded the extra FLASH space required is
|
||||
// about 17Kbytes. To save FLASH space only enable the fonts you need!
|
||||
|
||||
#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
|
||||
|
||||
// Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded
|
||||
// this will save ~20kbytes of FLASH
|
||||
#define SMOOTH_FONT
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 4. Not used
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 5. Other options
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Define the SPI clock frequency, this affects the graphics rendering speed. Too
|
||||
// fast and the TFT driver will not keep up and display corruption appears.
|
||||
// With an ILI9341 display 40MHz works OK, 80MHz sometimes fails
|
||||
// With a ST7735 display more than 27MHz may not work (spurious pixels and lines)
|
||||
// With an ILI9163 display 27 MHz works OK.
|
||||
// The RPi typically only works at 20MHz maximum.
|
||||
|
||||
// #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
|
||||
|
||||
// The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here:
|
||||
#define SPI_TOUCH_FREQUENCY 2500000
|
||||
|
||||
|
||||
// Comment out the following #define if "SPI Transactions" do not need to be
|
||||
// supported. When commented out the code size will be smaller and sketches will
|
||||
// run slightly faster, so leave it commented out unless you need it!
|
||||
|
||||
// Transaction support is needed to work with SD library but not needed with TFT_SdFat
|
||||
// Transaction support is required if other SPI devices are connected.
|
||||
|
||||
// Transactions are automatically enabled by the library for an ESP32 (to use HAL mutex)
|
||||
// so changing it here has no effect
|
||||
|
||||
// #define SUPPORT_TRANSACTIONS
|
||||
|
|
@ -0,0 +1,218 @@
|
|||
// USER DEFINED SETTINGS
|
||||
// Set driver type, fonts to be loaded, pins used and SPI control method etc
|
||||
//
|
||||
// See the User_Setup_Select.h file if you wish to be able to define multiple
|
||||
// setups and then easily select which setup file is used by the compiler.
|
||||
//
|
||||
// If this file is edited correctly then all the library example sketches should
|
||||
// run without the need to make any more changes for a particular hardware setup!
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 0. Call up the right driver file and any options for it
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Only define one driver, the other ones must be commented out
|
||||
#define ILI9341_DRIVER
|
||||
//#define ST7735_DRIVER
|
||||
//#define ILI9163_DRIVER
|
||||
//#define S6D02A1_DRIVER
|
||||
//#define RPI_ILI9486_DRIVER // 20MHz maximum SPI
|
||||
|
||||
// For M5Stack ESP32 module with integrated display ONLY, remove // in line below
|
||||
#define M5STACK
|
||||
|
||||
// For ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
|
||||
//#define TFT_WIDTH 128
|
||||
//#define TFT_HEIGHT 160
|
||||
//#define TFT_HEIGHT 128
|
||||
|
||||
// For ST7735 ONLY, define the type of display, originally this was based on the
|
||||
// colour of the tab on the screen protector film but this is not always true, so try
|
||||
// out the different options below if the screen does not display graphics correctly,
|
||||
// e.g. colours wrong, mirror images, or tray pixels at the edges.
|
||||
// Comment out ALL BUT ONE of these options for a ST7735 display driver, save this
|
||||
// this User_Setup file, then rebuild and upload the sketch to the board again:
|
||||
|
||||
//#define ST7735_INITB
|
||||
//#define ST7735_GREENTAB
|
||||
//#define ST7735_GREENTAB2
|
||||
//#define ST7735_GREENTAB3
|
||||
//#define ST7735_GREENTAB128 // For 128 x 128 display
|
||||
//#define ST7735_REDTAB
|
||||
//#define ST7735_BLACKTAB
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 1. Define the pins that are used to interface with the display here
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// We must use hardware SPI, a minimum of 3 GPIO pins is needed.
|
||||
// Typical setup for ESP8266 NodeMCU ESP-12 is :
|
||||
//
|
||||
// Display SDO/MISO to NodeMCU pin D6 (or leave disconnected if not reading TFT)
|
||||
// Display LED to NodeMCU pin VIN (or 5V, see below)
|
||||
// Display SCK to NodeMCU pin D5
|
||||
// Display SDI/MOSI to NodeMCU pin D7
|
||||
// Display DC (RS/AO)to NodeMCU pin D3
|
||||
// Display RESET to NodeMCU pin D4 (or RST, see below)
|
||||
// Display CS to NodeMCU pin D8 (or GND, see below)
|
||||
// Display GND to NodeMCU pin GND (0V)
|
||||
// Display VCC to NodeMCU 5V or 3.3V
|
||||
//
|
||||
// The TFT RESET pin can be connected to the NodeMCU RST pin or 3.3V to free up a control pin
|
||||
//
|
||||
// The DC (Data Command) pin may be labeled AO or RS (Register Select)
|
||||
//
|
||||
// With some displays such as the ILI9341 the TFT CS pin can be connected to GND if no more
|
||||
// SPI devices (e.g. an SD Card) are connected, in this case comment out the #define TFT_CS
|
||||
// line below so it is NOT defined. Other displays such at the ST7735 require the TFT CS pin
|
||||
// to be toggled during setup, so in these cases the TFT_CS line must be defined and connected.
|
||||
//
|
||||
// The NodeMCU D0 pin can be used for RST
|
||||
//
|
||||
// See Section 2. below if DC or CS is connected to D0
|
||||
//
|
||||
// Note: only some versions of the NodeMCU provide the USB 5V on the VIN pin
|
||||
// If 5V is not available at a pin you can use 3.3V but backlight brightness
|
||||
// will be lower.
|
||||
|
||||
|
||||
// ###### 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_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V
|
||||
|
||||
//#define TOUCH_CS PIN_D1 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR PIN_D2 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
|
||||
// ###### FOR ESP8266 OVERLAP MODE EDIT THE PIN NUMBERS IN THE FOLLOWING LINES ######
|
||||
|
||||
// Overlap mode shares the ESP8266 FLASH SPI bus with the TFT so has a performance impact
|
||||
// but saves pins for other functions.
|
||||
// Use NodeMCU SD0=MISO, SD1=MOSI, CLK=SCLK to connect to TFT in overlap mode
|
||||
|
||||
// In ESP8266 overlap mode the TFT chip select MUST connect to pin D3
|
||||
//#define TFT_CS PIN_D3
|
||||
//#define TFT_DC PIN_D5 // 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
|
||||
|
||||
// In ESP8266 overlap mode the following must be defined
|
||||
//#define TFT_SPI_OVERLAP
|
||||
|
||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR ESP32 SETUP ######
|
||||
|
||||
// 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_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 TOUCH_CS 21 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR 22 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
// For the M5Stack module use these #define lines
|
||||
#define TFT_MISO 19
|
||||
#define TFT_MOSI 23
|
||||
#define TFT_SCLK 18
|
||||
#define TFT_CS 14 // Chip select control pin
|
||||
#define TFT_DC 27 // Data Command control pin
|
||||
#define TFT_RST 33 // Reset pin (could connect to Arduino RESET pin)
|
||||
#define TFT_BL 32 // LED back-light
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 2. Define the way the DC and/or CS lines are driven (ESP8266 only)
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Normally the library uses direct register access for the DC and CS lines for speed
|
||||
// If D0 (GPIO16) is used for CS or DC then a different slower method must be used
|
||||
// Uncomment one line if D0 is used for DC or CS
|
||||
// DC on D0 = 6% performance penalty at 40MHz SPI running graphics test
|
||||
// CS on D0 = 2% performance penalty at 40MHz SPI running graphics test
|
||||
|
||||
// #define D0_USED_FOR_DC
|
||||
// #define D0_USED_FOR_CS
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 3. Define the fonts that are to be used here
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Comment out the #defines below with // to stop that font being loaded
|
||||
// The ESP8366 and ESP32 have plenty of memory so commenting out fonts is not
|
||||
// normally necessary. If all fonts are loaded the extra FLASH space required is
|
||||
// about 17Kbytes. To save FLASH space only enable the fonts you need!
|
||||
|
||||
#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
|
||||
|
||||
// Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded
|
||||
// this will save ~20kbytes of FLASH
|
||||
#define SMOOTH_FONT
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 4. Not used
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 5. Other options
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Define the SPI clock frequency, this affects the graphics rendering speed. Too
|
||||
// fast and the TFT driver will not keep up and display corruption appears.
|
||||
// With an ILI9341 display 40MHz works OK, 80MHz sometimes fails
|
||||
// With a ST7735 display more than 27MHz may not work (spurious pixels and lines)
|
||||
// With an ILI9163 display 27 MHz works OK.
|
||||
// The RPi typically only works at 20MHz maximum.
|
||||
|
||||
// #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
|
||||
|
||||
// The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here:
|
||||
#define SPI_TOUCH_FREQUENCY 2500000
|
||||
|
||||
|
||||
// Comment out the following #define if "SPI Transactions" do not need to be
|
||||
// supported. When commented out the code size will be smaller and sketches will
|
||||
// run slightly faster, so leave it commented out unless you need it!
|
||||
|
||||
// Transaction support is needed to work with SD library but not needed with TFT_SdFat
|
||||
// Transaction support is required if other SPI devices are connected.
|
||||
|
||||
// Transactions are automatically enabled by the library for an ESP32 (to use HAL mutex)
|
||||
// so changing it here has no effect
|
||||
|
||||
// #define SUPPORT_TRANSACTIONS
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
// USER DEFINED SETTINGS
|
||||
// Set driver type, fonts to be loaded, pins used and SPI control method etc
|
||||
//
|
||||
// See the User_Setup_Select.h file if you wish to be able to define multiple
|
||||
// setups and then easily select which setup file is used by the compiler.
|
||||
//
|
||||
// If this file is edited correctly then all the library example sketches should
|
||||
// run without the need to make any more changes for a particular hardware setup!
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 0. Call up the right driver file and any options for it
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Parallel bus is only supported on ESP32
|
||||
// Use ESP32 Parallel interface instead of SPI
|
||||
#define ESP32_PARALLEL
|
||||
|
||||
// Only define one driver, the other ones must be commented out
|
||||
#define ILI9481_DRIVER
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 1. Define the pins that are used to interface with the display here
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// ESP32 pins used
|
||||
#define TFT_CS 33 // Chip select control pin
|
||||
#define TFT_DC 15 // Data Command control pin - use a pin in the range 0-31
|
||||
#define TFT_RST 32 // Reset pin
|
||||
|
||||
#define TFT_WR 4 // Write strobe control pin - use a pin in the range 0-31
|
||||
#define TFT_RD 2
|
||||
|
||||
#define TFT_D0 12 // Must use pins in the range 0-31 for the data bus
|
||||
#define TFT_D1 13 // so a single register write sets/clears all bits
|
||||
#define TFT_D2 26
|
||||
#define TFT_D3 25
|
||||
#define TFT_D4 17
|
||||
#define TFT_D5 16
|
||||
#define TFT_D6 27
|
||||
#define TFT_D7 14
|
||||
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 2. Define the way the DC and/or CS lines are driven (ESP8266 only)
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 3. Define the fonts that are to be used here
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Comment out the #defines below with // to stop that font being loaded
|
||||
// The ESP8366 and ESP32 have plenty of memory so commenting out fonts is not
|
||||
// normally necessary. If all fonts are loaded the extra FLASH space required is
|
||||
// about 17Kbytes. To save FLASH space only enable the fonts you need!
|
||||
|
||||
#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
|
||||
|
||||
// Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded
|
||||
// this will save ~20kbytes of FLASH
|
||||
#define SMOOTH_FONT
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 4. Not used
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 5. Other options
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
// USER DEFINED SETTINGS
|
||||
// Set driver type, fonts to be loaded, pins used and SPI control method etc
|
||||
//
|
||||
// See the User_Setup_Select.h file if you wish to be able to define multiple
|
||||
// setups and then easily select which setup file is used by the compiler.
|
||||
//
|
||||
// If this file is edited correctly then all the library example sketches should
|
||||
// run without the need to make any more changes for a particular hardware setup!
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 0. Call up the right driver file and any options for it
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Parallel bus is only supported on ESP32
|
||||
// Use ESP32 Parallel interface instead of SPI
|
||||
#define ESP32_PARALLEL
|
||||
|
||||
// Only define one driver, the other ones must be commented out
|
||||
#define ILI9341_DRIVER
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 1. Define the pins that are used to interface with the display here
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// ESP32 pins used for the parallel interface TFT
|
||||
#define TFT_CS 33 // Chip select control pin
|
||||
#define TFT_DC 15 // Data Command control pin - use a pin in the range 0-31
|
||||
#define TFT_RST 32 // Reset pin
|
||||
|
||||
#define TFT_WR 4 // Write strobe control pin - use a pin in the range 0-31
|
||||
#define TFT_RD 2
|
||||
|
||||
#define TFT_D0 12 // Must use pins in the range 0-31 for the data bus
|
||||
#define TFT_D1 13 // so a single register write sets/clears all bits
|
||||
#define TFT_D2 26
|
||||
#define TFT_D3 25
|
||||
#define TFT_D4 17
|
||||
#define TFT_D5 16
|
||||
#define TFT_D6 27
|
||||
#define TFT_D7 14
|
||||
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 2. Define the way the DC and/or CS lines are driven (ESP8266 only)
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 3. Define the fonts that are to be used here
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Comment out the #defines below with // to stop that font being loaded
|
||||
// The ESP8366 and ESP32 have plenty of memory so commenting out fonts is not
|
||||
// normally necessary. If all fonts are loaded the extra FLASH space required is
|
||||
// about 17Kbytes. To save FLASH space only enable the fonts you need!
|
||||
|
||||
#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
|
||||
|
||||
// Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded
|
||||
// this will save ~20kbytes of FLASH
|
||||
#define SMOOTH_FONT
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 4. Not used
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 5. Other options
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,219 @@
|
|||
// USER DEFINED SETTINGS
|
||||
// Set driver type, fonts to be loaded, pins used and SPI control method etc
|
||||
//
|
||||
// See the User_Setup_Select.h file if you wish to be able to define multiple
|
||||
// setups and then easily select which setup file is used by the compiler.
|
||||
//
|
||||
// If this file is edited correctly then all the library example sketches should
|
||||
// run without the need to make any more changes for a particular hardware setup!
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 0. Call up the right driver file and any options for it
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Only define one driver, the other ones must be commented out
|
||||
//#define ILI9341_DRIVER
|
||||
//#define ST7735_DRIVER
|
||||
//#define ILI9163_DRIVER
|
||||
//#define S6D02A1_DRIVER
|
||||
//#define RPI_ILI9486_DRIVER // 20MHz maximum SPI
|
||||
#define HX8357D_DRIVER
|
||||
|
||||
// For M5Stack ESP32 module with integrated display ONLY, remove // in line below
|
||||
//#define M5STACK
|
||||
|
||||
// For ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
|
||||
//#define TFT_WIDTH 128
|
||||
//#define TFT_HEIGHT 160
|
||||
//#define TFT_HEIGHT 128
|
||||
|
||||
// For ST7735 ONLY, define the type of display, originally this was based on the
|
||||
// colour of the tab on the screen protector film but this is not always true, so try
|
||||
// out the different options below if the screen does not display graphics correctly,
|
||||
// e.g. colours wrong, mirror images, or tray pixels at the edges.
|
||||
// Comment out ALL BUT ONE of these options for a ST7735 display driver, save this
|
||||
// this User_Setup file, then rebuild and upload the sketch to the board again:
|
||||
|
||||
//#define ST7735_INITB
|
||||
//#define ST7735_GREENTAB
|
||||
//#define ST7735_GREENTAB2
|
||||
//#define ST7735_GREENTAB3
|
||||
//#define ST7735_GREENTAB128 // For 128 x 128 display
|
||||
//#define ST7735_REDTAB
|
||||
//#define ST7735_BLACKTAB
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 1. Define the pins that are used to interface with the display here
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// We must use hardware SPI, a minimum of 3 GPIO pins is needed.
|
||||
// Typical setup for ESP8266 NodeMCU ESP-12 is :
|
||||
//
|
||||
// Display SDO/MISO to NodeMCU pin D6 (or leave disconnected if not reading TFT)
|
||||
// Display LED to NodeMCU pin VIN (or 5V, see below)
|
||||
// Display SCK to NodeMCU pin D5
|
||||
// Display SDI/MOSI to NodeMCU pin D7
|
||||
// Display DC (RS/AO)to NodeMCU pin D3
|
||||
// Display RESET to NodeMCU pin D4 (or RST, see below)
|
||||
// Display CS to NodeMCU pin D8 (or GND, see below)
|
||||
// Display GND to NodeMCU pin GND (0V)
|
||||
// Display VCC to NodeMCU 5V or 3.3V
|
||||
//
|
||||
// The TFT RESET pin can be connected to the NodeMCU RST pin or 3.3V to free up a control pin
|
||||
//
|
||||
// The DC (Data Command) pin may be labeled AO or RS (Register Select)
|
||||
//
|
||||
// With some displays such as the ILI9341 the TFT CS pin can be connected to GND if no more
|
||||
// SPI devices (e.g. an SD Card) are connected, in this case comment out the #define TFT_CS
|
||||
// line below so it is NOT defined. Other displays such at the ST7735 require the TFT CS pin
|
||||
// to be toggled during setup, so in these cases the TFT_CS line must be defined and connected.
|
||||
//
|
||||
// The NodeMCU D0 pin can be used for RST
|
||||
//
|
||||
// See Section 2. below if DC or CS is connected to D0
|
||||
//
|
||||
// Note: only some versions of the NodeMCU provide the USB 5V on the VIN pin
|
||||
// If 5V is not available at a pin you can use 3.3V but backlight brightness
|
||||
// will be lower.
|
||||
|
||||
|
||||
// ###### 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_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V
|
||||
|
||||
//#define TOUCH_CS PIN_D1 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR PIN_D2 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
|
||||
// ###### FOR ESP8266 OVERLAP MODE EDIT THE PIN NUMBERS IN THE FOLLOWING LINES ######
|
||||
|
||||
// Overlap mode shares the ESP8266 FLASH SPI bus with the TFT so has a performance impact
|
||||
// but saves pins for other functions.
|
||||
// Use NodeMCU SD0=MISO, SD1=MOSI, CLK=SCLK to connect to TFT in overlap mode
|
||||
|
||||
// In ESP8266 overlap mode the TFT chip select MUST connect to pin D3
|
||||
//#define TFT_CS PIN_D3
|
||||
//#define TFT_DC PIN_D5 // 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
|
||||
|
||||
// In ESP8266 overlap mode the following must be defined
|
||||
//#define TFT_SPI_OVERLAP
|
||||
|
||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR ESP32 SETUP ######
|
||||
|
||||
// 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_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
|
||||
|
||||
// For the M5Stack module use these #define lines
|
||||
//#define TFT_MISO 19
|
||||
//#define TFT_MOSI 23
|
||||
//#define TFT_SCLK 18
|
||||
//#define TFT_CS 14 // Chip select control pin
|
||||
//#define TFT_DC 27 // Data Command control pin
|
||||
//#define TFT_RST 33 // Reset pin (could connect to Arduino RESET pin)
|
||||
//#define TFT_BL 32 // LED back-light
|
||||
|
||||
//#define TOUCH_CS 21 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR 22 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 2. Define the way the DC and/or CS lines are driven (ESP8266 only)
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Normally the library uses direct register access for the DC and CS lines for speed
|
||||
// If D0 (GPIO16) is used for CS or DC then a different slower method must be used
|
||||
// Uncomment one line if D0 is used for DC or CS
|
||||
// DC on D0 = 6% performance penalty at 40MHz SPI running graphics test
|
||||
// CS on D0 = 2% performance penalty at 40MHz SPI running graphics test
|
||||
|
||||
// #define D0_USED_FOR_DC
|
||||
// #define D0_USED_FOR_CS
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 3. Define the fonts that are to be used here
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Comment out the #defines below with // to stop that font being loaded
|
||||
// The ESP8366 and ESP32 have plenty of memory so commenting out fonts is not
|
||||
// normally necessary. If all fonts are loaded the extra FLASH space required is
|
||||
// about 17Kbytes. To save FLASH space only enable the fonts you need!
|
||||
|
||||
#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
|
||||
|
||||
// Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded
|
||||
// this will save ~20kbytes of FLASH
|
||||
#define SMOOTH_FONT
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 4. Not used
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 5. Other options
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Define the SPI clock frequency, this affects the graphics rendering speed. Too
|
||||
// fast and the TFT driver will not keep up and display corruption appears.
|
||||
// With an ILI9341 display 40MHz works OK, 80MHz sometimes fails
|
||||
// With a ST7735 display more than 27MHz may not work (spurious pixels and lines)
|
||||
// With an ILI9163 display 27 MHz works OK.
|
||||
// The RPi typically only works at 20MHz maximum.
|
||||
|
||||
// #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
|
||||
|
||||
// The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here:
|
||||
#define SPI_TOUCH_FREQUENCY 2500000
|
||||
|
||||
|
||||
// Comment out the following #define if "SPI Transactions" do not need to be
|
||||
// supported. When commented out the code size will be smaller and sketches will
|
||||
// run slightly faster, so leave it commented out unless you need it!
|
||||
|
||||
// Transaction support is needed to work with SD library but not needed with TFT_SdFat
|
||||
// Transaction support is required if other SPI devices are connected.
|
||||
|
||||
// Transactions are automatically enabled by the library for an ESP32 (to use HAL mutex)
|
||||
// so changing it here has no effect
|
||||
|
||||
// #define SUPPORT_TRANSACTIONS
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
// USER DEFINED SETTINGS
|
||||
// Set driver type, fonts to be loaded, pins used and SPI control method etc
|
||||
//
|
||||
// See the User_Setup_Select.h file if you wish to be able to define multiple
|
||||
// setups and then easily select which setup file is used by the compiler.
|
||||
//
|
||||
// If this file is edited correctly then all the library example sketches should
|
||||
// run without the need to make any more changes for a particular hardware setup!
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 0. Call up the right driver file and any options for it
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Parallel bus is only supported on ESP32
|
||||
// Use ESP32 Parallel interface instead of SPI
|
||||
#define ESP32_PARALLEL
|
||||
|
||||
// Only define one driver, the other ones must be commented out
|
||||
#define ILI9488_DRIVER
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 1. Define the pins that are used to interface with the display here
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// ESP32 pins used
|
||||
#define TFT_CS 33 // Chip select control pin
|
||||
#define TFT_DC 15 // Data Command control pin - use a pin in the range 0-31
|
||||
#define TFT_RST 32 // Reset pin
|
||||
|
||||
#define TFT_WR 4 // Write strobe control pin - use a pin in the range 0-31
|
||||
#define TFT_RD 2
|
||||
|
||||
#define TFT_D0 12 // Must use pins in the range 0-31 for the data bus
|
||||
#define TFT_D1 13 // so a single register write sets/clears all bits
|
||||
#define TFT_D2 26
|
||||
#define TFT_D3 25
|
||||
#define TFT_D4 17
|
||||
#define TFT_D5 16
|
||||
#define TFT_D6 27
|
||||
#define TFT_D7 14
|
||||
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 2. Define the way the DC and/or CS lines are driven (ESP8266 only)
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 3. Define the fonts that are to be used here
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Comment out the #defines below with // to stop that font being loaded
|
||||
// The ESP8366 and ESP32 have plenty of memory so commenting out fonts is not
|
||||
// normally necessary. If all fonts are loaded the extra FLASH space required is
|
||||
// about 17Kbytes. To save FLASH space only enable the fonts you need!
|
||||
|
||||
#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
|
||||
|
||||
// Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded
|
||||
// this will save ~20kbytes of FLASH
|
||||
#define SMOOTH_FONT
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 4. Not used
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 5. Other options
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
// USER DEFINED SETTINGS
|
||||
// Set driver type, fonts to be loaded etc
|
||||
//
|
||||
// See the User_Setup_Select.h file if you wish to be able to define multiple
|
||||
// setups and then easily select which setup file is used by the compiler.
|
||||
//
|
||||
// If this file is edited correctly then all the library example sketches should
|
||||
// run without the need to make any more changes for a particular hardware setup!
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 0. Call up the right driver file and any options for it
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
#define EPD_DRIVER // ePaper driver
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 1. Define the pins that are used to interface with the display here
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
|
||||
// READ THIS READ THIS READ THIS READ THIS READ THIS READ THIS
|
||||
// Install the ePaper library for your own display size and type
|
||||
// from here:
|
||||
// https://github.com/Bodmer/EPD_Libraries
|
||||
|
||||
// Note: Pin allocations for the ePaper signals are defined in
|
||||
// the ePaper library's epdif.h file. There follows the default
|
||||
// pins already included in epdif.h file for the ESP8266:
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// For ESP8266 connect as follows: //
|
||||
// Display 3.3V to NodeMCU 3V3 //
|
||||
// Display GND to NodeMCU GND //
|
||||
// //
|
||||
// Display GPIO NodeMCU pin //
|
||||
// BUSY 5 D1 //
|
||||
// RESET 4 D2 //
|
||||
// DC 0 D3 //
|
||||
// CS 2 D4 //
|
||||
// CLK 14 D5 //
|
||||
// D6 (MISO not connected to display) //
|
||||
// DIN 13 D7 //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 2. Not used
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 3. Define the fonts that are to be used here
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Comment out the #defines below with // to stop that font being loaded
|
||||
// The ESP8366 and ESP32 have plenty of memory so commenting out fonts is not
|
||||
// normally necessary. If all fonts are loaded the extra FLASH space required is
|
||||
// about 17Kbytes. To save FLASH space only enable the fonts you need!
|
||||
|
||||
#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_FONT8N // Font 8. Alternative to Font 8 below, slightly narrower, so 3 digits fit a 160 pixel TFT
|
||||
#define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
|
||||
#define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts
|
||||
|
||||
// Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded
|
||||
// this will save ~20kbytes of FLASH
|
||||
#define SMOOTH_FONT
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 4. Not used
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 5. Not used
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
|
|
@ -0,0 +1,252 @@
|
|||
// USER DEFINED SETTINGS
|
||||
// Set driver type, fonts to be loaded, pins used and SPI control method etc
|
||||
//
|
||||
// See the User_Setup_Select.h file if you wish to be able to define multiple
|
||||
// setups and then easily select which setup file is used by the compiler.
|
||||
//
|
||||
// If this file is edited correctly then all the library example sketches should
|
||||
// run without the need to make any more changes for a particular hardware setup!
|
||||
// Note that some sketches are designed for a particular TFT pixel width/height
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 0. Call up the right driver file and any options for it
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Only define one driver, the other ones must be commented out
|
||||
//#define ILI9341_DRIVER
|
||||
//#define ST7735_DRIVER
|
||||
//#define ILI9163_DRIVER
|
||||
//#define S6D02A1_DRIVER
|
||||
//#define RPI_ILI9486_DRIVER // 20MHz maximum SPI
|
||||
//#define HX8357D_DRIVER
|
||||
//#define ILI9481_DRIVER
|
||||
//#define ILI9488_DRIVER
|
||||
#define ST7789_DRIVER
|
||||
|
||||
// For M5Stack ESP32 module with integrated display ONLY, remove // in line below
|
||||
//#define M5STACK
|
||||
|
||||
// For ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
|
||||
//#define TFT_WIDTH 128
|
||||
//#define TFT_HEIGHT 160
|
||||
//#define TFT_HEIGHT 128
|
||||
|
||||
// For ST7735 ONLY, define the type of display, originally this was based on the
|
||||
// colour of the tab on the screen protector film but this is not always true, so try
|
||||
// out the different options below if the screen does not display graphics correctly,
|
||||
// e.g. colours wrong, mirror images, or tray pixels at the edges.
|
||||
// Comment out ALL BUT ONE of these options for a ST7735 display driver, save this
|
||||
// this User_Setup file, then rebuild and upload the sketch to the board again:
|
||||
|
||||
//#define ST7735_INITB
|
||||
//#define ST7735_GREENTAB
|
||||
//#define ST7735_GREENTAB2
|
||||
//#define ST7735_GREENTAB3
|
||||
//#define ST7735_GREENTAB128 // For 128 x 128 display
|
||||
//#define ST7735_REDTAB
|
||||
//#define ST7735_BLACKTAB
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 1. Define the pins that are used to interface with the display here
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// We must use hardware SPI, a minimum of 3 GPIO pins is needed.
|
||||
// Typical setup for ESP8266 NodeMCU ESP-12 is :
|
||||
//
|
||||
// Display SDO/MISO to NodeMCU pin D6 (or leave disconnected if not reading TFT)
|
||||
// Display LED to NodeMCU pin VIN (or 5V, see below)
|
||||
// Display SCK to NodeMCU pin D5
|
||||
// Display SDI/MOSI to NodeMCU pin D7
|
||||
// Display DC (RS/AO)to NodeMCU pin D3
|
||||
// Display RESET to NodeMCU pin D4 (or RST, see below)
|
||||
// Display CS to NodeMCU pin D8 (or GND, see below)
|
||||
// Display GND to NodeMCU pin GND (0V)
|
||||
// Display VCC to NodeMCU 5V or 3.3V
|
||||
//
|
||||
// The TFT RESET pin can be connected to the NodeMCU RST pin or 3.3V to free up a control pin
|
||||
//
|
||||
// The DC (Data Command) pin may be labeled AO or RS (Register Select)
|
||||
//
|
||||
// With some displays such as the ILI9341 the TFT CS pin can be connected to GND if no more
|
||||
// SPI devices (e.g. an SD Card) are connected, in this case comment out the #define TFT_CS
|
||||
// line below so it is NOT defined. Other displays such at the ST7735 require the TFT CS pin
|
||||
// to be toggled during setup, so in these cases the TFT_CS line must be defined and connected.
|
||||
//
|
||||
// The NodeMCU D0 pin can be used for RST
|
||||
//
|
||||
// See Section 2. below if DC or CS is connected to D0
|
||||
//
|
||||
// Note: only some versions of the NodeMCU provide the USB 5V on the VIN pin
|
||||
// If 5V is not available at a pin you can use 3.3V but backlight brightness
|
||||
// will be lower.
|
||||
|
||||
|
||||
// ###### 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_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V
|
||||
|
||||
//#define TOUCH_CS PIN_D2 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR PIN_D2 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
|
||||
// ###### FOR ESP8266 OVERLAP MODE EDIT THE PIN NUMBERS IN THE FOLLOWING LINES ######
|
||||
|
||||
// Overlap mode shares the ESP8266 FLASH SPI bus with the TFT so has a performance impact
|
||||
// but saves pins for other functions.
|
||||
// Use NodeMCU SD0=MISO, SD1=MOSI, CLK=SCLK to connect to TFT in overlap mode
|
||||
|
||||
// In ESP8266 overlap mode the TFT chip select MUST connect to pin D3
|
||||
//#define TFT_CS PIN_D3
|
||||
//#define TFT_DC PIN_D5 // 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
|
||||
|
||||
// In ESP8266 overlap mode the following must be defined
|
||||
//#define TFT_SPI_OVERLAP
|
||||
|
||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR ESP32 SETUP ######
|
||||
|
||||
// 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_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
|
||||
|
||||
// For the M5Stack module use these #define lines
|
||||
//#define TFT_MISO 19
|
||||
//#define TFT_MOSI 23
|
||||
//#define TFT_SCLK 18
|
||||
//#define TFT_CS 14 // Chip select control pin
|
||||
//#define TFT_DC 27 // Data Command control pin
|
||||
//#define TFT_RST 33 // Reset pin (could connect to Arduino RESET pin)
|
||||
//#define TFT_BL 32 // LED back-light
|
||||
|
||||
//#define TOUCH_CS 21 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR 22 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
// ###### EDIT THE PINs BELOW TO SUIT YOUR ESP32 PARALLEL TFT SETUP ######
|
||||
|
||||
// The library supports 8 bit parallel TFTs with the ESP32, the pin
|
||||
// selection below is compatible with ESP32 boards in UNO format.
|
||||
// Wemos D32 boards need to be modified, see diagram in Tools folder.
|
||||
// Only ILI9481 and ILI9341 based displays have been tested!
|
||||
|
||||
// Parallel bus is only supported on ESP32
|
||||
// Uncomment line below to use ESP32 Parallel interface instead of SPI
|
||||
|
||||
//#define ESP32_PARALLEL
|
||||
|
||||
// The ESP32 and TFT the pins used for testing are:
|
||||
//#define TFT_CS 33 // Chip select control pin (library pulls permanently low
|
||||
//#define TFT_DC 15 // Data Command control pin - use a pin in the range 0-31
|
||||
//#define TFT_RST 32 // Reset pin, toggles on startup
|
||||
|
||||
//#define TFT_WR 4 // Write strobe control pin - use a pin in the range 0-31
|
||||
//#define TFT_RD 2 // Read strobe control pin - use a pin in the range 0-31
|
||||
|
||||
//#define TFT_D0 12 // Must use pins in the range 0-31 for the data bus
|
||||
//#define TFT_D1 13 // so a single register write sets/clears all bits.
|
||||
//#define TFT_D2 26 // Pins can be randomly assigned, this does not affect
|
||||
//#define TFT_D3 25 // TFT screen update performance.
|
||||
//#define TFT_D4 17
|
||||
//#define TFT_D5 16
|
||||
//#define TFT_D6 27
|
||||
//#define TFT_D7 14
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 2. Define the way the DC and/or CS lines are driven (ESP8266 only)
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Normally the library uses direct register access for the DC and CS lines for speed
|
||||
// If D0 (GPIO16) is used for CS or DC then a different slower method must be used
|
||||
// Uncomment one line if D0 is used for DC or CS
|
||||
// DC on D0 = 6% performance penalty at 40MHz SPI running graphics test
|
||||
// CS on D0 = 2% performance penalty at 40MHz SPI running graphics test
|
||||
|
||||
// #define D0_USED_FOR_DC
|
||||
// #define D0_USED_FOR_CS
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 3. Define the fonts that are to be used here
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Comment out the #defines below with // to stop that font being loaded
|
||||
// The ESP8366 and ESP32 have plenty of memory so commenting out fonts is not
|
||||
// normally necessary. If all fonts are loaded the extra FLASH space required is
|
||||
// about 17Kbytes. To save FLASH space only enable the fonts you need!
|
||||
|
||||
#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
|
||||
|
||||
// Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded
|
||||
// this will save ~20kbytes of FLASH
|
||||
#define SMOOTH_FONT
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 4. Not used
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 5. Other options
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Define the SPI clock frequency, this affects the graphics rendering speed. Too
|
||||
// fast and the TFT driver will not keep up and display corruption appears.
|
||||
// With an ILI9341 display 40MHz works OK, 80MHz sometimes fails
|
||||
// With a ST7735 display more than 27MHz may not work (spurious pixels and lines)
|
||||
// With an ILI9163 display 27 MHz works OK.
|
||||
// The RPi typically only works at 20MHz maximum.
|
||||
|
||||
// #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
|
||||
|
||||
// The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here:
|
||||
#define SPI_TOUCH_FREQUENCY 2500000
|
||||
|
||||
|
||||
// Comment out the following #define if "SPI Transactions" do not need to be
|
||||
// supported. When commented out the code size will be smaller and sketches will
|
||||
// run slightly faster, so leave it commented out unless you need it!
|
||||
|
||||
// Transaction support is needed to work with SD library but not needed with TFT_SdFat
|
||||
// Transaction support is required if other SPI devices are connected.
|
||||
|
||||
// Transactions are automatically enabled by the library for an ESP32 (to use HAL mutex)
|
||||
// so changing it here has no effect
|
||||
|
||||
//#define SUPPORT_TRANSACTIONS
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
// USER DEFINED SETTINGS
|
||||
//
|
||||
// The User_Setup header that will be called up is defined in User_Setup_Select.h
|
||||
//
|
||||
// Set driver type, fonts to be loaded, pins used and SPI control method etc
|
||||
//
|
||||
// If this file is editted correctly then all the library example sketches should
|
||||
//
|
||||
// See the User_Setup_Select.h file if you wish to be able to define multiple
|
||||
// setups and then easily select which setup file is used by the compiler.
|
||||
//
|
||||
// If this file is edited correctly then all the library example sketches should
|
||||
// run without the need to make any more changes for a particular hardware setup!
|
||||
|
||||
// ##################################################################################
|
||||
|
|
@ -16,8 +16,14 @@
|
|||
// Only define one driver, the other ones must be commented out
|
||||
#define ILI9341_DRIVER
|
||||
//#define ST7735_DRIVER
|
||||
//#define ILI9163_DRIVER
|
||||
//#define S6D02A1_DRIVER
|
||||
//#define RPI_ILI9486_DRIVER // 20MHz maximum SPI
|
||||
|
||||
// For ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
|
||||
// For M5Stack ESP32 module with integrated display ONLY, remove // in line below
|
||||
//#define M5STACK
|
||||
|
||||
// For ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
|
||||
//#define TFT_WIDTH 128
|
||||
//#define TFT_HEIGHT 160
|
||||
//#define TFT_HEIGHT 128
|
||||
|
|
@ -32,6 +38,8 @@
|
|||
//#define ST7735_INITB
|
||||
//#define ST7735_GREENTAB
|
||||
//#define ST7735_GREENTAB2
|
||||
//#define ST7735_GREENTAB3
|
||||
//#define ST7735_GREENTAB128 // For 128 x 128 display
|
||||
//#define ST7735_REDTAB
|
||||
//#define ST7735_BLACKTAB
|
||||
|
||||
|
|
@ -42,13 +50,13 @@
|
|||
// ##################################################################################
|
||||
|
||||
// We must use hardware SPI, a minimum of 3 GPIO pins is needed.
|
||||
// Typical setup for NodeMCU ESP-12 is :
|
||||
// Typical setup for ESP8266 NodeMCU ESP-12 is :
|
||||
//
|
||||
// Display SDO/MISO to NodeMCU pin D6 (or leave disconnected if not reading TFT)
|
||||
// Display LED to NodeMCU pin VIN (or 5V, see below)
|
||||
// Display SCK to NodeMCU pin D5
|
||||
// Display SDI/MOSI to NodeMCU pin D7
|
||||
// Display DC (or AO)to NodeMCU pin D3
|
||||
// Display DC (RS/AO)to NodeMCU pin D3
|
||||
// Display RESET to NodeMCU pin D4 (or RST, see below)
|
||||
// Display CS to NodeMCU pin D8 (or GND, see below)
|
||||
// Display GND to NodeMCU pin GND (0V)
|
||||
|
|
@ -56,8 +64,10 @@
|
|||
//
|
||||
// The TFT RESET pin can be connected to the NodeMCU RST pin or 3.3V to free up a control pin
|
||||
//
|
||||
// The DC (Data Command) pin may be labeled AO or RS (Register Select)
|
||||
//
|
||||
// With some displays such as the ILI9341 the TFT CS pin can be connected to GND if no more
|
||||
// SPI deivces (e.g. an SD Card) are connected, in this case comment out the #define TFT_CS
|
||||
// SPI devices (e.g. an SD Card) are connected, in this case comment out the #define TFT_CS
|
||||
// line below so it is NOT defined. Other displays such at the ST7735 require the TFT CS pin
|
||||
// to be toggled during setup, so in these cases the TFT_CS line must be defined and connected.
|
||||
//
|
||||
|
|
@ -69,23 +79,64 @@
|
|||
// If 5V is not available at a pin you can use 3.3V but backlight brightness
|
||||
// will be lower.
|
||||
|
||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR SETUP ######
|
||||
|
||||
// ModeMCU
|
||||
// ###### 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_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V
|
||||
|
||||
// ESP32 Dev board (planned, not supported yet)
|
||||
//#define TFT_CS 5 // Chip select control pin
|
||||
//#define TFT_DC 2 // Data Command control pin
|
||||
//#define TFT_RST 4 // Reset pin (could connect to Arduino RESET pin)
|
||||
//#define TOUCH_CS PIN_D1 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR PIN_D2 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
|
||||
// ###### FOR ESP8266 OVERLAP MODE EDIT THE PIN NUMBERS IN THE FOLLOWING LINES ######
|
||||
|
||||
// Overlap mode shares the ESP8266 FLASH SPI bus with the TFT so has a performance impact
|
||||
// but saves pins for other functions.
|
||||
// Use NodeMCU SD0=MISO, SD1=MOSI, CLK=SCLK to connect to TFT in overlap mode
|
||||
|
||||
// In ESP8266 overlap mode the TFT chip select MUST connect to pin D3
|
||||
//#define TFT_CS PIN_D3
|
||||
//#define TFT_DC PIN_D5 // 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
|
||||
|
||||
// In ESP8266 overlap mode the following must be defined
|
||||
//#define TFT_SPI_OVERLAP
|
||||
|
||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR ESP32 SETUP ######
|
||||
|
||||
// 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_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 TOUCH_CS 21 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR 22 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
// For the M5Stack module use these #define lines
|
||||
//#define TFT_MISO 19
|
||||
//#define TFT_MOSI 23
|
||||
//#define TFT_SCLK 18
|
||||
//#define TFT_CS 14 // Chip select control pin
|
||||
//#define TFT_DC 27 // Data Command control pin
|
||||
//#define TFT_RST 33 // Reset pin (could connect to Arduino RESET pin)
|
||||
//#define TFT_BL 32 // LED back-light
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 2. Define the way the DC and/or CS lines are driven
|
||||
// Section 2. Define the way the DC and/or CS lines are driven (ESP8266 only)
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
|
|
@ -105,9 +156,9 @@
|
|||
// ##################################################################################
|
||||
|
||||
// Comment out the #defines below with // to stop that font being loaded
|
||||
// The ESP8366 had plenty of memory so commenting out fonts is not normally necessary
|
||||
// If all fonts are loaded the extra FLASH space required is about 17Kbytes...
|
||||
// To save FLASH space only enable the fonts you need!
|
||||
// The ESP8366 and ESP32 have plenty of memory so commenting out fonts is not
|
||||
// normally necessary. If all fonts are loaded the extra FLASH space required is
|
||||
// about 17Kbytes. To save FLASH space only enable the fonts you need!
|
||||
|
||||
#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
|
||||
|
|
@ -115,8 +166,13 @@
|
|||
#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
|
||||
|
||||
// Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded
|
||||
// this will save ~20kbytes of FLASH
|
||||
#define SMOOTH_FONT
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 4. Not used
|
||||
|
|
@ -130,23 +186,33 @@
|
|||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Define the SPI clock frequency
|
||||
// Define the SPI clock frequency, this affects the graphics rendering speed. Too
|
||||
// fast and the TFT driver will not keep up and display corruption appears.
|
||||
// With an ILI9341 display 40MHz works OK, 80MHz sometimes fails
|
||||
// With a ST7735 display more than 27MHz may not work (spurious pixels and lines)
|
||||
// With an ILI9163 display 27 MHz works OK.
|
||||
// The RPi typically only works at 20MHz maximum.
|
||||
|
||||
// #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 27000000 // Actually sets it to 26.67MHz = 80/3
|
||||
// #define SPI_FREQUENCY 40000000 // Maximum to use SPIFFS
|
||||
// #define SPI_FREQUENCY 80000000
|
||||
|
||||
// The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here:
|
||||
#define SPI_TOUCH_FREQUENCY 2500000
|
||||
|
||||
|
||||
// Comment out the following #define if "SPI Transactions" do not need to be
|
||||
// supported. Tranaction support is required if other SPI devices are connected.
|
||||
// When commented out the code size will be smaller and sketches will
|
||||
// supported. When commented out the code size will be smaller and sketches will
|
||||
// run slightly faster, so leave it commented out unless you need it!
|
||||
|
||||
// Transaction support is needed to work with SD library but not needed with TFT_SdFat
|
||||
// Transaction support is required if other SPI devices are connected.
|
||||
|
||||
// Transactions are automatically enabled by the library for an ESP32 (to use HAL mutex)
|
||||
// so changing it here has no effect
|
||||
|
||||
// #define SUPPORT_TRANSACTIONS
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
// USER DEFINED SETTINGS
|
||||
//
|
||||
// The User_Setup header that will be called up is defined in User_Setup_Select.h
|
||||
//
|
||||
// Set driver type, fonts to be loaded, pins used and SPI control method etc
|
||||
//
|
||||
// If this file is editted correctly then all the library example sketches should
|
||||
//
|
||||
// See the User_Setup_Select.h file if you wish to be able to define multiple
|
||||
// setups and then easily select which setup file is used by the compiler.
|
||||
//
|
||||
// If this file is edited correctly then all the library example sketches should
|
||||
// run without the need to make any more changes for a particular hardware setup!
|
||||
|
||||
// ##################################################################################
|
||||
|
|
@ -16,8 +16,14 @@
|
|||
// Only define one driver, the other ones must be commented out
|
||||
//#define ILI9341_DRIVER
|
||||
#define ST7735_DRIVER
|
||||
//#define ILI9163_DRIVER
|
||||
//#define S6D02A1_DRIVER
|
||||
//#define RPI_ILI9486_DRIVER // 20MHz maximum SPI
|
||||
|
||||
// For ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
|
||||
// For M5Stack ESP32 module with integrated display ONLY, remove // in line below
|
||||
//#define M5STACK
|
||||
|
||||
// For ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
|
||||
#define TFT_WIDTH 128
|
||||
#define TFT_HEIGHT 160
|
||||
//#define TFT_HEIGHT 128
|
||||
|
|
@ -33,6 +39,7 @@
|
|||
//#define ST7735_GREENTAB
|
||||
//#define ST7735_GREENTAB2
|
||||
//#define ST7735_GREENTAB3
|
||||
//#define ST7735_GREENTAB128 // For 128 x 128 display
|
||||
#define ST7735_REDTAB
|
||||
//#define ST7735_BLACKTAB
|
||||
|
||||
|
|
@ -43,13 +50,13 @@
|
|||
// ##################################################################################
|
||||
|
||||
// We must use hardware SPI, a minimum of 3 GPIO pins is needed.
|
||||
// Typical setup for NodeMCU ESP-12 is :
|
||||
// Typical setup for ESP8266 NodeMCU ESP-12 is :
|
||||
//
|
||||
// Display SDO/MISO to NodeMCU pin D6 (or leave disconnected if not reading TFT)
|
||||
// Display LED to NodeMCU pin VIN (or 5V, see below)
|
||||
// Display SCK to NodeMCU pin D5
|
||||
// Display SDI/MOSI to NodeMCU pin D7
|
||||
// Display DC (or AO)to NodeMCU pin D3
|
||||
// Display DC (RS/AO)to NodeMCU pin D3
|
||||
// Display RESET to NodeMCU pin D4 (or RST, see below)
|
||||
// Display CS to NodeMCU pin D8 (or GND, see below)
|
||||
// Display GND to NodeMCU pin GND (0V)
|
||||
|
|
@ -57,8 +64,10 @@
|
|||
//
|
||||
// The TFT RESET pin can be connected to the NodeMCU RST pin or 3.3V to free up a control pin
|
||||
//
|
||||
// The DC (Data Command) pin may be labeled AO or RS (Register Select)
|
||||
//
|
||||
// With some displays such as the ILI9341 the TFT CS pin can be connected to GND if no more
|
||||
// SPI deivces (e.g. an SD Card) are connected, in this case comment out the #define TFT_CS
|
||||
// SPI devices (e.g. an SD Card) are connected, in this case comment out the #define TFT_CS
|
||||
// line below so it is NOT defined. Other displays such at the ST7735 require the TFT CS pin
|
||||
// to be toggled during setup, so in these cases the TFT_CS line must be defined and connected.
|
||||
//
|
||||
|
|
@ -70,23 +79,64 @@
|
|||
// If 5V is not available at a pin you can use 3.3V but backlight brightness
|
||||
// will be lower.
|
||||
|
||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR SETUP ######
|
||||
|
||||
// ModeMCU
|
||||
// ###### 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_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V
|
||||
|
||||
// ESP32 Dev board (planned, not test/supported yet)
|
||||
//#define TFT_CS 5 // Chip select control pin
|
||||
//#define TFT_DC 2 // Data Command control pin
|
||||
//#define TFT_RST 4 // Reset pin (could connect to Arduino RESET pin)
|
||||
//#define TOUCH_CS PIN_D1 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR PIN_D2 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
|
||||
// ###### FOR ESP8266 OVERLAP MODE EDIT THE PIN NUMBERS IN THE FOLLOWING LINES ######
|
||||
|
||||
// Overlap mode shares the ESP8266 FLASH SPI bus with the TFT so has a performance impact
|
||||
// but saves pins for other functions.
|
||||
// Use NodeMCU SD0=MISO, SD1=MOSI, CLK=SCLK to connect to TFT in overlap mode
|
||||
|
||||
// In ESP8266 overlap mode the TFT chip select MUST connect to pin D3
|
||||
//#define TFT_CS PIN_D3
|
||||
//#define TFT_DC PIN_D5 // 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
|
||||
|
||||
// In ESP8266 overlap mode the following must be defined
|
||||
//#define TFT_SPI_OVERLAP
|
||||
|
||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR ESP32 SETUP ######
|
||||
|
||||
// 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_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 TOUCH_CS 21 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR 22 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
// For the M5Stack module use these #define lines
|
||||
//#define TFT_MISO 19
|
||||
//#define TFT_MOSI 23
|
||||
//#define TFT_SCLK 18
|
||||
//#define TFT_CS 14 // Chip select control pin
|
||||
//#define TFT_DC 27 // Data Command control pin
|
||||
//#define TFT_RST 33 // Reset pin (could connect to Arduino RESET pin)
|
||||
//#define TFT_BL 32 // LED back-light
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 2. Define the way the DC and/or CS lines are driven
|
||||
// Section 2. Define the way the DC and/or CS lines are driven (ESP8266 only)
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
|
|
@ -106,9 +156,9 @@
|
|||
// ##################################################################################
|
||||
|
||||
// Comment out the #defines below with // to stop that font being loaded
|
||||
// The ESP8366 had plenty of memory so commenting out fonts is not normally necessary
|
||||
// If all fonts are loaded the extra FLASH space required is about 17Kbytes...
|
||||
// To save FLASH space only enable the fonts you need!
|
||||
// The ESP8366 and ESP32 have plenty of memory so commenting out fonts is not
|
||||
// normally necessary. If all fonts are loaded the extra FLASH space required is
|
||||
// about 17Kbytes. To save FLASH space only enable the fonts you need!
|
||||
|
||||
#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
|
||||
|
|
@ -116,8 +166,13 @@
|
|||
#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
|
||||
|
||||
// Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded
|
||||
// this will save ~20kbytes of FLASH
|
||||
#define SMOOTH_FONT
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 4. Not used
|
||||
|
|
@ -131,23 +186,33 @@
|
|||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Define the SPI clock frequency
|
||||
// Define the SPI clock frequency, this affects the graphics rendering speed. Too
|
||||
// fast and the TFT driver will not keep up and display corruption appears.
|
||||
// With an ILI9341 display 40MHz works OK, 80MHz sometimes fails
|
||||
// With a ST7735 display more than 27MHz may not work (spurious pixels and lines)
|
||||
// With an ILI9163 display 27 MHz works OK.
|
||||
// The RPi typically only works at 20MHz maximum.
|
||||
|
||||
// #define SPI_FREQUENCY 1000000
|
||||
// #define SPI_FREQUENCY 5000000
|
||||
// #define SPI_FREQUENCY 10000000
|
||||
// #define SPI_FREQUENCY 20000000
|
||||
#define SPI_FREQUENCY 27000000 // Maximum for my ST7735. It is actually 26.67MHz = 80/3
|
||||
#define SPI_FREQUENCY 27000000 // Actually sets it to 26.67MHz = 80/3
|
||||
// #define SPI_FREQUENCY 40000000 // Maximum to use SPIFFS
|
||||
// #define SPI_FREQUENCY 80000000
|
||||
|
||||
// The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here:
|
||||
#define SPI_TOUCH_FREQUENCY 2500000
|
||||
|
||||
|
||||
// Comment out the following #define if "SPI Transactions" do not need to be
|
||||
// supported. Tranaction support is required if other SPI devices are connected.
|
||||
// When commented out the code size will be smaller and sketches will
|
||||
// supported. When commented out the code size will be smaller and sketches will
|
||||
// run slightly faster, so leave it commented out unless you need it!
|
||||
|
||||
// Transaction support is needed to work with SD library but not needed with TFT_SdFat
|
||||
// Transaction support is required if other SPI devices are connected.
|
||||
|
||||
// Transactions are automatically enabled by the library for an ESP32 (to use HAL mutex)
|
||||
// so changing it here has no effect
|
||||
|
||||
// #define SUPPORT_TRANSACTIONS
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
// USER DEFINED SETTINGS
|
||||
//
|
||||
// The User_Setup header that will be called up is defined in User_Setup_Select.h
|
||||
//
|
||||
// Set driver type, fonts to be loaded, pins used and SPI control method etc
|
||||
//
|
||||
// If this file is editted correctly then all the library example sketches should
|
||||
//
|
||||
// See the User_Setup_Select.h file if you wish to be able to define multiple
|
||||
// setups and then easily select which setup file is used by the compiler.
|
||||
//
|
||||
// If this file is edited correctly then all the library example sketches should
|
||||
// run without the need to make any more changes for a particular hardware setup!
|
||||
|
||||
// ##################################################################################
|
||||
|
|
@ -17,12 +17,32 @@
|
|||
//#define ILI9341_DRIVER
|
||||
//#define ST7735_DRIVER
|
||||
#define ILI9163_DRIVER
|
||||
//#define S6D02A1_DRIVER
|
||||
//#define RPI_ILI9486_DRIVER // 20MHz maximum SPI
|
||||
|
||||
// For ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
|
||||
// For M5Stack ESP32 module with integrated display ONLY, remove // in line below
|
||||
//#define M5STACK
|
||||
|
||||
// For ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
|
||||
#define TFT_WIDTH 128
|
||||
#define TFT_HEIGHT 160
|
||||
//#define TFT_HEIGHT 128
|
||||
|
||||
// For ST7735 ONLY, define the type of display, originally this was based on the
|
||||
// colour of the tab on the screen protector film but this is not always true, so try
|
||||
// out the different options below if the screen does not display graphics correctly,
|
||||
// e.g. colours wrong, mirror images, or tray pixels at the edges.
|
||||
// Comment out ALL BUT ONE of these options for a ST7735 display driver, save this
|
||||
// this User_Setup file, then rebuild and upload the sketch to the board again:
|
||||
|
||||
//#define ST7735_INITB
|
||||
//#define ST7735_GREENTAB
|
||||
//#define ST7735_GREENTAB2
|
||||
//#define ST7735_GREENTAB3
|
||||
//#define ST7735_GREENTAB128 // For 128 x 128 display
|
||||
//#define ST7735_REDTAB
|
||||
//#define ST7735_BLACKTAB
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 1. Define the pins that are used to interface with the display here
|
||||
|
|
@ -30,13 +50,13 @@
|
|||
// ##################################################################################
|
||||
|
||||
// We must use hardware SPI, a minimum of 3 GPIO pins is needed.
|
||||
// Typical setup for NodeMCU ESP-12 is :
|
||||
// Typical setup for ESP8266 NodeMCU ESP-12 is :
|
||||
//
|
||||
// Display SDO/MISO to NodeMCU pin D6 (or leave disconnected if not reading TFT)
|
||||
// Display LED to NodeMCU pin VIN (or 5V, see below)
|
||||
// Display SCK to NodeMCU pin D5
|
||||
// Display SDI/MOSI to NodeMCU pin D7
|
||||
// Display DC (or AO)to NodeMCU pin D3
|
||||
// Display DC (RS/AO)to NodeMCU pin D3
|
||||
// Display RESET to NodeMCU pin D4 (or RST, see below)
|
||||
// Display CS to NodeMCU pin D8 (or GND, see below)
|
||||
// Display GND to NodeMCU pin GND (0V)
|
||||
|
|
@ -44,8 +64,10 @@
|
|||
//
|
||||
// The TFT RESET pin can be connected to the NodeMCU RST pin or 3.3V to free up a control pin
|
||||
//
|
||||
// The DC (Data Command) pin may be labeled AO or RS (Register Select)
|
||||
//
|
||||
// With some displays such as the ILI9341 the TFT CS pin can be connected to GND if no more
|
||||
// SPI deivces (e.g. an SD Card) are connected, in this case comment out the #define TFT_CS
|
||||
// SPI devices (e.g. an SD Card) are connected, in this case comment out the #define TFT_CS
|
||||
// line below so it is NOT defined. Other displays such at the ST7735 require the TFT CS pin
|
||||
// to be toggled during setup, so in these cases the TFT_CS line must be defined and connected.
|
||||
//
|
||||
|
|
@ -57,23 +79,64 @@
|
|||
// If 5V is not available at a pin you can use 3.3V but backlight brightness
|
||||
// will be lower.
|
||||
|
||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR SETUP ######
|
||||
|
||||
// ModeMCU
|
||||
// ###### 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_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V
|
||||
|
||||
// ESP32 Dev board (planned, not supported yet)
|
||||
//#define TFT_CS 5 // Chip select control pin
|
||||
//#define TFT_DC 2 // Data Command control pin
|
||||
//#define TFT_RST 4 // Reset pin (could connect to Arduino RESET pin)
|
||||
//#define TOUCH_CS PIN_D1 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR PIN_D2 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
|
||||
// ###### FOR ESP8266 OVERLAP MODE EDIT THE PIN NUMBERS IN THE FOLLOWING LINES ######
|
||||
|
||||
// Overlap mode shares the ESP8266 FLASH SPI bus with the TFT so has a performance impact
|
||||
// but saves pins for other functions.
|
||||
// Use NodeMCU SD0=MISO, SD1=MOSI, CLK=SCLK to connect to TFT in overlap mode
|
||||
|
||||
// In ESP8266 overlap mode the TFT chip select MUST connect to pin D3
|
||||
//#define TFT_CS PIN_D3
|
||||
//#define TFT_DC PIN_D5 // 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
|
||||
|
||||
// In ESP8266 overlap mode the following must be defined
|
||||
//#define TFT_SPI_OVERLAP
|
||||
|
||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR ESP32 SETUP ######
|
||||
|
||||
// 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_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 TOUCH_CS 21 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR 22 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
// For the M5Stack module use these #define lines
|
||||
//#define TFT_MISO 19
|
||||
//#define TFT_MOSI 23
|
||||
//#define TFT_SCLK 18
|
||||
//#define TFT_CS 14 // Chip select control pin
|
||||
//#define TFT_DC 27 // Data Command control pin
|
||||
//#define TFT_RST 33 // Reset pin (could connect to Arduino RESET pin)
|
||||
//#define TFT_BL 32 // LED back-light
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 2. Define the way the DC and/or CS lines are driven
|
||||
// Section 2. Define the way the DC and/or CS lines are driven (ESP8266 only)
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
|
|
@ -93,9 +156,9 @@
|
|||
// ##################################################################################
|
||||
|
||||
// Comment out the #defines below with // to stop that font being loaded
|
||||
// The ESP8366 had plenty of memory so commenting out fonts is not normally necessary
|
||||
// If all fonts are loaded the extra FLASH space required is about 17Kbytes...
|
||||
// To save FLASH space only enable the fonts you need!
|
||||
// The ESP8366 and ESP32 have plenty of memory so commenting out fonts is not
|
||||
// normally necessary. If all fonts are loaded the extra FLASH space required is
|
||||
// about 17Kbytes. To save FLASH space only enable the fonts you need!
|
||||
|
||||
#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
|
||||
|
|
@ -103,8 +166,13 @@
|
|||
#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
|
||||
|
||||
// Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded
|
||||
// this will save ~20kbytes of FLASH
|
||||
#define SMOOTH_FONT
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 4. Not used
|
||||
|
|
@ -118,24 +186,33 @@
|
|||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Define the SPI clock frequency
|
||||
// Define the SPI clock frequency, this affects the graphics rendering speed. Too
|
||||
// fast and the TFT driver will not keep up and display corruption appears.
|
||||
// With an ILI9341 display 40MHz works OK, 80MHz sometimes fails
|
||||
// With a ST7735 display more than 27MHz may not work (spurious pixels and lines)
|
||||
// With an ILI9163 display TBD MHz works OK,
|
||||
// With an ILI9163 display 27 MHz works OK.
|
||||
// The RPi typically only works at 20MHz maximum.
|
||||
|
||||
// #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 27000000 // Actually sets it to 26.67MHz = 80/3
|
||||
// #define SPI_FREQUENCY 40000000 // Maximum to use SPIFFS
|
||||
// #define SPI_FREQUENCY 80000000
|
||||
|
||||
// The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here:
|
||||
#define SPI_TOUCH_FREQUENCY 2500000
|
||||
|
||||
|
||||
// Comment out the following #define if "SPI Transactions" do not need to be
|
||||
// supported. Tranaction support is required if other SPI devices are connected.
|
||||
// When commented out the code size will be smaller and sketches will
|
||||
// supported. When commented out the code size will be smaller and sketches will
|
||||
// run slightly faster, so leave it commented out unless you need it!
|
||||
|
||||
// Transaction support is needed to work with SD library but not needed with TFT_SdFat
|
||||
// Transaction support is required if other SPI devices are connected.
|
||||
|
||||
// Transactions are automatically enabled by the library for an ESP32 (to use HAL mutex)
|
||||
// so changing it here has no effect
|
||||
|
||||
// #define SUPPORT_TRANSACTIONS
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
// USER DEFINED SETTINGS
|
||||
//
|
||||
// The User_Setup header that will be called up is defined in User_Setup_Select.h
|
||||
//
|
||||
// Set driver type, fonts to be loaded, pins used and SPI control method etc
|
||||
//
|
||||
// If this file is editted correctly then all the library example sketches should
|
||||
//
|
||||
// See the User_Setup_Select.h file if you wish to be able to define multiple
|
||||
// setups and then easily select which setup file is used by the compiler.
|
||||
//
|
||||
// If this file is edited correctly then all the library example sketches should
|
||||
// run without the need to make any more changes for a particular hardware setup!
|
||||
|
||||
// ##################################################################################
|
||||
|
|
@ -18,6 +18,30 @@
|
|||
//#define ST7735_DRIVER
|
||||
//#define ILI9163_DRIVER
|
||||
#define S6D02A1_DRIVER
|
||||
//#define RPI_ILI9486_DRIVER // 20MHz maximum SPI
|
||||
|
||||
// For M5Stack ESP32 module with integrated display ONLY, remove // in line below
|
||||
//#define M5STACK
|
||||
|
||||
// For ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
|
||||
//#define TFT_WIDTH 128
|
||||
//#define TFT_HEIGHT 160
|
||||
//#define TFT_HEIGHT 128
|
||||
|
||||
// For ST7735 ONLY, define the type of display, originally this was based on the
|
||||
// colour of the tab on the screen protector film but this is not always true, so try
|
||||
// out the different options below if the screen does not display graphics correctly,
|
||||
// e.g. colours wrong, mirror images, or tray pixels at the edges.
|
||||
// Comment out ALL BUT ONE of these options for a ST7735 display driver, save this
|
||||
// this User_Setup file, then rebuild and upload the sketch to the board again:
|
||||
|
||||
//#define ST7735_INITB
|
||||
//#define ST7735_GREENTAB
|
||||
//#define ST7735_GREENTAB2
|
||||
//#define ST7735_GREENTAB3
|
||||
//#define ST7735_GREENTAB128 // For 128 x 128 display
|
||||
//#define ST7735_REDTAB
|
||||
//#define ST7735_BLACKTAB
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
|
|
@ -26,13 +50,13 @@
|
|||
// ##################################################################################
|
||||
|
||||
// We must use hardware SPI, a minimum of 3 GPIO pins is needed.
|
||||
// Typical setup for NodeMCU ESP-12 is :
|
||||
// Typical setup for ESP8266 NodeMCU ESP-12 is :
|
||||
//
|
||||
// Display SDO/MISO to NodeMCU pin D6 (or leave disconnected if not reading TFT)
|
||||
// Display LED to NodeMCU pin VIN (or 5V, see below)
|
||||
// Display SCK to NodeMCU pin D5
|
||||
// Display SDI/MOSI to NodeMCU pin D7
|
||||
// Display DC (or AO)to NodeMCU pin D3
|
||||
// Display DC (RS/AO)to NodeMCU pin D3
|
||||
// Display RESET to NodeMCU pin D4 (or RST, see below)
|
||||
// Display CS to NodeMCU pin D8 (or GND, see below)
|
||||
// Display GND to NodeMCU pin GND (0V)
|
||||
|
|
@ -40,8 +64,10 @@
|
|||
//
|
||||
// The TFT RESET pin can be connected to the NodeMCU RST pin or 3.3V to free up a control pin
|
||||
//
|
||||
// The DC (Data Command) pin may be labeled AO or RS (Register Select)
|
||||
//
|
||||
// With some displays such as the ILI9341 the TFT CS pin can be connected to GND if no more
|
||||
// SPI deivces (e.g. an SD Card) are connected, in this case comment out the #define TFT_CS
|
||||
// SPI devices (e.g. an SD Card) are connected, in this case comment out the #define TFT_CS
|
||||
// line below so it is NOT defined. Other displays such at the ST7735 require the TFT CS pin
|
||||
// to be toggled during setup, so in these cases the TFT_CS line must be defined and connected.
|
||||
//
|
||||
|
|
@ -53,23 +79,64 @@
|
|||
// If 5V is not available at a pin you can use 3.3V but backlight brightness
|
||||
// will be lower.
|
||||
|
||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR SETUP ######
|
||||
|
||||
// ModeMCU
|
||||
// ###### 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_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V
|
||||
|
||||
// ESP32 Dev board (planned, not supported yet)
|
||||
//#define TFT_CS 5 // Chip select control pin
|
||||
//#define TFT_DC 2 // Data Command control pin
|
||||
//#define TFT_RST 4 // Reset pin (could connect to Arduino RESET pin)
|
||||
//#define TOUCH_CS PIN_D1 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR PIN_D2 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
|
||||
// ###### FOR ESP8266 OVERLAP MODE EDIT THE PIN NUMBERS IN THE FOLLOWING LINES ######
|
||||
|
||||
// Overlap mode shares the ESP8266 FLASH SPI bus with the TFT so has a performance impact
|
||||
// but saves pins for other functions.
|
||||
// Use NodeMCU SD0=MISO, SD1=MOSI, CLK=SCLK to connect to TFT in overlap mode
|
||||
|
||||
// In ESP8266 overlap mode the TFT chip select MUST connect to pin D3
|
||||
//#define TFT_CS PIN_D3
|
||||
//#define TFT_DC PIN_D5 // 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
|
||||
|
||||
// In ESP8266 overlap mode the following must be defined
|
||||
//#define TFT_SPI_OVERLAP
|
||||
|
||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR ESP32 SETUP ######
|
||||
|
||||
// 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_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 TOUCH_CS 21 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR 22 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
// For the M5Stack module use these #define lines
|
||||
//#define TFT_MISO 19
|
||||
//#define TFT_MOSI 23
|
||||
//#define TFT_SCLK 18
|
||||
//#define TFT_CS 14 // Chip select control pin
|
||||
//#define TFT_DC 27 // Data Command control pin
|
||||
//#define TFT_RST 33 // Reset pin (could connect to Arduino RESET pin)
|
||||
//#define TFT_BL 32 // LED back-light
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 2. Define the way the DC and/or CS lines are driven
|
||||
// Section 2. Define the way the DC and/or CS lines are driven (ESP8266 only)
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
|
|
@ -89,9 +156,9 @@
|
|||
// ##################################################################################
|
||||
|
||||
// Comment out the #defines below with // to stop that font being loaded
|
||||
// The ESP8366 had plenty of memory so commenting out fonts is not normally necessary
|
||||
// If all fonts are loaded the extra FLASH space required is about 17Kbytes...
|
||||
// To save FLASH space only enable the fonts you need!
|
||||
// The ESP8366 and ESP32 have plenty of memory so commenting out fonts is not
|
||||
// normally necessary. If all fonts are loaded the extra FLASH space required is
|
||||
// about 17Kbytes. To save FLASH space only enable the fonts you need!
|
||||
|
||||
#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
|
||||
|
|
@ -99,8 +166,13 @@
|
|||
#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
|
||||
|
||||
// Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded
|
||||
// this will save ~20kbytes of FLASH
|
||||
#define SMOOTH_FONT
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 4. Not used
|
||||
|
|
@ -114,24 +186,33 @@
|
|||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Define the SPI clock frequency
|
||||
// Define the SPI clock frequency, this affects the graphics rendering speed. Too
|
||||
// fast and the TFT driver will not keep up and display corruption appears.
|
||||
// With an ILI9341 display 40MHz works OK, 80MHz sometimes fails
|
||||
// With a ST7735 display more than 27MHz may not work (spurious pixels and lines)
|
||||
// With an ILI9163 display TBD MHz works OK,
|
||||
// With an ILI9163 display 27 MHz works OK.
|
||||
// The RPi typically only works at 20MHz maximum.
|
||||
|
||||
// #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 27000000 // Actually sets it to 26.67MHz = 80/3
|
||||
// #define SPI_FREQUENCY 40000000 // Maximum to use SPIFFS
|
||||
// #define SPI_FREQUENCY 80000000
|
||||
|
||||
// The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here:
|
||||
#define SPI_TOUCH_FREQUENCY 2500000
|
||||
|
||||
|
||||
// Comment out the following #define if "SPI Transactions" do not need to be
|
||||
// supported. Tranaction support is required if other SPI devices are connected.
|
||||
// When commented out the code size will be smaller and sketches will
|
||||
// supported. When commented out the code size will be smaller and sketches will
|
||||
// run slightly faster, so leave it commented out unless you need it!
|
||||
|
||||
// Transaction support is needed to work with SD library but not needed with TFT_SdFat
|
||||
// Transaction support is required if other SPI devices are connected.
|
||||
|
||||
// Transactions are automatically enabled by the library for an ESP32 (to use HAL mutex)
|
||||
// so changing it here has no effect
|
||||
|
||||
// #define SUPPORT_TRANSACTIONS
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
// See the User_Setup_Select.h file if you wish to be able to define multiple
|
||||
// setups and then easily select which setup file is used by the compiler.
|
||||
//
|
||||
// If this file is editted correctly then all the library example sketches should
|
||||
// If this file is edited correctly then all the library example sketches should
|
||||
// run without the need to make any more changes for a particular hardware setup!
|
||||
|
||||
// ##################################################################################
|
||||
|
|
@ -20,6 +20,14 @@
|
|||
//#define S6D02A1_DRIVER
|
||||
#define RPI_ILI9486_DRIVER // 20MHz maximum SPI
|
||||
|
||||
// For M5Stack ESP32 module with integrated display ONLY, remove // in line below
|
||||
//#define M5STACK
|
||||
|
||||
// For ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
|
||||
//#define TFT_WIDTH 128
|
||||
//#define TFT_HEIGHT 160
|
||||
//#define TFT_HEIGHT 128
|
||||
|
||||
// For ST7735 ONLY, define the type of display, originally this was based on the
|
||||
// colour of the tab on the screen protector film but this is not always true, so try
|
||||
// out the different options below if the screen does not display graphics correctly,
|
||||
|
|
@ -31,14 +39,10 @@
|
|||
//#define ST7735_GREENTAB
|
||||
//#define ST7735_GREENTAB2
|
||||
//#define ST7735_GREENTAB3
|
||||
//#define ST7735_GREENTAB128 // For 128 x 128 display
|
||||
//#define ST7735_REDTAB
|
||||
//#define ST7735_BLACKTAB
|
||||
|
||||
// For ST7735 ONLY, define the pixel width and height in portrait orientation
|
||||
//#define TFT_WIDTH 128
|
||||
//#define TFT_HEIGHT 160
|
||||
//#define TFT_HEIGHT 128
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 1. Define the pins that are used to interface with the display here
|
||||
|
|
@ -46,13 +50,13 @@
|
|||
// ##################################################################################
|
||||
|
||||
// We must use hardware SPI, a minimum of 3 GPIO pins is needed.
|
||||
// Typical setup for NodeMCU ESP-12 is :
|
||||
// Typical setup for ESP8266 NodeMCU ESP-12 is :
|
||||
//
|
||||
// Display SDO/MISO to NodeMCU pin D6 (or leave disconnected if not reading TFT)
|
||||
// Display LED to NodeMCU pin VIN (or 5V, see below)
|
||||
// Display SCK to NodeMCU pin D5
|
||||
// Display SDI/MOSI to NodeMCU pin D7
|
||||
// Display DC (or AO)to NodeMCU pin D3
|
||||
// Display DC (RS/AO)to NodeMCU pin D3
|
||||
// Display RESET to NodeMCU pin D4 (or RST, see below)
|
||||
// Display CS to NodeMCU pin D8 (or GND, see below)
|
||||
// Display GND to NodeMCU pin GND (0V)
|
||||
|
|
@ -60,8 +64,10 @@
|
|||
//
|
||||
// The TFT RESET pin can be connected to the NodeMCU RST pin or 3.3V to free up a control pin
|
||||
//
|
||||
// The DC (Data Command) pin may be labeled AO or RS (Register Select)
|
||||
//
|
||||
// With some displays such as the ILI9341 the TFT CS pin can be connected to GND if no more
|
||||
// SPI deivces (e.g. an SD Card) are connected, in this case comment out the #define TFT_CS
|
||||
// SPI devices (e.g. an SD Card) are connected, in this case comment out the #define TFT_CS
|
||||
// line below so it is NOT defined. Other displays such at the ST7735 require the TFT CS pin
|
||||
// to be toggled during setup, so in these cases the TFT_CS line must be defined and connected.
|
||||
//
|
||||
|
|
@ -73,25 +79,64 @@
|
|||
// If 5V is not available at a pin you can use 3.3V but backlight brightness
|
||||
// will be lower.
|
||||
|
||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR SETUP ######
|
||||
|
||||
// ModeMCU
|
||||
// ###### 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_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V
|
||||
|
||||
//#define TFT_WR PIN_D2 // Write strobe for modified Raspberry Pi TFT only
|
||||
//#define TOUCH_CS PIN_D1 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
// ESP32 Dev board (planned, not supported yet)
|
||||
//#define TFT_CS 5 // Chip select control pin
|
||||
//#define TFT_DC 2 // Data Command control pin
|
||||
//#define TFT_RST 4 // Reset pin (could connect to Arduino RESET pin)
|
||||
//#define TFT_WR PIN_D2 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
|
||||
// ###### FOR ESP8266 OVERLAP MODE EDIT THE PIN NUMBERS IN THE FOLLOWING LINES ######
|
||||
|
||||
// Overlap mode shares the ESP8266 FLASH SPI bus with the TFT so has a performance impact
|
||||
// but saves pins for other functions.
|
||||
// Use NodeMCU SD0=MISO, SD1=MOSI, CLK=SCLK to connect to TFT in overlap mode
|
||||
|
||||
// In ESP8266 overlap mode the TFT chip select MUST connect to pin D3
|
||||
//#define TFT_CS PIN_D3
|
||||
//#define TFT_DC PIN_D5 // 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
|
||||
|
||||
// In ESP8266 overlap mode the following must be defined
|
||||
//#define TFT_SPI_OVERLAP
|
||||
|
||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR ESP32 SETUP ######
|
||||
|
||||
// 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_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 TOUCH_CS 21 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR 22 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
// For the M5Stack module use these #define lines
|
||||
//#define TFT_MISO 19
|
||||
//#define TFT_MOSI 23
|
||||
//#define TFT_SCLK 18
|
||||
//#define TFT_CS 14 // Chip select control pin
|
||||
//#define TFT_DC 27 // Data Command control pin
|
||||
//#define TFT_RST 33 // Reset pin (could connect to Arduino RESET pin)
|
||||
//#define TFT_BL 32 // LED back-light
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 2. Define the way the DC and/or CS lines are driven
|
||||
// Section 2. Define the way the DC and/or CS lines are driven (ESP8266 only)
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
|
|
@ -111,9 +156,9 @@
|
|||
// ##################################################################################
|
||||
|
||||
// Comment out the #defines below with // to stop that font being loaded
|
||||
// The ESP8366 had plenty of memory so commenting out fonts is not normally necessary
|
||||
// If all fonts are loaded the extra FLASH space required is about 17Kbytes...
|
||||
// To save FLASH space only enable the fonts you need!
|
||||
// The ESP8366 and ESP32 have plenty of memory so commenting out fonts is not
|
||||
// normally necessary. If all fonts are loaded the extra FLASH space required is
|
||||
// about 17Kbytes. To save FLASH space only enable the fonts you need!
|
||||
|
||||
#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
|
||||
|
|
@ -121,8 +166,13 @@
|
|||
#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
|
||||
|
||||
// Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded
|
||||
// this will save ~20kbytes of FLASH
|
||||
#define SMOOTH_FONT
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 4. Not used
|
||||
|
|
@ -136,24 +186,33 @@
|
|||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Define the SPI clock frequency
|
||||
// Define the SPI clock frequency, this affects the graphics rendering speed. Too
|
||||
// fast and the TFT driver will not keep up and display corruption appears.
|
||||
// With an ILI9341 display 40MHz works OK, 80MHz sometimes fails
|
||||
// With a ST7735 display more than 27MHz may not work (spurious pixels and lines)
|
||||
// With an ILI9163 display TBD MHz works OK,
|
||||
// With an ILI9163 display 27 MHz works OK.
|
||||
// The RPi typically only works at 20MHz maximum.
|
||||
|
||||
// #define SPI_FREQUENCY 1000000
|
||||
// #define SPI_FREQUENCY 5000000
|
||||
// #define SPI_FREQUENCY 10000000
|
||||
#define SPI_FREQUENCY 20000000
|
||||
#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
|
||||
|
||||
// The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here:
|
||||
#define SPI_TOUCH_FREQUENCY 2500000
|
||||
|
||||
|
||||
// Comment out the following #define if "SPI Transactions" do not need to be
|
||||
// supported. Tranaction support is required if other SPI devices are connected.
|
||||
// When commented out the code size will be smaller and sketches will
|
||||
// supported. When commented out the code size will be smaller and sketches will
|
||||
// run slightly faster, so leave it commented out unless you need it!
|
||||
|
||||
// Transaction support is needed to work with SD library but not needed with TFT_SdFat
|
||||
// Transaction support is required if other SPI devices are connected.
|
||||
|
||||
// Transactions are automatically enabled by the library for an ESP32 (to use HAL mutex)
|
||||
// so changing it here has no effect
|
||||
|
||||
// #define SUPPORT_TRANSACTIONS
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
// See the User_Setup_Select.h file if you wish to be able to define multiple
|
||||
// setups and then easily select which setup file is used by the compiler.
|
||||
//
|
||||
// If this file is editted correctly then all the library example sketches should
|
||||
// If this file is edited correctly then all the library example sketches should
|
||||
// run without the need to make any more changes for a particular hardware setup!
|
||||
|
||||
// ##################################################################################
|
||||
|
|
@ -20,7 +20,10 @@
|
|||
//#define S6D02A1_DRIVER
|
||||
#define RPI_ILI9486_DRIVER // 20MHz maximum SPI
|
||||
|
||||
// For ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
|
||||
// For M5Stack ESP32 module with integrated display ONLY, remove // in line below
|
||||
//#define M5STACK
|
||||
|
||||
// For ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
|
||||
//#define TFT_WIDTH 128
|
||||
//#define TFT_HEIGHT 160
|
||||
//#define TFT_HEIGHT 128
|
||||
|
|
@ -36,6 +39,7 @@
|
|||
//#define ST7735_GREENTAB
|
||||
//#define ST7735_GREENTAB2
|
||||
//#define ST7735_GREENTAB3
|
||||
//#define ST7735_GREENTAB128 // For 128 x 128 display
|
||||
//#define ST7735_REDTAB
|
||||
//#define ST7735_BLACKTAB
|
||||
|
||||
|
|
@ -46,13 +50,13 @@
|
|||
// ##################################################################################
|
||||
|
||||
// We must use hardware SPI, a minimum of 3 GPIO pins is needed.
|
||||
// Typical setup for NodeMCU ESP-12 is :
|
||||
// Typical setup for ESP8266 NodeMCU ESP-12 is :
|
||||
//
|
||||
// Display SDO/MISO to NodeMCU pin D6 (or leave disconnected if not reading TFT)
|
||||
// Display LED to NodeMCU pin VIN (or 5V, see below)
|
||||
// Display SCK to NodeMCU pin D5
|
||||
// Display SDI/MOSI to NodeMCU pin D7
|
||||
// Display DC (or AO)to NodeMCU pin D3
|
||||
// Display DC (RS/AO)to NodeMCU pin D3
|
||||
// Display RESET to NodeMCU pin D4 (or RST, see below)
|
||||
// Display CS to NodeMCU pin D8 (or GND, see below)
|
||||
// Display GND to NodeMCU pin GND (0V)
|
||||
|
|
@ -60,8 +64,10 @@
|
|||
//
|
||||
// The TFT RESET pin can be connected to the NodeMCU RST pin or 3.3V to free up a control pin
|
||||
//
|
||||
// The DC (Data Command) pin may be labeled AO or RS (Register Select)
|
||||
//
|
||||
// With some displays such as the ILI9341 the TFT CS pin can be connected to GND if no more
|
||||
// SPI deivces (e.g. an SD Card) are connected, in this case comment out the #define TFT_CS
|
||||
// SPI devices (e.g. an SD Card) are connected, in this case comment out the #define TFT_CS
|
||||
// line below so it is NOT defined. Other displays such at the ST7735 require the TFT CS pin
|
||||
// to be toggled during setup, so in these cases the TFT_CS line must be defined and connected.
|
||||
//
|
||||
|
|
@ -73,25 +79,64 @@
|
|||
// If 5V is not available at a pin you can use 3.3V but backlight brightness
|
||||
// will be lower.
|
||||
|
||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR SETUP ######
|
||||
|
||||
// ModeMCU
|
||||
// ###### 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_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V
|
||||
|
||||
#define TFT_WR PIN_D2 // Write strobe for modified Raspberry Pi TFT only
|
||||
//#define TOUCH_CS PIN_D1 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
// ESP32 Dev board (planned, not supported yet)
|
||||
//#define TFT_CS 5 // Chip select control pin
|
||||
//#define TFT_DC 2 // Data Command control pin
|
||||
//#define TFT_RST 4 // Reset pin (could connect to Arduino RESET pin)
|
||||
#define TFT_WR PIN_D2 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
|
||||
// ###### FOR ESP8266 OVERLAP MODE EDIT THE PIN NUMBERS IN THE FOLLOWING LINES ######
|
||||
|
||||
// Overlap mode shares the ESP8266 FLASH SPI bus with the TFT so has a performance impact
|
||||
// but saves pins for other functions.
|
||||
// Use NodeMCU SD0=MISO, SD1=MOSI, CLK=SCLK to connect to TFT in overlap mode
|
||||
|
||||
// In ESP8266 overlap mode the TFT chip select MUST connect to pin D3
|
||||
//#define TFT_CS PIN_D3
|
||||
//#define TFT_DC PIN_D5 // 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
|
||||
|
||||
// In ESP8266 overlap mode the following must be defined
|
||||
//#define TFT_SPI_OVERLAP
|
||||
|
||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR ESP32 SETUP ######
|
||||
|
||||
// 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_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 TOUCH_CS 21 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR 22 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
// For the M5Stack module use these #define lines
|
||||
//#define TFT_MISO 19
|
||||
//#define TFT_MOSI 23
|
||||
//#define TFT_SCLK 18
|
||||
//#define TFT_CS 14 // Chip select control pin
|
||||
//#define TFT_DC 27 // Data Command control pin
|
||||
//#define TFT_RST 33 // Reset pin (could connect to Arduino RESET pin)
|
||||
//#define TFT_BL 32 // LED back-light
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 2. Define the way the DC and/or CS lines are driven
|
||||
// Section 2. Define the way the DC and/or CS lines are driven (ESP8266 only)
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
|
|
@ -111,9 +156,9 @@
|
|||
// ##################################################################################
|
||||
|
||||
// Comment out the #defines below with // to stop that font being loaded
|
||||
// The ESP8366 had plenty of memory so commenting out fonts is not normally necessary
|
||||
// If all fonts are loaded the extra FLASH space required is about 17Kbytes...
|
||||
// To save FLASH space only enable the fonts you need!
|
||||
// The ESP8366 and ESP32 have plenty of memory so commenting out fonts is not
|
||||
// normally necessary. If all fonts are loaded the extra FLASH space required is
|
||||
// about 17Kbytes. To save FLASH space only enable the fonts you need!
|
||||
|
||||
#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
|
||||
|
|
@ -121,8 +166,13 @@
|
|||
#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
|
||||
|
||||
// Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded
|
||||
// this will save ~20kbytes of FLASH
|
||||
#define SMOOTH_FONT
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 4. Not used
|
||||
|
|
@ -136,24 +186,33 @@
|
|||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Define the SPI clock frequency
|
||||
// Define the SPI clock frequency, this affects the graphics rendering speed. Too
|
||||
// fast and the TFT driver will not keep up and display corruption appears.
|
||||
// With an ILI9341 display 40MHz works OK, 80MHz sometimes fails
|
||||
// With a ST7735 display more than 27MHz may not work (spurious pixels and lines)
|
||||
// With an ILI9163 display TBD MHz works OK,
|
||||
// With an ILI9163 display 27 MHz works OK.
|
||||
// The RPi typically only works at 20MHz maximum.
|
||||
|
||||
// #define SPI_FREQUENCY 1000000
|
||||
// #define SPI_FREQUENCY 5000000
|
||||
// #define SPI_FREQUENCY 10000000
|
||||
#define SPI_FREQUENCY 20000000
|
||||
#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
|
||||
|
||||
// The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here:
|
||||
#define SPI_TOUCH_FREQUENCY 2500000
|
||||
|
||||
|
||||
// Comment out the following #define if "SPI Transactions" do not need to be
|
||||
// supported. Tranaction support is required if other SPI devices are connected.
|
||||
// When commented out the code size will be smaller and sketches will
|
||||
// supported. When commented out the code size will be smaller and sketches will
|
||||
// run slightly faster, so leave it commented out unless you need it!
|
||||
|
||||
// Transaction support is needed to work with SD library but not needed with TFT_SdFat
|
||||
// Transaction support is required if other SPI devices are connected.
|
||||
|
||||
// Transactions are automatically enabled by the library for an ESP32 (to use HAL mutex)
|
||||
// so changing it here has no effect
|
||||
|
||||
// #define SUPPORT_TRANSACTIONS
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
// USER DEFINED SETTINGS
|
||||
//
|
||||
// The User_Setup header that will be called up is defined in User_Setup_Select.h
|
||||
//
|
||||
// Set driver type, fonts to be loaded, pins used and SPI control method etc
|
||||
//
|
||||
// If this file is editted correctly then all the library example sketches should
|
||||
//
|
||||
// See the User_Setup_Select.h file if you wish to be able to define multiple
|
||||
// setups and then easily select which setup file is used by the compiler.
|
||||
//
|
||||
// If this file is edited correctly then all the library example sketches should
|
||||
// run without the need to make any more changes for a particular hardware setup!
|
||||
|
||||
// ##################################################################################
|
||||
|
|
@ -16,8 +16,14 @@
|
|||
// Only define one driver, the other ones must be commented out
|
||||
//#define ILI9341_DRIVER
|
||||
#define ST7735_DRIVER
|
||||
//#define ILI9163_DRIVER
|
||||
//#define S6D02A1_DRIVER
|
||||
//#define RPI_ILI9486_DRIVER // 20MHz maximum SPI
|
||||
|
||||
// For ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
|
||||
// For M5Stack ESP32 module with integrated display ONLY, remove // in line below
|
||||
//#define M5STACK
|
||||
|
||||
// For ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
|
||||
#define TFT_WIDTH 128
|
||||
//#define TFT_HEIGHT 160
|
||||
#define TFT_HEIGHT 128
|
||||
|
|
@ -29,12 +35,12 @@
|
|||
// Comment out ALL BUT ONE of these options for a ST7735 display driver, save this
|
||||
// this User_Setup file, then rebuild and upload the sketch to the board again:
|
||||
|
||||
//#define ST7735_INITB // No display
|
||||
//#define ST7735_GREENTAB // 2 pixel left border
|
||||
//#define ST7735_GREENTAB2 // Colours wrong RB swap
|
||||
//#define ST7735_GREENTAB3 // 2 pixel left border
|
||||
//#define ST7735_INITB
|
||||
//#define ST7735_GREENTAB
|
||||
//#define ST7735_GREENTAB2
|
||||
//#define ST7735_GREENTAB3
|
||||
#define ST7735_GREENTAB128 // For 128 x 128 display
|
||||
//#define ST7735_REDTAB // colours wrong rotation 0 needs y shift of 32, 1 an x shift of 32
|
||||
//#define ST7735_REDTAB
|
||||
//#define ST7735_BLACKTAB
|
||||
|
||||
// ##################################################################################
|
||||
|
|
@ -44,7 +50,7 @@
|
|||
// ##################################################################################
|
||||
|
||||
// We must use hardware SPI, a minimum of 3 GPIO pins is needed.
|
||||
// Typical setup for NodeMCU ESP-12 is :
|
||||
// Typical setup for ESP8266 NodeMCU ESP-12 is :
|
||||
//
|
||||
// Display SDO/MISO to NodeMCU pin D6 (or leave disconnected if not reading TFT)
|
||||
// Display LED to NodeMCU pin VIN (or 5V, see below)
|
||||
|
|
@ -58,10 +64,10 @@
|
|||
//
|
||||
// The TFT RESET pin can be connected to the NodeMCU RST pin or 3.3V to free up a control pin
|
||||
//
|
||||
// The DC (Data Command) pin may be labell AO or RS (Register Select)
|
||||
// The DC (Data Command) pin may be labeled AO or RS (Register Select)
|
||||
//
|
||||
// With some displays such as the ILI9341 the TFT CS pin can be connected to GND if no more
|
||||
// SPI deivces (e.g. an SD Card) are connected, in this case comment out the #define TFT_CS
|
||||
// SPI devices (e.g. an SD Card) are connected, in this case comment out the #define TFT_CS
|
||||
// line below so it is NOT defined. Other displays such at the ST7735 require the TFT CS pin
|
||||
// to be toggled during setup, so in these cases the TFT_CS line must be defined and connected.
|
||||
//
|
||||
|
|
@ -73,23 +79,64 @@
|
|||
// If 5V is not available at a pin you can use 3.3V but backlight brightness
|
||||
// will be lower.
|
||||
|
||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR SETUP ######
|
||||
|
||||
// ModeMCU
|
||||
// ###### 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_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V
|
||||
|
||||
// ESP32 Dev board (planned, not test/supported yet)
|
||||
//#define TFT_CS 5 // Chip select control pin
|
||||
//#define TFT_DC 2 // Data Command control pin
|
||||
//#define TFT_RST 4 // Reset pin (could connect to Arduino RESET pin)
|
||||
//#define TOUCH_CS PIN_D1 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR PIN_D2 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
|
||||
// ###### FOR ESP8266 OVERLAP MODE EDIT THE PIN NUMBERS IN THE FOLLOWING LINES ######
|
||||
|
||||
// Overlap mode shares the ESP8266 FLASH SPI bus with the TFT so has a performance impact
|
||||
// but saves pins for other functions.
|
||||
// Use NodeMCU SD0=MISO, SD1=MOSI, CLK=SCLK to connect to TFT in overlap mode
|
||||
|
||||
// In ESP8266 overlap mode the TFT chip select MUST connect to pin D3
|
||||
//#define TFT_CS PIN_D3
|
||||
//#define TFT_DC PIN_D5 // 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
|
||||
|
||||
// In ESP8266 overlap mode the following must be defined
|
||||
//#define TFT_SPI_OVERLAP
|
||||
|
||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR ESP32 SETUP ######
|
||||
|
||||
// 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_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 TOUCH_CS 21 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR 22 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
// For the M5Stack module use these #define lines
|
||||
//#define TFT_MISO 19
|
||||
//#define TFT_MOSI 23
|
||||
//#define TFT_SCLK 18
|
||||
//#define TFT_CS 14 // Chip select control pin
|
||||
//#define TFT_DC 27 // Data Command control pin
|
||||
//#define TFT_RST 33 // Reset pin (could connect to Arduino RESET pin)
|
||||
//#define TFT_BL 32 // LED back-light
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 2. Define the way the DC and/or CS lines are driven
|
||||
// Section 2. Define the way the DC and/or CS lines are driven (ESP8266 only)
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
|
|
@ -109,9 +156,9 @@
|
|||
// ##################################################################################
|
||||
|
||||
// Comment out the #defines below with // to stop that font being loaded
|
||||
// The ESP8366 had plenty of memory so commenting out fonts is not normally necessary
|
||||
// If all fonts are loaded the extra FLASH space required is about 17Kbytes...
|
||||
// To save FLASH space only enable the fonts you need!
|
||||
// The ESP8366 and ESP32 have plenty of memory so commenting out fonts is not
|
||||
// normally necessary. If all fonts are loaded the extra FLASH space required is
|
||||
// about 17Kbytes. To save FLASH space only enable the fonts you need!
|
||||
|
||||
#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
|
||||
|
|
@ -119,8 +166,13 @@
|
|||
#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
|
||||
|
||||
// Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded
|
||||
// this will save ~20kbytes of FLASH
|
||||
#define SMOOTH_FONT
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 4. Not used
|
||||
|
|
@ -128,31 +180,39 @@
|
|||
// ##################################################################################
|
||||
|
||||
|
||||
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 5. Other options
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Define the SPI clock frequency
|
||||
// Define the SPI clock frequency, this affects the graphics rendering speed. Too
|
||||
// fast and the TFT driver will not keep up and display corruption appears.
|
||||
// With an ILI9341 display 40MHz works OK, 80MHz sometimes fails
|
||||
// With a ST7735 display more than 27MHz may not work (spurious pixels and lines)
|
||||
// With an ILI9163 display 27 MHz works OK.
|
||||
// The RPi typically only works at 20MHz maximum.
|
||||
|
||||
// #define SPI_FREQUENCY 1000000
|
||||
// #define SPI_FREQUENCY 5000000
|
||||
// #define SPI_FREQUENCY 10000000
|
||||
// #define SPI_FREQUENCY 20000000
|
||||
#define SPI_FREQUENCY 27000000 // Maximum for my ST7735. It is actually 26.67MHz = 80/3
|
||||
#define SPI_FREQUENCY 27000000 // Actually sets it to 26.67MHz = 80/3
|
||||
// #define SPI_FREQUENCY 40000000 // Maximum to use SPIFFS
|
||||
// #define SPI_FREQUENCY 80000000
|
||||
|
||||
// The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here:
|
||||
#define SPI_TOUCH_FREQUENCY 2500000
|
||||
|
||||
|
||||
// Comment out the following #define if "SPI Transactions" do not need to be
|
||||
// supported. Tranaction support is required if other SPI devices are connected.
|
||||
// When commented out the code size will be smaller and sketches will
|
||||
// supported. When commented out the code size will be smaller and sketches will
|
||||
// run slightly faster, so leave it commented out unless you need it!
|
||||
|
||||
// Transaction support is needed to work with SD library but not needed with TFT_SdFat
|
||||
// Transaction support is required if other SPI devices are connected.
|
||||
|
||||
// Transactions are automatically enabled by the library for an ESP32 (to use HAL mutex)
|
||||
// so changing it here has no effect
|
||||
|
||||
// #define SUPPORT_TRANSACTIONS
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
// USER DEFINED SETTINGS
|
||||
//
|
||||
// The User_Setup header that will be called up is defined in User_Setup_Select.h
|
||||
//
|
||||
// Set driver type, fonts to be loaded, pins used and SPI control method etc
|
||||
//
|
||||
// If this file is editted correctly then all the library example sketches should
|
||||
//
|
||||
// See the User_Setup_Select.h file if you wish to be able to define multiple
|
||||
// setups and then easily select which setup file is used by the compiler.
|
||||
//
|
||||
// If this file is edited correctly then all the library example sketches should
|
||||
// run without the need to make any more changes for a particular hardware setup!
|
||||
|
||||
// ##################################################################################
|
||||
|
|
@ -17,12 +17,32 @@
|
|||
//#define ILI9341_DRIVER
|
||||
//#define ST7735_DRIVER
|
||||
#define ILI9163_DRIVER
|
||||
//#define S6D02A1_DRIVER
|
||||
//#define RPI_ILI9486_DRIVER // 20MHz maximum SPI
|
||||
|
||||
// For ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
|
||||
// For M5Stack ESP32 module with integrated display ONLY, remove // in line below
|
||||
//#define M5STACK
|
||||
|
||||
// For ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
|
||||
#define TFT_WIDTH 128
|
||||
//#define TFT_HEIGHT 160
|
||||
#define TFT_HEIGHT 128
|
||||
|
||||
// For ST7735 ONLY, define the type of display, originally this was based on the
|
||||
// colour of the tab on the screen protector film but this is not always true, so try
|
||||
// out the different options below if the screen does not display graphics correctly,
|
||||
// e.g. colours wrong, mirror images, or tray pixels at the edges.
|
||||
// Comment out ALL BUT ONE of these options for a ST7735 display driver, save this
|
||||
// this User_Setup file, then rebuild and upload the sketch to the board again:
|
||||
|
||||
//#define ST7735_INITB
|
||||
//#define ST7735_GREENTAB
|
||||
//#define ST7735_GREENTAB2
|
||||
//#define ST7735_GREENTAB3
|
||||
//#define ST7735_GREENTAB128 // For 128 x 128 display
|
||||
//#define ST7735_REDTAB
|
||||
//#define ST7735_BLACKTAB
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 1. Define the pins that are used to interface with the display here
|
||||
|
|
@ -30,13 +50,13 @@
|
|||
// ##################################################################################
|
||||
|
||||
// We must use hardware SPI, a minimum of 3 GPIO pins is needed.
|
||||
// Typical setup for NodeMCU ESP-12 is :
|
||||
// Typical setup for ESP8266 NodeMCU ESP-12 is :
|
||||
//
|
||||
// Display SDO/MISO to NodeMCU pin D6 (or leave disconnected if not reading TFT)
|
||||
// Display LED to NodeMCU pin VIN (or 5V, see below)
|
||||
// Display SCK to NodeMCU pin D5
|
||||
// Display SDI/MOSI to NodeMCU pin D7
|
||||
// Display DC (or AO)to NodeMCU pin D3
|
||||
// Display DC (RS/AO)to NodeMCU pin D3
|
||||
// Display RESET to NodeMCU pin D4 (or RST, see below)
|
||||
// Display CS to NodeMCU pin D8 (or GND, see below)
|
||||
// Display GND to NodeMCU pin GND (0V)
|
||||
|
|
@ -44,8 +64,10 @@
|
|||
//
|
||||
// The TFT RESET pin can be connected to the NodeMCU RST pin or 3.3V to free up a control pin
|
||||
//
|
||||
// The DC (Data Command) pin may be labeled AO or RS (Register Select)
|
||||
//
|
||||
// With some displays such as the ILI9341 the TFT CS pin can be connected to GND if no more
|
||||
// SPI deivces (e.g. an SD Card) are connected, in this case comment out the #define TFT_CS
|
||||
// SPI devices (e.g. an SD Card) are connected, in this case comment out the #define TFT_CS
|
||||
// line below so it is NOT defined. Other displays such at the ST7735 require the TFT CS pin
|
||||
// to be toggled during setup, so in these cases the TFT_CS line must be defined and connected.
|
||||
//
|
||||
|
|
@ -57,23 +79,64 @@
|
|||
// If 5V is not available at a pin you can use 3.3V but backlight brightness
|
||||
// will be lower.
|
||||
|
||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR SETUP ######
|
||||
|
||||
// ModeMCU
|
||||
// ###### 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_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V
|
||||
|
||||
// ESP32 Dev board (planned, not supported yet)
|
||||
//#define TFT_CS 5 // Chip select control pin
|
||||
//#define TFT_DC 2 // Data Command control pin
|
||||
//#define TFT_RST 4 // Reset pin (could connect to Arduino RESET pin)
|
||||
//#define TOUCH_CS PIN_D1 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR PIN_D2 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
|
||||
// ###### FOR ESP8266 OVERLAP MODE EDIT THE PIN NUMBERS IN THE FOLLOWING LINES ######
|
||||
|
||||
// Overlap mode shares the ESP8266 FLASH SPI bus with the TFT so has a performance impact
|
||||
// but saves pins for other functions.
|
||||
// Use NodeMCU SD0=MISO, SD1=MOSI, CLK=SCLK to connect to TFT in overlap mode
|
||||
|
||||
// In ESP8266 overlap mode the TFT chip select MUST connect to pin D3
|
||||
//#define TFT_CS PIN_D3
|
||||
//#define TFT_DC PIN_D5 // 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
|
||||
|
||||
// In ESP8266 overlap mode the following must be defined
|
||||
//#define TFT_SPI_OVERLAP
|
||||
|
||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR ESP32 SETUP ######
|
||||
|
||||
// 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_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 TOUCH_CS 21 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR 22 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
// For the M5Stack module use these #define lines
|
||||
//#define TFT_MISO 19
|
||||
//#define TFT_MOSI 23
|
||||
//#define TFT_SCLK 18
|
||||
//#define TFT_CS 14 // Chip select control pin
|
||||
//#define TFT_DC 27 // Data Command control pin
|
||||
//#define TFT_RST 33 // Reset pin (could connect to Arduino RESET pin)
|
||||
//#define TFT_BL 32 // LED back-light
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 2. Define the way the DC and/or CS lines are driven
|
||||
// Section 2. Define the way the DC and/or CS lines are driven (ESP8266 only)
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
|
|
@ -93,9 +156,9 @@
|
|||
// ##################################################################################
|
||||
|
||||
// Comment out the #defines below with // to stop that font being loaded
|
||||
// The ESP8366 had plenty of memory so commenting out fonts is not normally necessary
|
||||
// If all fonts are loaded the extra FLASH space required is about 17Kbytes...
|
||||
// To save FLASH space only enable the fonts you need!
|
||||
// The ESP8366 and ESP32 have plenty of memory so commenting out fonts is not
|
||||
// normally necessary. If all fonts are loaded the extra FLASH space required is
|
||||
// about 17Kbytes. To save FLASH space only enable the fonts you need!
|
||||
|
||||
#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
|
||||
|
|
@ -103,8 +166,13 @@
|
|||
#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
|
||||
|
||||
// Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded
|
||||
// this will save ~20kbytes of FLASH
|
||||
#define SMOOTH_FONT
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 4. Not used
|
||||
|
|
@ -118,24 +186,33 @@
|
|||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Define the SPI clock frequency
|
||||
// Define the SPI clock frequency, this affects the graphics rendering speed. Too
|
||||
// fast and the TFT driver will not keep up and display corruption appears.
|
||||
// With an ILI9341 display 40MHz works OK, 80MHz sometimes fails
|
||||
// With a ST7735 display more than 27MHz may not work (spurious pixels and lines)
|
||||
// With an ILI9163 display 40 MHz works OK,
|
||||
// With an ILI9163 display 27 MHz works OK.
|
||||
// The RPi typically only works at 20MHz maximum.
|
||||
|
||||
// #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 27000000 // Actually sets it to 26.67MHz = 80/3
|
||||
// #define SPI_FREQUENCY 40000000 // Maximum to use SPIFFS
|
||||
// #define SPI_FREQUENCY 80000000
|
||||
|
||||
// The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here:
|
||||
#define SPI_TOUCH_FREQUENCY 2500000
|
||||
|
||||
|
||||
// Comment out the following #define if "SPI Transactions" do not need to be
|
||||
// supported. Tranaction support is required if other SPI devices are connected.
|
||||
// When commented out the code size will be smaller and sketches will
|
||||
// supported. When commented out the code size will be smaller and sketches will
|
||||
// run slightly faster, so leave it commented out unless you need it!
|
||||
|
||||
// Transaction support is needed to work with SD library but not needed with TFT_SdFat
|
||||
// Transaction support is required if other SPI devices are connected.
|
||||
|
||||
// Transactions are automatically enabled by the library for an ESP32 (to use HAL mutex)
|
||||
// so changing it here has no effect
|
||||
|
||||
// #define SUPPORT_TRANSACTIONS
|
||||
|
|
|
|||
|
|
@ -1,16 +1,12 @@
|
|||
// USER DEFINED SETTINGS
|
||||
//
|
||||
// The User_Setup header that will be called up is defined in User_Setup_Select.h
|
||||
//
|
||||
// Set driver type, fonts to be loaded, pins used and SPI control method etc
|
||||
//
|
||||
// If this file is editted correctly then all the library example sketches should
|
||||
//
|
||||
// See the User_Setup_Select.h file if you wish to be able to define multiple
|
||||
// setups and then easily select which setup file is used by the compiler.
|
||||
//
|
||||
// If this file is edited correctly then all the library example sketches should
|
||||
// run without the need to make any more changes for a particular hardware setup!
|
||||
|
||||
// IMPORTANT
|
||||
// This particular setup uses the SPI overlap capabiltiy of the ESP8266, this allows
|
||||
// the FLASH SPI pins to be re-used with the TFT, saving pins for other functions.
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 0. Call up the right driver file and any options for it
|
||||
|
|
@ -20,8 +16,14 @@
|
|||
// Only define one driver, the other ones must be commented out
|
||||
//#define ILI9341_DRIVER
|
||||
#define ST7735_DRIVER
|
||||
//#define ILI9163_DRIVER
|
||||
//#define S6D02A1_DRIVER
|
||||
//#define RPI_ILI9486_DRIVER // 20MHz maximum SPI
|
||||
|
||||
// For ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
|
||||
// For M5Stack ESP32 module with integrated display ONLY, remove // in line below
|
||||
//#define M5STACK
|
||||
|
||||
// For ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
|
||||
#define TFT_WIDTH 128
|
||||
#define TFT_HEIGHT 160
|
||||
//#define TFT_HEIGHT 128
|
||||
|
|
@ -37,6 +39,7 @@
|
|||
//#define ST7735_GREENTAB
|
||||
//#define ST7735_GREENTAB2
|
||||
//#define ST7735_GREENTAB3
|
||||
//#define ST7735_GREENTAB128 // For 128 x 128 display
|
||||
#define ST7735_REDTAB
|
||||
//#define ST7735_BLACKTAB
|
||||
|
||||
|
|
@ -47,46 +50,93 @@
|
|||
// ##################################################################################
|
||||
|
||||
// We must use hardware SPI, a minimum of 3 GPIO pins is needed.
|
||||
// Typical setup for NodeMCU ESP-12 with SPI overlap is :
|
||||
// Typical setup for ESP8266 NodeMCU ESP-12 is :
|
||||
//
|
||||
// Display SDO/MISO to NodeMCU SD0 (or leave disconnected if not reading TFT)
|
||||
// Display SDO/MISO to NodeMCU pin D6 (or leave disconnected if not reading TFT)
|
||||
// Display LED to NodeMCU pin VIN (or 5V, see below)
|
||||
// Display SCK to NodeMCU pin CLK
|
||||
// Display SDI/MOSI to NodeMCU pin SD1
|
||||
// Display DC (or AO)to NodeMCU pin D5
|
||||
// Display SCK to NodeMCU pin D5
|
||||
// Display SDI/MOSI to NodeMCU pin D7
|
||||
// Display DC (RS/AO)to NodeMCU pin D3
|
||||
// Display RESET to NodeMCU pin D4 (or RST, see below)
|
||||
// Display CS to NodeMCU pin D3
|
||||
// Display CS to NodeMCU pin D8 (or GND, see below)
|
||||
// Display GND to NodeMCU pin GND (0V)
|
||||
// Display VCC to NodeMCU 5V or 3.3V
|
||||
//
|
||||
// The TFT RESET pin can be connected to the NodeMCU RST pin or 3.3V to free up a control pin
|
||||
//
|
||||
// The DC (Data Command) pin may be labeled AO or RS (Register Select)
|
||||
//
|
||||
// With some displays such as the ILI9341 the TFT CS pin can be connected to GND if no more
|
||||
// SPI devices (e.g. an SD Card) are connected, in this case comment out the #define TFT_CS
|
||||
// line below so it is NOT defined. Other displays such at the ST7735 require the TFT CS pin
|
||||
// to be toggled during setup, so in these cases the TFT_CS line must be defined and connected.
|
||||
//
|
||||
// The NodeMCU D0 pin can be used for RST
|
||||
//
|
||||
// See Section 2. below if DC is connected to D0
|
||||
// See Section 2. below if DC or CS is connected to D0
|
||||
//
|
||||
// Note: only some versions of the NodeMCU provide the USB 5V on the VIN pin
|
||||
// If 5V is not available at a pin you can use 3.3V but backlight brightness
|
||||
// will be lower.
|
||||
|
||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR SETUP ######
|
||||
|
||||
// ModeMCU
|
||||
// Do not define TFT_CS in overlap mode, TFT chip select must connect to pin D3
|
||||
// ###### 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_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V
|
||||
|
||||
//#define TOUCH_CS PIN_D1 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR PIN_D2 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
|
||||
// ###### FOR ESP8266 OVERLAP MODE EDIT THE PIN NUMBERS IN THE FOLLOWING LINES ######
|
||||
|
||||
// Overlap mode shares the ESP8266 FLASH SPI bus with the TFT so has a performance impact
|
||||
// but saves pins for other functions.
|
||||
// Use NodeMCU SD0=MISO, SD1=MOSI, CLK=SCLK to connect to TFT in overlap mode
|
||||
|
||||
// In ESP8266 overlap mode the TFT chip select MUST connect to pin D3
|
||||
#define TFT_CS PIN_D3
|
||||
#define TFT_DC PIN_D5 // 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
|
||||
|
||||
// ESP32 Dev board
|
||||
//#define TFT_CS 5 // Chip select control pin
|
||||
//#define TFT_DC 2 // Data Command control pin
|
||||
//#define TFT_RST 4 // Reset pin (could connect to Arduino RESET pin)
|
||||
// In ESP8266 overlap mode the following must be defined
|
||||
#define TFT_SPI_OVERLAP
|
||||
|
||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR ESP32 SETUP ######
|
||||
|
||||
// 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_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 TOUCH_CS 21 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR 22 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
// For the M5Stack module use these #define lines
|
||||
//#define TFT_MISO 19
|
||||
//#define TFT_MOSI 23
|
||||
//#define TFT_SCLK 18
|
||||
//#define TFT_CS 14 // Chip select control pin
|
||||
//#define TFT_DC 27 // Data Command control pin
|
||||
//#define TFT_RST 33 // Reset pin (could connect to Arduino RESET pin)
|
||||
//#define TFT_BL 32 // LED back-light
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 2. Define the way the DC and/or CS lines are driven
|
||||
// Section 2. Define the way the DC and/or CS lines are driven (ESP8266 only)
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
|
|
@ -106,9 +156,9 @@
|
|||
// ##################################################################################
|
||||
|
||||
// Comment out the #defines below with // to stop that font being loaded
|
||||
// The ESP8366 had plenty of memory so commenting out fonts is not normally necessary
|
||||
// If all fonts are loaded the extra FLASH space required is about 17Kbytes...
|
||||
// To save FLASH space only enable the fonts you need!
|
||||
// The ESP8366 and ESP32 have plenty of memory so commenting out fonts is not
|
||||
// normally necessary. If all fonts are loaded the extra FLASH space required is
|
||||
// about 17Kbytes. To save FLASH space only enable the fonts you need!
|
||||
|
||||
#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
|
||||
|
|
@ -116,8 +166,13 @@
|
|||
#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
|
||||
|
||||
// Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded
|
||||
// this will save ~20kbytes of FLASH
|
||||
#define SMOOTH_FONT
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 4. Not used
|
||||
|
|
@ -131,33 +186,33 @@
|
|||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Define the SPI clock frequency
|
||||
// Define the SPI clock frequency, this affects the graphics rendering speed. Too
|
||||
// fast and the TFT driver will not keep up and display corruption appears.
|
||||
// With an ILI9341 display 40MHz works OK, 80MHz sometimes fails
|
||||
// With a ST7735 display more than 27MHz may not work (spurious pixels and lines)
|
||||
// With an ILI9163 display 27 MHz works OK.
|
||||
// The RPi typically only works at 20MHz maximum.
|
||||
|
||||
// #define SPI_FREQUENCY 1000000
|
||||
// #define SPI_FREQUENCY 5000000
|
||||
// #define SPI_FREQUENCY 10000000
|
||||
// #define SPI_FREQUENCY 20000000
|
||||
#define SPI_FREQUENCY 27000000 // Maximum for my ST7735. It is actually 26.67MHz = 80/3
|
||||
#define SPI_FREQUENCY 27000000 // Actually sets it to 26.67MHz = 80/3
|
||||
// #define SPI_FREQUENCY 40000000 // Maximum to use SPIFFS
|
||||
// #define SPI_FREQUENCY 80000000
|
||||
|
||||
// The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here:
|
||||
#define SPI_TOUCH_FREQUENCY 2500000
|
||||
|
||||
|
||||
// Comment out the following #define if "SPI Transactions" do not need to be
|
||||
// supported. Tranaction support is required if other SPI devices are connected.
|
||||
// When commented out the code size will be smaller and sketches will
|
||||
// supported. When commented out the code size will be smaller and sketches will
|
||||
// run slightly faster, so leave it commented out unless you need it!
|
||||
|
||||
// Transaction support is needed to work with SD library but not needed with TFT_SdFat
|
||||
|
||||
// Transaction support is required if other SPI devices are connected.
|
||||
|
||||
// Transactions are automatically enabled by the library for an ESP32 (to use HAL mutex)
|
||||
// so changing it here has no effect
|
||||
|
||||
// #define SUPPORT_TRANSACTIONS
|
||||
|
||||
// If this next #define is not commented out then the SPI pins used by the program FLASH
|
||||
// can be shared with the TFT, this frees up the HSPI SCK, MOSI and MISO pins.
|
||||
// The TFT must be connected as follows for this to work:
|
||||
// TFT Chip Select to GPIO0 (pin D3 on a NodeMCU)
|
||||
// TFT MOSI/SDA to GPIO8/SDD1 (pin SD1 on a NodeMCU)
|
||||
// TFT MISO to GPIO7/SDD0 (pin SD0 on a NodeMCU) - does not need to be connected
|
||||
// TFT SCK to GPIO6/SDCLK (pin CLK on a NodeMCU)
|
||||
|
||||
#define TFT_SPI_OVERLAP
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
// USER DEFINED SETTINGS
|
||||
//
|
||||
// The User_Setup header that will be called up is defined in User_Setup_Select.h
|
||||
// This file is a default template that can be copied to create new setup files
|
||||
// Add the new header file to the list in User_Setup_Select.h
|
||||
//
|
||||
// Set driver type, fonts to be loaded, pins used and SPI control method etc
|
||||
//
|
||||
// If this file is editted correctly then all the library example sketches should
|
||||
//
|
||||
// See the User_Setup_Select.h file if you wish to be able to define multiple
|
||||
// setups and then easily select which setup file is used by the compiler.
|
||||
//
|
||||
// If this file is edited correctly then all the library example sketches should
|
||||
// run without the need to make any more changes for a particular hardware setup!
|
||||
|
||||
// ##################################################################################
|
||||
|
|
@ -18,8 +16,14 @@
|
|||
// Only define one driver, the other ones must be commented out
|
||||
#define ILI9341_DRIVER
|
||||
//#define ST7735_DRIVER
|
||||
//#define ILI9163_DRIVER
|
||||
//#define S6D02A1_DRIVER
|
||||
//#define RPI_ILI9486_DRIVER // 20MHz maximum SPI
|
||||
|
||||
// For ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
|
||||
// For M5Stack ESP32 module with integrated display ONLY, remove // in line below
|
||||
//#define M5STACK
|
||||
|
||||
// For ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
|
||||
//#define TFT_WIDTH 128
|
||||
//#define TFT_HEIGHT 160
|
||||
//#define TFT_HEIGHT 128
|
||||
|
|
@ -34,6 +38,8 @@
|
|||
//#define ST7735_INITB
|
||||
//#define ST7735_GREENTAB
|
||||
//#define ST7735_GREENTAB2
|
||||
//#define ST7735_GREENTAB3
|
||||
//#define ST7735_GREENTAB128 // For 128 x 128 display
|
||||
//#define ST7735_REDTAB
|
||||
//#define ST7735_BLACKTAB
|
||||
|
||||
|
|
@ -44,13 +50,13 @@
|
|||
// ##################################################################################
|
||||
|
||||
// We must use hardware SPI, a minimum of 3 GPIO pins is needed.
|
||||
// Typical setup for NodeMCU ESP-12 is :
|
||||
// Typical setup for ESP8266 NodeMCU ESP-12 is :
|
||||
//
|
||||
// Display SDO/MISO to NodeMCU pin D6 (or leave disconnected if not reading TFT)
|
||||
// Display LED to NodeMCU pin VIN (or 5V, see below)
|
||||
// Display SCK to NodeMCU pin D5
|
||||
// Display SDI/MOSI to NodeMCU pin D7
|
||||
// Display DC (or AO)to NodeMCU pin D3
|
||||
// Display DC (RS/AO)to NodeMCU pin D3
|
||||
// Display RESET to NodeMCU pin D4 (or RST, see below)
|
||||
// Display CS to NodeMCU pin D8 (or GND, see below)
|
||||
// Display GND to NodeMCU pin GND (0V)
|
||||
|
|
@ -58,8 +64,10 @@
|
|||
//
|
||||
// The TFT RESET pin can be connected to the NodeMCU RST pin or 3.3V to free up a control pin
|
||||
//
|
||||
// The DC (Data Command) pin may be labeled AO or RS (Register Select)
|
||||
//
|
||||
// With some displays such as the ILI9341 the TFT CS pin can be connected to GND if no more
|
||||
// SPI deivces (e.g. an SD Card) are connected, in this case comment out the #define TFT_CS
|
||||
// SPI devices (e.g. an SD Card) are connected, in this case comment out the #define TFT_CS
|
||||
// line below so it is NOT defined. Other displays such at the ST7735 require the TFT CS pin
|
||||
// to be toggled during setup, so in these cases the TFT_CS line must be defined and connected.
|
||||
//
|
||||
|
|
@ -71,23 +79,65 @@
|
|||
// If 5V is not available at a pin you can use 3.3V but backlight brightness
|
||||
// will be lower.
|
||||
|
||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR SETUP ######
|
||||
|
||||
// ModeMCU
|
||||
// ###### 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_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V
|
||||
|
||||
// ESP32 Dev board (planned, not supported yet)
|
||||
//#define TFT_CS 5 // Chip select control pin
|
||||
//#define TFT_DC 2 // Data Command control pin
|
||||
//#define TFT_RST 4 // Reset pin (could connect to Arduino RESET pin)
|
||||
//#define TOUCH_CS PIN_D1 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR PIN_D2 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
|
||||
// ###### FOR ESP8266 OVERLAP MODE EDIT THE PIN NUMBERS IN THE FOLLOWING LINES ######
|
||||
|
||||
// Overlap mode shares the ESP8266 FLASH SPI bus with the TFT so has a performance impact
|
||||
// but saves pins for other functions.
|
||||
// Use NodeMCU SD0=MISO, SD1=MOSI, CLK=SCLK to connect to TFT in overlap mode
|
||||
|
||||
// In ESP8266 overlap mode the TFT chip select MUST connect to pin D3
|
||||
//#define TFT_CS PIN_D3
|
||||
//#define TFT_DC PIN_D5 // 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
|
||||
|
||||
// In ESP8266 overlap mode the following must be defined
|
||||
//#define TFT_SPI_OVERLAP
|
||||
|
||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR ESP32 SETUP ######
|
||||
|
||||
// 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_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 TOUCH_CS 22 // Chip select pin (T_CS) of touch screen
|
||||
|
||||
//#define TFT_WR 21 // Write strobe for modified Raspberry Pi TFT only
|
||||
|
||||
// For the M5Stack module use these #define lines
|
||||
//#define TFT_MISO 19
|
||||
//#define TFT_MOSI 23
|
||||
//#define TFT_SCLK 18
|
||||
//#define TFT_CS 14 // Chip select control pin
|
||||
//#define TFT_DC 27 // Data Command control pin
|
||||
//#define TFT_RST 33 // Reset pin (could connect to Arduino RESET pin)
|
||||
//#define TFT_BL 32 // LED back-light
|
||||
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 2. Define the way the DC and/or CS lines are driven
|
||||
// Section 2. Define the way the DC and/or CS lines are driven (ESP8266 only)
|
||||
//
|
||||
// ##################################################################################
|
||||
|
||||
|
|
@ -107,18 +157,23 @@
|
|||
// ##################################################################################
|
||||
|
||||
// Comment out the #defines below with // to stop that font being loaded
|
||||
// The ESP8366 had plenty of memory so commenting out fonts is not normally necessary
|
||||
// If all fonts are loaded the extra FLASH space required is about 17Kbytes...
|
||||
// To save FLASH space only enable the fonts you need!
|
||||
// The ESP8366 and ESP32 have plenty of memory so commenting out fonts is not
|
||||
// normally necessary. If all fonts are loaded the extra FLASH space required is
|
||||
// about 17Kbytes. To save FLASH space only enable the fonts you need!
|
||||
|
||||
#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_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT
|
||||
#define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
|
||||
#define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts
|
||||
|
||||
// Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded
|
||||
// this will save ~20kbytes of FLASH
|
||||
#define SMOOTH_FONT
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 4. Not used
|
||||
|
|
@ -132,23 +187,34 @@
|
|||
//
|
||||
// ##################################################################################
|
||||
|
||||
// Define the SPI clock frequency
|
||||
// Define the SPI clock frequency, this affects the graphics rendering speed. Too
|
||||
// fast and the TFT driver will not keep up and display corruption appears.
|
||||
// With an ILI9341 display 40MHz works OK, 80MHz sometimes fails
|
||||
// With a ST7735 display more than 27MHz may not work (spurious pixels and lines)
|
||||
// With an ILI9163 display 27 MHz works OK.
|
||||
// The RPi typically only works at 20MHz maximum.
|
||||
|
||||
// #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 27000000 // Actually sets it to 26.67MHz = 80/3
|
||||
// #define SPI_FREQUENCY 40000000 // Maximum to use SPIFFS
|
||||
// #define SPI_FREQUENCY 53400000
|
||||
// #define SPI_FREQUENCY 80000000
|
||||
|
||||
// The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here:
|
||||
#define SPI_TOUCH_FREQUENCY 2500000
|
||||
|
||||
|
||||
// Comment out the following #define if "SPI Transactions" do not need to be
|
||||
// supported. Tranaction support is required if other SPI devices are connected.
|
||||
// When commented out the code size will be smaller and sketches will
|
||||
// supported. When commented out the code size will be smaller and sketches will
|
||||
// run slightly faster, so leave it commented out unless you need it!
|
||||
|
||||
// Transaction support is needed to work with SD library but not needed with TFT_SdFat
|
||||
// Transaction support is required if other SPI devices are connected.
|
||||
|
||||
// Transactions are automatically enabled by the library for an ESP32 (to use HAL mutex)
|
||||
// so changing it here has no effect
|
||||
|
||||
// #define SUPPORT_TRANSACTIONS
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ const uint16_t closeWidth = 32;
|
|||
const uint16_t closeHeight = 32;
|
||||
|
||||
// The icon file can be created with the "UTFT ImageConverter 565" bitmap to .c file creation utility, more can be pasted in here
|
||||
const unsigned short close[1024] PROGMEM={
|
||||
const unsigned short closeX[1024] PROGMEM={
|
||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x30C3,0x4124,0x61C7,0x61C7,0x4124,0x30E3,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 0, 32 pixels
|
||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x48E3,0xA249,0xEB8E,0xFCB2,0xFD14,0xFD75,0xFD96,0xFD34,0xFCF3,0xEBEF,0xA28A,0x4904,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 1, 64 pixels
|
||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x58E3,0xC228,0xFC10,0xFD34,0xFE18,0xFE59,0xFE79,0xFE9A,0xFE9A,0xFE9A,0xFE9A,0xFE59,0xFD75,0xFC51,0xC28A,0x5904,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 2, 96 pixels
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
TFT_eSPI tft = TFT_eSPI(); // Invoke library, pins defined in User_Setup.h
|
||||
|
||||
// Include the header files that contain the icons
|
||||
#include "alert.h"
|
||||
#include "Alert.h"
|
||||
#include "Close.h"
|
||||
#include "Info.h"
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ void setup()
|
|||
// Draw the icons
|
||||
drawIcon(info, (tft.width() - infoWidth)/2 - 50, (tft.height() - infoHeight)/2, infoWidth, infoHeight);
|
||||
drawIcon(alert, (tft.width() - alertWidth)/2, (tft.height() - alertHeight)/2, alertWidth, alertHeight);
|
||||
drawIcon(close, (tft.width() - closeWidth)/2 + 50, (tft.height() - closeHeight)/2, closeWidth, closeHeight);
|
||||
drawIcon(closeX, (tft.width() - closeWidth)/2 + 50, (tft.height() - closeHeight)/2, closeWidth, closeHeight);
|
||||
|
||||
// Pause here to admire the icons!
|
||||
delay(4000);
|
||||
|
|
@ -57,7 +57,7 @@ void loop()
|
|||
// Loop filling and clearing screen
|
||||
drawIcon(info, random(tft.width() - infoWidth), random(tft.height() - infoHeight), infoWidth, infoHeight);
|
||||
drawIcon(alert, random(tft.width() - alertWidth), random(tft.height() - alertHeight), alertWidth, alertHeight);
|
||||
drawIcon(close, random(tft.width() - closeWidth), random(tft.height() - closeHeight), alertWidth, closeHeight);
|
||||
drawIcon(closeX, random(tft.width() - closeWidth), random(tft.height() - closeHeight), alertWidth, closeHeight);
|
||||
|
||||
// Clear screen after 100 x 3 = 300 icons drawn
|
||||
if (100 == count++) {
|
||||
|
|
@ -80,7 +80,7 @@ void loop()
|
|||
// Draw array "icon" of defined width and height at coordinate x,y
|
||||
// Maximum icon size is 255x255 pixels to avoid integer overflow
|
||||
|
||||
void drawIcon(const unsigned short* icon, int16_t x, int16_t y, int8_t width, int8_t height) {
|
||||
void drawIcon(const unsigned short* icon, int16_t x, int16_t y, uint16_t width, uint16_t height) {
|
||||
|
||||
uint16_t pix_buffer[BUFF_SIZE]; // Pixel buffer (16 bits per pixel)
|
||||
|
||||
|
|
|
|||
|
|
@ -79,15 +79,34 @@ void jpegRender(int xpos, int ypos) {
|
|||
pImg = JpegDec.pImage;
|
||||
|
||||
// calculate where the image block should be drawn on the screen
|
||||
int mcu_x = JpegDec.MCUx * mcu_w + xpos;
|
||||
int mcu_x = JpegDec.MCUx * mcu_w + xpos; // Calculate coordinates of top left corner of current MCU
|
||||
int mcu_y = JpegDec.MCUy * mcu_h + ypos;
|
||||
|
||||
// check if the image block size needs to be changed for the right and bottom edges
|
||||
// check if the image block size needs to be changed for the right edge
|
||||
if (mcu_x + mcu_w <= max_x) win_w = mcu_w;
|
||||
else win_w = min_w;
|
||||
|
||||
// check if the image block size needs to be changed for the bottom edge
|
||||
if (mcu_y + mcu_h <= max_y) win_h = mcu_h;
|
||||
else win_h = min_h;
|
||||
|
||||
// copy pixels into a contiguous block
|
||||
if (win_w != mcu_w)
|
||||
{
|
||||
uint16_t *cImg;
|
||||
int p = 0;
|
||||
cImg = pImg + win_w;
|
||||
for (int h = 1; h < win_h; h++)
|
||||
{
|
||||
p += mcu_w;
|
||||
for (int w = 0; w < win_w; w++)
|
||||
{
|
||||
*cImg = *(pImg + w + p);
|
||||
cImg++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// draw image MCU block only if it will fit on the screen
|
||||
if ( ( mcu_x + win_w) <= tft.width() && ( mcu_y + win_h) <= tft.height())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -130,12 +130,31 @@ void renderJPEG(int xpos, int ypos) {
|
|||
int mcu_x = JpegDec.MCUx * mcu_w + xpos; // Calculate coordinates of top left corner of current MCU
|
||||
int mcu_y = JpegDec.MCUy * mcu_h + ypos;
|
||||
|
||||
// check if the image block size needs to be changed for the right and bottom edges
|
||||
// check if the image block size needs to be changed for the right edge
|
||||
if (mcu_x + mcu_w <= max_x) win_w = mcu_w;
|
||||
else win_w = min_w;
|
||||
|
||||
// check if the image block size needs to be changed for the bottom edge
|
||||
if (mcu_y + mcu_h <= max_y) win_h = mcu_h;
|
||||
else win_h = min_h;
|
||||
|
||||
// copy pixels into a contiguous block
|
||||
if (win_w != mcu_w)
|
||||
{
|
||||
uint16_t *cImg;
|
||||
int p = 0;
|
||||
cImg = pImg + win_w;
|
||||
for (int h = 1; h < win_h; h++)
|
||||
{
|
||||
p += mcu_w;
|
||||
for (int w = 0; w < win_w; w++)
|
||||
{
|
||||
*cImg = *(pImg + w + p);
|
||||
cImg++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// draw image MCU block only if it will fit on the screen
|
||||
if (( mcu_x + win_w ) <= tft.width() && ( mcu_y + win_h ) <= tft.height())
|
||||
{
|
||||
|
|
@ -0,0 +1,284 @@
|
|||
/*
|
||||
The TFT_eSPI library incorporates an Adafruit_GFX compatible
|
||||
button handling class, this sketch is based on the Arduin-o-phone
|
||||
example.
|
||||
|
||||
This example diplays a keypad where numbers can be entered and
|
||||
send to the Serial Monitor window.
|
||||
|
||||
The sketch has been tested on the ESP8266 (which supports SPIFFS)
|
||||
|
||||
The minimum screen size is 320 x 240 as that is the keypad size.
|
||||
*/
|
||||
|
||||
// The SPIFFS (FLASH filing system) is used to hold touch screen
|
||||
// calibration data
|
||||
|
||||
#include "FS.h"
|
||||
|
||||
#include <SPI.h>
|
||||
#include <TFT_eSPI.h> // Hardware-specific library
|
||||
|
||||
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
|
||||
|
||||
// This is the file name used to store the calibration data
|
||||
// You can change this to create new calibration files.
|
||||
// The SPIFFS file name must start with "/".
|
||||
#define CALIBRATION_FILE "/TouchCalData1"
|
||||
|
||||
// Set REPEAT_CAL to true instead of false to run calibration
|
||||
// again, otherwise it will only be done once.
|
||||
// Repeat calibration if you change the screen rotation.
|
||||
#define REPEAT_CAL false
|
||||
|
||||
// Keypad start position, key sizes and spacing
|
||||
#define KEY_X 40 // Centre of key
|
||||
#define KEY_Y 96
|
||||
#define KEY_W 62 // Width and height
|
||||
#define KEY_H 30
|
||||
#define KEY_SPACING_X 18 // X and Y gap
|
||||
#define KEY_SPACING_Y 20
|
||||
#define KEY_TEXTSIZE 1 // Font size multiplier
|
||||
|
||||
// Using two fonts since numbers are nice when bold
|
||||
#define LABEL1_FONT &FreeSansOblique12pt7b // Key label font 1
|
||||
#define LABEL2_FONT &FreeSansBold12pt7b // Key label font 2
|
||||
|
||||
// Numeric display box size and location
|
||||
#define DISP_X 1
|
||||
#define DISP_Y 10
|
||||
#define DISP_W 238
|
||||
#define DISP_H 50
|
||||
#define DISP_TSIZE 3
|
||||
#define DISP_TCOLOR TFT_CYAN
|
||||
|
||||
// Number length, buffer for storing it and character index
|
||||
#define NUM_LEN 12
|
||||
char numberBuffer[NUM_LEN + 1] = "";
|
||||
uint8_t numberIndex = 0;
|
||||
|
||||
// We have a status line for messages
|
||||
#define STATUS_X 120 // Centred on this
|
||||
#define STATUS_Y 65
|
||||
|
||||
// Create 15 keys for the keypad
|
||||
char keyLabel[15][5] = {"New", "Del", "Send", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".", "0", "#" };
|
||||
uint16_t keyColor[15] = {TFT_RED, TFT_DARKGREY, TFT_DARKGREEN,
|
||||
TFT_BLUE, TFT_BLUE, TFT_BLUE,
|
||||
TFT_BLUE, TFT_BLUE, TFT_BLUE,
|
||||
TFT_BLUE, TFT_BLUE, TFT_BLUE,
|
||||
TFT_BLUE, TFT_BLUE, TFT_BLUE
|
||||
};
|
||||
|
||||
// Invoke the TFT_eSPI button class and create all the button objects
|
||||
TFT_eSPI_Button key[15];
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
void setup() {
|
||||
// Use serial port
|
||||
Serial.begin(9600);
|
||||
|
||||
// Initialise the TFT screen
|
||||
tft.init();
|
||||
|
||||
// Set the rotation before we calibrate
|
||||
tft.setRotation(0);
|
||||
|
||||
// Calibrate the touch screen and retrieve the scaling factors
|
||||
touch_calibrate();
|
||||
|
||||
// Clear the screen
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
// Draw keypad background
|
||||
tft.fillRect(0, 0, 240, 320, TFT_DARKGREY);
|
||||
|
||||
// Draw number display area and frame
|
||||
tft.fillRect(DISP_X, DISP_Y, DISP_W, DISP_H, TFT_BLACK);
|
||||
tft.drawRect(DISP_X, DISP_Y, DISP_W, DISP_H, TFT_WHITE);
|
||||
|
||||
// Draw keypad
|
||||
drawKeypad();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
void loop(void) {
|
||||
uint16_t t_x = 0, t_y = 0; // To store the touch coordinates
|
||||
|
||||
// Pressed will be set true is there is a valid touch on the screen
|
||||
boolean pressed = tft.getTouch(&t_x, &t_y);
|
||||
|
||||
// / Check if any key coordinate boxes contain the touch coordinates
|
||||
for (uint8_t b = 0; b < 15; b++) {
|
||||
if (pressed && key[b].contains(t_x, t_y)) {
|
||||
key[b].press(true); // tell the button it is pressed
|
||||
} else {
|
||||
key[b].press(false); // tell the button it is NOT pressed
|
||||
}
|
||||
}
|
||||
|
||||
// Check if any key has changed state
|
||||
for (uint8_t b = 0; b < 15; b++) {
|
||||
|
||||
if (b < 3) tft.setFreeFont(LABEL1_FONT);
|
||||
else tft.setFreeFont(LABEL2_FONT);
|
||||
|
||||
if (key[b].justReleased()) key[b].drawButton(); // draw normal
|
||||
|
||||
if (key[b].justPressed()) {
|
||||
key[b].drawButton(true); // draw invert
|
||||
|
||||
// if a numberpad button, append the relevant # to the numberBuffer
|
||||
if (b >= 3) {
|
||||
if (numberIndex < NUM_LEN) {
|
||||
numberBuffer[numberIndex] = keyLabel[b][0];
|
||||
numberIndex++;
|
||||
numberBuffer[numberIndex] = 0; // zero terminate
|
||||
}
|
||||
status(""); // Clear the old status
|
||||
}
|
||||
|
||||
// Del button, so delete last char
|
||||
if (b == 1) {
|
||||
numberBuffer[numberIndex] = 0;
|
||||
if (numberIndex > 0) {
|
||||
numberIndex--;
|
||||
numberBuffer[numberIndex] = 0;//' ';
|
||||
}
|
||||
status(""); // Clear the old status
|
||||
}
|
||||
|
||||
if (b == 2) {
|
||||
status("Sent value to serial port");
|
||||
Serial.println(numberBuffer);
|
||||
}
|
||||
// we dont really check that the text field makes sense
|
||||
// just try to call
|
||||
if (b == 0) {
|
||||
status("Value cleared");
|
||||
numberIndex = 0; // Reset index to 0
|
||||
numberBuffer[numberIndex] = 0; // Place null in buffer
|
||||
}
|
||||
|
||||
// Update the number display field
|
||||
tft.setTextDatum(TL_DATUM); // Use top left corner as text coord datum
|
||||
tft.setFreeFont(&FreeSans18pt7b); // Choose a nicefont that fits box
|
||||
tft.setTextColor(DISP_TCOLOR); // Set the font colour
|
||||
|
||||
// Draw the string, the value returned is the width in pixels
|
||||
int xwidth = tft.drawString(numberBuffer, DISP_X + 4, DISP_Y + 12);
|
||||
|
||||
// Now cover up the rest of the line up by drawing a black rectangle. No flicker this way
|
||||
// but it will not work with italic or oblique fonts due to character overlap.
|
||||
tft.fillRect(DISP_X + 4 + xwidth, DISP_Y + 1, DISP_W - xwidth - 5, DISP_H - 2, TFT_BLACK);
|
||||
|
||||
delay(10); // UI debouncing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
void drawKeypad()
|
||||
{
|
||||
// Draw the keys
|
||||
for (uint8_t row = 0; row < 5; row++) {
|
||||
for (uint8_t col = 0; col < 3; col++) {
|
||||
uint8_t b = col + row * 3;
|
||||
|
||||
if (b < 3) tft.setFreeFont(LABEL1_FONT);
|
||||
else tft.setFreeFont(LABEL2_FONT);
|
||||
|
||||
key[b].initButton(&tft, KEY_X + col * (KEY_W + KEY_SPACING_X),
|
||||
KEY_Y + row * (KEY_H + KEY_SPACING_Y), // x, y, w, h, outline, fill, text
|
||||
KEY_W, KEY_H, TFT_WHITE, keyColor[b], TFT_WHITE,
|
||||
keyLabel[b], KEY_TEXTSIZE);
|
||||
key[b].drawButton();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
void touch_calibrate()
|
||||
{
|
||||
uint16_t calData[5];
|
||||
uint8_t calDataOK = 0;
|
||||
|
||||
// check file system exists
|
||||
if (!SPIFFS.begin()) {
|
||||
Serial.println("Formating file system");
|
||||
SPIFFS.format();
|
||||
SPIFFS.begin();
|
||||
}
|
||||
|
||||
// check if calibration file exists and size is correct
|
||||
if (SPIFFS.exists(CALIBRATION_FILE)) {
|
||||
if (REPEAT_CAL)
|
||||
{
|
||||
// Delete if we want to re-calibrate
|
||||
SPIFFS.remove(CALIBRATION_FILE);
|
||||
}
|
||||
else
|
||||
{
|
||||
File f = SPIFFS.open(CALIBRATION_FILE, "r");
|
||||
if (f) {
|
||||
if (f.readBytes((char *)calData, 14) == 14)
|
||||
calDataOK = 1;
|
||||
f.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (calDataOK && !REPEAT_CAL) {
|
||||
// calibration data valid
|
||||
tft.setTouch(calData);
|
||||
} else {
|
||||
// data not valid so recalibrate
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
tft.setCursor(20, 0);
|
||||
tft.setTextFont(2);
|
||||
tft.setTextSize(1);
|
||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
|
||||
tft.println("Touch corners as indicated");
|
||||
|
||||
tft.setTextFont(1);
|
||||
tft.println();
|
||||
|
||||
if (REPEAT_CAL) {
|
||||
tft.setTextColor(TFT_RED, TFT_BLACK);
|
||||
tft.println("Set REPEAT_CAL to false to stop this running again!");
|
||||
}
|
||||
|
||||
tft.calibrateTouch(calData, TFT_MAGENTA, TFT_BLACK, 15);
|
||||
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
||||
tft.println("Calibration complete!");
|
||||
|
||||
// store data
|
||||
File f = SPIFFS.open(CALIBRATION_FILE, "w");
|
||||
if (f) {
|
||||
f.write((const unsigned char *)calData, 14);
|
||||
f.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
// Print something in the mini status bar
|
||||
void status(const char *msg) {
|
||||
tft.setTextPadding(240);
|
||||
//tft.setCursor(STATUS_X, STATUS_Y);
|
||||
tft.setTextColor(TFT_WHITE, TFT_DARKGREY);
|
||||
tft.setTextFont(0);
|
||||
tft.setTextDatum(TC_DATUM);
|
||||
tft.setTextSize(1);
|
||||
tft.drawString(msg, STATUS_X, STATUS_Y);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -4,6 +4,8 @@
|
|||
// Bit bashes SPI so it does NOT assume hardware SPI wired up
|
||||
// No other libraries are needed
|
||||
|
||||
// NOTE: This sketch does not work with parallel displays!
|
||||
|
||||
// Original author unknown
|
||||
// Adapted by Bodmer 22/5/16, updated 16/9/16
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
const uint16_t closeWidth = 32;
|
||||
const uint16_t closeHeight = 32;
|
||||
|
||||
const unsigned short close[1024] PROGMEM={
|
||||
const unsigned short closeX[1024] PROGMEM={
|
||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x30C3,0x4124,0x61C7,0x61C7,0x4124,0x30E3,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 0, 32 pixels
|
||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x48E3,0xA249,0xEB8E,0xFCB2,0xFD14,0xFD75,0xFD96,0xFD34,0xFCF3,0xEBEF,0xA28A,0x4904,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 1, 64 pixels
|
||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x58E3,0xC228,0xFC10,0xFD34,0xFE18,0xFE59,0xFE79,0xFE9A,0xFE9A,0xFE9A,0xFE9A,0xFE59,0xFD75,0xFC51,0xC28A,0x5904,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 2, 96 pixels
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
|
||||
|
||||
// Include the header files that contain the icons
|
||||
#include "alert.h"
|
||||
#include "Alert.h"
|
||||
#include "Close.h"
|
||||
#include "Info.h"
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ void setup()
|
|||
// Draw the icons
|
||||
drawIcon(info, 100, 100, infoWidth, infoHeight);
|
||||
drawIcon(alert, 140, 100, alertWidth, alertHeight);
|
||||
drawIcon(close, 180, 100, closeWidth, closeHeight);
|
||||
drawIcon(closeX, 180, 100, closeWidth, closeHeight);
|
||||
|
||||
// Pause here to admire the icons!
|
||||
delay(2000);
|
||||
|
|
@ -53,7 +53,7 @@ void loop()
|
|||
// Loop filling and clearing screen
|
||||
drawIcon(info, random(tft.width() - infoWidth), random(tft.height() - infoHeight), infoWidth, infoHeight);
|
||||
drawIcon(alert, random(tft.width() - alertWidth), random(tft.height() - alertHeight), alertWidth, alertHeight);
|
||||
drawIcon(close, random(tft.width() - closeWidth), random(tft.height() - closeHeight), alertWidth, closeHeight);
|
||||
drawIcon(closeX, random(tft.width() - closeWidth), random(tft.height() - closeHeight), alertWidth, closeHeight);
|
||||
|
||||
// Clear screen after 100 x 3 = 300 icons drawn
|
||||
if (100 == count++) {
|
||||
|
|
@ -76,7 +76,7 @@ void loop()
|
|||
// Draw array "icon" of defined width and height at coordinate x,y
|
||||
// Maximum icon size is 255x255 pixels to avoid integer overflow
|
||||
|
||||
void drawIcon(const unsigned short* icon, int16_t x, int16_t y, int8_t width, int8_t height) {
|
||||
void drawIcon(const unsigned short* icon, int16_t x, int16_t y, uint16_t width, uint16_t height) {
|
||||
|
||||
uint16_t pix_buffer[BUFF_SIZE]; // Pixel buffer (16 bits per pixel)
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ See more at http://blog.squix.ch
|
|||
// In case of problems make sure that you are using the font file with the correct version!
|
||||
|
||||
// Bodmer fix: End character is 0x7D not 0x7E, so bug in last line of the file corrected
|
||||
// this avoids screen corruption if ~ is printer
|
||||
// this avoids screen corruption if ~ is printed
|
||||
|
||||
// Bodmer change: '`' changed to tiny degree symbol (typically this character is on top left key of a QWERTY keyboard)
|
||||
|
||||
|
|
@ -157,8 +157,13 @@ void GfxUi::drawBmp(String filename, uint8_t x, uint16_t y) {
|
|||
} // End of bitmap file check
|
||||
|
||||
bmpFile.close();
|
||||
if(!goodBmp) Serial.println(F("BMP format not recognised."));
|
||||
_tft->setRotation(rotation); // Put back original rotation
|
||||
|
||||
if(!goodBmp) {
|
||||
Serial.print(F("BMP format not recognised. File:"));
|
||||
Serial.println(filename);
|
||||
}
|
||||
else
|
||||
_tft->setRotation(rotation); // Put back original rotation
|
||||
}
|
||||
|
||||
// These read 16- and 32-bit types from the SD card file.
|
||||
|
|
@ -270,30 +275,35 @@ void GfxUi::jpegRender(int xpos, int ypos) {
|
|||
int mcu_x = JpegDec.MCUx * mcu_w + xpos;
|
||||
int mcu_y = JpegDec.MCUy * mcu_h + ypos;
|
||||
|
||||
// check if the image block size needs to be changed for the right and bottom edges
|
||||
// check if the image block size needs to be changed for the right edge
|
||||
if (mcu_x + mcu_w <= max_x) win_w = mcu_w;
|
||||
else win_w = min_w;
|
||||
|
||||
// check if the image block size needs to be changed for the bottom edge
|
||||
if (mcu_y + mcu_h <= max_y) win_h = mcu_h;
|
||||
else win_h = min_h;
|
||||
|
||||
// calculate how many pixels must be drawn
|
||||
uint32_t mcu_pixels = win_w * win_h;
|
||||
// copy pixels into a contiguous block
|
||||
if (win_w != mcu_w)
|
||||
{
|
||||
uint16_t *cImg;
|
||||
int p = 0;
|
||||
cImg = pImg + win_w;
|
||||
for (int h = 1; h < win_h; h++)
|
||||
{
|
||||
p += mcu_w;
|
||||
for (int w = 0; w < win_w; w++)
|
||||
{
|
||||
*cImg = *(pImg + w + p);
|
||||
cImg++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// draw image MCU block only if it will fit on the screen
|
||||
if ( ( mcu_x + win_w) <= _tft->width() && ( mcu_y + win_h) <= _tft->height())
|
||||
{
|
||||
#ifdef USE_SPI_BUFFER
|
||||
// Now set a MCU bounding window on the TFT to push pixels into (x, y, x + width - 1, y + height - 1)
|
||||
_tft->setWindow(mcu_x, mcu_y, mcu_x + win_w - 1, mcu_y + win_h - 1);
|
||||
// Write all MCU pixels to the TFT window
|
||||
uint8_t *pImg8 = (uint8_t*)pImg; // Convert 16 bit pointer to an 8 bit pointer
|
||||
_tft->pushColors(pImg8, mcu_pixels*2); // Send bytes via 64 byte SPI port buffer
|
||||
#else
|
||||
// Now set a MCU bounding window on the TFT to push pixels into (x, y, x + width - 1, y + height - 1)
|
||||
_tft->setAddrWindow(mcu_x, mcu_y, mcu_x + win_w - 1, mcu_y + win_h - 1);
|
||||
// Write all MCU pixels to the TFT window
|
||||
while (mcu_pixels--) _tft->pushColor(*pImg++);
|
||||
#endif
|
||||
{
|
||||
_tft->pushImage(mcu_x, mcu_y, win_w, win_h, pImg);
|
||||
}
|
||||
|
||||
else if ( ( mcu_y + win_h) >= _tft->height()) JpegDec.abort();
|
||||
|
|
@ -18,22 +18,30 @@ SOFTWARE.
|
|||
See more at http://blog.squix.ch
|
||||
|
||||
Adapted by Bodmer to use the faster TFT_ILI9341_ESP library:
|
||||
https://github.com/Bodmer/TFT_ILI9341_ESP
|
||||
https://github.com/Bodmer/TFT_eSPI
|
||||
|
||||
Version 9
|
||||
*/
|
||||
|
||||
// ***************************************************************************************
|
||||
// WARNING - READ THIS
|
||||
//
|
||||
// 3M Flash Size MUST be allocated to SPIFFS using the IDE Tools menu option or else the
|
||||
// ESP8266 may crash or do strange things (due to lack of error checks in SPIFFS library?)
|
||||
// ***************************************************************************************
|
||||
//
|
||||
// Setup
|
||||
const int UPDATE_INTERVAL_SECS = 10 * 60; // Update every 10 minutes
|
||||
|
||||
// Pins for the TFT interface are defined in the User_Config.h file inside the TFT_ILI9341_ESP library
|
||||
// Pins for the TFT interface are defined in the User_Config.h file inside the TFT_eSPI library
|
||||
|
||||
// TimeClient settings
|
||||
const float UTC_OFFSET = 1;
|
||||
|
||||
// Wunderground Settings, EDIT TO SUIT YOUR LOCATION
|
||||
// Wunderground Settings, EDIT to suit your Wunderground key and location
|
||||
const boolean IS_METRIC = true; // Temperature only? Wind speed units appear to stay in mph. To do: investigate <<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
const String WUNDERGRROUND_API_KEY = "<WUNDERGROUND KEY HERE>";
|
||||
//const String WUNDERGRROUND_API_KEY = "1c265fajf48s0a82"; // Random key example showing how the above line should look
|
||||
//const String WUNDERGRROUND_API_KEY = "WUNDERGROUND KEY HERE";
|
||||
const String WUNDERGRROUND_API_KEY = "1c265fajf48s0a82"; // Random key example showing how the above line should look
|
||||
|
||||
// For language codes see https://www.wunderground.com/weather/api/d/docs?d=language-support&_ga=1.55148395.1951311424.1484425551
|
||||
const String WUNDERGRROUND_LANGUAGE = "EN"; // Language EN = English
|
||||
|
|
@ -53,8 +61,8 @@ const String WUNDERGROUND_CITY = "Base_Naval"; // City, "London", "FL/Boca_Raton
|
|||
#define WIND_SPEED_UNITS " kph"
|
||||
|
||||
//Thingspeak Settings - not used, no need to populate this at the moment
|
||||
const String THINGSPEAK_CHANNEL_ID = "<CHANNEL_ID_HERE>";
|
||||
const String THINGSPEAK_API_READ_KEY = "<API_READ_KEY_HERE>";
|
||||
const String THINGSPEAK_CHANNEL_ID = "CHANNEL_ID_HERE";
|
||||
const String THINGSPEAK_API_READ_KEY = "API_READ_KEY_HERE";
|
||||
|
||||
// List, so that the downloader knows what to fetch
|
||||
String wundergroundIcons [] = {"chanceflurries","chancerain","chancesleet","chancesnow","clear","cloudy","flurries","fog","hazy","mostlycloudy","mostlysunny","partlycloudy","partlysunny","rain","sleet","snow","sunny","tstorms","unknown"};
|
||||
|
|
@ -30,6 +30,7 @@
|
|||
New smart WU splash startup screen and updated progress messages
|
||||
Display does not need to be blanked between updates
|
||||
Icons nudged about slightly to add wind direction + speed
|
||||
Barometric pressure added
|
||||
*/
|
||||
|
||||
#define SERIAL_MESSAGES
|
||||
|
|
@ -6,7 +6,7 @@ const uint16_t closeWidth = 32;
|
|||
const uint16_t closeHeight = 32;
|
||||
|
||||
// The icon file can be created with the "UTFT ImageConverter 565" bitmap to .c file creation utility, more can be pasted in here
|
||||
const unsigned short close[1024] PROGMEM={
|
||||
const unsigned short closeX[1024] PROGMEM={
|
||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x30C3,0x4124,0x61C7,0x61C7,0x4124,0x30E3,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 0, 32 pixels
|
||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x48E3,0xA249,0xEB8E,0xFCB2,0xFD14,0xFD75,0xFD96,0xFD34,0xFCF3,0xEBEF,0xA28A,0x4904,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 1, 64 pixels
|
||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x58E3,0xC228,0xFC10,0xFD34,0xFE18,0xFE59,0xFE79,0xFE9A,0xFE9A,0xFE9A,0xFE9A,0xFE59,0xFD75,0xFC51,0xC28A,0x5904,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 2, 96 pixels
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library with default width and height
|
||||
|
||||
// Include the header files that contain the icons
|
||||
#include "alert.h"
|
||||
#include "Alert.h"
|
||||
#include "Close.h"
|
||||
#include "Info.h"
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ void setup()
|
|||
// Draw the icons
|
||||
drawIcon(info, (tft.width() - infoWidth)/2 - 50, (tft.height() - infoHeight)/2, infoWidth, infoHeight);
|
||||
drawIcon(alert, (tft.width() - alertWidth)/2, (tft.height() - alertHeight)/2, alertWidth, alertHeight);
|
||||
drawIcon(close, (tft.width() - closeWidth)/2 + 50, (tft.height() - closeHeight)/2, closeWidth, closeHeight);
|
||||
drawIcon(closeX, (tft.width() - closeWidth)/2 + 50, (tft.height() - closeHeight)/2, closeWidth, closeHeight);
|
||||
|
||||
// Pause here to admire the icons!
|
||||
delay(4000);
|
||||
|
|
@ -60,7 +60,7 @@ void loop()
|
|||
// Loop filling and clearing screen
|
||||
drawIcon(info, random(tft.width() - infoWidth), random(tft.height() - infoHeight), infoWidth, infoHeight);
|
||||
drawIcon(alert, random(tft.width() - alertWidth), random(tft.height() - alertHeight), alertWidth, alertHeight);
|
||||
drawIcon(close, random(tft.width() - closeWidth), random(tft.height() - closeHeight), alertWidth, closeHeight);
|
||||
drawIcon(closeX, random(tft.width() - closeWidth), random(tft.height() - closeHeight), alertWidth, closeHeight);
|
||||
|
||||
// Clear screen after 100 x 3 = 300 icons drawn
|
||||
if (100 == count++) {
|
||||
|
|
@ -83,7 +83,7 @@ void loop()
|
|||
// Draw array "icon" of defined width and height at coordinate x,y
|
||||
// Maximum icon size is 255x255 pixels to avoid integer overflow
|
||||
|
||||
void drawIcon(const unsigned short* icon, int16_t x, int16_t y, int8_t width, int8_t height) {
|
||||
void drawIcon(const unsigned short* icon, int16_t x, int16_t y, uint16_t width, uint16_t height) {
|
||||
|
||||
uint16_t pix_buffer[BUFF_SIZE]; // Pixel buffer (16 bits per pixel)
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,287 @@
|
|||
/*
|
||||
The TFT_eSPI library incorporates an Adafruit_GFX compatible
|
||||
button handling class, this sketch is based on the Arduin-o-phone
|
||||
example.
|
||||
|
||||
This example diplays a keypad where numbers can be entered and
|
||||
send to the Serial Monitor window.
|
||||
|
||||
The sketch has been tested on the ESP8266 (which supports SPIFFS)
|
||||
|
||||
The minimum screen size is 320 x 240 as that is the keypad size.
|
||||
|
||||
TOUCH_CS and SPI_TOUCH_FREQUENCY must be defined in the User_Setup.h file
|
||||
for the touch functions to do anything.
|
||||
*/
|
||||
|
||||
// The SPIFFS (FLASH filing system) is used to hold touch screen
|
||||
// calibration data
|
||||
|
||||
#include "FS.h"
|
||||
|
||||
#include <SPI.h>
|
||||
#include <TFT_eSPI.h> // Hardware-specific library
|
||||
|
||||
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
|
||||
|
||||
// This is the file name used to store the calibration data
|
||||
// You can change this to create new calibration files.
|
||||
// The SPIFFS file name must start with "/".
|
||||
#define CALIBRATION_FILE "/TouchCalData2"
|
||||
|
||||
// Set REPEAT_CAL to true instead of false to run calibration
|
||||
// again, otherwise it will only be done once.
|
||||
// Repeat calibration if you change the screen rotation.
|
||||
#define REPEAT_CAL false
|
||||
|
||||
// Keypad start position, key sizes and spacing
|
||||
#define KEY_X 40 // Centre of key
|
||||
#define KEY_Y 96
|
||||
#define KEY_W 62 // Width and height
|
||||
#define KEY_H 30
|
||||
#define KEY_SPACING_X 18 // X and Y gap
|
||||
#define KEY_SPACING_Y 20
|
||||
#define KEY_TEXTSIZE 1 // Font size multiplier
|
||||
|
||||
// Using two fonts since numbers are nice when bold
|
||||
#define LABEL1_FONT &FreeSansOblique12pt7b // Key label font 1
|
||||
#define LABEL2_FONT &FreeSansBold12pt7b // Key label font 2
|
||||
|
||||
// Numeric display box size and location
|
||||
#define DISP_X 1
|
||||
#define DISP_Y 10
|
||||
#define DISP_W 238
|
||||
#define DISP_H 50
|
||||
#define DISP_TSIZE 3
|
||||
#define DISP_TCOLOR TFT_CYAN
|
||||
|
||||
// Number length, buffer for storing it and character index
|
||||
#define NUM_LEN 12
|
||||
char numberBuffer[NUM_LEN + 1] = "";
|
||||
uint8_t numberIndex = 0;
|
||||
|
||||
// We have a status line for messages
|
||||
#define STATUS_X 120 // Centred on this
|
||||
#define STATUS_Y 65
|
||||
|
||||
// Create 15 keys for the keypad
|
||||
char keyLabel[15][5] = {"New", "Del", "Send", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".", "0", "#" };
|
||||
uint16_t keyColor[15] = {TFT_RED, TFT_DARKGREY, TFT_DARKGREEN,
|
||||
TFT_BLUE, TFT_BLUE, TFT_BLUE,
|
||||
TFT_BLUE, TFT_BLUE, TFT_BLUE,
|
||||
TFT_BLUE, TFT_BLUE, TFT_BLUE,
|
||||
TFT_BLUE, TFT_BLUE, TFT_BLUE
|
||||
};
|
||||
|
||||
// Invoke the TFT_eSPI button class and create all the button objects
|
||||
TFT_eSPI_Button key[15];
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
void setup() {
|
||||
// Use serial port
|
||||
Serial.begin(9600);
|
||||
|
||||
// Initialise the TFT screen
|
||||
tft.init();
|
||||
|
||||
// Set the rotation before we calibrate
|
||||
tft.setRotation(1);
|
||||
|
||||
// Calibrate the touch screen and retrieve the scaling factors
|
||||
touch_calibrate();
|
||||
|
||||
// Clear the screen
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
// Draw keypad background
|
||||
tft.fillRect(0, 0, 240, 320, TFT_DARKGREY);
|
||||
|
||||
// Draw number display area and frame
|
||||
tft.fillRect(DISP_X, DISP_Y, DISP_W, DISP_H, TFT_BLACK);
|
||||
tft.drawRect(DISP_X, DISP_Y, DISP_W, DISP_H, TFT_WHITE);
|
||||
|
||||
// Draw keypad
|
||||
drawKeypad();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
void loop(void) {
|
||||
uint16_t t_x = 0, t_y = 0; // To store the touch coordinates
|
||||
|
||||
// Pressed will be set true is there is a valid touch on the screen
|
||||
boolean pressed = tft.getTouch(&t_x, &t_y);
|
||||
|
||||
// / Check if any key coordinate boxes contain the touch coordinates
|
||||
for (uint8_t b = 0; b < 15; b++) {
|
||||
if (pressed && key[b].contains(t_x, t_y)) {
|
||||
key[b].press(true); // tell the button it is pressed
|
||||
} else {
|
||||
key[b].press(false); // tell the button it is NOT pressed
|
||||
}
|
||||
}
|
||||
|
||||
// Check if any key has changed state
|
||||
for (uint8_t b = 0; b < 15; b++) {
|
||||
|
||||
if (b < 3) tft.setFreeFont(LABEL1_FONT);
|
||||
else tft.setFreeFont(LABEL2_FONT);
|
||||
|
||||
if (key[b].justReleased()) key[b].drawButton(); // draw normal
|
||||
|
||||
if (key[b].justPressed()) {
|
||||
key[b].drawButton(true); // draw invert
|
||||
|
||||
// if a numberpad button, append the relevant # to the numberBuffer
|
||||
if (b >= 3) {
|
||||
if (numberIndex < NUM_LEN) {
|
||||
numberBuffer[numberIndex] = keyLabel[b][0];
|
||||
numberIndex++;
|
||||
numberBuffer[numberIndex] = 0; // zero terminate
|
||||
}
|
||||
status(""); // Clear the old status
|
||||
}
|
||||
|
||||
// Del button, so delete last char
|
||||
if (b == 1) {
|
||||
numberBuffer[numberIndex] = 0;
|
||||
if (numberIndex > 0) {
|
||||
numberIndex--;
|
||||
numberBuffer[numberIndex] = 0;//' ';
|
||||
}
|
||||
status(""); // Clear the old status
|
||||
}
|
||||
|
||||
if (b == 2) {
|
||||
status("Sent value to serial port");
|
||||
Serial.println(numberBuffer);
|
||||
}
|
||||
// we dont really check that the text field makes sense
|
||||
// just try to call
|
||||
if (b == 0) {
|
||||
status("Value cleared");
|
||||
numberIndex = 0; // Reset index to 0
|
||||
numberBuffer[numberIndex] = 0; // Place null in buffer
|
||||
}
|
||||
|
||||
// Update the number display field
|
||||
tft.setTextDatum(TL_DATUM); // Use top left corner as text coord datum
|
||||
tft.setFreeFont(&FreeSans18pt7b); // Choose a nicefont that fits box
|
||||
tft.setTextColor(DISP_TCOLOR); // Set the font colour
|
||||
|
||||
// Draw the string, the value returned is the width in pixels
|
||||
int xwidth = tft.drawString(numberBuffer, DISP_X + 4, DISP_Y + 12);
|
||||
|
||||
// Now cover up the rest of the line up by drawing a black rectangle. No flicker this way
|
||||
// but it will not work with italic or oblique fonts due to character overlap.
|
||||
tft.fillRect(DISP_X + 4 + xwidth, DISP_Y + 1, DISP_W - xwidth - 5, DISP_H - 2, TFT_BLACK);
|
||||
|
||||
delay(10); // UI debouncing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
void drawKeypad()
|
||||
{
|
||||
// Draw the keys
|
||||
for (uint8_t row = 0; row < 5; row++) {
|
||||
for (uint8_t col = 0; col < 3; col++) {
|
||||
uint8_t b = col + row * 3;
|
||||
|
||||
if (b < 3) tft.setFreeFont(LABEL1_FONT);
|
||||
else tft.setFreeFont(LABEL2_FONT);
|
||||
|
||||
key[b].initButton(&tft, KEY_X + col * (KEY_W + KEY_SPACING_X),
|
||||
KEY_Y + row * (KEY_H + KEY_SPACING_Y), // x, y, w, h, outline, fill, text
|
||||
KEY_W, KEY_H, TFT_WHITE, keyColor[b], TFT_WHITE,
|
||||
keyLabel[b], KEY_TEXTSIZE);
|
||||
key[b].drawButton();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
void touch_calibrate()
|
||||
{
|
||||
uint16_t calData[5];
|
||||
uint8_t calDataOK = 0;
|
||||
|
||||
// check file system exists
|
||||
if (!SPIFFS.begin()) {
|
||||
Serial.println("Formating file system");
|
||||
SPIFFS.format();
|
||||
SPIFFS.begin();
|
||||
}
|
||||
|
||||
// check if calibration file exists and size is correct
|
||||
if (SPIFFS.exists(CALIBRATION_FILE)) {
|
||||
if (REPEAT_CAL)
|
||||
{
|
||||
// Delete if we want to re-calibrate
|
||||
SPIFFS.remove(CALIBRATION_FILE);
|
||||
}
|
||||
else
|
||||
{
|
||||
File f = SPIFFS.open(CALIBRATION_FILE, "r");
|
||||
if (f) {
|
||||
if (f.readBytes((char *)calData, 14) == 14)
|
||||
calDataOK = 1;
|
||||
f.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (calDataOK && !REPEAT_CAL) {
|
||||
// calibration data valid
|
||||
tft.setTouch(calData);
|
||||
} else {
|
||||
// data not valid so recalibrate
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
tft.setCursor(20, 0);
|
||||
tft.setTextFont(2);
|
||||
tft.setTextSize(1);
|
||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
|
||||
tft.println("Touch corners as indicated");
|
||||
|
||||
tft.setTextFont(1);
|
||||
tft.println();
|
||||
|
||||
if (REPEAT_CAL) {
|
||||
tft.setTextColor(TFT_RED, TFT_BLACK);
|
||||
tft.println("Set REPEAT_CAL to false to stop this running again!");
|
||||
}
|
||||
|
||||
tft.calibrateTouch(calData, TFT_MAGENTA, TFT_BLACK, 15);
|
||||
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
||||
tft.println("Calibration complete!");
|
||||
|
||||
// store data
|
||||
File f = SPIFFS.open(CALIBRATION_FILE, "w");
|
||||
if (f) {
|
||||
f.write((const unsigned char *)calData, 14);
|
||||
f.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
// Print something in the mini status bar
|
||||
void status(const char *msg) {
|
||||
tft.setTextPadding(240);
|
||||
//tft.setCursor(STATUS_X, STATUS_Y);
|
||||
tft.setTextColor(TFT_WHITE, TFT_DARKGREY);
|
||||
tft.setTextFont(0);
|
||||
tft.setTextDatum(TC_DATUM);
|
||||
tft.setTextSize(1);
|
||||
tft.drawString(msg, STATUS_X, STATUS_Y);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -23,9 +23,6 @@ TFT_eSPI tft = TFT_eSPI();
|
|||
// JPEG decoder library
|
||||
#include <JPEGDecoder.h>
|
||||
|
||||
// Chip Select Pin for SD card
|
||||
#define SD_CS 53
|
||||
|
||||
// Return the minimum of two values a and b
|
||||
#define minimum(a,b) (((a) < (b)) ? (a) : (b))
|
||||
|
||||
|
|
@ -146,12 +143,31 @@ void renderJPEG(int xpos, int ypos) {
|
|||
int mcu_x = JpegDec.MCUx * mcu_w + xpos; // Calculate coordinates of top left corner of current MCU
|
||||
int mcu_y = JpegDec.MCUy * mcu_h + ypos;
|
||||
|
||||
// check if the image block size needs to be changed for the right and bottom edges
|
||||
// check if the image block size needs to be changed for the right edge
|
||||
if (mcu_x + mcu_w <= max_x) win_w = mcu_w;
|
||||
else win_w = min_w;
|
||||
|
||||
// check if the image block size needs to be changed for the bottom edge
|
||||
if (mcu_y + mcu_h <= max_y) win_h = mcu_h;
|
||||
else win_h = min_h;
|
||||
|
||||
// copy pixels into a contiguous block
|
||||
if (win_w != mcu_w)
|
||||
{
|
||||
uint16_t *cImg;
|
||||
int p = 0;
|
||||
cImg = pImg + win_w;
|
||||
for (int h = 1; h < win_h; h++)
|
||||
{
|
||||
p += mcu_w;
|
||||
for (int w = 0; w < win_w; w++)
|
||||
{
|
||||
*cImg = *(pImg + w + p);
|
||||
cImg++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// calculate how many pixels must be drawn
|
||||
uint32_t mcu_pixels = win_w * win_h;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,268 @@
|
|||
// This sketch if for an ESP32, it draws Jpeg images pulled from an SD Card
|
||||
// onto the TFT.
|
||||
|
||||
// As well as the TFT_eSPI library you will need the JPEG Decoder library.
|
||||
// A copy can be downloaded here, it is based on the library by Makoto Kurauchi.
|
||||
// https://github.com/Bodmer/JPEGDecoder
|
||||
|
||||
// Images on SD Card must be put in the root folder (top level) to be found
|
||||
// Use the SD library examples to verify your SD Card interface works!
|
||||
|
||||
// The example images used to test this sketch can be found in the library
|
||||
// JPEGDecoder/extras folder
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
||||
#include <SPI.h>
|
||||
|
||||
#include <FS.h>
|
||||
#include <SD.h>
|
||||
|
||||
#include <TFT_eSPI.h>
|
||||
TFT_eSPI tft = TFT_eSPI();
|
||||
|
||||
// JPEG decoder library
|
||||
#include <JPEGDecoder.h>
|
||||
|
||||
//####################################################################################################
|
||||
// Setup
|
||||
//####################################################################################################
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
// Set all chip selects high to avoid bus contention during initialisation of each peripheral
|
||||
digitalWrite(22, HIGH); // Touch controller chip select (if used)
|
||||
digitalWrite(15, HIGH); // TFT screen chip select
|
||||
digitalWrite( 5, HIGH); // SD card chips select, must use GPIO 5 (ESP32 SS)
|
||||
|
||||
tft.begin();
|
||||
|
||||
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);
|
||||
|
||||
Serial.println("initialisation done.");
|
||||
}
|
||||
|
||||
//####################################################################################################
|
||||
// Main loop
|
||||
//####################################################################################################
|
||||
void loop() {
|
||||
|
||||
tft.setRotation(2); // portrait
|
||||
tft.fillScreen(random(0xFFFF));
|
||||
|
||||
// The image is 300 x 300 pixels so we do some sums to position image in the middle of the screen!
|
||||
// Doing this by reading the image width and height from the jpeg info is left as an exercise!
|
||||
int x = (tft.width() - 300) / 2 - 1;
|
||||
int y = (tft.height() - 300) / 2 - 1;
|
||||
|
||||
drawSdJpeg("/EagleEye.jpg", x, y); // This draws a jpeg pulled off the SD Card
|
||||
delay(2000);
|
||||
|
||||
tft.setRotation(2); // portrait
|
||||
tft.fillScreen(random(0xFFFF));
|
||||
drawSdJpeg("/Baboon40.jpg", 0, 0); // This draws a jpeg pulled off the SD Card
|
||||
delay(2000);
|
||||
|
||||
tft.setRotation(2); // portrait
|
||||
tft.fillScreen(random(0xFFFF));
|
||||
drawSdJpeg("/lena20k.jpg", 0, 0); // This draws a jpeg pulled off the SD Card
|
||||
delay(2000);
|
||||
|
||||
tft.setRotation(1); // landscape
|
||||
tft.fillScreen(random(0xFFFF));
|
||||
drawSdJpeg("/Mouse480.jpg", 0, 0); // This draws a jpeg pulled off the SD Card
|
||||
|
||||
delay(2000);
|
||||
|
||||
while(1); // Wait here
|
||||
}
|
||||
|
||||
//####################################################################################################
|
||||
// Draw a JPEG on the TFT pulled from SD Card
|
||||
//####################################################################################################
|
||||
// xpos, ypos is top left corner of plotted image
|
||||
void drawSdJpeg(const char *filename, int xpos, int ypos) {
|
||||
|
||||
// Open the named file (the Jpeg decoder library will close it)
|
||||
File jpegFile = SD.open( filename, FILE_READ); // or, file handle reference for SD library
|
||||
|
||||
if ( !jpegFile ) {
|
||||
Serial.print("ERROR: File \""); Serial.print(filename); Serial.println ("\" not found!");
|
||||
return;
|
||||
}
|
||||
|
||||
Serial.println("===========================");
|
||||
Serial.print("Drawing file: "); Serial.println(filename);
|
||||
Serial.println("===========================");
|
||||
|
||||
// Use one of the following methods to initialise the decoder:
|
||||
boolean decoded = JpegDec.decodeSdFile(jpegFile); // Pass the SD file handle to the decoder,
|
||||
//boolean decoded = JpegDec.decodeSdFile(filename); // or pass the filename (String or character array)
|
||||
|
||||
if (decoded) {
|
||||
// print information about the image to the serial port
|
||||
jpegInfo();
|
||||
// render the image onto the screen at given coordinates
|
||||
jpegRender(xpos, ypos);
|
||||
}
|
||||
else {
|
||||
Serial.println("Jpeg file format not supported!");
|
||||
}
|
||||
}
|
||||
|
||||
//####################################################################################################
|
||||
// Draw a JPEG on the TFT, images will be cropped on the right/bottom sides if they do not fit
|
||||
//####################################################################################################
|
||||
// This function assumes xpos,ypos is a valid screen coordinate. For convenience images that do not
|
||||
// fit totally on the screen are cropped to the nearest MCU size and may leave right/bottom borders.
|
||||
void jpegRender(int xpos, int ypos) {
|
||||
|
||||
//jpegInfo(); // Print information from the JPEG file (could comment this line out)
|
||||
|
||||
uint16_t *pImg;
|
||||
uint16_t mcu_w = JpegDec.MCUWidth;
|
||||
uint16_t mcu_h = JpegDec.MCUHeight;
|
||||
uint32_t max_x = JpegDec.width;
|
||||
uint32_t max_y = JpegDec.height;
|
||||
|
||||
bool swapBytes = tft.getSwapBytes();
|
||||
tft.setSwapBytes(true);
|
||||
|
||||
// Jpeg images are draw as a set of image block (tiles) called Minimum Coding Units (MCUs)
|
||||
// Typically these MCUs are 16x16 pixel blocks
|
||||
// Determine the width and height of the right and bottom edge image blocks
|
||||
uint32_t min_w = min(mcu_w, max_x % mcu_w);
|
||||
uint32_t min_h = min(mcu_h, max_y % mcu_h);
|
||||
|
||||
// save the current image block size
|
||||
uint32_t win_w = mcu_w;
|
||||
uint32_t win_h = mcu_h;
|
||||
|
||||
// record the current time so we can measure how long it takes to draw an image
|
||||
uint32_t drawTime = millis();
|
||||
|
||||
// save the coordinate of the right and bottom edges to assist image cropping
|
||||
// to the screen size
|
||||
max_x += xpos;
|
||||
max_y += ypos;
|
||||
|
||||
// Fetch data from the file, decode and display
|
||||
while (JpegDec.read()) { // While there is more data in the file
|
||||
pImg = JpegDec.pImage ; // Decode a MCU (Minimum Coding Unit, typically a 8x8 or 16x16 pixel block)
|
||||
|
||||
// Calculate coordinates of top left corner of current MCU
|
||||
int mcu_x = JpegDec.MCUx * mcu_w + xpos;
|
||||
int mcu_y = JpegDec.MCUy * mcu_h + ypos;
|
||||
|
||||
// check if the image block size needs to be changed for the right edge
|
||||
if (mcu_x + mcu_w <= max_x) win_w = mcu_w;
|
||||
else win_w = min_w;
|
||||
|
||||
// check if the image block size needs to be changed for the bottom edge
|
||||
if (mcu_y + mcu_h <= max_y) win_h = mcu_h;
|
||||
else win_h = min_h;
|
||||
|
||||
// copy pixels into a contiguous block
|
||||
if (win_w != mcu_w)
|
||||
{
|
||||
uint16_t *cImg;
|
||||
int p = 0;
|
||||
cImg = pImg + win_w;
|
||||
for (int h = 1; h < win_h; h++)
|
||||
{
|
||||
p += mcu_w;
|
||||
for (int w = 0; w < win_w; w++)
|
||||
{
|
||||
*cImg = *(pImg + w + p);
|
||||
cImg++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// calculate how many pixels must be drawn
|
||||
uint32_t mcu_pixels = win_w * win_h;
|
||||
|
||||
// draw image MCU block only if it will fit on the screen
|
||||
if (( mcu_x + win_w ) <= tft.width() && ( mcu_y + win_h ) <= tft.height())
|
||||
tft.pushImage(mcu_x, mcu_y, win_w, win_h, pImg);
|
||||
else if ( (mcu_y + win_h) >= tft.height())
|
||||
JpegDec.abort(); // Image has run off bottom of screen so abort decoding
|
||||
}
|
||||
|
||||
tft.setSwapBytes(swapBytes);
|
||||
|
||||
showTime(millis() - drawTime); // These lines are for sketch testing only
|
||||
}
|
||||
|
||||
//####################################################################################################
|
||||
// Print image information to the serial port (optional)
|
||||
//####################################################################################################
|
||||
// JpegDec.decodeFile(...) or JpegDec.decodeArray(...) must be called before this info is available!
|
||||
void jpegInfo() {
|
||||
|
||||
// Print information extracted from the JPEG file
|
||||
Serial.println("JPEG image info");
|
||||
Serial.println("===============");
|
||||
Serial.print("Width :");
|
||||
Serial.println(JpegDec.width);
|
||||
Serial.print("Height :");
|
||||
Serial.println(JpegDec.height);
|
||||
Serial.print("Components :");
|
||||
Serial.println(JpegDec.comps);
|
||||
Serial.print("MCU / row :");
|
||||
Serial.println(JpegDec.MCUSPerRow);
|
||||
Serial.print("MCU / col :");
|
||||
Serial.println(JpegDec.MCUSPerCol);
|
||||
Serial.print("Scan type :");
|
||||
Serial.println(JpegDec.scanType);
|
||||
Serial.print("MCU width :");
|
||||
Serial.println(JpegDec.MCUWidth);
|
||||
Serial.print("MCU height :");
|
||||
Serial.println(JpegDec.MCUHeight);
|
||||
Serial.println("===============");
|
||||
Serial.println("");
|
||||
}
|
||||
|
||||
//####################################################################################################
|
||||
// Show the execution time (optional)
|
||||
//####################################################################################################
|
||||
// WARNING: for UNO/AVR legacy reasons printing text to the screen with the Mega might not work for
|
||||
// sketch sizes greater than ~70KBytes because 16 bit address pointers are used in some libraries.
|
||||
|
||||
// The Due will work fine with the HX8357_Due library.
|
||||
|
||||
void showTime(uint32_t msTime) {
|
||||
//tft.setCursor(0, 0);
|
||||
//tft.setTextFont(1);
|
||||
//tft.setTextSize(2);
|
||||
//tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
//tft.print(F(" JPEG drawn in "));
|
||||
//tft.print(msTime);
|
||||
//tft.println(F(" ms "));
|
||||
Serial.print(F(" JPEG drawn in "));
|
||||
Serial.print(msTime);
|
||||
Serial.println(F(" ms "));
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,206 @@
|
|||
// Example of drawing a graphical "switch" and using
|
||||
// the touch screen to change it's state.
|
||||
|
||||
// This sketch does not use the libraries button drawing
|
||||
// and handling functions.
|
||||
|
||||
// Based on Adafruit_GFX library onoffbutton example.
|
||||
|
||||
// Touch handling for XPT2046 based screens is handled by
|
||||
// the TFT_eSPI library.
|
||||
|
||||
// Calibration data is stored in SPIFFS so we need to include it
|
||||
#include "FS.h"
|
||||
|
||||
#include <SPI.h>
|
||||
|
||||
#include <TFT_eSPI.h> // Hardware-specific library
|
||||
|
||||
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
|
||||
|
||||
// This is the file name used to store the touch coordinate
|
||||
// calibration data. Cahnge the name to start a new calibration.
|
||||
#define CALIBRATION_FILE "/TouchCalData3"
|
||||
|
||||
// Set REPEAT_CAL to true instead of false to run calibration
|
||||
// again, otherwise it will only be done once.
|
||||
// Repeat calibration if you change the screen rotation.
|
||||
#define REPEAT_CAL false
|
||||
|
||||
boolean SwitchOn = false;
|
||||
|
||||
// Comment out to stop drawing black spots
|
||||
#define BLACK_SPOT
|
||||
|
||||
// Switch position and size
|
||||
#define FRAME_X 100
|
||||
#define FRAME_Y 64
|
||||
#define FRAME_W 120
|
||||
#define FRAME_H 50
|
||||
|
||||
// Red zone size
|
||||
#define REDBUTTON_X FRAME_X
|
||||
#define REDBUTTON_Y FRAME_Y
|
||||
#define REDBUTTON_W (FRAME_W/2)
|
||||
#define REDBUTTON_H FRAME_H
|
||||
|
||||
// Green zone size
|
||||
#define GREENBUTTON_X (REDBUTTON_X + REDBUTTON_W)
|
||||
#define GREENBUTTON_Y FRAME_Y
|
||||
#define GREENBUTTON_W (FRAME_W/2)
|
||||
#define GREENBUTTON_H FRAME_H
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------------------
|
||||
void setup(void)
|
||||
{
|
||||
Serial.begin(9600);
|
||||
tft.init();
|
||||
|
||||
// Set the rotation before we calibrate
|
||||
tft.setRotation(1);
|
||||
|
||||
// call screen calibration
|
||||
touch_calibrate();
|
||||
|
||||
// clear screen
|
||||
tft.fillScreen(TFT_BLUE);
|
||||
|
||||
// Draw button (this example does not use library Button class)
|
||||
redBtn();
|
||||
}
|
||||
//------------------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------------------
|
||||
void loop()
|
||||
{
|
||||
uint16_t x, y;
|
||||
|
||||
// See if there's any touch data for us
|
||||
if (tft.getTouch(&x, &y))
|
||||
{
|
||||
// Draw a block spot to show where touch was calculated to be
|
||||
#ifdef BLACK_SPOT
|
||||
tft.fillCircle(x, y, 2, TFT_BLACK);
|
||||
#endif
|
||||
|
||||
if (SwitchOn)
|
||||
{
|
||||
if ((x > REDBUTTON_X) && (x < (REDBUTTON_X + REDBUTTON_W))) {
|
||||
if ((y > REDBUTTON_Y) && (y <= (REDBUTTON_Y + REDBUTTON_H))) {
|
||||
Serial.println("Red btn hit");
|
||||
redBtn();
|
||||
}
|
||||
}
|
||||
}
|
||||
else //Record is off (SwitchOn == false)
|
||||
{
|
||||
if ((x > GREENBUTTON_X) && (x < (GREENBUTTON_X + GREENBUTTON_W))) {
|
||||
if ((y > GREENBUTTON_Y) && (y <= (GREENBUTTON_Y + GREENBUTTON_H))) {
|
||||
Serial.println("Green btn hit");
|
||||
greenBtn();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Serial.println(SwitchOn);
|
||||
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
void touch_calibrate()
|
||||
{
|
||||
uint16_t calData[5];
|
||||
uint8_t calDataOK = 0;
|
||||
|
||||
// check file system exists
|
||||
if (!SPIFFS.begin()) {
|
||||
Serial.println("Formating file system");
|
||||
SPIFFS.format();
|
||||
SPIFFS.begin();
|
||||
}
|
||||
|
||||
// check if calibration file exists and size is correct
|
||||
if (SPIFFS.exists(CALIBRATION_FILE)) {
|
||||
if (REPEAT_CAL)
|
||||
{
|
||||
// Delete if we want to re-calibrate
|
||||
SPIFFS.remove(CALIBRATION_FILE);
|
||||
}
|
||||
else
|
||||
{
|
||||
File f = SPIFFS.open(CALIBRATION_FILE, "r");
|
||||
if (f) {
|
||||
if (f.readBytes((char *)calData, 14) == 14)
|
||||
calDataOK = 1;
|
||||
f.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (calDataOK && !REPEAT_CAL) {
|
||||
// calibration data valid
|
||||
tft.setTouch(calData);
|
||||
} else {
|
||||
// data not valid so recalibrate
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
tft.setCursor(20, 0);
|
||||
tft.setTextFont(2);
|
||||
tft.setTextSize(1);
|
||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
|
||||
tft.println("Touch corners as indicated");
|
||||
|
||||
tft.setTextFont(1);
|
||||
tft.println();
|
||||
|
||||
if (REPEAT_CAL) {
|
||||
tft.setTextColor(TFT_RED, TFT_BLACK);
|
||||
tft.println("Set REPEAT_CAL to false to stop this running again!");
|
||||
}
|
||||
|
||||
tft.calibrateTouch(calData, TFT_MAGENTA, TFT_BLACK, 15);
|
||||
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
||||
tft.println("Calibration complete!");
|
||||
|
||||
// store data
|
||||
File f = SPIFFS.open(CALIBRATION_FILE, "w");
|
||||
if (f) {
|
||||
f.write((const unsigned char *)calData, 14);
|
||||
f.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void drawFrame()
|
||||
{
|
||||
tft.drawRect(FRAME_X, FRAME_Y, FRAME_W, FRAME_H, TFT_BLACK);
|
||||
}
|
||||
|
||||
// Draw a red button
|
||||
void redBtn()
|
||||
{
|
||||
tft.fillRect(REDBUTTON_X, REDBUTTON_Y, REDBUTTON_W, REDBUTTON_H, TFT_RED);
|
||||
tft.fillRect(GREENBUTTON_X, GREENBUTTON_Y, GREENBUTTON_W, GREENBUTTON_H, TFT_DARKGREY);
|
||||
drawFrame();
|
||||
tft.setTextColor(TFT_WHITE);
|
||||
tft.setTextSize(2);
|
||||
tft.setTextDatum(MC_DATUM);
|
||||
tft.drawString("ON", GREENBUTTON_X + (GREENBUTTON_W / 2), GREENBUTTON_Y + (GREENBUTTON_H / 2));
|
||||
SwitchOn = false;
|
||||
}
|
||||
|
||||
// Draw a green button
|
||||
void greenBtn()
|
||||
{
|
||||
tft.fillRect(GREENBUTTON_X, GREENBUTTON_Y, GREENBUTTON_W, GREENBUTTON_H, TFT_GREEN);
|
||||
tft.fillRect(REDBUTTON_X, REDBUTTON_Y, REDBUTTON_W, REDBUTTON_H, TFT_DARKGREY);
|
||||
drawFrame();
|
||||
tft.setTextColor(TFT_WHITE);
|
||||
tft.setTextSize(2);
|
||||
tft.setTextDatum(MC_DATUM);
|
||||
tft.drawString("OFF", REDBUTTON_X + (REDBUTTON_W / 2) + 1, REDBUTTON_Y + (REDBUTTON_H / 2));
|
||||
SwitchOn = true;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
// Bodmers BMP image rendering function
|
||||
|
||||
void drawBmp(const char *filename, int16_t x, int16_t y) {
|
||||
|
||||
if ((x >= tft.width()) || (y >= tft.height())) return;
|
||||
|
||||
fs::File bmpFS;
|
||||
|
||||
// Open requested file on SD card
|
||||
bmpFS = SPIFFS.open(filename, "r");
|
||||
|
||||
if (!bmpFS)
|
||||
{
|
||||
Serial.print("File not found");
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t seekOffset;
|
||||
uint16_t w, h, row, col;
|
||||
uint8_t r, g, b;
|
||||
|
||||
uint32_t startTime = millis();
|
||||
|
||||
if (read16(bmpFS) == 0x4D42)
|
||||
{
|
||||
read32(bmpFS);
|
||||
read32(bmpFS);
|
||||
seekOffset = read32(bmpFS);
|
||||
read32(bmpFS);
|
||||
w = read32(bmpFS);
|
||||
h = read32(bmpFS);
|
||||
|
||||
if ((read16(bmpFS) == 1) && (read16(bmpFS) == 24) && (read32(bmpFS) == 0))
|
||||
{
|
||||
y += h - 1;
|
||||
|
||||
tft.setSwapBytes(true);
|
||||
bmpFS.seek(seekOffset);
|
||||
|
||||
uint16_t padding = (4 - ((w * 3) & 3)) & 3;
|
||||
uint8_t lineBuffer[w * 3 + padding];
|
||||
|
||||
for (row = 0; row < h; row++) {
|
||||
|
||||
bmpFS.read(lineBuffer, sizeof(lineBuffer));
|
||||
uint8_t* bptr = lineBuffer;
|
||||
uint16_t* tptr = (uint16_t*)lineBuffer;
|
||||
// Convert 24 to 16 bit colours
|
||||
for (uint16_t col = 0; col < w; col++)
|
||||
{
|
||||
b = *bptr++;
|
||||
g = *bptr++;
|
||||
r = *bptr++;
|
||||
*tptr++ = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3);
|
||||
}
|
||||
|
||||
// Push the pixel row to screen, pushImage will crop the line if needed
|
||||
// y is decremented as the BMP image is drawn bottom up
|
||||
tft.pushImage(x, y--, w, 1, (uint16_t*)lineBuffer);
|
||||
}
|
||||
Serial.print("Loaded in "); Serial.print(millis() - startTime);
|
||||
Serial.println(" ms");
|
||||
}
|
||||
else Serial.println("BMP format not recognized.");
|
||||
}
|
||||
bmpFS.close();
|
||||
}
|
||||
|
||||
// These read 16- and 32-bit types from the SD card file.
|
||||
// BMP data is stored little-endian, Arduino is little-endian too.
|
||||
// May need to reverse subscript order if porting elsewhere.
|
||||
|
||||
uint16_t read16(fs::File &f) {
|
||||
uint16_t result;
|
||||
((uint8_t *)&result)[0] = f.read(); // LSB
|
||||
((uint8_t *)&result)[1] = f.read(); // MSB
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32_t read32(fs::File &f) {
|
||||
uint32_t result;
|
||||
((uint8_t *)&result)[0] = f.read(); // LSB
|
||||
((uint8_t *)&result)[1] = f.read();
|
||||
((uint8_t *)&result)[2] = f.read();
|
||||
((uint8_t *)&result)[3] = f.read(); // MSB
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
// This sketch draws BMP images pulled from SPIFFS onto the TFT. It is an
|
||||
// an example from this library: https://github.com/Bodmer/TFT_eSPI
|
||||
|
||||
// Images in SPIFFS must be put in the root folder (top level) to be found
|
||||
// Use the SPIFFS library example to verify SPIFFS works!
|
||||
|
||||
// The example image used to test this sketch can be found in the sketch
|
||||
// Data folder, press Ctrl+K to see this folder. Use the IDE "Tools" menu
|
||||
// option to upload the sketches data folder to the SPIFFS
|
||||
|
||||
// This sketch has been tested on the ESP32 and ESP8266
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
||||
//====================================================================================
|
||||
// Libraries
|
||||
//====================================================================================
|
||||
// Call up the SPIFFS FLASH filing system this is part of the ESP Core
|
||||
#define FS_NO_GLOBALS
|
||||
#include <FS.h>
|
||||
|
||||
#ifdef ESP32
|
||||
#include "SPIFFS.h" // For ESP32 only
|
||||
#endif
|
||||
|
||||
// Call up the TFT library
|
||||
#include <TFT_eSPI.h> // Hardware-specific library for ESP8266
|
||||
|
||||
// Invoke TFT library
|
||||
TFT_eSPI tft = TFT_eSPI();
|
||||
|
||||
//====================================================================================
|
||||
// Setup
|
||||
//====================================================================================
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
if (!SPIFFS.begin()) {
|
||||
Serial.println("SPIFFS initialisation failed!");
|
||||
while (1) yield(); // Stay here twiddling thumbs waiting
|
||||
}
|
||||
Serial.println("\r\nSPIFFS initialised.");
|
||||
|
||||
// Now initialise the TFT
|
||||
tft.begin();
|
||||
tft.setRotation(0); // 0 & 2 Portrait. 1 & 3 landscape
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
}
|
||||
|
||||
//====================================================================================
|
||||
// Loop
|
||||
//====================================================================================
|
||||
void loop()
|
||||
{
|
||||
int x = random(tft.width() - 128);
|
||||
int y = random(tft.height() - 160);
|
||||
|
||||
drawBmp("/parrot.bmp", x, y);
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
//====================================================================================
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 60 KiB |
|
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
Sketch to generate the setup() calibration values, these are reported
|
||||
to the Serial Monitor.
|
||||
|
||||
The sketch has been tested on the ESP8266 and screen with XPT2046 driver.
|
||||
*/
|
||||
|
||||
#include <SPI.h>
|
||||
#include <TFT_eSPI.h> // Hardware-specific library
|
||||
|
||||
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
void setup() {
|
||||
// Use serial port
|
||||
Serial.begin(115200);
|
||||
|
||||
// Initialise the TFT screen
|
||||
tft.init();
|
||||
|
||||
// Set the rotation before we calibrate
|
||||
tft.setRotation(1);
|
||||
|
||||
// Calibrate the touch screen and retrieve the scaling factors
|
||||
touch_calibrate();
|
||||
|
||||
/*
|
||||
// Replace above line with the code sent to Serial Monitor
|
||||
// once calibration is complete, e.g.:
|
||||
uint16_t calData[5] = { 286, 3534, 283, 3600, 6 };
|
||||
tft.setTouch(calData);
|
||||
*/
|
||||
|
||||
// Clear the screen
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
tft.drawCentreString("Touch screen to test!",tft.width()/2, tft.height()/2, 2);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
void loop(void) {
|
||||
uint16_t x = 0, y = 0; // To store the touch coordinates
|
||||
|
||||
// Pressed will be set true is there is a valid touch on the screen
|
||||
boolean pressed = tft.getTouch(&x, &y);
|
||||
|
||||
// Draw a white spot at the detected coordinates
|
||||
if (pressed) {
|
||||
tft.fillCircle(x, y, 2, TFT_WHITE);
|
||||
//Serial.print("x,y = ");
|
||||
//Serial.print(x);
|
||||
//Serial.print(",");
|
||||
//Serial.println(y);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
// Code to run a screen calibration, not needed when calibration values set in setup()
|
||||
void touch_calibrate()
|
||||
{
|
||||
uint16_t calData[5];
|
||||
uint8_t calDataOK = 0;
|
||||
|
||||
// Calibrate
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
tft.setCursor(20, 0);
|
||||
tft.setTextFont(2);
|
||||
tft.setTextSize(1);
|
||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
|
||||
tft.println("Touch corners as indicated");
|
||||
|
||||
tft.setTextFont(1);
|
||||
tft.println();
|
||||
|
||||
tft.calibrateTouch(calData, TFT_MAGENTA, TFT_BLACK, 15);
|
||||
|
||||
Serial.println(); Serial.println();
|
||||
Serial.println("// Use this calibration code in setup():");
|
||||
Serial.print(" uint16_t calData[5] = ");
|
||||
Serial.print("{ ");
|
||||
|
||||
for (uint8_t i = 0; i < 5; i++)
|
||||
{
|
||||
Serial.print(calData[i]);
|
||||
if (i < 4) Serial.print(", ");
|
||||
}
|
||||
|
||||
Serial.println(" };");
|
||||
Serial.print(" tft.setTouch(calData);");
|
||||
Serial.println(); Serial.println();
|
||||
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
||||
tft.println("Calibration complete!");
|
||||
tft.println("Calibration code sent to Serial port.");
|
||||
|
||||
delay(4000);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
// Example sketch to demonstrate the drawing of X BitMap (XBM)
|
||||
// format image onto the display.
|
||||
|
||||
// Information on the X BitMap (XBM) format can be found here:
|
||||
// https://en.wikipedia.org/wiki/X_BitMap
|
||||
|
||||
// This example is part of the TFT_eSPI library:
|
||||
// https://github.com/Bodmer/TFT_eSPI
|
||||
|
||||
// Created by Bodmer 23/04/18
|
||||
|
||||
#include "xbm.h" // Sketch tab header for xbm images
|
||||
|
||||
#include <TFT_eSPI.h> // Hardware-specific library
|
||||
|
||||
TFT_eSPI tft = TFT_eSPI(); // Invoke library
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
tft.begin(); // Initialise the display
|
||||
tft.fillScreen(TFT_BLACK); // Black screen fill
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
// Example 1
|
||||
// =========
|
||||
// Random x and y coordinates
|
||||
int x = random(tft.width() - logoWidth);
|
||||
int y = random(tft.height() - logoHeight);
|
||||
|
||||
// Draw bitmap with top left corner at x,y with foreground only color
|
||||
// Bits set to 1 plot as the defined color, bits set to 0 are not plotted
|
||||
// x y xbm xbm width xbm height color
|
||||
tft.drawXBitmap(x, y, logo, logoWidth, logoHeight, TFT_WHITE);
|
||||
|
||||
delay(500);
|
||||
|
||||
// Erase old one by drawing over with background colour
|
||||
tft.drawXBitmap(x, y, logo, logoWidth, logoHeight, TFT_BLACK);
|
||||
|
||||
|
||||
// Example 2
|
||||
// =========
|
||||
// New random x and y coordinates
|
||||
x = random(tft.width() - logoWidth);
|
||||
y = random(tft.height() - logoHeight);
|
||||
|
||||
// Draw bitmap with top left corner at x,y with foreground and background colors
|
||||
// Bits set to 1 plot as the defined fg color, bits set to 0 are plotted as bg color
|
||||
// x y xbm xbm width xbm height fg color bg color
|
||||
tft.drawXBitmap(x, y, logo, logoWidth, logoHeight, TFT_WHITE, TFT_RED);
|
||||
|
||||
delay(500);
|
||||
|
||||
// Erase old one by drawing over with background colour
|
||||
tft.drawXBitmap(x, y, logo, logoWidth, logoHeight, TFT_BLACK, TFT_BLACK);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
// Images can be converted to XBM format by using the online converter here:
|
||||
// https://www.online-utility.org/image/convert/to/XBM
|
||||
|
||||
// The output must be pasted in a header file, renamed and adjusted to appear
|
||||
// as as a const unsigned char array in PROGMEM (FLASH program memory).
|
||||
|
||||
// The xbm format adds padding to pixel rows so they are a whole number of bytes
|
||||
// In this example 50 pixel width means 56 bits = 7 bytes
|
||||
// the 50 height then means array uses 50 x 7 = 350 bytes of FLASH
|
||||
// The library ignores the padding bits when drawing the image on the display.
|
||||
|
||||
// Example of the correct format is shown below
|
||||
|
||||
#include <pgmspace.h> // PROGMEM support header
|
||||
|
||||
// Espressif logo 50 x 50 pixel array in XBM format
|
||||
#define logoWidth 50 // logo width
|
||||
#define logoHeight 50 // logo height
|
||||
|
||||
// Image is stored in this array
|
||||
PROGMEM const unsigned char logo[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x01, 0x00,
|
||||
0x00, 0x00, 0x00, 0x07, 0xFC, 0x07, 0x00, 0x00, 0x00, 0x82, 0x7F, 0xF0,
|
||||
0x1F, 0x00, 0x00, 0x00, 0xC6, 0xFF, 0xC3, 0x3F, 0x00, 0x00, 0x00, 0xE7,
|
||||
0xFF, 0x8F, 0x7F, 0x00, 0x00, 0x80, 0xE3, 0xFF, 0x1F, 0xFE, 0x00, 0x00,
|
||||
0x80, 0xE1, 0xFF, 0x7F, 0xFC, 0x01, 0x00, 0xC0, 0x00, 0xFF, 0xFF, 0xF8,
|
||||
0x03, 0x00, 0xE0, 0x00, 0xE0, 0xFF, 0xF1, 0x03, 0x00, 0x60, 0xF0, 0x81,
|
||||
0xFF, 0xE3, 0x07, 0x00, 0x60, 0xFC, 0x1F, 0xFE, 0xC7, 0x07, 0x00, 0x30,
|
||||
0xFE, 0x7F, 0xF8, 0x8F, 0x0F, 0x00, 0x30, 0xFF, 0xFF, 0xF1, 0x9F, 0x0F,
|
||||
0x00, 0xB0, 0xFF, 0xFF, 0xE3, 0x3F, 0x0F, 0x00, 0xB0, 0xFF, 0xFF, 0xC7,
|
||||
0x3F, 0x1E, 0x00, 0xB8, 0xFF, 0xFF, 0x8F, 0x7F, 0x1E, 0x00, 0x98, 0x1F,
|
||||
0xFC, 0x3F, 0xFF, 0x1C, 0x00, 0xB8, 0x3F, 0xE0, 0x3F, 0xFE, 0x1C, 0x00,
|
||||
0x98, 0xFF, 0xC3, 0x7F, 0xFE, 0x19, 0x00, 0x98, 0xFF, 0x0F, 0xFF, 0xFC,
|
||||
0x19, 0x00, 0x38, 0xFF, 0x3F, 0xFF, 0xFC, 0x01, 0x00, 0x30, 0xFE, 0x7F,
|
||||
0xFE, 0xF9, 0x03, 0x00, 0x30, 0xFC, 0xFF, 0xFC, 0xF9, 0x03, 0x00, 0x30,
|
||||
0xF8, 0xFF, 0xF8, 0xF3, 0x03, 0x00, 0x30, 0x00, 0xFF, 0xF9, 0xF3, 0x03,
|
||||
0x00, 0x70, 0x00, 0xFC, 0xF9, 0xF3, 0x07, 0x00, 0x60, 0x00, 0xF8, 0xF3,
|
||||
0xF3, 0x07, 0x00, 0xE0, 0xF8, 0xF8, 0xF3, 0xF7, 0x03, 0x00, 0xC0, 0xF8,
|
||||
0xF1, 0xF3, 0xE3, 0x03, 0x00, 0xC0, 0xFD, 0xF1, 0xF3, 0xF7, 0x01, 0x00,
|
||||
0x80, 0xFD, 0xF1, 0xF3, 0xE7, 0x00, 0x00, 0x00, 0xFF, 0xF1, 0xF3, 0x07,
|
||||
0x00, 0x00, 0x00, 0xFF, 0xF8, 0xF3, 0x07, 0x00, 0x00, 0x00, 0x7E, 0xF8,
|
||||
0xF3, 0x83, 0x03, 0x00, 0x00, 0x3C, 0xF8, 0xF3, 0xC3, 0x01, 0x00, 0x00,
|
||||
0x70, 0xF8, 0xF9, 0xE3, 0x00, 0x00, 0x00, 0xE0, 0xE1, 0x41, 0x78, 0x00,
|
||||
0x00, 0x00, 0xC0, 0x0F, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFD,
|
||||
0x07, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||
0x80, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, };
|
||||
|
||||
|
|
@ -0,0 +1,195 @@
|
|||
/*
|
||||
Sketch to demonstrate using the print class with smooth fonts
|
||||
|
||||
Sketch is writtent for a 240 x 320 display
|
||||
|
||||
Load the font file into SPIFFS first by using the Arduino IDE
|
||||
Sketch Data Upload menu option. Font files must be stored in the
|
||||
sketch data folder (Ctrl+k to view).
|
||||
https://github.com/esp8266/arduino-esp8266fs-plugin
|
||||
https://github.com/me-no-dev/arduino-esp32fs-plugin
|
||||
|
||||
New font files in the .vlw format can be created using the Processing
|
||||
sketch in the library Tools folder. The Processing sketch can convert
|
||||
TrueType fonts in *.ttf or *.otf files.
|
||||
|
||||
Note: SPIFFS does not accept an underscore _ in filenames!
|
||||
|
||||
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 in SPIFFS
|
||||
#define FS_NO_GLOBALS
|
||||
#include <FS.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
|
||||
|
||||
tft.init();
|
||||
tft.setRotation(1);
|
||||
|
||||
if (!SPIFFS.begin()) {
|
||||
Serial.println("SPIFFS initialisation failed!");
|
||||
while (1) yield(); // Stay here twiddling thumbs waiting
|
||||
}
|
||||
Serial.println("\r\nInitialisation done.");
|
||||
|
||||
listFiles(); // Lists the files so you can see what is in the SPIFFS
|
||||
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// 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);
|
||||
|
||||
// Display all characters of the font
|
||||
tft.showFont(2000);
|
||||
|
||||
// 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
|
||||
|
||||
// Unload the font to recover used RAM
|
||||
tft.unloadFont();
|
||||
|
||||
delay(10000);
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// List files in ESP8266 or ESP32 SPIFFS memory
|
||||
// -------------------------------------------------------------------------
|
||||
void listFiles(void) {
|
||||
Serial.println();
|
||||
Serial.println("SPIFFS files found:");
|
||||
|
||||
#ifdef ESP32
|
||||
listDir(SPIFFS, "/", true);
|
||||
#else
|
||||
fs::Dir dir = SPIFFS.openDir("/"); // Root directory
|
||||
String line = "=====================================";
|
||||
|
||||
Serial.println(line);
|
||||
Serial.println(" File name Size");
|
||||
Serial.println(line);
|
||||
|
||||
while (dir.next()) {
|
||||
String fileName = dir.fileName();
|
||||
Serial.print(fileName);
|
||||
int spaces = 25 - fileName.length(); // Tabulate nicely
|
||||
if (spaces < 0) spaces = 1;
|
||||
while (spaces--) Serial.print(" ");
|
||||
fs::File f = dir.openFile("r");
|
||||
Serial.print(f.size()); Serial.println(" bytes");
|
||||
yield();
|
||||
}
|
||||
|
||||
Serial.println(line);
|
||||
#endif
|
||||
Serial.println();
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
#ifdef ESP32
|
||||
void listDir(fs::FS &fs, const char * dirname, uint8_t levels) {
|
||||
Serial.printf("Listing directory: %s\n", dirname);
|
||||
|
||||
fs::File root = fs.open(dirname);
|
||||
if (!root) {
|
||||
Serial.println("Failed to open directory");
|
||||
return;
|
||||
}
|
||||
if (!root.isDirectory()) {
|
||||
Serial.println("Not a directory");
|
||||
return;
|
||||
}
|
||||
|
||||
fs::File file = root.openNextFile();
|
||||
while (file) {
|
||||
|
||||
if (file.isDirectory()) {
|
||||
Serial.print("DIR : ");
|
||||
String fileName = file.name();
|
||||
Serial.print(fileName);
|
||||
if (levels) {
|
||||
listDir(fs, file.name(), levels - 1);
|
||||
}
|
||||
} else {
|
||||
String fileName = file.name();
|
||||
Serial.print(" " + fileName);
|
||||
int spaces = 32 - fileName.length(); // Tabulate nicely
|
||||
if (spaces < 1) spaces = 1;
|
||||
while (spaces--) Serial.print(" ");
|
||||
String fileSize = (String) file.size();
|
||||
spaces = 8 - fileSize.length(); // Tabulate nicely
|
||||
if (spaces < 1) spaces = 1;
|
||||
while (spaces--) Serial.print(" ");
|
||||
Serial.println(fileSize + " bytes");
|
||||
}
|
||||
|
||||
file = root.openNextFile();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// -------------------------------------------------------------------------
|
||||
Binary file not shown.
|
|
@ -0,0 +1,83 @@
|
|||
/*====================================================================================
|
||||
This sketch supports for the ESP6266 and ESP32 SPIFFS filing system
|
||||
|
||||
Created by Bodmer 15th Jan 2017
|
||||
==================================================================================*/
|
||||
|
||||
//====================================================================================
|
||||
// Print a SPIFFS directory list (root directory)
|
||||
//====================================================================================
|
||||
|
||||
void listFiles(void) {
|
||||
Serial.println();
|
||||
Serial.println("SPIFFS files found:");
|
||||
|
||||
#ifdef ESP32
|
||||
listDir(SPIFFS, "/", true);
|
||||
#else
|
||||
fs::Dir dir = SPIFFS.openDir("/"); // Root directory
|
||||
String line = "=====================================";
|
||||
|
||||
Serial.println(line);
|
||||
Serial.println(" File name Size");
|
||||
Serial.println(line);
|
||||
|
||||
while (dir.next()) {
|
||||
String fileName = dir.fileName();
|
||||
Serial.print(fileName);
|
||||
int spaces = 25 - fileName.length(); // Tabulate nicely
|
||||
if (spaces < 0) spaces = 1;
|
||||
while (spaces--) Serial.print(" ");
|
||||
fs::File f = dir.openFile("r");
|
||||
Serial.print(f.size()); Serial.println(" bytes");
|
||||
yield();
|
||||
}
|
||||
|
||||
Serial.println(line);
|
||||
#endif
|
||||
Serial.println();
|
||||
delay(1000);
|
||||
}
|
||||
//====================================================================================
|
||||
|
||||
#ifdef ESP32
|
||||
void listDir(fs::FS &fs, const char * dirname, uint8_t levels) {
|
||||
Serial.printf("Listing directory: %s\n", dirname);
|
||||
|
||||
fs::File root = fs.open(dirname);
|
||||
if (!root) {
|
||||
Serial.println("Failed to open directory");
|
||||
return;
|
||||
}
|
||||
if (!root.isDirectory()) {
|
||||
Serial.println("Not a directory");
|
||||
return;
|
||||
}
|
||||
|
||||
fs::File file = root.openNextFile();
|
||||
while (file) {
|
||||
|
||||
if (file.isDirectory()) {
|
||||
Serial.print("DIR : ");
|
||||
String fileName = file.name();
|
||||
Serial.print(fileName);
|
||||
if (levels) {
|
||||
listDir(fs, file.name(), levels - 1);
|
||||
}
|
||||
} else {
|
||||
String fileName = file.name();
|
||||
Serial.print(" " + fileName);
|
||||
int spaces = 32 - fileName.length(); // Tabulate nicely
|
||||
if (spaces < 1) spaces = 1;
|
||||
while (spaces--) Serial.print(" ");
|
||||
String fileSize = (String) file.size();
|
||||
spaces = 8 - fileSize.length(); // Tabulate nicely
|
||||
if (spaces < 1) spaces = 1;
|
||||
while (spaces--) Serial.print(" ");
|
||||
Serial.println(fileSize + " bytes");
|
||||
}
|
||||
|
||||
file = root.openNextFile();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,148 @@
|
|||
// Created by Bodmer 24th Jan 2017 - Tested in Arduino IDE 1.8.5 esp8266 Core 2.4.0
|
||||
|
||||
// The latest Arduino IDE versions support UTF-8 encoding of Unicode characters
|
||||
// within sketches:
|
||||
// https://playground.arduino.cc/Code/UTF-8
|
||||
|
||||
/*
|
||||
The library expects strings to be in UTF-8 encoded format:
|
||||
https://www.fileformat.info/info/unicode/utf8.htm
|
||||
|
||||
Creating varaibles needs to be done with care when using character arrays:
|
||||
char c = 'µ'; // Wrong
|
||||
char bad[4] = "5µA"; // Wrong
|
||||
char good[] = "5µA"; // Good
|
||||
String okay = "5µA"; // Good
|
||||
|
||||
This is because UTF-8 characters outside the basic Latin set occupy more than
|
||||
1 byte per character! A 16 bit unicode character occupies 3 bytes!
|
||||
|
||||
*/
|
||||
|
||||
//====================================================================================
|
||||
// Libraries
|
||||
//====================================================================================
|
||||
// Call up the SPIFFS FLASH filing system this is part of the ESP Core
|
||||
|
||||
#include <TFT_eSPI.h> // Hardware-specific library
|
||||
|
||||
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
|
||||
|
||||
uint16_t bg = TFT_BLACK;
|
||||
uint16_t fg = TFT_WHITE;
|
||||
|
||||
|
||||
//====================================================================================
|
||||
// Setup
|
||||
//====================================================================================
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200); // Used for messages and the C array generator
|
||||
|
||||
Serial.println("NodeMCU vlw font test!");
|
||||
|
||||
if (!SPIFFS.begin()) {
|
||||
Serial.println("SPIFFS initialisation failed!");
|
||||
while (1) yield(); // Stay here twiddling thumbs waiting
|
||||
}
|
||||
Serial.println("\r\nInitialisation done.");
|
||||
|
||||
listFiles(); // Lists the files so you can see what is in the SPIFFS
|
||||
|
||||
tft.begin();
|
||||
tft.setRotation(0); // portrait
|
||||
|
||||
fg = TFT_WHITE;
|
||||
bg = TFT_BLACK;
|
||||
}
|
||||
|
||||
//====================================================================================
|
||||
// Loop
|
||||
//====================================================================================
|
||||
void loop()
|
||||
{
|
||||
tft.setTextColor(fg, bg);
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Anti-aliased font test
|
||||
|
||||
String test1 = "Hello World";
|
||||
|
||||
// Load a smooth font from SPIFFS
|
||||
tft.loadFont("Final-Frontier-28");
|
||||
|
||||
tft.setRotation(0);
|
||||
|
||||
// Show all characters on screen with 2 second (2000ms) delay between screens
|
||||
tft.showFont(2000); // Note: This function moves the cursor position!
|
||||
|
||||
tft.fillScreen(bg);
|
||||
tft.setCursor(0,0);
|
||||
|
||||
tft.println(test1);
|
||||
|
||||
// Remove font parameters from memory to recover RAM
|
||||
tft.unloadFont();
|
||||
|
||||
delay(2000);
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// We can have any random mix of characters in the font
|
||||
|
||||
String test2 = "仝倀"; // Unicodes 0x4EDD, 0x5000
|
||||
|
||||
tft.loadFont("Unicode-Test-72");
|
||||
|
||||
tft.setRotation(1);
|
||||
|
||||
// Show all characters on screen with 2 second (2000ms) delay between screens
|
||||
tft.showFont(2000); // Note: This function moves the cursor position!
|
||||
|
||||
tft.fillScreen(bg);
|
||||
tft.setCursor(0,0);
|
||||
|
||||
tft.setTextColor(TFT_CYAN, bg);
|
||||
tft.println(test2);
|
||||
|
||||
tft.setTextColor(TFT_YELLOW, bg);
|
||||
tft.println("12:00pm");
|
||||
|
||||
tft.setTextColor(TFT_MAGENTA, bg);
|
||||
tft.println("1000Ω");
|
||||
|
||||
// Remove font parameters from memory to recover RAM
|
||||
tft.unloadFont();
|
||||
|
||||
delay(2000);
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Latin and Hiragana font mix
|
||||
|
||||
String test3 = "こんにちは";
|
||||
|
||||
tft.loadFont("Latin-Hiragana-24");
|
||||
|
||||
tft.setRotation(0);
|
||||
|
||||
// Show all characters on screen with 2 second (2000ms) delay between screens
|
||||
tft.showFont(2000); // Note: This function moves the cursor position!
|
||||
|
||||
tft.fillScreen(bg);
|
||||
tft.setTextColor(TFT_GREEN, bg);
|
||||
tft.setCursor(0,0);
|
||||
|
||||
tft.println("Konnichiwa");
|
||||
tft.println(test3);
|
||||
tft.println();
|
||||
tft.println("Sayonara");
|
||||
tft.println("さようなら"); // Sayonara
|
||||
|
||||
// Remove font parameters from memory to recover RAM
|
||||
tft.unloadFont();
|
||||
|
||||
delay(2000);
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
}
|
||||
//====================================================================================
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue