├── table ├── lib ├── Time │ ├── Time.h │ ├── desktop.ini │ ├── examples │ │ ├── desktop.ini │ │ ├── Processing │ │ │ ├── desktop.ini │ │ │ └── SyncArduinoClock │ │ │ │ ├── desktop.ini │ │ │ │ ├── readme.txt │ │ │ │ └── SyncArduinoClock.pde │ │ ├── TimeGPS │ │ │ ├── desktop.ini │ │ │ └── TimeGPS.ino │ │ ├── TimeNTP │ │ │ ├── desktop.ini │ │ │ └── TimeNTP.ino │ │ ├── TimeRTC │ │ │ ├── desktop.ini │ │ │ └── TimeRTC.ino │ │ ├── TimeRTCLog │ │ │ ├── desktop.ini │ │ │ └── TimeRTCLog.ino │ │ ├── TimeRTCSet │ │ │ ├── desktop.ini │ │ │ └── TimeRTCSet.ino │ │ ├── TimeSerial │ │ │ ├── desktop.ini │ │ │ └── TimeSerial.ino │ │ ├── TimeArduinoDue │ │ │ ├── desktop.ini │ │ │ └── TimeArduinoDue.ino │ │ ├── TimeTeensy3 │ │ │ ├── desktop.ini │ │ │ └── TimeTeensy3.ino │ │ ├── TimeNTP_ESP8266WiFi │ │ │ ├── desktop.ini │ │ │ └── TimeNTP_ESP8266WiFi.ino │ │ └── TimeSerialDateStrings │ │ │ ├── desktop.ini │ │ │ └── TimeSerialDateStrings.ino │ ├── library.properties │ ├── library.json │ ├── keywords.txt │ ├── DateStrings.cpp │ ├── TimeLib.h │ └── Readme.txt ├── NTP │ ├── keywords.txt │ ├── .gitattributes │ ├── .gitignore │ ├── ntp.h │ ├── ntp.cpp │ └── Examples │ │ └── WiFiClock │ │ └── WiFiClock.ino ├── desktop.ini ├── arduinoWebSockets-master │ ├── desktop.ini │ ├── src │ │ ├── desktop.ini │ │ ├── libb64 │ │ │ ├── desktop.ini │ │ │ ├── AUTHORS │ │ │ ├── cdecode_inc.h │ │ │ ├── cencode_inc.h │ │ │ ├── LICENSE │ │ │ ├── cdecode.c │ │ │ └── cencode.c │ │ ├── libsha1 │ │ │ ├── desktop.ini │ │ │ └── libsha1.h │ │ └── WebSocketsClient.h │ ├── examples │ │ ├── desktop.ini │ │ ├── Nginx │ │ │ ├── desktop.ini │ │ │ └── esp8266.ssl.reverse.proxy.conf │ │ ├── WebSocketClient │ │ │ ├── desktop.ini │ │ │ └── WebSocketClient.ino │ │ ├── WebSocketServer │ │ │ ├── desktop.ini │ │ │ ├── WebSocketServer.ino │ │ │ └── WebSocketServerHttpHeaderValidation.ino │ │ ├── WebSocketClientAVR │ │ │ ├── desktop.ini │ │ │ └── WebSocketClientAVR.ino │ │ ├── WebSocketClientSSL │ │ │ ├── desktop.ini │ │ │ └── WebSocketClientSSL.ino │ │ └── WebSocketServer_LEDcontrol │ │ │ ├── desktop.ini │ │ │ └── WebSocketServer_LEDcontrol.ino │ ├── tests │ │ ├── desktop.ini │ │ ├── webSocketServer │ │ │ ├── desktop.ini │ │ │ ├── package.json │ │ │ └── index.js │ │ └── webSocket.html │ ├── library.properties │ ├── .gitignore │ ├── library.json │ └── README.md ├── NeoPixelBus │ ├── .gitattributes │ ├── .gitignore │ ├── examples │ │ ├── NeoPixelTest │ │ │ └── NeoPixelTest.pde │ │ └── NeoPixelFun │ │ │ └── NeoPixelFun.pde │ ├── NeoPixelAnimator.h │ ├── HslColor.h │ ├── HslColor.cpp │ ├── RgbColor.cpp │ ├── NeoPixelAnimator.cpp │ ├── NeoPixelBus.h │ ├── RgbColor.h │ └── NeoPixelesp8266.c └── readme.txt ├── .gitignore ├── druhvhtml ├── Menu.zip ├── desktop.ini ├── Menu │ ├── desktop.ini │ └── index.html ├── compressed │ ├── desktop.ini │ ├── compressed.html │ └── compressed.css └── settings.html ├── firmware 1.1.1 bug fixes.bin ├── lightclock 1.1 - sun and moon.bin ├── desktop.ini ├── .piolibdeps └── desktop.ini ├── thelightclockwifi └── desktop.ini ├── h ├── importfonts.h ├── clearromsure.h ├── send_progmem.h ├── password.h ├── webconfig.h ├── buttongradient.h ├── externallinks.h ├── timezone.h ├── alarm.h ├── root.h ├── colourjs.h └── game.h ├── .gitattributes ├── html ├── clearromsure.html ├── password.html ├── timezonesetup.html ├── testwebsock.html ├── advancedserverhtml.html ├── webconfig.html ├── timezone.html ├── alarm.html └── index.html ├── notes ├── memory usage.txt └── memory values.csv ├── readme.md ├── platformio.ini ├── .travis.yml └── Colour.js /table: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/Time/Time.h: -------------------------------------------------------------------------------- 1 | #include "TimeLib.h" 2 | -------------------------------------------------------------------------------- /lib/NTP/keywords.txt: -------------------------------------------------------------------------------- 1 | NTP KEYWORD1 2 | begin KEYWORD2 3 | getNtpTime KEYWORD2 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pioenvs 2 | *.clang_complete 3 | *.gcc-flags.json 4 | *.piolibdeps 5 | *.tmp -------------------------------------------------------------------------------- /druhvhtml/Menu.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrismelba/lightclockwifiv2/HEAD/druhvhtml/Menu.zip -------------------------------------------------------------------------------- /firmware 1.1.1 bug fixes.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrismelba/lightclockwifiv2/HEAD/firmware 1.1.1 bug fixes.bin -------------------------------------------------------------------------------- /lightclock 1.1 - sun and moon.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrismelba/lightclockwifiv2/HEAD/lightclock 1.1 - sun and moon.bin -------------------------------------------------------------------------------- /desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /lib/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /lib/Time/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /.piolibdeps/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /druhvhtml/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /druhvhtml/Menu/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /lib/Time/examples/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /thelightclockwifi/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /druhvhtml/compressed/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /lib/Time/examples/Processing/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /lib/Time/examples/TimeGPS/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /lib/Time/examples/TimeNTP/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /lib/Time/examples/TimeRTC/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /lib/Time/examples/TimeRTCLog/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /lib/Time/examples/TimeRTCSet/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /lib/Time/examples/TimeSerial/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /lib/Time/examples/TimeArduinoDue/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /lib/Time/examples/TimeTeensy3/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/src/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /lib/Time/examples/TimeNTP_ESP8266WiFi/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/examples/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/tests/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /lib/Time/examples/TimeSerialDateStrings/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/examples/Nginx/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/src/libb64/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/src/libsha1/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /lib/Time/examples/Processing/SyncArduinoClock/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/examples/WebSocketClient/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/examples/WebSocketServer/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/tests/webSocketServer/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/examples/WebSocketClientAVR/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/examples/WebSocketClientSSL/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/examples/WebSocketServer_LEDcontrol/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/src/libb64/AUTHORS: -------------------------------------------------------------------------------- 1 | libb64: Base64 Encoding/Decoding Routines 2 | ====================================== 3 | 4 | Authors: 5 | ------- 6 | 7 | Chris Venter chris.venter@gmail.com http://rocketpod.blogspot.com 8 | -------------------------------------------------------------------------------- /h/importfonts.h: -------------------------------------------------------------------------------- 1 | const char importfonts[] PROGMEM = R"=====( 2 | 5 | )====="; 6 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/library.properties: -------------------------------------------------------------------------------- 1 | name=WebSockets 2 | version=2.0.2 3 | author=Markus Sattler 4 | maintainer=Markus Sattler 5 | sentence=WebSockets for Arduino (Server + Client) 6 | paragraph=use 2.x.x for ESP and 1.3 for AVR 7 | category=Communication 8 | url=https://github.com/Links2004/arduinoWebSockets 9 | architectures=* 10 | -------------------------------------------------------------------------------- /lib/Time/library.properties: -------------------------------------------------------------------------------- 1 | name=Time 2 | version=1.5 3 | author=Michael Margolis 4 | maintainer=Paul Stoffregen 5 | sentence=Timekeeping functionality for Arduino 6 | paragraph=Date and Time functions, with provisions to synchronize to external time sources like GPS and NTP (Internet). This library is often used together with TimeAlarms and DS1307RTC. 7 | category=Timing 8 | url=http://playground.arduino.cc/code/time 9 | architectures=* 10 | 11 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Compiled Dynamic libraries 12 | *.so 13 | *.dylib 14 | *.dll 15 | 16 | # Fortran module files 17 | *.mod 18 | 19 | # Compiled Static libraries 20 | *.lai 21 | *.la 22 | *.a 23 | *.lib 24 | 25 | # Executables 26 | *.exe 27 | *.out 28 | *.app 29 | /tests/webSocketServer/node_modules 30 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /lib/NTP/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /lib/NeoPixelBus/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /lib/Time/examples/Processing/SyncArduinoClock/readme.txt: -------------------------------------------------------------------------------- 1 | SyncArduinoClock is a Processing sketch that responds to Arduino requests for 2 | time synchronization messages. 3 | 4 | The portIndex must be set the Serial port connected to Arduino. 5 | 6 | Download TimeSerial.pde onto Arduino and you should see the time 7 | message displayed when you run SyncArduinoClock in Processing. 8 | The Arduino time is set from the time on your computer through the 9 | Processing sketch. 10 | -------------------------------------------------------------------------------- /lib/Time/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Time", 3 | "frameworks": "Arduino", 4 | "keywords": "Time, date, hour, minute, second, day, week, month, year, RTC", 5 | "description": "Time keeping library", 6 | "url": "http://playground.arduino.cc/Code/Time", 7 | "authors": 8 | [ 9 | { 10 | "name": "Michael Margolis" 11 | }, 12 | { 13 | "name": "Paul Stoffregen" 14 | } 15 | ], 16 | "repository": 17 | { 18 | "type": "git", 19 | "url": "https://github.com/PaulStoffregen/Time" 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "WebSockets", 3 | "keywords": "wifi, http, web, server, client, websocket", 4 | "description": "WebSocket Server and Client for Arduino based on RFC6455", 5 | "repository": 6 | { 7 | "type": "git", 8 | "url": "https://github.com/Links2004/arduinoWebSockets.git" 9 | }, 10 | "exclude": "tests", 11 | "frameworks": "arduino", 12 | "platforms": "*", 13 | "authors": 14 | { 15 | "name": "Markus Sattler", 16 | "url": "https://github.com/Links2004", 17 | "maintainer": true 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /html/clearromsure.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |

Are you sure?


10 | This will clear all settings including your wifi password. When The Light Clock reboots please connect to it to set up local wifi again.


11 | Reset to factory default 12 | 13 | -------------------------------------------------------------------------------- /h/clearromsure.h: -------------------------------------------------------------------------------- 1 | const char clearromsure_html[] PROGMEM = R"=====( 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |

Are you sure?


10 | This will clear all settings including your wifi password. When The Light Clock reboots please connect to it to set up local wifi again.


11 | Reset to factory default 12 | 13 | 14 | )====="; 15 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/src/libsha1/libsha1.h: -------------------------------------------------------------------------------- 1 | /* ================ sha1.h ================ */ 2 | /* 3 | SHA-1 in C 4 | By Steve Reid 5 | 100% Public Domain 6 | */ 7 | 8 | #ifndef ESP8266 9 | 10 | typedef struct { 11 | uint32_t state[5]; 12 | uint32_t count[2]; 13 | unsigned char buffer[64]; 14 | } SHA1_CTX; 15 | 16 | void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]); 17 | void SHA1Init(SHA1_CTX* context); 18 | void SHA1Update(SHA1_CTX* context, const unsigned char* data, uint32_t len); 19 | void SHA1Final(unsigned char digest[20], SHA1_CTX* context); 20 | 21 | #endif -------------------------------------------------------------------------------- /h/send_progmem.h: -------------------------------------------------------------------------------- 1 | template 2 | size_t sendProgmem(WiFiClient client, const prog_char (&str)[N]) 3 | { 4 | return sendProgmem(client, str, N); 5 | } 6 | 7 | size_t sendProgmem(WiFiClient client, const prog_char progmem[], size_t size) { 8 | size_t maxSize=2920; // this seems to be the max that write() will ever actually send 9 | size_t sent=0; 10 | 11 | while(sent < size) { 12 | size_t sendSize = (maxSize < (size - sent)) ? maxSize : (size - sent); 13 | sent += client.write(progmem+sent, sendSize); // write() may send less than you asked it to 14 | } 15 | return sent; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /notes/memory usage.txt: -------------------------------------------------------------------------------- 1 | memory usage: 2 | 3 | added version 1: (magic byte = 196) 4 | 0-31: ssid 5 | 32-95: password 6 | 100-124: face1 7 | 125-149: face2 8 | 150-174: face3 9 | 10 | 175-176: lat 11 | 177-178: long 12 | 179: timezone 13 | 180: random mode 14 | 181: hour marks 15 | 182: sleep 16 | 183: sleepmin 17 | 184: showseconds 18 | 185: DSTauto 19 | 186: webMode 20 | 187-188: timezone 21 | 189: wake 22 | 190: wakemin 23 | 191: brightness 24 | 192: DSTtime 25 | 193: hourofdeath 26 | 194: minuteofdeath 27 | 195-227: clockname 28 | 29 | added version 1.1: (magic byte = 2) 30 | 228: sleeptype 31 | 229: dawnbreak 32 | 230: pixelCount 33 | 231: maxBrightness 34 | 35 | 36 | 509-511: magic first-boot byte c4 -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # The Light Clock 2 | 3 | ![image of the light clock](https://ksr-ugc.imgix.net/assets/004/815/608/a025734c5759b00a1bffc8bfab20cccb_original.jpg?ixlib=rb-2.1.0&w=680&fit=max&v=1446419018&auto=format&frame=1&q=92&s=9edd57b503ed8580d15e68ad82020695) 4 | 5 | This is a project to create a clock out of an ESP8266 chip and a string of neopixel LEDs. The project was released on a successful [kickstarter!](https://www.kickstarter.com/projects/1054187792/the-light-clock?token=00673970) in 2017 6 | 7 | In this repo are compiled binaries for the latest two firmware patches, plus all the code if you wish to modify for your device 8 | 9 | Instructions on building the light clock can be found on [instructables!](https://www.instructables.com/id/The-Light-Clock-IoT/) 10 | -------------------------------------------------------------------------------- /lib/NTP/.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear on external disk 35 | .Spotlight-V100 36 | .Trashes 37 | 38 | # Directories potentially created on remote AFP share 39 | .AppleDB 40 | .AppleDesktop 41 | Network Trash Folder 42 | Temporary Items 43 | .apdisk 44 | -------------------------------------------------------------------------------- /html/password.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | $fonts 4 | $css 5 | 6 | 7 | 8 | 9 | 10 | 11 | Network-> Password -> Timezone
12 |

Choose Your Network

13 |
14 |
    15 |
    16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /lib/NeoPixelBus/.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear on external disk 35 | .Spotlight-V100 36 | .Trashes 37 | 38 | # Directories potentially created on remote AFP share 39 | .AppleDB 40 | .AppleDesktop 41 | Network Trash Folder 42 | Temporary Items 43 | .apdisk 44 | -------------------------------------------------------------------------------- /platformio.ini: -------------------------------------------------------------------------------- 1 | # 2 | # Project Configuration File 3 | # 4 | # A detailed documentation with the EXAMPLES is located here: 5 | # http://docs.platformio.org/en/latest/projectconf.html 6 | # 7 | 8 | # A sign `#` at the beginning of the line indicates a comment 9 | # Comment lines are ignored. 10 | 11 | # Simple and base environment 12 | # [env:mybaseenv] 13 | # platform = %INSTALLED_PLATFORM_NAME_HERE% 14 | # framework = 15 | # board = 16 | # 17 | # Automatic targets - enable auto-uploading 18 | # targets = upload 19 | 20 | [env:nodemcuv2] 21 | platform=espressif8266 22 | framework=arduino 23 | board=nodemcuv2 24 | <<<<<<< HEAD 25 | //upload_port=thelightclock.local/update 26 | ======= 27 | upload_port=thelightclock.local/update 28 | >>>>>>> origin/master 29 | 30 | [platformio] 31 | src_dir=. 32 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/tests/webSocketServer/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "webSocketServer", 3 | "version": "1.0.0", 4 | "description": "WebSocketServer for testing", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/Links2004/arduinoWebSockets" 12 | }, 13 | "keywords": [ 14 | "esp8266", 15 | "websocket", 16 | "arduino" 17 | ], 18 | "author": "Markus Sattler", 19 | "license": "LGPLv2", 20 | "bugs": { 21 | "url": "https://github.com/Links2004/arduinoWebSockets/issues" 22 | }, 23 | "homepage": "https://github.com/Links2004/arduinoWebSockets", 24 | "dependencies": { 25 | "websocket": "^1.0.18" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/src/libb64/cdecode_inc.h: -------------------------------------------------------------------------------- 1 | /* 2 | cdecode.h - c header for a base64 decoding algorithm 3 | 4 | This is part of the libb64 project, and has been placed in the public domain. 5 | For details, see http://sourceforge.net/projects/libb64 6 | */ 7 | 8 | #ifndef BASE64_CDECODE_H 9 | #define BASE64_CDECODE_H 10 | 11 | typedef enum 12 | { 13 | step_a, step_b, step_c, step_d 14 | } base64_decodestep; 15 | 16 | typedef struct 17 | { 18 | base64_decodestep step; 19 | char plainchar; 20 | } base64_decodestate; 21 | 22 | void base64_init_decodestate(base64_decodestate* state_in); 23 | 24 | int base64_decode_value(char value_in); 25 | 26 | int base64_decode_block(const char* code_in, const int length_in, char* plaintext_out, base64_decodestate* state_in); 27 | 28 | #endif /* BASE64_CDECODE_H */ 29 | -------------------------------------------------------------------------------- /h/password.h: -------------------------------------------------------------------------------- 1 | const char password_html[] PROGMEM = R"=====( 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Network-> Password -> Timezone
    11 |

    Password

    12 |
    13 |
      14 |
      15 | 16 | 17 | 18 | 19 | 20 | )====="; 21 | -------------------------------------------------------------------------------- /notes/memory values.csv: -------------------------------------------------------------------------------- 1 | 179: timezone,timezone,between -12 and +12 2 | 181: hour marks,hour marks,"0, 1 or 2 for various settings" 3 | 182: sleep,sleep,hour of sleep time (0-23) 4 | 183: sleepmin,sleepmin,minutes of sleep time (0-59) 5 | 184: showseconds,showseconds,0 or 1 6 | 186: webMode,webMode,debugging 7 | 189: wake,wake,hour of wake time (0-23) 8 | 190: wakemin,wakemin,minutes of wake time (0-59) 9 | 191: brightness,brightness,current brightness (between 0 and 255) 10 | 192: DSTtime,DSTtime,DST or not (0 or 1) 11 | 195: clockname,clockname,for mdsn responder (string) 12 | 228: sleeptype,sleeptype,"int between 0 and 4 (dim, dots, moon, disabled)" 13 | 229: dawnbreak,dawnbreak,0 or 1 for on or off 14 | 230: pixelCount,pixelCount,0 to 255 to allow for different length LED strings 15 | 231: maxBrightness,maxBrightness,0 to 255 to allow for USB power vs mains power 16 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/src/libb64/cencode_inc.h: -------------------------------------------------------------------------------- 1 | /* 2 | cencode.h - c header for a base64 encoding algorithm 3 | 4 | This is part of the libb64 project, and has been placed in the public domain. 5 | For details, see http://sourceforge.net/projects/libb64 6 | */ 7 | 8 | #ifndef BASE64_CENCODE_H 9 | #define BASE64_CENCODE_H 10 | 11 | typedef enum 12 | { 13 | step_A, step_B, step_C 14 | } base64_encodestep; 15 | 16 | typedef struct 17 | { 18 | base64_encodestep step; 19 | char result; 20 | int stepcount; 21 | } base64_encodestate; 22 | 23 | void base64_init_encodestate(base64_encodestate* state_in); 24 | 25 | char base64_encode_value(char value_in); 26 | 27 | int base64_encode_block(const char* plaintext_in, int length_in, char* code_out, base64_encodestate* state_in); 28 | 29 | int base64_encode_blockend(char* code_out, base64_encodestate* state_in); 30 | 31 | #endif /* BASE64_CENCODE_H */ 32 | -------------------------------------------------------------------------------- /h/webconfig.h: -------------------------------------------------------------------------------- 1 | const char webconfig_html[] PROGMEM = R"=====( 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Network -> Password -> Timezone
      10 |

      Choose Your Network

      11 |
      12 |
        13 | $ssids 14 |
        17 | 18 | 19 | 20 | 21 | 22 | )====="; 23 | -------------------------------------------------------------------------------- /lib/Time/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Time 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | time_t KEYWORD1 9 | ####################################### 10 | # Methods and Functions (KEYWORD2) 11 | ####################################### 12 | now KEYWORD2 13 | second KEYWORD2 14 | minute KEYWORD2 15 | hour KEYWORD2 16 | day KEYWORD2 17 | month KEYWORD2 18 | year KEYWORD2 19 | isAM KEYWORD2 20 | isPM KEYWORD2 21 | weekday KEYWORD2 22 | setTime KEYWORD2 23 | adjustTime KEYWORD2 24 | setSyncProvider KEYWORD2 25 | setSyncInterval KEYWORD2 26 | timeStatus KEYWORD2 27 | TimeLib KEYWORD2 28 | ####################################### 29 | # Instances (KEYWORD2) 30 | ####################################### 31 | 32 | ####################################### 33 | # Constants (LITERAL1) 34 | ####################################### 35 | -------------------------------------------------------------------------------- /lib/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for the project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link to executable file. 4 | 5 | The source code of each library should be placed in separate directory, like 6 | "lib/private_lib/[here are source files]". 7 | 8 | For example, see how can be organized `Foo` and `Bar` libraries: 9 | 10 | |--lib 11 | | |--Bar 12 | | | |--docs 13 | | | |--examples 14 | | | |--src 15 | | | |- Bar.c 16 | | | |- Bar.h 17 | | |--Foo 18 | | | |- Foo.c 19 | | | |- Foo.h 20 | | |- readme.txt --> THIS FILE 21 | |- platformio.ini 22 | |--src 23 | |- main.c 24 | 25 | Then in `src/main.c` you should use: 26 | 27 | #include 28 | #include 29 | 30 | // rest H/C/CPP code 31 | 32 | PlatformIO will find your libraries automatically, configure preprocessor's 33 | include paths and build them. 34 | 35 | See additional options for PlatformIO Library Dependency Finder `lib_*`: 36 | 37 | http://docs.platformio.org/en/latest/projectconf.html#lib-install 38 | 39 | -------------------------------------------------------------------------------- /html/timezonesetup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Time Zone 4 | 5 | 6 | 7 | 8 | 9 |
        10 | 11 | Network-> Password -> Timezone
        12 |

        Set Timezone

        13 | 14 |
        15 |

        HOME

        16 | 17 |
        18 | UTC Offset:
        19 |
        20 | 21 |
        22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /h/buttongradient.h: -------------------------------------------------------------------------------- 1 | const char buttongradient_css[] PROGMEM = R"=====( 2 | 17 | )====="; 18 | -------------------------------------------------------------------------------- /html/testwebsock.html: -------------------------------------------------------------------------------- 1 | "text/html", "LED Control:

        R:
        G:
        B:
        " -------------------------------------------------------------------------------- /html/advancedserverhtml.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Time Zone 4 | 5 |
        6 | Set timezone manually:
        7 |
        8 |

        9 | 10 |
        11 |
        12 | Return without saving
        13 | Reset to factory default 14 | 15 | 36 | 37 | -------------------------------------------------------------------------------- /h/externallinks.h: -------------------------------------------------------------------------------- 1 | const char externallinks[] PROGMEM = R"=====( 2 | 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 | -------------------------------------------------------------------------------- /html/webconfig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Network -> Password -> Timezone
        11 |

        Choose Your Network

        12 |
        13 |
          14 | 15 |
          16 |
          17 |
          18 |
          21 |
          22 | 23 | 24 | 25 | 26 | 27 | 28 | 38 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/tests/webSocket.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 40 | 41 | 42 | 43 | LED Control:
          44 |
          45 | R:
          46 | G:
          47 | B:
          48 | 49 | -------------------------------------------------------------------------------- /lib/NTP/ntp.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * NTP.h - gets current time from an NTP server or pool of servers. 3 | * This code is a modified version of the example "Time_NTP.pde" which 4 | * is included with the time library. 5 | * modified by William Moeur and made into a library: 28 MAY 2015. 6 | * This code is in the public domain. 7 | *****************************************************************************/ 8 | 9 | #ifndef NTP_H 10 | #define NTP_H 11 | 12 | #include "IPAddress.h" 13 | #include "WiFiUdp.h" 14 | #include 15 | #include 16 | 17 | 18 | class NTP 19 | { 20 | public: 21 | NTP(); 22 | void begin(const char* ntpServerName, float TimeZoneOffset); 23 | time_t getNtpTime(void); 24 | void updateTimeZone(float TimeZoneOffset); 25 | 26 | 27 | private: 28 | #define LOCALPORT 2390 // local port to listen on for UDP packets 29 | #define NTP_PACKET_SIZE 48 // NTP time stamp is in the first 48 bytes of the message 30 | #define seventyYears 2208988800UL // Unix time starts on Jan 1 1970. that's 2208988800 seconds 31 | //#define SECS_PER_HOUR 3600 32 | 33 | void sendNTPpacket(IPAddress &address); 34 | uint8_t DSToffset(time_t date); 35 | 36 | WiFiUDP UDP; // A UDP instance to let us send and receive packets over UDP 37 | uint8_t packetBuffer[ NTP_PACKET_SIZE]; //buffer to hold incoming and outgoing packets 38 | const char* _serverName; 39 | time_t _syncInterval = SECS_PER_HOUR; 40 | float _timeZoneOffset; 41 | }; 42 | 43 | #endif /* NTP_H */ 44 | 45 | -------------------------------------------------------------------------------- /lib/Time/examples/TimeRTC/TimeRTC.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * TimeRTC.pde 3 | * example code illustrating Time library with Real Time Clock. 4 | * 5 | */ 6 | 7 | #include 8 | #include 9 | #include // a basic DS1307 library that returns time as a time_t 10 | 11 | void setup() { 12 | Serial.begin(9600); 13 | while (!Serial) ; // wait until Arduino Serial Monitor opens 14 | setSyncProvider(RTC.get); // the function to get the time from the RTC 15 | if(timeStatus()!= timeSet) 16 | Serial.println("Unable to sync with the RTC"); 17 | else 18 | Serial.println("RTC has set the system time"); 19 | } 20 | 21 | void loop() 22 | { 23 | if (timeStatus() == timeSet) { 24 | digitalClockDisplay(); 25 | } else { 26 | Serial.println("The time has not been set. Please run the Time"); 27 | Serial.println("TimeRTCSet example, or DS1307RTC SetTime example."); 28 | Serial.println(); 29 | delay(4000); 30 | } 31 | delay(1000); 32 | } 33 | 34 | void digitalClockDisplay(){ 35 | // digital clock display of the time 36 | Serial.print(hour()); 37 | printDigits(minute()); 38 | printDigits(second()); 39 | Serial.print(" "); 40 | Serial.print(day()); 41 | Serial.print(" "); 42 | Serial.print(month()); 43 | Serial.print(" "); 44 | Serial.print(year()); 45 | Serial.println(); 46 | } 47 | 48 | void printDigits(int digits){ 49 | // utility function for digital clock display: prints preceding colon and leading 0 50 | Serial.print(":"); 51 | if(digits < 10) 52 | Serial.print('0'); 53 | Serial.print(digits); 54 | } 55 | 56 | -------------------------------------------------------------------------------- /druhvhtml/compressed/compressed.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Settings 5 | 6 | 7 | 8 | 9 | 10 |
          11 |
            12 |
          • 13 | 14 |
            15 | 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 | 53 | 54 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # Continuous Integration (CI) is the practice, in software 2 | # engineering, of merging all developer working copies with a shared mainline 3 | # several times a day < http://docs.platformio.org/en/latest/ci/index.html > 4 | # 5 | # Documentation: 6 | # 7 | # * Travis CI Embedded Builds with PlatformIO 8 | # < https://docs.travis-ci.com/user/integration/platformio/ > 9 | # 10 | # * PlatformIO integration with Travis CI 11 | # < http://docs.platformio.org/en/latest/ci/travis.html > 12 | # 13 | # * User Guide for `platformio ci` command 14 | # < http://docs.platformio.org/en/latest/userguide/cmd_ci.html > 15 | # 16 | # 17 | # Please choice one of the following templates (proposed below) and uncomment 18 | # it (remove "# " before each line) or use own configuration according to the 19 | # Travis CI documentation (see above). 20 | # 21 | 22 | 23 | # 24 | # Template #1: General project. Test it using existing `platformio.ini`. 25 | # 26 | 27 | # language: python 28 | # python: 29 | # - "2.7" 30 | # 31 | # sudo: false 32 | # cache: 33 | # directories: 34 | # - "~/.platformio" 35 | # 36 | # install: 37 | # - pip install -U platformio 38 | # 39 | # script: 40 | # - platformio run 41 | 42 | 43 | # 44 | # Template #2: The project is intended to by used as a library with examples 45 | # 46 | 47 | # language: python 48 | # python: 49 | # - "2.7" 50 | # 51 | # sudo: false 52 | # cache: 53 | # directories: 54 | # - "~/.platformio" 55 | # 56 | # env: 57 | # - PLATFORMIO_CI_SRC=path/to/test/file.c 58 | # - PLATFORMIO_CI_SRC=examples/file.ino 59 | # - PLATFORMIO_CI_SRC=path/to/test/directory 60 | # 61 | # install: 62 | # - pip install -U platformio 63 | # 64 | # script: 65 | # - platformio ci --lib="." --board=TYPE_1 --board=TYPE_2 --board=TYPE_N 66 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/src/libb64/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright-Only Dedication (based on United States law) 2 | or Public Domain Certification 3 | 4 | The person or persons who have associated work with this document (the 5 | "Dedicator" or "Certifier") hereby either (a) certifies that, to the best of 6 | his knowledge, the work of authorship identified is in the public domain of the 7 | country from which the work is published, or (b) hereby dedicates whatever 8 | copyright the dedicators holds in the work of authorship identified below (the 9 | "Work") to the public domain. A certifier, moreover, dedicates any copyright 10 | interest he may have in the associated work, and for these purposes, is 11 | described as a "dedicator" below. 12 | 13 | A certifier has taken reasonable steps to verify the copyright status of this 14 | work. Certifier recognizes that his good faith efforts may not shield him from 15 | liability if in fact the work certified is not in the public domain. 16 | 17 | Dedicator makes this dedication for the benefit of the public at large and to 18 | the detriment of the Dedicator's heirs and successors. Dedicator intends this 19 | dedication to be an overt act of relinquishment in perpetuity of all present 20 | and future rights under copyright law, whether vested or contingent, in the 21 | Work. Dedicator understands that such relinquishment of all rights includes 22 | the relinquishment of all rights to enforce (by lawsuit or otherwise) those 23 | copyrights in the Work. 24 | 25 | Dedicator recognizes that, once placed in the public domain, the Work may be 26 | freely reproduced, distributed, transmitted, used, modified, built upon, or 27 | otherwise exploited by anyone for any purpose, commercial or non-commercial, 28 | and in any way, including by methods that have not yet been invented or 29 | conceived. -------------------------------------------------------------------------------- /druhvhtml/settings.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Settings 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
          13 |
            14 |
          • 15 | 16 |
            17 | 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 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /h/timezone.h: -------------------------------------------------------------------------------- 1 | const char timezone_html[] PROGMEM = R"=====( 2 | 3 | 4 | Time Zone 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
          13 |

          Set Timezone

          14 | 18 |
          19 |
          20 |

          HOME

          21 |
          22 |
          23 | Latitude:
          24 | Longitude:
          25 |
          26 |
          27 |
          28 |
          29 | UTC Offset
          30 |
          31 |
          32 |
          33 |
          34 | Return without saving
          35 | 36 | 37 | 38 | )====="; 39 | -------------------------------------------------------------------------------- /h/alarm.h: -------------------------------------------------------------------------------- 1 | const char alarm_html[] PROGMEM = R"=====( 2 | 3 | 4 | 5 | 6 | 7 | 10 | 11 | $externallinks 12 | 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 | -------------------------------------------------------------------------------- /lib/Time/examples/TimeTeensy3/TimeTeensy3.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * TimeRTC.pde 3 | * example code illustrating Time library with Real Time Clock. 4 | * 5 | */ 6 | 7 | #include 8 | 9 | void setup() { 10 | // set the Time library to use Teensy 3.0's RTC to keep time 11 | setSyncProvider(getTeensy3Time); 12 | 13 | Serial.begin(115200); 14 | while (!Serial); // Wait for Arduino Serial Monitor to open 15 | delay(100); 16 | if (timeStatus()!= timeSet) { 17 | Serial.println("Unable to sync with the RTC"); 18 | } else { 19 | Serial.println("RTC has set the system time"); 20 | } 21 | } 22 | 23 | void loop() { 24 | if (Serial.available()) { 25 | time_t t = processSyncMessage(); 26 | if (t != 0) { 27 | Teensy3Clock.set(t); // set the RTC 28 | setTime(t); 29 | } 30 | } 31 | digitalClockDisplay(); 32 | delay(1000); 33 | } 34 | 35 | void digitalClockDisplay() { 36 | // digital clock display of the time 37 | Serial.print(hour()); 38 | printDigits(minute()); 39 | printDigits(second()); 40 | Serial.print(" "); 41 | Serial.print(day()); 42 | Serial.print(" "); 43 | Serial.print(month()); 44 | Serial.print(" "); 45 | Serial.print(year()); 46 | Serial.println(); 47 | } 48 | 49 | time_t getTeensy3Time() 50 | { 51 | return Teensy3Clock.get(); 52 | } 53 | 54 | /* code to process time sync messages from the serial port */ 55 | #define TIME_HEADER "T" // Header tag for serial time sync message 56 | 57 | unsigned long processSyncMessage() { 58 | unsigned long pctime = 0L; 59 | const unsigned long DEFAULT_TIME = 1357041600; // Jan 1 2013 60 | 61 | if(Serial.find(TIME_HEADER)) { 62 | pctime = Serial.parseInt(); 63 | return pctime; 64 | if( pctime < DEFAULT_TIME) { // check the value is a valid time (greater than Jan 1 2013) 65 | pctime = 0L; // return 0 to indicate that the time is not valid 66 | } 67 | } 68 | return pctime; 69 | } 70 | 71 | void printDigits(int digits){ 72 | // utility function for digital clock display: prints preceding colon and leading 0 73 | Serial.print(":"); 74 | if(digits < 10) 75 | Serial.print('0'); 76 | Serial.print(digits); 77 | } 78 | 79 | -------------------------------------------------------------------------------- /html/timezone.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Time Zone 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
            16 |

            Set Timezone

            17 | 22 | 23 |
            24 |
            25 |

            HOME

            26 |
            27 |
            28 | Latitude:
            29 | Longitude:
            30 |
            31 | 32 |
            33 |
            34 |
            35 | UTC Offset
            36 |
            37 |
            38 | 39 |
            40 |
            41 | Return without saving
            42 | 43 | 64 | 65 | -------------------------------------------------------------------------------- /lib/Time/examples/TimeArduinoDue/TimeArduinoDue.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * TimeRTC.pde 3 | * example code illustrating Time library with Real Time Clock. 4 | * 5 | * This example requires Markus Lange's Arduino Due RTC Library 6 | * https://github.com/MarkusLange/Arduino-Due-RTC-Library 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | // Select the Slowclock source 13 | //RTC_clock rtc_clock(RC); 14 | RTC_clock rtc_clock(XTAL); 15 | 16 | void setup() { 17 | Serial.begin(9600); 18 | rtc_clock.init(); 19 | if (rtc_clock.date_already_set() == 0) { 20 | // Unfortunately, the Arduino Due hardware does not seem to 21 | // be designed to maintain the RTC clock state when the 22 | // board resets. Markus described it thusly: "Uhh the Due 23 | // does reset with the NRSTB pin. This resets the full chip 24 | // with all backup regions including RTC, RTT and SC. Only 25 | // if the reset is done with the NRST pin will these regions 26 | // stay with their old values." 27 | rtc_clock.set_time(__TIME__); 28 | rtc_clock.set_date(__DATE__); 29 | // However, this might work on other unofficial SAM3X boards 30 | // with different reset circuitry than Arduino Due? 31 | } 32 | setSyncProvider(getArduinoDueTime); 33 | if(timeStatus()!= timeSet) 34 | Serial.println("Unable to sync with the RTC"); 35 | else 36 | Serial.println("RTC has set the system time"); 37 | } 38 | 39 | time_t getArduinoDueTime() 40 | { 41 | return rtc_clock.unixtime(); 42 | } 43 | 44 | void loop() 45 | { 46 | digitalClockDisplay(); 47 | delay(1000); 48 | } 49 | 50 | void digitalClockDisplay(){ 51 | // digital clock display of the time 52 | Serial.print(hour()); 53 | printDigits(minute()); 54 | printDigits(second()); 55 | Serial.print(" "); 56 | Serial.print(day()); 57 | Serial.print(" "); 58 | Serial.print(month()); 59 | Serial.print(" "); 60 | Serial.print(year()); 61 | Serial.println(); 62 | } 63 | 64 | void printDigits(int digits){ 65 | // utility function for digital clock display: prints preceding colon and leading 0 66 | Serial.print(":"); 67 | if(digits < 10) 68 | Serial.print('0'); 69 | Serial.print(digits); 70 | } 71 | 72 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/tests/webSocketServer/index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var WebSocketServer = require('websocket').server; 3 | var http = require('http'); 4 | 5 | var server = http.createServer(function(request, response) { 6 | console.log((new Date()) + ' Received request for ' + request.url); 7 | response.writeHead(404); 8 | response.end(); 9 | }); 10 | server.listen(81, function() { 11 | console.log((new Date()) + ' Server is listening on port 8011'); 12 | }); 13 | 14 | wsServer = new WebSocketServer({ 15 | httpServer: server, 16 | // You should not use autoAcceptConnections for production 17 | // applications, as it defeats all standard cross-origin protection 18 | // facilities built into the protocol and the browser. You should 19 | // *always* verify the connection's origin and decide whether or not 20 | // to accept it. 21 | autoAcceptConnections: false 22 | }); 23 | 24 | function originIsAllowed(origin) { 25 | // put logic here to detect whether the specified origin is allowed. 26 | return true; 27 | } 28 | 29 | wsServer.on('request', function(request) { 30 | 31 | if (!originIsAllowed(request.origin)) { 32 | // Make sure we only accept requests from an allowed origin 33 | request.reject(); 34 | console.log((new Date()) + ' Connection from origin ' + request.origin + ' rejected.'); 35 | return; 36 | } 37 | 38 | var connection = request.accept('arduino', request.origin); 39 | console.log((new Date()) + ' Connection accepted.'); 40 | 41 | connection.on('message', function(message) { 42 | if (message.type === 'utf8') { 43 | console.log('Received Message: ' + message.utf8Data); 44 | // connection.sendUTF(message.utf8Data); 45 | } 46 | else if (message.type === 'binary') { 47 | console.log('Received Binary Message of ' + message.binaryData.length + ' bytes'); 48 | //connection.sendBytes(message.binaryData); 49 | } 50 | }); 51 | 52 | connection.on('close', function(reasonCode, description) { 53 | console.log((new Date()) + ' Peer ' + connection.remoteAddress + ' disconnected.'); 54 | }); 55 | 56 | connection.sendUTF("Hallo Client!"); 57 | }); -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/examples/WebSocketClientSSL/WebSocketClientSSL.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * WebSocketClientSSL.ino 3 | * 4 | * Created on: 10.12.2015 5 | * 6 | * note SSL is only possible with the ESP8266 7 | * 8 | */ 9 | 10 | #include 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | #include 18 | 19 | ESP8266WiFiMulti WiFiMulti; 20 | WebSocketsClient webSocket; 21 | 22 | 23 | #define USE_SERIAL Serial1 24 | 25 | void webSocketEvent(WStype_t type, uint8_t * payload, size_t length) { 26 | 27 | 28 | switch(type) { 29 | case WStype_DISCONNECTED: 30 | USE_SERIAL.printf("[WSc] Disconnected!\n"); 31 | break; 32 | case WStype_CONNECTED: 33 | { 34 | USE_SERIAL.printf("[WSc] Connected to url: %s\n", payload); 35 | 36 | // send message to server when Connected 37 | webSocket.sendTXT("Connected"); 38 | } 39 | break; 40 | case WStype_TEXT: 41 | USE_SERIAL.printf("[WSc] get text: %s\n", payload); 42 | 43 | // send message to server 44 | // webSocket.sendTXT("message here"); 45 | break; 46 | case WStype_BIN: 47 | USE_SERIAL.printf("[WSc] get binary length: %u\n", length); 48 | hexdump(payload, length); 49 | 50 | // send data to server 51 | // webSocket.sendBIN(payload, length); 52 | break; 53 | } 54 | 55 | } 56 | 57 | void setup() { 58 | // USE_SERIAL.begin(921600); 59 | USE_SERIAL.begin(115200); 60 | 61 | //Serial.setDebugOutput(true); 62 | USE_SERIAL.setDebugOutput(true); 63 | 64 | USE_SERIAL.println(); 65 | USE_SERIAL.println(); 66 | USE_SERIAL.println(); 67 | 68 | for(uint8_t t = 4; t > 0; t--) { 69 | USE_SERIAL.printf("[SETUP] BOOT WAIT %d...\n", t); 70 | USE_SERIAL.flush(); 71 | delay(1000); 72 | } 73 | 74 | WiFiMulti.addAP("SSID", "passpasspass"); 75 | 76 | //WiFi.disconnect(); 77 | while(WiFiMulti.run() != WL_CONNECTED) { 78 | delay(100); 79 | } 80 | 81 | webSocket.beginSSL("192.168.0.123", 81); 82 | webSocket.onEvent(webSocketEvent); 83 | 84 | } 85 | 86 | void loop() { 87 | webSocket.loop(); 88 | } 89 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/examples/WebSocketClient/WebSocketClient.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * WebSocketClient.ino 3 | * 4 | * Created on: 24.05.2015 5 | * 6 | */ 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | #include 16 | 17 | ESP8266WiFiMulti WiFiMulti; 18 | WebSocketsClient webSocket; 19 | 20 | 21 | #define USE_SERIAL Serial1 22 | 23 | void webSocketEvent(WStype_t type, uint8_t * payload, size_t lenght) { 24 | 25 | 26 | switch(type) { 27 | case WStype_DISCONNECTED: 28 | USE_SERIAL.printf("[WSc] Disconnected!\n"); 29 | break; 30 | case WStype_CONNECTED: 31 | { 32 | USE_SERIAL.printf("[WSc] Connected to url: %s\n", payload); 33 | 34 | // send message to server when Connected 35 | webSocket.sendTXT("Connected"); 36 | } 37 | break; 38 | case WStype_TEXT: 39 | USE_SERIAL.printf("[WSc] get text: %s\n", payload); 40 | 41 | // send message to server 42 | // webSocket.sendTXT("message here"); 43 | break; 44 | case WStype_BIN: 45 | USE_SERIAL.printf("[WSc] get binary lenght: %u\n", lenght); 46 | hexdump(payload, lenght); 47 | 48 | // send data to server 49 | // webSocket.sendBIN(payload, lenght); 50 | break; 51 | } 52 | 53 | } 54 | 55 | void setup() { 56 | // USE_SERIAL.begin(921600); 57 | USE_SERIAL.begin(115200); 58 | 59 | //Serial.setDebugOutput(true); 60 | USE_SERIAL.setDebugOutput(true); 61 | 62 | USE_SERIAL.println(); 63 | USE_SERIAL.println(); 64 | USE_SERIAL.println(); 65 | 66 | for(uint8_t t = 4; t > 0; t--) { 67 | USE_SERIAL.printf("[SETUP] BOOT WAIT %d...\n", t); 68 | USE_SERIAL.flush(); 69 | delay(1000); 70 | } 71 | 72 | WiFiMulti.addAP("SSID", "passpasspass"); 73 | 74 | //WiFi.disconnect(); 75 | while(WiFiMulti.run() != WL_CONNECTED) { 76 | delay(100); 77 | } 78 | 79 | webSocket.begin("192.168.0.123", 81); 80 | //webSocket.setAuthorization("user", "Password"); // HTTP Basic Authorization 81 | webSocket.onEvent(webSocketEvent); 82 | 83 | } 84 | 85 | void loop() { 86 | webSocket.loop(); 87 | } 88 | -------------------------------------------------------------------------------- /lib/NeoPixelBus/examples/NeoPixelTest/NeoPixelTest.pde: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define pixelCount 4 // this example assumes 4 pixels, making it smaller will cause a failure 4 | #define pixelPin 8 // make sure to set this to the correct pin 5 | 6 | #define colorSaturation 128 7 | 8 | NeoPixelBus strip = NeoPixelBus(pixelCount, pixelPin); 9 | // NeoPixelBus strip = NeoPixelBus(pixelCount, pixelPin, NEO_RGB); 10 | // 11 | // some pixels require the color components to be in a different order 12 | // using the flag NEO_GRB will use the order; green, red, then blue. 13 | // 14 | 15 | 16 | RgbColor red = RgbColor(colorSaturation, 0, 0); 17 | RgbColor green = RgbColor(0, colorSaturation, 0); 18 | RgbColor blue = RgbColor(0, 0, colorSaturation); 19 | RgbColor white = RgbColor(colorSaturation); 20 | RgbColor black = RgbColor(0); 21 | 22 | 23 | HslColor hslRed( red ); 24 | HslColor hslGreen( green ); 25 | HslColor hslBlue( blue ); 26 | HslColor hslWhite( white ); 27 | HslColor hslBlack( black ); 28 | 29 | void setup() 30 | { 31 | // this resets all the neopixels to an off state 32 | strip.Begin(); 33 | strip.Show(); 34 | } 35 | 36 | 37 | void loop() 38 | { 39 | delay(1000); 40 | 41 | // set the colors, 42 | // if they don't match in order, you may need to use NEO_GRB flag 43 | strip.SetPixelColor(0, red); 44 | strip.SetPixelColor(1, green); 45 | strip.SetPixelColor(2, blue); 46 | strip.SetPixelColor(3, white); 47 | strip.Show(); 48 | 49 | 50 | delay(3000); 51 | 52 | // turn off the pixels 53 | strip.SetPixelColor(0, black); 54 | strip.SetPixelColor(1, black); 55 | strip.SetPixelColor(2, black); 56 | strip.SetPixelColor(3, black); 57 | strip.Show(); 58 | 59 | delay(1000); 60 | 61 | // set the colors, 62 | // if they don't match in order, you may need to use NEO_GRB flag 63 | strip.SetPixelColor(0, hslRed); 64 | strip.SetPixelColor(1, hslGreen); 65 | strip.SetPixelColor(2, hslBlue); 66 | strip.SetPixelColor(3, hslWhite); 67 | strip.Show(); 68 | 69 | 70 | delay(3000); 71 | 72 | // turn off the pixels 73 | strip.SetPixelColor(0, hslBlack); 74 | strip.SetPixelColor(1, hslBlack); 75 | strip.SetPixelColor(2, hslBlack); 76 | strip.SetPixelColor(3, hslBlack); 77 | strip.Show(); 78 | } 79 | 80 | 81 | -------------------------------------------------------------------------------- /html/alarm.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 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 | -------------------------------------------------------------------------------- /lib/Time/examples/TimeRTCSet/TimeRTCSet.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * TimeRTCSet.pde 3 | * example code illustrating Time library with Real Time Clock. 4 | * 5 | * RTC clock is set in response to serial port time message 6 | * A Processing example sketch to set the time is included in the download 7 | * On Linux, you can use "date +T%s > /dev/ttyACM0" (UTC time zone) 8 | */ 9 | 10 | #include 11 | #include 12 | #include // a basic DS1307 library that returns time as a time_t 13 | 14 | 15 | void setup() { 16 | Serial.begin(9600); 17 | while (!Serial) ; // Needed for Leonardo only 18 | setSyncProvider(RTC.get); // the function to get the time from the RTC 19 | if (timeStatus() != timeSet) 20 | Serial.println("Unable to sync with the RTC"); 21 | else 22 | Serial.println("RTC has set the system time"); 23 | } 24 | 25 | void loop() 26 | { 27 | if (Serial.available()) { 28 | time_t t = processSyncMessage(); 29 | if (t != 0) { 30 | RTC.set(t); // set the RTC and the system time to the received value 31 | setTime(t); 32 | } 33 | } 34 | digitalClockDisplay(); 35 | delay(1000); 36 | } 37 | 38 | void digitalClockDisplay(){ 39 | // digital clock display of the time 40 | Serial.print(hour()); 41 | printDigits(minute()); 42 | printDigits(second()); 43 | Serial.print(" "); 44 | Serial.print(day()); 45 | Serial.print(" "); 46 | Serial.print(month()); 47 | Serial.print(" "); 48 | Serial.print(year()); 49 | Serial.println(); 50 | } 51 | 52 | void printDigits(int digits){ 53 | // utility function for digital clock display: prints preceding colon and leading 0 54 | Serial.print(":"); 55 | if(digits < 10) 56 | Serial.print('0'); 57 | Serial.print(digits); 58 | } 59 | 60 | /* code to process time sync messages from the serial port */ 61 | #define TIME_HEADER "T" // Header tag for serial time sync message 62 | 63 | unsigned long processSyncMessage() { 64 | unsigned long pctime = 0L; 65 | const unsigned long DEFAULT_TIME = 1357041600; // Jan 1 2013 66 | 67 | if(Serial.find(TIME_HEADER)) { 68 | pctime = Serial.parseInt(); 69 | return pctime; 70 | if( pctime < DEFAULT_TIME) { // check the value is a valid time (greater than Jan 1 2013) 71 | pctime = 0L; // return 0 to indicate that the time is not valid 72 | } 73 | } 74 | return pctime; 75 | } 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /lib/NeoPixelBus/NeoPixelAnimator.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------- 2 | NeoPixel is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU Lesser General Public License as 4 | published by the Free Software Foundation, either version 3 of 5 | the License, or (at your option) any later version. 6 | 7 | NeoPixel is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU Lesser General Public License for more details. 11 | 12 | You should have received a copy of the GNU Lesser General Public 13 | License along with NeoPixel. If not, see 14 | . 15 | --------------------------------------------------------------------*/ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | class NeoPixelBus; 23 | 24 | typedef std::function AnimUpdateCallback; 25 | 26 | class NeoPixelAnimator 27 | { 28 | public: 29 | NeoPixelAnimator(NeoPixelBus* bus); 30 | ~NeoPixelAnimator(); 31 | 32 | bool IsAnimating() const 33 | { 34 | return _activeAnimations > 0; 35 | } 36 | 37 | bool IsAnimating(uint16_t n) 38 | { 39 | return (IsAnimating() && _animations[n].time != 0); 40 | } 41 | 42 | void StartAnimation(uint16_t n, uint16_t time, AnimUpdateCallback animUpdate); 43 | void StopAnimation(uint16_t n); 44 | void UpdateAnimations(uint32_t maxDeltaMs = 1000); 45 | 46 | bool IsPaused() 47 | { 48 | return (!_isRunning); 49 | } 50 | 51 | void Pause() 52 | { 53 | _isRunning = false; 54 | } 55 | 56 | void Resume() 57 | { 58 | _isRunning = true; 59 | _animationLastTick = millis(); 60 | } 61 | 62 | void FadeTo(uint16_t time, RgbColor color); 63 | 64 | private: 65 | NeoPixelBus* _bus; 66 | 67 | struct AnimationContext 68 | { 69 | AnimationContext() : 70 | time(0), 71 | remaining(0), 72 | fnUpdate(NULL) 73 | {} 74 | 75 | uint16_t time; 76 | uint16_t remaining; 77 | 78 | AnimUpdateCallback fnUpdate; 79 | }; 80 | 81 | AnimationContext* _animations; 82 | uint32_t _animationLastTick; 83 | uint16_t _activeAnimations; 84 | bool _isRunning; 85 | }; -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/examples/WebSocketClientAVR/WebSocketClientAVR.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * WebSocketClientAVR.ino 3 | * 4 | * Created on: 10.12.2015 5 | * 6 | */ 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | 16 | 17 | // Enter a MAC address for your controller below. 18 | // Newer Ethernet shields have a MAC address printed on a sticker on the shield 19 | byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; 20 | 21 | // Set the static IP address to use if the DHCP fails to assign 22 | IPAddress ip(192, 168, 0, 177); 23 | 24 | WebSocketsClient webSocket; 25 | 26 | 27 | 28 | void webSocketEvent(WStype_t type, uint8_t * payload, size_t length) { 29 | 30 | 31 | switch(type) { 32 | case WStype_DISCONNECTED: 33 | Serial.println("[WSc] Disconnected!\n"); 34 | break; 35 | case WStype_CONNECTED: 36 | { 37 | Serial.print("[WSc] Connected to url: "); 38 | Serial.println((char *)payload); 39 | // send message to server when Connected 40 | webSocket.sendTXT("Connected"); 41 | } 42 | break; 43 | case WStype_TEXT: 44 | Serial.print("[WSc] get text: "); 45 | Serial.println((char *)payload); 46 | // send message to server 47 | // webSocket.sendTXT("message here"); 48 | break; 49 | case WStype_BIN: 50 | Serial.print("[WSc] get binary length: "); 51 | Serial.println(length); 52 | // hexdump(payload, length); 53 | 54 | // send data to server 55 | // webSocket.sendBIN(payload, length); 56 | break; 57 | } 58 | 59 | } 60 | 61 | void setup() 62 | { 63 | // Open serial communications and wait for port to open: 64 | Serial.begin(115200); 65 | while (!Serial) {} 66 | 67 | // start the Ethernet connection: 68 | if (Ethernet.begin(mac) == 0) { 69 | Serial.println("Failed to configure Ethernet using DHCP"); 70 | // no point in carrying on, so do nothing forevermore: 71 | // try to congifure using IP address instead of DHCP: 72 | Ethernet.begin(mac, ip); 73 | } 74 | 75 | webSocket.begin("192.168.0.123", 8011); 76 | webSocket.onEvent(webSocketEvent); 77 | 78 | } 79 | 80 | 81 | void loop() 82 | { 83 | webSocket.loop(); 84 | } 85 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/examples/WebSocketServer/WebSocketServer.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * WebSocketServer.ino 3 | * 4 | * Created on: 22.05.2015 5 | * 6 | */ 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | ESP8266WiFiMulti WiFiMulti; 16 | 17 | WebSocketsServer webSocket = WebSocketsServer(81); 18 | 19 | #define USE_SERIAL Serial1 20 | 21 | void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght) { 22 | 23 | switch(type) { 24 | case WStype_DISCONNECTED: 25 | USE_SERIAL.printf("[%u] Disconnected!\n", num); 26 | break; 27 | case WStype_CONNECTED: 28 | { 29 | IPAddress ip = webSocket.remoteIP(num); 30 | USE_SERIAL.printf("[%u] Connected from %d.%d.%d.%d url: %s\n", num, ip[0], ip[1], ip[2], ip[3], payload); 31 | 32 | // send message to client 33 | webSocket.sendTXT(num, "Connected"); 34 | } 35 | break; 36 | case WStype_TEXT: 37 | USE_SERIAL.printf("[%u] get Text: %s\n", num, payload); 38 | 39 | // send message to client 40 | // webSocket.sendTXT(num, "message here"); 41 | 42 | // send data to all connected clients 43 | // webSocket.broadcastTXT("message here"); 44 | break; 45 | case WStype_BIN: 46 | USE_SERIAL.printf("[%u] get binary lenght: %u\n", num, lenght); 47 | hexdump(payload, lenght); 48 | 49 | // send message to client 50 | // webSocket.sendBIN(num, payload, lenght); 51 | break; 52 | } 53 | 54 | } 55 | 56 | void setup() { 57 | // USE_SERIAL.begin(921600); 58 | USE_SERIAL.begin(115200); 59 | 60 | //Serial.setDebugOutput(true); 61 | USE_SERIAL.setDebugOutput(true); 62 | 63 | USE_SERIAL.println(); 64 | USE_SERIAL.println(); 65 | USE_SERIAL.println(); 66 | 67 | for(uint8_t t = 4; t > 0; t--) { 68 | USE_SERIAL.printf("[SETUP] BOOT WAIT %d...\n", t); 69 | USE_SERIAL.flush(); 70 | delay(1000); 71 | } 72 | 73 | WiFiMulti.addAP("SSID", "passpasspass"); 74 | 75 | while(WiFiMulti.run() != WL_CONNECTED) { 76 | delay(100); 77 | } 78 | 79 | webSocket.begin(); 80 | webSocket.onEvent(webSocketEvent); 81 | } 82 | 83 | void loop() { 84 | webSocket.loop(); 85 | } 86 | 87 | -------------------------------------------------------------------------------- /lib/Time/examples/TimeSerial/TimeSerial.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * TimeSerial.pde 3 | * example code illustrating Time library set through serial port messages. 4 | * 5 | * Messages consist of the letter T followed by ten digit time (as seconds since Jan 1 1970) 6 | * you can send the text on the next line using Serial Monitor to set the clock to noon Jan 1 2013 7 | T1357041600 8 | * 9 | * A Processing example sketch to automatically send the messages is included in the download 10 | * On Linux, you can use "date +T%s\n > /dev/ttyACM0" (UTC time zone) 11 | */ 12 | 13 | #include 14 | 15 | #define TIME_HEADER "T" // Header tag for serial time sync message 16 | #define TIME_REQUEST 7 // ASCII bell character requests a time sync message 17 | 18 | void setup() { 19 | Serial.begin(9600); 20 | while (!Serial) ; // Needed for Leonardo only 21 | pinMode(13, OUTPUT); 22 | setSyncProvider( requestSync); //set function to call when sync required 23 | Serial.println("Waiting for sync message"); 24 | } 25 | 26 | void loop(){ 27 | if (Serial.available()) { 28 | processSyncMessage(); 29 | } 30 | if (timeStatus()!= timeNotSet) { 31 | digitalClockDisplay(); 32 | } 33 | if (timeStatus() == timeSet) { 34 | digitalWrite(13, HIGH); // LED on if synced 35 | } else { 36 | digitalWrite(13, LOW); // LED off if needs refresh 37 | } 38 | delay(1000); 39 | } 40 | 41 | void digitalClockDisplay(){ 42 | // digital clock display of the time 43 | Serial.print(hour()); 44 | printDigits(minute()); 45 | printDigits(second()); 46 | Serial.print(" "); 47 | Serial.print(day()); 48 | Serial.print(" "); 49 | Serial.print(month()); 50 | Serial.print(" "); 51 | Serial.print(year()); 52 | Serial.println(); 53 | } 54 | 55 | void printDigits(int digits){ 56 | // utility function for digital clock display: prints preceding colon and leading 0 57 | Serial.print(":"); 58 | if(digits < 10) 59 | Serial.print('0'); 60 | Serial.print(digits); 61 | } 62 | 63 | 64 | void processSyncMessage() { 65 | unsigned long pctime; 66 | const unsigned long DEFAULT_TIME = 1357041600; // Jan 1 2013 67 | 68 | if(Serial.find(TIME_HEADER)) { 69 | pctime = Serial.parseInt(); 70 | if( pctime >= DEFAULT_TIME) { // check the integer is a valid time (greater than Jan 1 2013) 71 | setTime(pctime); // Sync Arduino clock to the time received on the serial port 72 | } 73 | } 74 | } 75 | 76 | time_t requestSync() 77 | { 78 | Serial.write(TIME_REQUEST); 79 | return 0; // the time will be sent later in response to serial mesg 80 | } 81 | 82 | -------------------------------------------------------------------------------- /lib/Time/examples/Processing/SyncArduinoClock/SyncArduinoClock.pde: -------------------------------------------------------------------------------- 1 | /** 2 | * SyncArduinoClock. 3 | * 4 | * portIndex must be set to the port connected to the Arduino 5 | * 6 | * The current time is sent in response to request message from Arduino 7 | * or by clicking the display window 8 | * 9 | * The time message is 11 ASCII text characters; a header (the letter 'T') 10 | * followed by the ten digit system time (unix time) 11 | */ 12 | 13 | 14 | import processing.serial.*; 15 | import java.util.Date; 16 | import java.util.Calendar; 17 | import java.util.GregorianCalendar; 18 | 19 | public static final short portIndex = 0; // select the com port, 0 is the first port 20 | public static final String TIME_HEADER = "T"; //header for arduino serial time message 21 | public static final char TIME_REQUEST = 7; // ASCII bell character 22 | public static final char LF = 10; // ASCII linefeed 23 | public static final char CR = 13; // ASCII linefeed 24 | Serial myPort; // Create object from Serial class 25 | 26 | void setup() { 27 | size(200, 200); 28 | println(Serial.list()); 29 | println(" Connecting to -> " + Serial.list()[portIndex]); 30 | myPort = new Serial(this,Serial.list()[portIndex], 9600); 31 | println(getTimeNow()); 32 | } 33 | 34 | void draw() 35 | { 36 | textSize(20); 37 | textAlign(CENTER); 38 | fill(0); 39 | text("Click to send\nTime Sync", 0, 75, 200, 175); 40 | if ( myPort.available() > 0) { // If data is available, 41 | char val = char(myPort.read()); // read it and store it in val 42 | if(val == TIME_REQUEST){ 43 | long t = getTimeNow(); 44 | sendTimeMessage(TIME_HEADER, t); 45 | } 46 | else 47 | { 48 | if(val == LF) 49 | ; //igonore 50 | else if(val == CR) 51 | println(); 52 | else 53 | print(val); // echo everying but time request 54 | } 55 | } 56 | } 57 | 58 | void mousePressed() { 59 | sendTimeMessage( TIME_HEADER, getTimeNow()); 60 | } 61 | 62 | 63 | void sendTimeMessage(String header, long time) { 64 | String timeStr = String.valueOf(time); 65 | myPort.write(header); // send header and time to arduino 66 | myPort.write(timeStr); 67 | myPort.write('\n'); 68 | } 69 | 70 | long getTimeNow(){ 71 | // java time is in ms, we want secs 72 | Date d = new Date(); 73 | Calendar cal = new GregorianCalendar(); 74 | long current = d.getTime()/1000; 75 | long timezone = cal.get(cal.ZONE_OFFSET)/1000; 76 | long daylight = cal.get(cal.DST_OFFSET)/1000; 77 | return current + timezone + daylight; 78 | } 79 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/examples/WebSocketServer/WebSocketServerHttpHeaderValidation.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * WebSocketServerHttpHeaderValidation.ino 3 | * 4 | * Created on: 08.06.2016 5 | * 6 | */ 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | ESP8266WiFiMulti WiFiMulti; 16 | 17 | WebSocketsServer webSocket = WebSocketsServer(81); 18 | 19 | #define USE_SERIAL Serial1 20 | 21 | const unsigned long int validSessionId = 12345; //some arbitrary value to act as a valid sessionId 22 | 23 | /* 24 | * Returns a bool value as an indicator to describe whether a user is allowed to initiate a websocket upgrade 25 | * based on the value of a cookie. This function expects the rawCookieHeaderValue to look like this "sessionId=|" 26 | */ 27 | bool isCookieValid(String rawCookieHeaderValue) { 28 | 29 | if (rawCookieHeaderValue.indexOf("sessionId") != -1) { 30 | String sessionIdStr = rawCookieHeaderValue.substring(rawCookieHeaderValue.indexOf("sessionId=") + 10, rawCookieHeaderValue.indexOf("|")); 31 | unsigned long int sessionId = strtoul(sessionIdStr.c_str(), NULL, 10); 32 | return sessionId == validSessionId; 33 | } 34 | return false; 35 | } 36 | 37 | /* 38 | * The WebSocketServerHttpHeaderValFunc delegate passed to webSocket.onValidateHttpHeader 39 | */ 40 | bool validateHttpHeader(String headerName, String headerValue) { 41 | 42 | //assume a true response for any headers not handled by this validator 43 | bool valid = true; 44 | 45 | if(headerName.equalsIgnoreCase("Cookie")) { 46 | //if the header passed is the Cookie header, validate it according to the rules in 'isCookieValid' function 47 | valid = isCookieValid(headerValue); 48 | } 49 | 50 | return valid; 51 | } 52 | 53 | void setup() { 54 | // USE_SERIAL.begin(921600); 55 | USE_SERIAL.begin(115200); 56 | 57 | //Serial.setDebugOutput(true); 58 | USE_SERIAL.setDebugOutput(true); 59 | 60 | USE_SERIAL.println(); 61 | USE_SERIAL.println(); 62 | USE_SERIAL.println(); 63 | 64 | for(uint8_t t = 4; t > 0; t--) { 65 | USE_SERIAL.printf("[SETUP] BOOT WAIT %d...\n", t); 66 | USE_SERIAL.flush(); 67 | delay(1000); 68 | } 69 | 70 | WiFiMulti.addAP("SSID", "passpasspass"); 71 | 72 | while(WiFiMulti.run() != WL_CONNECTED) { 73 | delay(100); 74 | } 75 | 76 | //connecting clients must supply a valid session cookie at websocket upgrade handshake negotiation time 77 | const char * headerkeys[] = { "Cookie" }; 78 | size_t headerKeyCount = sizeof(headerkeys) / sizeof(char*); 79 | webSocket.onValidateHttpHeader(validateHttpHeader, headerkeys, headerKeyCount); 80 | webSocket.begin(); 81 | } 82 | 83 | void loop() { 84 | webSocket.loop(); 85 | } 86 | 87 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/README.md: -------------------------------------------------------------------------------- 1 | WebSocket Server and Client for Arduino 2 | =========================================== 3 | 4 | a WebSocket Server and Client for Arduino based on RFC6455. 5 | 6 | 7 | ##### Supported features of RFC6455 ##### 8 | - text frame 9 | - binary frame 10 | - connection close 11 | - ping 12 | - pong 13 | 14 | ##### Not supported features of RFC6455 ##### 15 | - continuation frame 16 | 17 | ##### Limitations ##### 18 | - max input length is limited to the ram size and the ```WEBSOCKETS_MAX_DATA_SIZE``` define 19 | - max output length has no limit (the hardware is the limit) 20 | - Client send big frames with mask 0x00000000 (on AVR all frames) 21 | 22 | ##### Limitations for Async ##### 23 | - Functions called from within the context of the websocket event might not honor `yield()` and/or `delay()`. See [this issue](https://github.com/Links2004/arduinoWebSockets/issues/58#issuecomment-192376395) for more info and a potential workaround. 24 | - wss / SSL is not possible. 25 | 26 | ##### Supported Hardware ##### 27 | - ESP8266 [Arduino for ESP8266](https://github.com/Links2004/Arduino) 28 | - ESP31B 29 | - ATmega328 with Ethernet Shield (ATmega branch) 30 | - ATmega328 with enc28j60 (ATmega branch) 31 | - ATmega2560 with Ethernet Shield (ATmega branch) 32 | - ATmega2560 with enc28j60 (ATmega branch) 33 | 34 | ###### Note: ###### 35 | 36 | version 2.0 and up is not compatible with AVR/ATmega, check ATmega branch. 37 | 38 | Arduino for AVR not supports std namespace of c++. 39 | 40 | ### wss / SSL ### 41 | supported for: 42 | - wss client on the ESP8266 43 | - wss / SSL is not natively supported in WebSocketsServer however it is possible to achieve secure websockets 44 | by running the device behind an SSL proxy. See [Nginx](examples/Nginx/esp8266.ssl.reverse.proxy.conf) for a 45 | sample Nginx server configuration file to enable this. 46 | 47 | ### ESP Async TCP ### 48 | 49 | This libary can run in Async TCP mode on the ESP. 50 | 51 | The mode can be aktivated in the ```WebSockets.h``` (see WEBSOCKETS_NETWORK_TYPE define). 52 | 53 | [ESPAsyncTCP](https://github.com/me-no-dev/ESPAsyncTCP) libary is required. 54 | 55 | ### Issues ### 56 | Submit issues to: https://github.com/Links2004/arduinoWebSockets/issues 57 | 58 | [![Join the chat at https://gitter.im/Links2004/arduinoWebSockets](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Links2004/arduinoWebSockets?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 59 | 60 | ### License and credits ### 61 | 62 | The library is licensed under [LGPLv2.1](https://github.com/Links2004/arduinoWebSockets/blob/master/LICENSE) 63 | 64 | [libb64](http://libb64.sourceforge.net/) written by Chris Venter. It is distributed under Public Domain see [LICENSE](https://github.com/Links2004/arduinoWebSockets/blob/master/src/libb64/LICENSE). 65 | -------------------------------------------------------------------------------- /lib/Time/examples/TimeGPS/TimeGPS.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * TimeGPS.pde 3 | * example code illustrating time synced from a GPS 4 | * 5 | */ 6 | 7 | #include 8 | #include // http://arduiniana.org/libraries/TinyGPS/ 9 | #include 10 | // TinyGPS and SoftwareSerial libraries are the work of Mikal Hart 11 | 12 | SoftwareSerial SerialGPS = SoftwareSerial(10, 11); // receive on pin 10 13 | TinyGPS gps; 14 | 15 | // To use a hardware serial port, which is far more efficient than 16 | // SoftwareSerial, uncomment this line and remove SoftwareSerial 17 | //#define SerialGPS Serial1 18 | 19 | // Offset hours from gps time (UTC) 20 | const int offset = 1; // Central European Time 21 | //const int offset = -5; // Eastern Standard Time (USA) 22 | //const int offset = -4; // Eastern Daylight Time (USA) 23 | //const int offset = -8; // Pacific Standard Time (USA) 24 | //const int offset = -7; // Pacific Daylight Time (USA) 25 | 26 | // Ideally, it should be possible to learn the time zone 27 | // based on the GPS position data. However, that would 28 | // require a complex library, probably incorporating some 29 | // sort of database using Eric Muller's time zone shape 30 | // maps, at http://efele.net/maps/tz/ 31 | 32 | time_t prevDisplay = 0; // when the digital clock was displayed 33 | 34 | void setup() 35 | { 36 | Serial.begin(9600); 37 | while (!Serial) ; // Needed for Leonardo only 38 | SerialGPS.begin(4800); 39 | Serial.println("Waiting for GPS time ... "); 40 | } 41 | 42 | void loop() 43 | { 44 | while (SerialGPS.available()) { 45 | if (gps.encode(SerialGPS.read())) { // process gps messages 46 | // when TinyGPS reports new data... 47 | unsigned long age; 48 | int Year; 49 | byte Month, Day, Hour, Minute, Second; 50 | gps.crack_datetime(&Year, &Month, &Day, &Hour, &Minute, &Second, NULL, &age); 51 | if (age < 500) { 52 | // set the Time to the latest GPS reading 53 | setTime(Hour, Minute, Second, Day, Month, Year); 54 | adjustTime(offset * SECS_PER_HOUR); 55 | } 56 | } 57 | } 58 | if (timeStatus()!= timeNotSet) { 59 | if (now() != prevDisplay) { //update the display only if the time has changed 60 | prevDisplay = now(); 61 | digitalClockDisplay(); 62 | } 63 | } 64 | } 65 | 66 | void digitalClockDisplay(){ 67 | // digital clock display of the time 68 | Serial.print(hour()); 69 | printDigits(minute()); 70 | printDigits(second()); 71 | Serial.print(" "); 72 | Serial.print(day()); 73 | Serial.print(" "); 74 | Serial.print(month()); 75 | Serial.print(" "); 76 | Serial.print(year()); 77 | Serial.println(); 78 | } 79 | 80 | void printDigits(int digits) { 81 | // utility function for digital clock display: prints preceding colon and leading 0 82 | Serial.print(":"); 83 | if(digits < 10) 84 | Serial.print('0'); 85 | Serial.print(digits); 86 | } 87 | 88 | -------------------------------------------------------------------------------- /h/root.h: -------------------------------------------------------------------------------- 1 | const char root_html[] PROGMEM = R"=====( 2 | 3 | 4 | 5 | 6 | 13 | 14 | $externallinks 15 | $csswgradient 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 | $alarm 63 |
              64 | 68 |
              69 |
              70 | 71 | 72 | )====="; 73 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/src/libb64/cdecode.c: -------------------------------------------------------------------------------- 1 | /* 2 | cdecoder.c - c source to a base64 decoding algorithm implementation 3 | 4 | This is part of the libb64 project, and has been placed in the public domain. 5 | For details, see http://sourceforge.net/projects/libb64 6 | */ 7 | 8 | #ifdef ESP8266 9 | #include 10 | #endif 11 | 12 | #ifndef CORE_HAS_LIBB64 13 | #include "cdecode_inc.h" 14 | 15 | int base64_decode_value(char value_in) 16 | { 17 | static const char decoding[] = {62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-2,-1,-1,-1,0,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,-1,-1,-1,-1,-1,-1,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}; 18 | static const char decoding_size = sizeof(decoding); 19 | value_in -= 43; 20 | if (value_in < 0 || value_in > decoding_size) return -1; 21 | return decoding[(int)value_in]; 22 | } 23 | 24 | void base64_init_decodestate(base64_decodestate* state_in) 25 | { 26 | state_in->step = step_a; 27 | state_in->plainchar = 0; 28 | } 29 | 30 | int base64_decode_block(const char* code_in, const int length_in, char* plaintext_out, base64_decodestate* state_in) 31 | { 32 | const char* codechar = code_in; 33 | char* plainchar = plaintext_out; 34 | char fragment; 35 | 36 | *plainchar = state_in->plainchar; 37 | 38 | switch (state_in->step) 39 | { 40 | while (1) 41 | { 42 | case step_a: 43 | do { 44 | if (codechar == code_in+length_in) 45 | { 46 | state_in->step = step_a; 47 | state_in->plainchar = *plainchar; 48 | return plainchar - plaintext_out; 49 | } 50 | fragment = (char)base64_decode_value(*codechar++); 51 | } while (fragment < 0); 52 | *plainchar = (fragment & 0x03f) << 2; 53 | case step_b: 54 | do { 55 | if (codechar == code_in+length_in) 56 | { 57 | state_in->step = step_b; 58 | state_in->plainchar = *plainchar; 59 | return plainchar - plaintext_out; 60 | } 61 | fragment = (char)base64_decode_value(*codechar++); 62 | } while (fragment < 0); 63 | *plainchar++ |= (fragment & 0x030) >> 4; 64 | *plainchar = (fragment & 0x00f) << 4; 65 | case step_c: 66 | do { 67 | if (codechar == code_in+length_in) 68 | { 69 | state_in->step = step_c; 70 | state_in->plainchar = *plainchar; 71 | return plainchar - plaintext_out; 72 | } 73 | fragment = (char)base64_decode_value(*codechar++); 74 | } while (fragment < 0); 75 | *plainchar++ |= (fragment & 0x03c) >> 2; 76 | *plainchar = (fragment & 0x003) << 6; 77 | case step_d: 78 | do { 79 | if (codechar == code_in+length_in) 80 | { 81 | state_in->step = step_d; 82 | state_in->plainchar = *plainchar; 83 | return plainchar - plaintext_out; 84 | } 85 | fragment = (char)base64_decode_value(*codechar++); 86 | } while (fragment < 0); 87 | *plainchar++ |= (fragment & 0x03f); 88 | } 89 | } 90 | /* control should not reach here */ 91 | return plainchar - plaintext_out; 92 | } 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/src/libb64/cencode.c: -------------------------------------------------------------------------------- 1 | /* 2 | cencoder.c - c source to a base64 encoding algorithm implementation 3 | 4 | This is part of the libb64 project, and has been placed in the public domain. 5 | For details, see http://sourceforge.net/projects/libb64 6 | */ 7 | 8 | #ifdef ESP8266 9 | #include 10 | #endif 11 | 12 | #ifndef CORE_HAS_LIBB64 13 | #include "cencode_inc.h" 14 | 15 | const int CHARS_PER_LINE = 72; 16 | 17 | void base64_init_encodestate(base64_encodestate* state_in) 18 | { 19 | state_in->step = step_A; 20 | state_in->result = 0; 21 | state_in->stepcount = 0; 22 | } 23 | 24 | char base64_encode_value(char value_in) 25 | { 26 | static const char* encoding = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 27 | if (value_in > 63) return '='; 28 | return encoding[(int)value_in]; 29 | } 30 | 31 | int base64_encode_block(const char* plaintext_in, int length_in, char* code_out, base64_encodestate* state_in) 32 | { 33 | const char* plainchar = plaintext_in; 34 | const char* const plaintextend = plaintext_in + length_in; 35 | char* codechar = code_out; 36 | char result; 37 | char fragment; 38 | 39 | result = state_in->result; 40 | 41 | switch (state_in->step) 42 | { 43 | while (1) 44 | { 45 | case step_A: 46 | if (plainchar == plaintextend) 47 | { 48 | state_in->result = result; 49 | state_in->step = step_A; 50 | return codechar - code_out; 51 | } 52 | fragment = *plainchar++; 53 | result = (fragment & 0x0fc) >> 2; 54 | *codechar++ = base64_encode_value(result); 55 | result = (fragment & 0x003) << 4; 56 | case step_B: 57 | if (plainchar == plaintextend) 58 | { 59 | state_in->result = result; 60 | state_in->step = step_B; 61 | return codechar - code_out; 62 | } 63 | fragment = *plainchar++; 64 | result |= (fragment & 0x0f0) >> 4; 65 | *codechar++ = base64_encode_value(result); 66 | result = (fragment & 0x00f) << 2; 67 | case step_C: 68 | if (plainchar == plaintextend) 69 | { 70 | state_in->result = result; 71 | state_in->step = step_C; 72 | return codechar - code_out; 73 | } 74 | fragment = *plainchar++; 75 | result |= (fragment & 0x0c0) >> 6; 76 | *codechar++ = base64_encode_value(result); 77 | result = (fragment & 0x03f) >> 0; 78 | *codechar++ = base64_encode_value(result); 79 | 80 | ++(state_in->stepcount); 81 | if (state_in->stepcount == CHARS_PER_LINE/4) 82 | { 83 | *codechar++ = '\n'; 84 | state_in->stepcount = 0; 85 | } 86 | } 87 | } 88 | /* control should not reach here */ 89 | return codechar - code_out; 90 | } 91 | 92 | int base64_encode_blockend(char* code_out, base64_encodestate* state_in) 93 | { 94 | char* codechar = code_out; 95 | 96 | switch (state_in->step) 97 | { 98 | case step_B: 99 | *codechar++ = base64_encode_value(state_in->result); 100 | *codechar++ = '='; 101 | *codechar++ = '='; 102 | break; 103 | case step_C: 104 | *codechar++ = base64_encode_value(state_in->result); 105 | *codechar++ = '='; 106 | break; 107 | case step_A: 108 | break; 109 | } 110 | *codechar++ = 0x00; 111 | 112 | return codechar - code_out; 113 | } 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /lib/NTP/ntp.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * NTP.cpp - gets current time from an NTP server or pool of servers. 3 | * It is meant to be used with setSyncProvider from the Time library 4 | * - see Example WifiClock 5 | * This code is a modified version of the example "Time_NTP.pde" which 6 | * is included with the time library. 7 | * modified by William Moeur and made into a library: 28 MAY 2015. 8 | * This code is in the public domain. 9 | *****************************************************************************/ 10 | 11 | #include "ESP8266WiFi.h" 12 | #include "Arduino.h" 13 | #include "ntp.h" 14 | 15 | NTP::NTP(void) 16 | { 17 | } 18 | 19 | void NTP::begin(const char* ntpServerName, float TimeZoneOffset) 20 | { 21 | _serverName = ntpServerName; 22 | _timeZoneOffset = TimeZoneOffset; 23 | /* Start WiFiUDP socket, listening at local port LOCALPORT */ 24 | UDP.begin(LOCALPORT); 25 | } 26 | 27 | void NTP::updateTimeZone(float TimeZoneOffset) 28 | { 29 | _timeZoneOffset = TimeZoneOffset; 30 | } 31 | 32 | time_t NTP::getNtpTime(void) 33 | { 34 | 35 | while (UDP.parsePacket() > 0) ; // discard any previously received packets 36 | //get a random server from the pool 37 | IPAddress timeServerIP; 38 | WiFi.hostByName(_serverName, timeServerIP); 39 | sendNTPpacket(timeServerIP); 40 | uint32_t beginWait = millis(); 41 | while (millis() - beginWait < 1500) { 42 | int size = UDP.parsePacket(); 43 | if (size >= NTP_PACKET_SIZE) { 44 | Serial.println("Receive NTP Response"); 45 | UDP.read(packetBuffer, NTP_PACKET_SIZE); // read packet into the buffer 46 | time_t secsSince1900; 47 | // convert four bytes starting at location 40 to a long integer 48 | secsSince1900 = (time_t)packetBuffer[40] << 24; 49 | secsSince1900 |= (time_t)packetBuffer[41] << 16; 50 | secsSince1900 |= (time_t)packetBuffer[42] << 8; 51 | secsSince1900 |= (time_t)packetBuffer[43]; 52 | time_t secsSince1970 = secsSince1900 - 2208988800UL; 53 | float totalOffset = (float)(_timeZoneOffset); 54 | return secsSince1970 + (time_t)(totalOffset * SECS_PER_HOUR) ; 55 | } 56 | yield(); 57 | } 58 | Serial.println("No NTP Response :-("); 59 | return 0; // return 0 if unable to get the time 60 | } 61 | 62 | // send an NTP request to the time server at the given address 63 | void NTP::sendNTPpacket(IPAddress &address) 64 | { 65 | // set all bytes in the buffer to 0 66 | memset(packetBuffer, 0, NTP_PACKET_SIZE); 67 | // Initialize values needed to form NTP request 68 | // (see URL above for details on the packets) 69 | packetBuffer[0] = 0b11100011; // LI, Version, Mode 70 | packetBuffer[1] = 0; // Stratum, or type of clock 71 | packetBuffer[2] = 6; // Polling Interval 72 | packetBuffer[3] = 0xEC; // Peer Clock Precision 73 | // 8 bytes of zero for Root Delay & Root Dispersion 74 | packetBuffer[12] = 49; 75 | packetBuffer[13] = 0x4E; 76 | packetBuffer[14] = 49; 77 | packetBuffer[15] = 52; 78 | // all NTP fields have been given values, now 79 | // you can send a packet requesting a timestamp: 80 | UDP.beginPacket(address, 123); //NTP requests are to port 123 81 | UDP.write(packetBuffer, NTP_PACKET_SIZE); 82 | UDP.endPacket(); 83 | } 84 | 85 | 86 | -------------------------------------------------------------------------------- /Colour.js: -------------------------------------------------------------------------------- 1 | //code.stephenmorley.org 2 | function Colour(){this.getIntegerRGB=function(){var a=this.getRGB();return{r:Math.round(a.r),g:Math.round(a.g),b:Math.round(a.b),a:a.a}};this.getPercentageRGB=function(){var a=this.getRGB();return{r:100*a.r/255,g:100*a.g/255,b:100*a.b/255,a:a.a}};this.getCSSHexadecimalRGB=function(){var a=this.getIntegerRGB(),h=a.r.toString(16),k=a.g.toString(16),a=a.b.toString(16);return"#"+(2==h.length?h:"0"+h)+(2==k.length?k:"0"+k)+(2==a.length?a:"0"+a)};this.getCSSIntegerRGB=function(){var a=this.getIntegerRGB();return"rgb("+a.r+","+a.g+","+a.b+")"};this.getCSSIntegerRGBA=function(){var a=this.getIntegerRGB();return"rgba("+a.r+","+a.g+","+a.b+","+a.a+")"};this.getCSSPercentageRGB=function(){var a=this.getPercentageRGB();return"rgb("+a.r+"%,"+a.g+"%,"+a.b+"%)"};this.getCSSPercentageRGBA=function(){var a=this.getPercentageRGB();return"rgba("+a.r+"%,"+a.g+"%,"+a.b+"%,"+a.a+")"};this.getCSSHSL=function(){var a=this.getHSL();return"hsl("+a.h+","+a.s+"%,"+a.l+"%)"};this.getCSSHSLA=function(){var a=this.getHSL();return"hsla("+a.h+","+a.s+"%,"+a.l+"%,"+a.a+")"};this.setNodeColour=function(a){a.style.color=this.getCSSHexadecimalRGB()};this.setNodeBackgroundColour=function(a){a.style.backgroundColor=this.getCSSHexadecimalRGB()}}RGBColour.prototype=new Colour;function RGBColour(a,h,k,n){function m(a,b){if(0==b)var d=0;else switch(a){case c.r:d=(c.g-c.b)/b*60;0>d&&(d+=360);break;case c.g:d=(c.b-c.r)/b*60+120;break;case c.b:d=(c.r-c.g)/b*60+240}return d}var l=void 0===n?1:Math.max(0,Math.min(1,n)),c={r:Math.max(0,Math.min(255,a)),g:Math.max(0,Math.min(255,h)),b:Math.max(0,Math.min(255,k))},b=null,d=null;this.getRGB=function(){return{r:c.r,g:c.g,b:c.b,a:l}};this.getHSV=function(){if(null==b){var a=Math.max(c.r,c.g,c.b),d=a-Math.min(c.r,c.g,c.b);b={h:m(a,d),s:0==a?0:100*d/a,v:a/2.55}}return{h:b.h,s:b.s,v:b.v,a:l}};this.getHSL=function(){if(null==d){var a=Math.max(c.r,c.g,c.b),b=a-Math.min(c.r,c.g,c.b),f=a/255-b/510;d={h:m(a,b),s:0==b?0:b/2.55/(.5>f?2*f:2-2*f),l:100*f}}return{h:d.h,s:d.s,l:d.l,a:l}}}HSVColour.prototype=new Colour;function HSVColour(a,h,k,n){var m=void 0===n?1:Math.max(0,Math.min(1,n)),l=(a%360+360)%360,c=Math.max(0,Math.min(100,h)),b=Math.max(0,Math.min(100,k)),d=null,e=null;this.getRGB=function(){if(null==d){if(0==c)var a=b,f=b,g=b;else{var e=l/60-Math.floor(l/60),h=b*(1-c/100),k=b*(1-c/100*e),e=b*(1-c/100*(1-e));switch(Math.floor(l/60)){case 0:a=b;f=e;g=h;break;case 1:a=k;f=b;g=h;break;case 2:a=h;f=b;g=e;break;case 3:a=h;f=k;g=b;break;case 4:a=e;f=h;g=b;break;case 5:a=b,f=h,g=k}}d={r:2.55*a,g:2.55*f,b:2.55*g}}return{r:d.r,g:d.g,b:d.b,a:m}};this.getHSV=function(){return{h:l,s:c,v:b,a:m}};this.getHSL=function(){if(null==e){var a=(2-c/100)*b/2;e={h:l,s:c*b/(50>a?2*a:200-2*a),l:a};isNaN(e.s)&&(e.s=0)}return{h:e.h,s:e.s,l:e.l,a:m}}}HSLColour.prototype=new Colour;function HSLColour(a,h,k,n){var m=void 0===n?1:Math.max(0,Math.min(1,n)),l=(a%360+360)%360,c=Math.max(0,Math.min(100,h)),b=Math.max(0,Math.min(100,k)),d=null,e=null;this.getRGB=function(){if(null==d)if(0==c)d={r:2.55*b,g:2.55*b,b:2.55*b};else{var e=50>b?b*(1+c/100):b+c-b*c/100,f=2*b-e;d={r:(a+120)/60%6,g:a/60,b:(a+240)/60%6};for(var g in d)d.hasOwnProperty(g)&&(d[g]=1>d[g]?f+(e-f)*d[g]:3>d[g]?e:4>d[g]?f+(e-f)*(4-d[g]):f,d[g]*=2.55)}return{r:d.r,g:d.g,b:d.b,a:m}};this.getHSV=function(){if(null==e){var a=c*(50>b?b:100-b)/100;e={h:l,s:200*a/(b+a),v:a+b};isNaN(e.s)&&(e.s=0)}return{h:e.h,s:e.s,v:e.v,a:m}};this.getHSL=function(){return{h:l,s:c,l:b,a:m}}}; -------------------------------------------------------------------------------- /h/colourjs.h: -------------------------------------------------------------------------------- 1 | const char colourjs[] PROGMEM = R"=====( 2 | //code.stephenmorley.org 3 | function Colour(){this.getIntegerRGB=function(){var a=this.getRGB();return{r:Math.round(a.r),g:Math.round(a.g),b:Math.round(a.b),a:a.a}};this.getPercentageRGB=function(){var a=this.getRGB();return{r:100*a.r/255,g:100*a.g/255,b:100*a.b/255,a:a.a}};this.getCSSHexadecimalRGB=function(){var a=this.getIntegerRGB(),h=a.r.toString(16),k=a.g.toString(16),a=a.b.toString(16);return"#"+(2==h.length?h:"0"+h)+(2==k.length?k:"0"+k)+(2==a.length?a:"0"+a)};this.getCSSIntegerRGB=function(){var a=this.getIntegerRGB();return"rgb("+a.r+","+a.g+","+a.b+")"};this.getCSSIntegerRGBA=function(){var a=this.getIntegerRGB();return"rgba("+a.r+","+a.g+","+a.b+","+a.a+")"};this.getCSSPercentageRGB=function(){var a=this.getPercentageRGB();return"rgb("+a.r+"%,"+a.g+"%,"+a.b+"%)"};this.getCSSPercentageRGBA=function(){var a=this.getPercentageRGB();return"rgba("+a.r+"%,"+a.g+"%,"+a.b+"%,"+a.a+")"};this.getCSSHSL=function(){var a=this.getHSL();return"hsl("+a.h+","+a.s+"%,"+a.l+"%)"};this.getCSSHSLA=function(){var a=this.getHSL();return"hsla("+a.h+","+a.s+"%,"+a.l+"%,"+a.a+")"};this.setNodeColour=function(a){a.style.color=this.getCSSHexadecimalRGB()};this.setNodeBackgroundColour=function(a){a.style.backgroundColor=this.getCSSHexadecimalRGB()}}RGBColour.prototype=new Colour;function RGBColour(a,h,k,n){function m(a,b){if(0==b)var d=0;else switch(a){case c.r:d=(c.g-c.b)/b*60;0>d&&(d+=360);break;case c.g:d=(c.b-c.r)/b*60+120;break;case c.b:d=(c.r-c.g)/b*60+240}return d}var l=void 0===n?1:Math.max(0,Math.min(1,n)),c={r:Math.max(0,Math.min(255,a)),g:Math.max(0,Math.min(255,h)),b:Math.max(0,Math.min(255,k))},b=null,d=null;this.getRGB=function(){return{r:c.r,g:c.g,b:c.b,a:l}};this.getHSV=function(){if(null==b){var a=Math.max(c.r,c.g,c.b),d=a-Math.min(c.r,c.g,c.b);b={h:m(a,d),s:0==a?0:100*d/a,v:a/2.55}}return{h:b.h,s:b.s,v:b.v,a:l}};this.getHSL=function(){if(null==d){var a=Math.max(c.r,c.g,c.b),b=a-Math.min(c.r,c.g,c.b),f=a/255-b/510;d={h:m(a,b),s:0==b?0:b/2.55/(.5>f?2*f:2-2*f),l:100*f}}return{h:d.h,s:d.s,l:d.l,a:l}}}HSVColour.prototype=new Colour;function HSVColour(a,h,k,n){var m=void 0===n?1:Math.max(0,Math.min(1,n)),l=(a%360+360)%360,c=Math.max(0,Math.min(100,h)),b=Math.max(0,Math.min(100,k)),d=null,e=null;this.getRGB=function(){if(null==d){if(0==c)var a=b,f=b,g=b;else{var e=l/60-Math.floor(l/60),h=b*(1-c/100),k=b*(1-c/100*e),e=b*(1-c/100*(1-e));switch(Math.floor(l/60)){case 0:a=b;f=e;g=h;break;case 1:a=k;f=b;g=h;break;case 2:a=h;f=b;g=e;break;case 3:a=h;f=k;g=b;break;case 4:a=e;f=h;g=b;break;case 5:a=b,f=h,g=k}}d={r:2.55*a,g:2.55*f,b:2.55*g}}return{r:d.r,g:d.g,b:d.b,a:m}};this.getHSV=function(){return{h:l,s:c,v:b,a:m}};this.getHSL=function(){if(null==e){var a=(2-c/100)*b/2;e={h:l,s:c*b/(50>a?2*a:200-2*a),l:a};isNaN(e.s)&&(e.s=0)}return{h:e.h,s:e.s,l:e.l,a:m}}}HSLColour.prototype=new Colour;function HSLColour(a,h,k,n){var m=void 0===n?1:Math.max(0,Math.min(1,n)),l=(a%360+360)%360,c=Math.max(0,Math.min(100,h)),b=Math.max(0,Math.min(100,k)),d=null,e=null;this.getRGB=function(){if(null==d)if(0==c)d={r:2.55*b,g:2.55*b,b:2.55*b};else{var e=50>b?b*(1+c/100):b+c-b*c/100,f=2*b-e;d={r:(a+120)/60%6,g:a/60,b:(a+240)/60%6};for(var g in d)d.hasOwnProperty(g)&&(d[g]=1>d[g]?f+(e-f)*d[g]:3>d[g]?e:4>d[g]?f+(e-f)*(4-d[g]):f,d[g]*=2.55)}return{r:d.r,g:d.g,b:d.b,a:m}};this.getHSV=function(){if(null==e){var a=c*(50>b?b:100-b)/100;e={h:l,s:200*a/(b+a),v:a+b};isNaN(e.s)&&(e.s=0)}return{h:e.h,s:e.s,v:e.v,a:m}};this.getHSL=function(){return{h:l,s:c,l:b,a:m}}}; 4 | )====="; 5 | -------------------------------------------------------------------------------- /lib/Time/DateStrings.cpp: -------------------------------------------------------------------------------- 1 | /* DateStrings.cpp 2 | * Definitions for date strings for use with the Time library 3 | * 4 | * Updated for Arduino 1.5.7 18 July 2014 5 | * 6 | * No memory is consumed in the sketch if your code does not call any of the string methods 7 | * You can change the text of the strings, make sure the short strings are each exactly 3 characters 8 | * the long strings can be any length up to the constant dt_MAX_STRING_LEN defined in TimeLib.h 9 | * 10 | */ 11 | 12 | #if defined(__AVR__) 13 | #include 14 | #else 15 | // for compatiblity with Arduino Due and Teensy 3.0 and maybe others? 16 | #define PROGMEM 17 | #define PGM_P const char * 18 | #define pgm_read_byte(addr) (*(const unsigned char *)(addr)) 19 | #define pgm_read_word(addr) (*(const unsigned char **)(addr)) 20 | #define strcpy_P(dest, src) strcpy((dest), (src)) 21 | #endif 22 | #include // for strcpy_P or strcpy 23 | #include "TimeLib.h" 24 | 25 | // the short strings for each day or month must be exactly dt_SHORT_STR_LEN 26 | #define dt_SHORT_STR_LEN 3 // the length of short strings 27 | 28 | static char buffer[dt_MAX_STRING_LEN+1]; // must be big enough for longest string and the terminating null 29 | 30 | const char monthStr0[] PROGMEM = ""; 31 | const char monthStr1[] PROGMEM = "January"; 32 | const char monthStr2[] PROGMEM = "February"; 33 | const char monthStr3[] PROGMEM = "March"; 34 | const char monthStr4[] PROGMEM = "April"; 35 | const char monthStr5[] PROGMEM = "May"; 36 | const char monthStr6[] PROGMEM = "June"; 37 | const char monthStr7[] PROGMEM = "July"; 38 | const char monthStr8[] PROGMEM = "August"; 39 | const char monthStr9[] PROGMEM = "September"; 40 | const char monthStr10[] PROGMEM = "October"; 41 | const char monthStr11[] PROGMEM = "November"; 42 | const char monthStr12[] PROGMEM = "December"; 43 | 44 | const PROGMEM char * const PROGMEM monthNames_P[] = 45 | { 46 | monthStr0,monthStr1,monthStr2,monthStr3,monthStr4,monthStr5,monthStr6, 47 | monthStr7,monthStr8,monthStr9,monthStr10,monthStr11,monthStr12 48 | }; 49 | 50 | const char monthShortNames_P[] PROGMEM = "ErrJanFebMarAprMayJunJulAugSepOctNovDec"; 51 | 52 | const char dayStr0[] PROGMEM = "Err"; 53 | const char dayStr1[] PROGMEM = "Sunday"; 54 | const char dayStr2[] PROGMEM = "Monday"; 55 | const char dayStr3[] PROGMEM = "Tuesday"; 56 | const char dayStr4[] PROGMEM = "Wednesday"; 57 | const char dayStr5[] PROGMEM = "Thursday"; 58 | const char dayStr6[] PROGMEM = "Friday"; 59 | const char dayStr7[] PROGMEM = "Saturday"; 60 | 61 | const PROGMEM char * const PROGMEM dayNames_P[] = 62 | { 63 | dayStr0,dayStr1,dayStr2,dayStr3,dayStr4,dayStr5,dayStr6,dayStr7 64 | }; 65 | 66 | const char dayShortNames_P[] PROGMEM = "ErrSunMonTueWedThuFriSat"; 67 | 68 | /* functions to return date strings */ 69 | 70 | char* monthStr(uint8_t month) 71 | { 72 | strcpy_P(buffer, (PGM_P)pgm_read_word(&(monthNames_P[month]))); 73 | return buffer; 74 | } 75 | 76 | char* monthShortStr(uint8_t month) 77 | { 78 | for (int i=0; i < dt_SHORT_STR_LEN; i++) 79 | buffer[i] = pgm_read_byte(&(monthShortNames_P[i+ (month*dt_SHORT_STR_LEN)])); 80 | buffer[dt_SHORT_STR_LEN] = 0; 81 | return buffer; 82 | } 83 | 84 | char* dayStr(uint8_t day) 85 | { 86 | strcpy_P(buffer, (PGM_P)pgm_read_word(&(dayNames_P[day]))); 87 | return buffer; 88 | } 89 | 90 | char* dayShortStr(uint8_t day) 91 | { 92 | uint8_t index = day*dt_SHORT_STR_LEN; 93 | for (int i=0; i < dt_SHORT_STR_LEN; i++) 94 | buffer[i] = pgm_read_byte(&(dayShortNames_P[index + i])); 95 | buffer[dt_SHORT_STR_LEN] = 0; 96 | return buffer; 97 | } 98 | -------------------------------------------------------------------------------- /lib/NeoPixelBus/HslColor.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------- 2 | NeoPixel is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU Lesser General Public License as 4 | published by the Free Software Foundation, either version 3 of 5 | the License, or (at your option) any later version. 6 | 7 | NeoPixel is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU Lesser General Public License for more details. 11 | 12 | You should have received a copy of the GNU Lesser General Public 13 | License along with NeoPixel. If not, see 14 | . 15 | --------------------------------------------------------------------*/ 16 | #pragma once 17 | 18 | #include 19 | #define HSL_FLOAT 20 | 21 | // ------------------------------------------------------------------------ 22 | // HslColor represents a color object that is represented by Hue, Saturation, Lightness 23 | // component values. It contains helpful color routines to manipulate the 24 | // color. 25 | // ------------------------------------------------------------------------ 26 | struct HslColor 27 | { 28 | #ifdef HSL_FLOAT 29 | // ------------------------------------------------------------------------ 30 | // Construct a HslColor using H, S, L values (0.0 - 1.0) 31 | // ------------------------------------------------------------------------ 32 | HslColor(float h, float s, float l) : 33 | H(h), S(s), L(l) 34 | { 35 | }; 36 | #else 37 | // ------------------------------------------------------------------------ 38 | // Construct a HslColor using H, S, L values (0 - 255) 39 | // generally, L should be limited to between (0-127) 40 | // ------------------------------------------------------------------------ 41 | HslColor(uint8_t h, uint8_t s, uint8_t l) : 42 | H(h), S(s), L(l) 43 | { 44 | }; 45 | #endif 46 | 47 | // ------------------------------------------------------------------------ 48 | // Construct a HslColor using RgbColor 49 | // ------------------------------------------------------------------------ 50 | HslColor(RgbColor color); 51 | 52 | // ------------------------------------------------------------------------ 53 | // Construct a HslColor that will have its values set in latter operations 54 | // CAUTION: The H,S,L members are not initialized and may not be consistent 55 | // ------------------------------------------------------------------------ 56 | HslColor() 57 | { 58 | }; 59 | 60 | // ------------------------------------------------------------------------ 61 | // LinearBlend between two colors by the amount defined by progress variable 62 | // left - the color to start the blend at 63 | // right - the color to end the blend at 64 | // progress - (0.0 - 1.0) value where 0.0 will return left and 1.0 will return right 65 | // and a value between will blend the color weighted linearly between them 66 | // ------------------------------------------------------------------------ 67 | static HslColor LinearBlend(HslColor left, HslColor right, float progress); 68 | 69 | // ------------------------------------------------------------------------ 70 | // Hue, Saturation, Lightness color members 71 | // ------------------------------------------------------------------------ 72 | #ifdef HSL_FLOAT 73 | float H; 74 | float S; 75 | float L; 76 | #else 77 | uint8_t H; 78 | uint8_t S; 79 | uint8_t L; 80 | #endif 81 | }; 82 | 83 | -------------------------------------------------------------------------------- /lib/Time/examples/TimeSerialDateStrings/TimeSerialDateStrings.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * TimeSerialDateStrings.pde 3 | * example code illustrating Time library date strings 4 | * 5 | * This sketch adds date string functionality to TimeSerial sketch 6 | * Also shows how to handle different messages 7 | * 8 | * A message starting with a time header sets the time 9 | * A Processing example sketch to automatically send the messages is inclided in the download 10 | * On Linux, you can use "date +T%s\n > /dev/ttyACM0" (UTC time zone) 11 | * 12 | * A message starting with a format header sets the date format 13 | 14 | * send: Fs\n for short date format 15 | * send: Fl\n for long date format 16 | */ 17 | 18 | #include 19 | 20 | // single character message tags 21 | #define TIME_HEADER 'T' // Header tag for serial time sync message 22 | #define FORMAT_HEADER 'F' // Header tag indicating a date format message 23 | #define FORMAT_SHORT 's' // short month and day strings 24 | #define FORMAT_LONG 'l' // (lower case l) long month and day strings 25 | 26 | #define TIME_REQUEST 7 // ASCII bell character requests a time sync message 27 | 28 | static boolean isLongFormat = true; 29 | 30 | void setup() { 31 | Serial.begin(9600); 32 | while (!Serial) ; // Needed for Leonardo only 33 | setSyncProvider( requestSync); //set function to call when sync required 34 | Serial.println("Waiting for sync message"); 35 | } 36 | 37 | void loop(){ 38 | if (Serial.available() > 1) { // wait for at least two characters 39 | char c = Serial.read(); 40 | if( c == TIME_HEADER) { 41 | processSyncMessage(); 42 | } 43 | else if( c== FORMAT_HEADER) { 44 | processFormatMessage(); 45 | } 46 | } 47 | if (timeStatus()!= timeNotSet) { 48 | digitalClockDisplay(); 49 | } 50 | delay(1000); 51 | } 52 | 53 | void digitalClockDisplay() { 54 | // digital clock display of the time 55 | Serial.print(hour()); 56 | printDigits(minute()); 57 | printDigits(second()); 58 | Serial.print(" "); 59 | if(isLongFormat) 60 | Serial.print(dayStr(weekday())); 61 | else 62 | Serial.print(dayShortStr(weekday())); 63 | Serial.print(" "); 64 | Serial.print(day()); 65 | Serial.print(" "); 66 | if(isLongFormat) 67 | Serial.print(monthStr(month())); 68 | else 69 | Serial.print(monthShortStr(month())); 70 | Serial.print(" "); 71 | Serial.print(year()); 72 | Serial.println(); 73 | } 74 | 75 | void printDigits(int digits) { 76 | // utility function for digital clock display: prints preceding colon and leading 0 77 | Serial.print(":"); 78 | if(digits < 10) 79 | Serial.print('0'); 80 | Serial.print(digits); 81 | } 82 | 83 | void processFormatMessage() { 84 | char c = Serial.read(); 85 | if( c == FORMAT_LONG){ 86 | isLongFormat = true; 87 | Serial.println(F("Setting long format")); 88 | } 89 | else if( c == FORMAT_SHORT) { 90 | isLongFormat = false; 91 | Serial.println(F("Setting short format")); 92 | } 93 | } 94 | 95 | void processSyncMessage() { 96 | unsigned long pctime; 97 | const unsigned long DEFAULT_TIME = 1357041600; // Jan 1 2013 - paul, perhaps we define in time.h? 98 | 99 | pctime = Serial.parseInt(); 100 | if( pctime >= DEFAULT_TIME) { // check the integer is a valid time (greater than Jan 1 2013) 101 | setTime(pctime); // Sync Arduino clock to the time received on the serial port 102 | } 103 | } 104 | 105 | time_t requestSync() { 106 | Serial.write(TIME_REQUEST); 107 | return 0; // the time will be sent later in response to serial mesg 108 | } 109 | -------------------------------------------------------------------------------- /lib/Time/examples/TimeRTCLog/TimeRTCLog.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * TimeRTCLogger.pde 3 | * example code illustrating adding and subtracting Time. 4 | * 5 | * this sketch logs pin state change events 6 | * the time of the event and time since the previous event is calculated and sent to the serial port. 7 | */ 8 | 9 | #include 10 | #include 11 | #include // a basic DS1307 library that returns time as a time_t 12 | 13 | const int nbrInputPins = 6; // monitor 6 digital pins 14 | const int inputPins[nbrInputPins] = {2,3,4,5,6,7}; // pins to monitor 15 | boolean state[nbrInputPins] ; // the state of the monitored pins 16 | time_t prevEventTime[nbrInputPins] ; // the time of the previous event 17 | 18 | void setup() { 19 | Serial.begin(9600); 20 | setSyncProvider(RTC.get); // the function to sync the time from the RTC 21 | for(int i=0; i < nbrInputPins; i++){ 22 | pinMode( inputPins[i], INPUT); 23 | // uncomment these lines if pull-up resistors are wanted 24 | // pinMode( inputPins[i], INPUT_PULLUP); 25 | // state[i] = HIGH; 26 | } 27 | } 28 | 29 | void loop() 30 | { 31 | for(int i=0; i < nbrInputPins; i++) 32 | { 33 | boolean val = digitalRead(inputPins[i]); 34 | if(val != state[i]) 35 | { 36 | time_t duration = 0; // the time since the previous event 37 | state[i] = val; 38 | time_t timeNow = now(); 39 | if(prevEventTime[i] > 0) 40 | // if this was not the first state change, calculate the time from the previous change 41 | duration = duration = timeNow - prevEventTime[i]; 42 | logEvent(inputPins[i], val, timeNow, duration ); // log the event 43 | prevEventTime[i] = timeNow; // store the time for this event 44 | } 45 | } 46 | } 47 | 48 | void logEvent( int pin, boolean state, time_t timeNow, time_t duration) 49 | { 50 | Serial.print("Pin "); 51 | Serial.print(pin); 52 | if( state == HIGH) 53 | Serial.print(" went High at "); 54 | else 55 | Serial.print(" went Low at "); 56 | showTime(timeNow); 57 | if(duration > 0){ 58 | // only display duration if greater than 0 59 | Serial.print(", Duration was "); 60 | showDuration(duration); 61 | } 62 | Serial.println(); 63 | } 64 | 65 | 66 | void showTime(time_t t){ 67 | // display the given time 68 | Serial.print(hour(t)); 69 | printDigits(minute(t)); 70 | printDigits(second(t)); 71 | Serial.print(" "); 72 | Serial.print(day(t)); 73 | Serial.print(" "); 74 | Serial.print(month(t)); 75 | Serial.print(" "); 76 | Serial.print(year(t)); 77 | } 78 | 79 | void printDigits(int digits){ 80 | // utility function for digital clock display: prints preceding colon and leading 0 81 | Serial.print(":"); 82 | if(digits < 10) 83 | Serial.print('0'); 84 | Serial.print(digits); 85 | } 86 | 87 | void showDuration(time_t duration){ 88 | // prints the duration in days, hours, minutes and seconds 89 | if(duration >= SECS_PER_DAY){ 90 | Serial.print(duration / SECS_PER_DAY); 91 | Serial.print(" day(s) "); 92 | duration = duration % SECS_PER_DAY; 93 | } 94 | if(duration >= SECS_PER_HOUR){ 95 | Serial.print(duration / SECS_PER_HOUR); 96 | Serial.print(" hour(s) "); 97 | duration = duration % SECS_PER_HOUR; 98 | } 99 | if(duration >= SECS_PER_MIN){ 100 | Serial.print(duration / SECS_PER_MIN); 101 | Serial.print(" minute(s) "); 102 | duration = duration % SECS_PER_MIN; 103 | } 104 | Serial.print(duration); 105 | Serial.print(" second(s) "); 106 | } 107 | 108 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/examples/Nginx/esp8266.ssl.reverse.proxy.conf: -------------------------------------------------------------------------------- 1 | # ESP8266 nginx SSL reverse proxy configuration file (tested and working on nginx v1.10.0) 2 | 3 | # proxy cache location 4 | proxy_cache_path /opt/etc/nginx/cache levels=1:2 keys_zone=ESP8266_cache:10m max_size=10g inactive=5m use_temp_path=off; 5 | 6 | # webserver proxy 7 | server { 8 | 9 | # general server parameters 10 | listen 50080; 11 | server_name myDomain.net; 12 | access_log /opt/var/log/nginx/myDomain.net.access.log; 13 | 14 | # SSL configuration 15 | ssl on; 16 | ssl_certificate /usr/builtin/etc/certificate/lets-encrypt/myDomain.net/fullchain.pem; 17 | ssl_certificate_key /usr/builtin/etc/certificate/lets-encrypt/myDomain.net/privkey.pem; 18 | ssl_session_cache builtin:1000 shared:SSL:10m; 19 | ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 20 | ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4; 21 | ssl_prefer_server_ciphers on; 22 | 23 | location / { 24 | 25 | # proxy caching configuration 26 | proxy_cache ESP8266_cache; 27 | proxy_cache_revalidate on; 28 | proxy_cache_min_uses 1; 29 | proxy_cache_use_stale off; 30 | proxy_cache_lock on; 31 | # proxy_cache_bypass $http_cache_control; 32 | # include the sessionId cookie value as part of the cache key - keeps the cache per user 33 | # proxy_cache_key $proxy_host$request_uri$cookie_sessionId; 34 | 35 | # header pass through configuration 36 | proxy_set_header Host $host; 37 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 38 | proxy_set_header X-Forwarded-Proto $scheme; 39 | 40 | # ESP8266 custom headers which identify to the device that it's running through an SSL proxy 41 | proxy_set_header X-SSL On; 42 | proxy_set_header X-SSL-WebserverPort 50080; 43 | proxy_set_header X-SSL-WebsocketPort 50081; 44 | 45 | # extra debug headers 46 | add_header X-Proxy-Cache $upstream_cache_status; 47 | add_header X-Forwarded-For $proxy_add_x_forwarded_for; 48 | 49 | # actual proxying configuration 50 | proxy_ssl_session_reuse on; 51 | # target the IP address of the device with proxy_pass 52 | proxy_pass http://192.168.0.20; 53 | proxy_read_timeout 90; 54 | } 55 | } 56 | 57 | # websocket proxy 58 | server { 59 | 60 | # general server parameters 61 | listen 50081; 62 | server_name myDomain.net; 63 | access_log /opt/var/log/nginx/myDomain.net.wss.access.log; 64 | 65 | # SSL configuration 66 | ssl on; 67 | ssl_certificate /usr/builtin/etc/certificate/lets-encrypt/myDomain.net/fullchain.pem; 68 | ssl_certificate_key /usr/builtin/etc/certificate/lets-encrypt/myDomain.net/privkey.pem; 69 | ssl_session_cache builtin:1000 shared:SSL:10m; 70 | ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 71 | ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4; 72 | ssl_prefer_server_ciphers on; 73 | 74 | location / { 75 | 76 | # websocket upgrade tunnel configuration 77 | proxy_pass http://192.168.0.20:81; 78 | proxy_http_version 1.1; 79 | proxy_set_header Upgrade $http_upgrade; 80 | proxy_set_header Connection "Upgrade"; 81 | proxy_read_timeout 86400; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /druhvhtml/compressed/compressed.css: -------------------------------------------------------------------------------- 1 | @import url(http://fonts.googleapis.com/css?family=Abel);@import url(https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css);*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}html{background:#e0e0e0;background:-moz-linear-gradient(left,#e0e0e0 0,#ffffff 50%,#e0e0e0 100%);background:-webkit-gradient(linear,left top,right top,color-stop(0%,#e0e0e0),color-stop(50%,#ffffff),color-stop(100%,#e0e0e0));background:-webkit-linear-gradient(left,#e0e0e0 0,#ffffff 50%,#e0e0e0 100%);background:-o-linear-gradient(left,#e0e0e0 0,#ffffff 50%,#e0e0e0 100%);background:-ms-linear-gradient(left,#e0e0e0 0,#ffffff 50%,#e0e0e0 100%);background:linear-gradient(to right,#e0e0e0 0,#ffffff 50%,#e0e0e0 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#e0e0e0',endColorstr='#e0e0e0',GradientType=1)}body{margin:0;padding:40px;background:#fff;box-shadow:0 1px 10px rgba(0,0,0,0.1);border-radius:3px;font-family:'Abel',sans-serif}ul{margin:0;padding:0;list-style:none}a{text-decoration:none}label{font-weight:bold}input,select{background:#fff;text-transform:capitalize;margin:0;border:1px solid rgba(0,0,0,0.15);border-radius:3px;font-family:'Abel',sans-serif;font-size:15px;letter-spacing:1px;display:inline-block;padding:15px;-webkit-transition:all .6s ease 0s;-moz-transition:all .6s ease 0s;-ms-transition:all .6s ease 0s;-o-transition:all .6s ease 0s;transition:all .6s ease 0s}input:focus,select:focus{border-color:rgba(0,0,0,0.5);outline:0}select option{padding:0 10px}.settings-page{width:550px;margin:60px auto}.form-verticle ul li{width:100%;display:inline-block;margin-bottom:30px;margin-top:0;position:relative}.form-verticle ul li label{width:35%;display:inline-block;color:#222;text-transform:uppercase;letter-spacing:1.5px;line-height:48px;float:left}.form-verticle ul li .form-field{width:65%;display:inline-block;float:left}.form-verticle ul li .form-field select,.form-verticle ul li .form-field input{width:100%}.form-verticle ul li.checkbox input[type="checkbox"]{display:none}.form-verticle ul li.checkbox label{display:inline-block;cursor:pointer;font-weight:bold;padding-left:0;line-height:17px}.form-verticle ul li.checkbox label:before{color:#fff;content:"\f00c";font-family:FontAwesome;font-size:13px;text-align:center;line-height:20px;display:inline-block;width:23px;height:22px;margin-right:10px;position:absolute;left:35%;top:-2px;border:1px solid rgba(0,0,0,0.15);-webkit-transition:all .35s ease 0s;-moz-transition:all .35s ease 0s;-ms-transition:all .35s ease 0s;-o-transition:all .35s ease 0s;transition:all .35s ease 0s}.form-verticle ul li.checkbox input[type="checkbox"]:checked+label:before{color:#333;border-color:rgba(0,0,0,0.5)}.form-verticle ul li input.btn{width:auto}.btn{background:#f0f0f0;color:#111;text-align:center;width:auto;cursor:pointer;padding:15px 20px;text-transform:uppercase;border-radius:3px;font-family:'Abel',sans-serif;font-size:18px;letter-spacing:1px;font-weight:bold;display:inline-block;border:0;-webkit-transition:all .5s ease 0s;-moz-transition:all .5s ease 0s;-ms-transition:all .5s ease 0s;-o-transition:all .5s ease 0s;transition:all .5s ease 0s}.btn:hover{background:#111;color:#fff}.btn-default{background:#111;color:#fff}.btn-default:hover{background:#f0f0f0;color:#111}.btn-box{display:flex;justify-content:center}.btn-box .btn{font-size:14px;margin:0 5px;display:flex;align-items:center}@media screen and (max-width:550px){.settings-page{width:auto;margin:20px}}@media screen and (max-width:500px){.form-verticle ul li label{width:100%}.form-verticle ul li .form-field{width:100%}.hide-mobile{display:none!important}.btn-box{display:inline-block;width:100%}.btn-box .btn{margin:0 0 10px}.form-verticle ul li.checkbox label:before{left:auto;right:0}}@media screen and (max-width:480px){.settings-page{padding:10px 20px}} -------------------------------------------------------------------------------- /lib/NeoPixelBus/HslColor.cpp: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------- 2 | NeoPixel is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU Lesser General Public License as 4 | published by the Free Software Foundation, either version 3 of 5 | the License, or (at your option) any later version. 6 | 7 | NeoPixel is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU Lesser General Public License for more details. 11 | 12 | You should have received a copy of the GNU Lesser General Public 13 | License along with NeoPixel. If not, see 14 | . 15 | --------------------------------------------------------------------*/ 16 | 17 | #include "RgbColor.h" 18 | #include "HslColor.h" 19 | 20 | 21 | HslColor::HslColor(RgbColor color) 22 | { 23 | //Serial.print("RGB to HSL : "); 24 | //Serial.print(color.R); 25 | //Serial.print(", "); 26 | //Serial.print(color.G); 27 | //Serial.print(", "); 28 | //Serial.print(color.B); 29 | //Serial.print(" => "); 30 | 31 | // convert colors to float between (0.0 - 1.0) 32 | float r = color.R / 255.0f; 33 | float g = color.G / 255.0f; 34 | float b = color.B / 255.0f; 35 | 36 | float max = (r > g && r > b) ? r : (g > b) ? g : b; 37 | float min = (r < g && r < b) ? r : (g < b) ? g : b; 38 | 39 | float h, s, l; 40 | l = (max + min) / 2.0f; 41 | 42 | if (max == min) 43 | { 44 | h = s = 0.0f; 45 | } 46 | else 47 | { 48 | float d = max - min; 49 | s = (l > 0.5f) ? d / (2.0f - max - min) : d / (max + min); 50 | 51 | if (r > g && r > b) 52 | { 53 | h = (g - b) / d + (g < b ? 6.0f : 0.0f); 54 | } 55 | else if (g > b) 56 | { 57 | h = (b - r) / d + 2.0f; 58 | } 59 | else 60 | { 61 | h = (r - g) / d + 4.0f; 62 | } 63 | h /= 6.0f; 64 | } 65 | 66 | //Serial.print(h); 67 | //Serial.print(", "); 68 | //Serial.print(s); 69 | //Serial.print(", "); 70 | //Serial.print(l); 71 | //Serial.print(" = "); 72 | 73 | #ifdef HSL_FLOAT 74 | H = h; 75 | S = s; 76 | L = l; 77 | 78 | #else 79 | // convert 0.0-1.0 values to 0-255 80 | H = (uint8_t)(h * 255); 81 | S = (uint8_t)(s * 255); 82 | L = (uint8_t)(l * 255); 83 | #endif 84 | 85 | 86 | //Serial.print(H); 87 | //Serial.print(", "); 88 | //Serial.print(S); 89 | //Serial.print(", "); 90 | //Serial.print(L); 91 | //Serial.println(); 92 | } 93 | 94 | HslColor HslColor::LinearBlend(HslColor left, HslColor right, float progress) 95 | { 96 | float hue; 97 | float sat; 98 | float lum; 99 | float d = right.H-left.H; 100 | float temp; 101 | 102 | sat = left.S + progress*(right.S - left.S); 103 | lum = left.L + progress*(right.L - left.L); 104 | 105 | if (left.S==0||right.S==0) // special case, one of the colours is white 106 | { 107 | if (left.S==0) 108 | { 109 | hue = right.H; 110 | } else { 111 | hue = left.H; 112 | } 113 | } else { 114 | if (left.H > right.H) 115 | { 116 | temp = right.H; 117 | right.H = left.H; 118 | left.H = temp; 119 | d = -d; 120 | progress = 1-progress; 121 | } 122 | if (d>0.5) 123 | { 124 | left.H += 1; 125 | hue = (left.H+progress*(right.H-left.H)); 126 | if (hue > 1) 127 | { 128 | hue -= 1; 129 | } 130 | } 131 | else { 132 | hue = left.H+progress*d; 133 | } 134 | } 135 | 136 | 137 | return HslColor(hue, sat, lum); 138 | } -------------------------------------------------------------------------------- /lib/NeoPixelBus/RgbColor.cpp: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------- 2 | NeoPixel is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU Lesser General Public License as 4 | published by the Free Software Foundation, either version 3 of 5 | the License, or (at your option) any later version. 6 | 7 | NeoPixel is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU Lesser General Public License for more details. 11 | 12 | You should have received a copy of the GNU Lesser General Public 13 | License along with NeoPixel. If not, see 14 | . 15 | --------------------------------------------------------------------*/ 16 | 17 | #include "RgbColor.h" 18 | #include "HslColor.h" 19 | 20 | static float _CalcColor(float p, float q, float t) 21 | { 22 | if (t < 0.0f) 23 | t += 1.0f; 24 | if (t > 1.0f) 25 | t -= 1.0f; 26 | 27 | if (t < 1.0f / 6.0f) 28 | return p + (q - p) * 6.0f * t; 29 | 30 | if (t < 0.5f) 31 | return q; 32 | 33 | if (t < 2.0f / 3.0f) 34 | return p + ((q - p) * (2.0f / 3.0f - t) * 6.0f); 35 | 36 | return p; 37 | } 38 | 39 | RgbColor::RgbColor(HslColor color) 40 | { 41 | //Serial.print("HSL to RGB : "); 42 | //Serial.print(color.H); 43 | //Serial.print(", "); 44 | //Serial.print(color.S); 45 | //Serial.print(", "); 46 | //Serial.print(color.L); 47 | //Serial.print(" => "); 48 | 49 | float r; 50 | float g; 51 | float b; 52 | #ifdef HSL_FLOAT 53 | float h = color.H; 54 | float s = color.S; 55 | float l = color.L; 56 | #else 57 | float h = color.H / 255.0f; 58 | float s = color.S / 255.0f; 59 | float l = color.L / 255.0f; 60 | #endif 61 | 62 | if (color.S == 0.0f || color.L == 0.0f) 63 | { 64 | r = g = b = l; // achromatic or black 65 | } 66 | else 67 | { 68 | float q = l < 0.5f ? l * (1.0f + s) : l + s - (l * s); 69 | float p = 2.0f * l - q; 70 | r = _CalcColor(p, q, h + 1.0f / 3.0f); 71 | g = _CalcColor(p, q, h); 72 | b = _CalcColor(p, q, h - 1.0f / 3.0f); 73 | } 74 | 75 | //Serial.print(r); 76 | //Serial.print(", "); 77 | //Serial.print(g); 78 | //Serial.print(", "); 79 | //Serial.print(b); 80 | //Serial.print(" = "); 81 | 82 | R = (uint8_t)(r * 255.0f); 83 | G = (uint8_t)(g * 255.0f); 84 | B = (uint8_t)(b * 255.0f); 85 | 86 | //Serial.print(R); 87 | //Serial.print(", "); 88 | //Serial.print(G); 89 | //Serial.print(", "); 90 | //Serial.print(B); 91 | //Serial.println(); 92 | } 93 | 94 | 95 | 96 | uint8_t RgbColor::CalculateBrightness() const 97 | { 98 | return (uint8_t)(((uint16_t)R + (uint16_t)G + (uint16_t)B) / 3); 99 | } 100 | 101 | void RgbColor::Darken(uint8_t delta) 102 | { 103 | if (R > delta) 104 | { 105 | R -= delta; 106 | } 107 | else 108 | { 109 | R = 0; 110 | } 111 | 112 | if (G > delta) 113 | { 114 | G -= delta; 115 | } 116 | else 117 | { 118 | G = 0; 119 | } 120 | 121 | if (B > delta) 122 | { 123 | B -= delta; 124 | } 125 | else 126 | { 127 | B = 0; 128 | } 129 | } 130 | 131 | void RgbColor::Lighten(uint8_t delta) 132 | { 133 | if (R < 255 - delta) 134 | { 135 | R += delta; 136 | } 137 | else 138 | { 139 | R = 255; 140 | } 141 | 142 | if (G < 255 - delta) 143 | { 144 | G += delta; 145 | } 146 | else 147 | { 148 | G = 255; 149 | } 150 | 151 | if (B < 255 - delta) 152 | { 153 | B += delta; 154 | } 155 | else 156 | { 157 | B = 255; 158 | } 159 | } 160 | 161 | RgbColor RgbColor::LinearBlend(RgbColor left, RgbColor right, float progress) 162 | { 163 | return RgbColor( left.R + ((right.R - left.R) * progress), 164 | left.G + ((right.G - left.G) * progress), 165 | left.B + ((right.B - left.B) * progress)); 166 | } -------------------------------------------------------------------------------- /lib/NeoPixelBus/NeoPixelAnimator.cpp: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------- 2 | NeoPixel is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU Lesser General Public License as 4 | published by the Free Software Foundation, either version 3 of 5 | the License, or (at your option) any later version. 6 | 7 | NeoPixel is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU Lesser General Public License for more details. 11 | 12 | You should have received a copy of the GNU Lesser General Public 13 | License along with NeoPixel. If not, see 14 | . 15 | --------------------------------------------------------------------*/ 16 | 17 | #include "NeoPixelBus.h" 18 | #include "NeoPixelAnimator.h" 19 | 20 | NeoPixelAnimator::NeoPixelAnimator(NeoPixelBus* bus) : 21 | _bus(bus), 22 | _animationLastTick(0), 23 | _activeAnimations(0), 24 | _isRunning(true) 25 | { 26 | _animations = new AnimationContext[_bus->PixelCount()]; 27 | } 28 | 29 | NeoPixelAnimator::~NeoPixelAnimator() 30 | { 31 | _bus = NULL; 32 | if (_animations) 33 | { 34 | delete[] _animations; 35 | _animations = NULL; 36 | } 37 | } 38 | 39 | void NeoPixelAnimator::StartAnimation(uint16_t n, uint16_t time, AnimUpdateCallback animUpdate) 40 | { 41 | if (n >= _bus->PixelCount()) 42 | { 43 | return; 44 | } 45 | 46 | if (_activeAnimations == 0) 47 | { 48 | _animationLastTick = millis(); 49 | } 50 | 51 | StopAnimation(n); 52 | 53 | if (time == 0) 54 | { 55 | time = 1; 56 | } 57 | 58 | _animations[n].time = time; 59 | _animations[n].remaining = time; 60 | _animations[n].fnUpdate = animUpdate; 61 | 62 | _activeAnimations++; 63 | } 64 | 65 | void NeoPixelAnimator::StopAnimation(uint16_t n) 66 | { 67 | if (IsAnimating(n)) 68 | { 69 | _activeAnimations--; 70 | _animations[n].time = 0; 71 | _animations[n].remaining = 0; 72 | _animations[n].fnUpdate = NULL; 73 | } 74 | } 75 | 76 | void NeoPixelAnimator::FadeTo(uint16_t time, RgbColor color) 77 | { 78 | for (uint8_t n = 0; n < _bus->PixelCount(); n++) 79 | { 80 | RgbColor original = _bus->GetPixelColor(n); 81 | AnimUpdateCallback animUpdate = [=](float progress) 82 | { 83 | RgbColor updatedColor = RgbColor::LinearBlend(original, color, progress); 84 | _bus->SetPixelColor(n, updatedColor); 85 | }; 86 | StartAnimation(n, time, animUpdate); 87 | } 88 | } 89 | 90 | void NeoPixelAnimator::UpdateAnimations(uint32_t maxDeltaMs) 91 | { 92 | if (_isRunning) 93 | { 94 | uint32_t currentTick = millis(); 95 | uint32_t delta = currentTick - _animationLastTick; 96 | 97 | if (delta > maxDeltaMs) 98 | { 99 | delta = maxDeltaMs; 100 | } 101 | 102 | if (delta > 0) 103 | { 104 | uint16_t countAnimations = _activeAnimations; 105 | 106 | AnimationContext* pAnim; 107 | 108 | for (uint16_t iAnim = 0; iAnim < _bus->PixelCount() && countAnimations > 0; iAnim++) 109 | { 110 | pAnim = &_animations[iAnim]; 111 | 112 | if (pAnim->remaining > delta) 113 | { 114 | pAnim->remaining -= delta; 115 | 116 | float progress = (float)(pAnim->time - pAnim->remaining) / (float)pAnim->time; 117 | 118 | pAnim->fnUpdate(progress); 119 | countAnimations--; 120 | } 121 | else if (pAnim->remaining > 0) 122 | { 123 | pAnim->fnUpdate(1.0f); 124 | StopAnimation(iAnim); 125 | countAnimations--; 126 | } 127 | } 128 | 129 | _animationLastTick = currentTick; 130 | } 131 | } 132 | } 133 | 134 | -------------------------------------------------------------------------------- /lib/NTP/Examples/WiFiClock/WiFiClock.ino: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * WiFiClock 3 | * This program requires the addition of libraries: 4 | * NTP 5 | * tm1637 6 | * Time 7 | * Uses the system clock to keep track of time. 8 | * A tm1637 module connected to the ESP8266 will display this time. 9 | * The time is kept current by hourly requests from an NTP server pool. 10 | * 11 | * WiFi connection 12 | * You'll notice that there is no ssid or password hardwired into the code 13 | * If the ESP8266 has been previously connected to your network, it will 14 | * remember your credentials and use then to reconnect. 15 | * If this is the first time this module is to be connected to the network, 16 | * this code waits to retrieve your ssid and password over the serial port. 17 | * 18 | *************************************************************************/ 19 | 20 | /* You must dedicate two GPIO pins to be used to communicate with the tm1637 module 21 | * Make sure to connect: 22 | * tm1637_clk_pin to the CLK pin on the tm1637 clock module 23 | * tm1637_data_pin to the pin on the clock module labeled DIO 24 | */ 25 | #define tm1637_clk_pin 14 26 | #define tm1637_data_pin 13 27 | 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | bool startWiFi(void); 37 | time_t getNTPtime(void); 38 | void readLine(char buffer[], uint8_t size); 39 | void digitalClockDisplay(); 40 | void toggleColon(void); 41 | 42 | NTP NTPclient; 43 | tm1637 display(tm1637_clk_pin, tm1637_data_pin); 44 | Ticker clock; 45 | bool colon = true; 46 | bool updateTime = true; 47 | 48 | #define PST -8 //pacific standard time 49 | 50 | void setup() { 51 | Serial.begin(115200); 52 | Serial.println(); 53 | Serial.println(); 54 | while (!startWiFi()){delay(1500);} 55 | 56 | Serial.println("WiFi connected"); 57 | Serial.println("IP address: "); 58 | Serial.println(WiFi.localIP()); 59 | 60 | display.setBrightness(4); 61 | 62 | NTPclient.begin("time.nist.gov", PST); 63 | setSyncInterval(SECS_PER_HOUR); 64 | setSyncProvider(getNTPtime); 65 | 66 | clock.attach(0.5, toggleColon); 67 | 68 | } 69 | 70 | void loop() { 71 | if (updateTime){ 72 | updateTime = false; 73 | if (timeStatus() != timeNotSet) 74 | digitalClockDisplay(); 75 | } 76 | } 77 | 78 | time_t getNTPtime(void) 79 | { 80 | return NTPclient.getNtpTime(); 81 | } 82 | 83 | void digitalClockDisplay() 84 | { 85 | // digital clock display of the time 86 | display.writeTime(hourFormat12(), minute(), colon); 87 | colon = !colon; 88 | } 89 | 90 | 91 | bool startWiFi(void) 92 | { 93 | uint8_t i; 94 | //check for persistent wifi connection 95 | for (i=0;i<10;i++){ 96 | if (WiFi.status() == WL_CONNECTED) return true; 97 | delay(500); 98 | Serial.print("."); 99 | } 100 | 101 | /*didn't work: so ask user to enter credentials over Serial Port */ 102 | #define maxSSIDlength 20 103 | #define maxPASSlength 40 104 | char ssid[maxSSIDlength]; 105 | char pass[maxPASSlength]; 106 | 107 | //prompt the user for his ssid 108 | 109 | Serial.print("Enter ssid name: "); 110 | readLine(ssid, maxSSIDlength); 111 | Serial.println(); 112 | Serial.print("Enter pass phrase: "); 113 | readLine(pass, maxPASSlength); 114 | Serial.println(); 115 | 116 | Serial.print("Attempting to Connect"); 117 | if (WiFi.begin(ssid, pass) != WL_CONNECTED) { 118 | for (i=0;i<10;i++){ 119 | if (WiFi.status() == WL_CONNECTED) return true; 120 | delay(500); 121 | Serial.print("."); 122 | } 123 | } 124 | Serial.print("Failed to connect to: "); 125 | Serial.println(ssid); 126 | 127 | Serial.print("using pass phrase: "); 128 | Serial.println(pass); 129 | 130 | return false; 131 | } 132 | 133 | void readLine(char buffer[], uint8_t size) 134 | { 135 | uint8_t i = 0; 136 | char c; 137 | 138 | do { 139 | while (!Serial.available()){yield();} //wait for input 140 | c = Serial.read(); 141 | Serial.write(c); //echo characters back to user. 142 | if (c == '\r') break; 143 | if (c != '\n') 144 | buffer[i++] = c; 145 | } while (i < size-1); 146 | buffer[i] = '\0'; 147 | } 148 | 149 | void toggleColon(void) 150 | { 151 | updateTime = true; 152 | } 153 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/examples/WebSocketServer_LEDcontrol/WebSocketServer_LEDcontrol.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * WebSocketServer_LEDcontrol.ino 3 | * 4 | * Created on: 26.11.2015 5 | * 6 | */ 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #define LED_RED 15 18 | #define LED_GREEN 12 19 | #define LED_BLUE 13 20 | 21 | #define USE_SERIAL Serial 22 | 23 | 24 | ESP8266WiFiMulti WiFiMulti; 25 | 26 | ESP8266WebServer server = ESP8266WebServer(80); 27 | WebSocketsServer webSocket = WebSocketsServer(81); 28 | 29 | void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght) { 30 | 31 | switch(type) { 32 | case WStype_DISCONNECTED: 33 | USE_SERIAL.printf("[%u] Disconnected!\n", num); 34 | break; 35 | case WStype_CONNECTED: { 36 | IPAddress ip = webSocket.remoteIP(num); 37 | USE_SERIAL.printf("[%u] Connected from %d.%d.%d.%d url: %s\n", num, ip[0], ip[1], ip[2], ip[3], payload); 38 | 39 | // send message to client 40 | webSocket.sendTXT(num, "Connected"); 41 | } 42 | break; 43 | case WStype_TEXT: 44 | USE_SERIAL.printf("[%u] get Text: %s\n", num, payload); 45 | 46 | if(payload[0] == '#') { 47 | // we get RGB data 48 | 49 | // decode rgb data 50 | uint32_t rgb = (uint32_t) strtol((const char *) &payload[1], NULL, 16); 51 | 52 | analogWrite(LED_RED, ((rgb >> 16) & 0xFF)); 53 | analogWrite(LED_GREEN, ((rgb >> 8) & 0xFF)); 54 | analogWrite(LED_BLUE, ((rgb >> 0) & 0xFF)); 55 | } 56 | 57 | break; 58 | } 59 | 60 | } 61 | 62 | void setup() { 63 | //USE_SERIAL.begin(921600); 64 | USE_SERIAL.begin(115200); 65 | 66 | //USE_SERIAL.setDebugOutput(true); 67 | 68 | USE_SERIAL.println(); 69 | USE_SERIAL.println(); 70 | USE_SERIAL.println(); 71 | 72 | for(uint8_t t = 4; t > 0; t--) { 73 | USE_SERIAL.printf("[SETUP] BOOT WAIT %d...\n", t); 74 | USE_SERIAL.flush(); 75 | delay(1000); 76 | } 77 | 78 | pinMode(LED_RED, OUTPUT); 79 | pinMode(LED_GREEN, OUTPUT); 80 | pinMode(LED_BLUE, OUTPUT); 81 | 82 | digitalWrite(LED_RED, 1); 83 | digitalWrite(LED_GREEN, 1); 84 | digitalWrite(LED_BLUE, 1); 85 | 86 | WiFiMulti.addAP("SSID", "passpasspass"); 87 | 88 | while(WiFiMulti.run() != WL_CONNECTED) { 89 | delay(100); 90 | } 91 | 92 | // start webSocket server 93 | webSocket.begin(); 94 | webSocket.onEvent(webSocketEvent); 95 | 96 | if(MDNS.begin("esp8266")) { 97 | USE_SERIAL.println("MDNS responder started"); 98 | } 99 | 100 | // handle index 101 | server.on("/", []() { 102 | // send index.html 103 | server.send(200, "text/html", "LED Control:

              R:
              G:
              B:
              "); 104 | }); 105 | 106 | server.begin(); 107 | 108 | // Add service to MDNS 109 | MDNS.addService("http", "tcp", 80); 110 | MDNS.addService("ws", "tcp", 81); 111 | 112 | digitalWrite(LED_RED, 0); 113 | digitalWrite(LED_GREEN, 0); 114 | digitalWrite(LED_BLUE, 0); 115 | 116 | } 117 | 118 | void loop() { 119 | webSocket.loop(); 120 | server.handleClient(); 121 | } 122 | 123 | -------------------------------------------------------------------------------- /lib/NeoPixelBus/NeoPixelBus.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------- 2 | This file is a modification of the Adafruit NeoPixel library. 3 | 4 | NeoPixel is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as 6 | published by the Free Software Foundation, either version 3 of 7 | the License, or (at your option) any later version. 8 | 9 | NeoPixel is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with NeoPixel. If not, see 16 | . 17 | --------------------------------------------------------------------*/ 18 | #pragma once 19 | 20 | #include 21 | 22 | enum ColorType 23 | { 24 | ColorType_Rgb, 25 | ColorType_Hsl 26 | }; 27 | 28 | #if defined(ESP8266) 29 | #define NEOPIXEL_RAM_DECL ICACHE_RAM_ATTR 30 | #else 31 | // All other supported platforms use the default memory location 32 | #define NEOPIXEL_RAM_DECL 33 | #endif 34 | 35 | #include "RgbColor.h" 36 | #include "HslColor.h" 37 | #include "NeoPixelAnimator.h" 38 | 39 | // '_flagsPixels' flags for LED _pixels (third parameter to constructor): 40 | #define NEO_RGB 0x00 // Wired for RGB data order 41 | #define NEO_GRB 0x01 // Wired for GRB data order 42 | #define NEO_BRG 0x04 43 | #define NEO_COLMASK 0x05 44 | 45 | #define NEO_KHZ400 0x00 // 400 KHz datastream 46 | #define NEO_KHZ800 0x02 // 800 KHz datastream 47 | #define NEO_SPDMASK 0x02 48 | #define NEO_DIRTY 0x80 // a change was made it _pixels that requires a show 49 | 50 | // v1 NeoPixels aren't handled by default, include the following define before the 51 | // NeoPixelBus library include to support the slower bus speeds 52 | //#define INCLUDE_NEO_KHZ400_SUPPORT 53 | 54 | class NeoPixelBus 55 | { 56 | public: 57 | // Constructor: number of LEDs, pin number, LED type 58 | NeoPixelBus(uint16_t n, uint8_t p, uint8_t t = NEO_GRB | NEO_KHZ800); 59 | ~NeoPixelBus(); 60 | 61 | inline uint16_t getPixelCount() 62 | { 63 | return _countPixels; 64 | } 65 | 66 | void Begin(); 67 | void NEOPIXEL_RAM_DECL Show(); 68 | inline bool CanShow(void) const 69 | { 70 | return (micros() - _endTime) >= 50L; 71 | } 72 | void ClearTo(uint8_t r, uint8_t g, uint8_t b); 73 | void ClearTo(RgbColor c) 74 | { 75 | ClearTo(c.R, c.G, c.B); 76 | } 77 | 78 | bool IsDirty() const 79 | { 80 | return (_flagsPixels & NEO_DIRTY); 81 | }; 82 | void Dirty() 83 | { 84 | _flagsPixels |= NEO_DIRTY; 85 | }; 86 | void ResetDirty() 87 | { 88 | _flagsPixels &= ~NEO_DIRTY; 89 | } 90 | 91 | uint8_t* Pixels() const 92 | { 93 | return _pixels; 94 | }; 95 | uint16_t PixelCount() const 96 | { 97 | return _countPixels; 98 | }; 99 | 100 | void SetPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b); 101 | void SetPixelColor(uint16_t n, RgbColor c) 102 | { 103 | SetPixelColor(n, c.R, c.G, c.B); 104 | }; 105 | void SetPixelColor(uint16_t n, RgbColor c, uint8_t brightness) 106 | { 107 | SetPixelColor(n, c.R*((float)brightness/255), c.G*((float)brightness/255), c.B*((float)brightness/255)); 108 | }; 109 | 110 | RgbColor GetPixelColor(uint16_t n) const; 111 | 112 | private: 113 | friend NeoPixelAnimator; 114 | 115 | void setPin(uint8_t p); 116 | void UpdatePixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b); 117 | void UpdatePixelColor(uint16_t n, RgbColor c) 118 | { 119 | UpdatePixelColor(n, c.R, c.G, c.B); 120 | }; 121 | 122 | const uint16_t _countPixels; // Number of RGB LEDs in strip 123 | const uint16_t _sizePixels; // Size of '_pixels' buffer below 124 | 125 | uint8_t _flagsPixels; // Pixel flags (400 vs 800 KHz, RGB vs GRB color) 126 | uint8_t _pin; // Output pin number 127 | uint8_t* _pixels; // Holds LED color values (3 bytes each) 128 | uint32_t _endTime; // Latch timing reference 129 | #ifdef __AVR__ 130 | const volatile uint8_t* _port; // Output PORT register 131 | uint8_t _pinMask; // Output PORT bitmask 132 | #endif 133 | 134 | 135 | }; 136 | 137 | -------------------------------------------------------------------------------- /lib/arduinoWebSockets-master/src/WebSocketsClient.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file WebSocketsClient.h 3 | * @date 20.05.2015 4 | * @author Markus Sattler 5 | * 6 | * Copyright (c) 2015 Markus Sattler. All rights reserved. 7 | * This file is part of the WebSockets for Arduino. 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 | * 23 | */ 24 | 25 | #ifndef WEBSOCKETSCLIENT_H_ 26 | #define WEBSOCKETSCLIENT_H_ 27 | 28 | #include 29 | #include "WebSockets.h" 30 | 31 | class WebSocketsClient: private WebSockets { 32 | public: 33 | #ifdef __AVR__ 34 | typedef void (*WebSocketClientEvent)(WStype_t type, uint8_t * payload, size_t length); 35 | #else 36 | typedef std::function WebSocketClientEvent; 37 | #endif 38 | 39 | 40 | WebSocketsClient(void); 41 | ~WebSocketsClient(void); 42 | 43 | void begin(const char *host, uint16_t port, const char * url = "/", const char * protocol = "arduino"); 44 | void begin(String host, uint16_t port, String url = "/", String protocol = "arduino"); 45 | 46 | #if (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266) 47 | void beginSSL(const char *host, uint16_t port, const char * url = "/", const char * = "", const char * protocol = "arduino"); 48 | void beginSSL(String host, uint16_t port, String url = "/", String fingerprint = "", String protocol = "arduino"); 49 | #endif 50 | 51 | #if (WEBSOCKETS_NETWORK_TYPE != NETWORK_ESP8266_ASYNC) 52 | void loop(void); 53 | #else 54 | // Async interface not need a loop call 55 | void loop(void) __attribute__ ((deprecated)) {} 56 | #endif 57 | 58 | void onEvent(WebSocketClientEvent cbEvent); 59 | 60 | bool sendTXT(uint8_t * payload, size_t length = 0, bool headerToPayload = false); 61 | bool sendTXT(const uint8_t * payload, size_t length = 0); 62 | bool sendTXT(char * payload, size_t length = 0, bool headerToPayload = false); 63 | bool sendTXT(const char * payload, size_t length = 0); 64 | bool sendTXT(String & payload); 65 | 66 | bool sendBIN(uint8_t * payload, size_t length, bool headerToPayload = false); 67 | bool sendBIN(const uint8_t * payload, size_t length); 68 | 69 | void disconnect(void); 70 | 71 | void setAuthorization(const char * user, const char * password); 72 | void setAuthorization(const char * auth); 73 | 74 | protected: 75 | String _host; 76 | uint16_t _port; 77 | 78 | #if (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266) 79 | String _fingerprint; 80 | #endif 81 | WSclient_t _client; 82 | 83 | WebSocketClientEvent _cbEvent; 84 | 85 | void messageReceived(WSclient_t * client, WSopcode_t opcode, uint8_t * payload, size_t length); 86 | 87 | void clientDisconnect(WSclient_t * client); 88 | bool clientIsConnected(WSclient_t * client); 89 | 90 | #if (WEBSOCKETS_NETWORK_TYPE != NETWORK_ESP8266_ASYNC) 91 | void handleClientData(void); 92 | #endif 93 | 94 | void sendHeader(WSclient_t * client); 95 | void handleHeader(WSclient_t * client, String * headerLine); 96 | 97 | void connectedCb(); 98 | void connectFailedCb(); 99 | 100 | #if (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266_ASYNC) 101 | void asyncConnect(); 102 | #endif 103 | 104 | /** 105 | * called for sending a Event to the app 106 | * @param type WStype_t 107 | * @param payload uint8_t * 108 | * @param length size_t 109 | */ 110 | virtual void runCbEvent(WStype_t type, uint8_t * payload, size_t length) { 111 | if(_cbEvent) { 112 | _cbEvent(type, payload, length); 113 | } 114 | } 115 | 116 | }; 117 | 118 | #endif /* WEBSOCKETSCLIENT_H_ */ 119 | -------------------------------------------------------------------------------- /lib/NeoPixelBus/RgbColor.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------- 2 | NeoPixel is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU Lesser General Public License as 4 | published by the Free Software Foundation, either version 3 of 5 | the License, or (at your option) any later version. 6 | 7 | NeoPixel is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU Lesser General Public License for more details. 11 | 12 | You should have received a copy of the GNU Lesser General Public 13 | License along with NeoPixel. If not, see 14 | . 15 | --------------------------------------------------------------------*/ 16 | #pragma once 17 | 18 | #include 19 | 20 | struct HslColor; 21 | 22 | // ------------------------------------------------------------------------ 23 | // RgbColor represents a color object that is represented by Red, Green, Blue 24 | // component values. It contains helpful color routines to manipulate the 25 | // color. 26 | // ------------------------------------------------------------------------ 27 | struct RgbColor 28 | { 29 | // ------------------------------------------------------------------------ 30 | // Construct a RgbColor using R, G, B values (0-255) 31 | // ------------------------------------------------------------------------ 32 | RgbColor(uint8_t r, uint8_t g, uint8_t b) : 33 | R(r), G(g), B(b) 34 | { 35 | }; 36 | 37 | // ------------------------------------------------------------------------ 38 | // Construct a RgbColor using a single brightness value (0-255) 39 | // This works well for creating gray tone colors 40 | // (0) = blakc, (255) = white, (128) = gray 41 | // ------------------------------------------------------------------------ 42 | RgbColor(uint8_t brightness) : 43 | R(brightness), G(brightness), B(brightness) 44 | { 45 | }; 46 | 47 | // ------------------------------------------------------------------------ 48 | // Construct a RgbColor using HslColor 49 | // ------------------------------------------------------------------------ 50 | RgbColor(HslColor color); 51 | 52 | // ------------------------------------------------------------------------ 53 | // Construct a RgbColor that will have its values set in latter operations 54 | // CAUTION: The R,G,B members are not initialized and may not be consistent 55 | // ------------------------------------------------------------------------ 56 | RgbColor() 57 | { 58 | }; 59 | 60 | // ------------------------------------------------------------------------ 61 | // CalculateBrightness will calculate the overall brightness 62 | // NOTE: This is a simple linear brightness 63 | // ------------------------------------------------------------------------ 64 | uint8_t CalculateBrightness() const; 65 | 66 | // ------------------------------------------------------------------------ 67 | // Darken will adjust the color by the given delta toward black 68 | // NOTE: This is a simple linear change 69 | // delta - (0-255) the amount to dim the color 70 | // ------------------------------------------------------------------------ 71 | void Darken(uint8_t delta); 72 | 73 | // ------------------------------------------------------------------------ 74 | // Lighten will adjust the color by the given delta toward white 75 | // NOTE: This is a simple linear change 76 | // delta - (0-255) the amount to lighten the color 77 | // ------------------------------------------------------------------------ 78 | void Lighten(uint8_t delta); 79 | 80 | // ------------------------------------------------------------------------ 81 | // LinearBlend between two colors by the amount defined by progress variable 82 | // left - the color to start the blend at 83 | // right - the color to end the blend at 84 | // progress - (0.0 - 1.0) value where 0 will return left and 1.0 will return right 85 | // and a value between will blend the color weighted linearly between them 86 | // ------------------------------------------------------------------------ 87 | static RgbColor LinearBlend(RgbColor left, RgbColor right, float progress); 88 | 89 | // ------------------------------------------------------------------------ 90 | // Red, Green, Blue color members (0-255) where 91 | // (0,0,0) is black and (255,255,255) is white 92 | // ------------------------------------------------------------------------ 93 | uint8_t R; 94 | uint8_t G; 95 | uint8_t B; 96 | }; 97 | 98 | -------------------------------------------------------------------------------- /lib/Time/examples/TimeNTP/TimeNTP.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Time_NTP.pde 3 | * Example showing time sync to NTP time source 4 | * 5 | * This sketch uses the Ethernet library 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; 14 | // NTP Servers: 15 | IPAddress timeServer(132, 163, 4, 101); // time-a.timefreq.bldrdoc.gov 16 | // IPAddress timeServer(132, 163, 4, 102); // time-b.timefreq.bldrdoc.gov 17 | // IPAddress timeServer(132, 163, 4, 103); // time-c.timefreq.bldrdoc.gov 18 | 19 | 20 | const int timeZone = 1; // Central European Time 21 | //const int timeZone = -5; // Eastern Standard Time (USA) 22 | //const int timeZone = -4; // Eastern Daylight Time (USA) 23 | //const int timeZone = -8; // Pacific Standard Time (USA) 24 | //const int timeZone = -7; // Pacific Daylight Time (USA) 25 | 26 | 27 | EthernetUDP Udp; 28 | unsigned int localPort = 8888; // local port to listen for UDP packets 29 | 30 | void setup() 31 | { 32 | Serial.begin(9600); 33 | while (!Serial) ; // Needed for Leonardo only 34 | delay(250); 35 | Serial.println("TimeNTP Example"); 36 | if (Ethernet.begin(mac) == 0) { 37 | // no point in carrying on, so do nothing forevermore: 38 | while (1) { 39 | Serial.println("Failed to configure Ethernet using DHCP"); 40 | delay(10000); 41 | } 42 | } 43 | Serial.print("IP number assigned by DHCP is "); 44 | Serial.println(Ethernet.localIP()); 45 | Udp.begin(localPort); 46 | Serial.println("waiting for sync"); 47 | setSyncProvider(getNtpTime); 48 | } 49 | 50 | time_t prevDisplay = 0; // when the digital clock was displayed 51 | 52 | void loop() 53 | { 54 | if (timeStatus() != timeNotSet) { 55 | if (now() != prevDisplay) { //update the display only if time has changed 56 | prevDisplay = now(); 57 | digitalClockDisplay(); 58 | } 59 | } 60 | } 61 | 62 | void digitalClockDisplay(){ 63 | // digital clock display of the time 64 | Serial.print(hour()); 65 | printDigits(minute()); 66 | printDigits(second()); 67 | Serial.print(" "); 68 | Serial.print(day()); 69 | Serial.print(" "); 70 | Serial.print(month()); 71 | Serial.print(" "); 72 | Serial.print(year()); 73 | Serial.println(); 74 | } 75 | 76 | void printDigits(int digits){ 77 | // utility for digital clock display: prints preceding colon and leading 0 78 | Serial.print(":"); 79 | if(digits < 10) 80 | Serial.print('0'); 81 | Serial.print(digits); 82 | } 83 | 84 | /*-------- NTP code ----------*/ 85 | 86 | const int NTP_PACKET_SIZE = 48; // NTP time is in the first 48 bytes of message 87 | byte packetBuffer[NTP_PACKET_SIZE]; //buffer to hold incoming & outgoing packets 88 | 89 | time_t getNtpTime() 90 | { 91 | while (Udp.parsePacket() > 0) ; // discard any previously received packets 92 | Serial.println("Transmit NTP Request"); 93 | sendNTPpacket(timeServer); 94 | uint32_t beginWait = millis(); 95 | while (millis() - beginWait < 1500) { 96 | int size = Udp.parsePacket(); 97 | if (size >= NTP_PACKET_SIZE) { 98 | Serial.println("Receive NTP Response"); 99 | Udp.read(packetBuffer, NTP_PACKET_SIZE); // read packet into the buffer 100 | unsigned long secsSince1900; 101 | // convert four bytes starting at location 40 to a long integer 102 | secsSince1900 = (unsigned long)packetBuffer[40] << 24; 103 | secsSince1900 |= (unsigned long)packetBuffer[41] << 16; 104 | secsSince1900 |= (unsigned long)packetBuffer[42] << 8; 105 | secsSince1900 |= (unsigned long)packetBuffer[43]; 106 | return secsSince1900 - 2208988800UL + timeZone * SECS_PER_HOUR; 107 | } 108 | } 109 | Serial.println("No NTP Response :-("); 110 | return 0; // return 0 if unable to get the time 111 | } 112 | 113 | // send an NTP request to the time server at the given address 114 | void sendNTPpacket(IPAddress &address) 115 | { 116 | // set all bytes in the buffer to 0 117 | memset(packetBuffer, 0, NTP_PACKET_SIZE); 118 | // Initialize values needed to form NTP request 119 | // (see URL above for details on the packets) 120 | packetBuffer[0] = 0b11100011; // LI, Version, Mode 121 | packetBuffer[1] = 0; // Stratum, or type of clock 122 | packetBuffer[2] = 6; // Polling Interval 123 | packetBuffer[3] = 0xEC; // Peer Clock Precision 124 | // 8 bytes of zero for Root Delay & Root Dispersion 125 | packetBuffer[12] = 49; 126 | packetBuffer[13] = 0x4E; 127 | packetBuffer[14] = 49; 128 | packetBuffer[15] = 52; 129 | // all NTP fields have been given values, now 130 | // you can send a packet requesting a timestamp: 131 | Udp.beginPacket(address, 123); //NTP requests are to port 123 132 | Udp.write(packetBuffer, NTP_PACKET_SIZE); 133 | Udp.endPacket(); 134 | } 135 | 136 | -------------------------------------------------------------------------------- /lib/NeoPixelBus/NeoPixelesp8266.c: -------------------------------------------------------------------------------- 1 | /* 2 | NeoPixelEsp8266.h - NeoPixel library helper functions for Esp8266 using cycle count 3 | Copyright (c) 2015 Michael C. Miller. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | #if defined(ESP8266) 24 | 25 | inline uint32_t _getCycleCount() 26 | { 27 | uint32_t ccount; 28 | __asm__ __volatile__("rsr %0,ccount":"=a" (ccount)); 29 | return ccount; 30 | } 31 | 32 | #define CYCLES_800_T0H (F_CPU / 2500000) // 0.4us 33 | #define CYCLES_800_T1H (F_CPU / 1250000) // 0.8us 34 | #define CYCLES_800 (F_CPU / 800000) // 1.25us per bit 35 | #define CYCLES_400_T0H (F_CPU / 2000000) 36 | #define CYCLES_400_T1H (F_CPU / 833333) 37 | #define CYCLES_400 (F_CPU / 400000) 38 | 39 | void ICACHE_RAM_ATTR send_pixels_800(uint8_t* pixels, uint8_t* end, uint8_t pin) 40 | { 41 | const uint32_t pinRegister = _BV(pin); 42 | uint8_t mask; 43 | uint8_t subpix; 44 | uint32_t cyclesStart; 45 | 46 | // trigger emediately 47 | cyclesStart = _getCycleCount() - CYCLES_800; 48 | do 49 | { 50 | subpix = *pixels++; 51 | for (mask = 0x80; mask != 0; mask >>= 1) 52 | { 53 | // do the checks here while we are waiting on time to pass 54 | uint32_t cyclesBit = ((subpix & mask)) ? CYCLES_800_T1H : CYCLES_800_T0H; 55 | uint32_t cyclesNext = cyclesStart; 56 | uint32_t delta; 57 | 58 | // after we have done as much work as needed for this next bit 59 | // now wait for the HIGH 60 | do 61 | { 62 | // cache and use this count so we don't incur another 63 | // instruction before we turn the bit high 64 | cyclesStart = _getCycleCount(); 65 | } while ((cyclesStart - cyclesNext) < CYCLES_800); 66 | 67 | // set high 68 | GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, pinRegister); 69 | 70 | // wait for the LOW 71 | do 72 | { 73 | cyclesNext = _getCycleCount(); 74 | } while ((cyclesNext - cyclesStart) < cyclesBit); 75 | 76 | // set low 77 | GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, pinRegister); 78 | } 79 | } while (pixels < end); 80 | 81 | // while accurate, this isn't needed due to the delays at the 82 | // top of Show() to enforce between update timing 83 | // while ((_getCycleCount() - cyclesStart) < CYCLES_800); 84 | } 85 | 86 | void ICACHE_RAM_ATTR send_pixels_400(uint8_t* pixels, uint8_t* end, uint8_t pin) 87 | { 88 | const uint32_t pinRegister = _BV(pin); 89 | uint8_t mask; 90 | uint8_t subpix; 91 | uint32_t cyclesStart; 92 | 93 | // trigger emediately 94 | cyclesStart = _getCycleCount() - CYCLES_400; 95 | while (pixels < end) 96 | { 97 | subpix = *pixels++; 98 | for (mask = 0x80; mask; mask >>= 1) 99 | { 100 | uint32_t cyclesBit = ((subpix & mask)) ? CYCLES_400_T1H : CYCLES_400_T0H; 101 | uint32_t cyclesNext = cyclesStart; 102 | 103 | // after we have done as much work as needed for this next bit 104 | // now wait for the HIGH 105 | do 106 | { 107 | // cache and use this count so we don't incur another 108 | // instruction before we turn the bit high 109 | cyclesStart = _getCycleCount(); 110 | } while ((cyclesStart - cyclesNext) < CYCLES_400); 111 | 112 | // set high 113 | GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, pinRegister); 114 | 115 | // wait for the LOW 116 | do 117 | { 118 | cyclesNext = _getCycleCount(); 119 | } while ((cyclesNext - cyclesStart) < cyclesBit); 120 | 121 | // set low 122 | GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, pinRegister); 123 | } 124 | } 125 | 126 | // while accurate, this isn't needed due to the delays at the 127 | // top of Show() to enforce between update timing 128 | // while ((_getCycleCount() - cyclesStart) < CYCLES_400); 129 | } 130 | 131 | #endif -------------------------------------------------------------------------------- /h/game.h: -------------------------------------------------------------------------------- 1 | const char game_html[] PROGMEM = R"=====( 2 | 3 | 4 | 5 | 6 | $externallinks 7 | 83 | Game On! 84 | 85 | 86 | 101 | 102 | 103 | 104 | Click Fast To Win! 105 | 106 | 107 | 108 | 109 | 110 | )====="; 111 | -------------------------------------------------------------------------------- /druhvhtml/Menu/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 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 | 91 |
              92 | 93 | 94 | -------------------------------------------------------------------------------- /html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 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 | 94 |
              95 |
              96 | 97 | -------------------------------------------------------------------------------- /lib/Time/examples/TimeNTP_ESP8266WiFi/TimeNTP_ESP8266WiFi.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * TimeNTP_ESP8266WiFi.ino 3 | * Example showing time sync to NTP time source 4 | * 5 | * This sketch uses the ESP8266WiFi library 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | const char ssid[] = "*************"; // your network SSID (name) 13 | const char pass[] = "********"; // your network password 14 | 15 | // NTP Servers: 16 | static const char ntpServerName[] = "us.pool.ntp.org"; 17 | //static const char ntpServerName[] = "time.nist.gov"; 18 | //static const char ntpServerName[] = "time-a.timefreq.bldrdoc.gov"; 19 | //static const char ntpServerName[] = "time-b.timefreq.bldrdoc.gov"; 20 | //static const char ntpServerName[] = "time-c.timefreq.bldrdoc.gov"; 21 | 22 | const int timeZone = 1; // Central European Time 23 | //const int timeZone = -5; // Eastern Standard Time (USA) 24 | //const int timeZone = -4; // Eastern Daylight Time (USA) 25 | //const int timeZone = -8; // Pacific Standard Time (USA) 26 | //const int timeZone = -7; // Pacific Daylight Time (USA) 27 | 28 | 29 | WiFiUDP Udp; 30 | unsigned int localPort = 8888; // local port to listen for UDP packets 31 | 32 | time_t getNtpTime(); 33 | void digitalClockDisplay(); 34 | void printDigits(int digits); 35 | void sendNTPpacket(IPAddress &address); 36 | 37 | void setup() 38 | { 39 | Serial.begin(9600); 40 | while (!Serial) ; // Needed for Leonardo only 41 | delay(250); 42 | Serial.println("TimeNTP Example"); 43 | Serial.print("Connecting to "); 44 | Serial.println(ssid); 45 | WiFi.begin(ssid, pass); 46 | 47 | while (WiFi.status() != WL_CONNECTED) { 48 | delay(500); 49 | Serial.print("."); 50 | } 51 | 52 | Serial.print("IP number assigned by DHCP is "); 53 | Serial.println(WiFi.localIP()); 54 | Serial.println("Starting UDP"); 55 | Udp.begin(localPort); 56 | Serial.print("Local port: "); 57 | Serial.println(Udp.localPort()); 58 | Serial.println("waiting for sync"); 59 | setSyncProvider(getNtpTime); 60 | setSyncInterval(300); 61 | } 62 | 63 | time_t prevDisplay = 0; // when the digital clock was displayed 64 | 65 | void loop() 66 | { 67 | if (timeStatus() != timeNotSet) { 68 | if (now() != prevDisplay) { //update the display only if time has changed 69 | prevDisplay = now(); 70 | digitalClockDisplay(); 71 | } 72 | } 73 | } 74 | 75 | void digitalClockDisplay() 76 | { 77 | // digital clock display of the time 78 | Serial.print(hour()); 79 | printDigits(minute()); 80 | printDigits(second()); 81 | Serial.print(" "); 82 | Serial.print(day()); 83 | Serial.print("."); 84 | Serial.print(month()); 85 | Serial.print("."); 86 | Serial.print(year()); 87 | Serial.println(); 88 | } 89 | 90 | void printDigits(int digits) 91 | { 92 | // utility for digital clock display: prints preceding colon and leading 0 93 | Serial.print(":"); 94 | if (digits < 10) 95 | Serial.print('0'); 96 | Serial.print(digits); 97 | } 98 | 99 | /*-------- NTP code ----------*/ 100 | 101 | const int NTP_PACKET_SIZE = 48; // NTP time is in the first 48 bytes of message 102 | byte packetBuffer[NTP_PACKET_SIZE]; //buffer to hold incoming & outgoing packets 103 | 104 | time_t getNtpTime() 105 | { 106 | IPAddress ntpServerIP; // NTP server's ip address 107 | 108 | while (Udp.parsePacket() > 0) ; // discard any previously received packets 109 | Serial.println("Transmit NTP Request"); 110 | // get a random server from the pool 111 | WiFi.hostByName(ntpServerName, ntpServerIP); 112 | Serial.print(ntpServerName); 113 | Serial.print(": "); 114 | Serial.println(ntpServerIP); 115 | sendNTPpacket(ntpServerIP); 116 | uint32_t beginWait = millis(); 117 | while (millis() - beginWait < 1500) { 118 | int size = Udp.parsePacket(); 119 | if (size >= NTP_PACKET_SIZE) { 120 | Serial.println("Receive NTP Response"); 121 | Udp.read(packetBuffer, NTP_PACKET_SIZE); // read packet into the buffer 122 | unsigned long secsSince1900; 123 | // convert four bytes starting at location 40 to a long integer 124 | secsSince1900 = (unsigned long)packetBuffer[40] << 24; 125 | secsSince1900 |= (unsigned long)packetBuffer[41] << 16; 126 | secsSince1900 |= (unsigned long)packetBuffer[42] << 8; 127 | secsSince1900 |= (unsigned long)packetBuffer[43]; 128 | return secsSince1900 - 2208988800UL + timeZone * SECS_PER_HOUR; 129 | } 130 | } 131 | Serial.println("No NTP Response :-("); 132 | return 0; // return 0 if unable to get the time 133 | } 134 | 135 | // send an NTP request to the time server at the given address 136 | void sendNTPpacket(IPAddress &address) 137 | { 138 | // set all bytes in the buffer to 0 139 | memset(packetBuffer, 0, NTP_PACKET_SIZE); 140 | // Initialize values needed to form NTP request 141 | // (see URL above for details on the packets) 142 | packetBuffer[0] = 0b11100011; // LI, Version, Mode 143 | packetBuffer[1] = 0; // Stratum, or type of clock 144 | packetBuffer[2] = 6; // Polling Interval 145 | packetBuffer[3] = 0xEC; // Peer Clock Precision 146 | // 8 bytes of zero for Root Delay & Root Dispersion 147 | packetBuffer[12] = 49; 148 | packetBuffer[13] = 0x4E; 149 | packetBuffer[14] = 49; 150 | packetBuffer[15] = 52; 151 | // all NTP fields have been given values, now 152 | // you can send a packet requesting a timestamp: 153 | Udp.beginPacket(address, 123); //NTP requests are to port 123 154 | Udp.write(packetBuffer, NTP_PACKET_SIZE); 155 | Udp.endPacket(); 156 | } 157 | -------------------------------------------------------------------------------- /lib/NeoPixelBus/examples/NeoPixelFun/NeoPixelFun.pde: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define pixelCount 16 // make sure to set this to the number of pixels in your strip 5 | #define pixelPin 8 // make sure to set this to the correct pin 6 | 7 | NeoPixelBus strip = NeoPixelBus(pixelCount, pixelPin); 8 | NeoPixelAnimator animations(&strip); // NeoPixel animation management object 9 | 10 | uint16_t effectState = 0; // general purpose varible used to store effect state 11 | 12 | 13 | void setup() 14 | { 15 | strip.Begin(); 16 | strip.Show(); 17 | SetRandomSeed(); 18 | } 19 | 20 | 21 | void loop() 22 | { 23 | // There are four fun functions that implement different effects 24 | // uncomment one at a time and upload to see the effect 25 | 26 | // LoopAround(192, 200); // very interesting on rings of NeoPixels 27 | PickRandom(128); 28 | // FadeInFadeOutRinseRepeat(192); 29 | // LoopFade(192, 10); 30 | 31 | // wait until no more animations are running 32 | while (animations.IsAnimating()) 33 | { 34 | animations.UpdateAnimations(); 35 | strip.Show(); 36 | delay(31); // ~30hz change cycle 37 | } 38 | 39 | } 40 | 41 | void FadeInFadeOutRinseRepeat(uint8_t peak) 42 | { 43 | if (effectState == 0) 44 | { 45 | for (uint8_t pixel = 0; pixel < pixelCount; pixel++) 46 | { 47 | uint16_t time = random(800, 1000); 48 | RgbColor originalColor = strip.GetPixelColor(pixel); 49 | RgbColor color = RgbColor(random(peak), random(peak), random(peak)); 50 | 51 | // define the effect to apply, in this case linear blend 52 | AnimUpdateCallback animUpdate = [=](float progress) 53 | { 54 | // progress will start at 0.0 and end at 1.0 55 | RgbColor updatedColor = RgbColor::LinearBlend(originalColor, color, (uint8_t)(255 * progress)); 56 | strip.SetPixelColor(pixel, updatedColor); 57 | }; 58 | animations.StartAnimation(pixel, time, animUpdate); 59 | } 60 | } 61 | else if (effectState == 1) 62 | { 63 | for (uint8_t pixel = 0; pixel < pixelCount; pixel++) 64 | { 65 | uint16_t time = random(600, 700); 66 | RgbColor originalColor = strip.GetPixelColor(pixel); 67 | 68 | // define the effect to apply, in this case linear blend 69 | AnimUpdateCallback animUpdate = [=](float progress) 70 | { 71 | // progress will start at 0.0 and end at 1.0 72 | RgbColor updatedColor = RgbColor::LinearBlend(originalColor, RgbColor(0, 0, 0), (uint8_t)(255 * progress)); 73 | strip.SetPixelColor(pixel, updatedColor); 74 | }; 75 | // start the animation 76 | animations.StartAnimation(pixel, time, animUpdate); 77 | } 78 | } 79 | effectState = (effectState + 1) % 2; // next effectState and keep within the number of effectStates 80 | 81 | } 82 | 83 | void PickRandom(uint8_t peak) 84 | { 85 | // pick random set of pixels to animate 86 | uint8_t count = random(pixelCount); 87 | while (count > 0) 88 | { 89 | uint16_t pixel = random(pixelCount); 90 | 91 | // configure the animations 92 | HslColor color = HslColor(random(255), peak, peak); 93 | uint16_t time = random(100, 400); 94 | HslColor originalColor = strip.GetPixelColor(pixel); 95 | 96 | // define the effect to apply, in this case linear blend 97 | AnimUpdateCallback animUpdate = [=](float progress) 98 | { 99 | // progress will start at 0.0 and end at 1.0 100 | HslColor updatedColor = HslColor::LinearBlend(originalColor, color, (uint8_t)(255 * progress)); 101 | strip.SetPixelColor(pixel, updatedColor); 102 | }; 103 | // start the animation 104 | animations.StartAnimation(pixel, time, animUpdate); 105 | 106 | count--; 107 | } 108 | } 109 | 110 | void LoopAround(uint8_t peak, uint16_t speed) 111 | { 112 | // Looping around the ring sample 113 | uint16_t time = speed; 114 | 115 | 116 | // apply an animations to current pixel and previous 5 pixels 117 | for (uint16_t offset = 5; offset >= 0; offset--) 118 | { 119 | uint16_t pixel = (effectState + (pixelCount - offset)) % pixelCount; 120 | RgbColor originalColor = strip.GetPixelColor(pixel); 121 | RgbColor color; 122 | 123 | if (offset == 0) 124 | { 125 | // newest one fades up to a random color 126 | color = RgbColor(random(peak), random(peak), random(peak)); 127 | } 128 | else if (offset == 5) 129 | { 130 | // oldest fades to black 131 | color = RgbColor(0, 0, 0); 132 | } 133 | else 134 | { 135 | // all others just dim 136 | color = originalColor; 137 | color.Darken(color.CalculateBrightness() / 2); 138 | } 139 | 140 | // define the effect to apply, in this case linear blend 141 | AnimUpdateCallback animUpdate = [=](float progress) 142 | { 143 | // progress will start at 0.0 and end at 1.0 144 | RgbColor updatedColor = RgbColor::LinearBlend(originalColor, color, (uint8_t)(255 * progress)); 145 | strip.SetPixelColor(pixel, updatedColor); 146 | }; 147 | 148 | // start the animation 149 | animations.StartAnimation(pixel, time, animUpdate); 150 | } 151 | 152 | // move to next pixel 153 | effectState = (effectState + 1) % pixelCount; 154 | } 155 | 156 | void SetRandomSeed() 157 | { 158 | uint32_t seed; 159 | 160 | // random works best with a seed that can use 31 bits 161 | // analogRead on a unconnected pin tends toward less than four bits 162 | seed = analogRead(0); 163 | delay(1); 164 | 165 | for (int shifts = 3; shifts < 31; shifts += 3) 166 | { 167 | seed ^= analogRead(0) << shifts; 168 | delay(1); 169 | } 170 | 171 | // Serial.println(seed); 172 | randomSeed(seed); 173 | } 174 | -------------------------------------------------------------------------------- /lib/Time/TimeLib.h: -------------------------------------------------------------------------------- 1 | /* 2 | time.h - low level time and date functions 3 | */ 4 | 5 | /* 6 | July 3 2011 - fixed elapsedSecsThisWeek macro (thanks Vincent Valdy for this) 7 | - fixed daysToTime_t macro (thanks maniacbug) 8 | */ 9 | 10 | #ifndef _Time_h 11 | #ifdef __cplusplus 12 | #define _Time_h 13 | 14 | #include 15 | #ifndef __AVR__ 16 | #include // for __time_t_defined, but avr libc lacks sys/types.h 17 | #endif 18 | 19 | 20 | #if !defined(__time_t_defined) // avoid conflict with newlib or other posix libc 21 | typedef unsigned long time_t; 22 | #endif 23 | 24 | 25 | // This ugly hack allows us to define C++ overloaded functions, when included 26 | // from within an extern "C", as newlib's sys/stat.h does. Actually it is 27 | // intended to include "time.h" from the C library (on ARM, but AVR does not 28 | // have that file at all). On Mac and Windows, the compiler will find this 29 | // "Time.h" instead of the C library "time.h", so we may cause other weird 30 | // and unpredictable effects by conflicting with the C library header "time.h", 31 | // but at least this hack lets us define C++ functions as intended. Hopefully 32 | // nothing too terrible will result from overriding the C library header?! 33 | extern "C++" { 34 | typedef enum {timeNotSet, timeNeedsSync, timeSet 35 | } timeStatus_t ; 36 | 37 | typedef enum { 38 | dowInvalid, dowSunday, dowMonday, dowTuesday, dowWednesday, dowThursday, dowFriday, dowSaturday 39 | } timeDayOfWeek_t; 40 | 41 | typedef enum { 42 | tmSecond, tmMinute, tmHour, tmWday, tmDay,tmMonth, tmYear, tmNbrFields 43 | } tmByteFields; 44 | 45 | typedef struct { 46 | uint8_t Second; 47 | uint8_t Minute; 48 | uint8_t Hour; 49 | uint8_t Wday; // day of week, sunday is day 1 50 | uint8_t Day; 51 | uint8_t Month; 52 | uint8_t Year; // offset from 1970; 53 | } tmElements_t, TimeElements, *tmElementsPtr_t; 54 | 55 | //convenience macros to convert to and from tm years 56 | #define tmYearToCalendar(Y) ((Y) + 1970) // full four digit year 57 | #define CalendarYrToTm(Y) ((Y) - 1970) 58 | #define tmYearToY2k(Y) ((Y) - 30) // offset is from 2000 59 | #define y2kYearToTm(Y) ((Y) + 30) 60 | 61 | typedef time_t(*getExternalTime)(); 62 | //typedef void (*setExternalTime)(const time_t); // not used in this version 63 | 64 | 65 | /*==============================================================================*/ 66 | /* Useful Constants */ 67 | #define SECS_PER_MIN (60UL) 68 | #define SECS_PER_HOUR (3600UL) 69 | #define SECS_PER_DAY (SECS_PER_HOUR * 24UL) 70 | #define DAYS_PER_WEEK (7UL) 71 | #define SECS_PER_WEEK (SECS_PER_DAY * DAYS_PER_WEEK) 72 | #define SECS_PER_YEAR (SECS_PER_WEEK * 52UL) 73 | #define SECS_YR_2000 (946684800UL) // the time at the start of y2k 74 | 75 | /* Useful Macros for getting elapsed time */ 76 | #define numberOfSeconds(_time_) (_time_ % SECS_PER_MIN) 77 | #define numberOfMinutes(_time_) ((_time_ / SECS_PER_MIN) % SECS_PER_MIN) 78 | #define numberOfHours(_time_) (( _time_% SECS_PER_DAY) / SECS_PER_HOUR) 79 | #define dayOfWeek(_time_) ((( _time_ / SECS_PER_DAY + 4) % DAYS_PER_WEEK)+1) // 1 = Sunday 80 | #define elapsedDays(_time_) ( _time_ / SECS_PER_DAY) // this is number of days since Jan 1 1970 81 | #define elapsedSecsToday(_time_) (_time_ % SECS_PER_DAY) // the number of seconds since last midnight 82 | // The following macros are used in calculating alarms and assume the clock is set to a date later than Jan 1 1971 83 | // Always set the correct time before settting alarms 84 | #define previousMidnight(_time_) (( _time_ / SECS_PER_DAY) * SECS_PER_DAY) // time at the start of the given day 85 | #define nextMidnight(_time_) ( previousMidnight(_time_) + SECS_PER_DAY ) // time at the end of the given day 86 | #define elapsedSecsThisWeek(_time_) (elapsedSecsToday(_time_) + ((dayOfWeek(_time_)-1) * SECS_PER_DAY) ) // note that week starts on day 1 87 | #define previousSunday(_time_) (_time_ - elapsedSecsThisWeek(_time_)) // time at the start of the week for the given time 88 | #define nextSunday(_time_) ( previousSunday(_time_)+SECS_PER_WEEK) // time at the end of the week for the given time 89 | 90 | 91 | /* Useful Macros for converting elapsed time to a time_t */ 92 | #define minutesToTime_t ((M)) ( (M) * SECS_PER_MIN) 93 | #define hoursToTime_t ((H)) ( (H) * SECS_PER_HOUR) 94 | #define daysToTime_t ((D)) ( (D) * SECS_PER_DAY) // fixed on Jul 22 2011 95 | #define weeksToTime_t ((W)) ( (W) * SECS_PER_WEEK) 96 | 97 | /*============================================================================*/ 98 | /* time and date functions */ 99 | int hour(); // the hour now 100 | int hour(time_t t); // the hour for the given time 101 | int hourFormat12(); // the hour now in 12 hour format 102 | int hourFormat12(time_t t); // the hour for the given time in 12 hour format 103 | uint8_t isAM(); // returns true if time now is AM 104 | uint8_t isAM(time_t t); // returns true the given time is AM 105 | uint8_t isPM(); // returns true if time now is PM 106 | uint8_t isPM(time_t t); // returns true the given time is PM 107 | int minute(); // the minute now 108 | int minute(time_t t); // the minute for the given time 109 | int second(); // the second now 110 | int second(time_t t); // the second for the given time 111 | int day(); // the day now 112 | int day(time_t t); // the day for the given time 113 | int weekday(); // the weekday now (Sunday is day 1) 114 | int weekday(time_t t); // the weekday for the given time 115 | int month(); // the month now (Jan is month 1) 116 | int month(time_t t); // the month for the given time 117 | int year(); // the full four digit year: (2009, 2010 etc) 118 | int year(time_t t); // the year for the given time 119 | 120 | time_t now(); // return the current time as seconds since Jan 1 1970 121 | void setTime(time_t t); 122 | void setTime(int hr,int min,int sec,int day, int month, int yr); 123 | void adjustTime(long adjustment); 124 | 125 | /* date strings */ 126 | #define dt_MAX_STRING_LEN 9 // length of longest date string (excluding terminating null) 127 | char* monthStr(uint8_t month); 128 | char* dayStr(uint8_t day); 129 | char* monthShortStr(uint8_t month); 130 | char* dayShortStr(uint8_t day); 131 | 132 | /* time sync functions */ 133 | timeStatus_t timeStatus(); // indicates if time has been set and recently synchronized 134 | void setSyncProvider( getExternalTime getTimeFunction); // identify the external time provider 135 | void setSyncInterval(time_t interval); // set the number of seconds between re-sync 136 | 137 | /* low level functions to convert to and from system time */ 138 | void breakTime(time_t time, tmElements_t &tm); // break time_t into elements 139 | time_t makeTime(tmElements_t &tm); // convert time elements into time_t 140 | 141 | } // extern "C++" 142 | #endif // __cplusplus 143 | #endif /* _Time_h */ 144 | 145 | -------------------------------------------------------------------------------- /lib/Time/Readme.txt: -------------------------------------------------------------------------------- 1 | Readme file for Arduino Time Library 2 | 3 | Time is a library that provides timekeeping functionality for Arduino. 4 | 5 | The code is derived from the Playground DateTime library but is updated 6 | to provide an API that is more flexable and easier to use. 7 | 8 | A primary goal was to enable date and time functionality that can be used with 9 | a variety of external time sources with minimum differences required in sketch logic. 10 | 11 | Example sketches illustrate how similar sketch code can be used with: a Real Time Clock, 12 | internet NTP time service, GPS time data, and Serial time messages from a computer 13 | for time synchronization. 14 | 15 | The functions available in the library include: 16 | 17 | hour(); // the hour now (0-23) 18 | minute(); // the minute now (0-59) 19 | second(); // the second now (0-59) 20 | day(); // the day now (1-31) 21 | weekday(); // day of the week, Sunday is day 0 22 | month(); // the month now (1-12) 23 | year(); // the full four digit year: (2009, 2010 etc) 24 | 25 | there are also functions to return the hour in 12 hour format 26 | hourFormat12(); // the hour now in 12 hour format 27 | isAM(); // returns true if time now is AM 28 | isPM(); // returns true if time now is PM 29 | 30 | now(); // returns the current time as seconds since Jan 1 1970 31 | 32 | The time and date functions can take an optional parameter for the time. This prevents 33 | errors if the time rolls over between elements. For example, if a new minute begins 34 | between getting the minute and second, the values will be inconsistent. Using the 35 | following functions eliminates this probglem 36 | time_t t = now(); // store the current time in time variable t 37 | hour(t); // returns the hour for the given time t 38 | minute(t); // returns the minute for the given time t 39 | second(t); // returns the second for the given time t 40 | day(t); // the day for the given time t 41 | weekday(t); // day of the week for the given time t 42 | month(t); // the month for the given time t 43 | year(t); // the year for the given time t 44 | 45 | 46 | Functions for managing the timer services are: 47 | setTime(t); // set the system time to the give time t 48 | setTime(hr,min,sec,day,mnth,yr); // alternative to above, yr is 2 or 4 digit yr (2010 or 10 sets year to 2010) 49 | adjustTime(adjustment); // adjust system time by adding the adjustment value 50 | 51 | timeStatus(); // indicates if time has been set and recently synchronized 52 | // returns one of the following enumerations: 53 | timeNotSet // the time has never been set, the clock started at Jan 1 1970 54 | timeNeedsSync // the time had been set but a sync attempt did not succeed 55 | timeSet // the time is set and is synced 56 | Time and Date values are not valid if the status is timeNotSet. Otherwise values can be used but 57 | the returned time may have drifted if the status is timeNeedsSync. 58 | 59 | setSyncProvider(getTimeFunction); // set the external time provider 60 | setSyncInterval(interval); // set the number of seconds between re-sync 61 | 62 | 63 | There are many convenience macros in the time.h file for time constants and conversion of time units. 64 | 65 | To use the library, copy the download to the Library directory. 66 | 67 | The Time directory contains the Time library and some example sketches 68 | illustrating how the library can be used with various time sources: 69 | 70 | - TimeSerial.pde shows Arduino as a clock without external hardware. 71 | It is synchronized by time messages sent over the serial port. 72 | A companion Processing sketch will automatically provide these messages 73 | if it is running and connected to the Arduino serial port. 74 | 75 | - TimeSerialDateStrings.pde adds day and month name strings to the sketch above 76 | Short (3 character) and long strings are available to print the days of 77 | the week and names of the months. 78 | 79 | - TimeRTC uses a DS1307 real time clock to provide time synchronization. 80 | A basic RTC library named DS1307RTC is included in the download. 81 | To run this sketch the DS1307RTC library must be installed. 82 | 83 | - TimeRTCSet is similar to the above and adds the ability to set the Real Time Clock 84 | 85 | - TimeRTCLog demonstrates how to calculate the difference between times. 86 | It is a vary simple logger application that monitors events on digtial pins 87 | and prints (to the serial port) the time of an event and the time period since the previous event. 88 | 89 | - TimeNTP uses the Arduino Ethernet shield to access time using the internet NTP time service. 90 | The NTP protocol uses UDP and the UdpBytewise library is required, see: 91 | http://bitbucket.org/bjoern/arduino_osc/src/14667490521f/libraries/Ethernet/ 92 | 93 | - TimeGPS gets time from a GPS 94 | This requires the TinyGPS library from Mikal Hart: 95 | http://arduiniana.org/libraries/TinyGPS 96 | 97 | Differences between this code and the playground DateTime library 98 | although the Time library is based on the DateTime codebase, the API has changed. 99 | Changes in the Time library API: 100 | - time elements are functions returning int (they are variables in DateTime) 101 | - Years start from 1970 102 | - days of the week and months start from 1 (they start from 0 in DateTime) 103 | - DateStrings do not require a seperate library 104 | - time elements can be accessed non-atomically (in DateTime they are always atomic) 105 | - function added to automatically sync time with extrnal source 106 | - localTime and maketime parameters changed, localTime renamed to breakTime 107 | 108 | Technical notes: 109 | 110 | Internal system time is based on the standard Unix time_t. 111 | The value is the number of seconds since Jan 1 1970. 112 | System time begins at zero when the sketch starts. 113 | 114 | The internal time can be automatically synchronized at regular intervals to an external time source. 115 | This is enabled by calling the setSyncProvider(provider) function - the provider argument is 116 | the address of a function that returns the current time as a time_t. 117 | See the sketches in the examples directory for usage. 118 | 119 | The default interval for re-syncing the time is 5 minutes but can be changed by calling the 120 | setSyncInterval( interval) method to set the number of seconds between re-sync attempts. 121 | 122 | The Time library defines a structure for holding time elements that is a compact version of the C tm structure. 123 | All the members of the Arduino tm structure are bytes and the year is offset from 1970. 124 | Convenience macros provide conversion to and from the Arduino format. 125 | 126 | Low level functions to convert between system time and individual time elements are provided: 127 | breakTime( time, &tm); // break time_t into elements stored in tm struct 128 | makeTime( &tm); // return time_t from elements stored in tm struct 129 | 130 | The DS1307RTC library included in the download provides an example of how a time provider 131 | can use the low level functions to interface with the Time library. 132 | --------------------------------------------------------------------------------