Using qrcode with display BW 1bpp
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!
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!
Hello
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
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.