Hello All,
I am trying to rotate a GFX image (not bitmap) mapped to gyro data around the center of the GFX image x,y (see image pic). Turn left, rotate GFX left, etc.. Max rotation will be only about 60-90 degrees, then image will recenter itself when user stops turning (kind of how your eyes can only turn so far in your head, and then you turn your head).
I am coding this bit by bit. I think i can map the gyro data without issue.
But, I want to be able to rotate my GFX first(as a test run), by degrees, from a center of 0 (dead ahead on the GFX image), to max left -90, to max right +90. I am having difficulty understanding how to rotate the GFX image . I only need to re-draw the radians and the arcs, as the circles that they sit on can remain static (you would not notice a circle turning on itself).
- to change position
- create new data for TFT
- erase old data from TFT
- display new data
I have read through many tutorials, I can rotate a bitmap and I can position a scan drawLine radian to follow degrees. But I can't seem to get a handle on rotating my whole GFX image.
THX in advance for any pointers!
I have this code:
#include <Servo.h>
#include <UTFT_Geometry.h>
#include <UTFT.h>
extern uint8_t SmallFont[]; //comes w/UTFT
extern uint8_t BigFont[]; // comes w/UTFT
#define radiusMax 200
#define width 318
#define height 240
#define radius 140//
UTFT myGLCD(ILI9341_S5P, 12, 13, 10, 8, 9); // (ILI9341_S5P, MOSI, SCK, CS, RST,DC)
UTFT_Geometry geo(&myGLCD);
Servo servo;
#define center_x 160 //width/2
#define center_y 230 //height position
void radarRings() {//draws two rings, two radians, and bunch of arcs
//these circles can remain static
myGLCD.setColor(0, 255, 0); // Sets color
myGLCD.drawCircle (center_x, center_y, (radius / 2) );
myGLCD.drawCircle (center_x, center_y, (radius) );
//these arcs will have to be re-drawn to match gyro data
for (int i = -90; i <= 90; i += 20) { //i += is space between tick marks
geo.drawArc(center_x, center_y, radius, i, i, (radius * 0.2)); //short radians
geo.drawArc(center_x, center_y, radius / 2, i, i, (radius * 0.2));
}
geo.drawArc(center_x, center_y, radius - 30, -40, -40, (radius - 10 ));//long radians
geo.drawArc(center_x, center_y, radius - 30, 40, 40, (radius -10 ));
geo.drawArc(center_x, center_y, (radius + (radius * .1)), -90, -50, 1);//large radius markers
geo.drawArc(center_x, center_y, (radius + (radius * .1)), -30, 30, 1);
geo.drawArc(center_x, center_y, (radius + (radius * .1)), 50, 90, 1);
geo.drawArc(center_x, center_y, (radius - (radius * .1)), -90, -50, 1);//large radius arcs
geo.drawArc(center_x, center_y, (radius - (radius * .1)), -30, 30, 1);
geo.drawArc(center_x, center_y, (radius - (radius * .1)), 50, 90, 1);
geo.drawArc(center_x, center_y, (radius / 2 - (radius * .1)), -90, -50, 1);//small radius markers
geo.drawArc(center_x, center_y, (radius / 2 - (radius * .1)), -30, 30, 1);
geo.drawArc(center_x, center_y, (radius / 2 - (radius * .1)), 50, 90, 1);
geo.drawArc(center_x, center_y, (radius / 2 + (radius * .1)), -90, -50, 1);//small radius arcs
geo.drawArc(center_x, center_y, (radius / 2 + (radius * .1)), -30, 30, 1);
geo.drawArc(center_x, center_y, (radius / 2 + (radius * .1)), 50, 90, 1);
}
void setup() {
myGLCD.InitLCD();
myGLCD.InitLCD(LANDSCAPE);
myGLCD.fillScr(VGA_BLACK);
radarRings();
void loop() {
}
I am guessing that I will need something like this:
float scanCircle= map(, , , , *PI); // map gyro to position
float xscanCircle = ? //
float yscanCircle = ?
I think that if I had one x,y coordinate on the main radius circle, and drew the entire scanRings in relation to that, it would work......?
Or will have to plot the new variables into radarRings()// probably have to rewrite radarRings() so that this is possible?
//write over new position radarRings GFX pixels
else
{ if no change don't write over old radarRings GFX pixels?}
