logic function needed for touch screen buttons

i need to create some kind of logic function and merge it into my code
sorry im still learning all this and i am trying to clean up my code and get it working for my UI

at the moment i have 2 images a red button and a green button

when the program starts all buttons are off (red)

once one is pressed it will turn green then run another function to activate an electronic device
but then i want to be able to turn it off as well and then turn red

how do i keep up with what state they are in and also keep up with the state once the screen has cleared and gone on to something else. while the system is active i want it to be able to remember the state of all buttons .. but one the system is reset all buttons will be set as off

here is my screen touch code it is part of switch case as there are 5 screens i need to keep track off
case 3 is screen 3

case 3: {  // Screen 3 Active 

          if ((p.x > 130 && p.x < 204) && (p.y > 213 && p.y < 276))

            oneon();

          else if ((p.x > 144 && p.x < 163) && (p.y > 280 && p.y < 320))
            
            twoon();

keeping in mind this is a part of a switch case how do i keep track so

If button 1 is on it will run OneOff();
but on the same touch if it is off it would run OneOn();
the button one XY limits are
((p.x > 130 && p.x < 204) && (p.y > 213 && p.y < 276))

at the moment the on off functions are

void oneoff() {
  // Button 1 off
  switch_off(0);
  tft.setCursor(45, 2);
  tft.setTextColor(RED);  tft.setTextSize(2);
  tft.println("Socket 1");
  bmpDraw("off.bmp", 40, 22);
}

void oneon() {
  // Button 1 off
  switch_on(0);
  tft.setCursor(45, 2);
  tft.setTextColor(GREEN);  tft.setTextSize(2);
  tft.println("Socket 1");
  bmpDraw("on.bmp", 40, 22);
}