-
Notifications
You must be signed in to change notification settings - Fork 0
/
PAGE_FabFarmer.h
146 lines (121 loc) · 10.6 KB
/
PAGE_FabFarmer.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#ifndef PAGE_FabFarmer_H
#define PAGE_FabFarmer_H
//
// The FabFarmer PAGE
//
const char PAGE_FabFarmer[] PROGMEM = R"=====(
<!DOCTYPE html>
<html lang="de">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="style.css" rel="stylesheet" type="text/css" />
<title>FabFarmer - FabLab Bayreuth</title>
</head>
<body bgcolor="#F3E2A9">
<img align="middle" width="341" height="125" alt="FabFarmer Logo" src="data:image/gif;base64,R0lGODlhVQF9APcAAAAAABoaGjMzM01NTWZmZoCAgJmZmbOzs8zMzObm5v///wAA/wAz/wBm/wCZ/wDM/wD//wD/zAD/mQD/ZgD/MwD/ADP/AGb/AJn/AMz/AP//AP/MAP+ZAP9mAP8zAP8AAP8AM/8AZv8Amf8AzP8A/zMAZjMzZjNmZjOZZjPMZjP/ZpnMZpmZZplmZpkzZpkAZgAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBmAABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/MwD/ZgD/mQD/zAD//zMAADMAMzMAmTMAzDMA/zMzADMzMzMzmTMzzDMz/zNmADN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UQwioQxeqww4pKympS/8oTlYUCLLtCbORNc/VX/ygQRXNFsQMRRSYLsfWKsms0rT1VSAkQRSkkq2Q1VhQlOTb0BUrbqvZqrSR7SknLsiibsjpBqqlEREjbA3nSq1/gsq9aKQ9LRHskq4ClRr2KAk7jquzKRv3aSQIBrLu6qkwrsk4LsSXbq1NLtc5qrbaESgRbRH81OTRrsxXrRVH0Rd7aqm47rq9aWdlar/kqEESUqv3wrOEat63AWCFLrHXbsP2aqafKrHqbEgFbnXh7CIGrAIVkCOqKPasxrauaAA37S4tbQ6+KSgcwU980uQNRRI7ruK57qlvbuQ/bryfrr6N7E6ULsWSlrn91rJvaq6faIHpEUZC0rmbrqsD0sU5RhEO8+7Y0tbpWi6qoFLtPa7z9KrrJaxLLK7RQG0mrigJ7dKpyVbz9QEQoQLaG0Ca1Wq9I+7V2e78RC74pFLq9WrOc9AUGe745u6xXFBAAOw==">
<br><br>
<div id="mydynamicdata">Die Bodenfeuchte wird ausgelesen!</div> <!-- added a DIV, where the dynamic data goes to -->
<div style="max-width: 100%;">
<canvas id="moisture" width="341" height="200"></canvas>
</div>
<table width="341">
<tr><td colspan="2"><hr></span></td></tr>
<tr><td align="right">Zeit:</td><td><span id="x_ntpt"></span></td></tr>
<tr><td align="right">Datum:</td><td><span id="x_ntpd"></span></td></tr>
</table>
<span style="visibility: hidden;" id="x_data"></span>
<script src="microajax.js"></script>
<script src="chart.min.js"></script>
<script>
var ctx = document.getElementById("moisture").getContext("2d");
ctx.canvas.originalwidth = ctx.canvas.width;
ctx.canvas.originalheight = ctx.canvas.height;
function loadData() {
setValues("/admin/filldynamicdata", function() {
ctx.canvas.width = ctx.canvas.originalwidth;
ctx.canvas.height = ctx.canvas.originalheight;
var dataString = document.getElementById('x_data').innerHTML;
var items = dataString.split(',');
var labels = [];
var moistureArray = [];
var index;
for(index = 0; index < items.length; ++index) {
var elements = items[index].split(';');
labels[index] = elements[0];
moistureArray[index] = elements[1];
}
var data = {
labels: labels,
datasets: [
{
label: 'Feuchte in %',
data: moistureArray,
backgroundColor: 'rgba(55, 105, 29, 0.2)',
borderColor: 'rgba(55, 105, 29, 1)',
borderWidth: 1
}
]
};
var chart = new Chart(ctx, { type: 'line', data: data, options: { animation: false, responsive: false, lineTension: 0 } });
}); //-- this function calls the function on the ESP
setTimeout(loadData, 60000);
}
window.onload = function ()
{
loadData();
}
</script>
</body>
</html>
)=====";
#endif
//
// FILL WITH INFOMATION
//
void filldynamicdata(AsyncWebServerRequest *request)
{
char buffer[50];
String values = "";
values += "mydynamicdata|Die aktuelle Bodenfeuchte ist " + (String) Sens_Value + "%|div\n"; // Build a string, like this: ID|VALUE|TYPE
sprintf(buffer, "x_ntpt|%02d:%02d:%02d|div\n", DateTime.hour, DateTime.minute, DateTime.second);
values += buffer;
sprintf(buffer, "x_ntpd|%02d.%02d.%04d|div\n", DateTime.day, DateTime.month, DateTime.year);
values += buffer;
values += "x_data|";
values += db.getCommaSeparatedValues();
values += "|div\n";
request->send(200, "text/plain", values);
}
void handleNotFound(AsyncWebServerRequest *request) {
String message = F("File Not Found\n\n");
message += F("URI: ");
message += request->url();
message += F("\nMethod: ");
message += (request->method() == HTTP_GET) ? "GET" : "POST";
message += F("\nArguments: ");
message += request->args();
message += F("\n");
for (uint8_t i = 0; i < request->args(); i++) {
message += String(F(" ")) + request->argName(i) + F(": ") + request->arg(i) + F("\n");
}
AsyncWebServerResponse* response = request->beginResponse(404, "text/plain", message);
response->addHeader("Cache-Control", "no-cache, no-store, must-revalidate");
response->addHeader("Pragma", "no-cache");
response->addHeader("Expires", "-1");
request->send(response);
}
void processFabFarmer(AsyncWebServerRequest *request)
{
if (request->args() > 0 ) // Are there any POST/GET Fields ?
{
for ( uint8_t i = 0; i < request->args(); i++ ) { // Iterate through the fields
if (request->argName(i) == "firstname")
{
// Your processing for the transmitted form-variable
String fName = request->arg(i);
}
}
}
request->send_P(200, "text/html", PAGE_FabFarmer);
}