diff --git a/c_mpos/src/quirc_decode.c b/c_mpos/src/quirc_decode.c index 36716d7a..9f60392a 100644 --- a/c_mpos/src/quirc_decode.c +++ b/c_mpos/src/quirc_decode.c @@ -121,7 +121,7 @@ static mp_obj_t qrdecode(mp_uint_t n_args, const mp_obj_t *args) { // Convert decoded data to Python string QRDECODE_DEBUG_PRINT("qrdecode: Creating Python string\n"); - mp_obj_t result = mp_obj_new_str((const char *)data->payload, data->payload_len); + mp_obj_t result = mp_obj_new_bytes((const uint8_t *)data->payload, data->payload_len); QRDECODE_DEBUG_PRINT("qrdecode: Python string created\n"); // Clean up diff --git a/internal_filesystem/apps/com.example.camtest/assets/camtest.py b/internal_filesystem/apps/com.example.camtest/assets/camtest.py index dd6c6588..8614b8b5 100644 --- a/internal_filesystem/apps/com.example.camtest/assets/camtest.py +++ b/internal_filesystem/apps/com.example.camtest/assets/camtest.py @@ -1,3 +1,5 @@ +import time + appscreen = lv.screen_active() keepgoing = True @@ -105,7 +107,7 @@ close_label.set_text(lv.SYMBOL.CLOSE) close_label.center() def close_button_click(e): global keepgoing - print("Closing camera!") + print("Close button clicked") keepgoing = False close_button.add_event_cb(close_button_click,lv.EVENT.CLICKED,None) @@ -113,23 +115,26 @@ close_button.add_event_cb(close_button_click,lv.EVENT.CLICKED,None) from camera import Camera, GrabMode, PixelFormat, FrameSize, GainCeiling -cam = Camera( - data_pins=[12,13,15,11,14,10,7,2], - vsync_pin=6, - href_pin=4, - sda_pin=21, - scl_pin=16, - pclk_pin=9, - xclk_pin=8, - xclk_freq=20000000, - powerdown_pin=-1, - reset_pin=-1, - #pixel_format=PixelFormat.RGB565, - pixel_format=PixelFormat.GRAYSCALE, - frame_size=FrameSize.R240X240, - grab_mode=GrabMode.LATEST -) -#cam.init() automatically done when creating the Camera() +try: + cam = Camera( + data_pins=[12,13,15,11,14,10,7,2], + vsync_pin=6, + href_pin=4, + sda_pin=21, + scl_pin=16, + pclk_pin=9, + xclk_pin=8, + xclk_freq=20000000, + powerdown_pin=-1, + reset_pin=-1, + #pixel_format=PixelFormat.RGB565, + pixel_format=PixelFormat.GRAYSCALE, + frame_size=FrameSize.R240X240, + grab_mode=GrabMode.LATEST + ) + #cam.init() automatically done when creating the Camera() +except Exception as e: + print(f"Exception while initializing camera: {e}") #cam.reconfigure(frame_size=FrameSize.HVGA) #frame_size=FrameSize.HVGA, # 480x320 @@ -186,8 +191,7 @@ def try_capture(): try_capture() -import time -while appscreen == lv.screen_active() and keepgoing: +while appscreen == lv.screen_active() and keepgoing is True: try_capture() time.sleep_ms(100) # Allow for the MicroPython REPL to still work. Reducing it doesn't seem to affect the on-display FPS.