new features
[vfd-clock.git] / code / sketch_dec10a.ino
1 //NodeMCU  Wemos D1
2 //Arduino as ISP
3 #include <SPI.h>
4 #include <NTPClient.h>
5 #include <ESP8266WiFi.h>
6 #include <WiFiUdp.h>
7 #include <Adafruit_NeoPixel.h>
8 #include <TimeLib.h>
9
10 #include <DNSServer.h>
11 #include <ESP8266WebServer.h>
12 #include <WiFiManager.h>
13
14 #include <EEPROM.h>
15
16
17 #define LED_PIN D6
18 #define LED_COUNT 6
19
20 static uint16_t hue = 0; // 0-359
21 uint8_t saturation = 100; // 0-100
22 uint8_t lightness = 50; // 0-100
23 unsigned int PColor=0;
24 unsigned int Hour1 = 0;
25 unsigned int Hour2 = 0;
26 unsigned int Minute1 = 0;
27 unsigned int Minute2 = 0;
28 unsigned int Second1 = 0;
29 unsigned int Second2 = 0;
30
31 int utc=0;
32 bool displaySwitch=true;
33 unsigned int pause = 0;
34 unsigned long timeout;
35 //unsigned long newNTPreq;
36 unsigned long secondTick;
37 bool dst = false;
38 int minTmp;
39
40
41 const char *ssid     = "";
42 const char *password = "";
43
44 long utcOffsetInSeconds = 3600*utc;
45
46 // /header.html
47 const char data_header_html[] PROGMEM = {0X3C,0X68,0X74,0X6D,0X6C,0X3E,0X3C,0X68,0X65,0X61,0X64,0X3E,0X3C,0X6D,0X65,0X74,0X61,0X20,0X6E,0X61,0X6D,0X65,0X3D,0X76,0X69,0X65,0X77,0X70,0X6F,0X72,0X74,0X20,0X63,0X6F,0X6E,0X74,0X65,0X6E,0X74,0X3D,0X22,0X77,0X69,0X64,0X74,0X68,0X3D,0X64,0X65,0X76,0X69,0X63,0X65,0X2D,0X77,0X69,0X64,0X74,0X68,0X2C,0X69,0X6E,0X69,0X74,0X69,0X61,0X6C,0X2D,0X73,0X63,0X61,0X6C,0X65,0X3D,0X31,0X22,0X3E,0X3C,0X6D,0X65,0X74,0X61,0X20,0X63,0X68,0X61,0X72,0X73,0X65,0X74,0X3D,0X75,0X74,0X66,0X2D,0X38,0X3E,0X3C,0X73,0X74,0X79,0X6C,0X65,0X3E,0X62,0X6F,0X64,0X79,0X7B,0X66,0X6F,0X6E,0X74,0X2D,0X73,0X69,0X7A,0X65,0X3A,0X31,0X34,0X30,0X25,0X7D,0X23,0X6D,0X61,0X69,0X6E,0X7B,0X64,0X69,0X73,0X70,0X6C,0X61,0X79,0X3A,0X74,0X61,0X62,0X6C,0X65,0X3B,0X6D,0X61,0X72,0X67,0X69,0X6E,0X3A,0X61,0X75,0X74,0X6F,0X3B,0X70,0X61,0X64,0X64,0X69,0X6E,0X67,0X3A,0X30,0X20,0X31,0X30,0X70,0X78,0X20,0X30,0X20,0X31,0X30,0X70,0X78,0X7D,0X2C,0X68,0X32,0X7B,0X74,0X65,0X78,0X74,0X2D,0X61,0X6C,0X69,0X67,0X6E,0X3A,0X63,0X65,0X6E,0X74,0X65,0X72,0X7D,0X2E,0X62,0X75,0X74,0X74,0X6F,0X6E,0X7B,0X70,0X61,0X64,0X64,0X69,0X6E,0X67,0X3A,0X31,0X30,0X70,0X78,0X20,0X31,0X30,0X70,0X78,0X20,0X31,0X30,0X70,0X78,0X20,0X31,0X30,0X70,0X78,0X3B,0X77,0X69,0X64,0X74,0X68,0X3A,0X31,0X30,0X30,0X25,0X3B,0X62,0X61,0X63,0X6B,0X67,0X72,0X6F,0X75,0X6E,0X64,0X2D,0X63,0X6F,0X6C,0X6F,0X72,0X3A,0X23,0X34,0X43,0X41,0X46,0X35,0X30,0X3B,0X66,0X6F,0X6E,0X74,0X2D,0X73,0X69,0X7A,0X65,0X3A,0X31,0X32,0X30,0X25,0X7D,0X3C,0X2F,0X73,0X74,0X79,0X6C,0X65,0X3E,0X3C,0X74,0X69,0X74,0X6C,0X65,0X3E,0X56,0X46,0X44,0X20,0X43,0X6c,0X6f,0X63,0X6b,0X20,0X43,0X6f,0X6e,0X74,0X72,0X6f,0X6c,0X3C,0X2F,0X74,0X69,0X74,0X6C,0X65,0X3E,0X3C,0X2F,0X68,0X65,0X61,0X64,0X3E,0X3C,0X62,0X6F,0X64,0X79,0X3E,0X3C,0X64,0X69,0X76,0X20,0X69,0X64,0X3D,0X6D,0X61,0X69,0X6E,0X3E,0X3C,0X68,0X32,0x20,0x61,0x6c,0x69,0x67,0x6e,0x3d,0x22,0x63,0x65,0x6e,0x74,0x65,0x72,0x22,0X3E,0X56,0X46,0X44,0X20,0X43,0X6c,0X6f,0X63,0X6b,0X20,0X43,0X6f,0X6e,0X74,0X72,0X6f,0X6c,0X3C,0X2F,0X68,0X32,0X3E,0XA,0X3C,0X62,0X72,0X3E,0XA,0X3C,0X63,0X65,0X6E,0X74,0X65,0X72,0X3E,0X0A,0X00};
48
49 // /footer.html
50 const char data_footer_html[] PROGMEM = {0x3c,0x2f,0x63,0x65,0x6e,0x74,0x65,0x72,0x3e,0X3c,0X2f,0X62,0X6f,0X64,0X79,0X3e,0X0a,0X3c,0X2f,0X68,0X74,0X6d,0X6c,0X3e,0X0a,0x00};
51
52 // /body.html
53 const char data_body_html[] PROGMEM = {0X3C,0X66,0X6F,0X72,0X6D,0X20,0X61,0X63,0X74,0X69,0X6F,0X6E,0X3D,0X2F,0X20,0X6D,0X65,0X74,0X68,0X6F,0X64,0X3D,0X50,0X4F,0X53,0X54,0X3E,0XA,0X53,0X65,0X6C,0X65,0X63,0X74,0X20,0X79,0X6F,0X75,0X72,0X20,0X74,0X69,0X6D,0X65,0X7A,0X6F,0X6E,0X65,0X3A,0XA,0X3C,0X73,0X65,0X6C,0X65,0X63,0X74,0X20,0X6E,0X61,0X6D,0X65,0X3D,0X75,0X74,0X63,0X20,0X69,0X64,0X3D,0X75,0X74,0X63,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X2D,0X31,0X32,0X3E,0X28,0X47,0X4D,0X54,0X2D,0X31,0X32,0X3A,0X30,0X30,0X29,0X20,0X49,0X6E,0X74,0X65,0X72,0X6E,0X61,0X74,0X69,0X6F,0X6E,0X61,0X6C,0X20,0X44,0X61,0X74,0X65,0X20,0X4C,0X69,0X6E,0X65,0X20,0X57,0X65,0X73,0X74,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X2D,0X31,0X31,0X3E,0X28,0X47,0X4D,0X54,0X2D,0X31,0X31,0X3A,0X30,0X30,0X29,0X20,0X4D,0X69,0X64,0X77,0X61,0X79,0X20,0X49,0X73,0X6C,0X61,0X6E,0X64,0X2C,0X20,0X53,0X61,0X6D,0X6F,0X61,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X2D,0X31,0X30,0X3E,0X28,0X47,0X4D,0X54,0X2D,0X31,0X30,0X3A,0X30,0X30,0X29,0X20,0X48,0X61,0X77,0X61,0X69,0X69,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X2D,0X39,0X3E,0X28,0X47,0X4D,0X54,0X2D,0X30,0X39,0X3A,0X30,0X30,0X29,0X20,0X41,0X6C,0X61,0X73,0X6B,0X61,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X2D,0X38,0X3E,0X28,0X47,0X4D,0X54,0X2D,0X30,0X38,0X3A,0X30,0X30,0X29,0X20,0X50,0X61,0X63,0X69,0X66,0X69,0X63,0X20,0X54,0X69,0X6D,0X65,0X20,0X28,0X55,0X53,0X20,0X26,0X20,0X43,0X61,0X6E,0X61,0X64,0X61,0X29,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X2D,0X38,0X3E,0X28,0X47,0X4D,0X54,0X2D,0X30,0X38,0X3A,0X30,0X30,0X29,0X20,0X54,0X69,0X6A,0X75,0X61,0X6E,0X61,0X2C,0X20,0X42,0X61,0X6A,0X61,0X20,0X43,0X61,0X6C,0X69,0X66,0X6F,0X72,0X6E,0X69,0X61,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X2D,0X37,0X3E,0X28,0X47,0X4D,0X54,0X2D,0X30,0X37,0X3A,0X30,0X30,0X29,0X20,0X41,0X72,0X69,0X7A,0X6F,0X6E,0X61,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X2D,0X37,0X3E,0X28,0X47,0X4D,0X54,0X2D,0X30,0X37,0X3A,0X30,0X30,0X29,0X20,0X43,0X68,0X69,0X68,0X75,0X61,0X68,0X75,0X61,0X2C,0X20,0X4C,0X61,0X20,0X50,0X61,0X7A,0X2C,0X20,0X4D,0X61,0X7A,0X61,0X74,0X6C,0X61,0X6E,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X2D,0X37,0X3E,0X28,0X47,0X4D,0X54,0X2D,0X30,0X37,0X3A,0X30,0X30,0X29,0X20,0X4D,0X6F,0X75,0X6E,0X74,0X61,0X69,0X6E,0X20,0X54,0X69,0X6D,0X65,0X20,0X28,0X55,0X53,0X20,0X26,0X20,0X43,0X61,0X6E,0X61,0X64,0X61,0X29,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X2D,0X36,0X3E,0X28,0X47,0X4D,0X54,0X2D,0X30,0X36,0X3A,0X30,0X30,0X29,0X20,0X43,0X65,0X6E,0X74,0X72,0X61,0X6C,0X20,0X41,0X6D,0X65,0X72,0X69,0X63,0X61,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X2D,0X36,0X3E,0X28,0X47,0X4D,0X54,0X2D,0X30,0X36,0X3A,0X30,0X30,0X29,0X20,0X43,0X65,0X6E,0X74,0X72,0X61,0X6C,0X20,0X54,0X69,0X6D,0X65,0X20,0X28,0X55,0X53,0X20,0X26,0X20,0X43,0X61,0X6E,0X61,0X64,0X61,0X29,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X2D,0X36,0X3E,0X28,0X47,0X4D,0X54,0X2D,0X30,0X36,0X3A,0X30,0X30,0X29,0X20,0X47,0X75,0X61,0X64,0X61,0X6C,0X61,0X6A,0X61,0X72,0X61,0X2C,0X20,0X4D,0X65,0X78,0X69,0X63,0X6F,0X20,0X43,0X69,0X74,0X79,0X2C,0X20,0X4D,0X6F,0X6E,0X74,0X65,0X72,0X72,0X65,0X79,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X2D,0X36,0X3E,0X28,0X47,0X4D,0X54,0X2D,0X30,0X36,0X3A,0X30,0X30,0X29,0X20,0X53,0X61,0X73,0X6B,0X61,0X74,0X63,0X68,0X65,0X77,0X61,0X6E,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X2D,0X35,0X3E,0X28,0X47,0X4D,0X54,0X2D,0X30,0X35,0X3A,0X30,0X30,0X29,0X20,0X42,0X6F,0X67,0X6F,0X74,0X61,0X2C,0X20,0X4C,0X69,0X6D,0X61,0X2C,0X20,0X51,0X75,0X69,0X74,0X6F,0X2C,0X20,0X52,0X69,0X6F,0X20,0X42,0X72,0X61,0X6E,0X63,0X6F,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X2D,0X35,0X3E,0X28,0X47,0X4D,0X54,0X2D,0X30,0X35,0X3A,0X30,0X30,0X29,0X20,0X45,0X61,0X73,0X74,0X65,0X72,0X6E,0X20,0X54,0X69,0X6D,0X65,0X20,0X28,0X55,0X53,0X20,0X26,0X20,0X43,0X61,0X6E,0X61,0X64,0X61,0X29,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X2D,0X35,0X3E,0X28,0X47,0X4D,0X54,0X2D,0X30,0X35,0X3A,0X30,0X30,0X29,0X20,0X49,0X6E,0X64,0X69,0X61,0X6E,0X61,0X20,0X28,0X45,0X61,0X73,0X74,0X29,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X2D,0X34,0X3E,0X28,0X47,0X4D,0X54,0X2D,0X30,0X34,0X3A,0X30,0X30,0X29,0X20,0X41,0X74,0X6C,0X61,0X6E,0X74,0X69,0X63,0X20,0X54,0X69,0X6D,0X65,0X20,0X28,0X43,0X61,0X6E,0X61,0X64,0X61,0X29,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X2D,0X34,0X3E,0X28,0X47,0X4D,0X54,0X2D,0X30,0X34,0X3A,0X30,0X30,0X29,0X20,0X43,0X61,0X72,0X61,0X63,0X61,0X73,0X2C,0X20,0X4C,0X61,0X20,0X50,0X61,0X7A,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X2D,0X34,0X3E,0X28,0X47,0X4D,0X54,0X2D,0X30,0X34,0X3A,0X30,0X30,0X29,0X20,0X4D,0X61,0X6E,0X61,0X75,0X73,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X2D,0X34,0X3E,0X28,0X47,0X4D,0X54,0X2D,0X30,0X34,0X3A,0X30,0X30,0X29,0X20,0X53,0X61,0X6E,0X74,0X69,0X61,0X67,0X6F,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X2D,0X33,0X2E,0X35,0X3E,0X28,0X47,0X4D,0X54,0X2D,0X30,0X33,0X3A,0X33,0X30,0X29,0X20,0X4E,0X65,0X77,0X66,0X6F,0X75,0X6E,0X64,0X6C,0X61,0X6E,0X64,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X2D,0X33,0X3E,0X28,0X47,0X4D,0X54,0X2D,0X30,0X33,0X3A,0X30,0X30,0X29,0X20,0X42,0X72,0X61,0X73,0X69,0X6C,0X69,0X61,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X2D,0X33,0X3E,0X28,0X47,0X4D,0X54,0X2D,0X30,0X33,0X3A,0X30,0X30,0X29,0X20,0X42,0X75,0X65,0X6E,0X6F,0X73,0X20,0X41,0X69,0X72,0X65,0X73,0X2C,0X20,0X47,0X65,0X6F,0X72,0X67,0X65,0X74,0X6F,0X77,0X6E,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X2D,0X33,0X3E,0X28,0X47,0X4D,0X54,0X2D,0X30,0X33,0X3A,0X30,0X30,0X29,0X20,0X47,0X72,0X65,0X65,0X6E,0X6C,0X61,0X6E,0X64,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X2D,0X33,0X3E,0X28,0X47,0X4D,0X54,0X2D,0X30,0X33,0X3A,0X30,0X30,0X29,0X20,0X4D,0X6F,0X6E,0X74,0X65,0X76,0X69,0X64,0X65,0X6F,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X2D,0X32,0X3E,0X28,0X47,0X4D,0X54,0X2D,0X30,0X32,0X3A,0X30,0X30,0X29,0X20,0X4D,0X69,0X64,0X2D,0X41,0X74,0X6C,0X61,0X6E,0X74,0X69,0X63,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X2D,0X31,0X3E,0X28,0X47,0X4D,0X54,0X2D,0X30,0X31,0X3A,0X30,0X30,0X29,0X20,0X43,0X61,0X70,0X65,0X20,0X56,0X65,0X72,0X64,0X65,0X20,0X49,0X73,0X2E,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X2D,0X31,0X3E,0X28,0X47,0X4D,0X54,0X2D,0X30,0X31,0X3A,0X30,0X30,0X29,0X20,0X41,0X7A,0X6F,0X72,0X65,0X73,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X30,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X30,0X3A,0X30,0X30,0X29,0X20,0X43,0X61,0X73,0X61,0X62,0X6C,0X61,0X6E,0X63,0X61,0X2C,0X20,0X4D,0X6F,0X6E,0X72,0X6F,0X76,0X69,0X61,0X2C,0X20,0X52,0X65,0X79,0X6B,0X6A,0X61,0X76,0X69,0X6B,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X30,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X30,0X3A,0X30,0X30,0X29,0X20,0X47,0X72,0X65,0X65,0X6E,0X77,0X69,0X63,0X68,0X20,0X4D,0X65,0X61,0X6E,0X20,0X54,0X69,0X6D,0X65,0X20,0X3A,0X20,0X44,0X75,0X62,0X6C,0X69,0X6E,0X2C,0X20,0X45,0X64,0X69,0X6E,0X62,0X75,0X72,0X67,0X68,0X2C,0X20,0X4C,0X69,0X73,0X62,0X6F,0X6E,0X2C,0X20,0X4C,0X6F,0X6E,0X64,0X6F,0X6E,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X31,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X31,0X3A,0X30,0X30,0X29,0X20,0X41,0X6D,0X73,0X74,0X65,0X72,0X64,0X61,0X6D,0X2C,0X20,0X42,0X65,0X72,0X6C,0X69,0X6E,0X2C,0X20,0X42,0X65,0X72,0X6E,0X2C,0X20,0X52,0X6F,0X6D,0X65,0X2C,0X20,0X53,0X74,0X6F,0X63,0X6B,0X68,0X6F,0X6C,0X6D,0X2C,0X20,0X56,0X69,0X65,0X6E,0X6E,0X61,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X31,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X31,0X3A,0X30,0X30,0X29,0X20,0X42,0X65,0X6C,0X67,0X72,0X61,0X64,0X65,0X2C,0X20,0X42,0X72,0X61,0X74,0X69,0X73,0X6C,0X61,0X76,0X61,0X2C,0X20,0X42,0X75,0X64,0X61,0X70,0X65,0X73,0X74,0X2C,0X20,0X4C,0X6A,0X75,0X62,0X6C,0X6A,0X61,0X6E,0X61,0X2C,0X20,0X50,0X72,0X61,0X67,0X75,0X65,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X31,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X31,0X3A,0X30,0X30,0X29,0X20,0X42,0X72,0X75,0X73,0X73,0X65,0X6C,0X73,0X2C,0X20,0X43,0X6F,0X70,0X65,0X6E,0X68,0X61,0X67,0X65,0X6E,0X2C,0X20,0X4D,0X61,0X64,0X72,0X69,0X64,0X2C,0X20,0X50,0X61,0X72,0X69,0X73,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X31,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X31,0X3A,0X30,0X30,0X29,0X20,0X53,0X61,0X72,0X61,0X6A,0X65,0X76,0X6F,0X2C,0X20,0X53,0X6B,0X6F,0X70,0X6A,0X65,0X2C,0X20,0X57,0X61,0X72,0X73,0X61,0X77,0X2C,0X20,0X5A,0X61,0X67,0X72,0X65,0X62,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X31,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X31,0X3A,0X30,0X30,0X29,0X20,0X57,0X65,0X73,0X74,0X20,0X43,0X65,0X6E,0X74,0X72,0X61,0X6C,0X20,0X41,0X66,0X72,0X69,0X63,0X61,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X32,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X32,0X3A,0X30,0X30,0X29,0X20,0X41,0X6D,0X6D,0X61,0X6E,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X32,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X32,0X3A,0X30,0X30,0X29,0X20,0X41,0X74,0X68,0X65,0X6E,0X73,0X2C,0X20,0X42,0X75,0X63,0X68,0X61,0X72,0X65,0X73,0X74,0X2C,0X20,0X49,0X73,0X74,0X61,0X6E,0X62,0X75,0X6C,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X32,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X32,0X3A,0X30,0X30,0X29,0X20,0X42,0X65,0X69,0X72,0X75,0X74,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X32,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X32,0X3A,0X30,0X30,0X29,0X20,0X43,0X61,0X69,0X72,0X6F,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X32,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X32,0X3A,0X30,0X30,0X29,0X20,0X48,0X61,0X72,0X61,0X72,0X65,0X2C,0X20,0X50,0X72,0X65,0X74,0X6F,0X72,0X69,0X61,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X32,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X32,0X3A,0X30,0X30,0X29,0X20,0X48,0X65,0X6C,0X73,0X69,0X6E,0X6B,0X69,0X2C,0X20,0X4B,0X79,0X69,0X76,0X2C,0X20,0X52,0X69,0X67,0X61,0X2C,0X20,0X53,0X6F,0X66,0X69,0X61,0X2C,0X20,0X54,0X61,0X6C,0X6C,0X69,0X6E,0X6E,0X2C,0X20,0X56,0X69,0X6C,0X6E,0X69,0X75,0X73,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X32,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X32,0X3A,0X30,0X30,0X29,0X20,0X4A,0X65,0X72,0X75,0X73,0X61,0X6C,0X65,0X6D,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X32,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X32,0X3A,0X30,0X30,0X29,0X20,0X4D,0X69,0X6E,0X73,0X6B,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X32,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X32,0X3A,0X30,0X30,0X29,0X20,0X57,0X69,0X6E,0X64,0X68,0X6F,0X65,0X6B,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X33,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X33,0X3A,0X30,0X30,0X29,0X20,0X4B,0X75,0X77,0X61,0X69,0X74,0X2C,0X20,0X52,0X69,0X79,0X61,0X64,0X68,0X2C,0X20,0X42,0X61,0X67,0X68,0X64,0X61,0X64,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X33,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X33,0X3A,0X30,0X30,0X29,0X20,0X4D,0X6F,0X73,0X63,0X6F,0X77,0X2C,0X20,0X53,0X74,0X2E,0X20,0X50,0X65,0X74,0X65,0X72,0X73,0X62,0X75,0X72,0X67,0X2C,0X20,0X56,0X6F,0X6C,0X67,0X6F,0X67,0X72,0X61,0X64,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X33,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X33,0X3A,0X30,0X30,0X29,0X20,0X4E,0X61,0X69,0X72,0X6F,0X62,0X69,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X33,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X33,0X3A,0X30,0X30,0X29,0X20,0X54,0X62,0X69,0X6C,0X69,0X73,0X69,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X33,0X2E,0X35,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X33,0X3A,0X33,0X30,0X29,0X20,0X54,0X65,0X68,0X72,0X61,0X6E,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X34,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X34,0X3A,0X30,0X30,0X29,0X20,0X41,0X62,0X75,0X20,0X44,0X68,0X61,0X62,0X69,0X2C,0X20,0X4D,0X75,0X73,0X63,0X61,0X74,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X34,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X34,0X3A,0X30,0X30,0X29,0X20,0X42,0X61,0X6B,0X75,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X34,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X34,0X3A,0X30,0X30,0X29,0X20,0X59,0X65,0X72,0X65,0X76,0X61,0X6E,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X34,0X2E,0X35,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X34,0X3A,0X33,0X30,0X29,0X20,0X4B,0X61,0X62,0X75,0X6C,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X35,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X35,0X3A,0X30,0X30,0X29,0X20,0X59,0X65,0X6B,0X61,0X74,0X65,0X72,0X69,0X6E,0X62,0X75,0X72,0X67,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X35,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X35,0X3A,0X30,0X30,0X29,0X20,0X49,0X73,0X6C,0X61,0X6D,0X61,0X62,0X61,0X64,0X2C,0X20,0X4B,0X61,0X72,0X61,0X63,0X68,0X69,0X2C,0X20,0X54,0X61,0X73,0X68,0X6B,0X65,0X6E,0X74,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X35,0X2E,0X35,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X35,0X3A,0X33,0X30,0X29,0X20,0X53,0X72,0X69,0X20,0X4A,0X61,0X79,0X61,0X77,0X61,0X72,0X64,0X65,0X6E,0X61,0X70,0X75,0X72,0X61,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X35,0X2E,0X35,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X35,0X3A,0X33,0X30,0X29,0X20,0X43,0X68,0X65,0X6E,0X6E,0X61,0X69,0X2C,0X20,0X4B,0X6F,0X6C,0X6B,0X61,0X74,0X61,0X2C,0X20,0X4D,0X75,0X6D,0X62,0X61,0X69,0X2C,0X20,0X4E,0X65,0X77,0X20,0X44,0X65,0X6C,0X68,0X69,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X35,0X2E,0X37,0X35,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X35,0X3A,0X34,0X35,0X29,0X20,0X4B,0X61,0X74,0X68,0X6D,0X61,0X6E,0X64,0X75,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X36,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X36,0X3A,0X30,0X30,0X29,0X20,0X41,0X6C,0X6D,0X61,0X74,0X79,0X2C,0X20,0X4E,0X6F,0X76,0X6F,0X73,0X69,0X62,0X69,0X72,0X73,0X6B,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X36,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X36,0X3A,0X30,0X30,0X29,0X20,0X41,0X73,0X74,0X61,0X6E,0X61,0X2C,0X20,0X44,0X68,0X61,0X6B,0X61,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X36,0X2E,0X35,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X36,0X3A,0X33,0X30,0X29,0X20,0X59,0X61,0X6E,0X67,0X6F,0X6E,0X20,0X28,0X52,0X61,0X6E,0X67,0X6F,0X6F,0X6E,0X29,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X37,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X37,0X3A,0X30,0X30,0X29,0X20,0X42,0X61,0X6E,0X67,0X6B,0X6F,0X6B,0X2C,0X20,0X48,0X61,0X6E,0X6F,0X69,0X2C,0X20,0X4A,0X61,0X6B,0X61,0X72,0X74,0X61,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X37,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X37,0X3A,0X30,0X30,0X29,0X20,0X4B,0X72,0X61,0X73,0X6E,0X6F,0X79,0X61,0X72,0X73,0X6B,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X38,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X38,0X3A,0X30,0X30,0X29,0X20,0X42,0X65,0X69,0X6A,0X69,0X6E,0X67,0X2C,0X20,0X43,0X68,0X6F,0X6E,0X67,0X71,0X69,0X6E,0X67,0X2C,0X20,0X48,0X6F,0X6E,0X67,0X20,0X4B,0X6F,0X6E,0X67,0X2C,0X20,0X55,0X72,0X75,0X6D,0X71,0X69,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X38,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X38,0X3A,0X30,0X30,0X29,0X20,0X4B,0X75,0X61,0X6C,0X61,0X20,0X4C,0X75,0X6D,0X70,0X75,0X72,0X2C,0X20,0X53,0X69,0X6E,0X67,0X61,0X70,0X6F,0X72,0X65,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X38,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X38,0X3A,0X30,0X30,0X29,0X20,0X49,0X72,0X6B,0X75,0X74,0X73,0X6B,0X2C,0X20,0X55,0X6C,0X61,0X61,0X6E,0X20,0X42,0X61,0X74,0X61,0X61,0X72,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X38,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X38,0X3A,0X30,0X30,0X29,0X20,0X50,0X65,0X72,0X74,0X68,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X38,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X38,0X3A,0X30,0X30,0X29,0X20,0X54,0X61,0X69,0X70,0X65,0X69,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X39,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X39,0X3A,0X30,0X30,0X29,0X20,0X4F,0X73,0X61,0X6B,0X61,0X2C,0X20,0X53,0X61,0X70,0X70,0X6F,0X72,0X6F,0X2C,0X20,0X54,0X6F,0X6B,0X79,0X6F,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X39,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X39,0X3A,0X30,0X30,0X29,0X20,0X53,0X65,0X6F,0X75,0X6C,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X39,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X39,0X3A,0X30,0X30,0X29,0X20,0X59,0X61,0X6B,0X75,0X74,0X73,0X6B,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X39,0X2E,0X35,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X39,0X3A,0X33,0X30,0X29,0X20,0X41,0X64,0X65,0X6C,0X61,0X69,0X64,0X65,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X39,0X2E,0X35,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X30,0X39,0X3A,0X33,0X30,0X29,0X20,0X44,0X61,0X72,0X77,0X69,0X6E,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X31,0X30,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X31,0X30,0X3A,0X30,0X30,0X29,0X20,0X42,0X72,0X69,0X73,0X62,0X61,0X6E,0X65,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X31,0X30,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X31,0X30,0X3A,0X30,0X30,0X29,0X20,0X43,0X61,0X6E,0X62,0X65,0X72,0X72,0X61,0X2C,0X20,0X4D,0X65,0X6C,0X62,0X6F,0X75,0X72,0X6E,0X65,0X2C,0X20,0X53,0X79,0X64,0X6E,0X65,0X79,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X31,0X30,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X31,0X30,0X3A,0X30,0X30,0X29,0X20,0X48,0X6F,0X62,0X61,0X72,0X74,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X31,0X30,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X31,0X30,0X3A,0X30,0X30,0X29,0X20,0X47,0X75,0X61,0X6D,0X2C,0X20,0X50,0X6F,0X72,0X74,0X20,0X4D,0X6F,0X72,0X65,0X73,0X62,0X79,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X31,0X30,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X31,0X30,0X3A,0X30,0X30,0X29,0X20,0X56,0X6C,0X61,0X64,0X69,0X76,0X6F,0X73,0X74,0X6F,0X6B,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X31,0X31,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X31,0X31,0X3A,0X30,0X30,0X29,0X20,0X4D,0X61,0X67,0X61,0X64,0X61,0X6E,0X2C,0X20,0X53,0X6F,0X6C,0X6F,0X6D,0X6F,0X6E,0X20,0X49,0X73,0X2E,0X2C,0X20,0X4E,0X65,0X77,0X20,0X43,0X61,0X6C,0X65,0X64,0X6F,0X6E,0X69,0X61,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X31,0X32,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X31,0X32,0X3A,0X30,0X30,0X29,0X20,0X41,0X75,0X63,0X6B,0X6C,0X61,0X6E,0X64,0X2C,0X20,0X57,0X65,0X6C,0X6C,0X69,0X6E,0X67,0X74,0X6F,0X6E,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X31,0X32,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X31,0X32,0X3A,0X30,0X30,0X29,0X20,0X46,0X69,0X6A,0X69,0X2C,0X20,0X4B,0X61,0X6D,0X63,0X68,0X61,0X74,0X6B,0X61,0X2C,0X20,0X4D,0X61,0X72,0X73,0X68,0X61,0X6C,0X6C,0X20,0X49,0X73,0X2E,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X31,0X33,0X3E,0X28,0X47,0X4D,0X54,0X2B,0X31,0X33,0X3A,0X30,0X30,0X29,0X20,0X4E,0X75,0X6B,0X75,0X27,0X61,0X6C,0X6F,0X66,0X61,0X3C,0X2F,0X6F,0X70,0X74,0X69,0X6F,0X6E,0X3E,0XA,0X3C,0X2F,0X73,0X65,0X6C,0X65,0X63,0X74,0X3E,0XA,0X3C,0X62,0X72,0X3E,0X3C,0X69,0X6E,0X70,0X75,0X74,0X20,0X74,0X79,0X70,0X65,0X3D,0X73,0X75,0X62,0X6D,0X69,0X74,0X20,0X76,0X61,0X6C,0X75,0X65,0X3D,0X53,0X75,0X62,0X6D,0X69,0X74,0X3E,0XA,0X3C,0X2F,0X66,0X6F,0X72,0X6D,0X3E,0XA,0x00};
54
55 WiFiManager wifiManager;
56
57 WiFiServer server(80);
58 WiFiUDP ntpUDP;
59 NTPClient timeClient(ntpUDP, "pool.ntp.org");
60
61 Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
62
63 String header = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n";
64 String request = "";
65
66 //wemos
67 const int dataPin = 14;  //D5 //Outputs the byte to transfer
68 const int loadPin = 0;   //D3 //3 //Controls the internal transference of data in SN74HC595 internal registers
69 const int clockPin = 4;  //D2 // 4//Generates the clock signal to control the transference of data
70
71 byte digits[38] {
72   0b11111100, //0
73   0b01100000, //1
74   0b11011010, //2
75   0b11110010, //3
76   0b01100110, //4
77   0b10110110, //5
78   0b10111110, //6
79   0b11100000, //7
80   0b11111110, //8
81   0b11100110, //9
82   0b11101110, //A
83   0b00111110, //B
84   0b10011100, //C
85   0b01111010, //D
86   0b10011110, //E
87   0b10001110, //F
88   0b10111100, //G 
89   0b01101110, //H
90   0b00001100, //I
91   0b01111000, //J
92   0b10101110, //K
93   0b00011100, //L
94   0b10101000, //M
95   0b00101010, //N
96   0b11111100, //O
97   0b11001110, //P
98   0b11100110, //Q
99   0b00001010, //R
100   0b10110110, //S
101   0b00011110, //T
102   0b01111100, //U
103   0b01110100, //V
104   0b01010100, //W
105   0b01101110, //X
106   0b01110110, //Y
107   0b11011010, //Z
108   0b00000001, //.
109   0b00000000  //NULL
110 };
111
112 void setup() {
113   delay(10000);
114   Serial.begin(115200);
115   EEPROM.begin(512);
116   //utc = int(EEPROM.read(0));
117   EEPROM.get(0,utc);
118   EEPROM.end();
119   
120   pinMode(dataPin, OUTPUT);
121   pinMode(loadPin, OUTPUT);
122   pinMode(clockPin, OUTPUT);  
123   digitalWrite(loadPin, 0);
124   shiftOut(dataPin, clockPin, LSBFIRST, 0b00000000);
125   shiftOut(dataPin, clockPin, LSBFIRST, 0b00000000);
126   shiftOut(dataPin, clockPin, LSBFIRST, 0b00000000);
127   shiftOut(dataPin, clockPin, LSBFIRST, 0b00000000);
128   shiftOut(dataPin, clockPin, LSBFIRST, 0b00000000);
129   shiftOut(dataPin, clockPin, LSBFIRST, 0b00000000);
130   digitalWrite(loadPin, 1);
131
132   strip.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
133   strip.show();            // Turn OFF all pixels ASAP
134   strip.setBrightness(25); // Set BRIGHTNESS to about 1/5 (max = 255)
135   for (int b=0; b<6; b++) {
136     strip.setPixelColor(b,255,0,0);
137   }
138   strip.show();
139   for (int b=0; b<3; b++) {
140     chase();
141   }
142
143   WiFi.hostname("VFD-Clock2");
144   wifiManager.setHostname("VFD-Clock2");
145   wifiManager.setConnectTimeout(15);
146   int i=0;
147   wifiManager.autoConnect("VFD WiFi Manager");
148   
149   timeClient.begin();
150   server.begin();
151   timeClient.update();
152   timeClient.setUpdateInterval(86400000);
153
154   utcOffsetInSeconds = 3600*utc;
155   timeClient.setTimeOffset(utcOffsetInSeconds);
156   setTime(timeClient.getEpochTime());
157
158   //US DST CALC
159   if(month() == 11 && day() < 8 && day() < weekday()) {
160     dst=true;
161   }
162   if(month() == 11 && day() < 8 && weekday() == 1 && hour() < 1) {
163     dst=true;
164   }
165
166   if(month() < 11 && month() > 3) dst = true;
167
168   if(month() == 3 && day() > 7 && day() >= (weekday() + 7)) {
169     if(!(weekday() == 1 && hour() < 2)) dst = true;
170   }
171  
172   if(dst) utcOffsetInSeconds += 3600UL;
173
174
175   timeClient.setTimeOffset(utcOffsetInSeconds);
176   setTime(timeClient.getEpochTime());
177   timeout=millis()+5000;
178   secondTick=millis()+1000;
179 }
180
181 void chase() {
182   byte disp = 0;
183   for (unsigned int j=0; j<5; j++) {
184     for (unsigned int i=0; i<8; i++) {
185       digitalWrite(loadPin, 0);
186       bitSet(disp, i);
187       shiftOut(dataPin, clockPin, LSBFIRST, disp); //right
188       shiftOut(dataPin, clockPin, LSBFIRST, disp); //left
189       digitalWrite(loadPin, 1);
190       delay(25);
191       bitClear(disp, i);
192     }  
193   }
194 }
195
196 void casino() {
197   for (unsigned int i=0; i<20; i++) {
198     digitalWrite(loadPin, 0);
199     shiftOut(dataPin, clockPin, LSBFIRST, digits[random(0,9)]); //right
200     shiftOut(dataPin, clockPin, LSBFIRST, digits[random(0,9)]); //left
201     shiftOut(dataPin, clockPin, LSBFIRST, digits[random(0,9)]); //left
202     shiftOut(dataPin, clockPin, LSBFIRST, digits[random(0,9)]); //left
203     shiftOut(dataPin, clockPin, LSBFIRST, digits[random(0,9)]); //left
204     shiftOut(dataPin, clockPin, LSBFIRST, digits[random(0,9)]); //left
205     digitalWrite(loadPin, 1);
206     delay(25);
207   }  
208 }
209
210 /**
211  * Map HSL color space to RGB
212  * 
213  * Totally borrowed from:
214  * http://www.niwa.nu/2013/05/math-behind-colorspace-conversions-rgb-hsl/ 
215  * 
216  * Probably not the most efficient solution, but 
217  * it get's the job done.
218  */
219 uint32_t hsl(uint16_t ih, uint8_t is, uint8_t il) {
220
221   float h, s, l, t1, t2, tr, tg, tb;
222   uint8_t r, g, b;
223
224   h = (ih % 360) / 360.0;
225   s = constrain(is, 0, 100) / 100.0;
226   l = constrain(il, 0, 100) / 100.0;
227
228   if ( s == 0 ) { 
229     r = g = b = 255 * l;
230     return ((uint32_t)r << 16) | ((uint32_t)g <<  8) | b;
231   } 
232   
233   if ( l < 0.5 ) t1 = l * (1.0 + s);
234   else t1 = l + s - l * s;
235   
236   t2 = 2 * l - t1;
237   tr = h + 1/3.0;
238   tg = h;
239   tb = h - 1/3.0;
240
241   r = hsl_convert(tr, t1, t2);
242   g = hsl_convert(tg, t1, t2);
243   b = hsl_convert(tb, t1, t2);
244
245   // NeoPixel packed RGB color
246   return ((uint32_t)r << 16) | ((uint32_t)g <<  8) | b;
247 }
248 /**
249  * HSL Convert
250  * Helper function
251  */
252 uint8_t hsl_convert(float c, float t1, float t2) {
253
254   if ( c < 0 ) c+=1; 
255   else if ( c > 1 ) c-=1;
256
257   if ( 6 * c < 1 ) c = t2 + ( t1 - t2 ) * 6 * c;
258   else if ( 2 * c < 1 ) c = t1;
259   else if ( 3 * c < 2 ) c = t2 + ( t1 - t2 ) * ( 2/3.0 - c ) * 6;
260   else c = t2;
261   
262   return (uint8_t)(c*255); 
263 }
264
265 void loop() {
266   WiFiClient client = server.available();
267
268   unsigned int b=0;
269
270   if (client) { // if !available yet, we return to this client in next loop
271     char line[256];
272     int l = client.readBytesUntil('\n', line, sizeof(line));
273     line[l] = 0;
274     client.find((char*) "\r\n\r\n");
275     if (strncmp_P(line, PSTR("POST"), strlen("POST")) == 0) {
276       l = client.readBytes(line, sizeof(line));
277       line[l] = 0;
278       // parse the parameters sent by the html form
279       const char* delims = "="; //was =&
280       strtok(line, delims);
281       const char* value = strtok(NULL, delims);
282       //strtok(NULL, delims);
283       //const char* pass = strtok(NULL, delims);
284
285       // send a response before attemting to connect to the WiFi network
286       // because it will reset the SoftAP and disconnect the client station
287       client.println(F("HTTP/1.1 200 OK"));
288       client.println(F("Connection: close"));
289       client.println(F("Refresh: 1"));
290       client.println();
291       client.println(F("<html><body><h3>Applying configuration</h3><br>please wait...</body></html>"));
292       client.stop();
293       int tube[5];
294       tube[0]=digits[37];
295       tube[1]=digits[37];
296       tube[2]=digits[37];
297       tube[3]=digits[37];
298       tube[4]=digits[37];
299       tube[5]=digits[37];
300       digitalWrite(loadPin, 0);
301       for (int j=0; j<6; j++) {
302         shiftOut(dataPin, clockPin, LSBFIRST, digits[37]);
303       }
304       digitalWrite(loadPin, 1);
305       delay(300);
306       if (strncmp_P(line, PSTR("msg"), strlen("msg")) == 0) {
307         for (int i=0; i<strlen(value); i++) {
308           if (int(toupper(value[i])) >= 48 && int(toupper(value[i])) <=57) {
309             tube[0] = digits[int(toupper(value[i]))-48];
310           } else if (int(toupper(value[i])) >= 65 && int(toupper(value[i])) <=90) {
311             tube[0] = digits[int(toupper(value[i]))-55];
312           } else if (int(toupper(value[i])) >= 32) {
313             tube[0] = digits[37];
314           } else {
315             tube[0] = digits[36];
316           }
317           digitalWrite(loadPin, 0);
318           for (int j=0; j<6; j++) {
319             shiftOut(dataPin, clockPin, LSBFIRST, tube[j]);
320           }
321           digitalWrite(loadPin, 1);
322           delay(200);
323           for (int j=5; j>0; j--) {
324             tube[j]=tube[j-1];
325           }
326         }
327         for (int i=0; i<6; i++) {
328           tube[0] = digits[37];
329           digitalWrite(loadPin, 0);
330           for (int j=0; j<6; j++) {
331             shiftOut(dataPin, clockPin, LSBFIRST, tube[j]);
332           }
333           digitalWrite(loadPin, 1);
334           delay(250);
335           for (int j=5; j>0; j--) {
336             tube[j]=tube[j-1];
337           }
338
339         }
340       } else {
341         utc=atoi(value);
342         utcOffsetInSeconds = 3600*utc;
343
344         //US DST CALC
345         if(month() == 11 && day() < 8 && day() < weekday()) {
346           dst=true;
347         }
348         if(month() == 11 && day() < 8 && weekday() == 1 && hour() < 1) {
349           dst=true;
350         }
351
352         if(month() < 11 && month() > 3) dst = true;
353  
354         if(month() == 3 && day() > 7 && day() >= (weekday() + 7)) {
355           if(!(weekday() == 1 && hour() < 2)) dst = true;
356         }
357  
358         if(dst) utcOffsetInSeconds += 3600UL;
359       
360         timeClient.update();
361         timeClient.setTimeOffset(utcOffsetInSeconds);
362         setTime(timeClient.getEpochTime());
363         EEPROM.begin(512);
364         EEPROM.put(0, utc);
365         //EEPROM.update(0, utc);
366         //EEPROM.commit();
367         EEPROM.end();
368         //setTime(timeClient.getEpochTime()+utcOffsetInSeconds);
369       }
370     } else {
371       client.println();
372       client.print(data_header_html);  
373       client.print(F("Current GMT offset: "));
374       client.println((utc));
375       client.print(F("Current GMT offset in seconds: "));
376       client.println((utcOffsetInSeconds));
377       client.print(data_body_html);
378       client.println();
379       client.print(data_footer_html);
380       client.stop();
381     }    
382   } else {
383     if (millis()>=secondTick) {
384       secondTick=millis()+1000;
385       for (b=0; b<6; b++) {
386         strip.setPixelColor(b, hsl(PColor, saturation, 0));
387       }
388       PColor++;
389       if (PColor>360) {
390         PColor=0;
391       }
392       int secondd = (second()/1U) % 10;
393       int secondu = (second()/10U) % 10;
394       float percent = (float)secondd/10;      
395       if (secondu==0) {
396         strip.setPixelColor(1, hsl(PColor, saturation, (float)((lightness*(1-percent)))));
397         strip.setPixelColor(0, hsl(PColor, saturation, (float)((lightness*percent))));
398       }
399       if (secondu==1) {
400         strip.setPixelColor(0, hsl(PColor, saturation, (float)((lightness*(1-percent)))));
401         strip.setPixelColor(5, hsl(PColor, saturation, (float)((lightness*percent))));
402       }
403       if (secondu==2) {
404         strip.setPixelColor(5, hsl(PColor, saturation, (float)((lightness*(1-percent)))));
405         strip.setPixelColor(4, hsl(PColor, saturation, (float)((lightness*percent))));
406       }
407       if (secondu==3) {
408         strip.setPixelColor(4, hsl(PColor, saturation, (float)((lightness*(1-percent)))));
409         strip.setPixelColor(3, hsl(PColor, saturation, (float)((lightness*percent))));
410       }
411       if (secondu==4) {
412         strip.setPixelColor(3, hsl(PColor, saturation, (float)((lightness*(1-percent)))));
413         strip.setPixelColor(2, hsl(PColor, saturation, (float)((lightness*percent))));
414       }
415       if (secondu==5) {
416         strip.setPixelColor(1, hsl(PColor, saturation, (float)((lightness*percent))));
417         strip.setPixelColor(2, hsl(PColor, saturation, (float)((lightness*(1-percent)))));
418       }
419       strip.show();
420     }
421     //if (millis()>=timeout) {
422       timeout=millis()+5000;  
423
424       unsigned int b=0;
425       int Hour = hour();
426       int Minute = minute();
427       int Seconds = second();
428       int Hour1 = (Hour/10U) % 10;
429       int Hour2 = (Hour/1U) % 10;
430       int Minute1 = (Minute/10U) % 10;
431       int Minute2 = (Minute/1U) % 10;
432       int Second1 = (Seconds/10U) % 10;
433       int Second2 = (Seconds/1U) % 10;
434
435       if (minTmp != Minute2) {
436         //chase();
437         casino();
438       }
439       minTmp = Minute2;
440       //digitalWrite(loadPin, 0);
441       //shiftOut(dataPin, clockPin, LSBFIRST, 0b000000000000000000000000000000000000000000000000);
442       //digitalWrite(loadPin, 1);
443       //if (Second2==0 && Second1==0) {
444       //  casino();
445       //}
446       digitalWrite(loadPin, 0);
447       shiftOut(dataPin, clockPin, LSBFIRST, digits[Second2]); //right
448       shiftOut(dataPin, clockPin, LSBFIRST, digits[Second1]); //left
449       shiftOut(dataPin, clockPin, LSBFIRST, digits[Minute2]); //right
450       shiftOut(dataPin, clockPin, LSBFIRST, digits[Minute1]); //left
451       shiftOut(dataPin, clockPin, LSBFIRST, digits[Hour2]); //right
452       shiftOut(dataPin, clockPin, LSBFIRST, digits[Hour1]); //left
453       digitalWrite(loadPin, 1);
454     //}
455   }
456 }