From 6b8b72a7a0f85fbcd59e14f783e478d66e13290d Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Fri, 28 Nov 2025 17:55:02 +0100 Subject: [PATCH] quirc_decode: back to memcpy for stability --- c_mpos/src/quirc_decode.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/c_mpos/src/quirc_decode.c b/c_mpos/src/quirc_decode.c index 54337601..32eee102 100644 --- a/c_mpos/src/quirc_decode.c +++ b/c_mpos/src/quirc_decode.c @@ -56,12 +56,15 @@ static mp_obj_t qrdecode(mp_uint_t n_args, const mp_obj_t *args) { //QRDECODE_DEBUG_PRINT("qrdecode: Resized quirc object\n"); uint8_t *image = quirc_begin(qr, NULL, NULL); - //memcpy(image, bufinfo.buf, width * height); - uint8_t *temp_image = image; - //image = bufinfo.buf; // use existing buffer, rather than memcpy - but this doesnt find any images anymore :-/ - qr->image = bufinfo.buf; // if this works then we can also eliminate quirc's ps_alloc() + memcpy(image, bufinfo.buf, width * height); + // would be nice to be able to use the existing buffer (bufinfo.buf) here, avoiding memcpy, + // but that buffer is also being filled by image capture and displayed by lvgl + // and that becomes unstable... it shows black artifacts and crashes sometimes... + //uint8_t *temp_image = image; + //image = bufinfo.buf; + //qr->image = bufinfo.buf; // if this works then we can also eliminate quirc's ps_alloc() quirc_end(qr); - qr->image = temp_image; // restore, because quirc will try to free it + //qr->image = temp_image; // restore, because quirc will try to free it /* // Pointer swap - NO memcpy, NO internal.h needed