SlashDevin / NeoGPS

NMEA and ublox GPS parser for Arduino, configurable to use as few as 10 bytes of RAM
GNU General Public License v3.0
702 stars 194 forks source link

Neogps library and Tft display #131

Open mustafa-ozlu opened 4 years ago

mustafa-ozlu commented 4 years ago

Hi, i wrote a code for displaying gps nmea sentences to tft display. But my code not display results. Display all sentences 0.00 Where is my fault.

include

static const uint32_t GPSBaud = 38400;

include

static NMEAGPS gps; static gps_fix fix;

define gpsPort Serial

define GPS_PORT_NAME "Serial"

include

include

if defined(_GFXFONTH)

include <Fonts/FreeSerif9pt7b.h>

define ADJ_BASELINE 11

else

define ADJ_BASELINE 0

endif

define LCD_CS A3

define LCD_CD A2

define LCD_WR A1

define LCD_RD A0

define BLACK 0x0000

define BLUE 0x001F

define RED 0xF800

define GREEN 0x07E0

define CYAN 0x07FF

define MAGENTA 0xF81F

define YELLOW 0xFFE0

define WHITE 0xFFFF

MCUFRIEND_kbv tft; static const int32_t zone_hours = 3L; // "C" +3Hours Ankara Time static const int32_t zone_minutes = 0L; static const NeoGPS::clock_t zone_offset = zone_hours NeoGPS::SECONDS_PER_HOUR + zone_minutes NeoGPS::SECONDS_PER_MINUTE;

static const NeoGPS::Location_t Foca( 38.3810, -26.4550 ); long bearingToFoca = fix.location.BearingToDegrees( Foca ); long range = fix.location.DistanceMiles( Foca );

void setup() { gpsPort.begin( GPSBaud ); pinMode(13, OUTPUT); tft.reset(); uint16_t identifier = tft.readID(); tft.begin(identifier); tft.setRotation(1);

if defined(_GFXFONTH)

tft.setFont(&FreeSerif9pt7b);

endif

tft.fillScreen(BLUE); delay(100); tft.fillScreen(RED); delay(100); tft.fillScreen(GREEN); delay(100); tft.fillScreen(BLACK); tft.setCursor(20, 40); tft.setTextColor(MAGENTA); tft.setTextSize(2); tft.println("GPS BILGILERI"); delay(3000); tft.fillScreen(BLACK);

}

void loop() { displayInfo(); }

void adjustTime( NeoGPS::time_t & dt ) { NeoGPS::clock_t seconds = dt; // convert date/time structure to seconds seconds += zone_offset; dt = seconds; // convert seconds back to a date/time structure

} // adjustTime

void displayInfo() { while (gps.available( gpsPort )) { gps_fix fix = gps.read(); digitalWrite( 13, !digitalRead(13) ); } if ((gps.statistics.chars < 10) && (millis() > 5000)) { tft.setCursor(0, 35); tft.setTextSize(2); tft.println(F("GPS Sinyali Bekleniyor")); // while (true); } tft.fillScreen(BLACK); tft.setTextColor(WHITE); if (fix.valid.date && fix.valid.time) { adjustTime( fix.dateTime ); } tft.setCursor(1, 25); tft.setTextSize(2); tft.print(F("Saat : ")); if (fix.dateTime.hours < 10) { tft.print("0"); tft.print(fix.dateTime.hours); } else { tft.print(fix.dateTime.hours); } Serial.print("SAAT : "); Serial.print(fix.dateTime.hours); Serial.print(":"); Serial.print(fix.dateTime.minutes); Serial.print(":"); Serial.println(fix.dateTime.seconds); tft.print(F(":")); if (fix.dateTime.minutes < 10) { tft.print("0"); tft.print(fix.dateTime.minutes); } else { tft.print(fix.dateTime.minutes); } tft.print(F(":")); if (fix.dateTime.seconds < 10) { tft.print("0"); tft.println(fix.dateTime.seconds); } else { tft.println(fix.dateTime.seconds); } Serial.print("Tarih : "); Serial.print(fix.dateTime.date); Serial.print("/"); Serial.print(fix.dateTime.month); Serial.print("/"); Serial.println(fix.dateTime.year); tft.print(F("Tarih : ")); tft.print(fix.dateTime.date); tft.print(F("/")); tft.print(fix.dateTime.month); tft.print(F("/")); tft.println(fix.dateTime.year); tft.setTextColor(YELLOW); tft.setTextSize(1); tft.print("Lat : "); if (fix.latitude() < 0) { tft.print(fix.latitude()); tft.println(" S"); } else { tft.print(fix.latitude()); tft.println(" N"); } tft.setTextColor(YELLOW); tft.print("Long: "); if (fix.longitude() < 0) { tft.print(fix.longitude()); tft.println(" E"); } else { tft.print(fix.longitude()); tft.println(" W"); } gpsPort.print("LAT : "); gpsPort.print(fix.latitude() ); gpsPort.print(" LON : "); gpsPort.println(fix.longitude() ); tft.print("HIZ : "); tft.print(fix.speed()); tft.println(" Kts"); gpsPort.print("HIZ: "); gpsPort.println(fix.speed() ); tft.print("FOCA'ya :"); tft.print(range); tft.println(" Nm"); gpsPort.print("Mesafe: "); gpsPort.println( range ); tft.print("Kerteriz :"); tft.print(bearingToFoca); gpsPort.print("KERTE: "); gpsPort.println( bearingToFoca ); tft.setTextSize(2); tft.setCursor(200, 100); tft.setTextColor(RED); tft.print("ROTA"); tft.setCursor(220, 130); if (fix.heading() < 10) { tft.print("00"); tft.print(fix.heading()); } else if (fix.heading() < 100) { tft.print("0"); tft.print(fix.heading()); } else { tft.print(fix.heading()); } gpsPort.print("PRUVA: "); gpsPort.println(fix.heading() );

delay(2); }