Rebuilding modes and coloroptions
This commit is contained in:
parent
5d030e9576
commit
161a4d92f8
161
lichterKette.ino
161
lichterKette.ino
@ -20,21 +20,29 @@ unsigned long interval = 0;
|
|||||||
int mode = 0;
|
int mode = 0;
|
||||||
int element = 0;
|
int element = 0;
|
||||||
|
|
||||||
int colorval1 = 0;
|
unsigned int colorval1 = 0;
|
||||||
int colorval2 = 0;
|
unsigned int colorval2 = 0;
|
||||||
int colorval3 = 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 = ""
|
String responseHTML = ""
|
||||||
"<!DOCTYPE html><html><head><title>LedControl</title></head><body>"
|
"<!DOCTYPE html><html><head><title>LedControl</title></head><body>"
|
||||||
"<h1>Control</h1><br> "
|
"<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>"
|
"<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/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>"
|
"<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=1'>Run (once)</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=2'>Freaky breathe</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=3'>Run single</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=4'>Mode 4</a><br>"
|
||||||
"<a style='font-size:100px;' href='http://192.168.1.1/show&num=5'>5</a><br>";
|
"<a style='font-size:100px;' href='http://192.168.1.1/show?num=5'>5</a><br>";
|
||||||
|
|
||||||
|
|
||||||
void handleOn() {
|
void handleOn() {
|
||||||
@ -74,11 +82,42 @@ void handleOff() {
|
|||||||
webServer.send(200, "text/html", responseHTML);
|
webServer.send(200, "text/html", responseHTML);
|
||||||
}
|
}
|
||||||
void handleShow() {
|
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() {
|
void setup() {
|
||||||
strip.begin();
|
strip.begin();
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
Serial.println("Ready");
|
||||||
|
|
||||||
WiFi.mode(WIFI_AP);
|
WiFi.mode(WIFI_AP);
|
||||||
WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
|
WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
|
||||||
@ -94,12 +133,6 @@ void setup() {
|
|||||||
webServer.on("/show", handleShow);
|
webServer.on("/show", handleShow);
|
||||||
|
|
||||||
|
|
||||||
webServer.on("/1", handle1);
|
|
||||||
webServer.on("/2", handle2);
|
|
||||||
webServer.on("/3", handle3);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
webServer.onNotFound([]() {
|
webServer.onNotFound([]() {
|
||||||
webServer.send(200, "text/html", responseHTML);
|
webServer.send(200, "text/html", responseHTML);
|
||||||
});
|
});
|
||||||
@ -114,62 +147,60 @@ void loop() {
|
|||||||
dnsServer.processNextRequest();
|
dnsServer.processNextRequest();
|
||||||
webServer.handleClient();
|
webServer.handleClient();
|
||||||
|
|
||||||
|
if (millis() - previousMillis >= interval) {
|
||||||
|
// save the last time you blinked the LED
|
||||||
|
previousMillis = millis();
|
||||||
|
|
||||||
|
switch (mode) {
|
||||||
if (millis() - previousMillis >= interval) {
|
|
||||||
// save the last time you blinked the LED
|
|
||||||
previousMillis = millis();
|
|
||||||
|
|
||||||
switch(mode){
|
case 1:
|
||||||
|
|
||||||
case 1:
|
|
||||||
interval = 100;
|
interval = 100;
|
||||||
if(element<NUMPIXELS) {
|
if (element < NUMPIXELS) {
|
||||||
element++;
|
element++;
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
element = 0;
|
element = 0;
|
||||||
colorval1 = ((colorval1==50)? 0:50);
|
colorval1 = ((colorval1 == 50) ? 0 : 50);
|
||||||
}
|
|
||||||
|
|
||||||
strip.setPixelColor(element, strip.Color(255,colorval1,0)); // Moderately bright green color.
|
|
||||||
strip.show();
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
interval = 10;
|
|
||||||
|
|
||||||
if(colorval2 == 0)colorval1--;
|
|
||||||
else colorval1++;
|
|
||||||
|
|
||||||
if(colorval1 > 150) colorval2=0;
|
|
||||||
if(colorval1 < 30) colorval2=1;
|
|
||||||
for(int i=0;i<NUMPIXELS;i++){
|
|
||||||
strip.setPixelColor(i, strip.Color(colorval1,colorval1,colorval1));
|
|
||||||
|
|
||||||
}
|
|
||||||
strip.show();
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
|
|
||||||
interval = 100;
|
|
||||||
if(element<NUMPIXELS)
|
|
||||||
element++;
|
|
||||||
else
|
|
||||||
element = 0;
|
|
||||||
for(int i = 0; i < NUMPIXELS; i++){
|
|
||||||
strip.setPixelColor(i,strip.Color(((i==element)?100:200),((i==element)?100:50),((i==element)?100:0))); // Moderately bright green color.
|
|
||||||
}
|
|
||||||
strip.show();
|
|
||||||
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
previousMillis = millis();
|
strip.setPixelColor(element, strip.Color(255, colorval1, 0)); // Moderately bright green color.
|
||||||
|
strip.show();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
interval = 10;
|
||||||
|
|
||||||
|
if (colorval2 == 0)colorval1--;
|
||||||
|
else colorval1++;
|
||||||
|
|
||||||
|
if (colorval1 > 150) colorval2 = 0;
|
||||||
|
if (colorval1 < 30) colorval2 = 1;
|
||||||
|
for (int i = 0; i < NUMPIXELS; i++) {
|
||||||
|
strip.setPixelColor(i, strip.Color(colorval1, colorval1, colorval1));
|
||||||
|
|
||||||
|
}
|
||||||
|
strip.show();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
|
||||||
|
interval = 100;
|
||||||
|
if (element < NUMPIXELS)
|
||||||
|
element++;
|
||||||
|
else
|
||||||
|
element = 0;
|
||||||
|
for (int i = 0; i < NUMPIXELS; i++) {
|
||||||
|
strip.setPixelColor(i, strip.Color(((i == element) ? 100 : 200), ((i == element) ? 100 : 50), ((i == element) ? 100 : 0))); // Moderately bright green color.
|
||||||
|
}
|
||||||
|
strip.show();
|
||||||
|
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
previousMillis = millis();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user