I am trying to troubleshoot my code, but I am having issues due to the IDE not displaying the most recent snapshot image, which I am adding lines to with draw_line. I am getting an image displayed but I think it is likely the next to last image and not the one that I am trying to trouble shoot. Below is an abbreviated version of my code, and I need to have the most recent img snapshot with the added draw_lines at the time of the sys.exit.
import sys
from pyb import UART
# UART 3, and baudrate - this is the communication channel
uart = UART(3, 115200, timeout_char=200)
sensor.reset() # Reset and initialize the sensor.
sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.SVGA) # Set frame size to SVGA (800x600)
sensor.set_auto_exposure(False, exposure_us=1000)
sensor.skip_frames(time=500) # Wait for settings take effect.
clock = time.clock() # Create a clock object to track the FPS.
rec_code = 0 #this will contain the sheet count received
send_code = 0 #this will contain the outgoing positioning pixel
code_ready = 0 #ready indicator
test = 1 #set to 1 to run continuously for testing, 0 for regular operation
def get_data(rec_code,code_ready):
#code removed
def send_data(send_code,code_ready):
#code removed
def main(rec_code,pic_cnt):
#code removed
print(sheet_width)
print(gaps)
print(sheets)
print("xxx")
map_var = 0
img.to_rgb565() #change image to colro so colored lines can be added
for q_pos,q in enumerate(sheets):
if q_pos == rec_code-1:
map_var = q
img.draw_line((300,q,500,q), color=(50, 0, 205)) #add purple line for sheet being sent back
else:
img.draw_line((300,q,500,q), color=(255, 0, 0)) #add red lines at other sheets
if map_var > 440:
sensor.flush()
sys.exit()
while True:
if uart.any(): #"listen" for go signal, then call get_data
rec_code,code_ready = get_data(rec_code,code_ready)
if test: #set test to 1 to allow to run without incoming go signal
rec_code = 16
code_ready = 1
if code_ready != 0: #good go signal received
send_code = main(rec_code) # call main function to find sheets (does all the work)
rec_code,code_ready = send_data(send_code,code_ready)
Thanks,
Mike