LeeT WiFiLamp code and test

Dependencies:   ESP8266_WebServer mbed

Fork of WiFiLamp by Sebastian Schocke

Revision:
19:7fdccfd5b50b
Parent:
13:1e8f27da036a
Parent:
16:f2f2da9ef9ab
Child:
20:f5a6527bfda6
--- a/main.cpp	Mon Dec 29 20:58:11 2014 +0000
+++ b/main.cpp	Mon Dec 29 21:00:26 2014 +0000
@@ -37,7 +37,7 @@
 int main() {
     pc.baud(115200);
     
-    pc.printf("WiFi Lamp Test - v0.01 ...\r\n");    
+    pc.printf("WiFi Lamp - v0.02 ...\r\n");    
     
     setColor( 25, 0, 0);
     
@@ -74,7 +74,24 @@
             }
             std::string httpReply;
             if( request->URI == "/" ) {
-                httpReply = "<html><title>WiFi Lamp</title><body><h1>The WiFi Lamp V0.01 is alive ...</h1><br>Quick colour links:<br><a href='/red'>Red</a><br><a href='/green'>Green</a><br><a href='/blue'>Blue</a><br><a href='/white'>White</a><br></body></html>";
+                httpReply = "<html><title>WiFi Lamp</title> \
+<body><h1>The WiFi Lamp v0.02 is alive ...</h1>Quick colour links:<br> \
+<a href='/red'>Red</a><br><a href='/green'>Green</a><br><a href='/blue'>Blue</a><br><a href='/white'>White</a><br> \
+<form id='setcolour' action='setcolour' > \
+   <p> \
+   Red: <input type='text' name='r' value='0' /> \
+   </p> \
+   <p> \
+   Green: <input type='text' name='g' value='0' /> \
+   </p> \
+   <p> \
+   Blue: <input type='text' name='b' value='0' /> \
+   </p> \
+   <p> \
+   <input type='submit' /> \
+   </p> \
+</form> \
+                </body></html>";
                 setColor(0,0,0);
                 server.SendReply(request->LinkID, httpReply, mimeHTML);
             } else if( request->URI == "/red" ) {
@@ -93,14 +110,14 @@
                 httpReply = "<html><head><title>WiFi Lamp</title></head><body><h1>The WiFi Lamp is now White - To Turn <a href='/'>Off</a></h1></body></html>";
                 setColor(100, 100, 100);
                 server.SendReply(request->LinkID, httpReply, mimeHTML);
-            } else if( request->URI == "/setcolor" ) {
+            } else if( request->URI == "/setcolour" || request->URI == "/setcolor" ) {
                 int r=0, g=0, b=0;
                 
                 if(request->Parameters.count("r") > 0) r=atoi(request->Parameters["r"].c_str());
                 if(request->Parameters.count("g") > 0) g=atoi(request->Parameters["g"].c_str());
                 if(request->Parameters.count("b") > 0) b=atoi(request->Parameters["b"].c_str());
                 
-                pc.printf( "Set color to (%i, %i, %i)\r\n", r,g,b);
+                pc.printf( "Set colour to (%i, %i, %i)\r\n", r,g,b);
                 
                 setColor( r,g,b );