Gather variable for LCD use

Hi All,

I've got the below and I'm trying to make the results gathered from a GPS module usable as a variable for an LCD.

  double courseToSandgate =
    TinyGPSPlus::courseTo(
      gps.location.lat(),
      gps.location.lng(),
      SANDGATE_LAT,
      SANDGATE_LON);
  const char *cardinalToSandgate = TinyGPSPlus::cardinal(courseToSandgate);

  printStr(gps.course.isValid() ? TinyGPSPlus::cardinal(gps.course.deg()) : "*** ", 6);   // This shows heading in N/S/E/W word format.

static void printStr(const char *str, int len)
{
  int slen = strlen(str);
  for (int i = 0; i < len; ++i)
    Serial.print(i < slen ? str[i] : ' ');
  smartDelay(0);
}

The Serial.print in "static void printStr" displays correct information in Serial Monitor, how can I make the results that Serial.print gets and declare it and use it for displaying on an LCD?

I'd like to then show it below, cannot seem to figure it out. I'm guessing its something simple.....

display.print("resultshere");

Or can it be simplified and declared at the start here without having to use the "static void printStr" as I am not using it for anything else.

printStr(gps.course.isValid() ? TinyGPSPlus::cardinal(gps.course.deg()) : "*** ", 6); 

thanks heaps

Why not :try instead of guess?

oh ive been trying, now i've resulted to guessing :frowning: which obviously isnt going to help...

Just send the output to your lcd instance instead of Serial

static void printStrToLCD(const char *str, int len)
{
  int slen = strlen(str);
  for (int i = 0; i < len; ++i)
    lcd.print(i < slen ? str[i] : ' ');
  smartDelay(0);
}

Make sure you called setCursor() before calling this

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.