diff --git a/bathymetry_blink/bathymetry_blink.py b/bathymetry_blink/bathymetry_blink.py index 4026c35..2bc573e 100644 --- a/bathymetry_blink/bathymetry_blink.py +++ b/bathymetry_blink/bathymetry_blink.py @@ -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) @@ -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)) @@ -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 @@ -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.") + \ No newline at end of file