Hi, it's all in the title!
How do you proceed if for instance you want to display a message or image on the screen for 1 second? I tried with frameCount without success :/
Thanks!
// 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);
}
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."));
}
}
}
Return to Programming Questions
Users browsing this forum: No registered users and 6 guests