2026-03-04 1:21 AM
I'm using an STM32G0 with a 240 x 160 monochrome 1bpp SPI display. Is it possible to use the QR code component from the TouchGFX library?
I'm using TouchGFX version 4.26.0.
Many thanks!
Solved! Go to Solution.
2026-03-16 7:01 AM
Hello @EmanueleC.
1bpp support is not implemented in the QR code widget currently bundled with TouchGFX. However, the widgets are open source, so you can add it yourself. You can find QRCode.cpp here: Middlewares\ST\touchgfx\framework\source\touchgfx\widgets
I recommend copying this file to gui\src\common and modifying the copy. The project will automatically use your version instead of the default one.
You’ll need to implement a draw function for 1bpp and then extend the switch statement in the draw function to call this 1bpp-specific function when the bit depth is 1:
void QRCode::draw(const Rect& invalidatedArea) const
{
...
// Select correct drawing function for framebuffer format and alpha
switch (bpp)
{
case 1:
// Your 1bpp implementation goes here
break;
case 16:
// RGB565
drawfunc = (alpha < 255) ? &QRCode::drawBitRGB565Blend : &QRCode::drawBitRGB565;
break;
case 24:
// RGB888
drawfunc = (alpha < 255) ? &QRCode::drawBitRGB888Blend : &QRCode::drawBitRGB888;
break;
case 32:
// ARGB8888
drawfunc = (alpha < 255) ? &QRCode::drawBitARGB8888Blend : &QRCode::drawBitARGB8888;
break;
default:
return;
}
...
}Best regards,
Johan
2026-03-16 7:01 AM
Hello @EmanueleC.
1bpp support is not implemented in the QR code widget currently bundled with TouchGFX. However, the widgets are open source, so you can add it yourself. You can find QRCode.cpp here: Middlewares\ST\touchgfx\framework\source\touchgfx\widgets
I recommend copying this file to gui\src\common and modifying the copy. The project will automatically use your version instead of the default one.
You’ll need to implement a draw function for 1bpp and then extend the switch statement in the draw function to call this 1bpp-specific function when the bit depth is 1:
void QRCode::draw(const Rect& invalidatedArea) const
{
...
// Select correct drawing function for framebuffer format and alpha
switch (bpp)
{
case 1:
// Your 1bpp implementation goes here
break;
case 16:
// RGB565
drawfunc = (alpha < 255) ? &QRCode::drawBitRGB565Blend : &QRCode::drawBitRGB565;
break;
case 24:
// RGB888
drawfunc = (alpha < 255) ? &QRCode::drawBitRGB888Blend : &QRCode::drawBitRGB888;
break;
case 32:
// ARGB8888
drawfunc = (alpha < 255) ? &QRCode::drawBitARGB8888Blend : &QRCode::drawBitARGB8888;
break;
default:
return;
}
...
}Best regards,
Johan