Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
MaJerle committed Nov 15, 2020
2 parents 1bb45d4 + 00df88c commit 22d8656
Show file tree
Hide file tree
Showing 17 changed files with 371 additions and 151 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Lightweiht GPS NMEA parser
# Lightweight GPS NMEA parser

Platform independent GPS NMEA parser for embedded systems.

Expand Down
44 changes: 44 additions & 0 deletions dev/VisualStudio/lwgps_opts.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* \file lwgps_opts_template.h
* \brief LwGPS configuration file
*/

/*
* Copyright (c) 2020 Tilen MAJERLE
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
* AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* This file is part of LwGPS - Lightweight GPS NMEA parser library.
*
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: $2.1.0$
*/
#ifndef LWGPS_HDR_OPTS_H
#define LWGPS_HDR_OPTS_H

/* Rename this file to "lwgps_opts.h" for your application */

/*
* Open "include/lwgps/lwgps_opt.h" and
* copy & replace here settings you want to change values
*/

#endif /* LWGPS_HDR_OPTS_H */
14 changes: 14 additions & 0 deletions dev/VisualStudio/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,21 @@ extern void run_tests();

int
main() {
lwgps_float_t distance, bearing;
run_tests();

/* Calculate distance and bearing */
lwgps_distance_bearing(40.6, -73.7, 48.3, 11.7, &distance, &bearing);

printf("Distance: %lf meters\r\n", (double)distance);
printf("Bearing: %lf degrees\r\n", (double)bearing);

lwgps_distance_bearing(48.3, 11.7, 40.6, -73.7, &distance, &bearing);
printf("Distance: %lf meters\r\n", (double)distance);
printf("Bearing: %lf degrees\r\n", (double)bearing);

return 0;
}

/* JFK: 40.642569, -73.783790 */
/* Munich: 48.353962, 11.775114 */
4 changes: 2 additions & 2 deletions docs/api-reference/gps.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. _api_lwgps:

GPS NMEA Parser
===============
LwGPS
=====

.. doxygengroup:: LWGPS
13 changes: 8 additions & 5 deletions docs/api-reference/gps_opt.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
.. _api_lwgps_config:
.. _api_lwgps_opt:

GPS Configuration
=================
Configuration
=============

This is the default configuration of the middleware.
When any of the settings shall be modified, it shall be done in library header file, ``lwgps/src/include/lwgps/lwgps.h``
When any of the settings shall be modified, it shall be done in dedicated application config ``lwgps_opts.h`` file.

.. doxygengroup:: LWGPS_CONFIG
.. note::
Check :ref:`getting_started` to create configuration file.

.. doxygengroup:: LWGPS_OPT
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
author = 'Tilen MAJERLE'

# The full version, including alpha/beta/rc tags
version = '2.0.0'
version = '2.1.0'

# Try to get branch at which this is running
# and try to determine which version to display in sphinx
Expand Down
14 changes: 13 additions & 1 deletion docs/examples/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Examples and demos
==================

There are ``2`` very basic examples provided with the library.
There are several basic examples provided with the library.

Parse block of data
^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -31,5 +31,17 @@ Data are later processed outside interrupt context.
:linenos:
:caption: Example of buffer

Distance and bearing
^^^^^^^^^^^^^^^^^^^^

Library provides calculation of distance and bearing between ``2`` coordinates on earth.
This is useful if used with autonomnous devices to understand in which direction
device has to move to reach end point while knowing start coordinate.

.. literalinclude:: ../../examples/example_dist_bear.c
:language: c
:linenos:
:caption: Distance and bearing calculation

.. toctree::
:maxdepth: 2
20 changes: 20 additions & 0 deletions docs/get-started/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,28 @@ At this point it is assumed that you have successfully download library, either
* Copy ``lwgps`` folder to your project
* Add ``lwgps/src/include`` folder to `include path` of your toolchain
* Add source files from ``lwgps/src/`` folder to toolchain build
* Copy ``lwgps/src/include/lwgps/lwgps_opts_template.h`` to project folder and rename it to ``lwgps_opts.h``
* Build the project

Configuration file
^^^^^^^^^^^^^^^^^^

Library comes with template config file, which can be modified according to needs.
This file shall be named ``lwgps_opts.h`` and its default template looks like the one below.

.. note::
Default configuration template file location: ``lwgps/src/include/lwgps/lwgps_opts_template.h``.
File must be renamed to ``lwgps_opts.h`` first and then copied to the project directory (or simply renamed in-place) where compiler
include paths have access to it by using ``#include "lwgps_opts.h"``.

.. tip::
Check :ref:`api_lwgps_opt` section for possible configuration settings

.. literalinclude:: ../../lwgps/src/include/lwgps/lwgps_opts_template.h
:language: c
:linenos:
:caption: Template options file

Minimal example code
^^^^^^^^^^^^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LwGPS is lightweight, platform independent library to parse NMEA statements from
.. rst-class:: center
.. rst-class:: index_links

:ref:`download_library` · :ref:`getting_started` · `Open Github <https://github.com/MaJerle/lwgps>`_
:ref:`download_library` :ref:`getting_started` `Open Github <https://github.com/MaJerle/lwgps>`_

Features
^^^^^^^^
Expand Down
6 changes: 6 additions & 0 deletions docs/static/css/common.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/user-manual/how-it-works.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
How it works
============

GPS NMEA Parser parses raw data formatted as NMEA 0183 statements from GPS receivers. It supports up to ``4`` different statements:
LwGPS parses raw data formatted as NMEA 0183 statements from GPS receivers. It supports up to ``4`` different statements:

* ``GPGGA`` or ``GNGGA``: GPS fix data
* ``GPGSA`` or ``GNGSA``: GPS active satellites and dillusion of position
Expand All @@ -12,7 +12,7 @@ GPS NMEA Parser parses raw data formatted as NMEA 0183 statements from GPS recei

.. tip::
By changing different configuration options, it is possible to disable some statements.
Check :ref:`api_lwgps_config` for more information.
Check :ref:`api_lwgps_opt` for more information.

Application must assure to properly receive data from GPS receiver.
Usually GPS receivers communicate with host embedded system with UART protocol and output directly formatted NMEA 0183 statements.
Expand Down
2 changes: 1 addition & 1 deletion examples/example.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* This example uses direct processing function
* to process dummy NMEA data from GPS receiver
*/
#include "lwgps/lwgps.h"
#include <string.h>
#include <stdio.h>
#include "lwgps/lwgps.h"

/* GPS handle */
lwgps_t hgps;
Expand Down
24 changes: 24 additions & 0 deletions examples/example_dist_bear.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "lwgps/lwgps.h"

/* Distance and bearing results */
lwgps_float_t dist, bear;

/* New York coordinates */
lwgps_float_t lat1 = 40.685721;
lwgps_float_t lon1 = -73.820465;

/* Munich coordinates */
lwgps_float_t lat2 = 48.150906;
lwgps_float_t lon2 = 11.554176;

/* Go from New York to Munich */
/* Calculate distance and bearing related to north */
lwgps_distance_bearing(lat1, lon1, lat2, lon2, &dist, &bear);
printf("Distance: %f meters\r\n", (float)dist);
printf("Initial bearing: %f degrees\r\n", (float)bear);

/* Go from Munich to New York */
/* Calculate distance and bearing related to north */
lwgps_distance_bearing(lat2, lon2, lat1, lon1, &dist, &bear);
printf("Distance: %f meters\r\n", (float)dist);
printf("Initial bearing: %f degrees\r\n", (float)bear);

0 comments on commit 22d8656

Please sign in to comment.