I used this example as a starting point to convert some serial data to a usable string:
http://arduino.cc/forum/index.php/topic,45629.0.html
and came up with this:
#include <UTFT.h>
#include <UTouch.h>
// Uncomment the next two lines for the Arduino Mega
UTFT myGLCD(ITDB32S, 38,39,40,41); // Remember to change the model parameter to suit your display module!
UTouch myTouch(6,5,4,3,2);
extern uint8_t SmallFont[];
char inData[50]; // Allocate some space for the string
char inChar; // Where to store the character read
byte index = 0; // Index into array; where to store the character
boolean incomming = false;
void setup()
{
// Setup the LCD
myGLCD.InitLCD();
myGLCD.setFont(SmallFont);
myGLCD.clrScr();
myGLCD.setColor(255, 0, 0);
myGLCD.fillRect(0, 0, 319, 13);
myGLCD.setColor(64, 64, 64);
myGLCD.fillRect(0, 226, 319, 240);
myGLCD.setColor(255, 255, 255);
myGLCD.setBackColor(255, 0, 0);
myGLCD.print("* Loren's Operating System *", CENTER, 1);
myGLCD.setBackColor(64, 64, 64);
myGLCD.print("Arduino Status: Setup", LEFT, 14);
myGLCD.print("PI Status: ", LEFT, 28);
Serial.begin(9600);
Serial1.begin(9600);
Serial.println("setup Complete");
myGLCD.print("Arduino Status: Ready", LEFT, 14);
}
void loop(){
if (Serial1.available()>0){
//Serial.println("Stuff Available");
int inByte = Serial1.read();
if(inByte == 94){
Serial.println("Starting byte found");
incomming = true;
}
if(inByte == 38){
Serial.println("Ending byte found");
String temp = inData;
Serial.write(inData);
myGLCD.print(temp, LEFT, 42);
incomming = false;
index = 0;
}
if(incomming = true){
if(index < 19) // One less than the size of the array
{
inChar = Serial1.read(); // Read a character
inData[index] = inChar; // Store it
index++; // Increment where to write next
inData[index] = '\0'; // Null terminate the string
}
}
}
if (Serial.available()){
int inByte = Serial.read();
Serial1.write(inByte);
}
}
When I send the string
^Power&
through it I get this:
Starting byte found
Ending byte found
ÿÿÿÿÿÿ
I've tried every thing I can think of and find to convert "inData" to a string, including "String temp(inData)" and "String temp = inData" even referencing inData directly. What can I do to get a response that i can display on my tft from the serial command?
Thanks so much,
Loren