Snorktracker
 All Data Structures Files Functions Variables Macros Pages
Public Member Functions | Data Fields
MyDegrees Class Reference

#include <Gps.h>

Public Member Functions

 MyDegrees ()
 
 MyDegrees (const MyDegrees &myDegrees)
 
void clear ()
 
double value ()
 
bool set (const String &data)
 

Data Fields

uint16_t predecimal
 Value on the left side of the separator.
 
uint32_t billionths
 Value of the right side after the separator.
 
bool negative
 Is the value negative?
 

Detailed Description

Class to store the gps values with the right precision.

Definition at line 26 of file Gps.h.

Constructor & Destructor Documentation

MyDegrees::MyDegrees ( )

Constructor

Definition at line 185 of file Gps.h.

186  : predecimal(0)
187  , billionths(0)
188  , negative(false)
189 {
190 }
uint16_t predecimal
Value on the left side of the separator.
Definition: Gps.h:29
uint32_t billionths
Value of the right side after the separator.
Definition: Gps.h:30
bool negative
Is the value negative?
Definition: Gps.h:31
MyDegrees::MyDegrees ( const MyDegrees myDegrees)

Constructor

Definition at line 193 of file Gps.h.

194  : predecimal(myDegrees.predecimal)
195  , billionths(myDegrees.billionths)
196  , negative(myDegrees.negative)
197 {
198 }
uint16_t predecimal
Value on the left side of the separator.
Definition: Gps.h:29
uint32_t billionths
Value of the right side after the separator.
Definition: Gps.h:30
bool negative
Is the value negative?
Definition: Gps.h:31

Member Function Documentation

void MyDegrees::clear ( )

Reset the values.

Definition at line 201 of file Gps.h.

References billionths, negative, and predecimal.

Referenced by MyLocation::clear().

202 {
203  predecimal = 0;
204  billionths = 0;
205  negative = false;
206 }
uint16_t predecimal
Value on the left side of the separator.
Definition: Gps.h:29
uint32_t billionths
Value of the right side after the separator.
Definition: Gps.h:30
bool negative
Is the value negative?
Definition: Gps.h:31
bool MyDegrees::set ( const String &  data)

Sets the internal format from the nmea format.

Definition at line 217 of file Gps.h.

References billionths, negative, and predecimal.

Referenced by MyGps::setLatitude(), and MyGps::setLongitude().

218 {
219  const char *term = data.c_str();
220  uint32_t multiplier = 1000000000UL;
221  uint32_t leftOfDecimal = (uint32_t) atol(term);
222 
223  predecimal = (int16_t)leftOfDecimal;
224  billionths = 0;
225 
226  while (isdigit(*term)) {
227  ++term;
228  }
229 
230  if (*term == '.') {
231  while (isdigit(*++term)) {
232  multiplier /= 10;
233  billionths += (*term - '0') * multiplier;
234  }
235  }
236  negative = false;
237  return true;
238 }
uint16_t predecimal
Value on the left side of the separator.
Definition: Gps.h:29
uint32_t billionths
Value of the right side after the separator.
Definition: Gps.h:30
bool negative
Is the value negative?
Definition: Gps.h:31
double MyDegrees::value ( )

Recalculate the value from the pre and post decimal to double.

Definition at line 209 of file Gps.h.

References billionths, negative, and predecimal.

Referenced by MyLocation::latitude(), and MyLocation::longitude().

210 {
211  double ret = predecimal + billionths / 1000000000.0;
212 
213  return negative ? -ret : ret;
214 }
uint16_t predecimal
Value on the left side of the separator.
Definition: Gps.h:29
uint32_t billionths
Value of the right side after the separator.
Definition: Gps.h:30
bool negative
Is the value negative?
Definition: Gps.h:31

The documentation for this class was generated from the following file: