help with Printf_P(PSTR())

i am trying to print to an glcd using the glcd lib but i am having 2 problems that i have been googling for days and cant find the answer.

1.) i am wanting to print either a V or an A to tell if a gps has a lock. the code i am trying to use is...

    Serial.print("\nStatus: ");
    Serial.print(status);
        t5.CursorToXY(0,0);
    t5.Printf_P(PSTR("%01S"),status);

2.) i am printing a value of less then 16.00 but i want it to show ##.#V rather then just as ####V as it it showing up now.

// the data for the battery voltage
    Serial.print("\nVoltage: ");
    Serial.print(volts);
        t6.CursorToXY(0,0);
     t6.Printf_P(PSTR("%04d"),volts);t6.Printf_P(PSTR("V"));

We have no idea what t5 and t6 are, so it is not possible to tell precisely what is supposed to happen. You don't help, either, by not saying what does happen.

i am printing a value of less then 16.00 but i want it to show ##.#V rather then just as ####V as it it showing up now.

We don't know what type volts is, so printing it as an integer might be appropriate.

t5 and t6 are text areas i have defined to the glcd.

gText t1 = gText(10,0,  3,1,    fixednums15x31);    // used for the speedometer


gText t2 = gText(10,29, 5,1,    fixednums15x31);    // used for the tachometer

gText t3 = gText(60,0,  8,1,    SystemFont5x7);     //used for time 

gText t4 = gText(60,8,  8,1,    SystemFont5x7);     //used for date

gText t5 = gText(60,16, 1,1,    SystemFont5x7);     //used for sat. lock

gText t6 = gText(68,16, 5,1,    SystemFont5x7);     //used for the voltage of the battery

"volts" is defined as unsigned int volts;

but i tried it as a float however, that did not change anything so i changed it back since i am trying to save as much RAM as i can

"status" is defined as char status;

t6.Printf_P(PSTR("%04d"),volts);t6.Printf_P(PSTR("V")); //----------> is showing up on the glcd as "0001V". i am trying to make it show up as "01.2V"

t5.Printf_P(PSTR("%01S"),status); //-----------is not showing anything at all Serial.print(status);//----------> is showing "V" right now

i am not really sure what part of the code you need to see. i thoguht where i used "%04d" and "%01S" i should be using something else. i cant seem to find some where that says what "%04d" , "%02S" and "%02s" are used for and the difference between them. really i have been looking

If volts is an int, it will never show as 1.2 anywhere. Still not enough details about gText to explain how to print a float. Most likely, you will need to separate it into two parts - the whole value (1) and the fractional part (.2), then scale the fractional part (multiply by 10 and add 0.5) and truncate it (print as int) and print the two parts with a dot in between.

As to status bit, a char (printed using %c) is not a string (printed using %s). Also, we have no idea what is stored in status. Is it really a printable character?

i cant seem to find some where that says what "%04d" , "%02S" and "%02s" are used for and the difference between them. really i have been looking

They are format specifiers. Google printf (the basis of all value to character data conversion functions) to read about format specifiers.

ok im sry i still am not able to print volts to the glcd. it prints to the serial monitor just fine. i just dont understand.

i googled println and did some reading on that and got “stat” printing to the glcd like it should.

here is my code as far as i have it now

// A simple sketch to read GPS data and parse the $GPRMC string 
// see http://www.ladyada.net/make/gpsshield for more info
// GPS parser for 406a
#include "glcd.h"
#define BUFFSIZ 90 //90 plenty big
#include "fonts/allFonts.h"
char buffer[BUFFSIZ];

char *parseptr;

char buffidx;

uint8_t hour, minute, second, year, month, date;

//uint32_t latitude, longitude;

uint8_t groundspeed, trackangle;

//char latdir, longdir;

char status;

unsigned int tachometer;

float volts = 0.0;


//------------------------------------------------------------------------------
//-----------------------------------pin defined--------------------------------
//------------------------------------------------------------------------------

const int voltpin = 1;

//******************************************************************************
//************************************setup*************************************
//******************************************************************************


void setup() 

{ 	pinMode(voltpin, INPUT);//need to see the voltage of the battory

	
	GLCD.Init(NON_INVERTED);
	GLCD.ClearScreen();
	GLCD.SelectFont(System5x7);
	GLCD.Printf_P(PSTR("bike speedo test"));

   Serial.begin(9600);

   Serial1.begin(4800);

	delay(3000);

GLCD.ClearScreen();
 } 

gText t1 = gText(10,0,	3,1,	fixednums15x31);	// used for the speedometer
	
gText t2 = gText(10,29,	5,1,	fixednums15x31);	// used for the tachometer

gText t3 = gText(60,0,	8,1,	SystemFont5x7);		//used for time 

gText t4 = gText(60,8,	8,1,	SystemFont5x7);		//used for date

gText t5 = gText(60,16,	1,1,	SystemFont5x7);		//used for sat. lock

gText t6 = gText(68,16,	6,1,	SystemFont5x7); 	//used for the voltage of the battery





//***********************************************************************************
//***************************************start of loop*******************************
//***********************************************************************************

void loop() 

{ 

  uint32_t tmp;


	// read the value on analog input
	volts = analogRead(voltpin); //5v =317
	volts = volts * 5.0; //=1585
	volts = volts /1023.0; //=1.549364614
	volts = volts * 1.454545455;//=2.253621257
	
	//volts = parsedecimal(parseptr);

		//parseptr = strchr(parseptr, '.')+1;
	 

	//voltsdec = parsedecimal(parseptr);
  

  //Serial.print("\n\rread: ");

  readline();

  

  // check if $GPRMC (global positioning fixed data)

  if (strncmp(buffer, "$GPRMC",6) == 0) {

    

    // hhmmss time data

    parseptr = buffer+7;

    tmp = parsedecimal(parseptr); 

    hour = tmp / 10000;

    minute = (tmp / 100) % 100;

    second = tmp % 100;

	if (hour > 05)
	{
		hour -= (6);
	}
    
	else if (hour < 05)
	{
		hour += (18);
	}


    parseptr = strchr(parseptr, ',') + 1;


    status = parseptr[0];

    /*
    // grab latitude & long data

    // latitude

    parseptr = strchr(parseptr, ',')+1;

    latitude = parsedecimal(parseptr);

    if (latitude != 0) {

      latitude *= 10000;

      parseptr = strchr(parseptr, '.')+1;

      latitude += parsedecimal(parseptr);

    }

    parseptr = strchr(parseptr, ',') + 1;

    // read latitude N/S data

    if (parseptr[0] != ',') {

      latdir = parseptr[0];

    }

    

    //Serial.println(latdir);

    

    // longitude

    parseptr = strchr(parseptr, ',')+1;

    longitude = parsedecimal(parseptr);

    if (longitude != 0) {

      longitude *= 10000;

      parseptr = strchr(parseptr, '.')+1;

      longitude += parsedecimal(parseptr);

    }

    parseptr = strchr(parseptr, ',')+1;

    // read longitude E/W data

    if (parseptr[0] != ',') {

      longdir = parseptr[0];

    }

    */



parseptr = strchr(parseptr, ',') + 1;
parseptr = strchr(parseptr, ',') + 1;
parseptr = strchr(parseptr, ',') + 1;
parseptr = strchr(parseptr, ',') + 1;

    // groundspeed

    parseptr = strchr(parseptr, ',')+1;

    groundspeed = parsedecimal(parseptr);
    
	parseptr = strchr(parseptr, '.')+1;

	groundspeed += ((parsedecimal(parseptr))/100);

    groundspeed *=(1.1507);
	
    // track angle

    parseptr = strchr(parseptr, ',')+1;

    trackangle = parsedecimal(parseptr);


    // date

    parseptr = strchr(parseptr, ',')+1;

    tmp = parsedecimal(parseptr); 

    date = tmp / 10000;

    month = (tmp / 100) % 100;

    year = tmp % 100;

//***********************************************************************
//************************start of printing data*************************
//***********************************************************************

// the status connection to the satalites goes here
    
	Serial.print("\nStatus: ");
	Serial.print(status);
	    t5.CursorToXY(0,0);
	t5.Printf_P(PSTR("%01c"),status);//something is wrong here


// speed is printed from here

    Serial.print("\nSpeed: ");
    Serial.print(groundspeed, DEC);

    t1.CursorToXY(0,0);
	t1.Printf_P(PSTR("%3d"),groundspeed);


//the data for the tach is printed here
    Serial.print("\ntach: ");
    Serial.print(tachometer);
	t2.CursorToXY(0,0);
	if (tachometer <= 10300)
		{
		t2.Printf_P(PSTR("%5d"),tachometer);
		} 
	else if(tachometer >= 10301)
		{ 
		t2.SetFontColor(WHITE);
		t2.ClearArea();
		t2.Printf_P(PSTR("%5d"),tachometer);
		} 
 


// your heading in degrees is printed from here    
    Serial.print("\nTracking angle: ");
    Serial.print(trackangle, DEC);
    


// the data for the battery voltage
	Serial.print("\nVoltage: ");
	Serial.print(volts, DEC);
	    t6.CursorToXY(0,0);
	 t6.println(volts, DEC);
	t6.Printf_P(PSTR("V"));



// time of day is printed from here    
    Serial.print("\nTime: ");

    Serial.print(hour, DEC); Serial.print(':');

    Serial.print(minute, DEC); Serial.print(':');

    Serial.println(second, DEC);

	t3.CursorToXY(0,0);
	t3.Printf("%02d:%02d:%02d",hour,minute,second);

// the date is printed form here
    Serial.print("Date: ");

    Serial.print(month, DEC); Serial.print('/');

    Serial.print(date, DEC); Serial.print('/');

    Serial.println(year, DEC);

	t4.Printf("%02d/%02d/%02d", month, date, year);



    /*

    Serial.print("Lat: "); 

    if (latdir == 'N')

       Serial.print('+');

    else if (latdir == 'S')

       Serial.print('-');



    Serial.print(latitude/10000000, DEC); Serial.print('\°', BYTE); Serial.print(' ');

    Serial.print((latitude/10000)%100, DEC); Serial.print('\''); Serial.print(' ');

    Serial.print((latitude%10000)*6/1000, DEC); Serial.print('.');

    Serial.print(((latitude%10000)*6/10)%100, DEC); Serial.println('"');

   

    Serial.print("Long: ");

    if (longdir == 'E')

       Serial.print('+');

    else if (longdir == 'W')

       Serial.print('-');

    Serial.print(longitude/10000000, DEC); Serial.print('\°', BYTE); Serial.print(' ');

    Serial.print((longitude/10000)%100, DEC); Serial.print('\''); Serial.print(' ');

    Serial.print((longitude%10000)*6/1000, DEC); Serial.print('.');

    Serial.print(((longitude%10000)*6/10)%100, DEC); Serial.println('"');

   */

  }

  //Serial.println(buffer);

}



uint32_t parsedecimal(char *str) {

  uint32_t d = 0;

  

  while (str[0] != 0) {

   if ((str[0] > '9') || (str[0] < '0'))

     return d;

   d *= 10;

   d += str[0] - '0';

   str++;

  }

  return d;

}



void readline(void) {

  char c;

  

  buffidx = 0; // start at begninning

  while (1) {

      c=Serial1.read();

      if (c == -1)

        continue;

      Serial.print(c);

      if (c == '\n')

        continue;

      if ((buffidx == BUFFSIZ-1) || (c == '\r')) {

        buffer[buffidx] = 0;

        return;

      }

      buffer[buffidx++]= c;

  }

}
if (hour > 05)
{
	hour -= (6);
}

else if (hour < 05)
{
hour += (18);
}

And if the hour is exactly 5? Leave it alone? So how can you tell the difference between 11 (which after you subtract 6 becomes 5), and 5 (which stays the same)?

This might be better:

if (hour > 05)
  	{
		hour -= 6;
	}
	else 
	{
		hour += 18;
	}