Showing results for 
Search instead for 
Did you mean: 

Qrcode is not interpretable

Senior II

Hi everybody,

I'm trying to implement into a custom board, the dynamic Qrcode generation algorithm.

I'm using touchgfx 4.23.0, an SPI display with partial buffer strategy.

I would like to draw the string "" . Display seem to draw it correctly but when I'm try to read it using my phone, this one is not readle. it seems not valid..

I'm using the following initialization sequence:




void Screen_QrCodeView::setupScreen()

QR *code;

sprintf( string, "");
code = new QR( string );




display screendisplay screenQrcode detailQrcode detail

I don't understand the reason. If I change the size of QrCode using qrCode.setScale the result is the same.

Is it possibile to change the resoltuion of the QrCode? Is the QrCode resolution too poor respect the modern APP algorithm?

Does someone ahs the same issue? Please, Can someone try to draw the string and share the picture for a comparison, ?

What can I check in the project?


Thanks to all



Sorry, you missed my point: can you successfully display other things as QR codes ?

  • Other URLs as QR codes ?
  • Text other than URLs as QR codes ?


  • Have you checked your definition of string in your original code ?
  • Have you tried specifying the string as a literal directly in the constructor ?
Senior II



After updating Code with others sources files, finally Now it works correctly: I can rappresent anykind of text.

Remain to understand why is so dirty. Should the parial frame buffer system be the cause?


@MPast.1 wrote:

Should the parial frame buffer system be the cause?


I think it is possible, are you rendering it directly to the framebuffer like in this example:

What if you set scale to 1, can you still see 'dirty' pixels ?




The problem is always present when setScale is set more than 2.

It seems that algorithm forgot to draw and compiles wrong pixels.. very strange..

Another observation = I use 3 "large" buffer for draw screens..

Touchgfx config.png

If I don't wrong in 115200 bytes Touchgfx could draw 120 full rows . (my calcualtions= 115200 / (320 columns * 3 bytes (RGB)) = 120 rows). I know that partial buffer mode doesn't draw screens like single buffer, but I think that my buffer size can be enought fro draw a small square (100 x 100 pixel) on the screen.


At this point I need to check what happens inside the QrCode algorithms




I'm not very familiar with partial buffer strategy, but int this document

uses much smaller (4 lines) buffers. Maybe try to lower block size to 4 or 8 lines for example.

Inteference seems to repeat mostly with in 20 lines interval.


I'm trying with these settings and setScale(6):

Screenshot 2024-02-25 220923.png

  but the same problems appears:


The strange things is witch errors are present only on the left size of the code.

Tomorrow I will check the code.


Interesting, with smaller buffer there is more inteference.


If look closely, it seems that it is allways drawing same part of old data and then starts new (3 buffers). So its certainly partial buffer problem. Looks like SPI transfer starts allready and then in some point the correct data starts when framebuffer update routine gets there.

Here is some good conversation about writing directly to framebuffer in partial mode.

I just wonder would framebuffer locking work better, if you set set only one partial block instead of three.

One way to solve problem permanently would be use dynamic bitmaps, I would consider that also.



ST Employee

Hello @MPast.1 


Please find attached a custom container of a QrCode generator that I have made.
Note that the QrCode uses the Nayuki library in C++ (quite big) with MIT license.


We are working on making a QrCode using the C version of the library in the near future.


From your last post, it seem like your board works fine with no tearing. Somehow the tearing only happens with the QrCode which is unfortunate but indicates that it could be an issue with the QrCode generation rather than tearing.
Does the tearing happens with scaling of 1?


To make the QrCode works even with the tearing you could try to increase the correction level (from what I know there is 4 levels of correction [this is different from the version number, the version number defines the number of dots]).


Finally, 2 QrCode displaying the same data could look different just because their version is not the same.
Here is mine running on TouchGFX simulator with quartile (3rd highest) level of correction (also works on board):



Gaetan Godart
Software engineer at ST (TouchGFX)

hi @GaetanGodart ,

sorry for my late response but I want to confirm you taht your solution works perfectly.

I try different sizes and everything is drawn correctly without any wrong pixel.


Thank you very much