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
I am trying to push a rotated text onto a sprite. I can push the text to the sprite un-rotated, but when I try to push it rotated, I only get a green square. I am trying to make a compass wheel with the E and W letters rotated so that they will be upright when the wheel is rotated
void calcPoints(int degrees, int & x1, int & y1, int & x2, int & y2 ) {
x1 = 50 + 50 * cos (degrees * pi / 180);
y1 = 50 + 50 * sin (degrees * pi / 180);
x2 = 50 + 50 * cos (degrees * pi / 180);
y2 = 50 + 50 * sin (degrees * pi / 180);
}
void createWheel() {
dirWheel.setColorDepth(1);
dirWheel.createSprite(100, 100);
dirLetter.setColorDepth(1);
dirLetter.createSprite(14, 14);
dirLetter.fillSprite(TFT_BLACK);
dirLetter.setFreeFont(FM9);
dirLetter.setTextColor(TFT_GREEN,TFT_BLACK);
dirLetter.setTextDatum(CC_DATUM);
dirLetter.drawString("E", 7 ,7, GFXFF);
dirLetter.setPivot(7, 7);
dirWheel.setBitmapColor(TFT_GREEN, TFT_BLACK);
dirWheel.setPivot(50, 50);
dirWheel.fillSprite(TFT_BLACK);
dirLetter.pushToSprite(&dirWheel,1,43); //When this is is used, I get the E at the correct location on the dirWheel sprite
//dirLetter.pushRotated(&dirWheel,90); //When this line is used I get a green square at the middle of the dirWheel sprite
dirWheel.setFreeFont(FM9);
dirWheel.setTextColor(TFT_GREEN,TFT_BLACK);
dirWheel.setTextDatum(TC_DATUM);
dirWheel.drawString("N", 50 ,1, GFXFF);
dirWheel.setTextDatum(BC_DATUM);
dirWheel.drawString("S", 50 ,99, GFXFF);
dirWheel.pushRotated(0);
dirWheel.setTextDatum(ML_DATUM);
//dirWheel.drawString("E", 1 ,50, GFXFF);
dirWheel.setTextDatum(MR_DATUM);
dirWheel.drawString("W", 99 ,50, GFXFF);
int x1 = 0;
int y1 = 0;
int x2 = 0;
int y2 = 0;
calcPoints(45,x1,y1,x2,y2);
dirWheel.drawLine(x1, y1, x2, y2, TFT_GREEN);
calcPoints(135,x1,y1,x2,y2);
dirWheel.drawLine(x1, y1, x2, y2, TFT_GREEN);
calcPoints(225,x1,y1,x2,y2);
dirWheel.drawLine(x1, y1, x2, y2, TFT_GREEN);
calcPoints(315,x1,y1,x2,y2);
dirWheel.drawLine(x1, y1, x2, y2, TFT_GREEN);
dirWheel.setBitmapColor(TFT_GREEN, TFT_BLACK);
dirWheel.pushRotated(0);
}
void setup() {
Serial.begin(115200);
Serial.println();
Serial.println("Starting up...");
// Start the tft display
tft.init();
// Set the TFT display rotation in landscape mode
tft.setRotation(1);
// Clear the screen before writing to it
tft.fillScreen(TFT_BLACK);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
tft.setPivot(265, 185);
createWheel();
}
`
Am I doing something wrong or is this a bug ?
The text was updated successfully, but these errors were encountered:
I am trying to push a rotated text onto a sprite. I can push the text to the sprite un-rotated, but when I try to push it rotated, I only get a green square. I am trying to make a compass wheel with the E and W letters rotated so that they will be upright when the wheel is rotated
`#include "SPI.h"
#include "TFT_eSPI.h"
#include "Free_Fonts.h"
TFT_eSPI tft = TFT_eSPI();
TFT_eSprite dirWheel = TFT_eSprite(&tft);
TFT_eSprite dirLetter = TFT_eSprite(&tft);
void calcPoints(int degrees, int & x1, int & y1, int & x2, int & y2 ) {
x1 = 50 + 50 * cos (degrees * pi / 180);
y1 = 50 + 50 * sin (degrees * pi / 180);
x2 = 50 + 50 * cos (degrees * pi / 180);
y2 = 50 + 50 * sin (degrees * pi / 180);
}
void createWheel() {
dirWheel.setColorDepth(1);
dirWheel.createSprite(100, 100);
dirLetter.setColorDepth(1);
dirLetter.createSprite(14, 14);
dirLetter.fillSprite(TFT_BLACK);
dirLetter.setFreeFont(FM9);
dirLetter.setTextColor(TFT_GREEN,TFT_BLACK);
dirLetter.setTextDatum(CC_DATUM);
dirLetter.drawString("E", 7 ,7, GFXFF);
dirLetter.setPivot(7, 7);
dirWheel.setBitmapColor(TFT_GREEN, TFT_BLACK);
dirWheel.setPivot(50, 50);
dirWheel.fillSprite(TFT_BLACK);
dirLetter.pushToSprite(&dirWheel,1,43); //When this is is used, I get the E at the correct location on the dirWheel sprite
//dirLetter.pushRotated(&dirWheel,90); //When this line is used I get a green square at the middle of the dirWheel sprite
dirWheel.setFreeFont(FM9);
dirWheel.setTextColor(TFT_GREEN,TFT_BLACK);
dirWheel.setTextDatum(TC_DATUM);
dirWheel.drawString("N", 50 ,1, GFXFF);
dirWheel.setTextDatum(BC_DATUM);
dirWheel.drawString("S", 50 ,99, GFXFF);
dirWheel.pushRotated(0);
dirWheel.setTextDatum(ML_DATUM);
//dirWheel.drawString("E", 1 ,50, GFXFF);
dirWheel.setTextDatum(MR_DATUM);
dirWheel.drawString("W", 99 ,50, GFXFF);
int x1 = 0;
int y1 = 0;
int x2 = 0;
int y2 = 0;
calcPoints(45,x1,y1,x2,y2);
dirWheel.drawLine(x1, y1, x2, y2, TFT_GREEN);
calcPoints(135,x1,y1,x2,y2);
dirWheel.drawLine(x1, y1, x2, y2, TFT_GREEN);
calcPoints(225,x1,y1,x2,y2);
dirWheel.drawLine(x1, y1, x2, y2, TFT_GREEN);
calcPoints(315,x1,y1,x2,y2);
dirWheel.drawLine(x1, y1, x2, y2, TFT_GREEN);
dirWheel.setBitmapColor(TFT_GREEN, TFT_BLACK);
dirWheel.pushRotated(0);
}
void setup() {
Serial.begin(115200);
Serial.println();
Serial.println("Starting up...");
// Start the tft display
tft.init();
// Set the TFT display rotation in landscape mode
tft.setRotation(1);
// Clear the screen before writing to it
tft.fillScreen(TFT_BLACK);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
tft.setPivot(265, 185);
createWheel();
}
`
Am I doing something wrong or is this a bug ?
The text was updated successfully, but these errors were encountered: