Skip to content

Commit

Permalink
- reorganized writing to LCD (preparations for PROGMEM usage)
Browse files Browse the repository at this point in the history
  • Loading branch information
avr committed Jul 27, 2009
1 parent 197a225 commit d6f833e
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 12 deletions.
3 changes: 2 additions & 1 deletion 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.2 2009/07/24 15:52:40 avr Exp $
* $Id: GPSDisplay.c,v 1.3 2009/07/27 06:57:49 avr Exp $
*
*/

Expand Down Expand Up @@ -190,6 +190,7 @@ int main(void)
else {
// check error flags first
if ( ch & UART_FRAME_ERROR )
//uart_puts_p( PSTR("UART Frame Error!\r\n") );
uart_puts_P( "UART Frame Error!\r\n" );
if ( ch & UART_OVERRUN_ERROR )
uart_puts_P( "UART Overrun Error!\r\n" );
Expand Down
60 changes: 52 additions & 8 deletions LCDDisplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* Purpose: Implementation of the generic LCD display stuff
*
* $Id: LCDDisplay.c,v 1.1 2009/07/24 15:52:40 avr Exp $
* $Id: LCDDisplay.c,v 1.2 2009/07/27 06:57:49 avr Exp $
*
*/

Expand Down Expand Up @@ -107,14 +107,64 @@ static void LcdDisplayUpdate(void)
char temp[10];
char *src;
int seconds;
#if (defined __AVR__)
const char *pLCD1, *pLCD2;
#else
const char *pLCD1, *pLCD2;
#endif // __AVR__

// clear strings to be displayed next

memset( gLCDLine1, ' ', sizeof(gLCDLine1));
memset( gLCDLine2, ' ', sizeof(gLCDLine2));

// read display masks from memory

switch ( gDisplayMode ) {

case kTimeLocator:

pLCD1 = gLCDText[0][0];
pLCD2 = gLCDText[0][1];
break;

case kLatLon:
pLCD1 = gLCDText[2][0];
pLCD2 = gLCDText[2][1];
break;

case kLocatorAltitude:
pLCD1 = gLCDText[3][0];
pLCD2 = gLCDText[3][1];
break;

#if 0
case kSpeedRoute:
pLCD1 = gLCDText[4][0];
pLCD2 = gLCDText[4][1];
break;
#endif

case kDOP:
pLCD1 = gLCDText[5][0];
pLCD2 = gLCDText[5][1];
break;

case kDateTime:
default:
pLCD1 = gLCDText[1][0];
pLCD2 = gLCDText[1][1];
}

memcpy( gLCDLine1, pLCD1, sizeof(gLCDLine1) );
memcpy( gLCDLine2, pLCD2, sizeof(gLCDLine2) );

// fill display strings with data

switch ( gDisplayMode ) {

case kTimeLocator:
memcpy( gLCDLine1, gLCDText[0][0], sizeof(gLCDLine1) );

src = gGpsData.fTime;
gLCDLine1[3] = *src++;
gLCDLine1[4] = *src++;
Expand All @@ -124,12 +174,10 @@ static void LcdDisplayUpdate(void)
gLCDLine1[10] = *src++;

GpsCalculateLocator();
memcpy( gLCDLine2, gLCDText[0][1], sizeof(gLCDLine2) );
strncpy( &gLCDLine2[5], gLocator, 6 );
break;

case kLatLon:
memcpy( gLCDLine1, gLCDText[2][0], sizeof(gLCDLine1) );

src = gGpsData.fLatitude;
gLCDLine1[6] = *src++;
Expand All @@ -146,8 +194,6 @@ static void LcdDisplayUpdate(void)
gLCDLine1[14] = '"';
gLCDLine1[15] = gGpsData.fNorthSouth[0];

memcpy( gLCDLine2, gLCDText[2][1], sizeof(gLCDLine2) );

src = gGpsData.fLongitude;
gLCDLine2[5] = *src++;
gLCDLine2[6] = *src++;
Expand All @@ -167,10 +213,8 @@ static void LcdDisplayUpdate(void)

case kLocatorAltitude:
GpsCalculateLocator();
memcpy( gLCDLine1, gLCDText[3][0], sizeof(gLCDLine1) );
strncpy( &gLCDLine1[9], gLocator, 6 );

memcpy( gLCDLine2, gLCDText[3][1], sizeof(gLCDLine2) );
strncpy( &gLCDLine2[14-strlen(gGpsData.fAltitude)],
gGpsData.fAltitude, strlen(gGpsData.fAltitude) );
break;
Expand Down
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###############################################################################
# Makefile for the project GPSDisplay
#
# $Id: Makefile,v 1.3 2009/07/24 15:52:40 avr Exp $
# $Id: Makefile,v 1.4 2009/07/27 06:57:49 avr Exp $
#
###############################################################################

Expand Down Expand Up @@ -91,7 +91,8 @@ Serial.o: Serial.c

## Link
$(TARGET): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)
$(CC) $(LDFLAGS) $^ $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) \
-o $(TARGET) -Wl,-Map,$(PROJECT).map

## test targets

Expand Down Expand Up @@ -126,7 +127,7 @@ size:: ${TARGET}
## Clean target
.PHONY: clean
clean::
-rm -rf $(OBJECTS) GPSDisplay.elf .deps/* GPSDisplay.hex GPSDisplay.eep
-rm -rf $(OBJECTS) GPSDisplay.elf .deps/* GPSDisplay.hex GPSDisplay.eep GPSDisplay.map

## Other dependencies
-include $(shell mkdir .deps 2>/dev/null) $(wildcard .deps/*)
Expand Down

0 comments on commit d6f833e

Please sign in to comment.