How to use Momentary Button to power on LEDs (and) change buttoncycle

Seeking help on solving this chin scratching problem of how to use one momentary button to turn on power, and be used to also change the buttoncycle case from one neopixel animation to the next.

My thought is to have something similar to a headlamp, when the momentary button is held down, the power goes on and off, while also when you press the same button it changes from flashing neopixels to a different static neopixel for example. I have been finding some idea of various button presses, hold vs press, but not sure how to use those codes yet. The current code I figured may work by having the first case 0 be blank with no neopixels showing and the battery connected would not use energy, however on the serial viewport it shows the code constantly checking the button state, and the battery eventually does use energy doing this. My goal is have the code not drain the battery constantly checking the button state, and or actually close the circuit somehow.

The code is too large for this forum, but parts of it:

// Adafruit_NeoMatrix example for single NeoPixel Shield.
// Scrolls 'Howdy' across the matrix in a portrait (vertical) orientation.

#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#ifndef PSTR
#define PSTR // Make Arduino Due happy
#endif



#define PIN 6

int           LEDperiod   = 0; 
unsigned long prevLEDtime = 0L;

const int buttonPin  = 7  ;


int buttonState      = LOW;
int lastButtonState  = LOW;
int debounce_count = 0;

int  pixelState = 0;


int val = 0; 
int showType = 0;
//changed the bounce check = 10 to 0:
int bounceCheck = 0;





byte heart[17][3]={
  {
    1,1,1  }
  ,
  {
    1,1,1  }
  ,
  {
    1,1,1  }
  ,
  {
    1,1,1  }
  ,
  {
    1,1,1  }
  ,
  {
    1,1,1  }
  ,
  {
    1,1,1  }
  ,
  {
    1,1,1  }
  ,
  {
    1,1,1  }
  ,
  {
    1,1,1  }
  ,
  {
    1,1,1  }
  ,
  {
    1,1,1  }
  ,
  {
    1,1,1  }
  ,
  {
    1,1,1  }
  ,
  {
    1,1,1  }
  ,
  {
    1,1,1  }
  ,
  {
    1,1,1  }
  ,

};


// MATRIX DECLARATION:
// Parameter 1 = width of NeoPixel matrix
// Parameter 2 = height of matrix
// Parameter 3 = pin number (most are valid)
// Parameter 4 = matrix layout flags, add together as needed:
//   NEO_MATRIX_TOP, NEO_MATRIX_BOTTOM, NEO_MATRIX_LEFT, NEO_MATRIX_RIGHT:
//     Position of the FIRST LED in the matrix; pick two, e.g.
//     NEO_MATRIX_TOP + NEO_MATRIX_LEFT for the top-left corner.
//   NEO_MATRIX_ROWS, NEO_MATRIX_COLUMNS: LEDs are arranged in horizontal
//     rows or in vertical columns, respectively; pick one or the other.
//   NEO_MATRIX_PROGRESSIVE, NEO_MATRIX_ZIGZAG: all rows/columns proceed
//     in the same order, or alternate lines reverse direction; pick one.
//   See example below for these values in action.
// Parameter 5 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)


// Example for NeoPixel Shield.  In this application we'd like to use it
// as a 5x8 tall matrix, with the USB port positioned at the top of the
// Arduino.  When held that way, the first pixel is at the top right, and
// lines are arranged in columns, progressive order.  The shield uses
// 800 KHz (v2) pixels that expect GRB color data.
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(3, 17, PIN,
NEO_MATRIX_TOP    + NEO_MATRIX_LEFT +
NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG,
NEO_GRB            + NEO_KHZ800);




void setup() {
   pinMode(buttonPin, INPUT_PULLUP);

  

  
  matrix.begin();
  matrix.setTextWrap(false);
  matrix.setBrightness(50);


  Serial.begin(9600);
}

int x    = matrix.width();
int pass = 0;
int state = 0;


void loop() {
    unsigned long t = millis(); 
  
   matrix.fillScreen(0);
  
  // read the state of the switch into a local variable:
 if (buttonState = debounceRead(buttonPin));
  Serial.print("ButtonState: ");
  Serial.println(buttonState);
  Serial.print("LastButtonState: ");
  Serial.println(lastButtonState);
  Serial.print("showPixels: ");
  Serial.println(pixelState);
  // compare the buttonState to its previous state
  // compare the buttonState to its previous state

 



  if ((LOW == buttonState) && (buttonState != lastButtonState)){
  pixelState = (pixelState + 1) % 2;

  }
 
lastButtonState = buttonState;}

byte debounceRead(int pin)
{
  uint8_t pinState = digitalRead(pin);
  uint32_t timeout = millis();
  while (millis() < timeout+1)
  {
    if (digitalRead(pin) != pinState)
    {
      pinState = digitalRead(buttonPin);
     
      timeout = millis();
   
 
  }
  }

//loading************************************************************************************************
  //START START START START
  
  //BUTTON 1 SOLID OFF----------------------------------------------------------------
   
  switch(pixelState)
{
case 0: LEDperiod = 10000000L;
{

    //frame1 
    matrix.fillScreen(0);
   for(int k=0;k<255;k+=1){//(+10 ADJUSTS SPEED, 10 IS FASTER, 1 IS SLOW)
  for(int i=0;i<18;i++){
    for(int j=0;j<18; j++){
      matrix.setBrightness(0);
      if(heart[i][j]==1)
  
      {
        matrix.drawPixel(j, i, matrix.Color(0,0,0));
        }
     
    }
  }
  matrix.show();
  } 
  
 
    }
  
break;
}
 

matrix.fillScreen(0);

  
  
//BUTTON 2 FLASH--------------------------------------------------------------------------------


unsigned long now = millis();
switch(pixelState)
{
case 1: LEDperiod = 10000000L;
{

   for(int k=0;k<255;k+=10){//(+10 ADJUSTS SPEED, 10 IS FASTER, 1 IS SLOW)
  for(int i=0;i<18;i++){
    for(int j=0;j<18; j++){
      matrix.setBrightness(50);
      if(heart[i][j]==0)
  
      {
        matrix.drawPixel(j, i, matrix.Color(0,0,0));
        }
     
    }
  }
  matrix.show();

  }  
   
  
   // FRAME 2
     for(int k=0;k<255;k+=10){//(+10 ADJUSTS SPEED, 10 IS FASTER, 1 IS SLOW)
  for(int i=0;i<18;i++){
    for(int j=0;j<18; j++){
      matrix.setBrightness(50);
      if(heart[i][j]==1)
  
      {
        matrix.drawPixel(j, i, matrix.Color(255,0,0));
        }
      
    }
  }
  matrix.show();
     //DELAY
  }
  

    }
  
break;
}
    matrix.fillScreen(0);

  
//--------------------------------------------------------------
return pinState;

}


//--------------------------------------------------------------

I think you are missing something

My goal is have the code not drain the battery constantly checking the button state,

Unless you send the controller to sleep you use no more battery checking the state of a button than if you don't.

The current code I figured may work by having the first case 0 be blank with no neopixels showing and the battery connected would not use energy,

That is wrong, the Arduino does not work like that.