A test program which communicates with a Gameduino shield and writes some text on a VGA display.
Dependencies: Gameduino CommonTypes mbed
Simple test program to show how to use the Gameduino library.
Diff: main.cpp
- Revision:
- 0:5f0f384378b2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Nov 07 21:37:21 2012 +0000 @@ -0,0 +1,37 @@ +#include "mbed.h" +#include "Gameduino.h" + +int main() { + // Make a digital output for use with Gameduino. + DigitalOut cs( p8 ); + // Initialise an SPI link for communications with Gameduino. + // Use pin 5 for MOSI. + // Use pin 6 for MISO. + // Use pin 7 for SCK. + SPI spi( p5, p6, p7 ); + // 8MHz clock should be OK. + spi.frequency( 8000000 ); + // Set SPI format to use. + // Use 8 bits per SPI frame. + // Use SPI mode 0. + spi.format( 8, 0 ); + // Make a Gameduino and pass SPI link and digital output for chip select. + Gameduino gd( &spi, &cs ); + // Reset the Gameduino. + gd.begin(); + // Lets have a default ASCII character set. + gd.ascii(); + // Write something to character memory. + gd.__wstart( Gameduino::RAM_PIC ); + for( UInt8 c = 'A'; c <= 'Z'; ++c ) { + gd.__tr8( c ); + } + gd.__end(); + // Test copy method. + UInt8 copyData[] = "HELLO"; + gd.copy( Gameduino::RAM_PIC + 64, copyData, 5 ); + // Test putstr method. + gd.putstr( 3, 10, "Ambidextrous!" ); + // Finished with Gameduino. + gd.end(); +}