Enable interrupt code

Hello all i stumbled upon an interesting watch face code as follows. Please can someone show me how to increase screen on duration?

Thanks

// EnableInterrupt Simple example sketch. Demonstrates operation on a single pin of your choice.
// See https://github.com/GreyGnome/EnableInterrupt and the README.md for more information.
#include <EnableInterrupt.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <avr/sleep.h>
#include "RTClib.h"

// Uncomment this block to use hardware SPI
#define OLED_DC     A3
#define OLED_CS     A5
#define OLED_RESET  A4

#define BUTTON1 8
#define R1 10000
#define R2 10000
#define VOLTAGEDIV 0.5
#define BATTERYENERGY 4
#define BATTERYINPUT A11

Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS);
RTC_DS3231 rtc;
int interruptCount=0;
int count=0;

void interruptFunction() {
  interruptCount++;
  display.ssd1306_command(SSD1306_DISPLAYON);
}


void setup() {
  rtc.begin();
  rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));

  display.begin(SSD1306_SWITCHCAPVCC);

  pinMode(BUTTON1, INPUT_PULLUP);  
}

// In the loop we just display interruptCount. The value is updated by the interrupt routine.
void loop() {
  digitalWrite(BATTERYENERGY, HIGH);
  delay(50);
  float voltage = analogRead(BATTERYINPUT);
  voltage = (voltage / 1024) * 3.35;
  voltage = voltage / VOLTAGEDIV;
  delay(50);
  digitalWrite(BATTERYENERGY, LOW);
  int percent = (voltage - 3.38) / 0.0084;

  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(WHITE);
  
  display.setCursor(0, 0);
  DateTime now = rtc.now();
  display.print(now.hour());
  display.print(":");
  display.print(now.minute());
  display.setCursor(0, 20);
  display.print("Bat:");
  display.print(percent);
  display.print("%"); 

   if (UDADDR & _BV(ADDEN)){  // check if USB is connected.
        display.setCursor(0, 40);
        display.print("Charging"); 
       if (count >= 100) {
          count = 0;
          display.ssd1306_command(SSD1306_DISPLAYOFF);
      }
      if (digitalRead(BUTTON1) == 0) {
          display.ssd1306_command(SSD1306_DISPLAYON);
      }
   }else{ 
    if (count >= 20) {
      delay(500);     // this delay is needed, the sleep
      count = 0;
      sleepNow();     // sleep function called here
    }
  }
  count++;
  count = count % 1000;
 
  display.display();  
}


void sleepNow()         // here we put the arduino to sleep
{
    display.ssd1306_command(SSD1306_DISPLAYOFF);
    /* Now is the time to set the sleep mode. In the Atmega8 datasheet
     * http://www.atmel.com/dyn/resources/prod_documents/doc2486.pdf on page 35
     * there is a list of sleep modes which explains which clocks and
     * wake up sources are available in which sleep mode.
     *
     * In the avr/sleep.h file, the call names of these sleep modes are to be found:
     *
     * The 5 different modes are:
     *     SLEEP_MODE_IDLE         -the least power savings
     *     SLEEP_MODE_ADC
     *     SLEEP_MODE_PWR_SAVE
     *     SLEEP_MODE_STANDBY
     *     SLEEP_MODE_PWR_DOWN     -the most power savings
     *
     * For now, we want as much power savings as possible, so we
     * choose the according
     * sleep mode: SLEEP_MODE_PWR_DOWN
     *
     */  
    set_sleep_mode(SLEEP_MODE_STANDBY);   // sleep mode is set here
 
    sleep_enable();          // enables the sleep bit in the mcucr register
                             // so sleep is possible. just a safety pin
 
    /* Now it is time to enable an interrupt. We do it here so an
     * accidentally pushed interrupt button doesn't interrupt
     * our running program. if you want to be able to run
     * interrupt code besides the sleep function, place it in
     * setup() for example.
     *
     * In the function call attachInterrupt(A, B, C)
     * A   can be either 0 or 1 for interrupts on pin 2 or 3.  
     *
     * B   Name of a function you want to execute at interrupt for A.
     *
     * C   Trigger mode of the interrupt pin. can be:
     *             LOW        a low level triggers
     *             CHANGE     a change in level triggers
     *             RISING     a rising edge of a level triggers
     *             FALLING    a falling edge of a level triggers
     *
     * In all but the IDLE sleep modes only LOW can be used.
     */
   enableInterrupt(BUTTON1, interruptFunction, CHANGE);
 
    sleep_mode();            // here the device is actually put to sleep!!
                             // THE PROGRAM CONTINUES FROM HERE AFTER WAKING UP
 
    sleep_disable();         // first thing after waking from sleep:
                             // disable sleep...
    disableInterrupt(BUTTON1);      // disables interrupt 0 on pin 2 so the
                             // wakeUpNow code will not be executed
                             // during normal running time.
}

Hello Kadir,

There are two sections, where the display is turned off.

1st one is here:

We don’t put watchX into deep sleep when it is connected to the USB because it corrupts the USB communication between PC. That is why we only turn off the display here and not putting the watchX into deep sleep. If you change here the number “100” you increase the time display stays on when it is connected to the USB.

The second part where you put the watchX into sleep, in this case deep sleep when it is not connected to the USB is here:

If you increase the number 20 here

Then you increase the time that watchX stays on.

Let me know if you need more information.

All my bests, Mustafa.