Skip to content

Commit

Permalink
Fixed latitude wrapping, error checking
Browse files Browse the repository at this point in the history
  • Loading branch information
poster515 committed Oct 3, 2021
1 parent f3788b5 commit 2760a80
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions bathymetry_blink/bathymetry_blink.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
import numpy as np
import sys

MAX_ERRORS = 3
num_errors = 0

# Obtain default parameters
with open("./bathymetry_blink/bathy_config.json") as f:
config = json.load(f)
Expand Down Expand Up @@ -99,7 +102,7 @@

# update the location of the next row of elevation data to take
loc[0] += delta
loc[0] = loc[0] % rows
loc[0] = ((loc[0] + 90) % 180) - 90 # wraps to next pole if overflow

print("Lat index: " + str(latitude_index))
print("Lon index: " + str(longitude_index))
Expand All @@ -117,7 +120,7 @@

# send all pixel data to bt
for pixel in output_pixels:
print("Sending r: %1, g: %2, b: %3".format(*pixel))
print("Sending r: {}, g: {}, b: {}".format(*pixel))
bt.sendPixel(*pixel)

# finally, show the image
Expand All @@ -140,3 +143,8 @@
# flush any incomplete data
bt.show()

num_errors += 1

if num_errors > MAX_ERRORS:
sys.exit("Error count exceeds that allowed.")

0 comments on commit 2760a80

Please sign in to comment.