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;
}
}