Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add I2C support and various example fixes #36

Merged
merged 15 commits into from Nov 16, 2019
Next

add a function that will read raw data so we can use uart or i2c. upd…

…ated echotest to use new function
  • Loading branch information
ladyada committed Nov 2, 2019
commit 86e10dcb42c9005bd04cb60e8a56fe157afde995
@@ -181,6 +181,11 @@ def nmea_sentence(self):
"""Return raw_sentence which is the raw NMEA sentence read from the GPS"""
return self._raw_sentence

def read(self, num_bytes):
"""Read up to num_bytes of data from the GPS directly, without parsing.
Returns a bytearray with up to num_bytes or None if nothing was read"""
return self._uart.read(num_bytes)

def _read_sentence(self):
# Parse any NMEA sentence that is available.
# pylint: disable=len-as-condition
@@ -1,6 +1,6 @@
# Simple GPS module demonstration.
# Will print NMEA sentences received from the GPS, great for testing connection
# Uses the GPS only to send some commands, then reads directly from UART
# Uses the GPS to send some commands, then reads directly from the GPS
import time
import board
import busio
@@ -52,7 +52,7 @@
# Main loop runs forever printing data as it comes in
timestamp = time.monotonic()
while True:
data = uart.read(32) # read up to 32 bytes
data = gps.read(32) # read up to 32 bytes
# print(data) # this is a bytearray type

if data is not None:
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.