Commit 9276b016 authored by Bodmer's avatar Bodmer

Add support for 1 bit per pixel in Sprite class

This is stage one of support for ePaper displays from Waveshare.
Examples for 1 bit per pixel Sprites and 2 or 3 colour ePaper displays
to follow soon.
parent 1db0c30b
......@@ -74,14 +74,14 @@ void TFT_eSPI::loadFont(String fontName)
*/
unloadFont();
_gFontFilename = "/" + fontName + ".vlw";
fontFile = SPIFFS.open( _gFontFilename, "r");
if(!fontFile) return;
//unloadFont();
fontFile.seek(0, fs::SeekSet);
gFont.gCount = (uint16_t)readInt32(); // glyph count in file
......@@ -230,7 +230,8 @@ void TFT_eSPI::unloadFont( void )
free(gBitmap);
gBitmap = NULL;
}
fontFile.close();
if(fontFile) fontFile.close();
fontLoaded = false;
}
......
This diff is collapsed.
......@@ -14,15 +14,20 @@ class TFT_eSprite : public TFT_eSPI {
// 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);
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),
......@@ -49,10 +54,13 @@ class TFT_eSprite : public TFT_eSPI {
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),
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);
//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);
......@@ -92,13 +100,17 @@ class TFT_eSprite : public TFT_eSPI {
protected:
uint8_t _bpp;
uint16_t *_img; // pointer to 16 bit sprite
uint8_t *_img8; // pointer to 8 bit sprite
bool _created, _bpp16; // created and bits per pixel depth flags
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;
// 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
......@@ -106,6 +118,8 @@ class TFT_eSprite : public TFT_eSPI {
boolean _iswapBytes; // Swap the byte order for Sprite pushImage()
int32_t _iwidth, _iheight; // Sprite image width and height
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)
};
// 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
......@@ -156,8 +156,8 @@ TFT_eSPI::TFT_eSPI(int16_t w, int16_t h)
cursor_y = cursor_x = 0;
textfont = 1;
textsize = 1;
textcolor = 0xFFFF; // White
textbgcolor = 0x0000; // Black
textcolor = bitmap_fg = 0xFFFF; // White
textbgcolor = bitmap_bg = 0x0000; // Black
padX = 0; // No padding
textwrapX = true; // Wrap text at end of line when using print stream
textwrapY = false; // Wrap text at bottom of screen when using print stream
......@@ -998,7 +998,7 @@ void TFT_eSPI::pushImage(int32_t x, int32_t y, uint32_t w, uint32_t h, const uin
** Function name: pushImage
** Description: plot 8 bit image or sprite using a line buffer
***************************************************************************************/
void TFT_eSPI::pushImage(int32_t x, int32_t y, uint32_t w, uint32_t h, uint8_t *data)
void TFT_eSPI::pushImage(int32_t x, int32_t y, uint32_t w, uint32_t h, uint8_t *data, bool bpp8)
{
if ((x >= (int32_t)_width) || (y >= (int32_t)_height)) return;
......@@ -1020,11 +1020,11 @@ void TFT_eSPI::pushImage(int32_t x, int32_t y, uint32_t w, uint32_t h, uint8_t *
setAddrWindow(x, y, x + dw - 1, y + dh - 1); // Sets CS low and sent RAMWR
data += dx + dy * w;
// Line buffer makes plotting faster
uint16_t lineBuf[dw];
if (bpp8)
{
uint8_t blue[] = {0, 11, 21, 31}; // blue 2 to 5 bit colour lookup table
_lastColor = -1; // Set to illegal value
......@@ -1033,6 +1033,7 @@ void TFT_eSPI::pushImage(int32_t x, int32_t y, uint32_t w, uint32_t h, uint8_t *
uint8_t msbColor = 0;
uint8_t lsbColor = 0;
data += dx + dy * w;
while (dh--)
{
uint32_t len = dw;
......@@ -1060,6 +1061,39 @@ void TFT_eSPI::pushImage(int32_t x, int32_t y, uint32_t w, uint32_t h, uint8_t *
data += w;
}
}
else
{
while (dh--)
{
w = (w+7) & 0xFFF8;
int32_t len = dw;
uint8_t* ptr = data;
uint8_t* linePtr = (uint8_t*)lineBuf;
uint8_t bits = 8;
while(len>0)
{
if (len < 8) bits = len;
uint32_t xp = dx;
for (uint16_t i = 0; i < bits; i++)
{
uint8_t col = (ptr[(xp + dy * w)>>3] << (xp & 0x7)) & 0x80;
if (col) {*linePtr++ = bitmap_fg>>8; *linePtr++ = (uint8_t) bitmap_fg;}
else {*linePtr++ = bitmap_bg>>8; *linePtr++ = (uint8_t) bitmap_bg;}
//if (col) drawPixel((dw-len)+xp,h-dh,bitmap_fg);
//else drawPixel((dw-len)+xp,h-dh,bitmap_bg);
xp++;
}
*ptr++;
len -= 8;
}
pushColors(lineBuf, dw, false);
dy++;
}
}
CS_H;
......@@ -1070,9 +1104,9 @@ void TFT_eSPI::pushImage(int32_t x, int32_t y, uint32_t w, uint32_t h, uint8_t *
/***************************************************************************************
** Function name: pushImage
** Description: plot 8 bit image or sprite with 1 colour being transparent
** Description: plot 8 or 1 bit image or sprite with a transparent colour
***************************************************************************************/
void TFT_eSPI::pushImage(int32_t x, int32_t y, uint32_t w, uint32_t h, uint8_t *data, uint8_t transp)
void TFT_eSPI::pushImage(int32_t x, int32_t y, uint32_t w, uint32_t h, uint8_t *data, uint8_t transp, bool bpp8)
{
if ((x >= (int32_t)_width) || (y >= (int32_t)_height)) return;
......@@ -1092,13 +1126,15 @@ void TFT_eSPI::pushImage(int32_t x, int32_t y, uint32_t w, uint32_t h, uint8_t *
spi_begin();
inTransaction = true;
data += dx + dy * w;
int32_t xe = x + dw - 1, ye = y + dh - 1;
// Line buffer makes plotting faster
uint16_t lineBuf[dw];
if (bpp8)
{
data += dx + dy * w;
uint8_t blue[] = {0, 11, 21, 31}; // blue 2 to 5 bit colour lookup table
_lastColor = -1; // Set to illegal value
......@@ -1157,6 +1193,55 @@ void TFT_eSPI::pushImage(int32_t x, int32_t y, uint32_t w, uint32_t h, uint8_t *
y++;
data += w;
}
}
else
{
w = (w+7) & 0xFFF8;
while (dh--)
{
int32_t px = x;
boolean move = true;
uint16_t np = 0;
int32_t len = dw;
uint8_t* ptr = data;
uint8_t bits = 8;
while(len>0)
{
if (len < 8) bits = len;
uint32_t xp = dx;
uint32_t yp = (dy * w)>>3;
for (uint16_t i = 0; i < bits; i++)
{
//uint8_t col = (ptr[(xp + dy * w)>>3] << (xp & 0x7)) & 0x80;
if ((ptr[(xp>>3) + yp] << (xp & 0x7)) & 0x80)
{
if (move)
{
move = false;
setAddrWindow(px, y, xe, ye);
}
np++;
}
else
{
if (np)
{
pushColor(bitmap_fg, np);
np = 0;
move = true;
}
}
px++;
xp++;
}
*ptr++;
len -= 8;
}
if (np) pushColor(bitmap_fg, np);
y++;
dy++;
}
}
CS_H;
......@@ -1769,6 +1854,18 @@ void TFT_eSPI::setTextColor(uint16_t c, uint16_t b)
}
/***************************************************************************************
** Function name: setBitmapColor
** Description: Set the foreground foreground and background colour
***************************************************************************************/
void TFT_eSPI::setBitmapColor(uint16_t c, uint16_t b)
{
if (c == b) b = ~c;
bitmap_fg = c;
bitmap_bg = b;
}
/***************************************************************************************
** Function name: setTextWrap
** Description: Define if text should wrap at end of line
......@@ -2978,7 +3075,7 @@ void TFT_eSPI::pushColors(uint16_t *data, uint32_t len, bool swap)
#if defined (ESP32)
#ifdef ESP32_PARALLEL
if (swap) while ( len-- ) {tft_Write_16(*data); data++;}
else while ( len-- ) {transwap16(*data); data++;}
else while ( len-- ) {tft_Write_16S(*data); data++;}
#else
if (swap) SPI.writePixels(data,len<<1);
else SPI.writeBytes((uint8_t*)data,len<<1);
......@@ -3013,6 +3110,8 @@ void TFT_eSPI::pushColors(uint16_t *data, uint32_t len, bool swap)
}
len -= 16;
// ESP8266 wait time here at 40MHz SPI is ~5.45us
while(SPI1CMD & SPIBUSY) {}
SPI1W0 = color[0];
SPI1W1 = color[1];
......@@ -4446,6 +4545,136 @@ void writeBlock(uint16_t color, uint32_t repeat)
#endif
/***************************************************************************************
** Function name: getSetup
** Description: Get the setup details for diagnostic and sketch access
***************************************************************************************/
void TFT_eSPI::getSetup(setup_t &tft_settings)
{
#if defined (ESP8266)
tft_settings.esp = 8266;
#elif defined (ESP32)
tft_settings.esp = 32;
#else
tft_settings.esp = -1;
#endif
#if defined (SUPPORT_TRANSACTIONS)
tft_settings.trans = true;
#else
tft_settings.trans = false;
#endif
#if defined (ESP32_PARALLEL)
tft_settings.serial = false;
tft_settings.tft_spi_freq = 0;
#else
tft_settings.serial = true;
tft_settings.tft_spi_freq = SPI_FREQUENCY/100000;
#endif
tft_settings.tft_driver = TFT_DRIVER;
tft_settings.tft_width = _init_width;
tft_settings.tft_height = _init_height;
#ifdef CGRAM_OFFSET
tft_settings.r0_x_offset = colstart;
tft_settings.r0_y_offset = rowstart;
tft_settings.r1_x_offset = 0;
tft_settings.r1_y_offset = 0;
tft_settings.r2_x_offset = 0;
tft_settings.r2_y_offset = 0;
tft_settings.r3_x_offset = 0;
tft_settings.r3_y_offset = 0;
#else
tft_settings.r0_x_offset = 0;
tft_settings.r0_y_offset = 0;
tft_settings.r1_x_offset = 0;
tft_settings.r1_y_offset = 0;
tft_settings.r2_x_offset = 0;
tft_settings.r2_y_offset = 0;
tft_settings.r3_x_offset = 0;
tft_settings.r3_y_offset = 0;
#endif
#if defined (TFT_MOSI)
tft_settings.pin_tft_mosi = TFT_MOSI;
#else
tft_settings.pin_tft_mosi = -1;
#endif
#if defined (TFT_MISO)
tft_settings.pin_tft_miso = TFT_MISO;
#else
tft_settings.pin_tft_miso = -1;
#endif
#if defined (TFT_SCLK)
tft_settings.pin_tft_clk = TFT_SCLK;
#else
tft_settings.pin_tft_clk = -1;
#endif
#if defined (TFT_CS)
tft_settings.pin_tft_cs = TFT_CS;
#else
tft_settings.pin_tft_cs = -1;
#endif
#if defined (TFT_DC)
tft_settings.pin_tft_dc = TFT_DC;
#else
tft_settings.pin_tft_dc = -1;
#endif
#if defined (TFT_RD)
tft_settings.pin_tft_rd = TFT_RD;
#else
tft_settings.pin_tft_rd = -1;
#endif
#if defined (TFT_WR)
tft_settings.pin_tft_wr = TFT_WR;
#else
tft_settings.pin_tft_wr = -1;
#endif
#if defined (TFT_RST)
tft_settings.pin_tft_rst = TFT_RST;
#else
tft_settings.pin_tft_rst = -1;
#endif
#if defined (ESP32_PARALLEL)
tft_settings.pin_tft_d0 = TFT_D0;
tft_settings.pin_tft_d1 = TFT_D1;
tft_settings.pin_tft_d2 = TFT_D2;
tft_settings.pin_tft_d3 = TFT_D3;
tft_settings.pin_tft_d4 = TFT_D4;
tft_settings.pin_tft_d5 = TFT_D5;
tft_settings.pin_tft_d6 = TFT_D6;
tft_settings.pin_tft_d7 = TFT_D7;
#else
tft_settings.pin_tft_d0 = -1;
tft_settings.pin_tft_d1 = -1;
tft_settings.pin_tft_d2 = -1;
tft_settings.pin_tft_d3 = -1;
tft_settings.pin_tft_d4 = -1;
tft_settings.pin_tft_d5 = -1;
tft_settings.pin_tft_d6 = -1;
tft_settings.pin_tft_d7 = -1;
#endif
#if defined (TOUCH_CS)
tft_settings.pin_tch_cs = TOUCH_CS;
tft_settings.tch_spi_freq = SPI_TOUCH_FREQUENCY/100000;
#else
tft_settings.pin_tch_cs = -1;
tft_settings.tch_spi_freq = 0;
#endif
}
////////////////////////////////////////////////////////////////////////////////////////
#ifdef TOUCH_CS
#include "Extensions/Touch.cpp"
......
......@@ -155,42 +155,42 @@
#endif
#ifdef ESP32_PARALLEL
#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
#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
// 16 bit transfer with swapped bytes
#define transwap16(C) GPIO.out_w1tc = clr_mask; GPIO.out_w1ts = set_mask((uint8_t) (C >> 0)); WR_H; \
// 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
#if defined (ESP32)
#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)
#else
//#define RD_L GPOC=rdpinmask
//#define RD_H GPOS=rdpinmask
#endif
#endif
#elif defined (SEND_16_BITS)
......@@ -330,9 +330,55 @@ template <typename T> static inline void
swap_coord(T& a, T& b) { T t = a; a = b; b = t; }
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#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;
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
......@@ -444,6 +490,7 @@ 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),
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),
......@@ -489,9 +536,9 @@ class TFT_eSPI : public Print {
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 8 bit colours
void pushImage(int32_t x0, int32_t y0, uint32_t w, uint32_t h, uint8_t *data);
void pushImage(int32_t x0, int32_t y0, uint32_t w, uint32_t h, uint8_t *data, uint8_t transparent);
// 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);
......@@ -543,8 +590,11 @@ class TFT_eSPI : public Print {
size_t write(uint8_t);
void getSetup(setup_t& tft_settings); // Sketch provides the instance to populate
int32_t cursor_x, cursor_y;
uint32_t textcolor, textbgcolor;
uint32_t bitmap_fg, bitmap_bg;
private:
......
......@@ -40,7 +40,7 @@
//#include <User_Setups/Setup99.h>
//#include <User_Setups/SetupX_Template.h> // Setup file template for copying/editting
// ePaper #include <User_Setups/SetupX_Template.h> // Setup file template for copying/editting
#endif // USER_SETUP_LOADED
......@@ -58,39 +58,51 @@
// 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 0x9481
#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
#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
#define PIN_MOSI 8
#define PIN_MISO 7
#define PIN_SCLK 6
#define PIN_HWCS 0
#define PIN_D11 9
#define PIN_D12 10
// 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 // SD1
#define PIN_MISO 7 // SD0
#define PIN_SCLK 6 // CLK
#define PIN_HWCS 0 // CMD
#define PIN_D11 9 // SD2
#define PIN_D12 10 // SD4
......@@ -121,6 +121,10 @@
//#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
......@@ -130,9 +134,6 @@
//#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
// ##################################################################################
//
......@@ -199,6 +200,7 @@
// #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 53400000
// #define SPI_FREQUENCY 80000000
// The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here:
......
// 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 EPD_DRIVER
// ##################################################################################
//
// Section 1. Define the pins that are used to interface with the display here
//
// ##################################################################################
// ePaper pins are not defined here - dummy set
//#define TFT_CS
//#define TFT_DC
//#define TFT_RST
// ##################################################################################
//
// 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 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
//
// ##################################################################################
// ##################################################################################
//
// Section 5. Not used
//
// ##################################################################################
......@@ -75,7 +75,6 @@ calibrateTouch KEYWORD2
setTouch KEYWORD2
validTouch KEYWORD2
TFT_eSPI_Button KEYWORD1
initButton KEYWORD2
......@@ -99,8 +98,14 @@ pushBitmap KEYWORD2
pushSprite KEYWORD2
setScrollRect KEYWORD2
scroll KEYWORD2
printToSprite KEYWORD2
frameBuffer KEYWORD2
setBitmapColor KEYWORD2
alphaBlend KEYWORD2
showFont KEYWORD2
loadFont KEYWORD2
unloadFont KEYWORD2
getUnicodeIndex KEYWORD2
decodeUTF8 KEYWORD2
drawGlyph KEYWORD2
......@@ -14,10 +14,6 @@
"name": "Bodmer",
"email": "bodmer@anola.net",
"maintainer": true
},
{
"name": "Adafruit",
"url": "https://www.adafruit.com/"
}
],
"frameworks": "arduino",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment