Blynk Virtual pins

Hi,

I am creating a colour changing light with a Particle photon controlled by my smartphone using Blynk. I have an RGB LED connected to D0,D1 & D2 as BLUE RED GREEN.

I am trying to allow the user to either manually choose a colour using a ZERGBA set to the RGB pins in split mode or the user can push a button on the app set to V1 to automaticity fade the RGB LED.

I have copied in the fading code but need help implementing the button to switch the “mode”

I also want to add a slider to V2 to change the speed of the fade

Here’s my code so far;

Thanks
Mathew

//#define BLYNK_DEBUG // Uncomment this to see debug prints
#define BLYNK_PRINT Serial
#include "blynk/blynk.h"

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";

void setup()
{
    // Start off with the LED off.
    setColourRgb(0,0,0);
    Serial.begin(9600);
    delay(5000); // Allow board to settle
    Blynk.begin(auth);
}

// Attach a Button widget to the Virtual pin 1 
BLYNK_WRITE(V1) {
    if (param.asInt() == 1) { // On button High Fade RGB
       unsigned int rgbColour[3];
  
  // Start off with red.
  rgbColour[0] = 255;
  rgbColour[1] = 0;
  rgbColour[2] = 0;

  // Choose the colours to increment and decrement.
  for (int decColour = 0; decColour < 3; decColour += 1) {
    int incColour = decColour == 2 ? 0 : decColour + 1;

    // cross-fade the two colours.
    for(int i = 0; i < 255; i += 1) {
      rgbColour[decColour] -= 1;
      rgbColour[incColour] += 1;
      
      setColourRgb(rgbColour[0], rgbColour[1], rgbColour[2]);
      delay(FadeSpeed);
    }
    }
  }
}

void setColourRgb(unsigned int red, unsigned int green, unsigned int blue) {
  analogWrite(redPin, red);
  analogWrite(greenPin, green);
  analogWrite(bluePin, blue);
}
    }
}

BLYNK_WRITE(V2) {
    FadeSpeed = param.asInt()
    }
// Attach a ZeRGBa widget (mode: Merge) to the Virtual pin 0 - and control RGB led
BLYNK_WRITE(V0) {
    int red = param[0].asInt();
    int green = param[1].asInt();
    int blue = param[2].asInt();
    setColourRgb(rgbColour[0], rgbColour[1], rgbColour[2]);
}

void loop()
{
    Blynk.run();
    }
}

(deleted)