U8G Help - Cycle Screen on Button Press

Hello, I'm an amateur and have what may be a simple question.

I currently have my code running and cycling different information screens on a small OLED screen using the U8g library. I would like to be able to advance the screens manually with a button. Currently there is a delay then it advances. I would like for it to hold on a screen until I press a button.

How I came about this code was the graphics test example in the U8g library where it cycles through different graphics tests.

Here's the current portion of code I'm concerned about.

Thanks in advance.

void loop(void) {
  
  // picture loop
  u8g.firstPage();
  do {
    logo();
  } while ( u8g.nextPage() );
  delay(5000);

  u8g.firstPage();
  do {
    readout();
  } while ( u8g.nextPage() );
  delay(5000);

  u8g.firstPage();
  do {
    temp1();
  } while ( u8g.nextPage() );
  // rebuild the picture after some delay
  delay(5000);
  u8g.firstPage();
  do {
    humi();
  } while ( u8g.nextPage() );
  delay(5000);
  u8g.firstPage();
  do {
    index();
  } while ( u8g.nextPage() );
  delay(5000);

  u8g.firstPage();
  do {
    driver();
  } while ( u8g.nextPage() );
  delay(5000);

  u8g.firstPage();
  do {
    passenger();
  } while ( u8g.nextPage() );
  delay(5000);

  u8g.firstPage();
  do {
    acvent();
  } while (u8g.nextPage() );
  delay(5000);


}>

You need to redesign your code to get rid of all delays

Mark

I can remove the delays no problem. Then the code flies through the screens without pausing. What I'm trying to figure out is how to display the first screen then advance to the second screen with a button press.

How would I need to modify the "do" and "while" functions (which from what I can tell are required by U8g) to react with a High/Low button input?

chadpoland:
I can remove the delays no problem. Then the code flies through the screens without pausing. What I'm trying to figure out is how to display the first screen then advance to the second screen with a button press.

How would I need to modify the "do" and "while" functions (which from what I can tell are required by U8g) to react with a High/Low button input?

Did you read the Pushbutotn Tutorial ?
Push Button Tutorial
.

Get rid of the do/while loops and use switch/case