NMEA data to screen.

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
somewhereinusa
 
Posts: 61
Joined: Thu Nov 21, 2013 11:42 am

NMEA data to screen.

Post by somewhereinusa »

I am working on a speedometer/odometer/trip meter using an Arduino DUO, Adafruit Ultimate GPS Logger Shield, RA8875 and a 4.3" 40-pin TFT Display. I have been able to get a useable layout onto the screen. I get a good data stream from the GPS. How do I get the NEMA data parsed and onto the screen, All of the info I have been able to find has been with lcd screens and/or out of date code. I haven't been able to get any kind of start. Can someone point me in the right direction?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: NMEA data to screen.

Post by adafruit_support_rick »

Have you looked at the sample parsing sketch included with our GPS library? The GPS library has a parse function, and it breaks out the individual data points so you can display them any way you want.

User avatar
somewhereinusa
 
Posts: 61
Joined: Thu Nov 21, 2013 11:42 am

Re: NMEA data to screen.

Post by somewhereinusa »

I have looked at that and am able to see the results on the serial monitor. How do I get that to show on the tft screen?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: NMEA data to screen.

Post by adafruit_support_rick »

I had to check on this. Currently, the library does not support print and println. You have to use the textWrite function. The problem there is that textWrite only works with character strings, so you can't give it a variable as you can with print.

This means that you have to use the C-Language sprintf function to format a character string, and then output that with textWrite.

sprintf is a big subject. Try googling it for a tutorial. Let me know if you need help with it.

WARNING: the sprintf implementation in the arduino does NOT support floating-point numbers. You will have to treat the integer and fractional parts of FP numbers separately.

Here is the relevant part of the parsing sketch - I've replaced the print statements with snprintf formatted strings, suitable for use with textWrite

(BTW, you'll notice that I'm using the snprintf form of sprintf - it's safer because it's designed to prevent buffer overruns)

Code: Select all

  // approximately every 2 seconds or so, print out the current stats
  if (millis() - timer > 2000) { 
    timer = millis(); // reset the timer
    char buf[32] = "";
    snprintf(buf, 31, "\nTime: %02d:%02d:%02d.%03d\n", GPS.hour, GPS.minute, GPS.seconds, GPS.milliseconds);
    Serial.print(buf);
    snprintf(buf, 31, "Date: %02d/%02d/20%02d\n", GPS.day, GPS.month, GPS.year);
    Serial.print(buf);
    snprintf(buf, 31, "Fix: %d quality %d\n", GPS.fix, GPS.fixquality);
    Serial.print(buf);
//    Serial.print("\nTime: ");
//    Serial.print(GPS.hour, DEC); Serial.print(':');
//    Serial.print(GPS.minute, DEC); Serial.print(':');
//    Serial.print(GPS.seconds, DEC); Serial.print('.');
//    Serial.println(GPS.milliseconds);
//    Serial.print("Date: ");
//    Serial.print(GPS.day, DEC); Serial.print('/');
//    Serial.print(GPS.month, DEC); Serial.print("/20");
//    Serial.println(GPS.year, DEC);
//    Serial.print("Fix: "); Serial.print((int)GPS.fix);
//    Serial.print(" quality: "); Serial.println((int)GPS.fixquality); 
    if (GPS.fix) {
      snprintf(buf, 31, "Location: %4d.%04ld%c, ", (int)GPS.latitude, ((uint32_t)(GPS.latitude * 10000.0)%10000), (int)GPS.lat);
      Serial.print(buf);
      snprintf(buf, 31, "%5d.%04ld%c\n", (int)GPS.longitude, ((uint32_t)(GPS.longitude * 10000.0)%10000), (int)GPS.lon);
      Serial.print(buf);
//      Serial.print("Location: ");
//      Serial.print(GPS.latitude, 4); Serial.print(GPS.lat);
//      Serial.print(", "); 
//      Serial.print(GPS.longitude, 4); Serial.println(GPS.lon);
      
      snprintf(buf, 31, "Speed (knots): %d.%02ld\n", (int)GPS.speed, ((uint32_t)(GPS.speed * 100.0)%100));
      Serial.print(buf);
      snprintf(buf, 31, "Angle: %d.%02ld\n", (int)GPS.angle, ((uint32_t)(GPS.angle * 100.0)%100));
      Serial.print(buf);
      snprintf(buf, 31, "Altitude: %d.%02ld\n", (int)GPS.altitude, ((uint32_t)(GPS.altitude * 100.0)%100));
      Serial.print(buf);
      snprintf(buf, 31, "Satellites: %d\n", (int)GPS.satellites);
      Serial.print(buf);
//      Serial.print("Speed (knots): "); Serial.println(GPS.speed);
//      Serial.print("Angle: "); Serial.println(GPS.angle);
//      Serial.print("Altitude: "); Serial.println(GPS.altitude);
//      Serial.print("Satellites: "); Serial.println((int)GPS.satellites);
    }
  }

User avatar
wweetts
 
Posts: 3
Joined: Thu Dec 19, 2013 6:19 am

Re: NMEA data to screen.

Post by wweetts »

Hi

I will also use the Arduino due with the RA8875 Driver but, i have some problems with the SPI and the SPI.h liberary!

How do you connect the RA8875 to the Arduino Due and which SPI liberay do you use??

Thanks

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: NMEA data to screen.

Post by adafruit_support_rick »

The SPI library is part of the Arduino IDE.

The RA8875 library has not been ported to work with the Arduino Due. It won't compile. The OP was not using a Due.

User avatar
somewhereinusa
 
Posts: 61
Joined: Thu Nov 21, 2013 11:42 am

Re: NMEA data to screen.

Post by somewhereinusa »

In rereading this I see that I did make a mistake in my OP. I am using a UNO, not a DUO

User avatar
wweetts
 
Posts: 3
Joined: Thu Dec 19, 2013 6:19 am

Re: NMEA data to screen.

Post by wweetts »

Is a library for arduino due planned?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: NMEA data to screen.

Post by adafruit_support_rick »

We're working on porting all of our libraries to the Due. However, we have no scheduled date for the RA8875 at this time.

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”