Valentines Day Card 2010
16 Feb 2010
The circuit board is bolted to an acrylic backplate. The card and a black piece of craft foam are sandwiched in place. This will hopefully prevent the circuit board from tearing through the card.
The software has about 25 different messages, and it steps through them each time the button is pressed. Then it puts itself into power down mode until the next button press. Updating the matrix is handled by an interrupt routine that reads from a circular buffer. There's also a putchar routine that feeds into the buffer, so I can use it with I/O streams. This lets me use printf to write to the matrix.
And the font: The only 8-bit font with a heart character I know of is the Commodore 64 system font. I created ROM dumps from a C-64 quite some time ago, including the character generator. The C-64 was a strange machine by modern standards. Not only did the internal character representation differ from ASCII -- the Commodore version was called PETSCII -- but the font in the character generation and the stored screen state both used yet another representation known as screen code. I've modified the font into something more like ASCII, with the heart character as 0x7f. Please don't hurt me, Commodore!
The final code, with the font in program memory, comes to 4004 bytes, just fitting inside the 4096 bytes available. The font takes up 768 bytes of flash, and the avr-libc printf implementation takes up another 1.5k or so.
There are more pictures in this flickr gallery.
The code is posted on GitHub.
Lessons Learned
- AVR microcontrollers have some mad power management capabilities. While running, this card consumes around 20 millamps. While sleeping, it consumes ~1 microamp.
- When wiring up an LED matrix, think about which end should be the most significant bit. I wired up this project to be little-endian (MSB at the right), while the font I used was big-endian (MSB at the left). This was easy enough to fix in software.
- Additionally, I'm reaching the point where point-to-point prototyping may no longer be feasible. I guess I have to break down and learn some real circuit layout software.
- I should probably plan ahead more -- It'll be tough to top this next year.


