From 46dba2f32c2192cb0942c34a08754ed7fd003950 Mon Sep 17 00:00:00 2001 From: Brendan Haines Date: Mon, 2 Mar 2020 19:29:40 -0700 Subject: [PATCH] add line position calculation --- Software/python/hwtest.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Software/python/hwtest.py b/Software/python/hwtest.py index 9ea7c5f..3bb0c9e 100644 --- a/Software/python/hwtest.py +++ b/Software/python/hwtest.py @@ -95,17 +95,15 @@ curdoc().add_periodic_callback(update_plot, 250) def control_thread(): global brightness - ii = 0 while True: time.sleep(0.01) - brightness = [get_normalized_reflectivity(c) for c in range(8)] + brightness = np.clip([get_normalized_reflectivity(c) for c in range(8)], 0, 1) + line_position = np.sum((1 - brightness) * (np.arange(8) - 3.5))/np.sum(1-brightness) if DEBUG: for b in brightness: print(f"{b:1.2f}\t", end="") + print(f"{line_position:+1.2f}", end="") print() - ii += 1 - if ii == 10: - ii = 0 t = threading.Thread(target=control_thread)