-
Notifications
You must be signed in to change notification settings - Fork 3
/
PAGE_Default.h
109 lines (91 loc) · 3.5 KB
/
PAGE_Default.h
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#pragma once
#ifndef PAGE_EXAMPLE_H
#define PAGE_EXAMPLE_H
//
// The EXAMPLE PAGE
//
const char PAGE_example[] PROGMEM = R"=====(
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<h1>ESP12E Module / Thomas Hoeser 2017</h1>
<div id="mydynamicdata">DMX Channels: </div> <!-- added a DIV, where the dynamic data goes to -->
<script>
window.onload = function ()
{
load("style.css","css", function()
{
load("microajax.js","js", function()
{
setValues("/admin/filldynamicdata"); //-- this function calls the function on the ESP
});
});
}
function load(e,t,n){if("js"==t){var a=document.createElement("script");a.src=e,a.type="text/javascript",a.async=!1,a.onload=function(){n()},document.getElementsByTagName("head")[0].appendChild(a)}else if("css"==t){var a=document.createElement("link");a.href=e,a.rel="stylesheet",a.type="text/css",a.async=!1,a.onload=function(){n()},document.getElementsByTagName("head")[0].appendChild(a)}}
</script>
)=====";
#endif
void filldynamicdata()
{
int iLedRed = -1;
int iLedGreen = -1;
int iLedBlue = -1;
int iLedRed2 = -1;
int iErrPckt = 0;
int iErrSqc = 0;
if(udpPacketCount>0)
{
iLedRed = e131.data[DMX_RED ];
iLedGreen = e131.data[DMX_GREEN ];
iLedBlue = e131.data[DMX_BLUE ];
iLedRed2 = e131.data[DMX_RED2 ];
iErrPckt = e131.stats.packet_errors;
iErrSqc = e131.stats.sequence_errors;
}
String values ="";
values += "mydynamicdata|";
values += "firmware : " + (String) config.Firmware;
values += "<br>"; // Build a string, like this: ID|VALUE|TYPE
values += "Unit : " + (String) config.DeviceName;
values += "<br>"; // Build a string, like this: ID|VALUE|TYPE
values += "Module : " + (String) config.moduleNum;
values += "<br>"; // Build a string, like this: ID|VALUE|TYPE
values += "DMX Ch : " + (String) dmxStartChannel;
values += "<br>";
values += "<br>";
values += "Status : " + (String) esp_status;
values += "<br>";
values += "WLAN : " + (String) rssi_percent;
values += "%";
values += " - " + (String) rssi_value;
values += "db";
values += "<br>";
values += "BATT : " + (String) uiVoltLevel;
values += "%";
values += " - " + (String) fVoltLipo;
values += "V";
values += "<br>";
values += "<br>"; // Build a string, like this: ID|VALUE|TYPE
values += "RED : " + (String) iLedRed;
values += "<br>"; // Build a string, like this: ID|VALUE|TYPE
values += " GREEN : " + (String) iLedGreen;
values += "<br>"; // Build a string, like this: ID|VALUE|TYPE
values += " BLUE : " + (String) iLedBlue;
values += "|div\n"; // Build a string, like this: ID|VALUE|TYPE
// DEBUGGING(values);
// values += "mydynamicdata|" + (String) + "This is filled by AJAX. Millis since start: " + (String) millis() + "|div\n"; // Build a string, like this: ID|VALUE|TYPE
server.send ( 200, "text/plain", values);
}
void processExample()
{
if (server.args() > 0 ) // Are there any POST/GET Fields ?
{
for ( uint8_t i = 0; i < server.args(); i++ ) { // Iterate through the fields
if (server.argName(i) == "firstname")
{
// Your processing for the transmitted form-variable
String fName = server.arg(i);
}
}
}
server.send ( 200, "text/html", PAGE_example );
}