diff --git a/platformio/stima_v3/stimawifi/src/stimawifi.ino b/platformio/stima_v3/stimawifi/src/stimawifi.ino index 01e9edc24..3ad3f7839 100644 --- a/platformio/stima_v3/stimawifi/src/stimawifi.ino +++ b/platformio/stima_v3/stimawifi/src/stimawifi.ino @@ -28,7 +28,7 @@ https://doc.rmap.cc/stima_wifi/stimawifi_v3/stima_wifi_howto.html#software */ #include "stimawifi.h" - +#include "web_resources.h" void print_reset_reason() { @@ -333,110 +333,78 @@ String Geo(){ return "KO"; } -// function to prepare HTML response -//https://lastminuteengineers.com/esp8266-dht11-dht22-web-server-tutorial/ - -String Data(){ - String str ="

StimaWifi Report

\n" - "
\n" - "
\n" - "\n" - "\n" - "\n" - "
\n" - "
Temperature
\n" - "
"; - str +=summarydata.temperature; - str +="°C
\n" - "
\n" - "
\n" - "
\n" - "\n" - "\n" - "\n" - "
\n" - "
Humidity
\n" - "
"; - str +=summarydata.humidity; - str +="%
\n" - "
\n" - - "
\n" - "
PM2.5
\n" - "
"; - str +=summarydata.pm2; - str +="ug/m3
\n" - "
\n" - - "
\n" - "
PM10
\n" - "
"; - str +=summarydata.pm10; - str +="ug/m3
\n" - "
\n" - - "
\n" - "
CO2
\n" - "
"; - str +=summarydata.co2; - str +="ppm
\n" - "
\n"; - - return str; -} // function to prepare HTML response main page // https://lastminuteengineers.com/esp8266-dht11-dht22-web-server-tutorial/ -String FullPage(){ - String ptr = " \n" - "\n" - "\n" - "StimaWiFI Report\n" - "\n" - "\n" - "\n" - "\n" - - "
\n"; - - ptr +=Data(); - - ptr +="
\n" - "\n" - "\n"; - return ptr; +String FullPage() { + return F("\n" +" \n" +" \n" +" StimaWiFI Report\n" +" \n" +" \n" +"\n" +"\n" +"

StimaWifi Report

\n" +"
\n" +"

Not Connected

\n" +"
--
\n" +"
--
\n" +"
--
\n" +"
--
\n" +"
--
\n" +"
\n"); } @@ -445,11 +413,6 @@ void handle_FullPage() { webserver.send(200, "text/html", FullPage()); } -// web server response callback function -void handle_Data() { - webserver.send(200, "text/html", Data()); -} - // web server response callback function void handle_Json() { webserver.sendHeader("Access-Control-Allow-Origin", "*", true); @@ -1615,7 +1578,6 @@ void setup() { // setup web server webserver.enableDelay(false); webserver.on("/", handle_FullPage); - webserver.on("/data", handle_Data); webserver.on("/data.json", handle_Json); webserver.on("/geo", handle_Geo); webserver.on("/archive.dat", handle_Archive); diff --git a/platformio/stima_v3/stimawifi/src/web_resources.cpp b/platformio/stima_v3/stimawifi/src/web_resources.cpp new file mode 100644 index 000000000..8f1d604e0 --- /dev/null +++ b/platformio/stima_v3/stimawifi/src/web_resources.cpp @@ -0,0 +1,89 @@ +#include "web_resources.h" + +// svg url encoder -> https://mothereff.in/url + +// this file contains resources (in data uri format) used +// to compose the htmtl pages reachable at the +// http://.local url + +namespace web_resources { + + +// Temperature icon (SVG) +const char icn_tmp[] = "data:image/svg+xml," + "%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E" + "%3Cpath fill='%23fff' " + "d='M10.72 2.82c.331-.29.77-.439 1.205-.462a1.99 1.99 0 0 1 " + "1.8.999c.207.35.275.763.272 1.166-.005 2.967.009 5.934-.007 " + "8.902a4.44 4.44 0 0 1 2.017 2.184 4.37 4.37 0 0 1 .055 3.237 " + "4.34 4.34 0 0 1-1.996 2.275 4.353 4.353 0 0 1-5.963-1.889c-" + ".437-.867-.55-1.88-.362-2.83a4.4 4.4 0 0 1 2.262-2.975c.012-" + "3.016 0-6.033.006-9.05a1.98 1.98 0 0 1 .711-1.557' " + "style='fill:%23fff;stroke:none;'/%3E%3C/svg%3E"; + +// Humidity icon (SVG) +const char icn_hum[] = "data:image/svg+xml," + "%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E" + "%3Cpath fill='%23fff' " + "d='M7.319 9.24c1.32-2.154 4.68-6.217 4.68-6.217s3.364 4.063 " + "4.682 6.217c1.793 2.925 2.133 5.05 1.57 7.057-.437 1.574-" + "2.263 4.68-6.251 4.68s-5.813-3.106-6.252-4.68c-.561-2.007-" + ".222-4.131 1.57-7.057z'/%3E%3C/svg%3E"; + +// Particulate matter icon (SVG) +const char icn_pmx[] = "data:image/svg+xml," + "%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E" + "%3Ccircle cx='6.137' cy='7.393' r='2.046' fill='%23FFF'/%3E" + "%3Ccircle cx='12.405' cy='8.294' r='.901' fill='%23FFF'/%3E" + "%3Ccircle cx='16.099' cy='15.295' r='2.292' fill='%23FFF'/%3E" + "%3Ccircle cx='19.66' cy='11.266' r='.77' fill='%23FFF'/%3E" + "%3Ccircle cx='9.526' cy='14.805' r='1' fill='%23FFF'/%3E" + "%3Ccircle cx='4.786' cy='13.165' r='.851' fill='%23FFF'/%3E" + "%3Ccircle cx='6.4' cy='17.357' r='.263' fill='%23FFF'/%3E" + "%3Ccircle cx='15.76' cy='10.458' r='.263' fill='%23FFF'/%3E" + "%3C/svg%3E"; + +// CO2 icon (SVG) +const char icn_co2[] = "data:image/svg+xml," + "%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E" + "%3Cpath fill='%23fff' " + "d='M5.684 14.717a7.7 7.7 0 0 1-1.4-.106q-.563-.117-.914-.371" + "a1.66 1.66 0 0 1-.53-.69 4 4 0 0 1-.234-1.062 15 15 0 0 1-" + ".064-1.507q0-.87.064-1.497.064-.636.234-1.061.18-.435.53-" + ".69.35-.265.913-.372.562-.116 1.401-.116.33 0 .68.032.36 " + ".021.679.063.33.043.563.096v1.507l-.648-.053a22 22 0 0 0-" + ".446-.032 5.4 5.4 0 0 0-1.008.032.9.9 0 0 0-.435.149.67.67 " + "0 0 0-.234.35 3 3 0 0 0-.085.626q-.01.383-.01.966 0 .585 " + ".01.977.021.382.085.615a.67.67 0 0 0 .234.35q.158.117.435." + "16.276.031.7.032.33 0 .733-.022.414-.031.711-.074v1.528q-" + ".234.043-.573.085-.33.043-.69.064t-.7.021m6.082 0q-.944 0-" + "1.55-.106-.594-.117-.933-.371-.34-.255-.489-.69t-.19-1.062" + "a31 31 0 0 1-.032-1.507q0-.87.031-1.497.043-.636.191-1.072" + ".15-.435.489-.69t.934-.36q.605-.117 1.55-.117.944 0 1.539." + "116.605.107.944.361.34.255.489.69t.19 1.072q.043.627.043 " + "1.497t-.042 1.507a4.2 4.2 0 0 1-.191 1.062q-.15.435-.489." + "69-.34.254-.944.371-.595.105-1.54.106m0-1.602q.298 0 .478-" + ".022a.6.6 0 0 0 .297-.127.6.6 0 0 0 .149-.33q.053-.233.064-" + ".625.02-.404.02-1.03t-.02-1.019a3.2 3.2 0 0 0-.064-.626q-" + ".042-.234-.149-.33a.48.48 0 0 0-.297-.127 3 3 0 0 0-.478-" + ".032q-.296 0-.488.032a.47.47 0 0 0-.286.128q-.106.095-.16." + "329a4 4 0 0 0-.053.626q-.01.393-.01 1.019t.01 1.03q.01.392 " + ".053.626a.7.7 0 0 0 .16.329q.106.096.286.127.192.021.488." + "022'/%3E" + "%3Cpath fill='%23fff' " + "d='M15.991 16.755v-1.061q0-.594.021-1.03.033-.446.138-.764." + "106-.319.34-.541.233-.233.647-.404l1.55-.626q.265-.105.393-" + ".191a.36.36 0 0 0 .16-.212q.03-.128.031-.372 0-.265-.085-" + ".382-.086-.127-.308-.16a3.6 3.6 0 0 0-.626-.042q-.234 0-" + ".573.022-.34.02-.743.053-.393.031-.796.085V9.612q.36-.075 " + ".817-.128.456-.052.934-.085.478-.03.892-.031.551 0 1.03." + "074.487.063.86.276.37.212.572.626.213.403.213 1.093t-.149 " + "1.126a1.5 1.5 0 0 1-.403.668q-.266.244-.616.382l-1.74.68q-" + ".182.063-.287.138-.106.063-.149.17-.032.106-.032.286v.234h" + "3.376v1.634z'/%3E%3C/svg%3E"; + +// empty favicon link useful to avoid the favicon requests +// by browsers connecting to the station +const char favicon[] = ""; + +} // namespace web_resources \ No newline at end of file diff --git a/platformio/stima_v3/stimawifi/src/web_resources.h b/platformio/stima_v3/stimawifi/src/web_resources.h new file mode 100644 index 000000000..32108adff --- /dev/null +++ b/platformio/stima_v3/stimawifi/src/web_resources.h @@ -0,0 +1,14 @@ +#ifndef WEB_RESOURCES_H +#define WEB_RESOURCES_H + +namespace web_resources { + +extern const char icn_tmp[]; +extern const char icn_hum[]; +extern const char icn_pmx[]; +extern const char icn_co2[]; +extern const char favicon[]; + +} // namespace web_resources + +#endif // WEB_RESOURCES_H \ No newline at end of file