Zoltan Hudak / WebSwitch_mbed-dev

Dependencies:   EthernetInterface mbed-rtos mbed-dev

Files at this revision

API Documentation at this revision

Comitter:
hudakz
Date:
Mon May 01 20:03:14 2017 +0000
Parent:
1:c024e74b3a75
Commit message:
Button added.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-dev.lib Show annotated file Show diff for this revision Revisions of this file
diff -r c024e74b3a75 -r 4a51bdd24745 main.cpp
--- a/main.cpp	Fri Apr 14 07:17:03 2017 +0000
+++ b/main.cpp	Mon May 01 20:03:14 2017 +0000
@@ -19,6 +19,7 @@
 const int           ON = 1;
 
 DigitalOut          sw(LED1);
+float               roomTemp = 21.8;    // A temperature sensor output
 
 const string        PASSWORD = "secret";    // change as you like
 const string        HTTP_OK = "HTTP/1.0 200 OK";
@@ -26,10 +27,11 @@
 const string        UNAUTHORIZED = "HTTP/1.0 401 Unauthorized";
 string              httpHeader;     // HTTP header
 string              httpContent;    // HTTP content
+
 /**
  * @brief   Defines a custom MAC address
  * @note    Uncomment the code below to define a unique MAC address.
- *          Modify the mac array items as needed. 
+ *          Modify the mac array items as needed.
  * @param
  * @retval
  */
@@ -103,24 +105,26 @@
  * @retval
  */
 string& showWebPage(uint8_t status) {
-    httpContent = "<h2>WebSwitch - Smart Home</h2>\r\n";
+    char roomTempStr[5];
 
-    httpContent += "<pre>Temperature:\t21.8&deg;C\r\n</pre>";
+    //roomTemp = ds1820.read();
+    sprintf(roomTempStr, "%3.1f", roomTemp);
+
+    httpContent = "<h2><a href=\".\" title=\"Click to refresh the page\">Smart Home</a></h2>"; 
+    httpContent += "<pre>Temperature:\t" + string(roomTempStr) + "&deg;C\r\n</pre>";
 
     if(status == ON) {
-        httpContent += "<pre>\r\nHeating:\t<font color=#FF0000>ON </font>";
-        httpContent += " <a href=\"./?sw=0\">[Turn off]</a>\r\n";
+        httpContent += "<pre>\r\nHeating:\t<font color=#FF0000>On </font>";
+        httpContent += " <a href=\"./?sw=0\"><button>Turn off</button></a>\r\n";
     }
     else {
-        httpContent += "<pre>\r\nHeating:\t<font color=#BBBBBB>OFF</font>";
-        httpContent += " <a href=\"./?sw=1\">[Turn on]</a>\r\n";
+        httpContent += "<pre>\r\nHeating:\t<font color=#999999>Off</font>";
+        httpContent += " <a href=\"./?sw=1\"><button>Turn on</button></a>\r\n";
     }
 
-    //    httpContent += "  \r\n";
-    //    httpContent += "  <a href=\".\">Refresh status]</a>\r\n";
     httpContent += "</pre>\r\n";
     httpContent += "<hr>\r\n";
-    httpContent += "<pre>2017 ARMmbed Open Source</pre>";
+    httpContent += "<pre>2017 ARMmbed</pre>";
     return httpContent;
 }
 
@@ -157,7 +161,7 @@
 
     //setup ethernet interface
     ethernet.init(); //Use DHCP
-    //ethernet.init("192.168.1.36", "255.255.255.0", "192.168.1.1");   // Use static IP
+    //ethernet.init("192.168.1.181", "255.255.255.0", "192.168.1.1");   // Use static IP
     ethernet.connect();
     printf("USAGE: Type '%s/%s/' into your web browser and hit ENTER\r\n", ethernet.getIPAddress(), PASSWORD.c_str());
     printf("NOTE:  Don't forget to type the last '/'.\r\n\r\n");
@@ -259,3 +263,4 @@
         }
     }
 }
+
diff -r c024e74b3a75 -r 4a51bdd24745 mbed-dev.lib
--- a/mbed-dev.lib	Fri Apr 14 07:17:03 2017 +0000
+++ b/mbed-dev.lib	Mon May 01 20:03:14 2017 +0000
@@ -1,1 +1,1 @@
-https://mbed.org/users/mbed_official/code/mbed-dev/#e13f6fdb2ac4
+https://mbed.org/users/mbed_official/code/mbed-dev/#74e0ce7f98e8