SparkFun Forums 

Where electronics enthusiasts find answers.

By Old_Tron
#202003
Hello,

I've been using 2 & 3 line LCD's for decades but I've always had some function to set the cursor position.
I'm I missing something?

This is the best I can do, and it is sloppy at best:
Code: Select all
myTempStr = "   Temp ";
  myTempStr1 = newTemp;
  myTempStr.concat(myTempStr1);
  myTempStr.concat(" F     ");
  myTempStr.toCharArray(buffer, 20);
  spiSendString(buffer);
  //  delay(25);

  myTempStr = "    Baro ";
  myTempStr1 = newBp;
  myTempStr.concat(myTempStr1);
  myTempStr.concat(" inHg\n");
  myTempStr.toCharArray(buffer, 20);
  spiSendString(buffer);
  //  delay(25);
If someone could point me in the right direction, I'd sure appreciate it.
By Old_Tron
#202039
Hello,
lyndon; you are correct sir. Sometimes I read too fast and the hippocampus throws too much out, not enough Zen!

I’m using SPI on the OpenLCD (LCD-14074) mostly because I haven’t used it much, and the BMP280 is using I2C. I will likely move the OpenLCD to I2C, after I see what I can do with this.

It still drops a char on occasion? Maybe timing. But this does work!
Code: Select all
//  send data to OpenLCD
  char buffer[80];

  digitalWrite(csPin, LOW); //  select OpenLCD, NOT/CS, low(0)  SPI.beginTransaction()
  SPI.transfer(254);  //  control/command character
  SPI.transfer(128 + 0 + 2); // cursor(128) + row(0, 64, 20, 84) + position(0 - 19)
  digitalWrite(csPin, HIGH); // deselect OpenLCD, NOT/CS, high(1) SPI.endTransaction()
  delay(30);

  myTempStr = "Temp ";
  myTempStr1 = newTemp;
  myTempStr.concat(myTempStr1);
  myTempStr.concat(" F");
  myTempStr.toCharArray(buffer, 20);
  spiSendString(buffer);
  delay(30);

  digitalWrite(csPin, LOW); //  select OpenLCD, NOT/CS, low(0)  SPI.beginTransaction()
  SPI.transfer(254);  //  control/command character
  SPI.transfer(128 + 20 + 2); // cursor(128) + row(0, 64, 20, 84) + position(0 - 19)
  digitalWrite(csPin, HIGH); // deselect OpenLCD, NOT/CS, high(1) SPI.endTransaction()
  delay(30);

  myTempStr = "Baro ";
  myTempStr1 = newBaro;
  myTempStr.concat(myTempStr1);
  myTempStr.concat(" inHg");
  myTempStr.toCharArray(buffer, 20);
  spiSendString(buffer);
  delay(30);
Happy coding.