Init commit

This commit is contained in:
2020-04-10 11:53:47 +02:00
commit 55b69b9a8d
12 changed files with 1053 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch

67
.travis.yml Normal file
View File

@@ -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

7
.vscode/extensions.json vendored Normal file
View File

@@ -0,0 +1,7 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
]
}

5
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,5 @@
{
"files.associations": {
"random": "cpp"
}
}

39
include/README Normal file
View File

@@ -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

46
lib/README Normal file
View File

@@ -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 <Foo.h>
#include <Bar.h>
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

16
platformio.ini Normal file
View File

@@ -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

368
src/calendar.h Normal file
View File

@@ -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" }
};

166
src/data/index.html Normal file
View File

@@ -0,0 +1,166 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- <link rel="stylesheet" type="text/css" href="css/bootstrap-datetimepicker.css"> -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.1/moment.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.43/css/bootstrap-datetimepicker.min.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.43/css/bootstrap-datetimepicker-standalone.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.43/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mustache.js/3.1.0/mustache.min.js"></script>
</head>
<body>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/3.1.4/js/bootstrap-datetimepicker.min.js" integrity="sha256-sU6nRhzXDAC31Wdrirz7X2A2rSRWj10WnP9CA3vpYKw=" crossorigin="anonymous"></script>
<div class="container">
<h1 align="center">Budík</h1>
<div class="row">
<div data-form-number=0 class='form-row'>
<div class="form-group col-sm-3">
<select data-form="type" class="form-control mr-sm-2" id="inlineFormCustomSelect">
<option value="0" selected>Pracovne dni</option>
<option value="1">Vikendy</option>
<option value="2">Zajtra</option>
<option value="3">Iba raz</option>
</select>
</div>
<div class="form-group col-sm-3">
<div class='input-group time' id='datetimepicker2'>
<input data-form="time" type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
</div>
</div>
<div class="form-group col-sm-3">
<div class='input-group time' id='datetimepicker3'>
<input data-form="date" type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
</div>
</div>
<div class="btn-toolbar col-sm-3" role="toolbar" aria-label="Toolbar with button groups">
<div class="btn-group mr-2" role="group" aria-label="First group">
<button data-button=1 type="button" class="btn btn-secondary glyphicon glyphicon-plus"></button>
<button data-button=2 type="button" class="btn btn-secondary glyphicon glyphicon-minus"></button>
<button data-button=3 type="button" class="btn btn-secondary glyphicon glyphicon-edit"></button>
<button data-button=4 type="button" class="btn btn-secondary glyphicon glyphicon-save"></button>
</div>
</div>
</div>
<script type="text/javascript">
var nf = 0;
var when = { 0 : "Pracovne dni",
1 : "Vikendy",
2 : "Zajtra",
3 : "Iba raz"
};
var when_rev = {};
function add_to_end(s) {
h = $('.btn-toolbar')[0].outerHTML;
$('.container')
.append('<div class="row"><div class="col-sm-3">'+ when[s.kedy] +'</div><div class="col-sm-3">'+ s.cas +'</div><div class="col-sm-3">'+ s.datum +'</div>' + h + '</div>');
}
function set_datepicker() {
$('#datetimepicker3').datetimepicker({
pickTime: false,
format: "D.M.YYYY"
});
$('#datetimepicker2').datetimepicker({
format : 'HH:mm',
pickDate: false
});
}
function set_click_handler() {
$('.glyphicon-plus').click(function() {
console.log('PLUS');
nf++;
form = $('*[data-form-number=0]').html();
html1 = "<div class='row'><div data-form-number=" + nf + " class='form-row'>" + form + "</div></div>";
$('.container').append(html1);
set_datepicker();
});
$('.glyphicon-minus').click(function(el) {
console.log('MINUS');
$(this.parentNode.parentNode.parentNode).remove();
});
$('.glyphicon-edit').click(function() {
console.log('EDIT');
data = $(this.parentNode.parentNode.parentNode);
type = data.children().html();
time = data.children().next().html();
date = data.children().next().next().html();
if (date == "null") date = "";
nf++;
form = $('*[data-form-number=0]').html();
html1 = "<div data-form-number=" + nf + " class='form-row'>" + form + "</div>";
$(this.parentNode.parentNode.parentNode).html(html1);
$('*[data-form-number='+ nf +']').find('*[data-form="type"]').val(when_rev[type]);
$('*[data-form-number='+ nf +']').find('*[data-form="time"]').val(time);
$('*[data-form-number='+ nf +']').find('*[data-form="date"]').val(date);
set_datepicker();
});
$('.glyphicon-save').click(function() {
console.log('SAVE');
forms = $(this.parentNode.parentNode.parentNode);
type = forms.find('*[data-form="type"]').val();
time = forms.find('*[data-form="time"]').val();
date = forms.find('*[data-form="date"]').val();
h = $('.btn-toolbar')[0].outerHTML;
forms.replaceWith('<div class="col-sm-3">'+ when[type] +'</div><div class="col-sm-3">'+ time +'</div><div class="col-sm-3">'+ date+'</div>' + h + '</div>');
});
}
for (var key in when) {
when_rev[when[key]] = key;
};
$(function () {
settings = [ { "kedy": 0 , "cas": "6:38", "datum": null}, { "kedy": 0 , "cas": "17:00", "datum": null} ];
settings.forEach(s => add_to_end(s));
set_datepicker();
set_click_handler();
$('.container').append('<button type="button" class="btn btn-dark">Nastav</button>');
$('.container > button').click(function() {
console.log('SET SETTINGS');
})
});
</script>
</div>
</div>
</body>
</html>

126
src/data/indexvujs.html Normal file
View File

@@ -0,0 +1,126 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- <link rel="stylesheet" type="text/css" href="css/bootstrap-datetimepicker.css"> -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.1/moment.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.43/css/bootstrap-datetimepicker.min.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.43/css/bootstrap-datetimepicker-standalone.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.43/js/bootstrap-datetimepicker.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue-bootstrap-datetimepicker@5"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<body>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.11"></script>
<div id="app" class="container">
<h1 align="center">Budík</h1>
<div v-for="(setting,index) in settings" :key="setting.kedy" class="row">
<div data-form-number=0 class='form-row'>
<template v-if="setting.edit === true">
<div class="form-group col-sm-3">
<select v-model="setting.kedy" class="form-control mr-sm-2" id="inlineFormCustomSelect">
<option v-for="(item, key, index) in w" v-bind:value="key" >{{ item }}</option>
</select>
</div>
<div class="form-group col-sm-3">
<div class='input-group time' id='datetimepicker2'>
<date-picker :config="{format: 'HH:mm'}" v-model="setting.cas" ></date-picker>
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
</div>
</div>
<div class="form-group col-sm-3">
<div class='input-group time' id='datetimepicker3'>
<date-picker v-model="setting.datum" :config="{format: 'D.M.YYYY'}" class="form-control"></date-picker>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</template>
<template v-else>
<div class="form-group col-sm-3">
{{ when[setting.kedy] }}
</div>
<div class="form-group col-sm-3">
{{ setting.cas }}
</div>
<div class="form-group col-sm-3">
{{ setting.datum }}
</div>
</template>
<div class="btn-toolbar col-sm-3" role="toolbar" aria-label="Toolbar with button groups">
<div class="btn-group mr-2" role="group" aria-label="First group">
<button v-on:click="changePlus(index)" type="button" class="btn btn-secondary glyphicon glyphicon-plus"></button>
<button v-on:click="changeMinus(index)" type="button" class="btn btn-secondary glyphicon glyphicon-minus"></button>
<button v-on:click="changeEdit(index)" type="button" class="btn btn-secondary glyphicon glyphicon-edit"></button>
<button v-on:click="changeSave(index)" type="button" class="btn btn-secondary glyphicon glyphicon-save"></button>
</div>
</div>
</div>
</div>
<button v-on:click="postChanges" type="button" class="btn btn-primary btn-lg">Ulož</button>
</div>
<script type="text/javascript">
$(function () {
settings = [ { "kedy": 0 , "cas": "6:38", "datum": null, "edit": true}, { "kedy": 0 , "cas": "17:00", "datum": null, "edit":false} ];
when = { 0 : "Pracovne dni",
1 : "Vikendy",
2 : "Zajtra",
3 : "Iba raz"
};
Vue.component('date-picker', VueBootstrapDatetimePicker);
var app = new Vue({
el: '#app',
data: {
settings: settings,
w: when,
cas: null
},
methods: {
changePlus: function (index) {
this.settings.push({ "kedy": 0, "cas": "", "datum":"", "edit": true});
},
changeMinus: function(index) {
this.settings.splice(index,1);
},
changeEdit: function (index) {
this.settings[index].edit = true;
},
changeSave: function (index) {
this.settings[index].edit = false;
},
postChanges: function () {
console.log("SAVE CHANGES TO ESP");
axios.get('https://api.coindesk.com/v1/bpi/currentprice.json')
.then(response => (console.log(response)));
}
}
})
});
</script>
</body>
</html>

197
src/main.cpp Normal file
View File

@@ -0,0 +1,197 @@
#include <NTPClient.h>
// change next line to use with another board/shield
#include <WiFi.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#include <WiFiMulti.h>
#include <HTTPClient.h>
#include <ArduinoJson.h>
#include <DateTime.h>
#include <IotWebConf.h>
#include "calendar.h"
#ifndef PSTR
#define PSTR // Make Arduino Due happy
#endif
#define COMMAND_PARAMETER_LENGTH 30
#define PIN 15
#include <WiFiUdp.h>
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<sizeof(cal_names)/sizeof(cal_names[0]); i++) {
if (cal_names[i].m == m && cal_names[i].d ==d)
return String(cal_names[i].name);
}
return String("Sviatok");
}
String get_weather_line()
{
client.begin("http://api.openweathermap.org/data/2.5/weather?q=Trnava,sk&lang=sk&APPID=d15c61931a053026e98769dd9fc46ba3");
int code = client.GET();
if (code > 0) {
if(code == HTTP_CODE_OK) {
float temp;
String w;
String desc;
String payload = client.getString();
deserializeJson(doc, payload);
JsonObject obj = doc.as<JsonObject>();
temp = obj["main"]["temp"].as<float>();
w = obj["weather"][0]["main"].as<String>();
desc = obj["weather"][0]["description"].as<String>();
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 = "<!DOCTYPE html><html lang=\"en\"><head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\"/>";
s += "<title>IotWebConf 02 Status and Reset</title></head><body>Hello world!";
s += "Go to <a href='config'>configure page</a> to change settings.";
s += "</body></html>\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<LAST_LINE;i++) {
Serial.println(Lines[i]);
scroll_line(Lines[i]);
}
}
}

11
test/README Normal file
View File

@@ -0,0 +1,11 @@
This directory is intended for PIO Unit Testing and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PIO Unit Testing:
- https://docs.platformio.org/page/plus/unit-testing.html