Clone/Duplicate IDE Serial Monitor Information Display to a TFT LCD Display

I have searched and searched and even tried to create my own code with no luck. What I am currently trying to do is duplicate what I am seeing on my Arduino IDE serial monitor directly onto my 3.5" TFT display. The display is ILI9486 and the board is Mega 2560. The information coming across serial is raw data from GPS NEO-6M which is 9600 Baud NMEA data. Any and all help is very much appreciated. If possible I'd like to have the NMEA raw GPS Data scroll the same way it does in Serial Monitor.

That's probably not going to be easy.

You'll need to code an object that is a rectangle on the screen that you can pipe text to and it formats and scrolls it for you to begin with.

Then you will need to pipe your NEMA data to that object.

-jim lee

A GPS puts out a lot of characters every second.

I wonder if a Mega could be fast enough to write to keep up with screen writes.

For every new line of characters that comes in from the GPS, would you not need to re-write the entire screen ?

in my code using an OLED, rather than have oled functions scattered throughout the code, i wrote a single function that is passed 4 strings to display on the display if the string is not NULL knowing the y-coordinate for each line

you could write a similar function that is passed a single string and which buffers the previous strings, copying each buffered string to the next highest vertical string location or just managing which string if printed at which y-location

as suggested, you may want to add a delay to make each new string readable

snippets showing use of dispOled() to display 4 generic strings on an OLED display.

#ifdef SH1106
SH1106Wire  display(0x3c, 21, 22);
#else
SSD1306Wire  display(0x3c, 21, 22);
#endif

performed in setup()

   // init OLED display
    display.init();
 // display.flipScreenVertically();
    display.setFont(ArialMT_Plain_16);
    display.clear();
    display.setTextAlignment(TEXT_ALIGN_LEFT);
    display.setColor(WHITE);

generic function

// display up to 4 lines of text
void dispOled(
    const char  *s0,
    const char  *s1,
    const char  *s2,
    const char  *s3,
    bool         clr )
{
    if (clr)
        display.clear();

    display.setTextAlignment(TEXT_ALIGN_LEFT);

    if (s0)  {
        display.drawString(0, DISP_Y0,  s0);
    }
    if (s1)  {
        display.drawString(0, DISP_Y1, s1);
    }
    if (s2)  {
        display.drawString(0, DISP_Y2, s2);
    }
    if (s3)  {
        display.drawString(0, DISP_Y3, s3);
    }
    display.display();
}

in the following version, strings are also displayed thru a serial interface

// display up to 4 lines of text
void dispOled(
    const char  *s0,
    const char  *s1,
    const char  *s2,
    const char  *s3,
    bool         clr )
{
    char  s [40];

    if (clr)
        display.clear();

    display.setTextAlignment(TEXT_ALIGN_LEFT);

    if (s0)  {
        display.drawString(0, DISP_Y0,  s0);
        if (debug && NUL != *s0)  {
            sprintf (s, "... %s", s0);
            Serial.println (s);
        }
    }
    if (s1)  {
        display.drawString(0, DISP_Y1, s1);
        if (debug && NUL != *s1)  {
            sprintf (s, "    %s", s1);
            Serial.println (s);
        }
    }
    if (s2)  {
        display.drawString(0, DISP_Y2, s2);
        if (debug && NUL != *s2)  {
            sprintf (s, "    %s", s2);
            Serial.println (s);
        }
    }
    if (s3)  {
        display.drawString(0, DISP_Y3, s3);
        if (debug && NUL != *s3)  {
            sprintf (s, "    %s", s3);
            Serial.println (s);
        }
    }
    display.display();
}

example usage reporting that code is attempting to connect to WiFi with specific ssid and password strings

           dispOled("WiFi connecting", ssid, pass, 0, CLR);

In the code I had been working on for my display I had gotten as far as to what you are listing as “performed in setup”. In doing so I was able to set the display background, font style, font size, font color, cursor position, text alignment. I was able to use the the function I believe to be TFT.write (“test”); in doing so this tested my text data input to display. I then went on to try and use the function readDigital(0). As I had believed this would read data on my Digital Pin 0 which is my RX0 pin that my GPS is set to. The code I wrote was like sensorinput = readDigital(0) then I tried to TFT.print (sensorinput). I’ll try and post the code I had been working on this afternoon. I kept getting a flashing 1 from what I had done. I have no idea what I’m doing, but I want to learn. Thank you all for your help and quick responses.

I did something similar, it wasn't easy. Its handy once you have it working. But it does have the problem that its easily overran. In fact, it might be better to spool it to the SD drive, using that as a buffer. Then, as you have time, send it out to the window to view.

-jim lee