Hi there!
I am attempting to control SK6812 LEDs by using an ESP32. I am pretty familiar with the Neopixel library but I am attempting to blend that library into another project that uses a web server on the same ESP32.
So, I want the simple webpage on the ESP32 to control the LEDs. I can create buttons that set the LEDs to a predefined color, but I am hoping to have an input box for each channel (R, G, B, and W), then have an Apply button that sets the LEDs to whatever color has been defined.
My problem is: how to I retrieve the value from the HTML input boxes and set the variables to those values? Once those variables are set, I can pass them into the function that controls the LEDs.
Lines 209 - 215 contain the HTML code that builds the input boxes.
//################################## RGBW Inputs
client.println("<p><label for='RedValue'>Red Value:</label><input type='text' id='RedValue' name='RedValue' value='0'></p>");
client.println("<p><label for='GreenValue'>Green Value:</label><input type='text' id='GreenValue' name='GreenValue' value='0'></p>");
client.println("<p><label for='BlueValue'>Blue Value:</label><input type='text' id='BlueValue' name='BlueValue' value='0'></p>");
client.println("<p><label for='WhiteValue'>White Value:</label><input type='text' id='WhiteValue' name='WhiteValue' value='0'></p>");
client.println("<p><a href=\"/rgbw/apply\"><button class=\"button\">Apply RGBW Settings</button></a></p>");
Lines 174 - 182 contain the logic where I would like to assign the variables to the input box values.
} else if (header.indexOf("GET /rgbw/apply") >= 0) {
Serial.println("Applying RGBW settings");
int redAmt = 0;
int greenAmt = 128;
int blueAmt = 128;
int whiteAmt = 0;
Serial.print("The Red Amount is:");
Serial.println("");
set_entire_strip_color_dynamic(10, redAmt, greenAmt, blueAmt, whiteAmt);
Lines 310 - 318 contains the function that controls the LEDs
void set_entire_strip_color_dynamic(int wait, uint32_t redAmt, uint32_t greenAmt, uint32_t blueAmt, uint32_t whiteAmt)
{
for(int i=0; i<strip.numPixels(); i++)
{
strip.setPixelColor(i, redAmt, greenAmt, blueAmt, whiteAmt);
strip.show();
delay(wait);
}
}
Thanks for taking a look!
