You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If transparency isn't specified the function uses 0xFFFF as the transparent color.
The white text is not displayed if transparency isn't specified.
In Sprite.h transparency is specified as an OPTION but also with a value:
Push a rotated copy of Sprite to TFT with optional transparent colour
bool pushRotated(int16_t angle, uint32_t transp = 0x00FFFFFF); // Using fixed point maths
Is there a reason for the default transparency value?
Another question about the time completing a call to pushRotated. Mostly about 107ms in the example below but sometimes it grows up to 200ms or more.
It seems that happened always at the same angles.
I understand that the amount of data grows up if a sprite rectangle rotated because the bounding rectangle increases.
But the time increases more than expected.
Okay, my situation:
The sprite is a circle, a compass.
In this situation (circle) there is no "worst case", about 45 degrees or so, the bounding rectangle is always radius * 2.
Maybe you like to include an option to rotate a sprite in the original size.
In that case the time for the function pushRotated() should be the same.
void SpritePlot()
{
speed = millis();
//*********************************************************************************************************************
// Push rotated sprite.
// It seems that if transparency isn't specified the function uses 0xFFFF as the transparent color
// The white text is not displayed if transparency isn't specified
// In Sprite.h transparency is specified as an option but also with a value:
// Push a rotated copy of Sprite to TFT with optional transparent colour
// bool pushRotated(int16_t angle, uint32_t transp = 0x00FFFFFF); // Using fixed point maths
//*********************************************************************************************************************
sprite.pushRotated(angle, 0x1234); // with white text
//sprite.pushRotated(angle); // no white text
If transparency isn't specified the function uses 0xFFFF as the transparent color.
The white text is not displayed if transparency isn't specified.
In Sprite.h transparency is specified as an OPTION but also with a value:
Push a rotated copy of Sprite to TFT with optional transparent colour
bool pushRotated(int16_t angle, uint32_t transp = 0x00FFFFFF); // Using fixed point maths
Is there a reason for the default transparency value?
Another question about the time completing a call to pushRotated.
Mostly about 107ms in the example below but sometimes it grows up to 200ms or more.
It seems that happened always at the same angles.
I understand that the amount of data grows up if a sprite rectangle rotated because the bounding rectangle increases.
But the time increases more than expected.
Okay, my situation:
The sprite is a circle, a compass.
In this situation (circle) there is no "worst case", about 45 degrees or so, the bounding rectangle is always radius * 2.
Maybe you like to include an option to rotate a sprite in the original size.
In that case the time for the function pushRotated() should be the same.
#include <TFT_eSPI.h> // TFT_espi Library
TFT_eSPI tft = TFT_eSPI();
TFT_eSprite sprite = TFT_eSprite(&tft); // sprite
int16_t angle = 0;
uint32_t update = 0;
uint32_t speed = 0;
int32_t width = 320;
int32_t height = 480;
void setup(void)
{
tft.init();
tft.fillScreen(0x0000);
tft.setPivot(width / 2, height / 2 + 32);
Draw();
update = millis(); // next update time
}
void loop()
{
if (update <= millis())
{
SpritePlot(); // draw sprite
angle = angle+1; // increase angle
if (angle >= 360) angle = 0; // limit angle
update = millis() + 500; // update time in milliseconds
}
}
void Draw(void)
{
// draw title text
tft.setTextSize(1);
tft.setTextColor(0x0000, 0xFFFF);
tft.setCursor(8, 8, 2);
tft.print(" Time to complete pushRotated() = ");
tft.setTextSize(2);
tft.setCursor(8, 28, 1);
tft.print("Time > 190ms at deg");
// create sprite
sprite.createSprite(width, width);
sprite.setColorDepth(16);
sprite.setPivot(width / 2, width / 2);
// fill sprite background
sprite.fillSprite(0x0000);
// draw scope arc lines
sprite.drawCircle(width / 2, width / 2, width * 0.4, 0x03E0);
sprite.drawCircle(width / 2, width / 2, width * 0.32, 0x03E0);
sprite.drawCircle(width / 2, width / 2, width * 0.24, 0x03E0);
sprite.drawCircle(width / 2, width / 2, width * 0.16, 0x03E0);
sprite.drawCircle(width / 2, width / 2, width * 0.08, 0x03E0);
// draw scope angle lines
sprite.drawLine(width / 2, width / 2, width / 2 + (width * 0.4 * cos(90 * DEG_TO_RAD)), width / 2 - (width * 0.4 * sin(90 * DEG_TO_RAD)), 0x03E0);
// draw angle text
sprite.setTextSize(2);
sprite.setTextColor(0xFFFF, 0x0000);
sprite.setCursor(width / 2 - 34, width / 2 - 8, 1);
sprite.print("Rotate");
}
void SpritePlot()
{
speed = millis();
//*********************************************************************************************************************
// Push rotated sprite.
// It seems that if transparency isn't specified the function uses 0xFFFF as the transparent color
// The white text is not displayed if transparency isn't specified
// In Sprite.h transparency is specified as an option but also with a value:
// Push a rotated copy of Sprite to TFT with optional transparent colour
// bool pushRotated(int16_t angle, uint32_t transp = 0x00FFFFFF); // Using fixed point maths
//*********************************************************************************************************************
sprite.pushRotated(angle, 0x1234); // with white text
//sprite.pushRotated(angle); // no white text
// draw speed time
speed = millis() - speed;
tft.setTextColor(TFT_BLACK, TFT_WHITE);
tft.setTextSize(2);
tft.setCursor(240, 8, 1);
tft.printf("%ims ", speed);
// draw last Time > 190ms at degrees
if (speed >= 190)
{
tft.setTextColor(0x0000, 0xFFFF);
tft.setTextSize(2);
tft.setCursor(244, 28, 1);
tft.printf("%i ", angle);
}
}
The text was updated successfully, but these errors were encountered: