Author Topic: QR code generate in microcontroller  (Read 5709 times)

0 Members and 1 Guest are viewing this topic.

Offline Vindhyachal.taknikiTopic starter

  • Frequent Contributor
  • **
  • Posts: 487
QR code generate in microcontroller
« on: December 07, 2016, 08:21:07 am »
1. I have to generate QR code, have string of 100 bytes which needs to be fit in.
Controller I am using is Atmega2560 arduino.
generated code is to be shown on TFT & to be print on thermal printer also.

2. There are few libs on it in C/C++, but all use malloc functions. Is there any simple to use library for this? Any one has worked on it before?
 

Offline hamster_nz

  • Super Contributor
  • ***
  • Posts: 2803
  • Country: nz
Re: QR code generate in microcontroller
« Reply #1 on: December 07, 2016, 08:42:12 am »
I've used another 2D bar code, PFD417 ( https://en.wikipedia.org/wiki/PDF417 ) on an STM32 controller to display on an LCD. It worked well, and I feel is better suited to lower quality printers than QR codes.

On a PC I started with https://sourceforge.net/projects/pdf417lib/, and then manually replaced all the unchanging variables (width, height, barcode parameters like ECC) with constants, and rather than generating objects (aka malloc()ing a a structure, populating it, and then returning it's address to the caller) I had just one structure statically allocated. Along the way I generated BMP files and tested reading it with a free PDF417 reader app (https://play.google.com/store/apps/details?id=mobi.pdf417&hl=en) on my phone to make sure I hadn't broken it.

Once that was all done and debugged on the PC, then moved it to the STM32 and LCD with zero problems or embedded debugging required.
Gaze not into the abyss, lest you become recognized as an abyss domain expert, and they expect you keep gazing into the damn thing.
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: QR code generate in microcontroller
« Reply #2 on: December 07, 2016, 09:11:23 am »
The mostly use malloc because the input is variable length.
You can probably implement malloc, and make it just return one fixed memory block.

Have you searched github yet? I did find some C libs in a quick search. Maybe it's something.
https://github.com/fukuchi/libqrencode
https://github.com/tz1/qrduino
https://github.com/embedded-systems/qr
« Last Edit: December 07, 2016, 09:14:55 am by Jeroen3 »
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8275
Re: QR code generate in microcontroller
« Reply #3 on: December 07, 2016, 12:07:48 pm »
Figure out the size of QR code that you'll need, then replace all malloc()s with the appropriate constant-size array.

(A lot of code out there needlessly uses malloc() in general, even for constant sizes.)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf