myGPS code part 2
//********************************************************************
//
//********************************************************************
void fDeclareStartTime()
{
//if gps does not have day value then skip
if (GPS.day > 0)
{
char buf[25];
sprintf(buf, "%02d/%02d %02d:%02d:%02d", GPS.month, GPS.day, GPS.hour, GPS.minute, GPS.seconds);
sStartTime = buf;
}
}//end fDeclareStartTime()
void StartStopDistanceCounter()
{
if (lGPS_Lat0 == 0)
{
//save starting lat n lon if needed
lGPS_Lat0 = round(GPS.latitude * 100) * 60;
lGPS_Lon0 = round(GPS.longitude * 100) * 60;
}
}
void ResetDistanceCounter()
{
//byteUpdateDistanceInterval = 0;
lDistance = 0;
lGPS_Lat0 = 0;
lGPS_Lon0 = 0;
}//end void SetResetDistanceCounter()
void fResetElapsedTime()
{
sStartTime = "";
sEndTime = "";
sElasped = "";
tDays = 0;
tHourCount = 0;
tMinuteCount = 0;
//tSecondCount = 0;
//bRun = true;
}//void fResetElapsedTime()
void fBatteryPercentRemaingCharge()
{
byte V_BattNominal = 8;
byte V_MinRange = 6; //volts is lowest recomemded operating voltage
if (floatVbatt >= V_BattNominal)
{
BattPercent = 100.00;
return;
}
else if (V_MinRange > floatVbatt)
{
BattPercent = 0.00;
return;
}
else
{
BattPercent = ((floatVbatt - V_MinRange) * 100.0) / (V_BattNominal - V_MinRange);
}
}// end fBatteryPercentRemaingCharge()
//
////////////////////// OLED Picture Loop Draw ///////////////////
//// if data to be displayed exceeds screen size Arduino may lock up
//// shown by intertnal LED stops blinking
//
void PageOne(void) {
char buf[20];
float f = 0.0;
//(X,Y) X=left right, Y= up down
u8g.setFont(u8g_font_5x8);
u8g.drawStr( 0, 7, "BAT:");
u8g.setPrintPos(22, 7); u8g.print(floatVbatt);
u8g.drawStr(43, 7, "V" );
u8g.drawStr( 50, 7, "%" );
//r = sprintf(buf, "%d.%d", byteBatteryPercentUpper, byteBatteryPercentLower);
//sprintf(buf, "%", floatBattPercent);
u8g.setPrintPos(55, 7); u8g.print(BattPercent);
//u8g.setPrintPos(55, 7); u8g.print(byteBatteryPercentUpper + ".");
sprintf(buf, "UTC %02d:%02d:%02d", GPS.hour, GPS.minute, GPS.seconds);
u8g.setPrintPos(0, 15); u8g.print(buf);
u8g.drawStr(64, 15, "Fix: ");
u8g.setPrintPos(85, 15); u8g.print(GPS.fix);
sprintf(buf, "Date: %02d/%02d/%02d", GPS.day, GPS.month, GPS.year);
u8g.setPrintPos(0, 23); u8g.print(buf);
u8g.drawHLine(3, 26, 115);
u8g.drawVLine(3, 26, 27);
u8g.drawVLine(117, 26, 27);
u8g.drawHLine(3, 52, 115);
if (GPS.fix)
{
u8g.drawStr(0, 62, "Hdg:");
u8g.setPrintPos(25, 62); u8g.print(GPS.angle);
u8g.drawStr(91, 15, "^");
u8g.setPrintPos(99, 15); u8g.print(GPS.satellites);
u8g.drawStr(63, 62, "MPH:");
if ((lDistance * 3.2808) >= 500)
//>= 500 feet
{
//Knots-per-hour X 6076 (feet per Knot) = feet-per-hour
//feet-per-hour / 5280 (feet per mile) = mph
u8g.setPrintPos(83, 62); u8g.print(((GPS.speed * 6076) / 5280));
}
else
{
u8g.setPrintPos(83, 62); u8g.print(0.00);
}
//u8g.setFont(u8g_font_7x13);
u8g.drawStr(7, 37, "Lat:");
f = (GPS.latitude / 100);
u8g.setPrintPos(35, 37); u8g.print(int(f));
u8g.drawCircle(48, 32, 1, U8G_DRAW_ALL);
f = GPS.latitude - (int(f) * 100);
u8g.setPrintPos(55, 37); u8g.print(f);
u8g.setPrintPos(83, 37); u8g.print(GPS.lat);
f = 0.0;
u8g.drawStr(7, 48, "Lon:");
f = (GPS.longitude / 100);
u8g.setPrintPos(30, 48); u8g.print(int(f));
u8g.drawCircle(48, 42, 1, U8G_DRAW_ALL); // outer fixed circle
f = GPS.longitude - (int(f) * 100);
u8g.setPrintPos(55, 48); u8g.print(f);
u8g.setPrintPos(83, 48); u8g.print(GPS.lon);
}
}// void PageOne(void) end