#define num_datasets 720 struct wp { bool isactive; int8_t state; int powhist; int fpowhist; #if defined has_ntp int8_t hour; #endif }; wp wp_arr[num_datasets]; uint16_t datasetpt = 0; #if defined has_ntp void storewp(int inp, int finp, int8_t state, int8_t hour) { wp_arr[datasetpt].hour = hour; #else void storewp(int inp, int finp, int8_t state) { #endif wp_arr[datasetpt].isactive = true; wp_arr[datasetpt].state = state; wp_arr[datasetpt].powhist = inp; wp_arr[datasetpt].fpowhist = finp; datasetpt++; if (datasetpt >= num_datasets) datasetpt = 0; } void handleCmd() { String out; char HItemp[10]; char LOtemp[10]; for (uint8_t i = 0; i < server.args(); i++) { if (server.argName(i) == "on") { IsActive = true; WPstate = 0; } else if (server.argName(i) == "of") { IsActive = false; WPtimer = 5; } else if (server.argName(i) == "u100") HIlimit = 100; else if (server.argName(i) == "u200") HIlimit = 200; else if (server.argName(i) == "l400") LOlimit = -400; else if (server.argName(i) == "l500") LOlimit = -500; } out += "

\n"; sprintf(HItemp,"%d",HIlimit); out += "Hi limit "; out += HItemp; out += " \n"; if (IsActive) out += "\n"; else out += "\n"; out += " \n"; sprintf(LOtemp,"%d",LOlimit); out += "Lo limit "; out += LOtemp; out += "

\n"; out += "\n"; out += " \n"; out += "\n"; out += "

\n"; out += "\n"; out += " \n"; out += "\n"; out += "

\n"; /* else if (server.argName(i) == "HIlim") HIlimit = server.arg(i).toInt(); else if (server.argName(i) == "LOlim") LOlimit = server.arg(i).toInt(); out += "

\n"; out += "
\n"; out += "Manual: \n"; out += " \n"; out += " \n"; out += "
\n"; out += "
\n"; */ out += "Back\n"; out += "
"; server.send(200, "text/html", out); } void getGraph() { String out; out = "\n"; out += "\n"; out += "\n"; out += "WPcontrol\n"; out += "\n"; out += "
\n"; out += "

WP Control

\n"; out += "Config \n"; out += "Upload

\n"; out += "\n"; out += "
\n"; out += "\n"; server.send(200, "text/html", out); } void handleNotFound() { server.send(404, "text/plain", "Not Here"); } int8_t oldstate = 0; #define fullH 300 #define halfH 150 #define Hfact 0.15 void drawGraph() { String out; out.reserve(2000); uint8_t oldwp = 0; int oldi = 0; int8_t oldhour = -1; out += "\n"; out += "\n"; out += "\n"; { char temp[100]; int linenum; linenum = halfH - (float)HIlimit*Hfact; sprintf(temp,"\n",linenum,linenum); out += temp; linenum = halfH - (float)LOlimit*Hfact; sprintf(temp,"\n",linenum,linenum); out += temp; } for (int i=0;i= num_datasets) pos -= num_datasets; #if defined has_ntp newhour = wp_arr[pos].hour; if ((newhour != oldhour) && (oldhour >= 0)) { char temp[100]; if ((newhour == 12) || (newhour == 0)) // 12, 24 { sprintf(temp,"\n",10+i,10+i); out += temp; } else if ((newhour == 6) || (newhour == 18)) // 6, 18 { sprintf(temp,"\n",10+i,10+i); out += temp; } else { sprintf(temp,"\n",10+i,10+i); out += temp; } } oldhour = newhour; #endif newstate = wp_arr[pos].state; if (newstate != oldstate) { char temp[100]; if (newstate > 0) { sprintf(temp,"\n",10+i,10+i); out += temp; } else if (newstate < 0) { sprintf(temp,"\n",10+i,10+i); out += temp; } } oldstate = newstate; } out += "= num_datasets) pos -= num_datasets; int powdata = (float)wp_arr[pos].powhist*Hfact; if (wp_arr[pos].isactive) { sprintf(temp,"%d,%d ",10+i,halfH-powdata); out += temp; } } out += "\" fill=\"none\" stroke=\"red\" />\n"; out += "= num_datasets) pos -= num_datasets; int powdata = (float)wp_arr[pos].fpowhist*Hfact; if (wp_arr[pos].isactive) { sprintf(temp,"%d,%d ",10+i,halfH-powdata); out += temp; } } out += "\" fill=\"none\" stroke=\"blue\" />\n"; out += "\n"; server.send(200, "image/svg+xml", out); }