test ADC avec page Web reduite

Dependencies:   UIPEthernet mbed FCT_WEB hebergement

Fork of Nucleo_Web_ENC28J60 by FOURNET Olivier

P.S : 1ère mise en fonctionnement de la carte NUCLEO STM32F411RET6

Instruction pour la mise en fonctionnement : https://developer.mbed.org/users/Fo170/notebook/the-stm32-nucleo-64-board/

Revision:
5:a46a2512e17e
Parent:
4:d34811deedab
Child:
6:2ce163810c2f
--- a/main.cpp	Wed Feb 04 19:27:26 2015 +0000
+++ b/main.cpp	Sat Jul 25 17:43:36 2015 +0000
@@ -11,6 +11,9 @@
 #include <UIPClient.h>
 #include <string>
 
+DigitalOut myled(LED1);
+AnalogIn    a_in(PC_0);
+
 using namespace std;
 
 // UIPEthernet is the name of a global instance of UIPEthernetClass.
@@ -44,8 +47,11 @@
 
 // MAC number must be unique within the connected network. Modify as appropriate.
 const uint8_t    MY_MAC[6] = {0x00,0x01,0x02,0x03,0x04,0x06};
+
 // IP address must be also unique and compatible with your network. Change as appropriate.
-const IPAddress  MY_IP(192,168,1,181);
+const IPAddress  MY_IP(192,168,0,170);
+#define IPAdress_String "192.168.0.170"
+
 const uint16_t   MY_PORT = 80;      // for HTTP connection
 EthernetServer   myServer = EthernetServer(MY_PORT);
 // In this example we are turning on/off LED1.
@@ -112,19 +118,45 @@
 
 string& page(uint8_t status)
 {
-    httpContent = "<h2>Web Switch</h2>\r\n";
+    char buffer[32];
+    char time_stamp[32];//as our lcd is of 16 character it is so
+    //-------------
+    httpContent = "<h2>Web Switch Nucleo-F411RE & ENC28J60 (RTC et ADC) ";
+    httpContent += IPAdress_String "\r\n";
+    
+    // Test d'image en base64 :
+    // http://webcodertools.com/imagetobase64converter/Create
+    httpContent += "<img alt='' src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwwAADsMBx2+oZAAAABp0RVh0U29mdHdhcmUAUGFpbnQuTkVUIHYzLjUuMTAw9HKhAAAAUklEQVQ4T2NggIEGMIBzCTDgSh0cHAjrIcFgiGFoGoCWELYQrgLIgGsg4CtkaTibWNfu378fq2tpHx6EbcAMQ8J6iPU3cpIhbCqaisFpCTwVAwB5lit+0ltbrgAAAABJRU5ErkJggg=='>";
+    httpContent += "</h2>\r\n";
 
     if(status == 1) {
-        httpContent += "<pre>\r\n  <font color=#FF0000>ON</font>";
+        httpContent += "<pre>\r\n  <font color=#00FF00>ON</font>";
         httpContent += " <a href=\"./?sw=0\">[switch off]</a>\r\n";
     } else {
-        httpContent += "<pre>\r\n  <font color=#00FF00>OFF</font>";
+        httpContent += "<pre>\r\n  <font color=#FF0000>OFF</font>";
         httpContent += " <a href=\"./?sw=1\">[switch on]</a>\r\n";
     }
 
     httpContent += "  <a href=\".\">[refresh status]</a>\r\n";
     httpContent += "</pre>\r\n";
     httpContent += "<hr>\r\n";
+    //-------------
+    time_t seconds = time(NULL)+ 19800; // time(null) gives the GMT time .
+    // printf("Time as seconds since January 1, 1970 = %d\n", seconds);
+    strftime(time_stamp, 32, "%y %m %d, %H:%M:%Ss", localtime(&seconds)); 
+    // this converts the value in seconds obtained above to human readable format and assigns it to the timestamp   
+    sprintf(buffer, "%s", time_stamp);// diplays the human readable time
+    httpContent += buffer;
+    httpContent += "\r\n";    
+    httpContent += "<hr>\r\n";
+    //----------------
+    httpContent += "Temperature: ";
+    sprintf(buffer, "%4.3f", a_in * 3.3);
+    httpContent += buffer;
+    httpContent += "&deg;C\r\n";
+    httpContent += "<hr>\r\n";
+    //-----------
+    wait(1);
     return httpContent;
 }
 
@@ -144,7 +176,12 @@
 }
 
 int main()
-{
+{   
+ // RTC
+ set_time(1387188323); // Set RTC time to 16 December 2013 10:05:23 UTC
+ // Date and time are set.
+    
+    
     UIPEthernet.begin(MY_MAC,MY_IP);
     myServer.begin();
     while(1) {