Tue Dec 30, 2014 5:02 pm
Tue Dec 30, 2014 8:59 pm
// wait for A button to be pressed
if (gb.buttons.pressed(BTN_A))
{
// draw image and wait, I'm using println here but drawBitmap will work just as well.
gb.display.clear();
gb.display.println(F("This shows\nfor 1 second"));
gb.display.update();
delay(1000);
}
Wed Dec 31, 2014 1:44 pm
void show_a_message()
{
bool exit = false;
byte timer = 0;
// loop while we want to show the message
while (!exit)
{
if (gb.update())
{
// increment counter every frame (therefore: inside "if (gb.update())" )
timer++;
// if message is displayed for 20 frames: exit loop
// how long a frame takes depends on the frame rate
if (timer > 20)
{
timer = 0; // unnecessary in this example, but maybe useful in others
exit = true; // in this example a simple "break;" would do it as well
}
// display message
gb.display.print(F("A message."));
}
}
}