Commit b56a1d7a authored by Chris Klinger's avatar Chris Klinger
Browse files

Added a Reset Function to init the RGB Stripe

parent 1db59c21
......@@ -56,13 +56,11 @@ void setup(void) {
// see https://esp8266.github.io/Arduino/versions/2.0.0/doc/reference.html#analog-output
analogWriteRange(255);
resetOutputs();
// Root and 404
server.on("/", handleRoot);
server.onNotFound(handleNotFound);
// REST-API
server.on("/api/v1/state", HTTP_POST, handleApiRequest);
// iro.js User Interface and Javascript
server.on("/ui", HTTP_GET, []() {
server.send(200, "text/html", WEBINTERFACE);
......@@ -73,6 +71,10 @@ void setup(void) {
server.on("/iro.min.js", HTTP_GET, []() {
server.send(200, "application/javascript", IRO_JS);
});
// REST-API
server.on("/api/v1/state", HTTP_POST, handleApiRequest);
server.on("/api/v1/reset", HTTP_GET, resetOutputs);
server.begin();
Serial.println("WifiRGB HTTP server started");
......@@ -185,6 +187,16 @@ void handleApiRequest() {
server.send(200, "application/json", server.arg("plain"));
}
void resetOutputs() {
analogWrite(REDPIN, 255);
analogWrite(GREENPIN, 255);
analogWrite(BLUEPIN, 255);
analogWrite(REDPIN, 0);
analogWrite(GREENPIN, 0);
analogWrite(BLUEPIN, 0);
}
// this is a modified version of https://gist.github.com/hdznrrd/656996
RGB hsvToRgb(double h, double s, double v) {
int i;
......
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