Hello again all! I have an old Sainsmart 320x240 TFT screen and I’m using the UTFT libraries. I wish to use the screen and Sainsmart MEGA as a dedicated LCD and touchscreen device that simply outputs text and shapes as directed by another Arduino.
Here’s the general, simplified idea:
#include <UTFT.h>
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
extern uint8_t SevenSegNumFont[];
UTFT myGLCD(ITDB32S,38,39,40,41);
void setup()
{
Serial1.begin(115200);
// Setup the LCD
myGLCD.InitLCD();
myGLCD.clrScr();
}
void loop(){
int LCDdisplayArray[]={0 /*colorRed[0]*/, 255 /*colorGreen[1]*/, 8 /*colorBlue[2]*/, 0 /*shape/text[3]*/, 10 /*x1[4]*/, 10 /*y1[5]*/, 100 /*x2[6]*/, 100 /*y2[7]*/, 50 /*radius[8]*/, 0 /*clearScreen[9]*/, 0 /*text font[10]*/, 0 /*text justification[11]*//*, 0 text[12]*/, 0 /*Rotation[13]*/, 1 /*Lanadscape/Portrait[14]*/};//Recieve Data from Master
//Shape: 0=line, 1=Rect, 2=fillRect, 3= circ, 4=fillCirc,
//5=roundRect 6=text 7=pixel, 8=round Rect
int colorR=LCDdisplayArray[0];
int colorG=LCDdisplayArray[1];
int colorB=LCDdisplayArray[2];
int shape = LCDdisplayArray[3];
int x1= LCDdisplayArray[4];
int y1= LCDdisplayArray[5];
int x2= LCDdisplayArray[6];
int y2= LCDdisplayArray[7];
int radius= LCDdisplayArray[8];
int clearScreen= LCDdisplayArray[9];
int textFont= LCDdisplayArray[10];
int textJustification= LCDdisplayArray[11];
int text= LCDdisplayArray[12];
int rotation= LCDdisplayArray[13];
int landscapeOrPortrait= LCDdisplayArray[14];
switch(landscapeOrPortrait){
case 1:
myGLCD.InitLCD(LANDSCAPE);
break;
case 2:
myGLCD.InitLCD(PORTRAIT);
break;
}
myGLCD.setColor(colorR,colorG,colorB);
switch(shape){
case 0:
myGLCD.drawLine(x1,y1,x2,y2);
break;
case 1:
myGLCD.drawRect(x1,y1,x2,y2);
break;
case 2:
myGLCD.fillRect(x1,y1,x2,y2);
break;
case 3:
myGLCD.drawCircle(x1,y1,radius);
break;
case 4:
myGLCD.fillCircle(x1,y1,radius);
break;
case 5:
myGLCD.fillRoundRect(x1,y1,x2,y2);
break;
case 6:
switch(textFont){
case 0:
myGLCD.setFont(BigFont);
break;
case 1:
myGLCD.setFont(SevenSegNumFont);
break;
case 2:
myGLCD.setFont(SmallFont);
break;
}
case 7:
myGLCD.drawPixel(x1,y1);
break;
case 8:
myGLCD.drawRoundRect(x1,y1,x2,y2);
break;
}
if(clearScreen==1){
myGLCD.clrScr();
}
}
Data comes in off the Serial line and is placed into an array (we’ll assume that works fine). The data is information for the LCD to print. Shapes, colors, and coordinates have proven easy to handle but I need text too. The UTFT command for printing text is
myGLCD.print(“TEXT”, justification, Ycoordinate, rotationAngle)
Any ideas how to make my array setup able to print text from an array according to the UTFT syntax? This is still rough code, hope it gives you an idea of what I’m going for