Thank you guys for the previous relies. It's was a long few days trying to learn how to code and trying to make this stuff work together, with some flaws.
I ordered the Sainsmart Mega2560 and a serial OLED for the transmission display project. I was finally able to figure out how to add code for the Gear and Mode label positions while also learning to mix font sizes. I had a coworker try to help me with this, but he wrote up some code for to buffer the data Serial2 (19.2 baud Transmission controller) to send to Serial1 (19.2 baud OLED display). This seems to work, but not quite right. Can someone offer help on correction to the Arduino code to make this work correctly?
The first post shows captured data from the output of serial data from transmission controller. The data shows some apparent carriage return (0d) and line feed (0a) sent from the controller with the current values. I only need to display the Mode "m", "M", or "a", "A" and the Gear 1, 2, 3, 4.
Here is a video of the display working with the code below: Serial to OLED issue - YouTube
"&& buffer[1] == 20" he added in belief it would do something with the spaces, but this caused no serial communication. Once commented out serial data began to output.
#define HOME (char) 1 // Moveto character position 0.
#define FLARGER (char) 2 // Increase font size.
#define FRESET (char) 3 // Reset font to default/small.
#define CLS (char) 12 // Clear screen, moveto 0.
#define MOVETO (char) 16 // Position instruction
#define PPE (char) (19 + 64) //Arrows
#define GEARL (char) (0 + 64) // Position of Gear data field
#define MODEL (char) (7 + 64) //Position of Mode data field
#define LABEL (char) (3 + 64) //"Gear" label position
#define LABEL2 (char) (9 + 64) //"Mode" label position
#define RTALIGN (char) 18 //Ctrl-R right-align instruction
#define FSEGMENT (char) 19 //*Change Gear font to 7-SEGMENT
#define FBIG (char) 20 //*Change font to TEXT style for splash screen
//------------------------------------------------------------
//Setup
//------------------------------------------------------------
void setup() {
// initialize both serial ports:
Serial2.begin(19200);
Serial1.begin(19200);
Serial1.write (CLS);
delay(50);
Serial1.write (FRESET);
Serial1.write (MOVETO);
Serial1.write (LABEL);
Serial1.write ("Gear");
Serial1.write (MOVETO);
Serial1.write (PPE);
Serial1.write ("<--- --->");
Serial1.write (MOVETO);
Serial1.write (LABEL2);
Serial1.write ("Mode");
Serial1.write (FLARGER);
Serial1.write (FLARGER);
Serial1.write (FLARGER);
delay (800);
}
//-------------------------------------------------------------
//Start Loop
//-------------------------------------------------------------
void loop() {
int i = 0;
char buffer[5];
// read from port 0, send to port 1:
if(Serial2.available()) {
delay(30); // allows buffer to fill
while(Serial2.available() && i < 4) {
buffer[i++] = Serial2.read();
}
buffer[i++]='\0';
}
// did we receive data? If so, try to display it.
if(i > 0 /*&& buffer[1] == 20*/){
Serial1.write(MOVETO);
Serial1.write(GEARL);
Serial1.write(buffer[3]);
Serial1.write(MOVETO);
Serial1.write(MODE);
Serial1.write(buffer[1]);
}
}
Thanks for any help.