Commit 03f50991 authored by Mitchell Pomery's avatar Mitchell Pomery

Removed unneeded redundant if statements

parent a557f225
...@@ -47,7 +47,7 @@ char blue = (int) 255; ...@@ -47,7 +47,7 @@ char blue = (int) 255;
// For controlling the lights - Should only be changed by the functions // For controlling the lights - Should only be changed by the functions
int position = 0; // How far through the cycle we are int position = 0; // How far through the cycle we are
struct led ledArray[STRIPLENGTH]; // led array struct led ledArray[STRIPLENGTH]; // led array
int lightOption = 0; // Which predefined light sequence we are running int lightOption = 1; // Which predefined light sequence we are running
char brightness = (char) 128; //Brightness of the LEDs char brightness = (char) 128; //Brightness of the LEDs
// We seem to have issues at the moment putting this up to the maximum (255) // We seem to have issues at the moment putting this up to the maximum (255)
// Most likely due to the fact the LED strip is underpowered // Most likely due to the fact the LED strip is underpowered
...@@ -176,15 +176,13 @@ char *url_tail, bool tail_complete) { ...@@ -176,15 +176,13 @@ char *url_tail, bool tail_complete) {
return; return;
} }
else if (type == WebServer::GET) { else if (type == WebServer::GET) {
if (strlen(url_tail)) { while (strlen(url_tail)) {
while (strlen(url_tail)) { rc = server.nextURLparam(&url_tail, name, NAMELEN, value, VALUELEN);
rc = server.nextURLparam(&url_tail, name, NAMELEN, value, VALUELEN); if (rc != URLPARAM_EOS) {
if (rc != URLPARAM_EOS) { if (String(name).equals("seq")) {
if (String(name).equals("seq")) { lightOption = atoi(value);
lightOption = atoi(value); server.print(lightOption);
server.print(lightOption); position = 0;
position = 0;
}
} }
} }
} }
...@@ -218,25 +216,23 @@ char *url_tail, bool tail_complete) { ...@@ -218,25 +216,23 @@ char *url_tail, bool tail_complete) {
return; return;
} }
else if (type == WebServer::GET) { else if (type == WebServer::GET) {
if (strlen(url_tail)) { while (strlen(url_tail)) {
while (strlen(url_tail)) { rc = server.nextURLparam(&url_tail, name, NAMELEN, value, VALUELEN);
rc = server.nextURLparam(&url_tail, name, NAMELEN, value, VALUELEN); if (rc != URLPARAM_EOS) {
if (rc != URLPARAM_EOS) { if (String(name).equals("x")) {
if (String(name).equals("x")) { xPos = atoi(value);
xPos = atoi(value); }
} else if (String(name).equals("y")) {
else if (String(name).equals("y")) { yPos = atoi(value);
yPos = atoi(value); }
} else if (String(name).equals("r")) {
else if (String(name).equals("r")) { r = atoi(value);
r = atoi(value); }
} else if (String(name).equals("g")) {
else if (String(name).equals("g")) { g = atoi(value);
g = atoi(value); }
} else if (String(name).equals("b")) {
else if (String(name).equals("b")) { b = atoi(value);
b = atoi(value);
}
} }
} }
} }
...@@ -268,15 +264,13 @@ char *url_tail, bool tail_complete) { ...@@ -268,15 +264,13 @@ char *url_tail, bool tail_complete) {
return; return;
} }
else if (type == WebServer::GET) { //WebServer::POST else if (type == WebServer::GET) { //WebServer::POST
if (strlen(url_tail)) { while (strlen(url_tail)) {
while (strlen(url_tail)) { rc = server.nextURLparam(&url_tail, name, NAMELEN, value, VALUELEN);
rc = server.nextURLparam(&url_tail, name, NAMELEN, value, VALUELEN); if (rc != URLPARAM_EOS) {
if (rc != URLPARAM_EOS) { if (String(name).equals("bright")) {
if (String(name).equals("bright")) { strip.setBrightness(atoi(value));
strip.setBrightness(atoi(value)); server.print(atoi(value));
server.print(atoi(value)); strip.show();
strip.show();
}
} }
} }
} }
...@@ -452,30 +446,31 @@ void loop() ...@@ -452,30 +446,31 @@ void loop()
///TODO: Make these switches nicer ///TODO: Make these switches nicer
switch (lightOption) { switch (lightOption) {
case 0: // Don't change the lights at all case 0: // Don't change the lights at all
lightOption = 2;
break; break;
case 1: // Wipe the LED's to Red case 1: // RainbowCycle
rainbowCycle(20);
break;
// Cycling through LED Sequences
case 11:
colourWipe(strip.Color(red, green, blue), 50); colourWipe(strip.Color(red, green, blue), 50);
Serial.println("ColourWipe"); Serial.println("ColourWipe");
break; break;
case 2: case 12:
rainbow(20); rainbow(20);
Serial.println("Rainbow");
break; break;
case 3: case 13:
rainbowCycle(20); rainbowCycle(20);
Serial.println("RainbowCycle");
break; break;
case 4: case 14:
theaterChaseRainbow(20); theaterChaseRainbow(20);
Serial.println("TheaterChaseRainbow");
break; break;
default: default: // Go back to cycling
lightOption = 1; lightOption = 11;
break; break;
} }
// Show our lights // Show our lights
if (position == 0) { // if we have completed a sequence, move to the next one if (position == 0 && lightOption > 10) { // if we have completed a sequence, move to the next one
lightOption++; lightOption++;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment