Skip to content

Commit 803c981

Browse files
authored
Merge pull request #96 from awordforthat/issue82/update-gps-docs
add docstrings to GPS class attrs
2 parents f25a987 + a9d9a11 commit 803c981

File tree

1 file changed

+54
-18
lines changed

1 file changed

+54
-18
lines changed

adafruit_gps.py

Lines changed: 54 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -216,50 +216,96 @@ def _parse_data(sentence_type: int, data: List[str]) -> Optional[List]:
216216
return params
217217

218218

219-
# lint warning about too many attributes disabled
220-
# pylint: disable-msg=R0902
221-
222-
219+
# pylint: disable-msg=too-many-instance-attributes
223220
class GPS:
224221
"""GPS parsing module. Can parse simple NMEA data sentences from serial
225222
GPS modules to read latitude, longitude, and more.
226223
"""
227224

225+
# lint warning about too many statements disabled
226+
# pylint: disable-msg=R0915
228227
def __init__(self, uart: UART, debug: bool = False) -> None:
229228
self._uart = uart
230229
# Initialize null starting values for GPS attributes.
231230
self.timestamp_utc = None
231+
"""Timestamp in UTC"""
232232
self.latitude = None
233+
"""Degrees latitude"""
233234
self.latitude_degrees = None
235+
"""Degrees component of latitude measurement"""
234236
self.latitude_minutes = None # Use for full precision minutes
237+
"""Minutes component of latitude measurement"""
235238
self.longitude = None
239+
"""Degrees longitude"""
236240
self.longitude_degrees = None
241+
"""Degrees component of longitude measurement"""
237242
self.longitude_minutes = None # Use for full precision minutes
243+
"""Minutes component of longitude measurement"""
238244
self.fix_quality = 0
245+
"""
246+
GPS quality indicator
247+
248+
| 0 - fix not available
249+
| 1 - GPS fix
250+
| 2 - Differential GPS fix (values above 2 are 2.3 features)
251+
| 3 - PPS fix
252+
| 4 - Real Time Kinematic
253+
| 5 - Float RTK
254+
| 6 - estimated (dead reckoning)
255+
| 7 - Manual input mode
256+
| 8 - Simulation mode
257+
"""
239258
self.fix_quality_3d = 0
259+
"""
260+
The type of fix for a reading
261+
262+
| 1 - no fix
263+
| 2 - 2D fix
264+
| 3 - 3D fix
265+
"""
240266
self.satellites = None
267+
"""The number of satellites in use, 0 - 12"""
241268
self.satellites_prev = None
269+
"""The number of satellites in use from the previous data point, 0 - 12"""
242270
self.horizontal_dilution = None
271+
"""Horizontal dilution of precision (GGA)"""
243272
self.altitude_m = None
273+
"""Antenna altitude relative to mean sea level"""
244274
self.height_geoid = None
275+
"""Geoidal separation relative to WGS 84"""
245276
self.speed_knots = None
277+
"""Ground speed in knots"""
246278
self.track_angle_deg = None
279+
"""Track angle in degrees"""
247280
self._sats = None # Temporary holder for information from GSV messages
248-
self.sats = None # Completed information from GSV messages
281+
self.sats = None
282+
"""Information from GSV messages"""
249283
self.isactivedata = None
250-
self.true_track = None
251-
self.mag_track = None
284+
"""Status Valid(A) or Invalid(V)"""
252285
self.sat_prns = None
286+
"""Satellite pseudorandom noise code"""
253287
self.sel_mode = None
288+
"""
289+
Selection mode
290+
291+
| 'M' - manual
292+
| 'A' - automatic
293+
"""
254294
self.pdop = None
295+
"""Dilution of precision"""
255296
self.hdop = None
297+
"""Horizontal dilution of precision (GSA)"""
256298
self.vdop = None
299+
"""Vertical dilution of precision"""
257300
self.total_mess_num = None
301+
"""Number of messages"""
258302
self.mess_num = None
303+
"""Message number"""
259304
self._raw_sentence = None
260305
self._mode_indicator = None
261306
self._magnetic_variation = None
262307
self.debug = debug
308+
"""Toggles debug mode. When True, prints the incoming data sentence to the console"""
263309

264310
def update(self) -> bool:
265311
"""Check for updated data from the GPS module and process it
@@ -535,15 +581,6 @@ def _parse_gga(self, data: List[str]) -> bool:
535581
self.longitude_degrees, self.longitude_minutes = _read_int_degrees(data, 3, "w")
536582

537583
# GPS quality indicator
538-
# 0 - fix not available,
539-
# 1 - GPS fix,
540-
# 2 - Differential GPS fix (values above 2 are 2.3 features)
541-
# 3 - PPS fix
542-
# 4 - Real Time Kinematic
543-
# 5 - Float RTK
544-
# 6 - estimated (dead reckoning)
545-
# 7 - Manual input mode
546-
# 8 - Simulation mode
547584
self.fix_quality = data[5]
548585

549586
# Number of satellites in use, 0 - 12
@@ -662,8 +699,7 @@ def _parse_gsv(self, talker: bytes, data: List[str]) -> bool:
662699
# been seen for 30 seconds
663700
timestamp = time.monotonic()
664701
old = []
665-
for i in self.sats:
666-
sat = self.sats[i]
702+
for sat in self.sats.items():
667703
if (timestamp - sat[4]) > 30:
668704
old.append(i)
669705
for i in old:

0 commit comments

Comments
 (0)