Hello Forum. Having a bit of an issue trying to get text written on rows of my LCD, the “\e[i,0H” doesnt locate print as expected, it simply starts a new line of text after the contents of DATA with ;0H cant seem to stop that and get printing at the right location, i.e. each new row defined by the value of i. Any help appreciated please.
void loop()
{
if (radio.receiveDone()) //check if something was received (could be an interrupt from the radio)
{
for(int i=1; i <= 6; i++)
{
Serial.print("\e[i;0H");
delay(50);
Serial.print(i);
Serial.print((char*)radio.DATA);
delay(1000);
}
}
radio.receiveDone(); //put radio in RX mode
Serial.flush(); //make sure all serial data is clocked out before sleeping the MCU
}
Serial.Print has no concept that the "i" in your passed parameter is anything but the letter "i". It has no way of knowing you wanted variable substitution there.
UKPete:
Hello Ray. If I use Serial.print("\e[i;0H"); where the is an integer it works fine all the time.
Thanks. Pete
Serial.print has absolutely nothing to do with any LCD. What LCD are you using? What driver are you using for that LCD? ESC codes have to be parse, and executed by the LCD driver, and I have a hard time believing ANY LCD for an Arduino would implement such an antiquated interface.
Serial.print works fine when I use 0,1, etc in place of the letter . I am using… #include <Wire.h> #include <RFM69.h> #include <SPI.h>
an adaptor on the back of my 128 x 64 LCD from ByVac http://www.byvac.com/index.php/BV4611
To be honest, the three "Serial.print"s are a lot more intuitive, about the same amount of typing, and won't bloat your code, but there's plenty on sprintf online, if you decide to do it that way.