@@ -133,16 +133,19 @@ def try_capture(event, data):
133133 if not keepgoing :
134134 print ("try_capture called while keepgoing==False, aborting..." )
135135 return False # tell the task handler not to update (redraw)
136- if use_webcam :
137- current_cam_buffer = webcam .capture_frame (cam , "rgb565" )
138- elif cam .frame_available ():
139- current_cam_buffer = cam .capture ()
140- if current_cam_buffer and len (current_cam_buffer ) and keepgoing :
141- image_dsc .data = current_cam_buffer
142- #image.invalidate() # does not work so do this:
143- image .set_src (image_dsc )
144- if not use_webcam :
145- cam .free_buffer () # Free the old buffer
136+ try :
137+ if use_webcam :
138+ current_cam_buffer = webcam .capture_frame (cam , "rgb565" )
139+ elif cam .frame_available ():
140+ current_cam_buffer = cam .capture ()
141+ if current_cam_buffer and len (current_cam_buffer ) and keepgoing :
142+ image_dsc .data = current_cam_buffer
143+ #image.invalidate() # does not work so do this:
144+ image .set_src (image_dsc )
145+ if not use_webcam :
146+ cam .free_buffer () # Free the old buffer
147+ except Exception as e :
148+ print (f"Camera capture exception: { e } " )
146149
147150
148151def build_ui ():
@@ -263,6 +266,12 @@ def init_cam():
263266
264267while appscreen == lv .screen_active () and keepgoing :
265268 time .sleep_ms (100 )
269+ if status_label .get_text () != status_label_text :
270+ status_label .set_text (status_label_text )
271+ if status_label_text :
272+ status_label_cont .remove_flag (lv .obj .FLAG .HIDDEN )
273+ else :
274+ status_label_cont .add_flag (lv .obj .FLAG .HIDDEN )
266275
267276print ("camtest.py: stopping..." )
268277if cam :
0 commit comments