From 19ce2997a1fbb3760c0f7e655b612001cc7158c6 Mon Sep 17 00:00:00 2001 From: mikecarper Date: Mon, 31 Aug 2026 17:47:30 -0700 Subject: [PATCH] Fix Indicator QR module rendering --- src/helpers/ui/LGFXDisplay.cpp | 23 ++++++++++------------- test/test_indicator_render_profile.py | 3 +++ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/helpers/ui/LGFXDisplay.cpp b/src/helpers/ui/LGFXDisplay.cpp index d66ef5294..94190b3eb 100644 --- a/src/helpers/ui/LGFXDisplay.cpp +++ b/src/helpers/ui/LGFXDisplay.cpp @@ -384,20 +384,17 @@ bool LGFXDisplay::drawQrCode(const char* text, int x, int y, int size) { scaled_size, scaled_size, light); const int matrix_left = left + quiet_zone * module_size; const int matrix_top = top + quiet_zone * module_size; + // Paint complete modules instead of coalescing horizontal runs. The + // Indicator's indexed sprite path has produced alternating light modules + // inside coalesced dark runs on hardware, which destroys the three finder + // patterns even though the encoded matrix itself is valid. Individual + // module rectangles remain pixel-aligned and touch without gaps. for (uint_fast8_t row = 0; row < qr.size; ++row) { - int run_start = -1; - for (uint_fast16_t column = 0; column <= qr.size; ++column) { - const bool filled = column < qr.size - && lgfx_qrcode_getModule(&qr, column, row); - if (filled && run_start < 0) { - run_start = column; - } else if (!filled && run_start >= 0) { - buffer.fillRect( - matrix_left + run_start * module_size, - matrix_top + row * module_size, - (column - run_start) * module_size, - module_size, dark); - run_start = -1; + for (uint_fast8_t column = 0; column < qr.size; ++column) { + if (lgfx_qrcode_getModule(&qr, column, row)) { + buffer.fillRect(matrix_left + column * module_size, + matrix_top + row * module_size, + module_size, module_size, dark); } } } diff --git a/test/test_indicator_render_profile.py b/test/test_indicator_render_profile.py index 75bfeb915..6bfcb84bd 100644 --- a/test/test_indicator_render_profile.py +++ b/test/test_indicator_render_profile.py @@ -219,11 +219,14 @@ int main() { qr = qr[: qr.index("\nuint16_t LGFXDisplay::getTextWidth")] self.assertIn("lgfx_qrcode_initText", qr) self.assertIn("lgfx_qrcode_getModule", qr) + self.assertIn("ECC_LOW", qr) self.assertIn("static constexpr int quiet_zone = 4;", qr) self.assertIn("renderColor(UIColor::primary_txt)", qr) self.assertIn("renderColor(UIColor::window_bkg)", qr) self.assertIn("const int scaled_size = size * _coordinateScale;", qr) self.assertIn("x > width() - size", qr) + self.assertIn("module_size, module_size, dark", qr) + self.assertNotIn("run_start", qr) self.assertNotIn("buffer.qrcode", qr) self.assertNotIn("TFT_WHITE", qr) self.assertNotIn("TFT_BLACK", qr)