I had to comment Serial.flush() in order to get the fix.satellites, otherwise it stays at 0 (initialization).
Ah, it keeps the loop from getting back in time to read pollserial. It could be because the LAST_SENTENCE is incorrectly set to RMC (see below).
One other thing that would help... Have you sent any configuration commands to the GPS device? If you are only using date, time and location, you only need to be receiving the RMC and GGA sentences (see Choosing Your Configuration). Since you're using the NEO-6M module, you would send a "$PUBX,40" command with the message name to enable or disable.
This will save all the processing time for reading and parsing the characters, reducing the characters per second from ~500 to ~160, a significant savings. That also increases the GPS quiet time from ~500ms to ~840ms each second. You will be able to do more work after fix = gps.read()
before causing GPS characters to be lost.
Here's a modified setup
that starts the pollserial
first and then sends the configuration commands. Then it starts TVout
after that's completed:
#define NEO6M_DISABLE(m) F("PUBX,40," #m ",0,0,0,0,0,0")
#define NEO6M_ENABLE(m) F("PUBX,40," #m ",0,1,0,0,0,0")
void setup() {
Serial.begin( 9600 );
Serial.println( banner );
Serial.println( F("Date/Time,CS errors") );
Serial.flush();
pt2Funct fn = pserial.begin(9600); // save the return value for later
// Turn off the other NMEA sentences, they're wasting our time
gps.send_P( &pserial, NEO6M_DISABLE(GLL) );
gps.send_P( &pserial, NEO6M_DISABLE(GSA) );
gps.send_P( &pserial, NEO6M_DISABLE(GSV) );
gps.send_P( &pserial, NEO6M_DISABLE(VTG) );
// Turn on these two
gps.send_P( &pserial, NEO6M_ENABLE(RMC) );
gps.send_P( &pserial, NEO6M_ENABLE(GGA) );
TV.begin(_NTSC,184,72);
TV.select_font(font6x8);
TV.println( banner );
delay( 1000 ); // let the banner show for a bit
TV.set_hbi_hook( fn ); // from the pserial.begin above
TV.set_vbi_hook( setVBIflag );
TV.clear_screen();
TV.print("HEURE GMT: :\nSatellites:");
}
You will need to change line 29 in NMEAGPS_cfg.h from RMC to GGA:
#define LAST_SENTENCE_IN_INTERVAL NMEAGPS::NMEA_GGA
The NEO-6M sends the GGA last. After this change, you might try that Serial.flush
again. It's not a big deal if it still doesn't work. Also comment line 278 out:
//#define NMEAGPS_RECOGNIZE_ALL
This saves some more program space and processing time. This would be a good time to review GPSfix_cfg.h. Right now, only DATE, TIME and SATELLITES should be uncommented:
#define GPS_FIX_DATE
#define GPS_FIX_TIME
//#define GPS_FIX_LOCATION
//#define GPS_FIX_LOCATION_DMS
//#define GPS_FIX_ALTITUDE
//#define GPS_FIX_SPEED
//#define GPS_FIX_HEADING
#define GPS_FIX_SATELLITES
//#define GPS_FIX_HDOP
//#define GPS_FIX_VDOP
//#define GPS_FIX_PDOP
//#define GPS_FIX_LAT_ERR
//#define GPS_FIX_LON_ERR
//#define GPS_FIX_ALT_ERR
//#define GPS_FIX_GEOID_HEIGHT
This will save a lot of processing time and 1700 bytes of program space. It will save a little RAM, too.
It is now 11h99 with 70 satellites on my screen, I might need to update a larger portion of it
LOL, a leading space or zero will fix the time, and a leading or trailing space would fix the satellites count:
// Update the time
TV.set_cursor( 12*6, 0*8 );
if (fix.dateTime.hours < 10)
TV.write( ' ' );
TV.print( fix.dateTime.hours , DEC );
TV.set_cursor( 15*6, 0*8 );
if (fix.dateTime.minutes < 10)
TV.write( '0' );
TV.print( fix.dateTime.minutes, DEC );
// Update the satellites
TV.print( 12*6, 1*8, fix.satellites, DEC );
TV.write( ' ' );
Don't forget to scoot the colon over with an extra space for the hours:
TV.print("HEURE GMT: :\nSatellites:"); // the static labels
^ extra space
I think I used that above.
Do you think I can still read a 4*1 keypad by «traditional means» (array reading) or the Mega can't handle that with the TV? The keypad will input the waypoint (+,-,next,enter).
Sure, just poll the pins in loop
and do some software debounce. I wouldn't do it with Pin Change Interrupts. If it has trouble catching the press, you can "stretch" the presses with an RC debounce on the keys and skip the software debounce.
Cheers,
/dev