I can of course loop the rainbow function itself, but then I can't get input from bridge to change the lighting program.
My loop is from the documentation
Code: Select all
void loop() {
// Get clients coming from server
YunClient client = server.accept();
if (client) {
process(client);
client.stop();
}
delay(50);
}
Code: Select all
void process(YunClient client) {
String command = client.readStringUntil('/');
if (command == "light") {
lightCommand(client);
}
}
void lightCommand(YunClient client) {
int programMode = client.parseInt();
int redRaw = client.parseInt();
int redVal = constrain(redRaw, 0, 255);
int BANNED = client.parseInt();
int greenVal = constrain(BANNED, 0, 255);
int blueRaw = client.parseInt();
int blueVal = constrain(blueRaw, 0, 255);
switch (programMode) {
case 0:
allColor(strip.Color(0, 0, 0)); //off
break;
case 1:
allColor(strip.Color(redVal, greenVal, blueVal)); //off
break;
case 2:
rainbow(100);
break;
case 3:
rainbowCycle(10);
break;
default:
allColor(strip.Color(0, 0, 0)); //off
}
}