Skip to content

Commit

Permalink
- continuing development with Navilock NL-303P module...
Browse files Browse the repository at this point in the history
  - '°' sign no OK for LCD
  - HDOP display added
  - removed leading '0's in degrees display
  - fixed bugs in lat/lon seconds display
  - time filed is longer -> special treatment required
  - fixed locator calculation, was b...shit !
  - fixed char array sizes
  - enabled speed/course display
- gpssim.cc: a program to provide valid NMEA-strings for sim.
  • Loading branch information
avr committed Aug 10, 2009
1 parent 3ebfd37 commit 8402258
Show file tree
Hide file tree
Showing 9 changed files with 444 additions and 49 deletions.
13 changes: 12 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$Id: CHANGES,v 1.10 2009/07/30 11:03:39 avr Exp $
$Id: CHANGES,v 1.11 2009/08/10 15:05:53 avr Exp $

CHANGES file for project GPSDisplay
============================================================================
Expand All @@ -18,6 +18,17 @@ ToDo:
- reduce memory consumption of some calculations/conversion routines


2009/08/10 (thjm) - continuing development with Navilock NL-303P module...
- '�' sign no OK for LCD
- HDOP display added
- removed leading '0's in degrees display
- fixed bugs in lat/lon seconds display
- time filed is longer -> special treatment required
- fixed locator calculation, was b...shit !
- fixed char array sizes
- enabled speed/course display
- gpssim.cc: a program to provide valid NMEA-strings for sim.

2009/07/24 (thjm) - imported get8key4.* (P.Dannegger)
- checking push button to advance LCD display mode
- this uses counter1 which is also used in WhereAVR
Expand Down
80 changes: 65 additions & 15 deletions GPS.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* Purpose: Implementation of the GPS stuff
*
* $Id: GPS.c,v 1.5 2009/07/24 15:52:40 avr Exp $
* $Id: GPS.c,v 1.6 2009/08/10 15:05:53 avr Exp $
*
*/

Expand All @@ -15,6 +15,7 @@

#include <stdlib.h> // atoi()
#include <string.h>
#include <stdint.h>

/** @file GPS.c
* GPS routines.
Expand Down Expand Up @@ -79,21 +80,54 @@ void GpsMsgPrepare(void)
{
GpsDataClear( &gGpsData );

#if (defined GPS_NAVILOCK)
gTempGpsData.fTime[6] = 0; // cut '.sss' part of the data
#endif /* GPS_NAVILOCK */
strcpy( gGpsData.fTime, gTempGpsData.fTime ); // latest Time

#ifndef APRS
strcpy( gGpsData.fDate, gTempGpsData.fDate ); // latest Date
#endif /* APRS */

strcpy( gGpsData.fLatitude, gTempGpsData.fLatitude ); // latest Latitude
if ( gGpsData.fLatitude[0] == '0' ) // remove leading '0' in degrees field
gGpsData.fLatitude[0] = ' ';
gGpsData.fNorthSouth[0] = gTempGpsData.fNorthSouth[0];

strcpy( gGpsData.fLongitude, gTempGpsData.fLongitude ); // latest Longitude
for ( uint8_t i=0; i<2; i++ ) { // remove leading '0' in degrees field
if ( gGpsData.fLongitude[i] == '0' )
gGpsData.fLongitude[i] = ' ';
else
break;
}
gGpsData.fEastWest[0] = gTempGpsData.fEastWest[0];

strcpy( gGpsData.fAltitude, gTempGpsData.fAltitude ); // latest Altitude
for ( uint8_t i=0; i<sizeof(gTempGpsData.fSpeed); i++ ) // skip fractional value
if ( gTempGpsData.fSpeed[i] == '.' ) {
gTempGpsData.fSpeed[i] = 0;
break;
}
strcpy( gGpsData.fSpeed, gTempGpsData.fSpeed ); // latest Speed

for ( uint8_t i=0; i<sizeof(gTempGpsData.fCourse); i++ ) // skip fractional value
if ( gTempGpsData.fCourse[i] == '.' ) {
gTempGpsData.fCourse[i] = 0;
break;
}
strcpy( gGpsData.fCourse, gTempGpsData.fCourse ); // latest Course

strcpy( gGpsData.fSatellites, gTempGpsData.fSatellites ); // latest Satellites

#ifndef APRS
strcpy( gGpsData.fHDOP, gTempGpsData.fHDOP ); // latest HDOP
#endif /* APRS */

#if (defined APRS) || (defined TEST)
// convert altitude string into feet
GpsCalculateFeet();
#endif /* APRS || TEST */

// finally manipulate the status bits ...
if ( GpsDataIsValid( &gTempGpsData ) ) GpsDataSetValid( &gGpsData );
Expand Down Expand Up @@ -144,22 +178,30 @@ unsigned char GpsMsgHandler(unsigned char newchar)
return kTRUE;
}

// detect NMEA sentence type ...

if (commas == 0) {

switch (newchar) {

case ('C'): // Only the GPRMC sentence contains a "C"
case 'C': // Only the GPRMC sentence contains a "C"
gSentenceType = kGPRMC; // Set local parse variable
break;

case ('S'): // Take note if sentence contains an "S"
case 'S': // Take note if sentence contains an "S"
gSentenceType = kGPGSA; // ...because we don't want to parse it
break;

case ('A'): // The GPGGA sentence ID contains "A"
case 'A': // The GPGGA sentence ID contains "A"
if (gSentenceType != kGPGSA) // As does GPGSA, which we will ignore
gSentenceType = kGPGGA; // Set local parse variable
break;
#if 0
case 'V':
gSentenceType = kGPVTG;
break;
#endif

}

return kFALSE;
Expand Down Expand Up @@ -212,6 +254,7 @@ unsigned char GpsMsgHandler(unsigned char newchar)

#ifndef APRS
case 8: // HDOP field
gTempGpsData.fHDOP[index++] = newchar;
return kFALSE;
#endif /* APRS */

Expand Down Expand Up @@ -272,7 +315,7 @@ unsigned char GpsMsgHandler(unsigned char newchar)
return kFALSE;
#endif

case 7: // Speed field [knots]
case 7: // Speed field [km/h]
gTempGpsData.fSpeed[index++] = newchar;
return kFALSE;

Expand Down Expand Up @@ -361,11 +404,12 @@ void GpsCalculateFeet(void)
void GpsCalculateLocator(void)
{
char temp[5];
int degrees;
uint16_t degrees;
uint8_t minutes;

memset( gLocator, ' ', sizeof(gLocator));

// --- 1st character
// --- 1st character (20 degrees per 'digit')

strncpy( temp, gGpsData.fLongitude, 3 ); temp[3] = 0;

Expand All @@ -376,17 +420,19 @@ void GpsCalculateLocator(void)

gLocator[0] = 'A' + degrees / 20;

// --- 3rd character
// --- 3rd character (2 degrees per 'digit', 120 minutes in total)

gLocator[2] = '0' + ((degrees % 20) >> 1);

// --- 5th character
// --- 5th character (5 minutes per 'digit')

strncpy( temp, &gGpsData.fLongitude[4], 2 ); temp[2] = 0;
strncpy( temp, &gGpsData.fLongitude[3], 2 ); temp[2] = 0;

gLocator[4] = 'A' + atoi( temp ) / 24;
minutes = (degrees % 2) * 60 + atoi( temp );

// --- 2nd character
gLocator[4] = 'A' + minutes / 5;

// --- 2nd character (10 degrees per 'digit')

strncpy( temp, gGpsData.fLatitude, 2 ); temp[2] = 0;

Expand All @@ -397,15 +443,19 @@ void GpsCalculateLocator(void)

gLocator[1] = 'A' + degrees / 10;

// --- 4th character
// --- 4th character (1 degree per 'digit', 60 minutes in total)

gLocator[3] = '0' + degrees % 10;

// --- 6th character
// --- 6th character (2.5 minutes per 'digit')

strncpy( temp, &gGpsData.fLatitude[2], 2 ); temp[2] = 0;

minutes = atoi( temp ) << 1;
if ( atoi(&gGpsData.fLatitude[5]) >= 5000 )
minutes += 1;

gLocator[5] = 'A' + (atoi( temp ) << 1) / 24;
gLocator[5] = 'A' + minutes / 5;

// finally add the trailing \000

Expand Down
12 changes: 9 additions & 3 deletions GPS.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Purpose: GPS messaging definitions/declarations for the atmega8.
*
* $Id: GPS.h,v 1.3 2009/07/24 15:52:40 avr Exp $
* $Id: GPS.h,v 1.4 2009/08/10 15:05:53 avr Exp $
*/

#ifndef _GPS_h_
Expand All @@ -29,6 +29,8 @@ typedef enum {
kGPRMC = 1,
kGPGGA = 2,

kGPVTG = 3,

kGPGSA = 9 // detected, but not decoded

} EGPSSentenceType;
Expand All @@ -44,7 +46,11 @@ typedef struct {

unsigned char fStatus; // Status bits to indicate ...

#if (defined GPS_NAVILOCK)
char fTime[11]; // UTC time in HHMMSS.sss format
#else
char fTime[7]; // UTC time in HHMMSS format
#endif // GPS_NAVILOCK
#ifndef APRS
char fDate[7]; // Date in DDMMYY format
#endif /* APRS */
Expand All @@ -53,8 +59,8 @@ typedef struct {
char fLongitude[11]; // Longitude in DDDMM.MMMM format
char fEastWest[1];
char fAltitude[8]; // Altitude (meters) in MMM.MMM format
char fSpeed[6]; // Speed (knots) in kkk.kk format
char fCourse[6]; // Track angle (degrees) in ddd.dd format
char fSpeed[7]; // Speed (knots) in kkk.kk format
char fCourse[7]; // Track angle (degrees) in ddd.dd format
#ifndef APRS
char fHDOP[5]; // (H)DOP, precision value
#endif /* APRS */
Expand Down
7 changes: 3 additions & 4 deletions GPSDisplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* Purpose: Contains main() of project GPSDisplay
*
* $Id: GPSDisplay.c,v 1.3 2009/07/27 06:57:49 avr Exp $
* $Id: GPSDisplay.c,v 1.4 2009/08/10 15:05:53 avr Exp $
*
*/

Expand Down Expand Up @@ -171,7 +171,8 @@ int main(void)
unsigned int ch;
#endif // USE_N4TXI_UART

unsigned int lcd_mode = kDateTime;
//uint8_t lcd_mode = kDateTime;
uint8_t lcd_mode = kLatLon;

LcdDisplaySetMode( lcd_mode );

Expand Down Expand Up @@ -209,8 +210,6 @@ int main(void)

if ( GetKeyPress( BUTTON1 ) ) {

//while ( gKeyState & BUTTON1 ); // wait until button was released

lcd_mode++;

if ( lcd_mode > kMaxDisplayMode ) lcd_mode = kTimeLocator;
Expand Down
Loading

0 comments on commit 8402258

Please sign in to comment.