From 55b69b9a8db9e12ecfd63b3576f26e91c743f478 Mon Sep 17 00:00:00 2001 From: Jaro Date: Fri, 10 Apr 2020 11:53:47 +0200 Subject: [PATCH] Init commit --- .gitignore | 5 + .travis.yml | 67 ++++++++ .vscode/extensions.json | 7 + .vscode/settings.json | 5 + include/README | 39 +++++ lib/README | 46 +++++ platformio.ini | 16 ++ src/calendar.h | 368 ++++++++++++++++++++++++++++++++++++++++ src/data/index.html | 166 ++++++++++++++++++ src/data/indexvujs.html | 126 ++++++++++++++ src/main.cpp | 197 +++++++++++++++++++++ test/README | 11 ++ 12 files changed, 1053 insertions(+) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json create mode 100644 include/README create mode 100644 lib/README create mode 100644 platformio.ini create mode 100644 src/calendar.h create mode 100644 src/data/index.html create mode 100644 src/data/indexvujs.html create mode 100644 src/main.cpp create mode 100644 test/README diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..89cc49c --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.pio +.vscode/.browse.c_cpp.db* +.vscode/c_cpp_properties.json +.vscode/launch.json +.vscode/ipch diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..7c486f1 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,67 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < https://docs.platformio.org/page/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < https://docs.platformio.org/page/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < https://docs.platformio.org/page/userguide/cmd_ci.html > +# +# +# Please choose one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to be used as a library with examples. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..e80666b --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..1428c38 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.associations": { + "random": "cpp" + } +} \ No newline at end of file diff --git a/include/README b/include/README new file mode 100644 index 0000000..194dcd4 --- /dev/null +++ b/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/lib/README b/lib/README new file mode 100644 index 0000000..6debab1 --- /dev/null +++ b/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 0000000..1a56c6c --- /dev/null +++ b/platformio.ini @@ -0,0 +1,16 @@ +;PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:esp32doit-devkit-v1] +platform = espressif32 +board = esp32doit-devkit-v1 +framework = arduino +monitor_port = COM[13] +monitor_speed = 115200 \ No newline at end of file diff --git a/src/calendar.h b/src/calendar.h new file mode 100644 index 0000000..42bef6e --- /dev/null +++ b/src/calendar.h @@ -0,0 +1,368 @@ +struct calenar_names_def { + int m; int d; const char *name; +}; + +struct calenar_names_def cal_names[] { +{ 1, 2, "Alexandra, Karina" }, +{ 1, 3, "Daniela" }, +{ 1, 4, "Drahoslav" }, +{ 1, 5, "Andrea" }, +{ 1, 6, "Antonia" }, +{ 1, 7, "Bohuslava" }, +{ 1, 8, "Severin" }, +{ 1, 9, "Alexej" }, +{ 1, 10, "Dasa" }, +{ 1, 11, "Malvina" }, +{ 1, 12, "Ernest" }, +{ 1, 13, "Rastislav" }, +{ 1, 14, "Radovan" }, +{ 1, 15, "Dobroslav" }, +{ 1, 16, "Kristina" }, +{ 1, 17, "Natasa" }, +{ 1, 18, "Bohdana" }, +{ 1, 19, "Drahomira, Mario" }, +{ 1, 20, "Dalibor" }, +{ 1, 21, "Vincent" }, +{ 1, 22, "Zora" }, +{ 1, 23, "Milos" }, +{ 1, 24, "Timotej" }, +{ 1, 25, "Gejza" }, +{ 1, 26, "Tamara" }, +{ 1, 27, "Bohus" }, +{ 1, 28, "Alfonz" }, +{ 1, 29, "Gaspar" }, +{ 1, 30, "Ema" }, +{ 1, 31, "Emil" }, +{ 2, 1, "Tatiana" }, +{ 2, 2, "Erika, Erik" }, +{ 2, 3, "Blazej" }, +{ 2, 4, "Veronika" }, +{ 2, 5, "Agata" }, +{ 2, 6, "Dorota" }, +{ 2, 7, "Vanda" }, +{ 2, 8, "Zoja" }, +{ 2, 9, "Zdenko" }, +{ 2, 10, "Gabriela" }, +{ 2, 11, "Dezider" }, +{ 2, 12, "Perla" }, +{ 2, 13, "Arpad" }, +{ 2, 14, "Valentin" }, +{ 2, 15, "Pravoslav" }, +{ 2, 16, "Ida, Liana" }, +{ 2, 17, "Miloslava" }, +{ 2, 18, "Jaromir" }, +{ 2, 19, "Vlasta" }, +{ 2, 20, "Livia" }, +{ 2, 21, "Eleonora" }, +{ 2, 22, "Etela" }, +{ 2, 23, "Roman, Romana" }, +{ 2, 24, "Matej" }, +{ 2, 25, "Frederik, Frederika" }, +{ 2, 26, "Viktor" }, +{ 2, 27, "Alexander" }, +{ 2, 28, "Zlatica" }, +{ 2, 29, "Radomir" }, +{ 3, 1, "Albin" }, +{ 3, 2, "Anezka" }, +{ 3, 3, "Bohumil, Bohumila" }, +{ 3, 4, "Kazimir" }, +{ 3, 5, "Fridrich" }, +{ 3, 6, "Radoslav, Radoslava" }, +{ 3, 7, "Tomas" }, +{ 3, 8, "Alan, Alana" }, +{ 3, 9, "Frantiska" }, +{ 3, 10, "Bruno, Branislav" }, +{ 3, 11, "Angela, Angelika" }, +{ 3, 12, "Gregor" }, +{ 3, 13, "Vlastimil" }, +{ 3, 14, "Matilda" }, +{ 3, 15, "Svetlana" }, +{ 3, 16, "Boleslav" }, +{ 3, 17, "Lubica" }, +{ 3, 18, "Eduard" }, +{ 3, 19, "Jozef" }, +{ 3, 20, "Vitazoslav, Klaudius" }, +{ 3, 21, "Blahoslav" }, +{ 3, 22, "Benadik" }, +{ 3, 23, "Adrian" }, +{ 3, 24, "Gabriel" }, +{ 3, 25, "Marian" }, +{ 3, 26, "Emanuel" }, +{ 3, 27, "Alena" }, +{ 3, 28, "Sona" }, +{ 3, 29, "Miroslav" }, +{ 3, 30, "Vieroslava" }, +{ 3, 31, "Benjamin" }, +{ 4, 1, "Hugo" }, +{ 4, 2, "Zita" }, +{ 4, 3, "Richard" }, +{ 4, 4, "Izidor" }, +{ 4, 5, "Miroslava" }, +{ 4, 6, "Irena" }, +{ 4, 7, "Zoltan" }, +{ 4, 8, "Albert" }, +{ 4, 9, "Milena" }, +{ 4, 10, "Igor" }, +{ 4, 11, "Julius" }, +{ 4, 12, "Estera" }, +{ 4, 13, "Ales" }, +{ 4, 14, "Justina" }, +{ 4, 15, "Fedor" }, +{ 4, 16, "Dana, Danica" }, +{ 4, 17, "Rudolf, Rudolfa" }, +{ 4, 18, "Valer" }, +{ 4, 19, "Jela" }, +{ 4, 20, "Marcel" }, +{ 4, 21, "Ervin" }, +{ 4, 22, "Slavomir" }, +{ 4, 23, "Vojtech" }, +{ 4, 24, "Juraj" }, +{ 4, 25, "Marek" }, +{ 4, 26, "Jaroslava" }, +{ 4, 27, "Jaroslav" }, +{ 4, 28, "Jarmila" }, +{ 4, 29, "Lea" }, +{ 4, 30, "Anastazia" }, +{ 5, 2, "Zigmund" }, +{ 5, 3, "Galina, Timea" }, +{ 5, 4, "Florian" }, +{ 5, 5, "Lesia, Lesana" }, +{ 5, 6, "Hermina" }, +{ 5, 7, "Monika" }, +{ 5, 8, "Ingrida" }, +{ 5, 9, "Roland" }, +{ 5, 10, "Viktoria" }, +{ 5, 11, "Blazena" }, +{ 5, 12, "Pankrac" }, +{ 5, 13, "Servac" }, +{ 5, 14, "Bonifac" }, +{ 5, 15, "Zofia, Sofia" }, +{ 5, 16, "Svetozar" }, +{ 5, 17, "Gizela, Aneta" }, +{ 5, 18, "Viola" }, +{ 5, 19, "Gertruda" }, +{ 5, 20, "Bernard" }, +{ 5, 21, "Zina" }, +{ 5, 22, "Julia, Juliana" }, +{ 5, 23, "Zelmira" }, +{ 5, 24, "Ela" }, +{ 5, 25, "Urban, Vivien" }, +{ 5, 26, "Dusan" }, +{ 5, 27, "Iveta" }, +{ 5, 28, "Viliam" }, +{ 5, 29, "Vilma" }, +{ 5, 30, "Ferdinand" }, +{ 5, 31, "Petrana, Petronela" }, +{ 6, 1, "Zaneta" }, +{ 6, 2, "Xenia, Oxana" }, +{ 6, 3, "Karolina" }, +{ 6, 4, "Lenka" }, +{ 6, 5, "Laura" }, +{ 6, 6, "Norbert" }, +{ 6, 7, "Robert, Roberta" }, +{ 6, 8, "Medard" }, +{ 6, 9, "Stanislava" }, +{ 6, 10, "Margareta, Greta" }, +{ 6, 11, "Dobroslava" }, +{ 6, 12, "Zlatko" }, +{ 6, 13, "Anton" }, +{ 6, 14, "Vasil" }, +{ 6, 15, "Vit" }, +{ 6, 16, "Blanka, Bianka" }, +{ 6, 17, "Adolf" }, +{ 6, 18, "Vratislav" }, +{ 6, 19, "Alfred" }, +{ 6, 20, "Valeria" }, +{ 6, 21, "Alojz" }, +{ 6, 22, "Paulina" }, +{ 6, 23, "Sidonia" }, +{ 6, 24, "Jan" }, +{ 6, 25, "Olivia, Tadeas" }, +{ 6, 26, "Adriana" }, +{ 6, 27, "Ladislav, Ladislava" }, +{ 6, 28, "Beata" }, +{ 6, 29, "Peter, Pavol, Petra" }, +{ 6, 30, "Melania" }, +{ 7, 1, "Diana" }, +{ 7, 2, "Berta" }, +{ 7, 3, "Miloslav" }, +{ 7, 4, "Prokop" }, +{ 7, 5, "Cyril, Metod" }, +{ 7, 6, "Patrik, Patricia" }, +{ 7, 7, "Oliver" }, +{ 7, 8, "Ivan" }, +{ 7, 9, "Lujza" }, +{ 7, 10, "Amalia" }, +{ 7, 11, "Milota" }, +{ 7, 12, "Nina" }, +{ 7, 13, "Margita" }, +{ 7, 14, "Kamil" }, +{ 7, 15, "Henrich" }, +{ 7, 16, "Drahomir, Rut" }, +{ 7, 17, "Bohuslav" }, +{ 7, 18, "Kamila" }, +{ 7, 19, "Dusana" }, +{ 7, 20, "Ilja, Elias" }, +{ 7, 21, "Daniel" }, +{ 7, 22, "Magdalena" }, +{ 7, 23, "Olga" }, +{ 7, 24, "Vladimir" }, +{ 7, 25, "Jakub, Timur" }, +{ 7, 26, "Anna, Hana, Anita" }, +{ 7, 27, "Bozena" }, +{ 7, 28, "Kristof" }, +{ 7, 29, "Marta" }, +{ 7, 30, "Libusa" }, +{ 7, 31, "Ignac" }, +{ 8, 1, "Bozidara" }, +{ 8, 2, "Gustav" }, +{ 8, 3, "Jergus" }, +{ 8, 4, "Dominika, Dominik" }, +{ 8, 5, "Hortenzia" }, +{ 8, 6, "Jozefina" }, +{ 8, 7, "Stefania" }, +{ 8, 8, "Oskar" }, +{ 8, 9, "Lubomira" }, +{ 8, 10, "Vavrinec" }, +{ 8, 11, "Zuzana" }, +{ 8, 12, "Darina" }, +{ 8, 13, "Lubomir" }, +{ 8, 14, "Mojmir" }, +{ 8, 15, "Marcela" }, +{ 8, 16, "Leonard" }, +{ 8, 17, "Milica" }, +{ 8, 18, "Elena, Helena" }, +{ 8, 19, "Lydia" }, +{ 8, 20, "Anabela, Liliana" }, +{ 8, 21, "Jana" }, +{ 8, 22, "Tichomir" }, +{ 8, 23, "Filip" }, +{ 8, 24, "Bartolomej" }, +{ 8, 25, "Ludovit" }, +{ 8, 26, "Samuel" }, +{ 8, 27, "Silvia" }, +{ 8, 28, "Augustin" }, +{ 8, 29, "Nikola, Nikolaj" }, +{ 8, 30, "Ruzena" }, +{ 8, 31, "Nora" }, +{ 9, 1, "Drahoslava" }, +{ 9, 2, "Linda, Rebeka" }, +{ 9, 3, "Belo" }, +{ 9, 4, "Rozalia" }, +{ 9, 5, "Regina" }, +{ 9, 6, "Alica" }, +{ 9, 7, "Marianna" }, +{ 9, 8, "Miriama" }, +{ 9, 9, "Martina" }, +{ 9, 10, "Oleg" }, +{ 9, 11, "Bystrik" }, +{ 9, 12, "Maria, Marlena" }, +{ 9, 13, "Ctibor" }, +{ 9, 14, "Ludomil" }, +{ 9, 15, "Jolana" }, +{ 9, 16, "Ludmila" }, +{ 9, 17, "Olympia" }, +{ 9, 18, "Eugenia" }, +{ 9, 19, "Konstantin" }, +{ 9, 20, "Luboslav, Luboslava" }, +{ 9, 21, "Matus" }, +{ 9, 22, "Moric" }, +{ 9, 23, "Zdenka" }, +{ 9, 24, "Lubos, Lubor" }, +{ 9, 25, "Vladislav, Vladislava" }, +{ 9, 26, "Edita" }, +{ 9, 27, "Cyprian" }, +{ 9, 28, "Vaclav" }, +{ 9, 29, "Michal, Michaela" }, +{ 9, 30, "Jarolim" }, +{ 10, 1, "Arnold" }, +{ 10, 2, "Levoslav" }, +{ 10, 3, "Stela" }, +{ 10, 4, "Frantisek" }, +{ 10, 5, "Viera" }, +{ 10, 6, "Natalia" }, +{ 10, 7, "Eliska" }, +{ 10, 8, "Brigita" }, +{ 10, 9, "Dionyz" }, +{ 10, 10, "Slavomira" }, +{ 10, 11, "Valentina" }, +{ 10, 12, "Maximilian" }, +{ 10, 13, "Koloman" }, +{ 10, 14, "Boris" }, +{ 10, 15, "Terezia" }, +{ 10, 16, "Vladimira" }, +{ 10, 17, "Hedviga" }, +{ 10, 18, "Lukas" }, +{ 10, 19, "Kristian" }, +{ 10, 20, "Vendelin" }, +{ 10, 21, "Ursula" }, +{ 10, 22, "Sergej" }, +{ 10, 23, "Alojzia" }, +{ 10, 24, "Kvetoslava" }, +{ 10, 25, "Aurel" }, +{ 10, 26, "Demeter" }, +{ 10, 27, "Sabina" }, +{ 10, 28, "Dobromila" }, +{ 10, 29, "Klara" }, +{ 10, 30, "Simon, Simona" }, +{ 10, 31, "Aurelia" }, +{ 11, 1, "Denis, Denisa" }, +{ 11, 3, "Hubert" }, +{ 11, 4, "Karol" }, +{ 11, 5, "Imrich" }, +{ 11, 6, "Renata" }, +{ 11, 7, "Rene" }, +{ 11, 8, "Bohumir" }, +{ 11, 9, "Teodor" }, +{ 11, 10, "Tibor" }, +{ 11, 11, "Martin, Maros" }, +{ 11, 12, "Svatopluk" }, +{ 11, 13, "Stanislav" }, +{ 11, 14, "Irma" }, +{ 11, 15, "Leopold" }, +{ 11, 16, "Agnesa" }, +{ 11, 17, "Klaudia" }, +{ 11, 18, "Eugen" }, +{ 11, 19, "Alzbeta" }, +{ 11, 20, "Felix" }, +{ 11, 21, "Elvira" }, +{ 11, 22, "Cecilia" }, +{ 11, 23, "Klement" }, +{ 11, 24, "Emilia" }, +{ 11, 25, "Katarina" }, +{ 11, 26, "Kornel" }, +{ 11, 27, "Milan" }, +{ 11, 28, "Henrieta" }, +{ 11, 29, "Vratko" }, +{ 11, 30, "Ondrej, Andrej" }, +{ 12, 1, "Edmund" }, +{ 12, 2, "Bibiana" }, +{ 12, 3, "Oldrich" }, +{ 12, 4, "Barbora, Barbara" }, +{ 12, 5, "Oto" }, +{ 12, 6, "Mikulas" }, +{ 12, 7, "Ambroz" }, +{ 12, 8, "Marina" }, +{ 12, 9, "Izabela" }, +{ 12, 10, "Raduz" }, +{ 12, 11, "Hilda" }, +{ 12, 12, "Otilia" }, +{ 12, 13, "Lucia" }, +{ 12, 14, "Branislava, Bronislava" }, +{ 12, 15, "Ivica" }, +{ 12, 16, "Albina" }, +{ 12, 17, "Kornelia" }, +{ 12, 18, "Slava" }, +{ 12, 19, "Judita" }, +{ 12, 20, "Dagmara" }, +{ 12, 21, "Bohdan" }, +{ 12, 22, "Adela" }, +{ 12, 23, "Nadezda" }, +{ 12, 24, "Adam, Eva" }, +{ 12, 26, "Stefan" }, +{ 12, 27, "Filomena" }, +{ 12, 28, "Ivana, Ivona" }, +{ 12, 29, "Milada" }, +{ 12, 30, "David" }, +{ 12, 31, "Silvester" } +}; \ No newline at end of file diff --git a/src/data/index.html b/src/data/index.html new file mode 100644 index 0000000..1fd8afa --- /dev/null +++ b/src/data/index.html @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Budík

+
+
+
+ +
+ +
+
+ + + + +
+
+
+
+ + + + +
+
+ + +
+ +
+
+ + + \ No newline at end of file diff --git a/src/data/indexvujs.html b/src/data/indexvujs.html new file mode 100644 index 0000000..6992665 --- /dev/null +++ b/src/data/indexvujs.html @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Budík

+
+
+ + + + +
+
+ +
+ + + \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..5741069 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,197 @@ +#include +// change next line to use with another board/shield +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include "calendar.h" + +#ifndef PSTR + #define PSTR // Make Arduino Due happy +#endif + +#define COMMAND_PARAMETER_LENGTH 30 + +#define PIN 15 + +#include + +void handleRoot(); +void processCommand(); + +// -- Initial name of the Thing. Used e.g. as SSID of the own Access Point. +const char thingName[] = "BADThing"; +// -- Initial password to connect to the Thing, when it creates an own Access Point. +const char wifiInitialApPassword[] = "BADesp32"; + +DNSServer dnsServer; +WebServer server(80); +IotWebConf iotWebConf(thingName, &dnsServer, &server, wifiInitialApPassword); + + +enum Lines_names { TIME_LINE, DATE_LINE, WEATHER_LINE, NAMES_LINE, LAST_LINE }; +String Lines[LAST_LINE]; + +Adafruit_NeoMatrix *matrix; +const uint16_t colors[] = { + Adafruit_NeoMatrix::Color(255, 0, 0), Adafruit_NeoMatrix::Color(0, 255, 0), Adafruit_NeoMatrix::Color(0, 0, 255) }; + +WiFiUDP ntpUDP; + +// You can specify the time server pool and the offset (in seconds, can be +// changed later with setTimeOffset() ). Additionaly you can specify the +// update interval (in milliseconds, can be changed using setUpdateInterval() ). +NTPClient timeClient(ntpUDP, "europe.pool.ntp.org", 3600, 60000); +HTTPClient client; +DynamicJsonDocument doc(1024); + +String get_name_of_day(int m,int d) { + for (int i=0;i 0) { + + if(code == HTTP_CODE_OK) { + float temp; + String w; + String desc; + + String payload = client.getString(); + deserializeJson(doc, payload); + JsonObject obj = doc.as(); + temp = obj["main"]["temp"].as(); + w = obj["weather"][0]["main"].as(); + desc = obj["weather"][0]["description"].as(); + temp -= 273.15; + return String(temp) + String("C ") + desc; + } + } + + return "Error"; +} + +String get_time_line(){ + return String(DateTime.format("%H:%M")); +} + +String get_date_line(){ + return String(DateTime.format("%d.%m")); +} + +String get_names_line() { + int d = DateTime.getParts().getMonthDay(); + int m = DateTime.getParts().getMonth();m++; + return get_name_of_day(m,d); +} + +void setup_matrix() { + matrix = new Adafruit_NeoMatrix(32, 8, PIN, + NEO_MATRIX_BOTTOM + NEO_MATRIX_RIGHT + + NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG, + NEO_GBR + NEO_KHZ800); + + matrix->begin(); + matrix->setTextWrap(false); + matrix->setBrightness(1); + matrix->setTextColor(colors[1]); +} + +void setup(){ + Serial.begin(115200); + + //iotWebConf.setStatusPin(PIN); + iotWebConf.init(); + + // -- Set up required URL handlers on the web server. + server.on("/", handleRoot); + server.on("/config", []{ iotWebConf.handleConfig(); }); + server.onNotFound([](){ iotWebConf.handleNotFound(); }); + + setup_matrix(); + + +} + +void scroll_line(String line) { + int x = 0, mx = 32; + int y = 0; + + if (line.length() * 6 > mx) { + for (x = 0; x < line.length()*6 - mx; x++) { + matrix->fillScreen(0); + matrix->setCursor(-x, y); + matrix->setTextColor(colors[1]); + matrix->print(line); + matrix->show(); + if (x == 0) delay(300); + else delay(100); + } + delay(1000); + } else { + matrix->fillScreen(0); + matrix->setCursor(x, y); + matrix->setTextColor(colors[1]); + matrix->print(line); + matrix->show(); + delay(3000); + } +} + +void handleRoot() +{ + // -- Let IotWebConf test and handle captive portal requests. + if (iotWebConf.handleCaptivePortal()) + { + // -- Captive portal request were already served. + return; + } + String s = ""; + s += "IotWebConf 02 Status and ResetHello world!"; + s += "Go to configure page to change settings."; + s += "\n"; + + server.send(200, "text/html", s); +} + +void loop() { + unsigned long sec; + unsigned long n=0; + + // -- doLoop should be called as frequently as possible. + iotWebConf.doLoop(); + + if (WiFi.status() == WL_CONNECTED) { + timeClient.begin(); + timeClient.update(); + sec = timeClient.getEpochTime(); + DateTime.setTime(sec); + + if (n++ % 25 == 0) Lines[WEATHER_LINE] = get_weather_line(); + + Lines[TIME_LINE] = get_time_line(); + Lines[DATE_LINE] = get_date_line(); + Lines[NAMES_LINE] = get_names_line(); + + for (int i=0;i