HTTP server is created by connecting an ENC28J60 module to the mbed board. It is serving a webpage which enables remotely turn on/off LED1 (or other device). Compile, download, run and type 192.168.0.170/secret/ into your web browser and Flot Interactivity Graphique

Dependencies:   UIPEthernet mbed FCT_WEB hebergement

Fork of WebSwitch_ENC28J60 by Zoltan Hudak

Page généré : /media/uploads/Fo170/webservernucleo.png

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/

Vue d'ensemble : /media/uploads/Fo170/vue_d_ensemble_1.jpg

/media/uploads/Fo170/vue_d_ensemble_2.jpg

Vue de la carte ENC28J60 : /media/uploads/Fo170/carte_enc28j60_a.jpg

/media/uploads/Fo170/carte_enc28j60_b.jpg

Carte Nucléo : /media/uploads/Fo170/nucleo_stm32f411re.jpg

Revision:
11:afb33350db83
Parent:
10:bbee7dd4bcda
Child:
12:61b10a733ede
--- a/main.cpp	Tue Jul 28 11:26:32 2015 +0000
+++ b/main.cpp	Tue Jul 28 20:24:02 2015 +0000
@@ -72,19 +72,21 @@
 const string __image_401_Unauthorized__       = "<img alt='' src='http://olivier.fournet.free.fr/png/401_Unauthorized.png'>";
 
 #define NB_SAMPLES    10
+unsigned long int Sample = 0;
 float adc_samples[NB_SAMPLES];// = { 0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.01,1.02,1.03,1.04 };
 float time_samples[NB_SAMPLES];// = { -0.1,2,3,4,5,6,7,8,9,10,11,12,13,14 };
 float x_min = 0.0, x_max = 0.0;
 float y_min = 0.0, y_max = 0.0;
 float Seconds = 0.0;
-
+float k = 0.0;
+//------------
 Ticker second_ticker;
 
 void add_one_second()
-{
- Seconds = Seconds + 0.1;
+{       
+ Seconds = Seconds + k;//0.1;
 }
-
+//------------
 const uint16_t   MY_PORT = 80;      // for HTTP connection
 EthernetServer   myServer = EthernetServer(MY_PORT);
 // In this example we are turning on/off LED1.
@@ -148,12 +150,28 @@
 
 string& page(uint8_t status)
 {
-    char buffer[32];
+    char buffer[128];
     //char time_stamp[32];
     float meas;
     meas = a_in.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
     meas = meas * 3300.0; // Change the value to be in the 0 to 3300 range
     //Seconds = Seconds + 1;
+    x_min = x_max = Seconds;
+    y_min = y_max = meas;
+    int i;
+                    
+    for(i = 1 ; i < NB_SAMPLES ; i++)
+    {
+     time_samples[i-1] = time_samples[i];
+     adc_samples[i-1] = adc_samples[i];
+     if( time_samples[i] < x_min ) x_min = time_samples[i];
+     if( time_samples[i] > x_max ) x_max = time_samples[i];
+     if( adc_samples[i] < y_min ) y_min = adc_samples[i];
+     if( adc_samples[i] > y_max ) y_max = adc_samples[i];
+    }
+
+    adc_samples[NB_SAMPLES-1] = meas;
+    time_samples[NB_SAMPLES-1] = Seconds;
     //-------------
     httpContent = "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\r\n";
     httpContent += "<meta http-equiv=\"refresh\" content=\"";
@@ -171,8 +189,21 @@
     httpContent += "<script language=\"javascript\" type=\"text/javascript\">\r\n";
     httpContent += "var color_Y = \"#FF0000\";\r\n";
     httpContent += "var label_Y = \"Adc(x)\";\r\n";
-    httpContent += "var x_min = -0.5, x_max =  14.5, y_min = -0.5, y_max =  1.5;\r\n";
-    httpContent += "var array_value = [[-0.1,0.1],[2,0.2],[3,0.3],[4,0.4],[5,0.5],[6,0.6],[7,0.7],[8,0.8],[9,0.9],[10,1],[11,1.01],[12,1.02],[13,1.03],[14,1.04]];\r\n";
+    //httpContent += "var x_min = -0.5, x_max =  14.5, y_min = -0.5, y_max =  1.5;\r\n";
+    sprintf(buffer, "var x_min = %f, x_max = %f, y_min = %f, y_max = %f;\r\n", x_min, x_max, y_min, y_max);
+    httpContent += buffer;
+    //httpContent += "var array_value = [[-0.1,0.1],[2,0.2],[3,0.3],[4,0.4],[5,0.5],[6,0.6],[7,0.7],[8,0.8],[9,0.9],[10,1],[11,1.01],[12,1.02],[13,1.03],[14,1.04]];\r\n";
+    if(Sample > NB_SAMPLES)
+    {
+     httpContent += "var array_value = [";
+     for(i = 0 ; i < NB_SAMPLES ; i++)
+     {
+      sprintf(buffer, "[%f,%f],", time_samples[i], adc_samples[i]);
+      httpContent += buffer;
+     }
+     httpContent += "];\r\n";
+    }
+    Sample++;
     httpContent += "</script>\r\n";
  // Fin Variable JavaScript
     httpContent += "</HEAD><BODY>\r\n";
@@ -241,8 +272,7 @@
     }
 
     httpContent += "  <a href=\".\">[refresh status]</a>\r\n";
-    httpContent += "</pre>\r\n";
-    httpContent += "<hr>\r\n";
+    httpContent += "</pre>\r\n<hr>\r\n";
     
     httpContent += "</BODY></HTML>";
     //-----------
@@ -274,6 +304,7 @@
  
  // Init the ticker with the address of the function (add_one_second) to be attached and the interval (100 ms)
  second_ticker.attach(&add_one_second, 0.1);
+ k = (float)__Temp_between_measurements_in_Second__ / (float)NB_SAMPLES;
  //-----------------      
     UIPEthernet.begin(MY_MAC,MY_IP);
     myServer.begin();