Close

Simplicity Pays Off

A project log for Nyan Cat Badge Demo (2018 Supercon)

An adaptation of YouTube star Nyan Cat for the 2018 Hackaday Superconference Badge

rogerRoger 11/09/2018 at 20:080 Comments

I’m adapting the Nyan Cat animation to the Hackaday Belgrade 2018 badge (close predecessor to the Hackaday Superconference 2018 badge) and I chose to simplify the animated GIF data to a simple run-length encoding. RLE doesn’t compress as much as GIF, but it makes the decode algorithm simple. A simple algorithm takes up little program memory on the PIC32, and more importantly, it takes up less of my time coding and debugging. The latter is quite important when I’m trying to do something within the timeframe of a single weekend, as most Supercon badge hackers do.

The simplicity paid off when I wrote the code – just a few lines and only a few variables – and ran it on my Belgrade badge. The first test only decoded part of the first frame. I was actually quite surprised when the face of a cartoon cat looked back at me from the badge LCD! It is rare when a chunk of code works immediately on the first try.

After the first partial frame was proven to work, I extended the for() loop to the entire image, then I wrote an infinite loop to cycle through all 12 frames of the animation. I made the design decision for code simplicity and it paid off tremendously. Drastically reducing the time spent on implementation and (quite unexpectedly) completely eliminated the time spent on debugging.

If I had tried to port a GIF decode library I’m certain I would have needed to spend more time getting the code to compile and run on the badge, and it would not have been fun to debug if anything should go wrong.

This project’s progress is publicly visible on Github.

(Cross-posted to NewScrewdriver.com)

Discussions