Hey guys, I am porting and adapting a LCD serial library to Teensy.
(library for LCD Display: Serial Enabled 20x4 LCD - Black on Green 5V; From: Sparkfun)
In my old LCD library, (I used it with arduino Mega Boards) there are a lot of programlines with Serial3.write().
I changed them to SerialLCD.write() and now I have this problem:
Output Serial Monitor: all is fine
Output LCD:
Output on LCD expected: the red branded are missing
Hardware:
LCD Display: Serial Enabled 20x4 LCD - Black on Green 5V; From: Sparkfun
Board: Teensy 3.1; Power supply: USB
Software:
Arduino IDE 1.0.5-r2
Teensyduino 1.18
compiled without compiler warnings
Workaround: I replace "write" with "print" and the library works fine
In the next update I request a FIX. Thank you
(If somebody is interrested in the small LCD library. I will post it, if it is ready.)
(library for LCD Display: Serial Enabled 20x4 LCD - Black on Green 5V; From: Sparkfun)
In my old LCD library, (I used it with arduino Mega Boards) there are a lot of programlines with Serial3.write().
I changed them to SerialLCD.write() and now I have this problem:
Code:
#include <Arduino.h>
// the functions below are extracted and adepted from a class only to point the PROBLEM
usb_serial_class & mySerial = Serial;
HardwareSerial & SerialLcd = Serial3;
void GoToPosLCD(const uint8_t row, const uint8_t col){ // row 0 bis 3, col 0 bis 19
SerialLcd.write(254); // Command
switch (row) {
case 0:
SerialLcd.write(128 + col); // 128 first position row 1
break;
case 1:
SerialLcd.write(192 + col); // 192 first position row 2
break;
case 2:
SerialLcd.write(148 + col); // 148 first position row 3
break;
default:
SerialLcd.write(212 + col); // 212 first position row 4
}
}
void clearLCD(){
SerialLcd.write(254); // Command
SerialLcd.write(0x01); // clear LCD.
}
void setup()
{
Serial.begin(115200);
//extracted and adepted from a class ---------------Start
SerialLcd.begin(9600);
delay(500); // wait for LCD splash screen to boot up
SerialLcd.write(0x7C); //NOTE THE DIFFERENT COMMAND FLAG = 124 dec
SerialLcd.write(0x10); //ctrl-P 38400 baud
SerialLcd.flush();
delay(10); // I am not so happy, but it's only in setup.
//if you switch from 9600 to 38400 baud:
//with flush, delay(4) = to short, delay(5) = ok; without flush, delay(5) = to short, delay(6) = ok.
//The problem may be in the LCD? I have read this thread: http://forum.pjrc.com/threads/25487-Serial1-flush%28%29-Problems
SerialLcd.begin(38400); // set up serial port for xxxx baud
//extracted and adepted from a class ---------------End
delay(5000); // Debug
}
void loop(){
char tempStringPrint[]= "PrintTest ";
char tempStringWrite[]= "WriteTest ";
Serial.println(F("Serial without Poiner:")); // output is ok
Serial.print(tempStringPrint); // output is ok
Serial.write(tempStringWrite); // output is ok
Serial.println(); // output is ok
Serial.println(F("Serial with Poiner:")); // output is ok
mySerial.print(tempStringPrint); // output is ok
mySerial.write(tempStringWrite); // output is ok
Serial.println(F("\n")); // output is ok
clearLCD(); // output is ok
GoToPosLCD(0, 0);
SerialLcd.print(tempStringPrint); // output is ok
SerialLcd.write(tempStringWrite); // [COLOR="#FF0000"]!!! not sended !!![/COLOR]
GoToPosLCD(1, 0);
Serial3.print(tempStringPrint); // output is ok
Serial3.write(tempStringWrite); // output is ok
GoToPosLCD(2, 0);
SerialLcd.write("a "); // [COLOR="#FF0000"]!!! not sended !!![/COLOR]
SerialLcd.write(0x62); // output is ok
SerialLcd.print(" c "); // output is ok
SerialLcd.print(0x64); // output is ok
GoToPosLCD(3, 0);
Serial3.write("a "); // output is ok
Serial3.write(0x62); // output is ok
Serial3.print(" c "); // output is ok
Serial3.print(0x64); // output is ok
delay(1000);
}
Output Serial Monitor: all is fine
Code:
Serial without Poiner:
PrintTest WriteTest
Serial with Poiner:
PrintTest WriteTest
Serial without Poiner:
PrintTest WriteTest
Serial with Poiner:
PrintTest WriteTest
Output LCD:
Code:
PrintTest
PrintTest WriteTest
b c 100
a b c 100
Output on LCD expected: the red branded are missing
Code:
PrintTest [COLOR="#FF0000"]WriteTest[/COLOR]
PrintTest WriteTest
[COLOR="#FF0000"]a[/COLOR] b c 100
a b c 100
Hardware:
LCD Display: Serial Enabled 20x4 LCD - Black on Green 5V; From: Sparkfun
Board: Teensy 3.1; Power supply: USB
Software:
Arduino IDE 1.0.5-r2
Teensyduino 1.18
compiled without compiler warnings
Workaround: I replace "write" with "print" and the library works fine
In the next update I request a FIX. Thank you
(If somebody is interrested in the small LCD library. I will post it, if it is ready.)