DEV Community

Cover image for Let's develop a QR Code Generator, part IV: placing bits

Let's develop a QR Code Generator, part IV: placing bits

Massimo Artizzu on July 19, 2021

Ok, now we've finally got our error correction data, and it's time to place all those codewords into the matrix! So, we know there are parts of th...
Collapse
 
jarrodcolburn profile image
jarrodcolburn • Edited

Great tutorial. I'm trying to follow along... but I got to

function getRawQRCode(message) {
  // One day, we'll compute these values. But not today!
  const VERSION = 2;
  const TOTAL_CODEWORDS = 44;
  const LENGTH_BITS = 8;
  const DATA_CODEWORDS = 28;

  const codewords = new Uint8Array(TOTAL_CODEWORDS);
  codewords.set(getByteData(message, LENGTH_BITS, DATA_CODEWORDS), 0);
  codewords.set(getEDC(byteData, TOTAL_CODEWORDS), DATA_CODEWORDS);
//                        ^ where does this byteData come from?
Enter fullscreen mode Exit fullscreen mode

Where does this 'byteData' come from in the last line of code snippet?

I'm not seeing it anywhere else

Collapse
 
maxart2501 profile image
Massimo Artizzu

Good catch, you're right! It should be the result of calling getByteData in the previous line, that I've forgot to store in a variable for some reason.

I'll fix it later.

Collapse
 
jarrodcolburn profile image
jarrodcolburn

Thanks for this impressive tutorial. Your description and visuals are just amazing. I don't know how you had the discipline to pump out a 10 part series, but I'm glad you did... I'm a big fan of QR codes.

I was trying to follow along... is the code in a public repo?

Thread Thread
 
maxart2501 profile image
Massimo Artizzu • Edited

I had the intention to create a public repo, but to be honest I run out of steam right after this endeavour 😅 So what you're seeing in this series that's basically the public repo, sorry!

And actually this 10-part series was also meant to be longer, as there are parts that are still not covered, as I've mentioned at the end of part 10.

Maybe one day... 🤞 In the meanwhile, thank you for the kind words!

Collapse
 
hanscath profile image
Hans Cathcart

Awesome tutorial! In the part where you sum everything up, did you mean to say:

  1. start from the bottom left corner;

or

  1. start from the bottom right corner;

I suspect you meant starboard not port. :-)

  • - Feel free to remove this comment if I'm wrong, or after the correction.
Collapse
 
maxart2501 profile image
Massimo Artizzu

Thanks for the compliments and... You're totally correct. 👍 I've edited the post.