Cart 0

Open Source Optimisation with the Arduino Enigma QR Clock

Gareth Halfacree

Arduino Enigma QR Code clock

The beauty of releasing code under permissive, open-source licences is that others are free to improve and build upon what you've created. We're always thrilled to see software and hardware we've designed pop up in unusual places, and doubly so if it enhances on our original creation. We're not alone, of course, as exemplified by the Arduino Enigma project.

The project on which the Arduino Enigma is based was released back in 2012. Designed as an awkwardly-unreadable clock - the time-telling equivalent of a useless machine, in effect - the original design generated a Quick Response Code (QR Code) for every minute of the day, generating each in turn algorithmically - the ATmega328 microcontroller powering the Arduino Uno having too little storage to simply hold pre-generated bitmap images for display.

The trouble with the original project can be traced to the performance of the code: generating a new QR Code and rendering it on the display takes several seconds, meaning the clock could only change once every minute. Desiring a higher resolution, the Arduino Enigma team set about optimising the original code - available thanks to the open-source ethos adopted by the original project.

The optimisation started with the removal of the code's search for the optimal QR mask, instead using a pre-calculated fixed mask. This alone was enough to drop the generation time from six seconds to under one, achieving the original goal of a QR Code clock updating every second - but actually displaying the image on the liquid-crystal display (LCD) took longer. Adding a new high-speed display library and holding the last generated image as a bitmap so that only modified elements are drawn dropped the drawing time to match the generation time, allowing the clock to display seconds for the first time.

Next time you're creating a project, think about the benefits of releasing it under permissive licences - and you too may find that someone takes your idea and runs with it!

A QR generation library was ported to the Arduino UNO and Seeed LCD touchscreen platform. Originally the generation time was 6 seconds, making the display of seconds impossible. As @ch00ftech suggested, eliminating the search for the optimal QR mask and instead applying a fixed mask, drops the generation time to less than one second.


Older Post Newer Post