Skip to content

Instantly share code, notes, and snippets.

@tjpeden
Last active March 21, 2019 04:11
Show Gist options
  • Save tjpeden/095b415ec8942060feee0d892cf2da89 to your computer and use it in GitHub Desktop.
Save tjpeden/095b415ec8942060feee0d892cf2da89 to your computer and use it in GitHub Desktop.
Displaying GPS FeatherWing data on an OLED FeatherWing

The Problem

No GPS messages are processed when doing full or partial fill on the screen.

When line 53 is commented out GPS messages are processed as normal and data on the screen updates, albeit unreadable. If line 53 is uncommented GPS messages stop being processed after the first second. This is demonstrated by passing debug=True in the GPS constructor and viewing the serial monitor in Mu. GPS messages stop showing up in the serial monitor after the first second.

The screen is still being updated, boxes can be drawn, etc but messages from the GPS do not flow thus the data on the OLED is stale.

Debugging

Things I've Tried

  • adding time.sleep calls to the beginning and end of the loop of various lengths (0.1, 0.25, 0.5, 0.75)
  • changing the message update rate (all values listed in Arduino lib)
  • changing the fix update rate (all values listed in Arduino lib)
  • adding time.sleep in place of the fill call
  • rearrange code so that oled rendering is done after reading GPS data

Details

Library Versions: adafruit-circuitpython-bundle-4.x-mpy-20190320

boot_out.txt:

Adafruit CircuitPython 4.0.0-beta.5 on 2019-03-17; Adafruit Feather nRF52840 Express with nRF52840
import time
from board import SCL, SDA, RX, TX
from busio import I2C, UART
from adafruit_gps import GPS
from adafruit_ssd1306 import SSD1306_I2C
i2c = I2C(SCL, SDA)
uart = UART(TX, RX, baudrate=9600, timeout=3)
gps = GPS(uart, debug=True)
oled = SSD1306_I2C(128, 32, i2c)
gps.send_command(b'PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
gps.send_command(b'PMTK300,1000,0,0,0,0')
gps.send_command(b'PMTK220,1000')
date = ''
position = ''
# time.sleep(1)
last_print = time.monotonic()
while True:
gps.update()
if not gps.has_fix:
print('Waiting for fix...')
date = 'Waiting for fix...'
current = time.monotonic()
if gps.has_fix and current - last_print >= 1.0:
last_print = current
date = '{}/{}/{} {:02}:{:02}:{:02}'.format(
gps.timestamp_utc.tm_mon,
gps.timestamp_utc.tm_mday,
gps.timestamp_utc.tm_year,
gps.timestamp_utc.tm_hour,
gps.timestamp_utc.tm_min,
gps.timestamp_utc.tm_sec
)
position = '({:.2f}, {:.2f}) {}/{}'.format(
gps.latitude,
gps.longitude,
gps.satellites,
gps.fix_quality
)
# print(position)
# print(date)
oled.fill(0)
oled.text(date, 0, 0, 1)
oled.text(position, 0, 8, 1)
oled.show()
# time.sleep(0.75)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment