Bare-metal mbed; the Gameduino bouncing ball
(Last modified
6 Jan 2012)
Since I hooked the Gameduino (GD) to the mbed and did some text (check here), it only makes
sense that I do some graphics, too. The simplest graphics to add
is James Bowman's animated bouncing ball demo, so that's what I
did. Here is a short video of my version of the bouncing
ball. It starts with a second or so of text (from the original
gd_test program), then shows the ball bouncing around (.mov file,
right-click and view with QuickTime or VLC):
In order to add in James' demo code, I needed to add the
GD_uncompress routine to my gdsupport library. The porting from
the original C++ to the ANSI C that I prefer to use was
straightforward. The resulting mbed executable weighs in at 17.5
KB and runs the animation at 72 frames per second on a 96 MHz
mbed. According to James, the limiting factor for frame rate in
this demo is usually the SPI bus speed. The code running the
animation you see here is using an SPI clock of 4 MHz. SPI clock
rates of 1 MHz and 8 MHz (the maximum the GD can accept) both showed 72
frames/sec frame rate, as well.
You can download the source for my gd_test program, as well as a
ready-to-load executable file, from this
zip archive.
Note that you will not be able to rebuild from my sources until I get
around to putting my full GD library on the site. But you can
look through the source for the test file to see how to hook into the
GD and make things happen.
The only changes I made to James' original bouncing ball source were to
replace all of his C++ class invocations with my corresponding C
function calls and replace his use of 'byte' with 'char' or 'signed
char', as appropriate. Note that I did have to modify his ball.h
file, as the file's draw_ball() function used incomplete argument lists
when invoking his xsprite method; I've included my updated ball.h for
your review.
Next up, StarCraft 2 on the mbed! (OK, maybe not...)
Home