Thursday, September 9, 2010

LCDShield tilt meter animation

After creating the earthquake detector, I wanted to try an experiment with the dual-axis accelerometer as a tilt detector. The first step was to figure out how the font generator code from Jeff Miller worked. It's a bit funky, with the pixel in the lower right corner of the character being displayed first, followed by the rest of the right-hand column from top to bottom, then the rest of the character from top left to bottom right. Once I got that sussed, I used Excel to draw my little stick figure as 4 8x16 pixel font characters per frame. Then I slapped together a visual basic script to convert the Excel data from CSV format to the C++ format needed by the font tables for the Arduino. Finally, it was a simple matter to write the C++ code to interpret the tilt angle as events to be acted on by the C++ routines.

The animation is a bit sloppy, and the stick figure has a tendency to leave "droppings" behind him. But, the entire point of this experiment was as a proof-of-concept, and I was successful on that count. I may go back and clean the animation up later, when I have more free time. Basically, the challenge is to add a black out frame to remove the stick figure from the screen before advancing him to the next x-y position without causing excessive flicker. Ideally I'd like to move from hacked font data to actual sprites, but that means rewriting the character generator function and I'm not ready to try that yet.

Again, the Japanino is a fun little kit that is almost infinitely customizable if you get the shields from companies like Sparkfun. But, it's less about the skills needed to solder the kits together as it is the programming required to make the basic building block functions you need to drive the kits. Fortunately, these things aren't that expensive, so if you do make a mistake, it's not going to cost you that much.

Or you can go to youtube directly.

As a side note, I added the youtube video for the accelerometer blog entry.

No comments: