Getting a function to loop within a switch case

'm trying to get the function flash() to repeat, but it stops when clickevent() occurs again and case 0 becomes active.

I think my error is that case 0 is not becoming active because it's stuck on case 1 maybe? I can get it to start using while() statements or do while() statements but then I can't exit the loop, any help would be very appreciated.

// ======== change the lighting mode setting between flash and solid with a single click of the button ===========
int ModeSetting = 0;
void clickEvent()
{
    Serial.println("Click Occured");
    ModeSetting++;
    if (ModeSetting > 1)
        ModeSetting = 0;
    ChangeMode(ModeSetting);
}

void ChangeMode(int i)
{
    switch (i)
    {
    case 0:
        strip.setBrightness(255);
        Serial.println("MODE = SOLID COLOUR"); // SOLID LIGHT;
        break;
    case 1:
        flash(); // THE FUNCTION THAT NEEDS TO LOOP pls help

        break;
    }
}

int flashstate = LOW;
unsigned long PrevFlashMillis = 0;
const long flashinterval = 1000;
void flash()
{
    unsigned long currentFlashMillis = millis();
    if (currentFlashMillis - PrevFlashMillis >= flashinterval)
    {
        // save the last time you blinked the LED
        PrevFlashMillis = currentFlashMillis;
        // if the LED is off turn it on and vice-versa:
        if (flashstate == LOW)
        {
            strip.setBrightness(255);
            Serial.println("FLASH ON");
            flashstate == HIGH;
        }
        else
        {
            strip.setBrightness(0);
            Serial.println("FLASH OFF");
            flashstate == LOW;
        }
    }
}
        flash(); // THE FUNCTION THAT NEEDS TO LOOP pls help

You need to explain that comment. Either the function loops internally, not returning until somehow it magically knows to return, OR ChangeMode() has to call the function over and over.

It seems unlikely that ChangeMode() should hang around until some mysterious event causes it to finally return.

So, it seems far more likely that you need to restructure your code. ChangeMode() should simply set a flag indicating that flashing is required. The loop() function should handle calling flash() over and over, if flashing is needed.

Thanks, it's for a bike light, the single press (clickEvent function) will cause neopixels to either blink or be steady, and other events such as double click will change the colour etc,

So your suggestion is to have a variable in the ChangeMode Case 1 called FlashFlag that will go High or low, and a IF statement with the FlashFlag variable as the conditional in the main loop?

So your suggestion is to have a variable in the ChangeMode Case 1 called FlashFlag that will go High or low, and a IF statement with the FlashFlag variable as the conditional in the main loop?

true or false, not HIGH or LOW, but, yes, that is the general idea.