Don't attach the code, post it directly in the forum so we can read it.
Please read the "how to post to this forum" thread.
Here is his code:
#include <SMARTGPU2.h>
SMARTGPU2 lcd; //create our object called LCD
char Dacq[35], Spointer[4]; //data vector we must save on microSD
unsigned long pointer=0;
const int numReadings = 10;
int i, Counter=0;
int Tens1, Tens2, Tens3, Tens4; // vectors of numReadings places
float Tens1F, Tens2F, Tens3F, Tens4F;
float Tratio=20.0;
char SV1[7], SV2[7], SV3[7], SV4[7];
FILERESULT res; //this variable that will store all SMARTGPU2 commands responses
unsigned int writtenBytes=0;
/*********************** function that reports errors and loops forever ********************************/
void die(FILERESULT response){ //if the response is different than OK, print and loop forever
if(response!=F_OK){
lcd.string(100, (MAX_Y_LANDSCAPE+1)-50, MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,"Error...",0);
while(1);
}
}
/*********************************************************/
void setup() {
// put your setup code here, to run once:
lcd.init(); //configure the serial and pinout of arduino board for SMARTGPU2 support
lcd.start(); //initialize the SMARTGPU2 processor
lcd.baudChange(BAUD5); //set high baud for advanced applications
lcd.orientation(LANDSCAPE_LEFT); //set orientation as LANDSCAPE
lcd.setTextColour(YELLOW); //Sets the font style
lcd.setTextSize(FONT0);
lcd.setTextBackFill(TRANS);
}
void loop() {
// put your main code here, to run repeatedly:
do {
for(i=0; i<numReadings; i++) { //take 10 readings in additions
Tens1+=analogRead(A0);
Tens2+=analogRead(A1);
Tens3+=analogRead(A2);
Tens4+=analogRead(A3);
}
Tens1F=(Tens1/10.0)*(5.0/1023.0)*Tratio; //average smoothing and Temperature convertions
Tens2F=(Tens2/10.0)*(5.0/1023.0)*Tratio;
Tens3F=(Tens3/10.0)*(5.0/1023.0)*Tratio;
Tens4F=(Tens4/10.0)*(5.0/1023.0)*Tratio;
dtostrf(Tens1F,6,2,SV1); // float to style-C string convertion
dtostrf(Tens2F,6,2,SV2);
dtostrf(Tens3F,6,2,SV3);
dtostrf(Tens4F,6,2,SV4);
Dacq[0]='\0';
strcat(Dacq, SV1); strcat(Dacq, "\n"); strcat(Dacq, SV2); strcat(Dacq, "\n"); strcat(Dacq, SV3); strcat(Dacq, "\n"); strcat(Dacq, SV4);
strcat(Dacq, "\n"); strcat(Dacq, "\0"); //fomating my output data line.
/******************* Saves collected data into microSD Flash memory *******************************/
lcd.string(205, (MAX_Y_LANDSCAPE+1)-70, MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,"Saving...",0); //prints on SMARTGPU2 the new pointer position
res=lcd.SDFopenFile("Data01.txt", WRITEONLY, WORKSPACE0); //Try to open a file Data00.txt" in the workspace block 0
if(res!=F_OK){ //If the file doesn't Open is because it doesn't exist
res=lcd.SDFnewFile("Data01.txt"); //Creates the file
die(res); //If any error loop forever
res=lcd.SDFopenFile("Data01.txt", WRITEONLY, WORKSPACE0); //Try to open the created file
die(res); //If any error loop forever
}
sprintf (Spointer, "%04i", pointer);
lcd.drawRectangle(95,(MAX_Y_LANDSCAPE+1)-52, 150, (MAX_Y_LANDSCAPE+1)-37,BLUE,FILL);
lcd.string(100, (MAX_Y_LANDSCAPE+1)-50, MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,Spointer,0); //prints on SMARTGPU2 the current pointer position
delay(10);
res=lcd.SDFsetFilePointer(pointer, WORKSPACE0); // sets a new position pointer on the file "Data00.txt" (It`s supossed)
delay(2);
die(res);
res=lcd.SDFwriteFile(Dacq, sizeof(Dacq), &writtenBytes, WORKSPACE0);
delay(10);
die(res);
res=lcd.SDFsaveFile(WORKSPACE0);
delay(2);
die(res);
pointer+=sizeof(Dacq); //increments file pointer
lcd.SDFcloseFile(WORKSPACE0); //Close the file --------------------
lcd.drawRectangle(200,(MAX_Y_LANDSCAPE+1)-74, 250, (MAX_Y_LANDSCAPE+1)-54,BLUE,FILL); // Prints total accumulated Energy
delay(2000); //Every 2 seconds repeat the loop.
Counter++;
} while(Counter<5);
lcd.string(201, (MAX_Y_LANDSCAPE+1)-70, MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE," The end",0); //prints on SMARTGPU2 the new pointer position
while(1); //enless loop.
}