More complicated test program that generates text, coloured sprites and sound.

Dependencies:   Gameduino mbed CommonTypes

GameduinoTest.cpp

Committer:
RichardE
Date:
2012-05-05
Revision:
0:13f69384ff8a
Child:
1:c8ec5f958f3c

File content as of revision 0:13f69384ff8a:

/*
 * SOURCE FILE : GameduinoTest.cpp
 *
 * Definition of class GameduinoTest.
 * Tests a Gameduino object.
 *
 */

#include "GameduinoTest.h"      // this module's prototypes
#include "mbed.h"               // mbed library
#include "Gameduino.h"          // for Gameduino class

/***************/
/* CONSTRUCTOR */
/***************/
GameduinoTest::GameduinoTest() {
}

/**************/
/* DESTRUCTOR */
/**************/
GameduinoTest::~GameduinoTest() {
}

/****************/
/* RUN THE TEST */
/****************/
void GameduinoTest::Run( void ) {
    // Make a serial port for communicating with PC.
    Serial pc( USBTX, USBRX );
    // Sign on message.
    pc.printf( "Up and running!\r\n" );
    // 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 );
    // 4MHz clock should be OK since this is default on an Arduino.
    spi.frequency( 4000000 );
    // 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();
    // Read from ident register.
    UInt8 id = gd.rd( Gameduino::IDENT );
    // Report back to PC.
    pc.printf( "Gameduino ID is 0x%02X.\r\n", (int)id );
    // Write something to character memory.
    gd.__wstart( Gameduino::RAM_PIC );
    for( UInt8 c = 'A'; c <= 'Z'; ++c ) {
        gd.__tr8( c );
    }
    gd.__end();
}