forked from ornea/slowcooker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpid_data_only.ino
39 lines (31 loc) · 1.71 KB
/
pid_data_only.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
void handle_pid_data_only()
{
START_HTML;
START_PAGE(AppConfig.EpHostname, " PID Data Only");
server.sendContent(F("<div id='main'>"
"easycook PID controller. <br>"
" ticks  , °C  , error , pTerm , ITerm , dTerm , CV ,  Millis  , %Hum, State"
"</div>"
"<div id='arrfieldoutputheadings'>"
"</div>"
"<div id='arrfieldoutputvalues'>"
"</div>"
"<script>"
"var i=0;var k=0;"
"var connection=new WebSocket('ws://'+location.hostname+':81/',['arduino']);"
"connection.onopen=function(){connection.send('Connect '+new Date());};"
"connection.onerror=function(error){console.log('WebSocket Error ',error);};"
"connection.onmessage=function(e){console.log('Server: ',e.data);"
"var msg=e.data;"
"if(msg.indexOf('"PID_DATA_PREAMBLE"') == 0){" //is the first char the preamble
"msg = msg.slice(1);"
"var arrmsg=msg.split(',');"
"var elements=document.getElementById('arrfieldoutputvalues');"
"var d = new Date();"
"elements.outerHTML += '<br>' + msg + d.toLocaleDateString() + ' ' + d.toLocaleTimeString();"
"}};"
"</script>"
"<br>"));
END_PAGE_CUSTOM;
END_PAGE;
}