Skip to content

Commit

Permalink
Merge pull request #18 from pimoroni/feature/pps
Browse files Browse the repository at this point in the history
Fix PPS for #14.
  • Loading branch information
Gadgetoid authored Jul 17, 2023
2 parents 045b0e4 + 10b5a0a commit 65cbb25
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
9 changes: 7 additions & 2 deletions examples/pps.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@

gps = PA1010D()

pulse_width = 100

if len(sys.argv) > 2:
pulse_width = int(sys.argv[2])

if sys.argv[1] == "on":
gps.send_command("PMTK255,1")
gps.send_command(f"PMTK285,4,{pulse_width}")
else:
gps.send_command("PMTK255,0")
gps.send_command(f"PMTK285,0,{pulse_width}")

result = gps.update()

Expand Down
15 changes: 15 additions & 0 deletions library/pa1010d/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@

PA1010D_ADDR = 0x10

PPS_DISABLE = 0
PPS_AFTER_FIRST_FIX = 1
PPS_3D_FIX_ONLY = 2
PPS_3D_2D_FIX_ONLY = 3
PPS_ALWAYS = 4


class PA1010D():
__slots__ = (
Expand Down Expand Up @@ -220,6 +226,15 @@ def update(self, wait_for="GGA", timeout=5):

raise TimeoutError("Timeout waiting for {wait_for} message.".format(wait_for=wait_for))

def set_pps(self, mode, pulse_width=100):
if mode not in (0, 1, 2, 3, 4):
raise ValueError("Invalid PPS mode (0 to 4)")

if pulse_width > 900 or pulse_width < 1:
raise ValueError("Invalid PPS pulse_width (1 to 900ms)")

self.send_command(f"PMTK285,{mode},{pulse_width}")


if __name__ == "__main__":
gps = PA1010D()
Expand Down

0 comments on commit 65cbb25

Please sign in to comment.