cron library added
This commit is contained in:
parent
3fd9489c59
commit
4202b5348b
3
.gitmodules
vendored
3
.gitmodules
vendored
|
|
@ -7,3 +7,6 @@
|
|||
[submodule "components/webguiapp"]
|
||||
path = components/webguiapp
|
||||
url = https://gitlab.com/userbogd/webguiapp.git
|
||||
[submodule "components/esp_cron"]
|
||||
path = components/esp_cron
|
||||
url = https://github.com/userbogd/esp_cron.git
|
||||
|
|
|
|||
|
|
@ -11,14 +11,72 @@
|
|||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
const timarr_test = [{'num':1,'start':1675757575,'cron':'* * * * * *'},
|
||||
{'num':2,'start':1675757575,'cron':'* * * * * *'},
|
||||
{'num':3,'start':1675757575,'cron':'* * * * * *'},
|
||||
{'num':4,'start':1675757575,'cron':'* * * * * *'},
|
||||
{'num':5,'start':1675757575,'cron':'* * * * * *'}];
|
||||
function drawtimer(tarr)
|
||||
objects_test = ["scene_1","scene_2","scene_3","scene_4","scene_5","scene_6","scene_7","scene_8","scene_9","scene_10","scene_11","scene_12","scene_13","scene_14","scene_15","scene_16"];
|
||||
actions_test = ["start", "stop"];
|
||||
timarr_test = [{'num':1, 'obj':2, 'act':0, 'start':1000000000,'cron':'*/2 * * * * *'},
|
||||
{'num':2, 'obj':12,'act':1, 'start':1622222222,'cron':'6 0 12 * * *'},
|
||||
{'num':3, 'obj':8,'act':0, 'start':1675757575,'cron':'* * * * * *'}];
|
||||
function savetm(n)
|
||||
{
|
||||
var num =
|
||||
|
||||
}
|
||||
function deltm(n)
|
||||
{
|
||||
alert("Delete timer "+n);
|
||||
timarr_test.splice(n-1,1);
|
||||
drawtimers(timarr_test);
|
||||
}
|
||||
function setcron(n)
|
||||
{
|
||||
|
||||
}
|
||||
function drawtimers(tarr)
|
||||
{
|
||||
var num = tarr.length;
|
||||
var target = document.getElementById("timer");
|
||||
var content = "";
|
||||
for (i = 1; i<=num; i++)
|
||||
{
|
||||
content +=("<div class=\"timer\">");
|
||||
content +=("<label class=\"tmlab\">Timer "+i+"</label>");
|
||||
content +=("<div class=\"timerrec\">");
|
||||
|
||||
content +=("<div class=\"nowrap\">");
|
||||
//content +=("<label for=\"cron"+i+"\">Cron string:</label>");
|
||||
content +=("<input type=\"text\" id=\"cron"+i+"\" value=\""+tarr[i-1].cron+"\"></input>");
|
||||
content +=("<button class=\"tmbtn btn\" type=\"button\" onclick=\"setcron("+i+")\">Set cron</button></div></div>")
|
||||
|
||||
|
||||
content +=("<input class=\"tmpick\" type=\"datetime-local\" value=\""+UnixToStr(tarr[i-1].start,10,1)+"\"></input>");
|
||||
content +=("<select id=\"action\">");
|
||||
for (k = 0; k < actions_test.length; k++){
|
||||
var selected = (tarr[i-1].act == k)?"selected":"";
|
||||
content +=("<option value=\""+(k+1)+"\" "+selected+">"+actions_test[k]+"</option>");}
|
||||
content +=("</select>");
|
||||
|
||||
content +=("<select id=\"object\">");
|
||||
for (k = 0; k < objects_test.length; k++){
|
||||
var selected = (tarr[i-1].obj == k)?"selected":"";
|
||||
content +=("<option value=\""+(k+1)+"\" "+selected+">"+objects_test[k]+"</option>");}
|
||||
content +=("</select>");
|
||||
|
||||
|
||||
content +=("<button class=\"btn\" type=\"button\" onclick=\"savetm("+i+")\">Save</button>");
|
||||
content +=("<button class=\"btn\" type=\"button\" onclick=\"deltm("+i+")\">Delete</button>");
|
||||
|
||||
content +=("</div>");
|
||||
target.innerHTML = content;
|
||||
}
|
||||
}
|
||||
function applytm()
|
||||
{
|
||||
|
||||
}
|
||||
function addtm()
|
||||
{
|
||||
var num = timarr_test.length + 1;
|
||||
timarr_test.push({'num':num,'start':1500000000,'cron':'* * * * * *'});
|
||||
drawtimers(timarr_test);
|
||||
}
|
||||
</script>
|
||||
<script>PageSurround();</script>
|
||||
|
|
@ -26,21 +84,27 @@
|
|||
<main>
|
||||
<section>
|
||||
<div class="ml">
|
||||
<div class="mlp">
|
||||
<div class="mlpc">
|
||||
<form name="tmr" method="post">
|
||||
<div class="mlhdr">TIMER</div>
|
||||
|
||||
|
||||
<br />
|
||||
<script>PrintSaveFail('~status_fail~');
|
||||
PrintSaveBtn('tmr'); PrintApplyBtn('tmr');</script>
|
||||
|
||||
<div class="container">
|
||||
<div id="timer"></div>
|
||||
</div>
|
||||
|
||||
<button type="button" class ='btn' id='bt1' onclick="applytm()">Apply</button>
|
||||
<button type="button" class ='btn' id='bt2' onclick="addtm()">Add new timer</button>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
<script>
|
||||
showMenu('header-toggle','navbar');
|
||||
drawtimers(timarr_test);
|
||||
showMenu('header-toggle','navbar');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ api/stat.json
|
|||
api/status.json
|
||||
api/tmr.json
|
||||
api/wifiscan.json
|
||||
application.html
|
||||
favicon.ico
|
||||
index.html
|
||||
info.html
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ div label input {margin-right: 100px;}
|
|||
}
|
||||
input:checked + span{background-color: var(--navy-color);}
|
||||
|
||||
.channel{ widht:100%;
|
||||
.channel{ width:100%;
|
||||
display: flex;
|
||||
flex-wrap:no-wrap;
|
||||
margin:10px;
|
||||
|
|
@ -154,3 +154,59 @@ input:checked + .slider:before {
|
|||
border-radius: 50%;
|
||||
}
|
||||
|
||||
/*Timer styles*/
|
||||
.timer
|
||||
{
|
||||
width:100%;
|
||||
padding: 10px;
|
||||
margin:5px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.4);
|
||||
}
|
||||
|
||||
.timerrec {
|
||||
width:100%;
|
||||
display: flex;
|
||||
flex-wrap:wrap;
|
||||
}
|
||||
|
||||
.tmbtn{
|
||||
float:right;
|
||||
|
||||
}
|
||||
.tmlab{
|
||||
float:left;
|
||||
}
|
||||
|
||||
.nowrap
|
||||
{
|
||||
display: flex;
|
||||
flex-wrap:no-wrap;
|
||||
align-items: center;
|
||||
width:100%;
|
||||
}
|
||||
|
||||
/* The Modal (background) */
|
||||
.modal {
|
||||
display: none; /* Hidden by default */
|
||||
position: fixed; /* Stay in place */
|
||||
z-index: 1; /* Sit on top */
|
||||
padding-top: 100px; /* Location of the box */
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%; /* Full width */
|
||||
height: 100%; /* Full height */
|
||||
overflow: auto; /* Enable scroll if needed */
|
||||
background-color: rgb(0,0,0); /* Fallback color */
|
||||
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
|
||||
}
|
||||
|
||||
/* Modal Content */
|
||||
.modal-content {
|
||||
background-color: #fefefe;
|
||||
margin: auto;
|
||||
padding: 20px;
|
||||
border: 1px solid #888;
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,22 @@ var hedmen = `
|
|||
<div class="nav__list">
|
||||
<div class="nav__items">
|
||||
<h3 class="nav__subtitle">APPLICATION</h3>
|
||||
|
||||
<div class="nav__dropdown">
|
||||
<a href="#" class="nav__link">
|
||||
<i class='icon-chart-bar nav__icon'></i>
|
||||
<span class="nav__name">UTILITIES</span>
|
||||
<i class='icon-down-open nav__icon nav__dropdown-icon'></i>
|
||||
</a>
|
||||
|
||||
<div class="nav__dropdown-collapse">
|
||||
<div class="nav__dropdown-content">
|
||||
<a href="application.html" class="nav__dropdown-item">Utilities</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="nav__dropdown">
|
||||
<a href="#" class="nav__link">
|
||||
<i class='icon-wrench nav__icon'></i>
|
||||
|
|
|
|||
1
components/esp_cron
Submodule
1
components/esp_cron
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 6785ad092344b6c391fa24b0a0b25ffd258d79e6
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
dependencies:
|
||||
idf:
|
||||
component_hash: null
|
||||
source:
|
||||
type: idf
|
||||
version: 4.4.4
|
||||
manifest_hash: bac36ae84ced55f21212b58505f6d1d92af6f127b76119962963f68835e2e89f
|
||||
target: esp32
|
||||
version: 1.0.0
|
||||
dependencies:
|
||||
idf:
|
||||
component_hash: null
|
||||
source:
|
||||
type: idf
|
||||
version: 4.4.4
|
||||
manifest_hash: f9b3d78d7d56685d1c543701158a0fab7a56c908117ed70644f77e4247c831ae
|
||||
target: esp32
|
||||
version: 1.0.0
|
||||
|
|
|
|||
16
main/main.c
16
main/main.c
|
|
@ -2,7 +2,8 @@
|
|||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
#include "webguiapp.h"
|
||||
|
||||
#include "cron.h"
|
||||
#include "jobs.h"
|
||||
|
||||
int HTTPPrintCustom(httpd_req_t *req, char *buf, char *var, int arg);
|
||||
HTTP_IO_RESULT AfterPostHandlerCustom(httpd_req_t *req, const char *filename, char *PostData);
|
||||
|
|
@ -15,6 +16,19 @@ void app_main(void)
|
|||
regUserEventHandler(&UserMQTTEventHndlr);
|
||||
WebGuiAppInit();
|
||||
|
||||
void test_cron_job_sample_callback(cron_job *job)
|
||||
{
|
||||
//int N = *((int*)(job->data));
|
||||
int N = 0;
|
||||
//ESP_LOGW("MAIN", "Cron job executed with data %d", N);
|
||||
return;
|
||||
}
|
||||
|
||||
cron_job *jobs[2];
|
||||
//jobs[0]=cron_job_create("* * * * * *",test_cron_job_sample_callback,(void *)0);
|
||||
jobs[1] = cron_job_create("* * * * * *", test_cron_job_sample_callback, (void*) 10000);
|
||||
cron_start();
|
||||
|
||||
while (true)
|
||||
{
|
||||
sleep(1);
|
||||
|
|
|
|||
1569
sdkconfig.old
1569
sdkconfig.old
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user