This is where I am as of now. I have to set the LCD positions still and add a few other features. I have a SMARTGPU on the way.
My display code, I'm working off of examples to try to learn it.
#include <SMARTGPU.h> //include the SMARTGPU library!
SMARTGPU lcd; //create our object called LCD
//Each time we use the touchscreen we must define a int array that stores the X and Y readed or touched coordinates.
int touch[2];
//Each time we use the touchicon we must define a char array that stores the name of the touched icon.
char icon[3];
char pixelArray[3]; //Array to store the RGB888 pixel obtained with memoryRead()
#define ligBlue 0x96DD
//brightness function
void settings(){
static int bright=127; //Maximum bright is set by default 133 min 14
static int buttonCen=271; //button center, static variables to avoid losing the parameters even if we go to main menu
lcd.imageSD(0,0,"Bright"); //Load image from SD card, image is 320x240(full screen) so we load it from top left corner X:0,Y:0
lcd.imageSD(0,0,"WinHead"); //draw header
while(1){ //Loop forever in the settings!
lcd.drawRectangle(40,64,(bright*2)+12,66,0x4C7C,FILL); //draw brightness bar 266 max 40 min
lcd.drawRectangle((bright*2)+12,64,266,66,WHITE,FILL); //fill the rest of the bar with white
lcd.imageSD((bright*2)+12,57,"button"); //Load the button icon 266 max pos X, 40 min X pos
delay(100); //delay to avoid fast change and flickering
while(lcd.touchScreen(touch)==0 & lcd.touchIcon(icon)==0); //wait for a touch to do something
if(lcd.touchIcon(icon)==1){ //if the received touch was on any icon we exit go to main menu
break;
}
//touch on Screen, change brightness and draw button icon
if(touch[YCOORD]>55 & touch[YCOORD]<85 ){ //if the previous touch was on active area
lcd.imageSD((bright*2)+12,57,"clrBar"); //clear the button icon
//check where to move left or right
if(touch[XCOORD]>buttonCen){ //if we need to move the bar to the right
bright+=10; //increase the brightness
buttonCen+=22; //increase the center of the button
if(bright>127){ //if the button reach the right corner
bright=127; //set maximum bright
buttonCen=271; //set maximum button center
}
}else{ //move the bar to the left
bright-=10; //decrease the brightness
buttonCen-=22; //decrease the center of the button
if(bright<14){ //if the button reach the left corner
bright=14; //set minimum bright
buttonCen=40; //set minimum button center
}
}
lcd.bright(bright); //set new brightness value to SMART GPU
}
}
}
void setup() {
Serial.begin (9600);
lcd.init(); //configure the serial and pinout of arduino board for SMARTGPU support
lcd.start(); //initialize the SMARTGPU processor
0x4F,01;
lcd.setScreenBackground(ligBlue);
lcd.imageSD(0,0,"splash"); //startup image
delay (5000);
}
void loop() {
unsigned char ic;
while(1){
//load Desktop
lcd.imageSD(0,0,"Mainscreen");
ic=0;
while(ic==0){ //loop until we get a click on one application
// read rpm and place on screen
while(lcd.touchScreen(touch)==0); //Wait for touch
if(touch[XCOORD]<70 & touch[YCOORD]> 8 & touch[YCOORD]< 230){ //If touch on menu
ic=((touch[YCOORD]-8)/27)+1; //divide (222pixels/8)=27 and add 1, to get the icon number
} //else go back
}
//begin application based on icon number
switch(ic){ //now that we know a touch was made on a specified icon
case 1:
suspensionCom();
break; //end of case 2 suspension monitor
case 2:
boomCom();
break; //end of case 3 boom height control
case 3:
settings(); //brightness control
break;
default: //default for any other case
break; //do nothing
}
}
}
// suspension data function
void suspensionCom() {// function name
lcd.imageSD(0,0,"suspension"); //needs to be full screen bmp file
while(1){ //Loop forever in suspension page
while(lcd.touchScreen(touch)==0 & lcd.touchIcon(icon)==0); //wait for a touch to do something
if(lcd.touchIcon(icon)==1){ //if the received touch was on any icon we exit go to main menu
break;
}
Serial.write (1);
int lfpwm = Serial.read();
char lfout[2] = {lfpwm};
Serial.write (2);
int rfpwm = Serial.read();
char rfout[2] = {rfpwm};
Serial.write (3);
int lrpwm = Serial.read();
char lrout[2] = {lrpwm};
Serial.write (4);
int rrpwm = Serial.read();
char rrout[2] = {rrpwm};
Serial.write (5);
float manual = Serial.read();
char manin[2] = {manual};
Serial.write(6);
int lfin = Serial.read();
char leftfin[2] = {lfin};
Serial.write(7);
int rfin = Serial.read();
char rightfin[2] = {rfin};
Serial.write(8);
int lrin = Serial.read();
char leftrin[2] = {lrin};
Serial.write(9);
int rrin = Serial.read();
char rightrin[2] = {rrin};
// enter display data and screen positions
lcd.string(224,34,255,65,BLACK,FONT7,TRANS,lfout);
lcd.string(80,36,100,55,BLACK,FONT0,TRANS,rfout);
lcd.string(224,34,255,65,BLACK,FONT7,TRANS,lrout);
lcd.string(80,36,100,55,BLACK,FONT0,TRANS,rrout);
lcd.string(224,34,255,65,BLACK,FONT7,TRANS,manin);
lcd.string(80,36,100,55,BLACK,FONT0,TRANS,leftfin);
lcd.string(80,36,100,55,BLACK,FONT0,TRANS,rightfin);
lcd.string(80,36,100,55,BLACK,FONT0,TRANS,leftrin);
lcd.string(80,36,100,55,BLACK,FONT0,TRANS,rightrin);
}
}
// boom data function
void boomCom(){
lcd.imageSD(0,0,"boom"); //needs full screen bmp file
while(1){ //Loop forever in boom page
while(lcd.touchScreen(touch)==0 & lcd.touchIcon(icon)==0); //wait for a touch to do something
if(lcd.touchIcon(icon)==1){ //if the received touch was on any icon we exit go to main menu
break;
}
Serial.write (10);
int leftpwm = Serial.read();
char leftout[2] = {leftpwm};
Serial.write (11);
int cenpwm = Serial.read();
char cenout[2] = {cenpwm};
Serial.write (12);
int rightpwm = Serial.read();
char rightout[2] = {rightpwm};
Serial.write (13);
int leftsensor = Serial.read();
char leftin[2] = {leftsensor};
Serial.write (14);
int centersensor = Serial.read();
char centin[2] = {centersensor};
Serial.write (15);
int rightsensor = Serial.read();
char rightin[2] = {rightsensor};
Serial.write (16);
int heightpot = Serial.read();
char manpot[2] = {heightpot};
// enter display data and screen positions
lcd.string(224,34,255,65,BLACK,FONT7,TRANS,leftout);
lcd.string(80,36,100,55,BLACK,FONT0,TRANS,cenout);
lcd.string(224,34,255,65,BLACK,FONT7,TRANS,rightout);
lcd.string(80,36,100,55,BLACK,FONT0,TRANS,leftin);
lcd.string(224,34,255,65,BLACK,FONT7,TRANS,centin);
lcd.string(80,36,100,55,BLACK,FONT0,TRANS,rightin);
lcd.string(80,36,100,55,BLACK,FONT0,TRANS,manpot);
}
}
I believe I will need to get an Arduino Mega to get multiple serial ports for the display module.