diff --git a/examples/pps.py b/examples/pps.py index a679c60..f4d812b 100755 --- a/examples/pps.py +++ b/examples/pps.py @@ -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() diff --git a/library/pa1010d/__init__.py b/library/pa1010d/__init__.py index a3c0110..a38240d 100644 --- a/library/pa1010d/__init__.py +++ b/library/pa1010d/__init__.py @@ -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__ = ( @@ -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()