LeeT WiFiLamp code and test
Dependencies: ESP8266_WebServer mbed
Fork of WiFiLamp by
Diff: main.cpp
- Revision:
- 10:f48a9f923271
- Parent:
- 9:319aeb6e0123
- Child:
- 12:fbf950985e1c
--- a/main.cpp Sat Dec 27 05:56:47 2014 +0000 +++ b/main.cpp Sun Dec 28 15:28:27 2014 +0000 @@ -35,8 +35,9 @@ } int main() { - pc.printf("WiFi Lamp Test...\r\n"); - + + pc.printf("WiFi Lamp Test - v0.01 ...\r\n"); + setColor( 250, 0, 0); wifiCHPD = 0; @@ -72,14 +73,26 @@ } std::string httpReply; if( request->URI == "/" ) { - httpReply = "<html><head><title>WiFi Lamp</title></head><body><h1>The WiFi Lamp is alive(<a href='/red'>Red</a>)</h1></body></html>"; + 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>"; setColor(0,0,0); server.SendHTMLReply(request->LinkID, httpReply); } else if( request->URI == "/red" ) { - httpReply = "<html><head><title>WiFi Lamp</title></head><body><h1>The WiFi Lamp(Red) is alive(<a href='/'>Off</a>)</h1></body></html>"; + httpReply = "<html><head><title>WiFi Lamp</title></head><body><h1>The WiFi Lamp is now Red - To Turn <a href='/'>Off</a></h1></body></html>"; setColor(100, 0, 0); server.SendHTMLReply(request->LinkID, httpReply); - } else if ( request->URI == "/setcolor" ) { + } else if( request->URI == "/green" ) { + httpReply = "<html><head><title>WiFi Lamp</title></head><body><h1>The WiFi Lamp is now Green - To Turn <a href='/'>Off</a></h1></body></html>"; + setColor(0, 100, 0); + server.SendHTMLReply(request->LinkID, httpReply); + } else if( request->URI == "/blue" ) { + httpReply = "<html><head><title>WiFi Lamp</title></head><body><h1>The WiFi Lamp is now Blue - To Turn <a href='/'>Off</a></h1></body></html>"; + setColor(0, 0, 100); + server.SendHTMLReply(request->LinkID, httpReply); + } else if( request->URI == "/white" ) { + 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.SendHTMLReply(request->LinkID, httpReply); + } else if( request->URI == "/setcolor" ) { int r=0, g=0, b=0; if(request->Parameters.count("r") > 0) r=atoi(request->Parameters["r"].c_str());