Skip to content

Commit

Permalink
Fix PPS for #14.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gadgetoid committed Jul 14, 2023
1 parent 045b0e4 commit 10b5a0a
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 10b5a0a

Please sign in to comment.