diff --git a/examples/latlon.py b/examples/latlon.py index 21216d8..b880142 100755 --- a/examples/latlon.py +++ b/examples/latlon.py @@ -1,12 +1,10 @@ #!/usr/bin/env python3 import time -from pa1010d import PA1010D, PPS +from pa1010d import PA1010D -gps = PA1010D() -# Blink PPS LED always, but with less obnoxious pulse width -gps.set_pps(PPS.ALWAYS, pulse_width=5) +gps = PA1010D() while True: result = gps.update() diff --git a/library/CHANGELOG.txt b/library/CHANGELOG.txt index 0f98d12..eba8bc4 100644 --- a/library/CHANGELOG.txt +++ b/library/CHANGELOG.txt @@ -1,3 +1,11 @@ +0.0.2 +----- + +* Add support for disabling PPS LED +* Handle spurious newlines in sentences +* Add PDOP, VDOP and HDOP output +* Handle GLL messages + 0.0.1 ----- diff --git a/library/README.md b/library/README.md index 7212995..a7b249f 100644 --- a/library/README.md +++ b/library/README.md @@ -32,6 +32,14 @@ Stable (library only) from PyPi: * Just run `sudo pip3 install pa1010d` # Changelog +0.0.2 +----- + +* Add support for disabling PPS LED +* Handle spurious newlines in sentences +* Add PDOP, VDOP and HDOP output +* Handle GLL messages + 0.0.1 ----- diff --git a/library/pa1010d/__init__.py b/library/pa1010d/__init__.py index 132322c..427fd0a 100644 --- a/library/pa1010d/__init__.py +++ b/library/pa1010d/__init__.py @@ -1,35 +1,15 @@ import time import smbus -import enum import pynmea2 -__version__ = '0.0.1' +__version__ = '0.0.2' PA1010D_ADDR = 0x10 -class PPS(enum.Enum): - """Available states for the PA1010D PPS LED""" - - """Disable PPS LED""" - DISABLE = 0 - - """Blink after the first fix""" - AFTER_FIRST_FIX = 1 - - """Blink only for 3D fix""" - ONLY_3D = 2 - - """Blink for 2D or 3D fix""" - ONLY_2D_3D = 3 - - """Blink always""" - ALWAYS = 4 - - class PA1010D(): __slots__ = ( "timestamp", @@ -80,7 +60,7 @@ def _write_sentence(self, bytestring): """ for char_index in bytestring: - self._i2c.write_byte(self._i2c_addr, char_index) + self._i2c.write_byte(self._i2c_addr, ord(char_index)) def send_command(self, command, add_checksum=True): """Send a command string to the PA1010D. @@ -88,13 +68,10 @@ def send_command(self, command, add_checksum=True): If add_checksum is True (the default) a NMEA checksum will automatically be computed and added. """ - if type(command) is str: - command = command.encode("ascii") - # TODO replace with pynmea2 functionality - if command.startswith(b"$"): + if command.startswith("$"): command = command[1:] - if command.endswith(b"*"): + if command.endswith("*"): command = command[:-1] buf = bytearray() @@ -128,25 +105,10 @@ def read_sentence(self, timeout=5): # Should be a full \r\n since the GPS emits spurious newlines if buf[-2:] == [ord("\r"), ord("\n")]: # Remove line ending and spurious newlines from the sentence - return bytearray(buf).decode("ascii").strip().replace("\n", "") + return bytearray(buf).decode("ascii").strip().replace("\n","") raise TimeoutError("Timeout waiting for readline") - def set_pps(self, mode=PPS.ALWAYS, pulse_width=100): - """Set pulse per second config. - - Define the status LED behaviour on the PA1010d. - - :param mode: One PPS enum types - :param pulse_width: LED pulse with in ms (1ms to 999ms) - - """ - if not isinstance(mode, PPS): - raise ValueError("Mode must be of type PPS") - - sentence = "PMTK285,{mode},{pulse_width}".format(mode=mode.value, pulse_width=pulse_width) - self.send_command(sentence) - def update(self, wait_for="GGA", timeout=5): """Attempt to update from PA1010D. @@ -226,11 +188,7 @@ def update(self, wait_for="GGA", timeout=5): # $PMTK011,MTKGPS*08 Successful bootup # $PMTK010,001*2E Startup # $PMTK010,002*2D Wake from standby, normal operation - - # set_pps will produce a: - # $PMTK001,285,3*3F Confirm PPS LED setting - if self._debug: - print(sentence) + print(sentence) return True else: diff --git a/library/setup.cfg b/library/setup.cfg index f544f9a..0b502ac 100644 --- a/library/setup.cfg +++ b/library/setup.cfg @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- [metadata] name = pa1010d -version = 0.0.1 +version = 0.0.2 author = Philip Howard author_email = phil@pimoroni.com description = Python library for the PA1010D i2c GPS module