Help to get image on 2.4" TFT dispaly

Hi, I have a code for a compass in Arduino and i have a code that i run in Processing 4 IDE to display the compass and all the info. I have a 2.4" TFT display and i cant figure out how to convert the code that im using in processing to show on the TFT lcd display. The display is 320x240 and the processing code is for an image of 320x240. I have attached a copy of the code please help.

import org.firmata.;
import cc.arduino.
;

import processing.serial.;
import cc.arduino.
;

float Pitch;
float Bank;
float Azimuth;
float ArtificialHoizonMagnificationFactor=0.7;
float CompassMagnificationFactor=0.85;
float SpanAngle=120;
int NumberOfScaleMajorDivisions;
int NumberOfScaleMinorDivisions;
PVector v1, v2;

Serial port;
float Phi;
float Theta;
float Psi;

void setup()
{
size(320, 240);
rectMode(CENTER);
smooth();
strokeCap(SQUARE);//Optional

println(Serial.list());
port = new Serial(this, Serial.list()[0], 115200);
port.bufferUntil('\n');
}
void draw()
{
background(0);
translate(320/4, 240/2.1);
MakeAnglesDependentOnMPU6050();

Compass();

}
void serialEvent(Serial port)
{
String input = port.readStringUntil('\n');
if(input != null){
input = trim(input);
String[] values = split(input, " ");
if(values.length == 3){
float phi = float(values[0]);
float theta = float(values[1]);
float psi = float(values[2]);
print(phi);
print(theta);
println(psi);
Phi = phi;
Theta = theta;
Psi = psi;
}
}
}
void MakeAnglesDependentOnMPU6050()
{
Bank =-Phi/5;
Pitch=Theta*10;
Azimuth=Psi;
}

void Compass()
{ stroke(0);
strokeWeight(4);
fill(100, 255, 100);
triangle(3.5, -65.6, -3.5, -65.6, 0, -84.4);

translate(320/4, 5);
scale(CompassMagnificationFactor);
noFill();
stroke(100);
strokeWeight(80);
ellipse(0, 0, 176, 234);
strokeWeight(50);
stroke(50);
fill(0, 0, 40);
ellipse(0, 0, 143, 190);
for (int k=255;k>0;k=k-5)
{
noStroke();
fill(0, 0, 255-k);
ellipse(0, 0, 2k, 2k);
}
rotate(-PI-radians(Azimuth));
strokeWeight(20);
NumberOfScaleMajorDivisions=18;
NumberOfScaleMinorDivisions=36;
SpanAngle=180;
CircularScale();
rotate(PI);
SpanAngle=180;
CircularScale();
rotate(-PI);
fill(255);
textSize(14);
textAlign(CENTER);
text("W", -114, 0, 23.5, 25);
text("E", 114, 0, 23.5, 25);
text("N", 0, -114, 23.5, 25);
text("S", 0, 114, 23.5, 25);

rotate(PI/4);
textSize(10);
text("NW", -114, 0, 23.5, 15.6);
text("SE", 114, 0, 23.5, 15.6);
text("NE", 0, -114, 23.5, 15.6);
text("SW", 0, 114, 23.5, 15.6);
rotate(-PI/4);
CompassPointer();
}
void CompassPointer()
{ rotate(-PI+radians(Azimuth));
stroke(0);
strokeWeight(4);
fill(100, 255, 100);
triangle(13.5, -75.6, -13.5, -75.6, 0, -94.4);

}
void Plane()
{
fill(0);
strokeWeight(1);
stroke(0, 255, 0);
triangle(-4.7, 0, 4.7, 0, 0, 7.8);
rect(25.8, 0, 32.8, 6.25);
rect(-25.8, 0, 32.8, 6.25);
}
void CircularScale()
{
float GaugeWidth=350;
textSize(GaugeWidth/30);
float StrokeWidth=1;
float an;
float DivxPhasorCloser;
float DivxPhasorDistal;
float DivyPhasorCloser;
float DivyPhasorDistal;
strokeWeight(2StrokeWidth);
stroke(255);
float DivCloserPhasorLenght=GaugeWidth/2-GaugeWidth/9-StrokeWidth;
float DivDistalPhasorLenght=GaugeWidth/2-GaugeWidth/7.5-StrokeWidth;
for (int Division=0;Division<NumberOfScaleMinorDivisions+1;Division++)
{
an=SpanAngle/2+Division
SpanAngle/NumberOfScaleMinorDivisions;
DivxPhasorCloser=DivCloserPhasorLenghtcos(radians(an));
DivxPhasorDistal=DivDistalPhasorLenght
cos(radians(an));
DivyPhasorCloser=DivCloserPhasorLenghtsin(radians(an));
DivyPhasorDistal=DivDistalPhasorLenght
sin(radians(an));
line(DivxPhasorCloser, DivyPhasorCloser, DivxPhasorDistal, DivyPhasorDistal);
}
DivCloserPhasorLenght=GaugeWidth/2-GaugeWidth/10-StrokeWidth;
DivDistalPhasorLenght=GaugeWidth/2-GaugeWidth/7.4-StrokeWidth;
for (int Division=0;Division<NumberOfScaleMajorDivisions+1;Division++)
{
an=SpanAngle/2+DivisionSpanAngle/NumberOfScaleMajorDivisions;
DivxPhasorCloser=DivCloserPhasorLenght
cos(radians(an));
DivxPhasorDistal=DivDistalPhasorLenghtcos(radians(an));
DivyPhasorCloser=DivCloserPhasorLenght
sin(radians(an));
DivyPhasorDistal=DivDistalPhasorLenght*sin(radians(an));
if (Division==NumberOfScaleMajorDivisions/2|Division==0|Division==NumberOfScaleMajorDivisions)
{
strokeWeight(15);
stroke(0);
line(DivxPhasorCloser, DivyPhasorCloser, DivxPhasorDistal, DivyPhasorDistal);
strokeWeight(8);
stroke(100, 255, 100);
line(DivxPhasorCloser, DivyPhasorCloser, DivxPhasorDistal, DivyPhasorDistal);
}
else
{
strokeWeight(3);
stroke(255);
line(DivxPhasorCloser, DivyPhasorCloser, DivxPhasorDistal, DivyPhasorDistal);
}
}
}
void Axis()
{
stroke(255, 0, 0);
strokeWeight(3);
line(-27, 0, 27, 0);
line(0, 87.5, 0, -87.5);
fill(100, 255, 100);
stroke(0);
triangle(0, -89, -2.3, -79.7, 2.3, -79.7);
triangle(0, 89, -2.3, 79.7, 2.3, 79.7);

stroke(0);
strokeWeight(4);
fill(100, 255, 100);
triangle(3.5, -65.6, -3.5, -65.6, 0, -84.4);
}

void Borders()
{
noFill();
stroke(0);
strokeWeight(400);
rect(0, 0, 258, 344);
strokeWeight(200);
ellipse(0, 0, 234.7, 312.5);
fill(0);
noStroke();
rect(4320/5, 0,320, 2240);
rect(-4320/5, 0, 320, 2240);
}

You will need to work within the confines of your selected graphic (GLCD) driver library. For example, using Adafruit's graphic library:
Overview | Adafruit GFX Graphics Library | Adafruit Learning System

Please edit your post to add code tags. See the "How to get the best out of the forum" post for instructions.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.