mirror of
https://github.com/Bodmer/TFT_eSPI.git
synced 2025-08-02 12:14:40 +02:00
Add Sprite rotation and examples
Sprites can be rendered rotated with defined pivot points, 3 new examples have been added "Rotated_Sprite_1/2/3". The FLASH bitmap example has been moved to the Generic examples folder. Boundary checks have been added to pushImage() A new scrolling and wrapping in a Sprite example has been added.
This commit is contained in:
@@ -33,6 +33,9 @@ TFT_eSprite::TFT_eSprite(TFT_eSPI *tft)
|
|||||||
_xptr = 0; // pushColor coordinate
|
_xptr = 0; // pushColor coordinate
|
||||||
_yptr = 0;
|
_yptr = 0;
|
||||||
|
|
||||||
|
_xpivot = 0;
|
||||||
|
_ypivot = 0;
|
||||||
|
|
||||||
this->cursor_y = this->cursor_x = 0; // Text cursor position
|
this->cursor_y = this->cursor_x = 0; // Text cursor position
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,43 +65,61 @@ void* TFT_eSprite::createSprite(int16_t w, int16_t h, uint8_t frames)
|
|||||||
_sh = h;
|
_sh = h;
|
||||||
_scolor = TFT_BLACK;
|
_scolor = TFT_BLACK;
|
||||||
|
|
||||||
|
_xpivot = w/2;
|
||||||
|
_ypivot = h/2;
|
||||||
|
|
||||||
|
_img8 = (uint8_t*) callocSprite(w, h, frames);
|
||||||
|
_img8_1 = _img8;
|
||||||
|
_img8_2 = _img8;
|
||||||
|
_img = (uint16_t*) _img8;
|
||||||
|
|
||||||
|
// This is to make it clear what pointer size is expected to be used
|
||||||
|
// but casting in the user sketch is needed due to the use of void*
|
||||||
|
if (_bpp == 1)
|
||||||
|
{
|
||||||
|
w = (w+7) & 0xFFF8;
|
||||||
|
_img8_2 = _img8 + ( (w>>3) * h + 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_img8)
|
||||||
|
{
|
||||||
|
_created = true;
|
||||||
|
return _img8;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************************
|
||||||
|
** Function name: callocSprite
|
||||||
|
** Description: Allocate a memory area for the Sprite and return pointer
|
||||||
|
*************************************************************************************x*/
|
||||||
|
|
||||||
|
void* TFT_eSprite::callocSprite(int16_t w, int16_t h, uint8_t frames)
|
||||||
|
{
|
||||||
// Add one extra "off screen" pixel to point out-of-bounds setWindow() coordinates
|
// Add one extra "off screen" pixel to point out-of-bounds setWindow() coordinates
|
||||||
// this means push/writeColor functions do not need additional bounds checks and
|
// this means push/writeColor functions do not need additional bounds checks and
|
||||||
// hence will run faster in normal circumstances.
|
// hence will run faster in normal circumstances.
|
||||||
|
uint8_t* ptr8 = NULL;
|
||||||
|
|
||||||
if (_bpp == 16)
|
if (_bpp == 16)
|
||||||
{
|
{
|
||||||
|
|
||||||
#if defined (ESP32) && defined (CONFIG_SPIRAM_SUPPORT)
|
#if defined (ESP32) && defined (CONFIG_SPIRAM_SUPPORT)
|
||||||
if ( psramFound() ) _img8_1 = ( uint8_t*) ps_calloc(w * h + 1, sizeof(uint16_t));
|
if ( psramFound() ) ptr8 = ( uint8_t*) ps_calloc(w * h + 1, sizeof(uint16_t));
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
_img8_1 = ( uint8_t*) calloc(w * h + 1, sizeof(uint16_t));
|
ptr8 = ( uint8_t*) calloc(w * h + 1, sizeof(uint16_t));
|
||||||
|
|
||||||
_img8_2 = _img8_1;
|
|
||||||
_img = (uint16_t*) _img8_1;
|
|
||||||
|
|
||||||
if (_img)
|
|
||||||
{
|
|
||||||
_created = true;
|
|
||||||
return _img;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (_bpp == 8)
|
else if (_bpp == 8)
|
||||||
{
|
{
|
||||||
#if defined (ESP32) && defined (CONFIG_SPIRAM_SUPPORT)
|
#if defined (ESP32) && defined (CONFIG_SPIRAM_SUPPORT)
|
||||||
if ( psramFound() ) _img8_1 = ( uint8_t*) ps_calloc(w * h + 1, sizeof(uint8_t));
|
if ( psramFound() ) ptr8 = ( uint8_t*) ps_calloc(w * h + 1, sizeof(uint8_t));
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
_img8_1 = ( uint8_t*) calloc(w * h + 1, sizeof(uint8_t));
|
ptr8 = ( uint8_t*) calloc(w * h + 1, sizeof(uint8_t));
|
||||||
|
|
||||||
if (_img8_1)
|
|
||||||
{
|
|
||||||
_img8 = _img8_1;
|
|
||||||
_img8_2 = _img8_1;
|
|
||||||
_created = true;
|
|
||||||
return _img8;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else // Must be 1 bpp
|
else // Must be 1 bpp
|
||||||
@@ -114,21 +135,13 @@ void* TFT_eSprite::createSprite(int16_t w, int16_t h, uint8_t frames)
|
|||||||
if (frames > 2) frames = 2; // Currently restricted to 2 frame buffers
|
if (frames > 2) frames = 2; // Currently restricted to 2 frame buffers
|
||||||
if (frames < 1) frames = 1;
|
if (frames < 1) frames = 1;
|
||||||
#if defined (ESP32) && defined (CONFIG_SPIRAM_SUPPORT)
|
#if defined (ESP32) && defined (CONFIG_SPIRAM_SUPPORT)
|
||||||
if ( psramFound() ) _img8 = ( uint8_t*) ps_calloc(frames * (w>>3) * h + frames, sizeof(uint8_t));
|
if ( psramFound() ) ptr8 = ( uint8_t*) ps_calloc(frames * (w>>3) * h + frames, sizeof(uint8_t));
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
_img8 = ( uint8_t*) calloc(frames * (w>>3) * h + frames, sizeof(uint8_t));
|
ptr8 = ( uint8_t*) calloc(frames * (w>>3) * h + frames, sizeof(uint8_t));
|
||||||
|
|
||||||
if (_img8)
|
|
||||||
{
|
|
||||||
_created = true;
|
|
||||||
_img8_1 = _img8;
|
|
||||||
_img8_2 = _img8 + ( (w>>3) * h + 1 );
|
|
||||||
return _img8_1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return ptr8;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************************************
|
/***************************************************************************************
|
||||||
@@ -151,8 +164,8 @@ void* TFT_eSprite::frameBuffer(int8_t f)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************************************
|
/***************************************************************************************
|
||||||
** Function name: setDepth
|
** Function name: setColorDepth
|
||||||
** Description: Set bits per pixel for colour (8 or 16)
|
** Description: Set bits per pixel for colour (1, 8 or 16)
|
||||||
*************************************************************************************x*/
|
*************************************************************************************x*/
|
||||||
|
|
||||||
void* TFT_eSprite::setColorDepth(int8_t b)
|
void* TFT_eSprite::setColorDepth(int8_t b)
|
||||||
@@ -175,6 +188,19 @@ void* TFT_eSprite::setColorDepth(int8_t b)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************************
|
||||||
|
** Function name: getColorDepth
|
||||||
|
** Description: Get bits per pixel for colour (1, 8 or 16)
|
||||||
|
*************************************************************************************x*/
|
||||||
|
|
||||||
|
int8_t TFT_eSprite::getColorDepth(void)
|
||||||
|
{
|
||||||
|
if (_created) return _bpp;
|
||||||
|
else return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************************
|
/***************************************************************************************
|
||||||
** Function name: setBitmapColor
|
** Function name: setBitmapColor
|
||||||
** Description: Set the foreground foreground and background colour
|
** Description: Set the foreground foreground and background colour
|
||||||
@@ -201,6 +227,232 @@ void TFT_eSprite::deleteSprite(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************************
|
||||||
|
** Function name: setPivot
|
||||||
|
** Description: Set the pivot point in this Sprite
|
||||||
|
*************************************************************************************x*/
|
||||||
|
void TFT_eSprite::setPivot(int16_t x, int16_t y)
|
||||||
|
{
|
||||||
|
_xpivot = x;
|
||||||
|
_ypivot = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************************
|
||||||
|
** Function name: getPivotX
|
||||||
|
** Description: Get the x pivot position
|
||||||
|
***************************************************************************************/
|
||||||
|
int16_t TFT_eSprite::getPivotX(void)
|
||||||
|
{
|
||||||
|
return _xpivot;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************************
|
||||||
|
** Function name: getPivotY
|
||||||
|
** Description: Get the y pivot position
|
||||||
|
***************************************************************************************/
|
||||||
|
int16_t TFT_eSprite::getPivotY(void)
|
||||||
|
{
|
||||||
|
return _ypivot;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************************
|
||||||
|
** Function name: pushRotated
|
||||||
|
** Description: Push a rotated copy of the Sprite to TFT screen
|
||||||
|
*************************************************************************************x*/
|
||||||
|
bool TFT_eSprite::pushRotated(int16_t angle, int32_t transp)
|
||||||
|
{
|
||||||
|
if ( !_created ) return false;
|
||||||
|
|
||||||
|
// Trig values for the rotation
|
||||||
|
float radAngle = -angle * 0.0174532925; // Convert degrees to radians
|
||||||
|
float sinra = sin(radAngle);
|
||||||
|
float cosra = cos(radAngle);
|
||||||
|
|
||||||
|
// Bounding box parameters
|
||||||
|
int16_t min_x;
|
||||||
|
int16_t min_y;
|
||||||
|
int16_t max_x;
|
||||||
|
int16_t max_y;
|
||||||
|
|
||||||
|
// Get the bounding box of this rotated source Sprite relative to Sprite pivot
|
||||||
|
getRotatedBounds(sinra, cosra, width(), height(), _xpivot, _ypivot, &min_x, &min_y, &max_x, &max_y);
|
||||||
|
|
||||||
|
// Move bounding box so source Sprite pivot coincides with TFT pivot
|
||||||
|
min_x += _tft->_xpivot;
|
||||||
|
max_x += _tft->_xpivot;
|
||||||
|
min_y += _tft->_ypivot;
|
||||||
|
max_y += _tft->_ypivot;
|
||||||
|
|
||||||
|
// Test only to show bounding box on TFT
|
||||||
|
// _tft->drawRect(min_x, min_y, max_x - min_x + 1, max_y - min_y + 1, TFT_GREEN);
|
||||||
|
|
||||||
|
// Return if bounding box is outside of TFT area
|
||||||
|
if (min_x > _tft->width()) return true;
|
||||||
|
if (min_y > _tft->height()) return true;
|
||||||
|
if (max_x < 0) return true;
|
||||||
|
if (max_y < 0) return true;
|
||||||
|
|
||||||
|
// Clip bounding box to be within TFT area
|
||||||
|
if (min_x < 0) min_x = 0;
|
||||||
|
if (min_y < 0) min_y = 0;
|
||||||
|
if (max_x > _tft->width()) max_x = _tft->width();
|
||||||
|
if (max_y > _tft->height()) max_y = _tft->height();
|
||||||
|
|
||||||
|
|
||||||
|
// Scan destination bounding box and fetch transformed pixels from source Sprite
|
||||||
|
for (int32_t x = min_x; x <= max_x; x++) {
|
||||||
|
int32_t xt = x - _tft->_xpivot;
|
||||||
|
float cxt = cosra * xt + _xpivot;
|
||||||
|
float sxt = sinra * xt + _ypivot;
|
||||||
|
bool column_drawn = false;
|
||||||
|
for (int32_t y = min_y; y <= max_y; y++) {
|
||||||
|
int32_t yt = y - _tft->_ypivot;
|
||||||
|
int32_t xs = (int32_t)round(cxt - sinra * yt);
|
||||||
|
// Do not calculate ys unless xs is in bounds
|
||||||
|
if (xs >= 0 && xs < width())
|
||||||
|
{
|
||||||
|
int32_t ys = (int32_t)round(sxt + cosra * yt);
|
||||||
|
// Check if ys is in bounds
|
||||||
|
if (ys >= 0 && ys < height()) {
|
||||||
|
int32_t rp = readPixel(xs, ys);
|
||||||
|
if (rp != transp) _tft->drawPixel(x, y, rp);
|
||||||
|
column_drawn = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (column_drawn) y = max_y; // Skip remaining column pixels
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************************
|
||||||
|
** Function name: pushRotated
|
||||||
|
** Description: Push a rotated copy of the Sprite to another Sprite
|
||||||
|
*************************************************************************************x*/
|
||||||
|
bool TFT_eSprite::pushRotated(TFT_eSprite *spr, int16_t angle, int32_t transp)
|
||||||
|
{
|
||||||
|
if ( !_created ) return false; // Check this Sprite is created
|
||||||
|
if ( !spr->_created ) return false; // Ckeck destination Sprite is created
|
||||||
|
|
||||||
|
// Trig values for the rotation
|
||||||
|
float radAngle = -angle * 0.0174532925; // Convert degrees to radians
|
||||||
|
float sinra = sin(radAngle);
|
||||||
|
float cosra = cos(radAngle);
|
||||||
|
|
||||||
|
// Bounding box parameters
|
||||||
|
int16_t min_x;
|
||||||
|
int16_t min_y;
|
||||||
|
int16_t max_x;
|
||||||
|
int16_t max_y;
|
||||||
|
|
||||||
|
// Get the bounding box of this rotated source Sprite
|
||||||
|
getRotatedBounds(sinra, cosra, width(), height(), _xpivot, _ypivot, &min_x, &min_y, &max_x, &max_y);
|
||||||
|
|
||||||
|
// Move bounding box so source Sprite pivot coincides with destination Sprite pivot
|
||||||
|
min_x += spr->_xpivot;
|
||||||
|
max_x += spr->_xpivot;
|
||||||
|
min_y += spr->_ypivot;
|
||||||
|
max_y += spr->_ypivot;
|
||||||
|
|
||||||
|
// Test only to show bounding box
|
||||||
|
// spr->fillSprite(TFT_BLACK);
|
||||||
|
// spr->drawRect(min_x, min_y, max_x - min_x + 1, max_y - min_y + 1, TFT_GREEN);
|
||||||
|
|
||||||
|
// Return if bounding box is completely outside of destination Sprite
|
||||||
|
if (min_x > spr->width()) return true;
|
||||||
|
if (min_y > spr->height()) return true;
|
||||||
|
if (max_x < 0) return true;
|
||||||
|
if (max_y < 0) return true;
|
||||||
|
|
||||||
|
// Clip bounding box if it is partially within destination Sprite
|
||||||
|
if (min_x < 0) min_x = 0;
|
||||||
|
if (min_y < 0) min_y = 0;
|
||||||
|
if (max_x > spr->width()) max_x = spr->width();
|
||||||
|
if (max_y > spr->height()) max_y = spr->height();
|
||||||
|
|
||||||
|
// Scan destination bounding box and fetch transformed pixels from source Sprite
|
||||||
|
for (int32_t x = min_x; x <= max_x; x++)
|
||||||
|
{
|
||||||
|
int32_t xt = x - spr->_xpivot;
|
||||||
|
float cxt = cosra * xt + _xpivot;
|
||||||
|
float sxt = sinra * xt + _ypivot;
|
||||||
|
bool column_drawn = false;
|
||||||
|
for (int32_t y = min_y; y <= max_y; y++)
|
||||||
|
{
|
||||||
|
int32_t yt = y - spr->_ypivot;
|
||||||
|
int32_t xs = (int32_t)round(cxt - sinra * yt);
|
||||||
|
// Do not calculate ys unless xs is in bounds
|
||||||
|
if (xs >= 0 && xs < width())
|
||||||
|
{
|
||||||
|
int32_t ys = (int32_t)round(sxt + cosra * yt);
|
||||||
|
// Check if ys is in bounds
|
||||||
|
if (ys >= 0 && ys < height())
|
||||||
|
{
|
||||||
|
int32_t rp = readPixel(xs, ys);
|
||||||
|
if (rp != transp) spr->drawPixel(x, y, rp);
|
||||||
|
column_drawn = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (column_drawn) y = max_y; // Skip the remaining pixels below the Sprite
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************************
|
||||||
|
** Function name: rotatedBounds
|
||||||
|
** Description: Get bounding box of a rotated Sprite wrt pivot
|
||||||
|
*************************************************************************************x*/
|
||||||
|
void TFT_eSprite::getRotatedBounds(float sina, float cosa, int16_t w, int16_t h, int16_t xp, int16_t yp,
|
||||||
|
int16_t *min_x, int16_t *min_y, int16_t *max_x, int16_t *max_y)
|
||||||
|
{
|
||||||
|
w -= xp; // w is now right edge coordinate relative to xp
|
||||||
|
h -= yp; // h is now bottom edge coordinate relative to yp
|
||||||
|
|
||||||
|
// Calculate new corner coordinates
|
||||||
|
int16_t x0 = -xp * cosa - yp * sina;
|
||||||
|
int16_t y0 = xp * sina - yp * cosa;
|
||||||
|
|
||||||
|
int16_t x1 = w * cosa - yp * sina;
|
||||||
|
int16_t y1 = -w * sina - yp * cosa;
|
||||||
|
|
||||||
|
int16_t x2 = h * sina + w * cosa;
|
||||||
|
int16_t y2 = h * cosa - w * sina;
|
||||||
|
|
||||||
|
int16_t x3 = h * sina - xp * cosa;
|
||||||
|
int16_t y3 = h * cosa + xp * sina;
|
||||||
|
|
||||||
|
// Find bounding box extremes, enlarge box to accomodate rounding errors
|
||||||
|
*min_x = x0-2;
|
||||||
|
if (x1 < *min_x) *min_x = x1-2;
|
||||||
|
if (x2 < *min_x) *min_x = x2-2;
|
||||||
|
if (x3 < *min_x) *min_x = x3-2;
|
||||||
|
|
||||||
|
*max_x = x0+2;
|
||||||
|
if (x1 > *max_x) *max_x = x1+2;
|
||||||
|
if (x2 > *max_x) *max_x = x2+2;
|
||||||
|
if (x3 > *max_x) *max_x = x3+2;
|
||||||
|
|
||||||
|
*min_y = y0-2;
|
||||||
|
if (y1 < *min_y) *min_y = y1-2;
|
||||||
|
if (y2 < *min_y) *min_y = y2-2;
|
||||||
|
if (y3 < *min_y) *min_y = y3-2;
|
||||||
|
|
||||||
|
*max_y = y0+2;
|
||||||
|
if (y1 > *max_y) *max_y = y1+2;
|
||||||
|
if (y2 > *max_y) *max_y = y2+2;
|
||||||
|
if (y3 > *max_y) *max_y = y3+2;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************************
|
/***************************************************************************************
|
||||||
** Function name: pushSprite
|
** Function name: pushSprite
|
||||||
** Description: Push the sprite to the TFT at x, y
|
** Description: Push the sprite to the TFT at x, y
|
||||||
@@ -289,33 +541,53 @@ uint16_t TFT_eSprite::readPixel(int32_t x, int32_t y)
|
|||||||
** Function name: pushImage
|
** Function name: pushImage
|
||||||
** Description: push 565 colour image into a defined area of a sprite
|
** Description: push 565 colour image into a defined area of a sprite
|
||||||
*************************************************************************************x*/
|
*************************************************************************************x*/
|
||||||
// TODO Need to add more area boundary checks
|
|
||||||
void TFT_eSprite::pushImage(int32_t x, int32_t y, uint32_t w, uint32_t h, uint16_t *data)
|
void TFT_eSprite::pushImage(int32_t x, int32_t y, uint32_t w, uint32_t h, uint16_t *data)
|
||||||
{
|
{
|
||||||
if ((x >= _iwidth) || (y >= _iheight) || (w == 0) || (h == 0) || !_created) return;
|
if ((x >= _iwidth) || (y >= _iheight) || (w == 0) || (h == 0) || !_created) return;
|
||||||
|
if ((x + (int32_t)w < 0) || (y + (int32_t)h < 0)) return;
|
||||||
|
|
||||||
|
int32_t xo = 0;
|
||||||
|
int32_t yo = 0;
|
||||||
|
|
||||||
|
int32_t xs = x;
|
||||||
|
int32_t ys = y;
|
||||||
|
|
||||||
|
uint32_t ws = w;
|
||||||
|
uint32_t hs = h;
|
||||||
|
|
||||||
|
if (x < 0) { xo = -x; xs = 0; }
|
||||||
|
if (y < 0) { yo = -y; ys = 0; }
|
||||||
|
|
||||||
|
if (xs + w >= _iwidth) ws = _iwidth - xs;
|
||||||
|
if (ys + h >= _iheight) hs = _iheight - ys;
|
||||||
|
|
||||||
if (_bpp == 16)
|
if (_bpp == 16)
|
||||||
{
|
{
|
||||||
for (uint32_t yp = y; yp < y + h; yp++)
|
for (uint32_t yp = yo; yp < yo + hs; yp++)
|
||||||
{
|
{
|
||||||
for (uint32_t xp = x; xp < x + w; xp++)
|
x = xs;
|
||||||
|
for (uint32_t xp = xo; xp < xo + ws; xp++)
|
||||||
{
|
{
|
||||||
uint16_t color = *data++;
|
uint16_t color = data[xp + yp * w];
|
||||||
if(!_iswapBytes) color = color<<8 | color>>8;
|
if(!_iswapBytes) color = color<<8 | color>>8;
|
||||||
_img[xp + yp * _iwidth] = color;
|
_img[x + ys * _iwidth] = color;
|
||||||
|
x++;
|
||||||
}
|
}
|
||||||
|
ys++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (_bpp == 8)
|
else if (_bpp == 8)
|
||||||
{
|
{
|
||||||
for (uint32_t yp = y; yp < y + h; yp++)
|
for (uint32_t yp = yo; yp < yo + hs; yp++)
|
||||||
{
|
{
|
||||||
for (uint32_t xp = x; xp < x + w; xp++)
|
x = xs;
|
||||||
|
for (uint32_t xp = xo; xp < xo + ws; xp++)
|
||||||
{
|
{
|
||||||
uint16_t color = *data++;
|
uint16_t color = data[xp + yp * w];
|
||||||
if(_iswapBytes) color = color<<8 | color>>8;
|
if(_iswapBytes) color = color<<8 | color>>8;
|
||||||
_img8[xp + yp * _iwidth] = (uint8_t)((color & 0xE000)>>8 | (color & 0x0700)>>6 | (color & 0x0018)>>3);
|
_img8[x + ys * _iwidth] = (uint8_t)((color & 0xE000)>>8 | (color & 0x0700)>>6 | (color & 0x0018)>>3);
|
||||||
}
|
}
|
||||||
|
ys++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,34 +632,54 @@ void TFT_eSprite::pushImage(int32_t x, int32_t y, uint32_t w, uint32_t h, uint1
|
|||||||
** Function name: pushImage
|
** Function name: pushImage
|
||||||
** Description: push 565 colour FLASH (PROGMEM) image into a defined area
|
** Description: push 565 colour FLASH (PROGMEM) image into a defined area
|
||||||
*************************************************************************************x*/
|
*************************************************************************************x*/
|
||||||
// TODO Need to add more area boundary checks
|
|
||||||
void TFT_eSprite::pushImage(int32_t x, int32_t y, uint32_t w, uint32_t h, const uint16_t *data)
|
void TFT_eSprite::pushImage(int32_t x, int32_t y, uint32_t w, uint32_t h, const uint16_t *data)
|
||||||
{
|
{
|
||||||
if ((x >= _iwidth) || (y >= _iheight) || (w == 0) || (h == 0) || !_created) return;
|
if ((x >= _iwidth) || (y >= _iheight) || (w == 0) || (h == 0) || !_created) return;
|
||||||
|
if ((x + (int32_t)w < 0) || (y + (int32_t)h < 0)) return;
|
||||||
|
|
||||||
|
int32_t xo = 0;
|
||||||
|
int32_t yo = 0;
|
||||||
|
|
||||||
|
int32_t xs = x;
|
||||||
|
int32_t ys = y;
|
||||||
|
|
||||||
|
uint32_t ws = w;
|
||||||
|
uint32_t hs = h;
|
||||||
|
|
||||||
|
if (x < 0) { xo = -x; xs = 0; }
|
||||||
|
if (y < 0) { yo = -y; ys = 0; }
|
||||||
|
|
||||||
|
if (xs + w >= _iwidth) ws = _iwidth - xs;
|
||||||
|
if (ys + h >= _iheight) hs = _iheight - ys;
|
||||||
|
|
||||||
if (_bpp == 16)
|
if (_bpp == 16)
|
||||||
{
|
{
|
||||||
for (uint32_t yp = y; yp < y + h; yp++)
|
for (uint32_t yp = yo; yp < yo + hs; yp++)
|
||||||
{
|
{
|
||||||
for (uint32_t xp = x; xp < x + w; xp++)
|
x = xs;
|
||||||
|
for (uint32_t xp = xo; xp < xo + ws; xp++)
|
||||||
{
|
{
|
||||||
uint16_t color = pgm_read_word(data++);
|
uint16_t color = pgm_read_word(data + xp + yp * w);
|
||||||
if(!_iswapBytes) color = color<<8 | color>>8;
|
if(!_iswapBytes) color = color<<8 | color>>8;
|
||||||
_img[xp + yp * _iwidth] = color;
|
_img[x + ys * _iwidth] = color;
|
||||||
|
x++;
|
||||||
}
|
}
|
||||||
|
ys++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (_bpp == 8)
|
else if (_bpp == 8)
|
||||||
{
|
{
|
||||||
for (uint32_t yp = y; yp < y + h; yp++)
|
for (uint32_t yp = yo; yp < yo + hs; yp++)
|
||||||
{
|
{
|
||||||
for (uint32_t xp = x; xp < x + w; xp++)
|
x = xs;
|
||||||
|
for (uint32_t xp = xo; xp < xo + ws; xp++)
|
||||||
{
|
{
|
||||||
uint16_t color = pgm_read_word(data++);
|
uint16_t color = pgm_read_word(data + xp + yp * w);
|
||||||
if(_iswapBytes) color = color<<8 | color>>8;
|
if(_iswapBytes) color = color<<8 | color>>8;
|
||||||
_img8[xp + yp * _iwidth] = (uint8_t)((color & 0xE000)>>8 | (color & 0x0700)>>6 | (color & 0x0018)>>3);
|
_img8[x + ys * _iwidth] = (uint8_t)((color & 0xE000)>>8 | (color & 0x0700)>>6 | (color & 0x0018)>>3);
|
||||||
}
|
}
|
||||||
|
ys++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,9 +22,10 @@ class TFT_eSprite : public TFT_eSPI {
|
|||||||
// Select the frame buffer for graphics
|
// Select the frame buffer for graphics
|
||||||
void* frameBuffer(int8_t f);
|
void* frameBuffer(int8_t f);
|
||||||
|
|
||||||
// Set the colour depth to 8 or 16 bits. Can be used to change depth an existing
|
// Set or get 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.
|
// sprite, but clears it to black, returns a new pointer if sprite is re-created.
|
||||||
void* setColorDepth(int8_t b);
|
void* setColorDepth(int8_t b);
|
||||||
|
int8_t getColorDepth(void);
|
||||||
|
|
||||||
void setBitmapColor(uint16_t c, uint16_t b);
|
void setBitmapColor(uint16_t c, uint16_t b);
|
||||||
|
|
||||||
@@ -34,7 +35,7 @@ class TFT_eSprite : public TFT_eSPI {
|
|||||||
|
|
||||||
fillSprite(uint32_t color),
|
fillSprite(uint32_t color),
|
||||||
|
|
||||||
// Define a window to push 16 bit colour pixels into is a raster order
|
// Define a window to push 16 bit colour pixels into in a raster order
|
||||||
// Colours are converted to 8 bit if depth is set to 8
|
// 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),
|
setWindow(int32_t x0, int32_t y0, int32_t x1, int32_t y1),
|
||||||
pushColor(uint32_t color),
|
pushColor(uint32_t color),
|
||||||
@@ -59,9 +60,23 @@ class TFT_eSprite : public TFT_eSPI {
|
|||||||
// Set the sprite text cursor position for print class (does not change the TFT screen cursor)
|
// 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);
|
||||||
|
|
||||||
|
// Set the rotation of the Sprite (for 1bpp Sprites only)
|
||||||
void setRotation(uint8_t rotation);
|
void setRotation(uint8_t rotation);
|
||||||
uint8_t getRotation(void);
|
uint8_t getRotation(void);
|
||||||
|
|
||||||
|
// Push a rotated copy of Sprite to TFT with optional transparent colour
|
||||||
|
bool pushRotated(int16_t angle, int32_t transp = -1);
|
||||||
|
// Push a rotated copy of Sprite to another different Sprite with optional transparent colour
|
||||||
|
bool pushRotated(TFT_eSprite *spr, int16_t angle, int32_t transp = -1);
|
||||||
|
// Set and get the pivot point for this Sprite
|
||||||
|
void setPivot(int16_t x, int16_t y);
|
||||||
|
int16_t getPivotX(void),
|
||||||
|
getPivotY(void);
|
||||||
|
|
||||||
|
// Get the bounding box for a rotated copy of this Sprite
|
||||||
|
void getRotatedBounds(float sina, float cosa, int16_t w, int16_t h, int16_t xp, int16_t yp,
|
||||||
|
int16_t *min_x, int16_t *min_y, int16_t *max_x, int16_t *max_y);
|
||||||
|
|
||||||
// Read the colour of a pixel at x,y and return value in 565 format
|
// Read the colour of a pixel at x,y and return value in 565 format
|
||||||
uint16_t readPixel(int32_t x0, int32_t y0);
|
uint16_t readPixel(int32_t x0, int32_t y0);
|
||||||
|
|
||||||
@@ -98,15 +113,21 @@ class TFT_eSprite : public TFT_eSPI {
|
|||||||
|
|
||||||
TFT_eSPI *_tft;
|
TFT_eSPI *_tft;
|
||||||
|
|
||||||
|
// Reserve memory for the Sprite and return a pointer
|
||||||
|
void* callocSprite(int16_t width, int16_t height, uint8_t frames = 1);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
uint8_t _bpp;
|
uint8_t _bpp; // bits per pixel (1, 8 or 16)
|
||||||
uint16_t *_img; // pointer to 16 bit sprite
|
uint16_t *_img; // pointer to 16 bit sprite
|
||||||
uint8_t *_img8; // pointer to 8 bit sprite
|
uint8_t *_img8; // pointer to 8 bit sprite
|
||||||
uint8_t *_img8_1; // pointer to frame 1
|
uint8_t *_img8_1; // pointer to frame 1
|
||||||
uint8_t *_img8_2; // pointer to frame 2
|
uint8_t *_img8_2; // pointer to frame 2
|
||||||
|
|
||||||
bool _created; // created and bits per pixel depth flags
|
int16_t _xpivot; // x pivot point coordinate
|
||||||
|
int16_t _ypivot; // y pivot point coordinate
|
||||||
|
|
||||||
|
bool _created; // A Sprite has been created and memory reserved
|
||||||
bool _gFont = false;
|
bool _gFont = false;
|
||||||
|
|
||||||
// int32_t _icursor_x, _icursor_y;
|
// int32_t _icursor_x, _icursor_y;
|
||||||
|
13
README.md
13
README.md
@@ -1,15 +1,20 @@
|
|||||||
|
|
||||||
# News
|
# News
|
||||||
|
|
||||||
1. androdlang has published a really nice companion library to extend the graphics capabilities of TFT_eSPI, you can find this here:
|
1. Sprites can now by pushed to the screen (or another Sprite) with a rotation angle. The new function is pushRotated(). Three new examples (Rotate_Sprite_1/2/3) have been added to show how the functions can be used to rotate text, images and to draw animated dials with moving needles.
|
||||||
|
|
||||||
|
2. A new TFT_eFEX support library has been created which includes extra functions such as drawing a BMP or Jpeg to the screen. This library will simplify the examples. It will be expanded at a future date to include meters, dials and GUI elements like progress bars, graphs and animated buttons:
|
||||||
|
https://github.com/Bodmer/TFT_eFEX
|
||||||
|
|
||||||
|
3. androdlang has published a really nice companion library to extend the graphics capabilities of TFT_eSPI, you can find this here:
|
||||||
https://github.com/androdlang/TFTShape
|
https://github.com/androdlang/TFTShape
|
||||||
|
|
||||||
2. I have created a user updateable graphics extension library template that can be used to create your own graphics extensions. The Library contains examples and is commented so it should be clear what you need to do to add functions. You can find it here:
|
4. I have created a user updateable graphics extension library template that can be used to create your own graphics extensions. The Library contains examples and is commented so it should be clear what you need to do to add functions. You can find it here:
|
||||||
https://github.com/Bodmer/TFT_eFX
|
https://github.com/Bodmer/TFT_eFX
|
||||||
|
|
||||||
3. The capability to read from an ST7789V TFT with a single bidirectional SDA pin has been added. At the moment this **ONLY** works with an ESP32. It is enabled with a #define TFT_SDA_READ in the setup file.
|
5. The capability to read from an ST7789V TFT with a single bidirectional SDA pin has been added. At the moment this **ONLY** works with an ESP32. It is enabled with a #define TFT_SDA_READ in the setup file.
|
||||||
|
|
||||||
4. ST7789V displays are manufactured in two variants that have the red and blue pixels swapped, this is catered for by a new option in the setup file:
|
6. ST7789V displays are manufactured in two variants that have the red and blue pixels swapped, this is catered for by a new option in the setup file:
|
||||||
//#define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue
|
//#define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue
|
||||||
//#define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red
|
//#define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red
|
||||||
|
|
||||||
|
49
TFT_eSPI.cpp
49
TFT_eSPI.cpp
@@ -188,6 +188,9 @@ TFT_eSPI::TFT_eSPI(int16_t w, int16_t h)
|
|||||||
addr_row = 0xFFFF;
|
addr_row = 0xFFFF;
|
||||||
addr_col = 0xFFFF;
|
addr_col = 0xFFFF;
|
||||||
|
|
||||||
|
_xpivot = 0;
|
||||||
|
_ypivot = 0;
|
||||||
|
|
||||||
#ifdef LOAD_GLCD
|
#ifdef LOAD_GLCD
|
||||||
fontsloaded = 0x0002; // Bit 1 set
|
fontsloaded = 0x0002; // Bit 1 set
|
||||||
#endif
|
#endif
|
||||||
@@ -1062,7 +1065,7 @@ void TFT_eSPI::pushImage(int32_t x, int32_t y, uint32_t w, uint32_t h, const uin
|
|||||||
for (int j = 0; j < 64; j++) {
|
for (int j = 0; j < 64; j++) {
|
||||||
pix_buffer[j] = pgm_read_word(&data[i * 64 + j]);
|
pix_buffer[j] = pgm_read_word(&data[i * 64 + j]);
|
||||||
}
|
}
|
||||||
pushColors(pix_buffer, 64, !_swapBytes);
|
pushColors(pix_buffer, 64, _swapBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Work out number of pixels not yet sent
|
// Work out number of pixels not yet sent
|
||||||
@@ -1074,7 +1077,7 @@ void TFT_eSPI::pushImage(int32_t x, int32_t y, uint32_t w, uint32_t h, const uin
|
|||||||
{
|
{
|
||||||
pix_buffer[i] = pgm_read_word(&data[nb * 64 + i]);
|
pix_buffer[i] = pgm_read_word(&data[nb * 64 + i]);
|
||||||
}
|
}
|
||||||
pushColors(pix_buffer, np, !_swapBytes);
|
pushColors(pix_buffer, np, _swapBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
CS_H;
|
CS_H;
|
||||||
@@ -1115,7 +1118,7 @@ void TFT_eSPI::pushImage(int32_t x, int32_t y, uint32_t w, uint32_t h, const uin
|
|||||||
|
|
||||||
uint16_t lineBuf[dw];
|
uint16_t lineBuf[dw];
|
||||||
|
|
||||||
if (_swapBytes) transp = transp >> 8 | transp << 8;
|
if (!_swapBytes) transp = transp >> 8 | transp << 8;
|
||||||
|
|
||||||
while (dh--)
|
while (dh--)
|
||||||
{
|
{
|
||||||
@@ -1140,14 +1143,14 @@ void TFT_eSPI::pushImage(int32_t x, int32_t y, uint32_t w, uint32_t h, const uin
|
|||||||
move = true;
|
move = true;
|
||||||
if (np)
|
if (np)
|
||||||
{
|
{
|
||||||
pushColors(lineBuf, np, !_swapBytes);
|
pushColors(lineBuf, np, _swapBytes);
|
||||||
np = 0;
|
np = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
px++;
|
px++;
|
||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
if (np) pushColors(lineBuf, np, !_swapBytes);
|
if (np) pushColors(lineBuf, np, _swapBytes);
|
||||||
|
|
||||||
y++;
|
y++;
|
||||||
data += w;
|
data += w;
|
||||||
@@ -2097,6 +2100,37 @@ void TFT_eSPI::setTextColor(uint16_t c, uint16_t b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************************
|
||||||
|
** Function name: setPivot
|
||||||
|
** Description: Set the pivot point on the TFT
|
||||||
|
*************************************************************************************x*/
|
||||||
|
void TFT_eSPI::setPivot(int16_t x, int16_t y)
|
||||||
|
{
|
||||||
|
_xpivot = x;
|
||||||
|
_ypivot = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************************
|
||||||
|
** Function name: getPivotX
|
||||||
|
** Description: Get the x pivot position
|
||||||
|
***************************************************************************************/
|
||||||
|
int16_t TFT_eSPI::getPivotX(void)
|
||||||
|
{
|
||||||
|
return _xpivot;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************************
|
||||||
|
** Function name: getPivotY
|
||||||
|
** Description: Get the y pivot position
|
||||||
|
***************************************************************************************/
|
||||||
|
int16_t TFT_eSPI::getPivotY(void)
|
||||||
|
{
|
||||||
|
return _ypivot;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************************
|
/***************************************************************************************
|
||||||
** Function name: setBitmapColor
|
** Function name: setBitmapColor
|
||||||
** Description: Set the foreground foreground and background colour
|
** Description: Set the foreground foreground and background colour
|
||||||
@@ -3272,7 +3306,7 @@ void TFT_eSPI::pushColor(uint16_t color, uint32_t len)
|
|||||||
void TFT_eSPI::startWrite(void)
|
void TFT_eSPI::startWrite(void)
|
||||||
{
|
{
|
||||||
spi_begin();
|
spi_begin();
|
||||||
|
inTransaction = true;
|
||||||
CS_L;
|
CS_L;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3282,9 +3316,8 @@ void TFT_eSPI::startWrite(void)
|
|||||||
***************************************************************************************/
|
***************************************************************************************/
|
||||||
void TFT_eSPI::endWrite(void)
|
void TFT_eSPI::endWrite(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
CS_H;
|
CS_H;
|
||||||
|
inTransaction = false;
|
||||||
spi_end();
|
spi_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
22
TFT_eSPI.h
22
TFT_eSPI.h
@@ -213,12 +213,16 @@
|
|||||||
|
|
||||||
// Use single register write for CS_L and DC_C if pins are both in range 0-31
|
// Use single register write for CS_L and DC_C if pins are both in range 0-31
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
#if (TFT_CS >= 0) && (TFT_CS < 32) && (TFT_DC >= 0) && (TFT_DC < 32)
|
#ifdef TFT_CS
|
||||||
#ifdef RPI_ILI9486_DRIVER // RPi display needs a slower CD and DC change
|
#if (TFT_CS >= 0) && (TFT_CS < 32) && (TFT_DC >= 0) && (TFT_DC < 32)
|
||||||
#define CS_L_DC_C GPIO.out_w1tc = ((1 << TFT_CS) | (1 << TFT_DC)); \
|
#ifdef RPI_ILI9486_DRIVER // RPi display needs a slower CD and DC change
|
||||||
GPIO.out_w1tc = ((1 << TFT_CS) | (1 << TFT_DC))
|
#define CS_L_DC_C GPIO.out_w1tc = ((1 << TFT_CS) | (1 << TFT_DC)); \
|
||||||
|
GPIO.out_w1tc = ((1 << TFT_CS) | (1 << TFT_DC))
|
||||||
|
#else
|
||||||
|
#define CS_L_DC_C GPIO.out_w1tc = ((1 << TFT_CS) | (1 << TFT_DC))
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#define CS_L_DC_C GPIO.out_w1tc = ((1 << TFT_CS) | (1 << TFT_DC))
|
#define CS_L_DC_C CS_L; DC_C
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#define CS_L_DC_C CS_L; DC_C
|
#define CS_L_DC_C CS_L; DC_C
|
||||||
@@ -676,7 +680,7 @@ class TFT_eSPI : public Print {
|
|||||||
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 color),
|
||||||
drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t fgcolor, uint16_t bgcolor),
|
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 fgcolor, uint16_t bgcolor), // For 1bpp sprites
|
setBitmapColor(uint16_t fgcolor, uint16_t bgcolor), // For 1bpp sprites
|
||||||
|
setPivot(int16_t x, int16_t y),
|
||||||
setCursor(int16_t x, int16_t y),
|
setCursor(int16_t x, int16_t y),
|
||||||
setCursor(int16_t x, int16_t y, uint8_t font),
|
setCursor(int16_t x, int16_t y, uint8_t font),
|
||||||
setTextColor(uint16_t color),
|
setTextColor(uint16_t color),
|
||||||
@@ -741,6 +745,9 @@ class TFT_eSPI : public Print {
|
|||||||
int16_t getCursorX(void),
|
int16_t getCursorX(void),
|
||||||
getCursorY(void);
|
getCursorY(void);
|
||||||
|
|
||||||
|
int16_t getPivotX(void),
|
||||||
|
getPivotY(void);
|
||||||
|
|
||||||
uint16_t fontsLoaded(void),
|
uint16_t fontsLoaded(void),
|
||||||
color565(uint8_t red, uint8_t green, uint8_t blue), // Convert 8 bit red, green and blue to 16 bits
|
color565(uint8_t red, uint8_t green, uint8_t blue), // Convert 8 bit red, green and blue to 16 bits
|
||||||
color8to16(uint8_t color332); // Convert 8 bit colour to 16 bits
|
color8to16(uint8_t color332); // Convert 8 bit colour to 16 bits
|
||||||
@@ -798,6 +805,9 @@ class TFT_eSPI : public Print {
|
|||||||
textdatum, // Text reference datum
|
textdatum, // Text reference datum
|
||||||
rotation; // Display rotation (0-3)
|
rotation; // Display rotation (0-3)
|
||||||
|
|
||||||
|
int16_t _xpivot; // x pivot point coordinate
|
||||||
|
int16_t _ypivot; // x pivot point coordinate
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
inline void spi_begin() __attribute__((always_inline));
|
inline void spi_begin() __attribute__((always_inline));
|
||||||
|
@@ -66,6 +66,11 @@
|
|||||||
// #define ST7735_BLACKTAB
|
// #define ST7735_BLACKTAB
|
||||||
// #define ST7735_REDTAB160x80 // For 160 x 80 display (24 offset) (https://www.aliexpress.com/item/ShengYang-1pcs-IPS-0-96-inch-7P-SPI-HD-65K-Full-Color-OLED-Module-ST7735-Drive/32918394604.html)
|
// #define ST7735_REDTAB160x80 // For 160 x 80 display (24 offset) (https://www.aliexpress.com/item/ShengYang-1pcs-IPS-0-96-inch-7P-SPI-HD-65K-Full-Color-OLED-Module-ST7735-Drive/32918394604.html)
|
||||||
|
|
||||||
|
// If colours are inverted (white shows as black) then uncomment one of the next
|
||||||
|
// 2 lines try both options, one of the options should correct the inversion.
|
||||||
|
//#define TFT_INVERSION_ON
|
||||||
|
//#define TFT_INVERSION_OFF
|
||||||
|
|
||||||
// ##################################################################################
|
// ##################################################################################
|
||||||
//
|
//
|
||||||
// Section 1. Define the pins that are used to interface with the display here
|
// Section 1. Define the pins that are used to interface with the display here
|
||||||
|
@@ -1,42 +0,0 @@
|
|||||||
// We need this header file to use FLASH as storage with PROGMEM directive:
|
|
||||||
#include <pgmspace.h>
|
|
||||||
|
|
||||||
// Icon width and height
|
|
||||||
const uint16_t alertWidth = 32;
|
|
||||||
const uint16_t alertHeight = 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 alert[1024] PROGMEM={
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0840,0x0000,0x0000,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,0x0000,0x0000,0x0000,0x1080,0xAC66,0xEDE8,0xFE69,0xC4C6,0x2901,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 1, 64 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xBCC6,0xFE68,0xFE68,0xFE6A,0xFE68,0xEDE8,0x18A1,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 2, 96 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x8344,0xFE48,0xFE8C,0xFFDD,0xFFFF,0xFEF0,0xFE48,0xB466,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 3, 128 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1880,0xEDC7,0xFE48,0xFF99,0xFFBC,0xFF9B,0xFFBD,0xFE6A,0xFE48,0x5A23,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 4, 160 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x9BE5,0xFE28,0xFED0,0xFFBC,0xFF7A,0xFF9A,0xFF9B,0xFF35,0xFE28,0xBCA6,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 5, 192 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3962,0xFE28,0xFE28,0xFF9A,0xFF79,0xFF9A,0xFF9B,0xFF9A,0xFFBD,0xFE6B,0xFE28,0x72E3,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 6, 224 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xB465,0xFE28,0xFEF2,0xFF7A,0xFF79,0xFF7A,0xFF9A,0xFF7A,0xFF7A,0xFF78,0xFE28,0xDD67,0x0860,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 7, 256 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x5A22,0xFE07,0xFE29,0xFF9B,0xFF37,0xFF58,0xFF79,0xFF79,0xFF79,0xFF58,0xFF9B,0xFEAE,0xFE07,0x93A4,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 8, 288 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xC4A5,0xFE07,0xFF15,0xFF37,0xFF36,0xAD11,0x2965,0x2965,0xCDF4,0xFF37,0xFF37,0xFF79,0xFE07,0xFE07,0x2901,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 9, 320 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x7B03,0xFDE7,0xFE4B,0xFF79,0xFEF4,0xFF15,0xB552,0x2945,0x2945,0xDE55,0xFF16,0xFF15,0xFF58,0xFED1,0xFDE7,0xAC25,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 10, 352 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0840,0xDD26,0xFDE7,0xFF57,0xFED3,0xFED2,0xFEF4,0xBD93,0x2124,0x2124,0xDE75,0xFF14,0xFED3,0xFED3,0xFF7A,0xFE08,0xFDE7,0x49A2,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 11, 384 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x9BA4,0xFDC6,0xFE6E,0xFF36,0xFE90,0xFEB1,0xFED3,0xC592,0x2124,0x2124,0xE675,0xFED3,0xFEB2,0xFEB1,0xFEF3,0xFEF3,0xFDC6,0xBC45,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 12, 416 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3141,0xF5C6,0xF5C7,0xFF58,0xFE90,0xFE6F,0xFE8F,0xFEB1,0xCDB2,0x2104,0x2104,0xF6B4,0xFEB1,0xFE90,0xFE8F,0xFE90,0xFF58,0xFE0A,0xF5C6,0x72A3,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 13, 448 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xABE4,0xF5A6,0xFEB1,0xFED3,0xFE4E,0xFE6E,0xFE6F,0xFE90,0xD5F2,0x18E3,0x18E3,0xFED4,0xFE90,0xFE6F,0xFE6F,0xFE6E,0xFE91,0xFF36,0xF5A6,0xCCA5,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 14, 480 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x5202,0xF5A6,0xF5C7,0xFF58,0xFE4D,0xFE4D,0xFE4D,0xFE4E,0xFE6F,0xDE11,0x18C3,0x18C3,0xFED3,0xFE6F,0xFE6E,0xFE4E,0xFE4D,0xFE4D,0xFF16,0xFE2C,0xF5A6,0x9363,0x0000,0x0000,0x0000,0x0000,0x0000, // row 15, 512 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0xBC44,0xF585,0xFED3,0xFE6F,0xFE2C,0xFE2C,0xFE2D,0xFE4D,0xFE4E,0xE630,0x10A2,0x2104,0xFED1,0xFE4E,0xFE4D,0xFE4D,0xFE2D,0xFE2C,0xFE4D,0xFF37,0xF586,0xF585,0x28E1,0x0000,0x0000,0x0000,0x0000, // row 16, 544 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x7282,0xF565,0xF5EA,0xFF16,0xFE0B,0xFE0B,0xFE0B,0xFE2C,0xFE2C,0xFE4D,0xF670,0x1082,0x2924,0xFEB0,0xFE2D,0xFE2C,0xFE2C,0xFE2C,0xFE0B,0xFE0B,0xFEB2,0xFE6F,0xF565,0xA383,0x0000,0x0000,0x0000,0x0000, // row 17, 576 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0840,0xD4C4,0xF565,0xFEF5,0xFE0C,0xFDE9,0xFDEA,0xFE0A,0xFE0B,0xFE0B,0xFE2C,0xFE8F,0x0861,0x2964,0xFE8F,0xFE2C,0xFE0B,0xFE0B,0xFE0B,0xFE0A,0xFDEA,0xFE0B,0xFF37,0xF586,0xF565,0x4181,0x0000,0x0000,0x0000, // row 18, 608 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x9343,0xF545,0xF60C,0xFED3,0xFDC8,0xFDC8,0xFDC9,0xFDE9,0xFDEA,0xFDEA,0xFE0B,0xFE8E,0x0861,0x3184,0xFE6D,0xFE0B,0xFE0A,0xFDEA,0xFDEA,0xFDE9,0xFDC9,0xFDC9,0xFE4E,0xFEB2,0xF545,0xB3E3,0x0000,0x0000,0x0000, // row 19, 640 pixels
|
|
||||||
0x0000,0x0000,0x28E0,0xF544,0xF545,0xFF17,0xFDC8,0xFDA7,0xFDA7,0xFDC8,0xFDC8,0xFDC9,0xFDC9,0xFDE9,0xFE6C,0x10A2,0x39C4,0xFE4C,0xFDEA,0xFDE9,0xFDC9,0xFDC9,0xFDC8,0xFDC8,0xFDA7,0xFDA8,0xFF16,0xF588,0xF544,0x6222,0x0000,0x0000, // row 20, 672 pixels
|
|
||||||
0x0000,0x0000,0xA383,0xF524,0xF64E,0xFE4E,0xFD86,0xFD86,0xFD87,0xFDA7,0xFDA7,0xFDA8,0xFDC8,0xFDC8,0xFE2A,0xA469,0xB4EA,0xFE2A,0xFDC9,0xFDC8,0xFDC8,0xFDA8,0xFDA7,0xFDA7,0xFD87,0xFD86,0xFDEA,0xFED3,0xF524,0xC443,0x0000,0x0000, // row 21, 704 pixels
|
|
||||||
0x0000,0x51C1,0xF504,0xF546,0xFF16,0xF565,0xFD65,0xFD65,0xFD86,0xFD86,0xFD86,0xFDA7,0xFDA7,0xFDA7,0xFDE8,0xFE6A,0xFE4A,0xFDE8,0xFDA7,0xFDA7,0xFDA7,0xFDA7,0xFD86,0xFD86,0xFD86,0xFD65,0xFD65,0xFEB2,0xF5CA,0xF504,0x8AE2,0x0000, // row 22, 736 pixels
|
|
||||||
0x0000,0xB3A2,0xED03,0xFE92,0xFDC9,0xF543,0xF544,0xFD44,0xFD65,0xFD65,0xFD65,0xFD86,0xFD86,0xFD86,0xFDA7,0xFDC7,0xFDC7,0xFDA7,0xFD86,0xFD86,0xFD86,0xFD86,0xFD65,0xFD65,0xFD65,0xFD44,0xF544,0xFD86,0xFEF5,0xED03,0xE4C3,0x1880, // row 23, 768 pixels
|
|
||||||
0x7241,0xECE3,0xF567,0xFED3,0xF523,0xF523,0xF523,0xF543,0xF544,0xF544,0xFD65,0xFD65,0xFD65,0xFD65,0xD4E6,0x39C5,0x39A5,0xD4E6,0xFD86,0xFD65,0xFD65,0xFD65,0xFD65,0xF544,0xF544,0xF543,0xF523,0xF523,0xFE2E,0xF5EC,0xECE3,0x9B42, // row 24, 800 pixels
|
|
||||||
0xD443,0xECE3,0xFED4,0xF565,0xF502,0xF502,0xF522,0xF523,0xF523,0xF543,0xF544,0xF544,0xF544,0xFD65,0x8B64,0x18C3,0x18C3,0x8344,0xFD85,0xFD44,0xF544,0xF544,0xF544,0xF543,0xF523,0xF523,0xF522,0xF502,0xF523,0xFEF5,0xED04,0xECE3, // row 25, 832 pixels
|
|
||||||
0xECC3,0xF5AB,0xFE6F,0xF501,0xF4E1,0xF501,0xF502,0xF502,0xF522,0xF522,0xF523,0xF523,0xF523,0xFD84,0xC504,0x20E1,0x18E1,0xC4E4,0xFD84,0xF543,0xF523,0xF523,0xF523,0xF522,0xF522,0xF502,0xF502,0xF501,0xF501,0xFDC9,0xF62F,0xECC3, // row 26, 864 pixels
|
|
||||||
0xECC2,0xFE92,0xF523,0xF4E0,0xF4E0,0xF4E1,0xF4E1,0xF501,0xF501,0xF502,0xF502,0xF522,0xF522,0xF543,0xFDE3,0xFEA5,0xF6A4,0xFE04,0xF543,0xF522,0xF522,0xF522,0xF502,0xF502,0xF501,0xF501,0xF4E1,0xF4E1,0xF4E0,0xF4E1,0xFED4,0xECC2, // row 27, 896 pixels
|
|
||||||
0xECA2,0xF5EC,0xF4E0,0xF4C0,0xF4E0,0xF4E0,0xF4E0,0xF4E1,0xF4E1,0xF501,0xF501,0xF501,0xF502,0xF502,0xF542,0xFDA2,0xFDA2,0xF542,0xF502,0xF502,0xF502,0xF501,0xF501,0xF501,0xF4E1,0xF4E1,0xF4E0,0xF4E0,0xF4E0,0xF4C0,0xF5A9,0xECA2, // row 28, 928 pixels
|
|
||||||
0xECA2,0xECA2,0xECC2,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4E1,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xECC2,0xECC3,0xECA2, // row 29, 960 pixels
|
|
||||||
0x8AC1,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0x9B01, // row 30, 992 pixels
|
|
||||||
0x0000,0x1880,0x51A0,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x61E0,0x28E0,0x0000}; // row 31, 1024 pixels
|
|
||||||
|
|
@@ -1,41 +0,0 @@
|
|||||||
// We need this header file to use FLASH as storage with PROGMEM directive:
|
|
||||||
#include <pgmspace.h>
|
|
||||||
|
|
||||||
// Icon width and height
|
|
||||||
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 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
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x2041,0x8945,0xF34D,0xFD34,0xFDB6,0xFD75,0xFD55,0xFD55,0xFD96,0xFDD7,0xFDF7,0xFDF7,0xFDB6,0xFDB6,0xFDD7,0xFDF7,0xFD75,0xF38E,0x8965,0x2041,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 3, 128 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x4082,0xE208,0xF410,0xFD34,0xFC92,0xFBEF,0xFBAE,0xFBEF,0xFC71,0xFD14,0xFD75,0xFDB6,0xFD75,0xFD14,0xFC92,0xFC51,0xFC71,0xFCF3,0xFD75,0xFC30,0xEA28,0x40A2,0x0000,0x0000,0x0000,0x0000,0x0000, // row 4, 160 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x3861,0xE1E7,0xF451,0xFC92,0xFB4D,0xFA49,0xFA49,0xFAEB,0xFBAE,0xFC71,0xFD34,0xFDB6,0xFE18,0xFDB6,0xFD34,0xFC71,0xFBAE,0xFB0C,0xFAEB,0xFBAE,0xFCD3,0xFC71,0xE208,0x4082,0x0000,0x0000,0x0000,0x0000, // row 5, 192 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x1020,0xD986,0xF430,0xFC30,0xFA28,0xF924,0xF965,0xFA8A,0xFB0C,0xFBAE,0xFC51,0xFD14,0xFD75,0xFDB6,0xFD75,0xFD14,0xFC51,0xFC71,0xFBEF,0xFA28,0xF9C7,0xFA8A,0xFC51,0xF430,0xD9A6,0x1020,0x0000,0x0000,0x0000, // row 6, 224 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x78A2,0xEB6D,0xFC30,0xF9C7,0xF861,0xF8A2,0xFA08,0xFEDB,0xFD55,0xFB4D,0xFC10,0xFC92,0xFD14,0xFD34,0xFD14,0xFC92,0xFCB2,0xFF7D,0xFF7D,0xFB2C,0xF945,0xF8E3,0xF9E7,0xFC30,0xEB8E,0x78C3,0x0000,0x0000,0x0000, // row 7, 256 pixels
|
|
||||||
0x0000,0x0000,0x3841,0xD9E7,0xF492,0xF208,0xF041,0xF800,0xF945,0xFE9A,0xFFFF,0xFFFF,0xFD75,0xFB8E,0xFC10,0xFC51,0xFC71,0xFC51,0xFCB2,0xFF7D,0xFFFF,0xFFFF,0xFF3C,0xFA8A,0xF882,0xF841,0xFA08,0xFC92,0xDA08,0x3841,0x0000,0x0000, // row 8, 288 pixels
|
|
||||||
0x0000,0x0000,0x88A2,0xEBCF,0xF2EB,0xF061,0xF000,0xF8E3,0xFE79,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFD75,0xFB4D,0xFBAE,0xFBAE,0xFC71,0xFF7D,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFEFB,0xFA28,0xF800,0xF061,0xF2EB,0xEBEF,0x90C3,0x0000,0x0000, // row 9, 320 pixels
|
|
||||||
0x0000,0x2820,0xD1C7,0xF410,0xE945,0xE800,0xF000,0xFE9A,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFD34,0xFAEB,0xFBCF,0xFF5D,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFF1C,0xF986,0xF000,0xF145,0xF410,0xD1E7,0x2820,0x0000, // row 10, 352 pixels
|
|
||||||
0x0000,0x6841,0xDB2C,0xEACB,0xE041,0xE800,0xF000,0xFEFB,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFD14,0xFF1C,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFBCF,0xF082,0xF000,0xE841,0xEACB,0xE34D,0x7061,0x0000, // row 11, 384 pixels
|
|
||||||
0x0000,0x9861,0xE3CF,0xE186,0xE000,0xE800,0xE800,0xF145,0xFEDB,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFB8E,0xF000,0xF000,0xE800,0xE800,0xE986,0xEBCF,0xA082,0x0000, // row 12, 416 pixels
|
|
||||||
0x0800,0xB8A2,0xE3AE,0xD8A2,0xD800,0xE000,0xE800,0xE800,0xF145,0xFEFB,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFB8E,0xF000,0xF000,0xE800,0xE800,0xE000,0xE0A2,0xEBAE,0xC0C3,0x0800, // row 13, 448 pixels
|
|
||||||
0x1800,0xC124,0xE30C,0xD020,0xD800,0xE000,0xE000,0xE800,0xE800,0xF145,0xFEDB,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFB8E,0xF000,0xF000,0xE800,0xE800,0xE000,0xE000,0xD820,0xE30C,0xC124,0x1800, // row 14, 480 pixels
|
|
||||||
0x2800,0xC165,0xDAAA,0xC800,0xD000,0xD800,0xE000,0xE000,0xE800,0xE800,0xF124,0xFE79,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFB6D,0xF000,0xF000,0xE800,0xE800,0xE000,0xE000,0xD800,0xD000,0xDAAA,0xC165,0x2800, // row 15, 512 pixels
|
|
||||||
0x2000,0xB924,0xD269,0xC800,0xD000,0xD000,0xD800,0xE000,0xE000,0xE800,0xE924,0xFEFB,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xF36D,0xE800,0xE800,0xE800,0xE000,0xE000,0xD800,0xD000,0xD000,0xDA69,0xC145,0x2800, // row 16, 544 pixels
|
|
||||||
0x1000,0xB0A2,0xD28A,0xC000,0xC800,0xD000,0xD000,0xD800,0xD800,0xE165,0xFEFB,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xF3AE,0xE000,0xE000,0xD800,0xD800,0xD000,0xD000,0xC800,0xD28A,0xB8C3,0x1000, // row 17, 576 pixels
|
|
||||||
0x0000,0xA800,0xD2AA,0xB800,0xC000,0xC800,0xC800,0xD000,0xD965,0xFEFB,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xEBAE,0xD800,0xD800,0xD000,0xC800,0xC800,0xC000,0xD2AA,0xB020,0x0000, // row 18, 608 pixels
|
|
||||||
0x0000,0x8000,0xCA69,0xB841,0xB800,0xC000,0xC800,0xD186,0xFEFB,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xEBCF,0xD000,0xC800,0xC800,0xC000,0xC041,0xCA69,0x8000,0x0000, // row 19, 640 pixels
|
|
||||||
0x0000,0x4800,0xC1C7,0xB8E3,0xB800,0xB800,0xC000,0xF69A,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xEBEF,0xFE79,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xE410,0xC841,0xC000,0xB800,0xC0E3,0xC1C7,0x4800,0x0000, // row 20, 672 pixels
|
|
||||||
0x0000,0x1000,0xB061,0xC1E7,0xB000,0xB000,0xB800,0xD269,0xFFBE,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xE38E,0xD000,0xD965,0xF69A,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xDB0C,0xC020,0xB800,0xB000,0xC1E7,0xB061,0x1000,0x0000, // row 21, 704 pixels
|
|
||||||
0x0000,0x0000,0x6000,0xB9C7,0xB061,0xB000,0xB000,0xB800,0xCA49,0xFF9E,0xFFFF,0xFFFF,0xFFFF,0xE38E,0xC800,0xC800,0xC800,0xD186,0xF69A,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xDB0C,0xB800,0xB800,0xB000,0xB061,0xC1C7,0x6000,0x0000,0x0000, // row 22, 736 pixels
|
|
||||||
0x0000,0x0000,0x1800,0xB041,0xB986,0xA800,0xA800,0xB000,0xB000,0xCA49,0xFF7D,0xFFFF,0xDB8E,0xC000,0xC000,0xC000,0xC000,0xC000,0xC986,0xF6DB,0xFFFF,0xFFFF,0xD30C,0xB800,0xB000,0xB000,0xA800,0xB986,0xB041,0x1800,0x0000,0x0000, // row 23, 768 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x5800,0xB0E3,0xA8C3,0xA800,0xA800,0xA800,0xB000,0xCACB,0xD38E,0xB000,0xB800,0xB800,0xB800,0xB800,0xB800,0xB800,0xC145,0xF6DB,0xD34D,0xB000,0xB000,0xA800,0xA800,0xB0C3,0xB0E3,0x5800,0x0000,0x0000,0x0000, // row 24, 800 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x6000,0xB124,0xA882,0xA000,0xA800,0xA800,0xA800,0xA800,0xB000,0xB000,0xB000,0xB000,0xB000,0xB000,0xB000,0xB000,0xB000,0xA800,0xA800,0xA800,0xA800,0xA882,0xB124,0x6000,0x0000,0x0000,0x0000,0x0000, // row 25, 832 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x6000,0xB104,0xA882,0xA000,0xA000,0xA000,0xA800,0xA800,0xA800,0xA800,0xA800,0xA800,0xA800,0xA800,0xA800,0xA800,0xA800,0xA000,0xA000,0xA882,0xB104,0x6000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 26, 864 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x6000,0xB0A2,0xA8C3,0xA020,0xA000,0xA000,0xA000,0xA000,0xA000,0xA000,0xA000,0xA000,0xA000,0xA000,0xA000,0xA000,0xA020,0xA8C3,0xB0A2,0x6000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 27, 896 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x4800,0xA800,0xB0C3,0xA0A2,0x9800,0x9800,0x9800,0x9800,0xA000,0xA000,0xA000,0x9800,0x9800,0x9800,0xA082,0xB0E3,0xA800,0x4800,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 28, 928 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x5800,0xA800,0xB0A2,0xA8E3,0xA0A2,0xA041,0x9800,0x9800,0xA041,0xA0A2,0xA8E3,0xB0A2,0xA800,0x5800,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 29, 960 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3000,0x6000,0x8800,0xA000,0xA800,0xA800,0xA000,0x8800,0x6000,0x3000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 30, 992 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000}; // row 31, 1024 pixels
|
|
@@ -1,110 +0,0 @@
|
|||||||
// Code partly derived from ILI9341_Due library example
|
|
||||||
|
|
||||||
// Draws the 3 icons across the middle of the screen and pauses.
|
|
||||||
// Then draws 300 icons at random locations, clears screen and repeats
|
|
||||||
//
|
|
||||||
// This demonstrates drawing icons from FLASH
|
|
||||||
|
|
||||||
// Icons are stored in tabs, e.g. Alert.h etc
|
|
||||||
// more than one icon can be in a header file.
|
|
||||||
|
|
||||||
// Original sketch header follow:
|
|
||||||
/*
|
|
||||||
This sketch demonstrates loading images from arrays stored in program (FLASH) memory.
|
|
||||||
|
|
||||||
This sketch does not use/need any fonts at all...
|
|
||||||
|
|
||||||
Arrays containing FLASH images can be created with UTFT library tool:
|
|
||||||
(libraries\UTFT\Tools\ImageConverter565.exe)
|
|
||||||
Convert to .c format then copy into a new tab
|
|
||||||
|
|
||||||
The number and size of icons is limited by available FLASH memory. The icon array will
|
|
||||||
use width x height x 2 bytes of FLASH, i.e. 32 x 32 icon uses ~2048 bytes
|
|
||||||
|
|
||||||
*/
|
|
||||||
#include <TFT_eSPI.h> // Graphics and font library for ST7735 driver chip
|
|
||||||
#include <SPI.h>
|
|
||||||
|
|
||||||
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 "Close.h"
|
|
||||||
#include "Info.h"
|
|
||||||
|
|
||||||
long count = 0; // Loop count
|
|
||||||
|
|
||||||
void setup()
|
|
||||||
{
|
|
||||||
Serial.begin(115200);
|
|
||||||
tft.init();
|
|
||||||
tft.setRotation(1); // landscape
|
|
||||||
|
|
||||||
tft.fillScreen(TFT_BLACK);
|
|
||||||
|
|
||||||
// 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(closeX, (tft.width() - closeWidth)/2 + 50, (tft.height() - closeHeight)/2, closeWidth, closeHeight);
|
|
||||||
|
|
||||||
// Pause here to admire the icons!
|
|
||||||
delay(4000);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
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(closeX, random(tft.width() - closeWidth), random(tft.height() - closeHeight), alertWidth, closeHeight);
|
|
||||||
|
|
||||||
// Clear screen after 100 x 3 = 300 icons drawn
|
|
||||||
if (100 == count++) {
|
|
||||||
count = 1;
|
|
||||||
tft.setRotation(2 * random(2)); // Rotate randomly to clear display left>right or right>left to reduce monotony!
|
|
||||||
tft.fillScreen(TFT_BLACK);
|
|
||||||
tft.setRotation(1);
|
|
||||||
Serial.println(millis());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//====================================================================================
|
|
||||||
// This is the function to draw the icon stored as an array in program memory (FLASH)
|
|
||||||
//====================================================================================
|
|
||||||
|
|
||||||
// To speed up rendering we use a 64 pixel buffer
|
|
||||||
#define BUFF_SIZE 64
|
|
||||||
|
|
||||||
// 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, uint16_t width, uint16_t height) {
|
|
||||||
|
|
||||||
uint16_t pix_buffer[BUFF_SIZE]; // Pixel buffer (16 bits per pixel)
|
|
||||||
|
|
||||||
// Set up a window the right size to stream pixels into
|
|
||||||
tft.setAddrWindow(x, y, x + width - 1, y + height - 1);
|
|
||||||
|
|
||||||
// Work out the number whole buffers to send
|
|
||||||
uint16_t nb = ((uint16_t)height * width) / BUFF_SIZE;
|
|
||||||
|
|
||||||
// Fill and send "nb" buffers to TFT
|
|
||||||
for (int i = 0; i < nb; i++) {
|
|
||||||
for (int j = 0; j < BUFF_SIZE; j++) {
|
|
||||||
pix_buffer[j] = pgm_read_word(&icon[i * BUFF_SIZE + j]);
|
|
||||||
}
|
|
||||||
tft.pushColors(pix_buffer, BUFF_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Work out number of pixels not yet sent
|
|
||||||
uint16_t np = ((uint16_t)height * width) % BUFF_SIZE;
|
|
||||||
|
|
||||||
// Send any partial buffer left over
|
|
||||||
if (np) {
|
|
||||||
for (int i = 0; i < np; i++) pix_buffer[i] = pgm_read_word(&icon[nb * BUFF_SIZE + i]);
|
|
||||||
tft.pushColors(pix_buffer, np);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@@ -1,41 +0,0 @@
|
|||||||
// We need this header file to use FLASH as storage with PROGMEM directive:
|
|
||||||
#include <pgmspace.h>
|
|
||||||
|
|
||||||
// Icon width and height
|
|
||||||
const uint16_t infoWidth = 32;
|
|
||||||
const uint16_t infoHeight = 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 info[1024] PROGMEM={
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,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,0x0000,0x0861,0x4A69,0x8C71,0xA514,0xBDF7,0xBDF7,0xA514,0x8C71,0x4A69,0x0861,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 1, 64 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x39E7,0x9CF3,0xEF7D,0xF79E,0xFFDF,0xFFDF,0xFFDF,0xFFDF,0xFFDF,0xFFDF,0xF79E,0xEF7D,0x9CF3,0x39E7,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 2, 96 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x2965,0x9492,0xF79E,0xFFDF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFDF,0xF79E,0x9492,0x2965,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 3, 128 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x630C,0xEF7D,0xFFDF,0xFFFF,0xFFFF,0xFFFF,0xD75F,0xB6BF,0x9E5F,0x963F,0x963F,0x9E5F,0xB6BF,0xD75F,0xFFFF,0xFFFF,0xFFFF,0xFFDF,0xEF7D,0x630C,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 4, 160 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x73AE,0xEF7D,0xFFDF,0xFFFF,0xFFDF,0xBEDF,0x7DBF,0x7DBF,0x7DDF,0x7DDF,0x7DDF,0x7DDF,0x7DDF,0x7DBF,0x759F,0x7DBE,0xBEBF,0xFFDF,0xFFFF,0xFFDF,0xEF7D,0x73AE,0x0000,0x0000,0x0000,0x0000,0x0000, // row 5, 192 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x630C,0xEF7D,0xFFFF,0xFFFF,0xE77F,0x7DBE,0x759E,0x759F,0x7DBF,0x7DDF,0x7DDF,0x85FF,0x7DDF,0x7DDF,0x7DBF,0x759F,0x759E,0x6D7E,0x7DBE,0xDF7F,0xFFFF,0xFFFF,0xEF7D,0x630C,0x0000,0x0000,0x0000,0x0000, // row 6, 224 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x31A6,0xEF5D,0xFFDF,0xFFFF,0xCF1E,0x6D7E,0x6D7E,0x759E,0x759F,0x7DBF,0x7DDF,0x8E1F,0xBEDF,0xC6FF,0x8DFF,0x75BF,0x759F,0x759E,0x6D7E,0x655E,0x655D,0xCF1E,0xFFFF,0xFFDF,0xEF5D,0x31A6,0x0000,0x0000,0x0000, // row 7, 256 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x94B2,0xF7BE,0xFFFF,0xDF5E,0x655D,0x655D,0x6D7E,0x6D7E,0x759E,0x75BF,0x759F,0xEFBF,0xFFFF,0xFFFF,0xEFBF,0x759F,0x759E,0x6D7E,0x6D7E,0x655D,0x653D,0x653D,0xDF5E,0xFFFF,0xF7BE,0x94B2,0x0000,0x0000,0x0000, // row 8, 288 pixels
|
|
||||||
0x0000,0x0000,0x4228,0xEF7D,0xFFFF,0xF7BF,0x6D5D,0x653D,0x655D,0x6D5E,0x6D7E,0x759E,0x759E,0x85DF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0x8DFE,0x6D7E,0x6D7E,0x6D5E,0x655D,0x653D,0x5D1D,0x6D5D,0xF7BF,0xFFFF,0xEF7D,0x4228,0x0000,0x0000, // row 9, 320 pixels
|
|
||||||
0x0000,0x0000,0xA534,0xFFDF,0xFFDF,0xA65D,0x5D1D,0x5D1D,0x653D,0x655E,0x6D7E,0x6D7E,0x6D7E,0x651E,0xE77F,0xFFFF,0xFFFF,0xF7BF,0x5CFE,0x6D7E,0x6D7E,0x655E,0x653D,0x5D1D,0x5D1D,0x54FC,0xA65D,0xFFDF,0xFFDF,0xA534,0x0000,0x0000, // row 10, 352 pixels
|
|
||||||
0x0000,0x18E3,0xEF5D,0xFFFF,0xEF9E,0x5CFC,0x54FC,0x5D1D,0x5D3D,0x653D,0x655E,0x6D7E,0x6D7E,0x653E,0x6D3E,0xB67E,0xBEBE,0x755E,0x5D1E,0x6D5E,0x655E,0x653D,0x5D3D,0x5D1D,0x54FC,0x54DC,0x54FC,0xEF9E,0xFFFF,0xEF5D,0x18E3,0x0000, // row 11, 384 pixels
|
|
||||||
0x0000,0x630C,0xEF7D,0xFFDF,0xB69D,0x54DC,0x54FC,0x5CFC,0x5D1D,0x653D,0x653D,0x655E,0x6D5E,0x655E,0x5CFE,0x4C9D,0x4C7D,0x54DD,0x653E,0x655E,0x653D,0x653D,0x5D1D,0x5CFC,0x54FC,0x54DC,0x4CBC,0xB69D,0xFFDF,0xEF7D,0x630C,0x0000, // row 12, 416 pixels
|
|
||||||
0x0000,0x94B2,0xF7BE,0xFFDF,0x85BC,0x4CBC,0x54DC,0x54FC,0x5CFD,0x5D1D,0x5D3D,0x653D,0x655D,0x653D,0x85DE,0xC6FE,0xC6FE,0x85BE,0x653D,0x653D,0x5D3D,0x5D1D,0x5CFD,0x54FC,0x54DC,0x4CBC,0x4CBB,0x85BC,0xFFDF,0xF7BE,0x94B2,0x0000, // row 13, 448 pixels
|
|
||||||
0x0000,0xB5B6,0xFFDF,0xF7BE,0x651C,0x4CBB,0x4CBC,0x54DC,0x54FC,0x5CFC,0x5D1D,0x5D1D,0x653D,0x5D1D,0xE77E,0xFFDF,0xFFDF,0xEF9E,0x5CFD,0x5D1D,0x5D1D,0x5CFC,0x54FC,0x54DC,0x4CBC,0x4CBB,0x449B,0x651B,0xF7BE,0xFFDF,0xB5B6,0x0000, // row 14, 480 pixels
|
|
||||||
0x0000,0xC638,0xFFDF,0xF7BE,0x54DB,0x449B,0x4CBB,0x4CBC,0x54DC,0x54FC,0x54FC,0x5D1D,0x5D1D,0x7D7D,0xF7BE,0xF7BE,0xF7BE,0xF7BE,0x7D7D,0x5CFD,0x54FC,0x54FC,0x54DC,0x4CBC,0x4CBB,0x449B,0x447B,0x54BB,0xF7BE,0xFFDF,0xC638,0x0000, // row 15, 512 pixels
|
|
||||||
0x0000,0xC638,0xFFDF,0xF79E,0x4CBB,0x449B,0x449B,0x4CBB,0x4CBC,0x54DC,0x54DC,0x54FC,0x54DC,0x753C,0xF7BE,0xF7BE,0xF7BE,0xF7BE,0x753C,0x54DC,0x54DC,0x54DC,0x4CBC,0x4CBB,0x449B,0x449B,0x3C7B,0x4C9B,0xF79E,0xFFDF,0xC638,0x0000, // row 16, 544 pixels
|
|
||||||
0x0000,0xB5B6,0xFFDF,0xF7BE,0x5CFB,0x3C7B,0x447B,0x449B,0x4CBB,0x4CBC,0x4CBC,0x4CDC,0x4CBC,0x6D1C,0xF7BE,0xF7BE,0xF7BE,0xF7BE,0x6CFC,0x4CBC,0x4CBC,0x4CBC,0x4CBB,0x449B,0x447B,0x3C7B,0x3C5A,0x54DB,0xF7BE,0xFFDF,0xB5B6,0x0000, // row 17, 576 pixels
|
|
||||||
0x0000,0x94B2,0xF7BE,0xF7BE,0x755B,0x3C5A,0x3C7B,0x447B,0x449B,0x449B,0x4CBB,0x4CBB,0x4C9B,0x6CFB,0xF79E,0xF79E,0xF79E,0xF79E,0x64FB,0x449B,0x4CBB,0x449B,0x449B,0x447B,0x3C7B,0x3C5A,0x3C5A,0x753B,0xF7BE,0xF7BE,0x9CD3,0x0000, // row 18, 608 pixels
|
|
||||||
0x0000,0x6B4D,0xEF7D,0xF7BE,0xA61C,0x3C5A,0x3C5A,0x3C7B,0x447B,0x447B,0x449B,0x449B,0x447B,0x64DB,0xF79E,0xF79E,0xF79E,0xF79E,0x64DB,0x447B,0x449B,0x447B,0x447B,0x3C7B,0x3C5A,0x3C5A,0x343A,0xA61C,0xF7BE,0xEF7D,0x6B4D,0x0000, // row 19, 640 pixels
|
|
||||||
0x0000,0x2124,0xE71C,0xFFDF,0xDF3D,0x3C5A,0x343A,0x3C5A,0x3C5A,0x3C7B,0x3C7B,0x447B,0x3C5B,0x64BA,0xF79E,0xF79E,0xF79E,0xF79E,0x64BA,0x3C5B,0x3C7B,0x3C7B,0x3C5A,0x3C5A,0x343A,0x343A,0x343A,0xDF3D,0xFFDF,0xE71C,0x2124,0x0000, // row 20, 672 pixels
|
|
||||||
0x0000,0x0000,0xAD75,0xF7BE,0xF79E,0x859B,0x343A,0x343A,0x345A,0x3C5A,0x3C5A,0x3C5A,0x3C5A,0x5C9A,0xEF7D,0xEF7D,0xEF7D,0xEF7D,0x5C9A,0x3C3A,0x3C5A,0x3C5A,0x345A,0x343A,0x343A,0x341A,0x859B,0xF79E,0xF7BE,0xAD75,0x0000,0x0000, // row 21, 704 pixels
|
|
||||||
0x0000,0x0000,0x528A,0xE71C,0xFFDF,0xDF3D,0x3C5A,0x343A,0x343A,0x343A,0x343A,0x3C5A,0x343A,0x4C5A,0xEF7D,0xEF7D,0xEF7D,0xEF7D,0x4C59,0x343A,0x343A,0x343A,0x343A,0x343A,0x341A,0x3C5A,0xDF3D,0xFFDF,0xE71C,0x528A,0x0000,0x0000, // row 22, 736 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x9CD3,0xF79E,0xF7BE,0xBE7C,0x3419,0x341A,0x341A,0x343A,0x343A,0x341A,0x2B99,0xC69C,0xEF7D,0xEF7D,0xD6DC,0x2398,0x341A,0x343A,0x341A,0x341A,0x2C19,0x2C19,0xBE7C,0xF7BE,0xF79E,0x9CD3,0x0000,0x0000,0x0000, // row 23, 768 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x39E7,0xDEDB,0xFFDF,0xF79E,0x9DFB,0x2C19,0x2C19,0x2C1A,0x341A,0x341A,0x2BB9,0x2B57,0x6459,0x74B9,0x2337,0x2BB9,0x341A,0x2C1A,0x2C19,0x2C19,0x2C19,0x9DFB,0xF79E,0xFFDF,0xDEDB,0x39E7,0x0000,0x0000,0x0000, // row 24, 800 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x632C,0xDEFB,0xFFDF,0xEF7D,0xB65C,0x3C39,0x2BF9,0x2C19,0x2C19,0x2BF9,0x2398,0x1B58,0x1B37,0x2398,0x2BF9,0x2C19,0x2BF9,0x2BF9,0x3439,0xB65C,0xEF7D,0xFFDF,0xDEFB,0x632C,0x0000,0x0000,0x0000,0x0000, // row 25, 832 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x73AE,0xDEFB,0xF7BE,0xF79E,0xDF1C,0x7D5A,0x2BF9,0x2BF9,0x2BF9,0x2BF9,0x23D9,0x23D9,0x2BF9,0x2BF9,0x2BF9,0x2BF9,0x7D5A,0xDF1C,0xF79E,0xF7BE,0xDEFB,0x73AE,0x0000,0x0000,0x0000,0x0000,0x0000, // row 26, 864 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x632C,0xDEDB,0xF79E,0xFFDF,0xEF7D,0xD6FC,0x9DFB,0x5CDA,0x4C9A,0x3419,0x3419,0x4C9A,0x5CDA,0x9DFB,0xD6FC,0xEF7D,0xFFDF,0xF79E,0xDEDB,0x632C,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 27, 896 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x4208,0x94B2,0xDEFB,0xF7BE,0xFFDF,0xF7BE,0xF79E,0xEF7D,0xEF5D,0xEF5D,0xEF7D,0xF79E,0xF7BE,0xFFDF,0xF7BE,0xDEFB,0x94B2,0x4208,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 28, 928 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x528A,0xA534,0xDEDB,0xE73C,0xF79E,0xF7BE,0xF7BE,0xF7BE,0xF7BE,0xF79E,0xE73C,0xDEDB,0xA534,0x528A,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 29, 960 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x18C3,0x5AEB,0x8C71,0xAD55,0xBDD7,0xBDD7,0xAD55,0x8C71,0x5AEB,0x18C3,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 30, 992 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000}; // row 31, 1024 pixels
|
|
@@ -1,106 +0,0 @@
|
|||||||
// Icons are stored in tabs ^ e.g. Alert.h etc above this line
|
|
||||||
// more than one icon can be in a header file
|
|
||||||
|
|
||||||
/*
|
|
||||||
This sketch demonstrates loading images from arrays stored in program (FLASH) memory.
|
|
||||||
|
|
||||||
Works with TFT_eSPI library here:
|
|
||||||
https://github.com/Bodmer/TFT_eSPI
|
|
||||||
|
|
||||||
This sketch does not use/need any fonts at all...
|
|
||||||
|
|
||||||
Code derived from ILI9341_due example
|
|
||||||
|
|
||||||
Make sure all the display driver and pin comnenctions 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 ######
|
|
||||||
#########################################################################
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <TFT_eSPI.h> // Hardware-specific library
|
|
||||||
|
|
||||||
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
|
|
||||||
|
|
||||||
// Include the header files that contain the icons
|
|
||||||
#include "Alert.h"
|
|
||||||
#include "Close.h"
|
|
||||||
#include "Info.h"
|
|
||||||
|
|
||||||
long count = 0; // Loop count
|
|
||||||
|
|
||||||
void setup()
|
|
||||||
{
|
|
||||||
Serial.begin(115200);
|
|
||||||
tft.begin();
|
|
||||||
tft.setRotation(1); // landscape
|
|
||||||
|
|
||||||
tft.fillScreen(TFT_BLACK);
|
|
||||||
|
|
||||||
// Draw the icons
|
|
||||||
drawIcon(info, 100, 100, infoWidth, infoHeight);
|
|
||||||
drawIcon(alert, 140, 100, alertWidth, alertHeight);
|
|
||||||
drawIcon(closeX, 180, 100, closeWidth, closeHeight);
|
|
||||||
|
|
||||||
// Pause here to admire the icons!
|
|
||||||
delay(2000);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
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(closeX, random(tft.width() - closeWidth), random(tft.height() - closeHeight), alertWidth, closeHeight);
|
|
||||||
|
|
||||||
// Clear screen after 100 x 3 = 300 icons drawn
|
|
||||||
if (100 == count++) {
|
|
||||||
count = 1;
|
|
||||||
tft.setRotation(2 * random(2)); // Rotate randomly to clear display left>right or right>left to reduce monotony!
|
|
||||||
tft.fillScreen(TFT_BLACK);
|
|
||||||
tft.setRotation(1);
|
|
||||||
//Serial.println(millis());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//====================================================================================
|
|
||||||
// This is the function to draw the icon stored as an array in program memory (FLASH)
|
|
||||||
//====================================================================================
|
|
||||||
|
|
||||||
// To speed up rendering we use a 64 pixel buffer
|
|
||||||
#define BUFF_SIZE 64
|
|
||||||
|
|
||||||
// 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, uint16_t width, uint16_t height) {
|
|
||||||
|
|
||||||
uint16_t pix_buffer[BUFF_SIZE]; // Pixel buffer (16 bits per pixel)
|
|
||||||
|
|
||||||
// Set up a window the right size to stream pixels into
|
|
||||||
tft.setWindow(x, y, x + width - 1, y + height - 1);
|
|
||||||
|
|
||||||
// Work out the number whole buffers to send
|
|
||||||
uint16_t nb = ((uint16_t)height * width) / BUFF_SIZE;
|
|
||||||
|
|
||||||
// Fill and send "nb" buffers to TFT
|
|
||||||
for (int i = 0; i < nb; i++) {
|
|
||||||
for (int j = 0; j < BUFF_SIZE; j++) {
|
|
||||||
pix_buffer[j] = pgm_read_word(&icon[i * BUFF_SIZE + j]);
|
|
||||||
}
|
|
||||||
tft.pushColors(pix_buffer, BUFF_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Work out number of pixels not yet sent
|
|
||||||
uint16_t np = ((uint16_t)height * width) % BUFF_SIZE;
|
|
||||||
|
|
||||||
// Send any partial buffer left over
|
|
||||||
if (np) {
|
|
||||||
for (int i = 0; i < np; i++) pix_buffer[i] = pgm_read_word(&icon[nb * BUFF_SIZE + i]);
|
|
||||||
tft.pushColors(pix_buffer, np);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@@ -1,42 +0,0 @@
|
|||||||
// We need this header file to use FLASH as storage with PROGMEM directive:
|
|
||||||
#include <pgmspace.h>
|
|
||||||
|
|
||||||
// Icon width and height
|
|
||||||
const uint16_t alertWidth = 32;
|
|
||||||
const uint16_t alertHeight = 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 alert[1024] PROGMEM={
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0840,0x0000,0x0000,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,0x0000,0x0000,0x0000,0x1080,0xAC66,0xEDE8,0xFE69,0xC4C6,0x2901,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 1, 64 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xBCC6,0xFE68,0xFE68,0xFE6A,0xFE68,0xEDE8,0x18A1,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 2, 96 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x8344,0xFE48,0xFE8C,0xFFDD,0xFFFF,0xFEF0,0xFE48,0xB466,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 3, 128 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1880,0xEDC7,0xFE48,0xFF99,0xFFBC,0xFF9B,0xFFBD,0xFE6A,0xFE48,0x5A23,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 4, 160 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x9BE5,0xFE28,0xFED0,0xFFBC,0xFF7A,0xFF9A,0xFF9B,0xFF35,0xFE28,0xBCA6,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 5, 192 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3962,0xFE28,0xFE28,0xFF9A,0xFF79,0xFF9A,0xFF9B,0xFF9A,0xFFBD,0xFE6B,0xFE28,0x72E3,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 6, 224 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xB465,0xFE28,0xFEF2,0xFF7A,0xFF79,0xFF7A,0xFF9A,0xFF7A,0xFF7A,0xFF78,0xFE28,0xDD67,0x0860,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 7, 256 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x5A22,0xFE07,0xFE29,0xFF9B,0xFF37,0xFF58,0xFF79,0xFF79,0xFF79,0xFF58,0xFF9B,0xFEAE,0xFE07,0x93A4,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 8, 288 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xC4A5,0xFE07,0xFF15,0xFF37,0xFF36,0xAD11,0x2965,0x2965,0xCDF4,0xFF37,0xFF37,0xFF79,0xFE07,0xFE07,0x2901,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 9, 320 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x7B03,0xFDE7,0xFE4B,0xFF79,0xFEF4,0xFF15,0xB552,0x2945,0x2945,0xDE55,0xFF16,0xFF15,0xFF58,0xFED1,0xFDE7,0xAC25,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 10, 352 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0840,0xDD26,0xFDE7,0xFF57,0xFED3,0xFED2,0xFEF4,0xBD93,0x2124,0x2124,0xDE75,0xFF14,0xFED3,0xFED3,0xFF7A,0xFE08,0xFDE7,0x49A2,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 11, 384 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x9BA4,0xFDC6,0xFE6E,0xFF36,0xFE90,0xFEB1,0xFED3,0xC592,0x2124,0x2124,0xE675,0xFED3,0xFEB2,0xFEB1,0xFEF3,0xFEF3,0xFDC6,0xBC45,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 12, 416 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3141,0xF5C6,0xF5C7,0xFF58,0xFE90,0xFE6F,0xFE8F,0xFEB1,0xCDB2,0x2104,0x2104,0xF6B4,0xFEB1,0xFE90,0xFE8F,0xFE90,0xFF58,0xFE0A,0xF5C6,0x72A3,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 13, 448 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xABE4,0xF5A6,0xFEB1,0xFED3,0xFE4E,0xFE6E,0xFE6F,0xFE90,0xD5F2,0x18E3,0x18E3,0xFED4,0xFE90,0xFE6F,0xFE6F,0xFE6E,0xFE91,0xFF36,0xF5A6,0xCCA5,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 14, 480 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x5202,0xF5A6,0xF5C7,0xFF58,0xFE4D,0xFE4D,0xFE4D,0xFE4E,0xFE6F,0xDE11,0x18C3,0x18C3,0xFED3,0xFE6F,0xFE6E,0xFE4E,0xFE4D,0xFE4D,0xFF16,0xFE2C,0xF5A6,0x9363,0x0000,0x0000,0x0000,0x0000,0x0000, // row 15, 512 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0xBC44,0xF585,0xFED3,0xFE6F,0xFE2C,0xFE2C,0xFE2D,0xFE4D,0xFE4E,0xE630,0x10A2,0x2104,0xFED1,0xFE4E,0xFE4D,0xFE4D,0xFE2D,0xFE2C,0xFE4D,0xFF37,0xF586,0xF585,0x28E1,0x0000,0x0000,0x0000,0x0000, // row 16, 544 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x7282,0xF565,0xF5EA,0xFF16,0xFE0B,0xFE0B,0xFE0B,0xFE2C,0xFE2C,0xFE4D,0xF670,0x1082,0x2924,0xFEB0,0xFE2D,0xFE2C,0xFE2C,0xFE2C,0xFE0B,0xFE0B,0xFEB2,0xFE6F,0xF565,0xA383,0x0000,0x0000,0x0000,0x0000, // row 17, 576 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0840,0xD4C4,0xF565,0xFEF5,0xFE0C,0xFDE9,0xFDEA,0xFE0A,0xFE0B,0xFE0B,0xFE2C,0xFE8F,0x0861,0x2964,0xFE8F,0xFE2C,0xFE0B,0xFE0B,0xFE0B,0xFE0A,0xFDEA,0xFE0B,0xFF37,0xF586,0xF565,0x4181,0x0000,0x0000,0x0000, // row 18, 608 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x9343,0xF545,0xF60C,0xFED3,0xFDC8,0xFDC8,0xFDC9,0xFDE9,0xFDEA,0xFDEA,0xFE0B,0xFE8E,0x0861,0x3184,0xFE6D,0xFE0B,0xFE0A,0xFDEA,0xFDEA,0xFDE9,0xFDC9,0xFDC9,0xFE4E,0xFEB2,0xF545,0xB3E3,0x0000,0x0000,0x0000, // row 19, 640 pixels
|
|
||||||
0x0000,0x0000,0x28E0,0xF544,0xF545,0xFF17,0xFDC8,0xFDA7,0xFDA7,0xFDC8,0xFDC8,0xFDC9,0xFDC9,0xFDE9,0xFE6C,0x10A2,0x39C4,0xFE4C,0xFDEA,0xFDE9,0xFDC9,0xFDC9,0xFDC8,0xFDC8,0xFDA7,0xFDA8,0xFF16,0xF588,0xF544,0x6222,0x0000,0x0000, // row 20, 672 pixels
|
|
||||||
0x0000,0x0000,0xA383,0xF524,0xF64E,0xFE4E,0xFD86,0xFD86,0xFD87,0xFDA7,0xFDA7,0xFDA8,0xFDC8,0xFDC8,0xFE2A,0xA469,0xB4EA,0xFE2A,0xFDC9,0xFDC8,0xFDC8,0xFDA8,0xFDA7,0xFDA7,0xFD87,0xFD86,0xFDEA,0xFED3,0xF524,0xC443,0x0000,0x0000, // row 21, 704 pixels
|
|
||||||
0x0000,0x51C1,0xF504,0xF546,0xFF16,0xF565,0xFD65,0xFD65,0xFD86,0xFD86,0xFD86,0xFDA7,0xFDA7,0xFDA7,0xFDE8,0xFE6A,0xFE4A,0xFDE8,0xFDA7,0xFDA7,0xFDA7,0xFDA7,0xFD86,0xFD86,0xFD86,0xFD65,0xFD65,0xFEB2,0xF5CA,0xF504,0x8AE2,0x0000, // row 22, 736 pixels
|
|
||||||
0x0000,0xB3A2,0xED03,0xFE92,0xFDC9,0xF543,0xF544,0xFD44,0xFD65,0xFD65,0xFD65,0xFD86,0xFD86,0xFD86,0xFDA7,0xFDC7,0xFDC7,0xFDA7,0xFD86,0xFD86,0xFD86,0xFD86,0xFD65,0xFD65,0xFD65,0xFD44,0xF544,0xFD86,0xFEF5,0xED03,0xE4C3,0x1880, // row 23, 768 pixels
|
|
||||||
0x7241,0xECE3,0xF567,0xFED3,0xF523,0xF523,0xF523,0xF543,0xF544,0xF544,0xFD65,0xFD65,0xFD65,0xFD65,0xD4E6,0x39C5,0x39A5,0xD4E6,0xFD86,0xFD65,0xFD65,0xFD65,0xFD65,0xF544,0xF544,0xF543,0xF523,0xF523,0xFE2E,0xF5EC,0xECE3,0x9B42, // row 24, 800 pixels
|
|
||||||
0xD443,0xECE3,0xFED4,0xF565,0xF502,0xF502,0xF522,0xF523,0xF523,0xF543,0xF544,0xF544,0xF544,0xFD65,0x8B64,0x18C3,0x18C3,0x8344,0xFD85,0xFD44,0xF544,0xF544,0xF544,0xF543,0xF523,0xF523,0xF522,0xF502,0xF523,0xFEF5,0xED04,0xECE3, // row 25, 832 pixels
|
|
||||||
0xECC3,0xF5AB,0xFE6F,0xF501,0xF4E1,0xF501,0xF502,0xF502,0xF522,0xF522,0xF523,0xF523,0xF523,0xFD84,0xC504,0x20E1,0x18E1,0xC4E4,0xFD84,0xF543,0xF523,0xF523,0xF523,0xF522,0xF522,0xF502,0xF502,0xF501,0xF501,0xFDC9,0xF62F,0xECC3, // row 26, 864 pixels
|
|
||||||
0xECC2,0xFE92,0xF523,0xF4E0,0xF4E0,0xF4E1,0xF4E1,0xF501,0xF501,0xF502,0xF502,0xF522,0xF522,0xF543,0xFDE3,0xFEA5,0xF6A4,0xFE04,0xF543,0xF522,0xF522,0xF522,0xF502,0xF502,0xF501,0xF501,0xF4E1,0xF4E1,0xF4E0,0xF4E1,0xFED4,0xECC2, // row 27, 896 pixels
|
|
||||||
0xECA2,0xF5EC,0xF4E0,0xF4C0,0xF4E0,0xF4E0,0xF4E0,0xF4E1,0xF4E1,0xF501,0xF501,0xF501,0xF502,0xF502,0xF542,0xFDA2,0xFDA2,0xF542,0xF502,0xF502,0xF502,0xF501,0xF501,0xF501,0xF4E1,0xF4E1,0xF4E0,0xF4E0,0xF4E0,0xF4C0,0xF5A9,0xECA2, // row 28, 928 pixels
|
|
||||||
0xECA2,0xECA2,0xECC2,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4E1,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xECC2,0xECC3,0xECA2, // row 29, 960 pixels
|
|
||||||
0x8AC1,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0x9B01, // row 30, 992 pixels
|
|
||||||
0x0000,0x1880,0x51A0,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x61E0,0x28E0,0x0000}; // row 31, 1024 pixels
|
|
||||||
|
|
@@ -1,41 +0,0 @@
|
|||||||
// We need this header file to use FLASH as storage with PROGMEM directive:
|
|
||||||
#include <pgmspace.h>
|
|
||||||
|
|
||||||
// Icon width and height
|
|
||||||
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 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
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x2041,0x8945,0xF34D,0xFD34,0xFDB6,0xFD75,0xFD55,0xFD55,0xFD96,0xFDD7,0xFDF7,0xFDF7,0xFDB6,0xFDB6,0xFDD7,0xFDF7,0xFD75,0xF38E,0x8965,0x2041,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 3, 128 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x4082,0xE208,0xF410,0xFD34,0xFC92,0xFBEF,0xFBAE,0xFBEF,0xFC71,0xFD14,0xFD75,0xFDB6,0xFD75,0xFD14,0xFC92,0xFC51,0xFC71,0xFCF3,0xFD75,0xFC30,0xEA28,0x40A2,0x0000,0x0000,0x0000,0x0000,0x0000, // row 4, 160 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x3861,0xE1E7,0xF451,0xFC92,0xFB4D,0xFA49,0xFA49,0xFAEB,0xFBAE,0xFC71,0xFD34,0xFDB6,0xFE18,0xFDB6,0xFD34,0xFC71,0xFBAE,0xFB0C,0xFAEB,0xFBAE,0xFCD3,0xFC71,0xE208,0x4082,0x0000,0x0000,0x0000,0x0000, // row 5, 192 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x1020,0xD986,0xF430,0xFC30,0xFA28,0xF924,0xF965,0xFA8A,0xFB0C,0xFBAE,0xFC51,0xFD14,0xFD75,0xFDB6,0xFD75,0xFD14,0xFC51,0xFC71,0xFBEF,0xFA28,0xF9C7,0xFA8A,0xFC51,0xF430,0xD9A6,0x1020,0x0000,0x0000,0x0000, // row 6, 224 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x78A2,0xEB6D,0xFC30,0xF9C7,0xF861,0xF8A2,0xFA08,0xFEDB,0xFD55,0xFB4D,0xFC10,0xFC92,0xFD14,0xFD34,0xFD14,0xFC92,0xFCB2,0xFF7D,0xFF7D,0xFB2C,0xF945,0xF8E3,0xF9E7,0xFC30,0xEB8E,0x78C3,0x0000,0x0000,0x0000, // row 7, 256 pixels
|
|
||||||
0x0000,0x0000,0x3841,0xD9E7,0xF492,0xF208,0xF041,0xF800,0xF945,0xFE9A,0xFFFF,0xFFFF,0xFD75,0xFB8E,0xFC10,0xFC51,0xFC71,0xFC51,0xFCB2,0xFF7D,0xFFFF,0xFFFF,0xFF3C,0xFA8A,0xF882,0xF841,0xFA08,0xFC92,0xDA08,0x3841,0x0000,0x0000, // row 8, 288 pixels
|
|
||||||
0x0000,0x0000,0x88A2,0xEBCF,0xF2EB,0xF061,0xF000,0xF8E3,0xFE79,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFD75,0xFB4D,0xFBAE,0xFBAE,0xFC71,0xFF7D,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFEFB,0xFA28,0xF800,0xF061,0xF2EB,0xEBEF,0x90C3,0x0000,0x0000, // row 9, 320 pixels
|
|
||||||
0x0000,0x2820,0xD1C7,0xF410,0xE945,0xE800,0xF000,0xFE9A,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFD34,0xFAEB,0xFBCF,0xFF5D,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFF1C,0xF986,0xF000,0xF145,0xF410,0xD1E7,0x2820,0x0000, // row 10, 352 pixels
|
|
||||||
0x0000,0x6841,0xDB2C,0xEACB,0xE041,0xE800,0xF000,0xFEFB,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFD14,0xFF1C,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFBCF,0xF082,0xF000,0xE841,0xEACB,0xE34D,0x7061,0x0000, // row 11, 384 pixels
|
|
||||||
0x0000,0x9861,0xE3CF,0xE186,0xE000,0xE800,0xE800,0xF145,0xFEDB,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFB8E,0xF000,0xF000,0xE800,0xE800,0xE986,0xEBCF,0xA082,0x0000, // row 12, 416 pixels
|
|
||||||
0x0800,0xB8A2,0xE3AE,0xD8A2,0xD800,0xE000,0xE800,0xE800,0xF145,0xFEFB,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFB8E,0xF000,0xF000,0xE800,0xE800,0xE000,0xE0A2,0xEBAE,0xC0C3,0x0800, // row 13, 448 pixels
|
|
||||||
0x1800,0xC124,0xE30C,0xD020,0xD800,0xE000,0xE000,0xE800,0xE800,0xF145,0xFEDB,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFB8E,0xF000,0xF000,0xE800,0xE800,0xE000,0xE000,0xD820,0xE30C,0xC124,0x1800, // row 14, 480 pixels
|
|
||||||
0x2800,0xC165,0xDAAA,0xC800,0xD000,0xD800,0xE000,0xE000,0xE800,0xE800,0xF124,0xFE79,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFB6D,0xF000,0xF000,0xE800,0xE800,0xE000,0xE000,0xD800,0xD000,0xDAAA,0xC165,0x2800, // row 15, 512 pixels
|
|
||||||
0x2000,0xB924,0xD269,0xC800,0xD000,0xD000,0xD800,0xE000,0xE000,0xE800,0xE924,0xFEFB,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xF36D,0xE800,0xE800,0xE800,0xE000,0xE000,0xD800,0xD000,0xD000,0xDA69,0xC145,0x2800, // row 16, 544 pixels
|
|
||||||
0x1000,0xB0A2,0xD28A,0xC000,0xC800,0xD000,0xD000,0xD800,0xD800,0xE165,0xFEFB,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xF3AE,0xE000,0xE000,0xD800,0xD800,0xD000,0xD000,0xC800,0xD28A,0xB8C3,0x1000, // row 17, 576 pixels
|
|
||||||
0x0000,0xA800,0xD2AA,0xB800,0xC000,0xC800,0xC800,0xD000,0xD965,0xFEFB,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xEBAE,0xD800,0xD800,0xD000,0xC800,0xC800,0xC000,0xD2AA,0xB020,0x0000, // row 18, 608 pixels
|
|
||||||
0x0000,0x8000,0xCA69,0xB841,0xB800,0xC000,0xC800,0xD186,0xFEFB,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xEBCF,0xD000,0xC800,0xC800,0xC000,0xC041,0xCA69,0x8000,0x0000, // row 19, 640 pixels
|
|
||||||
0x0000,0x4800,0xC1C7,0xB8E3,0xB800,0xB800,0xC000,0xF69A,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xEBEF,0xFE79,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xE410,0xC841,0xC000,0xB800,0xC0E3,0xC1C7,0x4800,0x0000, // row 20, 672 pixels
|
|
||||||
0x0000,0x1000,0xB061,0xC1E7,0xB000,0xB000,0xB800,0xD269,0xFFBE,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xE38E,0xD000,0xD965,0xF69A,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xDB0C,0xC020,0xB800,0xB000,0xC1E7,0xB061,0x1000,0x0000, // row 21, 704 pixels
|
|
||||||
0x0000,0x0000,0x6000,0xB9C7,0xB061,0xB000,0xB000,0xB800,0xCA49,0xFF9E,0xFFFF,0xFFFF,0xFFFF,0xE38E,0xC800,0xC800,0xC800,0xD186,0xF69A,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xDB0C,0xB800,0xB800,0xB000,0xB061,0xC1C7,0x6000,0x0000,0x0000, // row 22, 736 pixels
|
|
||||||
0x0000,0x0000,0x1800,0xB041,0xB986,0xA800,0xA800,0xB000,0xB000,0xCA49,0xFF7D,0xFFFF,0xDB8E,0xC000,0xC000,0xC000,0xC000,0xC000,0xC986,0xF6DB,0xFFFF,0xFFFF,0xD30C,0xB800,0xB000,0xB000,0xA800,0xB986,0xB041,0x1800,0x0000,0x0000, // row 23, 768 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x5800,0xB0E3,0xA8C3,0xA800,0xA800,0xA800,0xB000,0xCACB,0xD38E,0xB000,0xB800,0xB800,0xB800,0xB800,0xB800,0xB800,0xC145,0xF6DB,0xD34D,0xB000,0xB000,0xA800,0xA800,0xB0C3,0xB0E3,0x5800,0x0000,0x0000,0x0000, // row 24, 800 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x6000,0xB124,0xA882,0xA000,0xA800,0xA800,0xA800,0xA800,0xB000,0xB000,0xB000,0xB000,0xB000,0xB000,0xB000,0xB000,0xB000,0xA800,0xA800,0xA800,0xA800,0xA882,0xB124,0x6000,0x0000,0x0000,0x0000,0x0000, // row 25, 832 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x6000,0xB104,0xA882,0xA000,0xA000,0xA000,0xA800,0xA800,0xA800,0xA800,0xA800,0xA800,0xA800,0xA800,0xA800,0xA800,0xA800,0xA000,0xA000,0xA882,0xB104,0x6000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 26, 864 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x6000,0xB0A2,0xA8C3,0xA020,0xA000,0xA000,0xA000,0xA000,0xA000,0xA000,0xA000,0xA000,0xA000,0xA000,0xA000,0xA000,0xA020,0xA8C3,0xB0A2,0x6000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 27, 896 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x4800,0xA800,0xB0C3,0xA0A2,0x9800,0x9800,0x9800,0x9800,0xA000,0xA000,0xA000,0x9800,0x9800,0x9800,0xA082,0xB0E3,0xA800,0x4800,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 28, 928 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x5800,0xA800,0xB0A2,0xA8E3,0xA0A2,0xA041,0x9800,0x9800,0xA041,0xA0A2,0xA8E3,0xB0A2,0xA800,0x5800,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 29, 960 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3000,0x6000,0x8800,0xA000,0xA800,0xA800,0xA000,0x8800,0x6000,0x3000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 30, 992 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000}; // row 31, 1024 pixels
|
|
@@ -1,113 +0,0 @@
|
|||||||
// Code partly derived from ILI9341_due library example
|
|
||||||
|
|
||||||
// Draws the 3 icons across the middle of the screen and pauses.
|
|
||||||
// Then draws 300 icons at random locations, clears screen and repeats
|
|
||||||
//
|
|
||||||
// This demonstrates drawing icons from FLASH
|
|
||||||
|
|
||||||
// Icons are stored in tabs, e.g. Alert.h etc
|
|
||||||
// more than one icon can be in a header file.
|
|
||||||
|
|
||||||
/*
|
|
||||||
This sketch demonstrates loading images from arrays stored in program (FLASH) memory.
|
|
||||||
|
|
||||||
Works with TFT_eSPI library here:
|
|
||||||
https://github.com/Bodmer/TFT_eSPI
|
|
||||||
|
|
||||||
This sketch does not use/need any fonts at all...
|
|
||||||
|
|
||||||
Arrays containing FLASH images can be created with UTFT library tool:
|
|
||||||
(libraries\UTFT\Tools\ImageConverter565.exe)
|
|
||||||
Convert to .c format then copy into a new tab
|
|
||||||
|
|
||||||
The number and size of icons is limited by available FLASH memory. The icon array will
|
|
||||||
use width x height x 2 bytes of FLASH, i.e. 32 x 32 icon uses ~2048 bytes
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <TFT_eSPI.h> // Hardware-specific library
|
|
||||||
#include <SPI.h>
|
|
||||||
|
|
||||||
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 "Close.h"
|
|
||||||
#include "Info.h"
|
|
||||||
|
|
||||||
long count = 0; // Loop count
|
|
||||||
|
|
||||||
void setup()
|
|
||||||
{
|
|
||||||
Serial.begin(115200);
|
|
||||||
tft.begin();
|
|
||||||
tft.setRotation(1); // landscape
|
|
||||||
|
|
||||||
tft.fillScreen(TFT_BLACK);
|
|
||||||
|
|
||||||
// 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(closeX, (tft.width() - closeWidth)/2 + 50, (tft.height() - closeHeight)/2, closeWidth, closeHeight);
|
|
||||||
|
|
||||||
// Pause here to admire the icons!
|
|
||||||
delay(4000);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
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(closeX, random(tft.width() - closeWidth), random(tft.height() - closeHeight), alertWidth, closeHeight);
|
|
||||||
|
|
||||||
// Clear screen after 100 x 3 = 300 icons drawn
|
|
||||||
if (100 == count++) {
|
|
||||||
count = 1;
|
|
||||||
tft.setRotation(2 * random(2)); // Rotate randomly to clear display left>right or right>left to reduce monotony!
|
|
||||||
tft.fillScreen(TFT_BLACK);
|
|
||||||
tft.setRotation(1);
|
|
||||||
Serial.println(millis());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//====================================================================================
|
|
||||||
// This is the function to draw the icon stored as an array in program memory (FLASH)
|
|
||||||
//====================================================================================
|
|
||||||
|
|
||||||
// To speed up rendering we use a 64 pixel buffer
|
|
||||||
#define BUFF_SIZE 64
|
|
||||||
|
|
||||||
// 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, uint16_t width, uint16_t height) {
|
|
||||||
|
|
||||||
uint16_t pix_buffer[BUFF_SIZE]; // Pixel buffer (16 bits per pixel)
|
|
||||||
|
|
||||||
// Set up a window the right size to stream pixels into
|
|
||||||
tft.setWindow(x, y, x + width - 1, y + height - 1);
|
|
||||||
|
|
||||||
// Work out the number whole buffers to send
|
|
||||||
uint16_t nb = ((uint16_t)height * width) / BUFF_SIZE;
|
|
||||||
|
|
||||||
// Fill and send "nb" buffers to TFT
|
|
||||||
for (int i = 0; i < nb; i++) {
|
|
||||||
for (int j = 0; j < BUFF_SIZE; j++) {
|
|
||||||
pix_buffer[j] = pgm_read_word(&icon[i * BUFF_SIZE + j]);
|
|
||||||
}
|
|
||||||
tft.pushColors(pix_buffer, BUFF_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Work out number of pixels not yet sent
|
|
||||||
uint16_t np = ((uint16_t)height * width) % BUFF_SIZE;
|
|
||||||
|
|
||||||
// Send any partial buffer left over
|
|
||||||
if (np) {
|
|
||||||
for (int i = 0; i < np; i++) pix_buffer[i] = pgm_read_word(&icon[nb * BUFF_SIZE + i]);
|
|
||||||
tft.pushColors(pix_buffer, np);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@@ -1,41 +0,0 @@
|
|||||||
// We need this header file to use FLASH as storage with PROGMEM directive:
|
|
||||||
#include <pgmspace.h>
|
|
||||||
|
|
||||||
// Icon width and height
|
|
||||||
const uint16_t infoWidth = 32;
|
|
||||||
const uint16_t infoHeight = 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 info[1024] PROGMEM={
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,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,0x0000,0x0861,0x4A69,0x8C71,0xA514,0xBDF7,0xBDF7,0xA514,0x8C71,0x4A69,0x0861,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 1, 64 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x39E7,0x9CF3,0xEF7D,0xF79E,0xFFDF,0xFFDF,0xFFDF,0xFFDF,0xFFDF,0xFFDF,0xF79E,0xEF7D,0x9CF3,0x39E7,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 2, 96 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x2965,0x9492,0xF79E,0xFFDF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFDF,0xF79E,0x9492,0x2965,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 3, 128 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x630C,0xEF7D,0xFFDF,0xFFFF,0xFFFF,0xFFFF,0xD75F,0xB6BF,0x9E5F,0x963F,0x963F,0x9E5F,0xB6BF,0xD75F,0xFFFF,0xFFFF,0xFFFF,0xFFDF,0xEF7D,0x630C,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 4, 160 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x73AE,0xEF7D,0xFFDF,0xFFFF,0xFFDF,0xBEDF,0x7DBF,0x7DBF,0x7DDF,0x7DDF,0x7DDF,0x7DDF,0x7DDF,0x7DBF,0x759F,0x7DBE,0xBEBF,0xFFDF,0xFFFF,0xFFDF,0xEF7D,0x73AE,0x0000,0x0000,0x0000,0x0000,0x0000, // row 5, 192 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x630C,0xEF7D,0xFFFF,0xFFFF,0xE77F,0x7DBE,0x759E,0x759F,0x7DBF,0x7DDF,0x7DDF,0x85FF,0x7DDF,0x7DDF,0x7DBF,0x759F,0x759E,0x6D7E,0x7DBE,0xDF7F,0xFFFF,0xFFFF,0xEF7D,0x630C,0x0000,0x0000,0x0000,0x0000, // row 6, 224 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x31A6,0xEF5D,0xFFDF,0xFFFF,0xCF1E,0x6D7E,0x6D7E,0x759E,0x759F,0x7DBF,0x7DDF,0x8E1F,0xBEDF,0xC6FF,0x8DFF,0x75BF,0x759F,0x759E,0x6D7E,0x655E,0x655D,0xCF1E,0xFFFF,0xFFDF,0xEF5D,0x31A6,0x0000,0x0000,0x0000, // row 7, 256 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x94B2,0xF7BE,0xFFFF,0xDF5E,0x655D,0x655D,0x6D7E,0x6D7E,0x759E,0x75BF,0x759F,0xEFBF,0xFFFF,0xFFFF,0xEFBF,0x759F,0x759E,0x6D7E,0x6D7E,0x655D,0x653D,0x653D,0xDF5E,0xFFFF,0xF7BE,0x94B2,0x0000,0x0000,0x0000, // row 8, 288 pixels
|
|
||||||
0x0000,0x0000,0x4228,0xEF7D,0xFFFF,0xF7BF,0x6D5D,0x653D,0x655D,0x6D5E,0x6D7E,0x759E,0x759E,0x85DF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0x8DFE,0x6D7E,0x6D7E,0x6D5E,0x655D,0x653D,0x5D1D,0x6D5D,0xF7BF,0xFFFF,0xEF7D,0x4228,0x0000,0x0000, // row 9, 320 pixels
|
|
||||||
0x0000,0x0000,0xA534,0xFFDF,0xFFDF,0xA65D,0x5D1D,0x5D1D,0x653D,0x655E,0x6D7E,0x6D7E,0x6D7E,0x651E,0xE77F,0xFFFF,0xFFFF,0xF7BF,0x5CFE,0x6D7E,0x6D7E,0x655E,0x653D,0x5D1D,0x5D1D,0x54FC,0xA65D,0xFFDF,0xFFDF,0xA534,0x0000,0x0000, // row 10, 352 pixels
|
|
||||||
0x0000,0x18E3,0xEF5D,0xFFFF,0xEF9E,0x5CFC,0x54FC,0x5D1D,0x5D3D,0x653D,0x655E,0x6D7E,0x6D7E,0x653E,0x6D3E,0xB67E,0xBEBE,0x755E,0x5D1E,0x6D5E,0x655E,0x653D,0x5D3D,0x5D1D,0x54FC,0x54DC,0x54FC,0xEF9E,0xFFFF,0xEF5D,0x18E3,0x0000, // row 11, 384 pixels
|
|
||||||
0x0000,0x630C,0xEF7D,0xFFDF,0xB69D,0x54DC,0x54FC,0x5CFC,0x5D1D,0x653D,0x653D,0x655E,0x6D5E,0x655E,0x5CFE,0x4C9D,0x4C7D,0x54DD,0x653E,0x655E,0x653D,0x653D,0x5D1D,0x5CFC,0x54FC,0x54DC,0x4CBC,0xB69D,0xFFDF,0xEF7D,0x630C,0x0000, // row 12, 416 pixels
|
|
||||||
0x0000,0x94B2,0xF7BE,0xFFDF,0x85BC,0x4CBC,0x54DC,0x54FC,0x5CFD,0x5D1D,0x5D3D,0x653D,0x655D,0x653D,0x85DE,0xC6FE,0xC6FE,0x85BE,0x653D,0x653D,0x5D3D,0x5D1D,0x5CFD,0x54FC,0x54DC,0x4CBC,0x4CBB,0x85BC,0xFFDF,0xF7BE,0x94B2,0x0000, // row 13, 448 pixels
|
|
||||||
0x0000,0xB5B6,0xFFDF,0xF7BE,0x651C,0x4CBB,0x4CBC,0x54DC,0x54FC,0x5CFC,0x5D1D,0x5D1D,0x653D,0x5D1D,0xE77E,0xFFDF,0xFFDF,0xEF9E,0x5CFD,0x5D1D,0x5D1D,0x5CFC,0x54FC,0x54DC,0x4CBC,0x4CBB,0x449B,0x651B,0xF7BE,0xFFDF,0xB5B6,0x0000, // row 14, 480 pixels
|
|
||||||
0x0000,0xC638,0xFFDF,0xF7BE,0x54DB,0x449B,0x4CBB,0x4CBC,0x54DC,0x54FC,0x54FC,0x5D1D,0x5D1D,0x7D7D,0xF7BE,0xF7BE,0xF7BE,0xF7BE,0x7D7D,0x5CFD,0x54FC,0x54FC,0x54DC,0x4CBC,0x4CBB,0x449B,0x447B,0x54BB,0xF7BE,0xFFDF,0xC638,0x0000, // row 15, 512 pixels
|
|
||||||
0x0000,0xC638,0xFFDF,0xF79E,0x4CBB,0x449B,0x449B,0x4CBB,0x4CBC,0x54DC,0x54DC,0x54FC,0x54DC,0x753C,0xF7BE,0xF7BE,0xF7BE,0xF7BE,0x753C,0x54DC,0x54DC,0x54DC,0x4CBC,0x4CBB,0x449B,0x449B,0x3C7B,0x4C9B,0xF79E,0xFFDF,0xC638,0x0000, // row 16, 544 pixels
|
|
||||||
0x0000,0xB5B6,0xFFDF,0xF7BE,0x5CFB,0x3C7B,0x447B,0x449B,0x4CBB,0x4CBC,0x4CBC,0x4CDC,0x4CBC,0x6D1C,0xF7BE,0xF7BE,0xF7BE,0xF7BE,0x6CFC,0x4CBC,0x4CBC,0x4CBC,0x4CBB,0x449B,0x447B,0x3C7B,0x3C5A,0x54DB,0xF7BE,0xFFDF,0xB5B6,0x0000, // row 17, 576 pixels
|
|
||||||
0x0000,0x94B2,0xF7BE,0xF7BE,0x755B,0x3C5A,0x3C7B,0x447B,0x449B,0x449B,0x4CBB,0x4CBB,0x4C9B,0x6CFB,0xF79E,0xF79E,0xF79E,0xF79E,0x64FB,0x449B,0x4CBB,0x449B,0x449B,0x447B,0x3C7B,0x3C5A,0x3C5A,0x753B,0xF7BE,0xF7BE,0x9CD3,0x0000, // row 18, 608 pixels
|
|
||||||
0x0000,0x6B4D,0xEF7D,0xF7BE,0xA61C,0x3C5A,0x3C5A,0x3C7B,0x447B,0x447B,0x449B,0x449B,0x447B,0x64DB,0xF79E,0xF79E,0xF79E,0xF79E,0x64DB,0x447B,0x449B,0x447B,0x447B,0x3C7B,0x3C5A,0x3C5A,0x343A,0xA61C,0xF7BE,0xEF7D,0x6B4D,0x0000, // row 19, 640 pixels
|
|
||||||
0x0000,0x2124,0xE71C,0xFFDF,0xDF3D,0x3C5A,0x343A,0x3C5A,0x3C5A,0x3C7B,0x3C7B,0x447B,0x3C5B,0x64BA,0xF79E,0xF79E,0xF79E,0xF79E,0x64BA,0x3C5B,0x3C7B,0x3C7B,0x3C5A,0x3C5A,0x343A,0x343A,0x343A,0xDF3D,0xFFDF,0xE71C,0x2124,0x0000, // row 20, 672 pixels
|
|
||||||
0x0000,0x0000,0xAD75,0xF7BE,0xF79E,0x859B,0x343A,0x343A,0x345A,0x3C5A,0x3C5A,0x3C5A,0x3C5A,0x5C9A,0xEF7D,0xEF7D,0xEF7D,0xEF7D,0x5C9A,0x3C3A,0x3C5A,0x3C5A,0x345A,0x343A,0x343A,0x341A,0x859B,0xF79E,0xF7BE,0xAD75,0x0000,0x0000, // row 21, 704 pixels
|
|
||||||
0x0000,0x0000,0x528A,0xE71C,0xFFDF,0xDF3D,0x3C5A,0x343A,0x343A,0x343A,0x343A,0x3C5A,0x343A,0x4C5A,0xEF7D,0xEF7D,0xEF7D,0xEF7D,0x4C59,0x343A,0x343A,0x343A,0x343A,0x343A,0x341A,0x3C5A,0xDF3D,0xFFDF,0xE71C,0x528A,0x0000,0x0000, // row 22, 736 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x9CD3,0xF79E,0xF7BE,0xBE7C,0x3419,0x341A,0x341A,0x343A,0x343A,0x341A,0x2B99,0xC69C,0xEF7D,0xEF7D,0xD6DC,0x2398,0x341A,0x343A,0x341A,0x341A,0x2C19,0x2C19,0xBE7C,0xF7BE,0xF79E,0x9CD3,0x0000,0x0000,0x0000, // row 23, 768 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x39E7,0xDEDB,0xFFDF,0xF79E,0x9DFB,0x2C19,0x2C19,0x2C1A,0x341A,0x341A,0x2BB9,0x2B57,0x6459,0x74B9,0x2337,0x2BB9,0x341A,0x2C1A,0x2C19,0x2C19,0x2C19,0x9DFB,0xF79E,0xFFDF,0xDEDB,0x39E7,0x0000,0x0000,0x0000, // row 24, 800 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x632C,0xDEFB,0xFFDF,0xEF7D,0xB65C,0x3C39,0x2BF9,0x2C19,0x2C19,0x2BF9,0x2398,0x1B58,0x1B37,0x2398,0x2BF9,0x2C19,0x2BF9,0x2BF9,0x3439,0xB65C,0xEF7D,0xFFDF,0xDEFB,0x632C,0x0000,0x0000,0x0000,0x0000, // row 25, 832 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x73AE,0xDEFB,0xF7BE,0xF79E,0xDF1C,0x7D5A,0x2BF9,0x2BF9,0x2BF9,0x2BF9,0x23D9,0x23D9,0x2BF9,0x2BF9,0x2BF9,0x2BF9,0x7D5A,0xDF1C,0xF79E,0xF7BE,0xDEFB,0x73AE,0x0000,0x0000,0x0000,0x0000,0x0000, // row 26, 864 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x632C,0xDEDB,0xF79E,0xFFDF,0xEF7D,0xD6FC,0x9DFB,0x5CDA,0x4C9A,0x3419,0x3419,0x4C9A,0x5CDA,0x9DFB,0xD6FC,0xEF7D,0xFFDF,0xF79E,0xDEDB,0x632C,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 27, 896 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x4208,0x94B2,0xDEFB,0xF7BE,0xFFDF,0xF7BE,0xF79E,0xEF7D,0xEF5D,0xEF5D,0xEF7D,0xF79E,0xF7BE,0xFFDF,0xF7BE,0xDEFB,0x94B2,0x4208,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 28, 928 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x528A,0xA534,0xDEDB,0xE73C,0xF79E,0xF7BE,0xF7BE,0xF7BE,0xF7BE,0xF79E,0xE73C,0xDEDB,0xA534,0x528A,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 29, 960 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x18C3,0x5AEB,0x8C71,0xAD55,0xBDD7,0xBDD7,0xAD55,0x8C71,0x5AEB,0x18C3,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 30, 992 pixels
|
|
||||||
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000}; // row 31, 1024 pixels
|
|
@@ -38,4 +38,3 @@ const unsigned short alert[1024] PROGMEM={
|
|||||||
0xECA2,0xECA2,0xECC2,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4E1,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xECC2,0xECC3,0xECA2, // row 29, 960 pixels
|
0xECA2,0xECA2,0xECC2,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4E1,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xECC2,0xECC3,0xECA2, // row 29, 960 pixels
|
||||||
0x8AC1,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0x9B01, // row 30, 992 pixels
|
0x8AC1,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0x9B01, // row 30, 992 pixels
|
||||||
0x0000,0x1880,0x51A0,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x61E0,0x28E0,0x0000}; // row 31, 1024 pixels
|
0x0000,0x1880,0x51A0,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x61E0,0x28E0,0x0000}; // row 31, 1024 pixels
|
||||||
|
|
72
examples/Generic/TFT_Flash_Bitmap/TFT_Flash_Bitmap.ino
Normal file
72
examples/Generic/TFT_Flash_Bitmap/TFT_Flash_Bitmap.ino
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
// Icon images are stored in tabs ^ e.g. Alert.h etc above this line
|
||||||
|
// more than one icon can be in a header file
|
||||||
|
|
||||||
|
// Arrays containing FLASH images can be created with UTFT library tool:
|
||||||
|
// (libraries\UTFT\Tools\ImageConverter565.exe)
|
||||||
|
// Convert to .c format then copy into a new tab
|
||||||
|
|
||||||
|
/*
|
||||||
|
This sketch demonstrates loading images from arrays stored in program (FLASH) memory.
|
||||||
|
|
||||||
|
Works with TFT_eSPI library here:
|
||||||
|
https://github.com/Bodmer/TFT_eSPI
|
||||||
|
|
||||||
|
This sketch does not use/need any fonts at all...
|
||||||
|
|
||||||
|
Code derived from ILI9341_due library example
|
||||||
|
|
||||||
|
Make sure all the display driver and pin comnenctions 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 ######
|
||||||
|
#########################################################################
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <TFT_eSPI.h> // Hardware-specific library
|
||||||
|
|
||||||
|
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
|
||||||
|
|
||||||
|
// Include the header files that contain the icons
|
||||||
|
#include "Alert.h"
|
||||||
|
#include "Close.h"
|
||||||
|
#include "Info.h"
|
||||||
|
|
||||||
|
long count = 0; // Loop count
|
||||||
|
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
Serial.begin(115200);
|
||||||
|
tft.begin();
|
||||||
|
tft.setRotation(1); // landscape
|
||||||
|
|
||||||
|
tft.fillScreen(TFT_BLACK);
|
||||||
|
|
||||||
|
// Swap the colour byte order when rendering
|
||||||
|
tft.setSwapBytes(true);
|
||||||
|
|
||||||
|
// Draw the icons
|
||||||
|
tft.pushImage(100, 100, infoWidth, infoHeight, info);
|
||||||
|
tft.pushImage(140, 100, alertWidth, alertHeight, alert);
|
||||||
|
tft.pushImage(180, 100, closeWidth, closeHeight, closeX);
|
||||||
|
|
||||||
|
// Pause here to admire the icons!
|
||||||
|
delay(2000);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop()
|
||||||
|
{
|
||||||
|
// Loop filling and clearing screen
|
||||||
|
tft.pushImage(random(tft.width() - infoWidth), random(tft.height() - infoHeight), infoWidth, infoHeight, info);
|
||||||
|
tft.pushImage(random(tft.width() - alertWidth), random(tft.height() - alertHeight), alertWidth, alertHeight, alert);
|
||||||
|
tft.pushImage(random(tft.width() - closeWidth), random(tft.height() - closeHeight), alertWidth, closeHeight, closeX);
|
||||||
|
|
||||||
|
// Clear screen after 100 x 3 = 300 icons drawn
|
||||||
|
if (1000 == count++) {
|
||||||
|
count = 1;
|
||||||
|
tft.setRotation(2 * random(2)); // Rotate randomly to clear display left>right or right>left to reduce monotony!
|
||||||
|
tft.fillScreen(TFT_BLACK);
|
||||||
|
tft.setRotation(1);
|
||||||
|
}
|
||||||
|
}
|
182
examples/Sprite/Rotated_Sprite_1/Rotated_Sprite_1.ino
Normal file
182
examples/Sprite/Rotated_Sprite_1/Rotated_Sprite_1.ino
Normal file
@@ -0,0 +1,182 @@
|
|||||||
|
// This example plots a rotated Sprite to the screen using the pushRotated()
|
||||||
|
// function. It is written for a 240 x 320 TFT screen.
|
||||||
|
|
||||||
|
// Two rotation pivot points must be set, one for the Sprite and one for the TFT
|
||||||
|
// using setPivot(). These pivot points do not need to be within the visible screen
|
||||||
|
// or Sprite boundary.
|
||||||
|
|
||||||
|
// When the Sprite is rotated and pushed to the TFT with pushRotated(angle) it will be
|
||||||
|
// drawn so that the two pivot points coincide. This makes rotation about a point on the
|
||||||
|
// screen very simple. The rotation is clockwise with increasing angle. The angle is in
|
||||||
|
// degrees, an angle of 0 means no Sprite rotation.
|
||||||
|
|
||||||
|
// The pushRotated() function works with 1, 8 and 16 bit per pixel (bpp) Sprites.
|
||||||
|
|
||||||
|
// The original Sprite is unchanged so can be plotted again at a different angle.
|
||||||
|
|
||||||
|
// Optionally a transparent colour can be defined, pixels of this colour will
|
||||||
|
// not be plotted to the TFT.
|
||||||
|
|
||||||
|
// For 1 bpp Sprites the foreground and background colours are defined with the
|
||||||
|
// function spr.setBitmapColor(foregroundColor, backgroundColor).
|
||||||
|
|
||||||
|
// Created by Bodmer 6/1/19 as an example to the TFT_eSPI library:
|
||||||
|
// https://github.com/Bodmer/TFT_eSPI
|
||||||
|
|
||||||
|
#include <TFT_eSPI.h>
|
||||||
|
|
||||||
|
TFT_eSPI tft = TFT_eSPI(); // TFT object
|
||||||
|
|
||||||
|
TFT_eSprite spr = TFT_eSprite(&tft); // Sprite object
|
||||||
|
|
||||||
|
// =======================================================================================
|
||||||
|
// Setup
|
||||||
|
// =======================================================================================
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(250000); // Debug only
|
||||||
|
|
||||||
|
tft.begin(); // initialize
|
||||||
|
tft.setRotation(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// =======================================================================================
|
||||||
|
// Loop
|
||||||
|
// =======================================================================================
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
|
||||||
|
int xw = tft.width()/2; // xw, yh is midle of screen
|
||||||
|
int yh = tft.height()/2;
|
||||||
|
|
||||||
|
|
||||||
|
showMessage("90 degree angles");
|
||||||
|
tft.setPivot(xw, yh); // Set pivot to middle of TFT screen
|
||||||
|
drawX(xw, yh); // Show where screen pivot is
|
||||||
|
|
||||||
|
// Create the Sprite
|
||||||
|
spr.setColorDepth(8); // Create an 8bpp Sprite of 60x30 pixels
|
||||||
|
spr.createSprite(64, 30); // 8bpp requires 64 * 30 = 1920 bytes
|
||||||
|
spr.setPivot(32, 55); // Set pivot relative to top left corner of Sprite
|
||||||
|
spr.fillSprite(TFT_BLACK); // Fill the Sprite with black
|
||||||
|
|
||||||
|
spr.setTextColor(TFT_GREEN); // Green text
|
||||||
|
spr.setTextDatum(MC_DATUM); // Middle centre datum
|
||||||
|
spr.drawString("Hello", 32, 15, 4); // Plot text, font 4, in Sprite at 30, 15
|
||||||
|
|
||||||
|
spr.pushRotated(0);
|
||||||
|
spr.pushRotated(90);
|
||||||
|
spr.pushRotated(180);
|
||||||
|
spr.pushRotated(270);
|
||||||
|
|
||||||
|
delay(2000);
|
||||||
|
|
||||||
|
|
||||||
|
showMessage("45 degree angles");
|
||||||
|
drawX(xw, yh); // Show where screen pivot is
|
||||||
|
|
||||||
|
spr.pushRotated(45);
|
||||||
|
spr.pushRotated(135);
|
||||||
|
spr.pushRotated(225);
|
||||||
|
spr.pushRotated(315);
|
||||||
|
|
||||||
|
delay(2000); // Pause so we see it
|
||||||
|
|
||||||
|
|
||||||
|
showMessage("Moved Sprite pivot point");
|
||||||
|
drawX(xw, yh); // Show where screen pivot is
|
||||||
|
|
||||||
|
spr.setPivot(-20, 15); // Change just the Sprite pivot point
|
||||||
|
|
||||||
|
spr.pushRotated(45);
|
||||||
|
spr.pushRotated(135);
|
||||||
|
spr.pushRotated(225);
|
||||||
|
spr.pushRotated(315);
|
||||||
|
|
||||||
|
delay(2000); // Pause so we see it
|
||||||
|
|
||||||
|
|
||||||
|
showMessage("Moved TFT pivot point");
|
||||||
|
tft.setPivot(100, 100); // Change just the TFT pivot point
|
||||||
|
drawX(100, 100); // Show where pivot is
|
||||||
|
|
||||||
|
spr.pushRotated(45);
|
||||||
|
spr.pushRotated(135);
|
||||||
|
spr.pushRotated(225);
|
||||||
|
spr.pushRotated(315);
|
||||||
|
|
||||||
|
delay(2000); // Pause so we see it
|
||||||
|
|
||||||
|
|
||||||
|
showMessage("Transparent rotations");
|
||||||
|
tft.fillCircle(xw, yh, 70, TFT_DARKGREY); // Draw a filled circle
|
||||||
|
|
||||||
|
tft.setPivot(xw, yh); // Set pivot to middle of screen
|
||||||
|
drawX(xw, yh); // Show where pivot is
|
||||||
|
|
||||||
|
spr.deleteSprite();
|
||||||
|
|
||||||
|
spr.setColorDepth(8); // Create a 8bpp Sprite
|
||||||
|
spr.createSprite(40, 30); // Create a new Sprite 40x30
|
||||||
|
spr.setPivot(20, 70); // Set Sprite pivot at 20,80
|
||||||
|
|
||||||
|
spr.setTextColor(TFT_RED); // Red text in Sprite
|
||||||
|
spr.setTextDatum(MC_DATUM); // Middle centre datum
|
||||||
|
|
||||||
|
int num = 1;
|
||||||
|
|
||||||
|
for (int16_t angle = 30; angle <= 360; angle += 30)
|
||||||
|
{
|
||||||
|
spr.fillSprite(TFT_BLACK); // Clear the Sprite
|
||||||
|
spr.drawNumber(num, 20, 15, 4); // Plot number, in Sprite at 15,15 and with font 4
|
||||||
|
spr.pushRotated(angle, TFT_BLACK); // Plot rotated Sprite, black being transparent
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
|
||||||
|
spr.setTextColor(TFT_WHITE); // White text in Sprite
|
||||||
|
spr.setPivot(-75, 15); // Set Sprite pivot at -75,15
|
||||||
|
|
||||||
|
for (int16_t angle = -90; angle < 270; angle += 30)
|
||||||
|
{
|
||||||
|
spr.fillSprite(TFT_BLACK); // Clear the Sprite
|
||||||
|
spr.drawNumber(angle+90, 15, 15, 4); // Plot number, in Sprite at 15,15 and with font 4
|
||||||
|
spr.pushRotated(angle, TFT_BLACK); // Plot rotated Sprite, black being transparent
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
|
||||||
|
delay(8000); // Pause so we see it
|
||||||
|
|
||||||
|
spr.deleteSprite();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// =======================================================================================
|
||||||
|
// Draw an X centered on x,y
|
||||||
|
// =======================================================================================
|
||||||
|
|
||||||
|
void drawX(int x, int y)
|
||||||
|
{
|
||||||
|
tft.drawLine(x-5, y-5, x+5, y+5, TFT_WHITE);
|
||||||
|
tft.drawLine(x-5, y+5, x+5, y-5, TFT_WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// =======================================================================================
|
||||||
|
// Show a message at the top of the screen
|
||||||
|
// =======================================================================================
|
||||||
|
|
||||||
|
void showMessage(String msg)
|
||||||
|
{
|
||||||
|
// Clear the screen areas
|
||||||
|
tft.fillRect(0, 0, tft.width(), 20, TFT_BLACK);
|
||||||
|
tft.fillRect(0, 20, tft.width(), tft.height()-20, TFT_BLUE);
|
||||||
|
|
||||||
|
uint8_t td = tft.getTextDatum(); // Get current datum
|
||||||
|
|
||||||
|
tft.setTextDatum(TC_DATUM); // Set new datum
|
||||||
|
|
||||||
|
tft.drawString(msg, tft.width()/2, 2, 2); // Message in font 2
|
||||||
|
|
||||||
|
tft.setTextDatum(td); // Restore old datum
|
||||||
|
}
|
||||||
|
|
||||||
|
// =======================================================================================
|
181
examples/Sprite/Rotated_Sprite_2/Rotated_Sprite_2.ino
Normal file
181
examples/Sprite/Rotated_Sprite_2/Rotated_Sprite_2.ino
Normal file
@@ -0,0 +1,181 @@
|
|||||||
|
// This example plots a rotated Sprite into another Sprite and then the resultant composited
|
||||||
|
// Sprite is pushed to the TFT screen. This example is for a 240 x 320 screen.
|
||||||
|
|
||||||
|
// The motivation for developing this capability is that animated dials can be drawn easily
|
||||||
|
// and the complex calculations involved are handled by the TFT_eSPI library. To create a dial
|
||||||
|
// with a moving needle a graphic of a meter needle is plotted at a specified angle into another
|
||||||
|
// Sprite that contains the dial face. When the needle Sprite is pushed to the dial Sprite the
|
||||||
|
// plotting ensures two pivot points for each Sprite coincide with pixel level accuracy.
|
||||||
|
|
||||||
|
// Two rotation pivot points must be set, one for the first Sprite and one for the second
|
||||||
|
// Sprite using setPivot(). These pivot points do not need to be within the Sprite boundaries.
|
||||||
|
|
||||||
|
// In this example a needle graphic is also be plotted direct to a defined TFT pivot point.
|
||||||
|
|
||||||
|
// The rotation angle is in degrees, an angle of 0 means no Sprite rotation.
|
||||||
|
|
||||||
|
// The pushRotated() function works with 1, 8 and 16 bit per pixel (bpp) Sprites.
|
||||||
|
|
||||||
|
// For 1 bpp Sprites the foreground and background colours are defined with the
|
||||||
|
// member function setBitmapColor(foregroundColor, backgroundColor).
|
||||||
|
|
||||||
|
// Created by Bodmer 6/1/19 as an example to the TFT_eSPI library:
|
||||||
|
// https://github.com/Bodmer/TFT_eSPI
|
||||||
|
|
||||||
|
#include <TFT_eSPI.h>
|
||||||
|
|
||||||
|
TFT_eSPI tft = TFT_eSPI();
|
||||||
|
|
||||||
|
TFT_eSprite dial = TFT_eSprite(&tft); // Sprite object for dial
|
||||||
|
TFT_eSprite needle = TFT_eSprite(&tft); // Sprite object for needle
|
||||||
|
|
||||||
|
uint32_t startMillis;
|
||||||
|
|
||||||
|
int16_t angle = 0;
|
||||||
|
|
||||||
|
// =======================================================================================
|
||||||
|
// Setup
|
||||||
|
// =======================================================================================
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(250000); // Debug only
|
||||||
|
|
||||||
|
tft.begin();
|
||||||
|
tft.setRotation(1);
|
||||||
|
|
||||||
|
// Clear TFT screen
|
||||||
|
tft.fillScreen(TFT_NAVY);
|
||||||
|
|
||||||
|
// Create the dial Sprite and dial (this temporarily hijacks the use of the needle Sprite)
|
||||||
|
createDialScale(-120, 120, 30); // create scale (start angle, end angle, increment angle)
|
||||||
|
drawEmptyDial("Label", 12345); // draw the centre of dial in the Sprite
|
||||||
|
|
||||||
|
dial.pushSprite(110, 0); // push a copy of the dial to the screen so we can see it
|
||||||
|
|
||||||
|
// Create the needle Sprite
|
||||||
|
createNeedle(); // draw the needle graphic
|
||||||
|
needle.pushSprite(95, 7); // push a copy of the needle to the screen so we can see it
|
||||||
|
}
|
||||||
|
|
||||||
|
// =======================================================================================
|
||||||
|
// Loop
|
||||||
|
// =======================================================================================
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
|
||||||
|
// Push the needle sprite to the dial Sprite at different angles and then push the dial to the screen
|
||||||
|
// Use angle increments in range 1 to 6 for smoother or faster movement
|
||||||
|
for (int16_t angle = -120; angle <= 120; angle += 2) {
|
||||||
|
plotDial(0, 0, angle, "RPM", angle + 120);
|
||||||
|
delay(25);
|
||||||
|
yield(); // Avoid a watchdog time-out
|
||||||
|
}
|
||||||
|
|
||||||
|
delay(1000); // Pause
|
||||||
|
|
||||||
|
// Update the dial Sprite with decreasing angle and plot to screen at 0,0, no delay
|
||||||
|
for (int16_t angle = 120; angle >= -120; angle -= 2) {
|
||||||
|
plotDial(0, 0, angle, "RPM", angle + 120);
|
||||||
|
yield(); // Avoid a watchdog time-out
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now show plotting of the rotated needle direct to the TFT
|
||||||
|
tft.setPivot(45, 150); // Set the TFT pivot point that the needle will rotate around
|
||||||
|
|
||||||
|
// The needle graphic has a black border so if the angle increment is small
|
||||||
|
// (6 degrees or less in this case) it wipes the last needle position when
|
||||||
|
// it is rotated and hence it clears the swept area to black
|
||||||
|
for (int16_t angle = 0; angle <= 360; angle += 5)
|
||||||
|
{
|
||||||
|
needle.pushRotated(angle); // Plot direct to TFT at specifed angle
|
||||||
|
yield(); // Avoid a watchdog time-out
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// =======================================================================================
|
||||||
|
// Create the dial sprite, the dial outer and place scale markers
|
||||||
|
// =======================================================================================
|
||||||
|
|
||||||
|
void createDialScale(int16_t start_angle, int16_t end_angle, int16_t increment)
|
||||||
|
{
|
||||||
|
// Create the dial Sprite
|
||||||
|
dial.setColorDepth(8); // Size is odd (i.e. 91) so there is a centre pixel at 45,45
|
||||||
|
dial.createSprite(91, 91); // 8bpp requires 91 * 91 = 8281 bytes
|
||||||
|
dial.setPivot(45, 45); // set pivot in middle of dial Sprite
|
||||||
|
|
||||||
|
// Draw dial outline
|
||||||
|
dial.fillSprite(TFT_TRANSPARENT); // Fill with transparent colour
|
||||||
|
dial.fillCircle(45, 45, 43, TFT_DARKGREY); // Draw dial outer
|
||||||
|
|
||||||
|
// Hijack the use of the needle Sprite since that has not been used yet!
|
||||||
|
needle.createSprite(3, 3); // 3 pixels wide, 3 high
|
||||||
|
needle.fillSprite(TFT_WHITE); // Fill with white
|
||||||
|
needle.setPivot(1, 43); // Set pivot point x to the Sprite centre and y to marker radius
|
||||||
|
|
||||||
|
for (int16_t angle = start_angle; angle <= end_angle; angle += increment) {
|
||||||
|
needle.pushRotated(&dial, angle); // Sprite is used to make scale markers
|
||||||
|
yield(); // Avoid a watchdog time-out
|
||||||
|
}
|
||||||
|
|
||||||
|
needle.deleteSprite(); // Delete the hijacked Sprite
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// =======================================================================================
|
||||||
|
// Add the empty dial face with label and value
|
||||||
|
// =======================================================================================
|
||||||
|
|
||||||
|
void drawEmptyDial(String label, int16_t val)
|
||||||
|
{
|
||||||
|
// Draw black face
|
||||||
|
dial.fillCircle(45, 45, 40, TFT_BLACK);
|
||||||
|
dial.drawPixel(45, 45, TFT_WHITE); // For demo only, mark pivot point with a while pixel
|
||||||
|
|
||||||
|
dial.setTextDatum(TC_DATUM); // Draw dial text
|
||||||
|
dial.drawString(label, 45, 15, 2);
|
||||||
|
dial.drawNumber(val, 45, 60, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// =======================================================================================
|
||||||
|
// Update the dial and plot to screen with needle at defined angle
|
||||||
|
// =======================================================================================
|
||||||
|
|
||||||
|
void plotDial(int16_t x, int16_t y, int16_t angle, String label, uint16_t val)
|
||||||
|
{
|
||||||
|
// Draw the blank dial in the Sprite, add label and number
|
||||||
|
drawEmptyDial(label, val);
|
||||||
|
|
||||||
|
// Push a rotated needle Sprite to the dial Sprite, with black as transparent colour
|
||||||
|
needle.pushRotated(&dial, angle, TFT_BLACK); // dial is the destination Sprite
|
||||||
|
|
||||||
|
// Push the resultant dial Sprite to the screen, with transparent colour
|
||||||
|
dial.pushSprite(x, y, TFT_TRANSPARENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
// =======================================================================================
|
||||||
|
// Create the needle Sprite and the image of the needle
|
||||||
|
// =======================================================================================
|
||||||
|
|
||||||
|
void createNeedle(void)
|
||||||
|
{
|
||||||
|
needle.setColorDepth(8);
|
||||||
|
needle.createSprite(11, 49); // create the needle Sprite 11 pixels wide by 49 high
|
||||||
|
|
||||||
|
needle.fillSprite(TFT_BLACK); // Fill with black
|
||||||
|
|
||||||
|
// Define needle pivot point
|
||||||
|
uint16_t piv_x = needle.width() / 2; // x pivot of Sprite (middle)
|
||||||
|
uint16_t piv_y = needle.height() - 10; // y pivot of Sprite (10 pixels from bottom)
|
||||||
|
needle.setPivot(piv_x, piv_y); // Set pivot point in this Sprite
|
||||||
|
|
||||||
|
// Draw the red needle with a yellow tip
|
||||||
|
// Keep needle tip 1 pixel inside dial circle to avoid leaving stray pixels
|
||||||
|
needle.fillRect(piv_x - 1, 2, 3, piv_y + 8, TFT_RED);
|
||||||
|
needle.fillRect(piv_x - 1, 2, 3, 5, TFT_YELLOW);
|
||||||
|
|
||||||
|
// Draw needle centre boss
|
||||||
|
needle.fillCircle(piv_x, piv_y, 5, TFT_MAROON);
|
||||||
|
needle.drawPixel( piv_x, piv_y, TFT_WHITE); // Mark needle pivot point with a white pixel
|
||||||
|
}
|
||||||
|
|
||||||
|
// =======================================================================================
|
140
examples/Sprite/Rotated_Sprite_3/Rotated_Sprite_3.ino
Normal file
140
examples/Sprite/Rotated_Sprite_3/Rotated_Sprite_3.ino
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
/*====================================================================================
|
||||||
|
|
||||||
|
This example draws a jpeg image in a Sprite then plots a rotated copy of the Sprite
|
||||||
|
to the TFT.
|
||||||
|
|
||||||
|
The jpeg used is in the sketch Data folder (presss Ctrl+K to see folder)
|
||||||
|
|
||||||
|
The jpeg must be uploaded to the ESP8266 or ESP32 SPIFFS by using the Tools menu
|
||||||
|
sketch data upload option of the Arduino IDE. If you do not have that option it can
|
||||||
|
be added. Close the Serial Monitor window before uploading to avoid an error message!
|
||||||
|
|
||||||
|
To add the upload option for the ESP8266 see:
|
||||||
|
http://www.esp8266.com/viewtopic.php?f=32&t=10081
|
||||||
|
https://github.com/esp8266/arduino-esp8266fs-plugin/releases
|
||||||
|
|
||||||
|
To add the upload option for the ESP32 see:
|
||||||
|
https://github.com/me-no-dev/arduino-esp32fs-plugin
|
||||||
|
|
||||||
|
Created by Bodmer 6/1/19 as an example to the TFT_eSPI library:
|
||||||
|
https://github.com/Bodmer/TFT_eSPI
|
||||||
|
|
||||||
|
Extension funtions in the TFT_eFEX library are used to list SPIFFS files and render
|
||||||
|
the jpeg to the TFT and to the Sprite:
|
||||||
|
https://github.com/Bodmer/TFT_eFEX
|
||||||
|
|
||||||
|
To render the Jpeg image the JPEGDecoder library is needed, this can be obtained
|
||||||
|
with the IDE library manager, or downloaded from here:
|
||||||
|
https://github.com/Bodmer/JPEGDecoder
|
||||||
|
|
||||||
|
==================================================================================*/
|
||||||
|
|
||||||
|
//====================================================================================
|
||||||
|
// 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" // Needed for ESP32 only
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// https://github.com/Bodmer/TFT_eSPI
|
||||||
|
#include <TFT_eSPI.h> // Hardware-specific library
|
||||||
|
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
|
||||||
|
TFT_eSprite spr = TFT_eSprite(&tft); // Create Sprite object "spr" with pointer to "tft" object
|
||||||
|
|
||||||
|
// https://github.com/Bodmer/TFT_eFEX
|
||||||
|
#include <TFT_eFEX.h> // Include the function extension library
|
||||||
|
TFT_eFEX fex = TFT_eFEX(&tft); // Create TFT_eFX object "fex" with pointer to "tft" object
|
||||||
|
|
||||||
|
|
||||||
|
//====================================================================================
|
||||||
|
// Setup
|
||||||
|
//====================================================================================
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
Serial.begin(250000); // Used for messages
|
||||||
|
|
||||||
|
tft.begin();
|
||||||
|
tft.setRotation(0); // 0 & 2 Portrait. 1 & 3 landscape
|
||||||
|
tft.fillScreen(TFT_BLACK);
|
||||||
|
|
||||||
|
// Create a sprite to hold the jpeg (or part of it)
|
||||||
|
spr.createSprite(80, 64);
|
||||||
|
|
||||||
|
// Initialise SPIFFS
|
||||||
|
if (!SPIFFS.begin()) {
|
||||||
|
Serial.println("SPIFFS initialisation failed!");
|
||||||
|
while (1) yield(); // Stay here twiddling thumbs waiting
|
||||||
|
}
|
||||||
|
Serial.println("\r\nInitialisation done.\r\n");
|
||||||
|
|
||||||
|
// Lists the files so you can see what is in the SPIFFS
|
||||||
|
fex.listSPIFFS();
|
||||||
|
|
||||||
|
// Note the / before the SPIFFS file name must be present, this means the file is in
|
||||||
|
// the root directory of the SPIFFS, e.g. "/tiger.jpg" for a file called "tiger.jpg"
|
||||||
|
|
||||||
|
// Send jpeg info to serial port
|
||||||
|
fex.jpegInfo("/Eye_80x64.jpg");
|
||||||
|
|
||||||
|
// Draw jpeg iamge in Sprite spr at 0,0
|
||||||
|
fex.drawJpeg("/Eye_80x64.jpg", 0 , 0, &spr);
|
||||||
|
}
|
||||||
|
|
||||||
|
//====================================================================================
|
||||||
|
// Loop
|
||||||
|
//====================================================================================
|
||||||
|
void loop()
|
||||||
|
{
|
||||||
|
|
||||||
|
tft.fillScreen(random(0xFFFF));
|
||||||
|
|
||||||
|
|
||||||
|
// Set the TFT pivot point to the centre of the screen
|
||||||
|
tft.setPivot(tft.width() / 2, tft.height() / 2);
|
||||||
|
|
||||||
|
// Set Sprite pivot point to centre of Sprite
|
||||||
|
spr.setPivot(spr.width() / 2, spr.height() / 2);
|
||||||
|
|
||||||
|
// Push Sprite to the TFT at 0,0 (not rotated)
|
||||||
|
spr.pushSprite(0, 0);
|
||||||
|
|
||||||
|
delay(1000);
|
||||||
|
|
||||||
|
// Push copies of Sprite rotated through increasing angles 0-360 degrees
|
||||||
|
// with 45 fegree increments
|
||||||
|
for (int16_t angle = 0; angle <= 360; angle += 45) {
|
||||||
|
spr.pushRotated(angle);
|
||||||
|
delay(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
delay(2000);
|
||||||
|
|
||||||
|
// Move Sprite pivot to a point above the image at 40,-60
|
||||||
|
// (Note: Top left corner is Sprite coordinate 0,0)
|
||||||
|
// The TFT pivot point has already been set to middle of screen.
|
||||||
|
/* .Pivot point at 40,-60
|
||||||
|
^
|
||||||
|
|
|
||||||
|
-60
|
||||||
|
< 40 >|
|
||||||
|
______V______
|
||||||
|
| |
|
||||||
|
| Sprite |
|
||||||
|
|_____________|
|
||||||
|
*/
|
||||||
|
spr.setPivot(40, -60);
|
||||||
|
|
||||||
|
// Push Sprite to screen rotated about the new pivot points
|
||||||
|
// negative angle rotates Sprite anticlockwise
|
||||||
|
for (int16_t angle = 330; angle >= 0; angle -= 30) {
|
||||||
|
spr.pushRotated(angle);
|
||||||
|
yield(); // Stop watchdog triggering
|
||||||
|
}
|
||||||
|
|
||||||
|
delay(5000);
|
||||||
|
}
|
||||||
|
//====================================================================================
|
BIN
examples/Sprite/Rotated_Sprite_3/data/EagleEye.jpg
Normal file
BIN
examples/Sprite/Rotated_Sprite_3/data/EagleEye.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
BIN
examples/Sprite/Rotated_Sprite_3/data/Eye_80x64.jpg
Normal file
BIN
examples/Sprite/Rotated_Sprite_3/data/Eye_80x64.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.7 KiB |
@@ -0,0 +1,139 @@
|
|||||||
|
// This **ONLY** works for 1 and 16 bpp Sprites due to lack of bounds checking in the
|
||||||
|
// Sprite pushImage() function for 8 bit Sprites (it is on the TO DO list)
|
||||||
|
|
||||||
|
// Wrapping scroll example by Bodmer for the TFT_eSPI library
|
||||||
|
|
||||||
|
//==========================================================================================
|
||||||
|
|
||||||
|
#include <TFT_eSPI.h>
|
||||||
|
|
||||||
|
TFT_eSPI tft = TFT_eSPI();
|
||||||
|
|
||||||
|
TFT_eSprite gfx = TFT_eSprite(&tft); // Sprite object for graphics write
|
||||||
|
|
||||||
|
TFT_eSprite fb = TFT_eSprite(&tft); // Sprite object for frame buffer
|
||||||
|
|
||||||
|
// Width and height of the Sprite
|
||||||
|
#define WIDTH 60
|
||||||
|
#define HEIGHT 60
|
||||||
|
|
||||||
|
// Define scroll increment in x and y directions
|
||||||
|
// positive numbers = right, down
|
||||||
|
// negative numbers = left, up
|
||||||
|
#define XDELTA 1
|
||||||
|
#define YDELTA 1
|
||||||
|
|
||||||
|
int16_t scroll_x = 0; // Keep track of the scrolled position, this is where the origin
|
||||||
|
int16_t scroll_y = 0; // (top left) of the gfx Sprite will be
|
||||||
|
|
||||||
|
int16_t radius = 5; // radius of circle
|
||||||
|
|
||||||
|
bool grow = true; // grow or shrink circle
|
||||||
|
|
||||||
|
uint16_t *gfxPtr; // Pointer to start of graphics sprite memory area
|
||||||
|
|
||||||
|
//==========================================================================================
|
||||||
|
//==========================================================================================
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(115200);
|
||||||
|
tft.init();
|
||||||
|
tft.fillScreen(TFT_BLACK);
|
||||||
|
|
||||||
|
tft.setRotation(1);
|
||||||
|
|
||||||
|
//tft.invertDisplay(true);
|
||||||
|
|
||||||
|
// Create a 1bpp sprite for the graphics
|
||||||
|
gfx.setColorDepth(1);
|
||||||
|
gfxPtr = (uint16_t*) gfx.createSprite(WIDTH, HEIGHT); // 480 bytes needed
|
||||||
|
gfx.fillSprite(TFT_BLACK); // Note: Sprite is filled with black when created
|
||||||
|
|
||||||
|
// Create a 1bpp sprite for the frame buffer
|
||||||
|
fb.setColorDepth(1);
|
||||||
|
fb.createSprite(WIDTH, HEIGHT); // 480 bytes needed
|
||||||
|
fb.fillSprite(TFT_BLACK); // Note: Sprite is filled with black when created
|
||||||
|
|
||||||
|
// Text colour and alignment in graphics Sprite
|
||||||
|
gfx.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||||
|
gfx.setTextDatum(MC_DATUM);
|
||||||
|
|
||||||
|
// Text colour and alignment in frame buffer
|
||||||
|
fb.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||||
|
fb.setTextDatum(MC_DATUM);
|
||||||
|
|
||||||
|
// Next 3 lines are for test only to see what we have drawn
|
||||||
|
drawGraphics(); // draw the graphics in the gfx sprite and copy to buffer
|
||||||
|
gfx.pushSprite(0, 0); // Plot to screen so we see what it looks like
|
||||||
|
delay(2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================================
|
||||||
|
//==========================================================================================
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
uint32_t tnow = millis();
|
||||||
|
drawGraphics(); // Not needed if scrolling graphics are static
|
||||||
|
|
||||||
|
wrappingScroll(XDELTA, YDELTA);
|
||||||
|
|
||||||
|
// Plot two copies without "Hello", then one in the middle with "Hello"
|
||||||
|
//fb.setBitmapColor(TFT_WHITE, TFT_RED );
|
||||||
|
fb.pushSprite(0, 0); // Plot frame buffer onto the TFT screen
|
||||||
|
//fb.setBitmapColor(TFT_WHITE, TFT_BLUE );
|
||||||
|
fb.pushSprite(120, 0); // Plot frame buffer onto the TFT screen
|
||||||
|
|
||||||
|
fb.drawString("Hello", 30, 20, 2); // Plot hello in frame buffer
|
||||||
|
//fb.setBitmapColor(TFT_BLACK, TFT_GREEN);
|
||||||
|
fb.pushSprite(60, 0); // Plot frame buffer in middle of other two
|
||||||
|
|
||||||
|
//Serial.println(millis() - tnow);
|
||||||
|
delay(20);
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================================
|
||||||
|
// Draw graphics in the master Sprite
|
||||||
|
//==========================================================================================
|
||||||
|
|
||||||
|
void drawGraphics(void)
|
||||||
|
{
|
||||||
|
gfx.fillSprite(TFT_BLACK); // Clear sprite each time and completely redraw
|
||||||
|
|
||||||
|
//gfx.drawRect(0,0,60,60,TFT_WHITE); // Test to check alignment
|
||||||
|
|
||||||
|
gfx.drawCircle( 30 , 30, radius, TFT_WHITE);
|
||||||
|
if (grow) radius++;
|
||||||
|
else radius--;
|
||||||
|
|
||||||
|
if ( radius > 25 ) grow = false;
|
||||||
|
if ( radius < 1 ) grow = true;
|
||||||
|
|
||||||
|
gfx.drawString("World", 30, 40, 2); // Plot hello in frame buffer
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================================
|
||||||
|
// This function scrolls and wraps the graphic in a 1 bit per pixel Sprite, dy and dy
|
||||||
|
// control the scroll direction. Pixels that scroll off one side appear on the other.
|
||||||
|
// Scrolling is achieved by plotting one Sprite inside another with an offset. This has
|
||||||
|
// to be done by plotting 4 times into a second frame buffer Sprite.
|
||||||
|
//==========================================================================================
|
||||||
|
void wrappingScroll(int16_t dx, int16_t dy)
|
||||||
|
{
|
||||||
|
// Position the quadrants so they overlap all areas of the buffer
|
||||||
|
scroll_x += dx;
|
||||||
|
if (scroll_x < -WIDTH) scroll_x += WIDTH;
|
||||||
|
if (scroll_x > 0) scroll_x -= WIDTH;
|
||||||
|
|
||||||
|
scroll_y += dy;
|
||||||
|
if (scroll_y < -HEIGHT) scroll_y += HEIGHT;
|
||||||
|
if (scroll_y > 0) scroll_y -= HEIGHT;
|
||||||
|
|
||||||
|
// push the 4 quadrants of gfx. sprite into the fb. sprite
|
||||||
|
// pushImage will do the cropping
|
||||||
|
fb.pushImage(scroll_x, scroll_y, WIDTH, HEIGHT, gfxPtr);
|
||||||
|
fb.pushImage(scroll_x + WIDTH, scroll_y, WIDTH, HEIGHT, gfxPtr);
|
||||||
|
fb.pushImage(scroll_x, scroll_y + HEIGHT, WIDTH, HEIGHT, gfxPtr);
|
||||||
|
fb.pushImage(scroll_x + WIDTH, scroll_y + HEIGHT, WIDTH, HEIGHT, gfxPtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================================
|
@@ -74,11 +74,11 @@ textWidth KEYWORD2
|
|||||||
fontHeight KEYWORD2
|
fontHeight KEYWORD2
|
||||||
|
|
||||||
getTouchRaw KEYWORD2
|
getTouchRaw KEYWORD2
|
||||||
|
convertRawXY KEYWORD2
|
||||||
getTouchRawZ KEYWORD2
|
getTouchRawZ KEYWORD2
|
||||||
getTouch KEYWORD2
|
getTouch KEYWORD2
|
||||||
calibrateTouch KEYWORD2
|
calibrateTouch KEYWORD2
|
||||||
setTouch KEYWORD2
|
setTouch KEYWORD2
|
||||||
validTouch KEYWORD2
|
|
||||||
|
|
||||||
TFT_eSPI_Button KEYWORD1
|
TFT_eSPI_Button KEYWORD1
|
||||||
|
|
||||||
@@ -97,7 +97,13 @@ TFT_eSprite KEYWORD1
|
|||||||
|
|
||||||
createSprite KEYWORD2
|
createSprite KEYWORD2
|
||||||
setColorDepth KEYWORD2
|
setColorDepth KEYWORD2
|
||||||
|
getColorDepth KEYWORD2
|
||||||
deleteSprite KEYWORD2
|
deleteSprite KEYWORD2
|
||||||
|
pushRotated KEYWORD2
|
||||||
|
rotatedBounds KEYWORD2
|
||||||
|
setPivot KEYWORD2
|
||||||
|
getPivotX KEYWORD2
|
||||||
|
getPivotY KEYWORD2
|
||||||
fillSprite KEYWORD2
|
fillSprite KEYWORD2
|
||||||
pushBitmap KEYWORD2
|
pushBitmap KEYWORD2
|
||||||
pushSprite KEYWORD2
|
pushSprite KEYWORD2
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "TFT_eSPI",
|
"name": "TFT_eSPI",
|
||||||
"version": "1.3.10",
|
"version": "1.3.11",
|
||||||
"keywords": "tft, ePaper, display, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486, ST7789",
|
"keywords": "tft, ePaper, display, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486, ST7789",
|
||||||
"description": "A TFT and ePaper SPI graphics library for ESP8266 and ESP32",
|
"description": "A TFT and ePaper SPI graphics library for ESP8266 and ESP32",
|
||||||
"repository":
|
"repository":
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
name=TFT_eSPI
|
name=TFT_eSPI
|
||||||
version=1.3.10
|
version=1.3.11
|
||||||
author=Bodmer
|
author=Bodmer
|
||||||
maintainer=Bodmer
|
maintainer=Bodmer
|
||||||
sentence=A fast TFT graphics library for ESP8266 and ESP32 processors for the Arduino IDE
|
sentence=A fast TFT graphics library for ESP8266 and ESP32 processors for the Arduino IDE
|
||||||
|
Reference in New Issue
Block a user