Skip to content

Commit 4952641

Browse files
authored
Added tips on using floats to README
1 parent 5ffed45 commit 4952641

File tree

1 file changed

+49
-2
lines changed

1 file changed

+49
-2
lines changed

README.rst

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,54 @@ This is easily achieved by downloading
3131
Usage Example
3232
=============
3333

34-
See examples/simple.py for a demonstration of parsing and printing GPS location.
34+
See examples/gps_simpletest.py for a demonstration of parsing and printing GPS location.
35+
36+
Important:
37+
Feather boards and many other circuitpython boards will round to two decimal places like this:
38+
39+
.. code-block:: python
40+
41+
>>> float('1234.5678')
42+
1234.57
43+
44+
This isn't ideal for gps data as this lowers the accuracty from 0.1m to 11m.
45+
46+
This can be fixed by using string formatting when the gps data is outputted.
47+
48+
An implementation of this can be found in examples/gps_simpletest.py
49+
50+
.. code-block:: python
51+
52+
import time
53+
import board
54+
import busio
55+
56+
import adafruit_gps
57+
58+
RX = board.RX
59+
TX = board.TX
60+
61+
uart = busio.UART(TX, RX, baudrate=9600, timeout=3000)
62+
63+
gps = adafruit_gps.GPS(uart, debug=False)
64+
65+
gps.send_command(b'PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
66+
67+
gps.send_command(b'PMTK220,1000')
68+
69+
while True:
70+
71+
gps.update()
72+
73+
current = time.monotonic()
74+
if current - last_print >= 1.0:
75+
last_print = current
76+
if not gps.has_fix:
77+
print('Waiting for fix...')
78+
continue
79+
print('=' * 40) # Print a separator line.
80+
print('Latitude: {0:.6f} degrees'.format(gps.latitude))
81+
print('Longitude: {0:.6f} degrees'.format(gps.longitude))
3582
3683
Contributing
3784
============
@@ -85,4 +132,4 @@ Now, once you have the virtual environment activated:
85132
86133
This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to
87134
view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to
88-
locally verify it will pass.
135+
locally verify it will pass.

0 commit comments

Comments
 (0)