Slow reactions from code

Can anyone tell me why in the below code, when the SWstate transitions to low why it takes 7 seconds for the screen status to change. Is there a more efficient/faster way to write this so the transition is instant? Thanks for your input in advance.

// Date and time functions using a DS1307 RTC connected via I2C and Wire lib

#include <Wire.h>
#include "RTClib.h"
#include "U8glib.h"

const int GarDoorSw = 2;     // the number of Garage door feedback
int SWState = 0;         // variable for reading the Garage Door Switch Status

//**************************************************
// Change this constructor to match your display!!!
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE|U8G_I2C_OPT_DEV_0);  // I2C / TWI 
//**************************************************
#define OLED_I2C_ADDRESS   0x3C
#define OLED_CONTROL_BYTE_CMD_SINGLE  0x80
#define OLED_CONTROL_BYTE_CMD_STREAM  0x00
#define OLED_CONTROL_BYTE_DATA_STREAM 0x40

#define OLED_CMD_DISPLAY_NORMAL         0xA6
#define OLED_CMD_DISPLAY_INVERTED       0xA7

RTC_DS1307 rtc;

long previousMillis = 0;        // will store last time delay was updated

// the follow variables is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long interval = 5000;           // interval at which to change page of the OLED (milliseconds)


void setup () {
  #ifdef AVR
  Wire.begin();
  #else
  Wire1.begin(); // Shield I2C pins connect to alt I2C bus on Arduino Due
  init_OLED();
  reset_display();           // Clear logo and load saved mode
  u8g.setFont(u8g_font_tpss);
  u8g.setColorIndex(1); // Instructs the display to draw with a pixel on. 
  Serial.begin(57600);
  


#endif
  rtc.begin();

  if (! rtc.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
  }
  
  // initialize the pushbutton pin as an input:
  pinMode(GarDoorSw, INPUT);
 

}
void loop () {
  // read the state of the Garage door switch:
  SWState = digitalRead( GarDoorSw);
  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if ( SWState == LOW) {
    DoorSw();}
   else { closed ();}
   DateTime now = rtc.now();
     Serial.print(" since midnight 1/1/1970 = ");
    Serial.print(now.unixtime());
    Serial.print("s = ");
    Serial.print(now.unixtime() / 86400L);
    Serial.println("d");
    
    // calculate a date which is 7 days and 30 seconds into the future
    DateTime future (now.unixtime() + 7 * 86400L + 30);
  }
void closed () {
   
  
    DateTime now = rtc.now();
       u8g.firstPage();  
  do {
    u8g.setFont(u8g_font_tpss);
u8g.setPrintPos( 0, 10);
    u8g.print(now.year(), DEC);
     u8g.print('/');
     u8g.print(now.month(), DEC);
     u8g.print('/');
    u8g.print(now.day(), DEC);
     u8g.print(' ');
     u8g.print(now.hour(), DEC);
     u8g.print(':');
     u8g.print(now.minute(), DEC);
     u8g.print(':');
     u8g.print(now.second(), DEC);
     u8g.println();
     
   u8g.drawStr( 0, 23, "Hello Connor!");   
   u8g.drawStr( 0, 34, "Hello Owen!"); 
   u8g.drawStr( 0, 45, "Hello Vanessa!"); 
   u8g.drawStr( 0, 60, "Garage Closed!"); 

     } while( u8g.nextPage() );
   
  
  }


void  DoorSw() {
 


     u8g.firstPage();  
  do {
   
    u8g.setFont(u8g_font_courB18r);
 u8g.drawStr( 12, 18, "GARAGE");
 u8g.drawStr( 23, 36, "DOOR");
 u8g.drawStr( 8, 56, " OPEN");
 Wire.beginTransmission(OLED_I2C_ADDRESS);
 Wire.write(OLED_CONTROL_BYTE_CMD_STREAM);
  Wire.write(0xA7);
  Wire.endTransmission();
 } while( u8g.nextPage() );
 
delay (1000);

     u8g.firstPage();  
  do {
   
    u8g.setFont(u8g_font_courB18r);
 u8g.drawStr( 12, 18, "GARAGE");
 u8g.drawStr( 23, 36, "DOOR");
 u8g.drawStr( 8, 56, " OPEN");
 Wire.beginTransmission(OLED_I2C_ADDRESS);
 Wire.write(OLED_CONTROL_BYTE_CMD_STREAM);
  Wire.write(0xA6);
  Wire.endTransmission();
 } while( u8g.nextPage() );
 
}

I see a delay(1000) on line 129. That can't help.

The demo several things at a time illustrates how to use millis() to manage timing without blocking.

...R

Thanks I will try your method to increase my code speed.