Gameduino/Workshop 1
From Hackerspace Brussels
We printed alphabetic characters on the background after initializing the ascii table (GD.ascii() call), and modified the H character to be printed with colors.
#include <SPI.h>
#include <GD.h>
void setup()
{
GD.begin();
GD.ascii(); // Initialize ASCII table
// Colors are stored in a table at address 0x2000
// The structure is: 4 2-byte colors per character. Therefore, each character's color table is 8 bytes
// By default, characters' background is color 0, and characters' foreground is color 3
GD.wr16(0x2000+'H'*8, RGB(0,255,0)); // Color 0 for H is green (background)
GD.wr16(0x2000+'H'*8+2, RGB(255,128,0)); // Color 1 for H is orange
GD.wr16(0x2000+'H'*8+4, RGB(0,128,255)); // Color 2 for H is light blue
GD.wr16(0x2000+'H'*8+6, RGB(255,0,0)); // Color 3 for H is red (foreground)
// Character's descriptions are stored in a table at address 0x1000
// Each character's description is a 8x8 matrix of 2-bit indexed colors. Therefore, each character description is 16 bytes
// Each character's line is 2 bytes
GD.wr16(0x1000+'H'*16+2, 0xFFFF); // Second line (line 1) is [11 11 11 11 11 11 11 11], so full of color 3, so red
GD.wr16(0x1000+'H'*16+4, 0x5555); // Third line (line 2) is [01 01 01 01 01 01 01 01], so full of color 1, so orange
GD.wr16(0x1000+'H'*16+6, 0xaaaa); // Fourth line (line 3) is [10 10 10 10 10 10 10 10], so full of color 2, so blue
// And finally we write the alpha characters
GD.putstr(0, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
GD.putstr(1, 1, "abcdefghijklmnopqrstuvwxyz"); // Note that the coordinates are in characters and not in pixels
}
void loop()
{
}