Rebuilding modes and coloroptions

This commit is contained in:
Lukas Bachschwell 2016-07-30 18:04:44 +02:00
parent 5d030e9576
commit 161a4d92f8

View File

@ -20,21 +20,29 @@ unsigned long interval = 0;
int mode = 0;
int element = 0;
int colorval1 = 0;
int colorval2 = 0;
int colorval3 = 0;
unsigned int colorval1 = 0;
unsigned int colorval2 = 0;
unsigned int colorval3 = 0;
unsigned int primary_r = 0;
unsigned int primary_g = 0;
unsigned int primary_b = 0;
unsigned int second_r = 0;
unsigned int second_g = 0;
unsigned int second_b = 0;
String responseHTML = ""
"<!DOCTYPE html><html><head><title>LedControl</title></head><body>"
"<h1>Control</h1><br> "
"<a style='font-size:100px;' href='http://192.168.1.1/on'>on</a><br><br><a style='font-size:100px;'href='http://192.168.1.1/off'>off</a>"
"<br><a style='font-size:100px;' href='http://192.168.1.1/1'>run</a></body><br><a style='font-size:100px;' href='http://192.168.1.1/3'>run single</a><br><a style='font-size:100px;' href='http://192.168.1.1/2'>freaky</a></body></html>"
"<br><a style='font-size:100px;' href='http://192.168.1.1/show&num=0'>0</a><br>"
"<a style='font-size:100px;' href='http://192.168.1.1/show&num=1'>1</a><br>"
"<a style='font-size:100px;' href='http://192.168.1.1/show&num=2'>2</a><br>"
"<a style='font-size:100px;' href='http://192.168.1.1/show&num=3'>3</a><br>"
"<a style='font-size:100px;' href='http://192.168.1.1/show&num=4'>4</a><br>"
"<a style='font-size:100px;' href='http://192.168.1.1/show&num=5'>5</a><br>";
"<br><a style='font-size:100px;' href='http://192.168.1.1/show?num=0'>0</a><br>"
"<a style='font-size:100px;' href='http://192.168.1.1/show?num=1'>Run (once)</a><br>"
"<a style='font-size:100px;' href='http://192.168.1.1/show?num=2'>Freaky breathe</a><br>"
"<a style='font-size:100px;' href='http://192.168.1.1/show?num=3'>Run single</a><br>"
"<a style='font-size:100px;' href='http://192.168.1.1/show?num=4'>Mode 4</a><br>"
"<a style='font-size:100px;' href='http://192.168.1.1/show?num=5'>5</a><br>";
void handleOn() {
@ -74,11 +82,42 @@ void handleOff() {
webServer.send(200, "text/html", responseHTML);
}
void handleShow() {
Serial.println(webServer.args());
for ( uint8_t i = 0; i < webServer.args(); i++ ) {
if (webServer.argName( i ) == "num") {
char buf[3];
webServer.arg( i ).toCharArray(buf, 3);
int num = atoi(buf);
switch (num) {
case 0:
mode = 0;
Serial.println("leds should be off here");
break;
case 1:
mode = 1;
Serial.println("mode 1 run");
break;
case 2:
mode = 2;
Serial.println("mode 2 runSingle");
break;
case 3:
mode = 3;
Serial.println("mode 3 freaky breath");
break;
case 4:
mode = 4;
Serial.println("mode 4");
break;
}
Serial.println(num);
}
}
webServer.send(200, "text/html", responseHTML);
}
void setup() {
strip.begin();
Serial.begin(115200);
Serial.println("Ready");
WiFi.mode(WIFI_AP);
WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
@ -94,12 +133,6 @@ void setup() {
webServer.on("/show", handleShow);
webServer.on("/1", handle1);
webServer.on("/2", handle2);
webServer.on("/3", handle3);
webServer.onNotFound([]() {
webServer.send(200, "text/html", responseHTML);
});
@ -114,8 +147,6 @@ void loop() {
dnsServer.processNextRequest();
webServer.handleClient();
if (millis() - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = millis();