SHOW:
|
|
- or go back to the newest paste.
1 | void WebServer() | |
2 | { | |
3 | WiFiClient client = server.available(); // Listen for incoming clients | |
4 | if (client) | |
5 | { // If a new client connects, | |
6 | //Serial.println("New Client."); // print a message out in the serial port | |
7 | String currentLine = ""; // make a String to hold incoming data from the client | |
8 | currentTime = millis(); | |
9 | previousTime = currentTime; | |
10 | while (client.connected() && currentTime - previousTime <= timeoutTime) | |
11 | { // loop while the client's connected | |
12 | currentTime = millis(); | |
13 | if (client.available()) | |
14 | { // if there's bytes to read from the client, | |
15 | char c = client.read(); // read a byte, then | |
16 | Serial.write(c); // print it out the serial monitor | |
17 | header += c; | |
18 | if (c == '\n') | |
19 | { // if the byte is a newline character | |
20 | // if the current line is blank, you got two newline characters in a row. | |
21 | // that's the end of the client HTTP request, so send a response: | |
22 | if (currentLine.length() == 0) | |
23 | { | |
24 | // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK) | |
25 | // and a content-type so the client knows what's coming, then a blank line: | |
26 | client.println("HTTP/1.1 200 OK"); | |
27 | client.println("Content-type:text/html"); | |
28 | client.println("Connection: close"); | |
29 | client.println(); | |
30 | ||
31 | // Defing redirections | |
32 | if (header.indexOf("GET /forcentp") >= 0) | |
33 | { | |
34 | NTPtime(); | |
35 | } | |
36 | if (header.indexOf("GET /hred") >= 0) | |
37 | { | |
38 | colorH = 0xff0000; // | |
39 | color_H = "Red"; | |
40 | Show(); | |
41 | } | |
42 | if (header.indexOf("GET /hgreen") >= 0) | |
43 | { | |
44 | colorH = 0x00ff00; // | |
45 | color_H = "Green"; | |
46 | Show(); | |
47 | } | |
48 | if (header.indexOf("GET /hblue") >= 0) | |
49 | { | |
50 | colorH = 0x0000ff; | |
51 | color_H = "Blue"; | |
52 | Show(); | |
53 | } | |
54 | if (header.indexOf("GET /hgreygreen") >= 0) | |
55 | { | |
56 | colorH = 0x4d6b53; // GreyGreen | |
57 | color_H = "GreyGreen"; | |
58 | Show(); | |
59 | } | |
60 | if (header.indexOf("GET /hgold") >= 0) | |
61 | { | |
62 | colorH = 0xffd700; // Gold | |
63 | color_H = "Gold"; | |
64 | Show(); | |
65 | } | |
66 | ||
67 | if (header.indexOf("GET /kred") >= 0) | |
68 | { | |
69 | colorK = 0xff0000; // | |
70 | color_K = "Red"; | |
71 | Show(); | |
72 | } | |
73 | if (header.indexOf("GET /kgreen") >= 0) | |
74 | { | |
75 | colorK = 0x00ff00; // | |
76 | color_K = "Green"; | |
77 | Show(); | |
78 | } | |
79 | if (header.indexOf("GET /kblue") >= 0) | |
80 | { | |
81 | colorK = 0x0000ff; | |
82 | color_K = "Blue"; | |
83 | Show(); | |
84 | } | |
85 | if (header.indexOf("GET /kgreygreen") >= 0) | |
86 | { | |
87 | colorK = 0x4d6b53; // GreyGreen | |
88 | color_K = "GreyGreen"; | |
89 | Show(); | |
90 | } | |
91 | if (header.indexOf("GET /kgold") >= 0) | |
92 | { | |
93 | colorK = 0xffd700; // Gold | |
94 | color_K = "Gold"; | |
95 | Show(); | |
96 | } | |
97 | if (header.indexOf("GET /kwhite") >= 0) | |
98 | { | |
99 | colorK = 0xffffff; // White | |
100 | color_K = "White"; | |
101 | Show(); | |
102 | } | |
103 | ||
104 | if (header.indexOf("GET /mred") >= 0) | |
105 | { | |
106 | colorM = 0xff0000; // | |
107 | color_M = "Red"; | |
108 | Show(); | |
109 | } | |
110 | if (header.indexOf("GET /mgreen") >= 0) | |
111 | { | |
112 | colorM = 0x00ff00; // | |
113 | color_M = "Green"; | |
114 | Show(); | |
115 | } | |
116 | if (header.indexOf("GET /mblue") >= 0) | |
117 | { | |
118 | colorM = 0x0000ff; | |
119 | color_M = "Blue"; | |
120 | Show(); | |
121 | } | |
122 | if (header.indexOf("GET /mgreygreen") >= 0) | |
123 | { | |
124 | colorM = 0x4d6b53; // GreyGreen | |
125 | color_M = "GreyGreen"; | |
126 | Show(); | |
127 | } | |
128 | if (header.indexOf("GET /mgold") >= 0) | |
129 | { | |
130 | colorM = 0xffd700; // Gold | |
131 | color_M = "Gold"; | |
132 | Show(); | |
133 | } | |
134 | if (header.indexOf("GET /sred") >= 0) | |
135 | { | |
136 | colorS = 0xff0000; // | |
137 | color_S = "Red"; | |
138 | Show(); | |
139 | } | |
140 | if (header.indexOf("GET /sgreen") >= 0) | |
141 | { | |
142 | colorS = 0x00ff00; // | |
143 | color_S = "Green"; | |
144 | Show(); | |
145 | } | |
146 | if (header.indexOf("GET /sblue") >= 0) | |
147 | { | |
148 | colorS = 0x0000ff; | |
149 | color_S = "Blue"; | |
150 | Show(); | |
151 | } | |
152 | if (header.indexOf("GET /sgreygreen") >= 0) | |
153 | { | |
154 | colorS = 0x4d6b53; // GreyGreen | |
155 | color_S = "GreyGreen"; | |
156 | Show(); | |
157 | } | |
158 | if (header.indexOf("GET /sgold") >= 0) | |
159 | { | |
160 | colorS = 0xffd700; // Gold | |
161 | color_S = "Gold"; | |
162 | Show(); | |
163 | } | |
164 | if (header.indexOf("GET /swhite") >= 0) | |
165 | { | |
166 | colorS = 0xffffff; // White | |
167 | color_S = "White"; | |
168 | Show(); | |
169 | } | |
170 | if (header.indexOf("GET /mwhite") >= 0) | |
171 | { | |
172 | colorM = 0xffffff; // White | |
173 | color_M = "White"; | |
174 | Show(); | |
175 | } | |
176 | if (header.indexOf("GET /hwhite") >= 0) | |
177 | { | |
178 | colorH = 0xffffff; // White | |
179 | color_H = "White"; | |
180 | Show(); | |
181 | } | |
182 | if (header.indexOf("GET /seth") >= 0) | |
183 | { | |
184 | old_mode = clock_mode; | |
185 | FastLED.clear(); | |
186 | clock_mode = 4; | |
187 | } | |
188 | if (header.indexOf("GET /setm") >= 0) | |
189 | { | |
190 | old_mode = clock_mode; | |
191 | FastLED.clear(); | |
192 | clock_mode = 5; | |
193 | } | |
194 | if (header.indexOf("GET /sets") >= 0) | |
195 | { | |
196 | old_mode = clock_mode; | |
197 | FastLED.clear(); | |
198 | clock_mode = 6; | |
199 | } | |
200 | if (header.indexOf("GET /done") >=0) | |
201 | { | |
202 | done(); | |
203 | } | |
204 | if (header.indexOf("GET /watchdog") >= 0) | |
205 | { | |
206 | feedDog(); | |
207 | } | |
208 | if (header.indexOf("GET /secson") >= 0) | |
209 | { | |
210 | effectThree(); | |
211 | old_mode = clock_mode; | |
212 | clock_mode = 0; | |
213 | } | |
214 | if (header.indexOf("GET /blink") >= 0) | |
215 | { | |
216 | effectThree(); | |
217 | old_mode = clock_mode; | |
218 | clock_mode = 12; | |
219 | } | |
220 | if (header.indexOf("GET /secsoff") >= 0) | |
221 | { | |
222 | effectOne(); | |
223 | old_mode = clock_mode; | |
224 | for (int i = 0; i < (sizeof(allSecs)); i++) | |
225 | { | |
226 | leds[allSecs[i]] = CRGB::Black; | |
227 | } | |
228 | clock_mode = 1; | |
229 | } | |
230 | if (header.indexOf("GET /brplus") >= 0) // | |
231 | { | |
232 | bright = bright + 5; | |
233 | Serial.println(bright); | |
234 | FastLED.setBrightness(bright); | |
235 | } | |
236 | if (header.indexOf("GET /brmin") >= 0) // | |
237 | { | |
238 | bright = bright - 5; | |
239 | Serial.println(bright); | |
240 | FastLED.setBrightness(bright); | |
241 | } | |
242 | ||
243 | if (header.indexOf("GET /summer") >= 0) | |
244 | { | |
245 | dls = 1; | |
246 | timeClient.setTimeOffset(7200); // Set offset time in seconds to adjust for your timezone, for example: GMT +1 = 3600, GMT -1 = -3600 | |
247 | NTPtime(); | |
248 | } | |
249 | if (header.indexOf("GET /winter") >= 0) | |
250 | { | |
251 | dls = 0; | |
252 | timeClient.setTimeOffset(3600); // Set offset time in seconds to adjust for your timezone, for example: GMT +1 = 3600, GMT -1 = -3600 | |
253 | NTPtime(); | |
254 | } | |
255 | if (header.indexOf("GET /erroron") >= 0) | |
256 | { | |
257 | effectThree(); | |
258 | old_mode = clock_mode; | |
259 | clock_mode = 2; | |
260 | } | |
261 | if (header.indexOf("GET /erroroff") >= 0) | |
262 | { | |
263 | effectOne(); | |
264 | /* | |
265 | for (int i = 0; i < (sizeof(err)); i++) | |
266 | { | |
267 | leds[err[i]] = CRGB::Black; | |
268 | } | |
269 | */ | |
270 | clock_mode = old_mode; | |
271 | //NTPtime(); | |
272 | } | |
273 | if (header.indexOf("GET /showip") >= 0) | |
274 | { | |
275 | old_mode = clock_mode; | |
276 | counter = 0; | |
277 | effectThree(); | |
278 | //showip(); | |
279 | clock_mode = 3; | |
280 | } | |
281 | if (header.indexOf("GET /test") >= 0) | |
282 | { | |
283 | old_mode = clock_mode; | |
284 | effectThree(); | |
285 | clock_mode = 9; | |
286 | } | |
287 | /* | |
288 | if (header.indexOf("GET /border") >= 0) | |
289 | { | |
290 | old_mode = clock_mode; | |
291 | effectThree(); | |
292 | clock_mode = 10; | |
293 | } | |
294 | */ | |
295 | if (header.indexOf("GET /date") >= 0) | |
296 | { | |
297 | old_mode = clock_mode; | |
298 | effectOne(); | |
299 | clock_mode = 10; | |
300 | } | |
301 | ||
302 | if (header.indexOf("GET /time") >= 0) | |
303 | { | |
304 | old_mode = clock_mode; | |
305 | effectOne(); | |
306 | clock_mode = 13; | |
307 | } | |
308 | ||
309 | if (header.indexOf("GET /nightHr-") >= 0) | |
310 | { | |
311 | nightHr --; | |
312 | if (nightHr < 0) | |
313 | { | |
314 | nightHr = 23; | |
315 | } | |
316 | } | |
317 | if (header.indexOf("GET /nightHr+") >= 0) | |
318 | { | |
319 | nightHr ++; | |
320 | if (nightHr > 23) | |
321 | { | |
322 | nightHr = 0; | |
323 | } | |
324 | } | |
325 | if (header.indexOf("GET /nightMin-") >= 0) | |
326 | { | |
327 | nightMin = nightMin - 15; | |
328 | if (nightMin <= -1) | |
329 | { | |
330 | nightMin = 45; | |
331 | } | |
332 | } | |
333 | if (header.indexOf("GET /nightMin+") >= 0) | |
334 | { | |
335 | nightMin = nightMin + 15; | |
336 | if (nightMin >= 59) | |
337 | { | |
338 | nightMin = 0; | |
339 | } | |
340 | } | |
341 | ||
342 | if (header.indexOf("GET /dayHr-") >= 0) | |
343 | { | |
344 | dayHr --; | |
345 | if (dayHr < 0) | |
346 | { | |
347 | dayHr = 23; | |
348 | } | |
349 | } | |
350 | if (header.indexOf("GET /dayHr+") >= 0) | |
351 | { | |
352 | dayHr ++; | |
353 | if (dayHr > 23) | |
354 | { | |
355 | dayHr = 0; | |
356 | } | |
357 | } | |
358 | if (header.indexOf("GET /dayMin-") >= 0) | |
359 | { | |
360 | dayMin = dayMin - 15; | |
361 | if (dayMin <= -1) | |
362 | { | |
363 | dayMin = 45; | |
364 | } | |
365 | } | |
366 | if (header.indexOf("GET /dayMin+") >= 0) | |
367 | { | |
368 | dayMin = dayMin + 15; | |
369 | if (dayMin >= 59) | |
370 | { | |
371 | dayMin = 0; | |
372 | } | |
373 | } | |
374 | ||
375 | if (header.indexOf("GET /hourplus") >= 0) | |
376 | { | |
377 | h = h + 1; | |
378 | } | |
379 | if (header.indexOf("GET /hourmin") >= 0) | |
380 | { | |
381 | h = h - 1; | |
382 | } | |
383 | if (header.indexOf("GET /minuteplus") >= 0) | |
384 | { | |
385 | m = m + 1; | |
386 | } | |
387 | if (header.indexOf("GET /minuteplus") >= 0) | |
388 | { | |
389 | m = m + 1; | |
390 | } | |
391 | if (header.indexOf("GET /titleoff") >= 0) | |
392 | { | |
393 | title = 0; | |
394 | } | |
395 | if (header.indexOf("GET /titleon") >= 0) | |
396 | { | |
397 | title = 1; | |
398 | } | |
399 | // color picker | |
400 | ||
401 | if (header.indexOf("GET /HOUR?r") >= 0) | |
402 | { | |
403 | pos1 = header.indexOf('r'); | |
404 | pos2 = header.indexOf('g'); | |
405 | pos3 = header.indexOf('b'); | |
406 | pos4 = header.indexOf('&'); | |
407 | redString = header.substring(pos1+1, pos2); | |
408 | greenString = header.substring(pos2+1, pos3); | |
409 | blueString = header.substring(pos3+1, pos4); | |
410 | re = redString.toInt(); | |
411 | gr = greenString.toInt(); | |
412 | bl = blueString.toInt(); | |
413 | Serial.print("R: "); | |
414 | Serial.println(re, HEX); | |
415 | Serial.print("G: "); | |
416 | Serial.println(gr, HEX); | |
417 | Serial.print("B: "); | |
418 | Serial.println(bl, HEX); | |
419 | String rgb = String(re, HEX) + String(gr, HEX) + String(bl, HEX); | |
420 | Serial.print("rgb: "); | |
421 | Serial.println(rgb); | |
422 | long RGB = (re << 16) | (gr << 8) | bl; | |
423 | Serial.print("RGB: "); | |
424 | Serial.println(RGB); | |
425 | colorH = RGB; | |
426 | Serial.print("colorH: "); | |
427 | Serial.println(colorH); | |
428 | } | |
429 | ||
430 | if (header.indexOf("GET /MIN?r") >= 0) | |
431 | { | |
432 | pos1 = header.indexOf('r'); | |
433 | pos2 = header.indexOf('g'); | |
434 | pos3 = header.indexOf('b'); | |
435 | pos4 = header.indexOf('&'); | |
436 | redString = header.substring(pos1+1, pos2); | |
437 | greenString = header.substring(pos2+1, pos3); | |
438 | blueString = header.substring(pos3+1, pos4); | |
439 | re = redString.toInt(); | |
440 | gr = greenString.toInt(); | |
441 | bl = blueString.toInt(); | |
442 | Serial.print("R: "); | |
443 | Serial.println(re, HEX); | |
444 | Serial.print("G: "); | |
445 | Serial.println(gr, HEX); | |
446 | Serial.print("B: "); | |
447 | Serial.println(bl, HEX); | |
448 | String rgb = String(re, HEX) + String(gr, HEX) + String(bl, HEX); | |
449 | Serial.print("rgb: "); | |
450 | Serial.println(rgb); | |
451 | long RGB = (re << 16) | (gr << 8) | bl; | |
452 | Serial.print("RGB: "); | |
453 | Serial.println(RGB); | |
454 | colorM = RGB; | |
455 | Serial.print("colorM: "); | |
456 | Serial.println(colorM); | |
457 | } | |
458 | ||
459 | if (header.indexOf("GET /SEC?r") >= 0) | |
460 | { | |
461 | pos1 = header.indexOf('r'); | |
462 | pos2 = header.indexOf('g'); | |
463 | pos3 = header.indexOf('b'); | |
464 | pos4 = header.indexOf('&'); | |
465 | redString = header.substring(pos1+1, pos2); | |
466 | greenString = header.substring(pos2+1, pos3); | |
467 | blueString = header.substring(pos3+1, pos4); | |
468 | re = redString.toInt(); | |
469 | gr = greenString.toInt(); | |
470 | bl = blueString.toInt(); | |
471 | Serial.print("R: "); | |
472 | Serial.println(re, HEX); | |
473 | Serial.print("G: "); | |
474 | Serial.println(gr, HEX); | |
475 | Serial.print("B: "); | |
476 | Serial.println(bl, HEX); | |
477 | String rgb = String(re, HEX) + String(gr, HEX) + String(bl, HEX); | |
478 | Serial.print("rgb: "); | |
479 | Serial.println(rgb); | |
480 | long RGB = (re << 16) | (gr << 8) | bl; | |
481 | Serial.print("RGB: "); | |
482 | Serial.println(RGB); | |
483 | colorS = RGB; | |
484 | Serial.print("colorS: "); | |
485 | Serial.println(colorS); | |
486 | } | |
487 | ||
488 | // color picker | |
489 | ||
490 | if(header.indexOf("GET /bright") >= 0) | |
491 | { | |
492 | pos1 = header.indexOf('t'); | |
493 | pos2 = header.indexOf('&'); | |
494 | valueString = header.substring(pos1+1, pos2); | |
495 | //Serial.println("Start:"); | |
496 | //Serial.println(pos1); // -1 | |
497 | //Serial.println(valueString); // 210 | |
498 | bright = valueString.toInt(); | |
499 | FastLED.setBrightness(bright); | |
500 | //Serial.println("Done."); | |
501 | } | |
502 | ||
503 | // Display the HTML web page | |
504 | client.println("<!DOCTYPE html><html>"); | |
505 | client.println("<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">"); | |
506 | client.println("<link rel=\"icon\" href=\"data:,\">"); | |
507 | //client.println("<link rel=\"stylesheet\" href=\"https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css\">"); | |
508 | client.println("<script src=\"https://cdnjs.cloudflare.com/ajax/libs/jscolor/2.0.4/jscolor.min.js\">"); | |
509 | //client.println("<script src=\"https://cdnjs.cloudflare.com/ajax/libs/jscolor/2.4.8/jscolor.min.js\">"); | |
510 | client.println("<style><input data-jscolor=\"{position:'top'}\"></style></script>"); //https://jscolor.com/examples/ | |
511 | // client.println("<style=\"position:absolute; left:280px; top:10px;\"> toHEXString = <span id=\"hex-str\"></span><br /> toRGBString = <span id=\"rgb-str\"></span><br /> R, G, B = <span id=\"rgb\"></span><br /> H, S, V = <span id=\"hsv\"></span>"); | |
512 | client.println("<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}"); | |
513 | client.println(".button { background-color: #195B6A; border: none; color: white; padding: 10px;"); | |
514 | client.println("text-decoration: none; font-size: 20px; margin: 2px; cursor: pointer; width: 100px; border-radius: 12px;}"); | |
515 | client.println(".button2 { background-color: #195B6A; border: none; color: black; padding: 10px;}"); | |
516 | client.println(".button3 { background-color: #FFFF00; border: none; color: black; padding: 10px;"); | |
517 | client.println("text-decoration: none; font-size: 20px; margin: 2px; cursor: pointer; height: 40px; width: 100px; border-radius: 12px;}"); | |
518 | client.println(".button4 { background-color: #0000FF; border: none; color: black; padding: 10px;"); | |
519 | client.println("text-decoration: none; font-size: 20px; margin: 2px; cursor: pointer; height: 40px; width: 100px; border-radius: 12px;}"); | |
520 | client.println(".button5 { background-color: #00FF00; border: none; color: black; padding: 10px;"); | |
521 | client.println("text-decoration: none; font-size: 20px; margin: 2px; cursor: pointer; height: 40px; width: 100px; border-radius: 12px;}"); | |
522 | client.println(".button6 { background-color: #FF0000; border: none; color: black; padding: 10px;"); | |
523 | client.println("text-decoration: none; font-size: 20px; margin: 2px; cursor: pointer; height: 40px; width: 100px; border-radius: 12px;}"); | |
524 | client.println(".button7 { background-color: #FFFFFF; border: none; color: black; padding: 10px;"); | |
525 | client.println("text-decoration: none; font-size: 20px; margin: 2px; cursor: pointer; height: 40px; width: 100px; border-radius: 12px;}"); | |
526 | client.println(".button8 { background-color: #F0F3F4; border: none; color: black; padding: 10px;"); | |
527 | client.println("text-decoration: none; font-size: 20px; margin: 2px; cursor: pointer; height: 40px; width: 100px; border-radius: 12px;}"); | |
528 | //client.println("<meta http-equiv=\"refresh\" content=\"1\">"); | |
529 | ||
530 | ||
531 | client.println("</style></head>"); | |
532 | ||
533 | // Web Page Heading | |
534 | client.println("<body style='background-color: #77878A; text-color: yellow'><h1>Clock settings page</h1>"); | |
535 | ||
536 | // Display current settings and clock modes | |
537 | client.print("<h2>Time: "); | |
538 | client.print(h); | |
539 | client.print(":"); | |
540 | if (m <10) | |
541 | { | |
542 | client.print("0"); | |
543 | } | |
544 | client.print(m); | |
545 | client.print(":"); | |
546 | if (s <10) | |
547 | { | |
548 | client.print("0"); | |
549 | } | |
550 | client.print(s); | |
551 | client.print(" | "); | |
552 | client.print("Date: "); | |
553 | client.print(Day); | |
554 | client.print("-"); | |
555 | client.print(Month); | |
556 | client.print("-"); | |
557 | client.print(Year); | |
558 | ||
559 | client.print("<br>"); | |
560 | client.print("Dim time: "); | |
561 | client.print(nightHr); | |
562 | client.print(":"); | |
563 | if (nightMin < 10) | |
564 | { | |
565 | client.print("0"); | |
566 | } | |
567 | client.print(nightMin); | |
568 | ||
569 | client.print(" | Back to normal: "); | |
570 | client.print(dayHr); | |
571 | client.print(":"); | |
572 | if (dayMin < 10) | |
573 | { | |
574 | client.print("0"); | |
575 | } | |
576 | client.print(dayMin); | |
577 | ||
578 | client.println("</h2>"); | |
579 | client.print("Uptime: "); | |
580 | client.print(uptime::getDays()); | |
581 | client.print(" days, "); | |
582 | client.print(uptime::getHours()); | |
583 | client.print(" hours, "); | |
584 | client.print(uptime::getMinutes()); | |
585 | client.print(" minutes, Startup reason: "); | |
586 | client.println(ESP.getResetReason()); | |
587 | client.println("<br>"); | |
588 | client.print("Last NTP update: "); | |
589 | client.print(updHour); | |
590 | client.print(":"); | |
591 | if (updMinute < 10) | |
592 | { | |
593 | client.print("0"); | |
594 | } | |
595 | client.print(updMinute); | |
596 | client.print(":"); | |
597 | if (updSecond < 10) | |
598 | { | |
599 | client.print("0"); | |
600 | } | |
601 | client.print(updSecond); | |
602 | ||
603 | client.print(" | Dog last fed at: "); | |
604 | client.print(fedH); | |
605 | client.print(":"); | |
606 | if (fedM < 10) | |
607 | { | |
608 | client.print("0"); | |
609 | } | |
610 | client.print(fedM); | |
611 | client.print(":"); | |
612 | if (fedS < 10) | |
613 | { | |
614 | client.print("0"); | |
615 | }client.print(fedS); | |
616 | client.print(" / "); | |
617 | client.print(fedDD); | |
618 | client.print("-"); | |
619 | client.print(fedMM); | |
620 | client.print("-"); | |
621 | client.println(Year); | |
622 | ||
623 | client.println("<br><br>"); | |
624 | ||
625 | // Color picker | |
626 | ||
627 | client.println("<table style=\"width:50%; margin-left:auto; margin-right:auto\">"); | |
628 | client.println("</table>"); | |
629 | ||
630 | client.println("<br><br>"); | |
631 | ||
632 | // Color picker | |
633 | ||
634 | client.println("<table style=\"width:50%; margin-left:auto; margin-right:auto\">"); | |
635 | ||
636 | client.println("<tr>"); | |
637 | /* | |
638 | client.println("<td><label for=\"colorpicker\">Hour</label>"); | |
639 | client.println("<input type=\"color\" id=\"colorpicker\" value=\"#000000\"></td>"); | |
640 | */ | |
641 | ||
642 | /* | |
643 | client.println("<td><input name=\"color\" class=\"color{onImmediateChange:'updateInfo(this);'}\" value=\"000000\" size=\"9\"><input type=\"hidden\" id=\"info-r\" name=\"colorr\"/><input type=\"hidden\" id=\"info-g\" name=\"colorg\"/><input type=\"hidden\" id=\"info-b\" name=\"colorb\"/>"); | |
644 | client.println("<script type=\"text/javascript\"> function updateInfo(color) {document.getElementById('info-r').value = color.rgb[0];document.getElementById('info-g').value = color.rgb[1]; document.getElementById('info-b').value = color.rgb[2];} </script></td>"); | |
645 | */ | |
646 | ||
647 | client.println("<td><h2>Colors</h2></td>"); | |
648 | /* | |
649 | client.println("<td><a class =\"button\" href=\"#\" id=\"change_hour\" role=\"button\"></a></td>"); | |
650 | client.println("<td><input class=\"jscolor\" href=\"#\" id=\"btnPicker\" type=\"button\">Hour</td>"); | |
651 | client.println("<script>function updateColor(picker) {document.getElementById('rgb').innerHTML = Math.round(picker.rgb[0]) + ', ' + Math.round(picker.rgb[1]) + ', ' + Math.round(picker.rgb[2]);}"); | |
652 | //client.println("document.getElementById('btnPicker').addEventListener('change', function(e){updateColor(this.jscolor)})</script>"); | |
653 | client.println("document.getElementById(\"btnPicker\").href=\"HOUR?r\" + Math.round(picker.rgb[0]) + \"g\" + Math.round(picker.rgb[1]) + \"b\" + Math.round(picker.rgb[2]) + \"&\";}</script>"); | |
654 | */ | |
655 | ||
656 | client.println("<div class=\"container1\"><div class=\"row\"</div>"); | |
657 | client.println("<td><a class =\"button\" href=\"#\" id=\"change_hour\" role=\"button\">Hour</a></td>"); | |
658 | client.println("<td><input class=\"jscolor {onFineChange:'update(this)'}\" id=\"rgbH\"></div></td>"); | |
659 | - | client.println("<script>function update(picker) {document.getElementById('rgbH').innerHTML = Math.round(picker.rgb[0]) + ', ' + Math.round(picker.rgb[1]) + ', ' + Math.round(picker.rgb[2]);"); |
659 | + | client.println("<script>function update1(picker) {document.getElementById('rgbH').innerHTML = Math.round(picker.rgb[0]) + ', ' + Math.round(picker.rgb[1]) + ', ' + Math.round(picker.rgb[2]);"); |
660 | client.println("document.getElementById(\"change_hour\").href=\"HOUR?r\" + Math.round(picker.rgb[0]) + \"g\" + Math.round(picker.rgb[1]) + \"b\" + Math.round(picker.rgb[2]) + \"&\";}</script>"); | |
661 | ||
662 | client.println("<div class=\"container2\"><div class=\"row2\"</div>"); | |
663 | client.println("<td><a class =\"button\" href=\"#\" id=\"change_min\" role=\"button\">Min</a></td>"); | |
664 | client.println("<td><input class=\"jscolor {onFineChange:'update(this)'}\" id=\"rgbM\"></div></td>"); | |
665 | - | client.println("<script>function update(picker1) {document.getElementById('rgbM').innerHTML = Math.round(picker1.rgb[0]) + ', ' + Math.round(picker1.rgb[1]) + ', ' + Math.round(picker1.rgb[2]);"); |
665 | + | client.println("<script>function update2(picker1) {document.getElementById('rgbM').innerHTML = Math.round(picker1.rgb[0]) + ', ' + Math.round(picker1.rgb[1]) + ', ' + Math.round(picker1.rgb[2]);"); |
666 | client.println("document.getElementById(\"change_min\").href=\"MIN?r\" + Math.round(picker1.rgb[0]) + \"g\" + Math.round(picker1.rgb[1]) + \"b\" + Math.round(picker1.rgb[2]) + \"&\";}</script>"); | |
667 | ||
668 | client.println("<div class=\"container3\"><div class=\"row3\"</div>"); | |
669 | client.println("<td><a class =\"button\" href=\"#\" id=\"change_sec\" role=\"button\">Sec</a></td>"); | |
670 | client.println("<td><input class=\"jscolor {onFineChange:'update(this)'}\" id=\"rgbS\"></div></td>"); | |
671 | - | client.println("<script>function update(picker2) {document.getElementById('rgbS').innerHTML = Math.round(picker2.rgb[0]) + ', ' + Math.round(picker2.rgb[1]) + ', ' + Math.round(picker2.rgb[2]);"); |
671 | + | client.println("<script>function update3(picker2) {document.getElementById('rgbS').innerHTML = Math.round(picker2.rgb[0]) + ', ' + Math.round(picker2.rgb[1]) + ', ' + Math.round(picker2.rgb[2]);"); |
672 | client.println("document.getElementById(\"change_sec\").href=\"SEC?r\" + Math.round(picker2.rgb[0]) + \"g\" + Math.round(picker2.rgb[1]) + \"b\" + Math.round(picker2.rgb[2]) + \"&\";}</script>"); | |
673 | ||
674 | client.println("</tr>"); | |
675 | ||
676 | client.println("<tr>"); | |
677 | client.println("<td><h2>Options</h2></td>"); | |
678 | //client.println("<td><input type=\"radio\" id=\"Summer\" label=\"Summer\" value=\"Summer\" onclick=\"javascript:window.location.href='/summer'; return true;\" /></td>"); | |
679 | ||
680 | if (dls == 0) | |
681 | { | |
682 | client.println("<td><a href=\"/summer\"><button class=\"button\">Summer</button></a></td>"); | |
683 | } | |
684 | else | |
685 | { | |
686 | client.println("<td><a href=\"/summer\"><button class=\"button button2\">Summer</button></a></td>"); | |
687 | } | |
688 | if (dls == 1) | |
689 | { | |
690 | client.println("<td><a href=\"/winter\"><button class=\"button\">Winter</button></a></td>"); | |
691 | } | |
692 | else | |
693 | { | |
694 | client.println("<td><a href=\"/winter\"><button class=\"button button2\">Winter</button></a></td>"); | |
695 | } | |
696 | client.println("<td><a href=\"/forcentp\"><button class=\"button\">NTP</button></a></td>"); | |
697 | if (clock_mode == 0) | |
698 | { | |
699 | client.println("<td><a href=\"/secson\"><button class=\"button button2\">SecsOn</button></a></td>"); | |
700 | } | |
701 | else | |
702 | { | |
703 | client.println("<td><a href=\"/secson\"><button class=\"button\">SecsOn</button></a></td>"); | |
704 | } | |
705 | if (clock_mode == 1) | |
706 | { | |
707 | client.println("<td><a href=\"/secsoff\"><button class=\"button button2\">SecsOff</button></a></td>"); | |
708 | } | |
709 | else | |
710 | { | |
711 | client.println("<td><a href=\"/secsoff\"><button class=\"button\">SecsOff</button></a></td>"); | |
712 | } | |
713 | if (clock_mode == 12) | |
714 | { | |
715 | client.println("<td><a href=\"/blink\"><button class=\"button button2\">Blink</button></a></td>"); | |
716 | } | |
717 | else | |
718 | { | |
719 | client.println("<td><a href=\"/blink\"><button class=\"button\">Blink</button></a></td>"); | |
720 | } | |
721 | client.println("</tr>"); | |
722 | ||
723 | client.println("<tr>"); | |
724 | client.println("<td><a href=\"#\" id=\"change_bright\" class=\"button\">Bright</button></a></td>"); | |
725 | client.println("<td><input type='range' name=slider1 min='0' max='255' step='5' value="); | |
726 | client.println(bright); | |
727 | client.println("oninput='showValue1(this.value)'>"); | |
728 | client.println("<span id='bright'></span></td>"); | |
729 | client.println("<script>function showValue1(newValue) {document.getElementById('bright').innerHTML = newValue;"); | |
730 | client.println("document.getElementById(\"change_bright\").href=\"bright\" + newValue + \"&\";}</script>"); | |
731 | client.print("<td><h2> BR: "); | |
732 | client.print(bright); | |
733 | client.println("</h2></td>"); | |
734 | client.println("<td><a href=\"/watchdog\"><button class=\"button\">Watchdog</button></a></td>"); | |
735 | if (title == 0) | |
736 | { | |
737 | client.println("<td><a href=\"/titleon\"><button class=\"button\">Title</button></a></td>"); | |
738 | } | |
739 | else | |
740 | { | |
741 | client.println("<td><a href=\"/titleoff\"><button class=\"button button2\">Title</button></a></td>"); | |
742 | } | |
743 | client.println("<td><a href=\"https://www.spookjuh.nl/woordklok-2022/\"><button class=\"button button2\">Manual</button></a></td>"); | |
744 | client.println("</tr>"); | |
745 | ||
746 | client.println("</table>"); | |
747 | ||
748 | client.println("<table style=\"width:50%; margin-left:auto; margin-right:auto\">"); | |
749 | ||
750 | client.println("<tr>"); | |
751 | client.println("<td><h2>Night time</h2></td>"); | |
752 | client.println("<td><a href=\"/nightHr-\"><button class=\"button\">Hr -</button></a></td>"); | |
753 | client.println("<td><a href=\"/nightHr+\"><button class=\"button\">Hr +</button></a></td>"); | |
754 | client.println("<td><a href=\"/nightMin-\"><button class=\"button\">Min -</button></a></td>"); | |
755 | client.println("<td><a href=\"/nightMin+\"><button class=\"button\">Min +</button></a></td>"); | |
756 | client.println("</tr>"); | |
757 | ||
758 | client.println("<tr>"); | |
759 | client.println("<td><h2>Day time</h2></td>"); | |
760 | client.println("<td><a href=\"/dayHr-\"><button class=\"button\">Hr -</button></a></td>"); | |
761 | client.println("<td><a href=\"/dayHr+\"><button class=\"button\">Hr +</button></a></td>"); | |
762 | client.println("<td><a href=\"/dayMin-\"><button class=\"button\">Min -</button></a></td>"); | |
763 | client.println("<td><a href=\"/dayMin+\"><button class=\"button\">Min +</button></a></td>"); | |
764 | client.println("</tr>"); | |
765 | ||
766 | client.println("</table>"); | |
767 | ||
768 | client.println("<br>"); | |
769 | //client.println("<a href=\"/reboot\"><button class=\"button button2\">Reboot</button></a>"); | |
770 | client.print("<br>"); | |
771 | client.print("Filename: "); | |
772 | client.println(Filename); | |
773 | client.print(" | Mem heap: "); | |
774 | client.println(ESP.getFreeHeap()); | |
775 | ||
776 | client.println("</body></html>"); | |
777 | ||
778 | // The HTTP response ends with another blank line | |
779 | client.println(); | |
780 | // Break out of the while loop | |
781 | break; | |
782 | } | |
783 | else | |
784 | { // if you got a newline, then clear currentLine | |
785 | currentLine = ""; | |
786 | } | |
787 | } | |
788 | else if (c != '\r') | |
789 | { // if you got anything else but a carriage return character, | |
790 | currentLine += c; // add it to the end of the currentLine | |
791 | } | |
792 | } | |
793 | } | |
794 | ||
795 | // Clear the header variable | |
796 | header = ""; | |
797 | ||
798 | // Close the connection | |
799 | client.stop(); | |
800 | //Serial.println("Client disconnected."); | |
801 | //Serial.println(""); | |
802 | } | |
803 | } |