More complicated test program that generates text, coloured sprites and sound.
Dependencies: Gameduino mbed CommonTypes
Diff: GameduinoTest.cpp
- Revision:
- 2:5604e16b78bd
- Parent:
- 1:c8ec5f958f3c
--- a/GameduinoTest.cpp Sat May 05 17:18:35 2012 +0000 +++ b/GameduinoTest.cpp Sun May 06 10:37:27 2012 +0000 @@ -42,6 +42,22 @@ } } +/*********************/ +/* TEST PLOTS METHOD */ +/*********************/ +// Pass pointer to Gameduino to use in gd. +void GameduinoTest::TestPlots( Gameduino *gd ) { + #define PLOTLEN 3 + Gameduino::sprplot records[ PLOTLEN ] = { + { 0, 0, 26, 0 }, + { 16, 1, 27, 0 }, + { 32, 2, 28, 0 }, + }; + gd->__wstartspr( 110 ); + gd->plots( 170, 0, records, PLOTLEN ); + gd->__end(); +} + /****************/ /* RUN THE TEST */ /****************/ @@ -57,8 +73,8 @@ // Use pin 6 for MISO. // Use pin 7 for SCK. SPI spi( p5, p6, p7 ); - // 4MHz clock should be OK since this is default on an Arduino. - spi.frequency( 4000000 ); + // 8MHz clock should be OK. + spi.frequency( 8000000 ); // Set SPI format to use. // Use 8 bits per SPI frame. // Use SPI mode 0. @@ -98,8 +114,28 @@ } y += 18; } + // Test out sprite2x2 method. + gd.sprite2x2( 90, 150, 16, 38, 0, Gameduino::None, 0 ); + // Test out __wstartspr method. + gd.__wstartspr( 95 ); + y = 32; + for( UInt8 imageNum = 15; imageNum < 19; ++imageNum ) { + gd.TransferSprite( 150, y, imageNum, 0 ); + y += 16; + } + gd.__end(); + // Test out plots method. + TestPlots( &gd ); // Do some sprite animation. AnimationTest( &gd ); + // Make a noise. + gd.voice( 25, Gameduino::SineWave, 8000, 127, 127 ); + wait_ms( 1000 ); + gd.voice( 25, Gameduino::SineWave, 0, 0, 0 ); + // Make another noise. + gd.voice( 25, Gameduino::WhiteNoise, 8000, 127, 127 ); + wait_ms( 1000 ); + gd.voice( 25, Gameduino::WhiteNoise, 0, 0, 0 ); // Finished with Gameduino. gd.end(); }