Library Functions.
More...
Library Functions.
Adds custom GPG statement to array of user selectable statements. Array is available to user using TM_GPS_t workign structure.
- Note
- Functions uses malloc() function to allocate memory, so make sure you have enough heap memory available.
-
Also note, that your GPS receiver HAVE TO send statement type you use in this function, or TM_GPS_Update() function will always return that there is not data available to read.
- Parameters
-
| *GPS_Data | Pointer to working TM_GPS_t structure |
| *GPG_Statement | String of NMEA starting line address, including "$" at beginning |
| TermNumber | Position in NMEA statement |
- Return values
-
| Success | status:
- NULL: Malloc() failed or you reached limit of user selectable custom statements:
- > NULL: Function succeded, pointer to TM_GPS_Custom_t structure
|
| void TM_GPS_ConvertFloat |
( |
float |
num, |
|
|
TM_GPS_Float_t * |
Float_Data, |
|
|
uint8_t |
decimals |
|
) |
| |
Converts float number into integer and decimal part.
- Parameters
-
| num | Float number to split into 2 parts |
| *Float_Data | Pointer to TM_GPS_Float_t structure where to save result |
| decimals | Number of decimal places for conversion |
- Note
- Example: You have number 15.002 in float format.
- You want to split this to integer and decimal part with 6 decimal places.
- Call TM_GPS_ConvertFloat(15.002, &Float_Struct, 6);
- Result will be: Integer: 15; Decimal: 2000 (0.002 * 10^6)
- Return values
-
| float TM_GPS_ConvertSpeed |
( |
float |
SpeedInKnots, |
|
|
TM_GPS_Speed_t |
toSpeed |
|
) |
| |
Converts speed in knots (from GPS) to user selectable speed.
- Parameters
-
| speedInKnots | float value from GPS module |
| toSpeed | Select to which speed you want conversion from knot. This parameter ca be a value of TM_GPS_Speed_t enumeration. |
- Return values
-
| Calculated | speed from knots to user selectable format |
Calculates distance between 2 coordinates on earth and bearing from start to end point in relation to the north.
- Parameters
-
| *Distance_Data | Pointer to TM_GPS_Distance_t structure with latitude and longitude set values |
- Note
- Calculation results will be saved in *Distance_Data TM_GPS_Distance_t structure
- Return values
-
| void TM_GPS_Init |
( |
TM_GPS_t * |
GPS_Data, |
|
|
uint32_t |
baudrate |
|
) |
| |
Initializes GPS and USART peripheral.
- Parameters
-
| *GPS_Data | Pointer to TM_GPS_t structure to set default values |
| baudrate | Specify GPS baudrate for USART. Most common are 9600 or 115200 bauds |
- Note
- GPS baudrate can have other values. Check GPS datasheet for proper info.
- Return values
-
Update GPS data.
- Note
- This function must be called periodically, as fast as possible. It basically checks if data is available on GPS USART and parse it to useful data for user.
-
- When you first call this function and there is not available data from GPS, this function will return TM_GPS_Result_FirstTimeWaiting.
- This will be returning all the time we don't have any useful data.
- When first time useful data is received from GPS (everything parsed), TM_GPS_Result_NewData will be returned.
- When we have already new data, next time we call this function, TM_GPS_Result_OldData will be returning until we don't receive new packet of useful data.
-
If you are making GPS logger, then when you receive TM_GPS_Result_NewData it is time to save your data.
- Parameters
-
| *GPS_Data | Pointer to working TM_GPS_t structure |
- Return values
-