Skip to content

Commit

Permalink
Fix NoneType access error
Browse files Browse the repository at this point in the history
  • Loading branch information
wrongsyntax committed Feb 8, 2025
1 parent c86ea5d commit 7c2050b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions samples/xm125_polling.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

import src.modules.autopilot.altimeter as altimeter

altimeter = altimeter.XM125()
altimeter = altimeter.XM125(average_window=5)
altimeter.begin()

while True:
result = altimeter.measure()
if result:
print("Average dist: ", result[0]['averaged'][0])
average = result[0]['averaged']

# Average distance will not be available until at least `average_window` measurements have been taken
if average:
print("Average dist: ", result[0]['averaged'][0])

sleep(0.5)

0 comments on commit 7c2050b

Please sign in to comment.