Atmega32u4 Sleep Mode Problem

Hello everyone,

I upload a watch code on my leonardo, but also i have some problems.

Due to the power saving problems, i wrote a code with interrupts

if((getLastTime()) > (10)){
        if(!(usbConnected)){
            //delay(4000);
            display.ssd1306_command(SSD1306_DISPLAYOFF);
            if(!(usbConnected)&& (!(DisplayState))){
                power_adc_disable();
                set_sleep_mode (SLEEP_MODE_PWR_DOWN);
                sleep_enable();
                attachPinChangeInterrupt(digitalPinToPinChangeInterrupt(PREV_PIN), wakeFromBUTTON, FALLING);
                sleep_cpu();
                sleep_disable();
                detachPinChangeInterrupt(digitalPinToPinChangeInterrupt(PREV_PIN));
            power_adc_enable();}
            lastTime = millis()/1000.0;
            display.ssd1306_command(SSD1306_DISPLAYON);
            delay(4000);
        }
    }

but when i push the PREV_PIN always do the same things.

I want when Display is on bool Display=1
when Display is off bool Display=0

How can I write that like this?

I upload a watch code on my leonardo, but also i have some problems.

So you think we have to ask what problems you have?

Due to the power saving problems, i wrote a code with interrupts

Post complete code! In most cases the error is that part of the code people are hiding from us.

but when i push the PREV_PIN always do the same things.

That's what I would expect, I would be surprised if it does something different every time you press that button. Why do you expect that?

I want when Display is on bool Display=1
when Display is off bool Display=0

That must be in a part of the code your hiding from us.

Also post a wiring diagram of your setup so we know what hardware the code should run on.

pylon:
So you think we have to ask what problems you have?

Post complete code! In most cases the error is that part of the code people are hiding from us.

That's what I would expect, I would be surprised if it does something different every time you press that button. Why do you expect that?

That must be in a part of the code your hiding from us.

Also post a wiring diagram of your setup so we know what hardware the code should run on.

You don't have to. You don't have to post here either.
Of course i'm hiding the code.
I just wanna void to bool actually. I need " bool display; "

Of course i’m hiding the code.

No “of course” here, usually the people asking for help in the forum are cooperative.

I just wanna void to bool actually. I need " bool display; "

So why don’t you just do that? We cannot help because we haven’t seen the code yet.