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:
1 parent
e8c201db5e
commit
96228cbf44
30 files changed
+1164
-656
No files matched your search
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user