Add cron_next

This commit is contained in:
Stephan Hadinger 2022-02-21 22:40:00 +01:00
parent e83e501155
commit e2d34985fe
5 changed files with 1224 additions and 1161 deletions

View File

@ -582,6 +582,7 @@ extern const bcstring be_const_str_montserrat_font;
extern const bcstring be_const_str_name;
extern const bcstring be_const_str_nan;
extern const bcstring be_const_str_next;
extern const bcstring be_const_str_next_cron;
extern const bcstring be_const_str_nil;
extern const bcstring be_const_str_no_X20GPIO_X20specified_X20for_X20neopixelbus;
extern const bcstring be_const_str_null_cb;

File diff suppressed because it is too large Load Diff

View File

@ -1,96 +1,97 @@
#include "be_constobj.h"
static be_define_const_map_slots(be_class_tasmota_map) {
{ be_const_key(try_rule, -1), be_const_closure(Tasmota_try_rule_closure) },
{ be_const_key(find_op, -1), be_const_closure(Tasmota_find_op_closure) },
{ be_const_key(cmd_res, -1), be_const_var(0) },
{ be_const_key(set_timer, 80), be_const_closure(Tasmota_set_timer_closure) },
{ be_const_key(strptime, 81), be_const_func(l_strptime) },
{ be_const_key(wire_scan, -1), be_const_closure(Tasmota_wire_scan_closure) },
{ be_const_key(eth, 35), be_const_func(l_eth) },
{ be_const_key(remove_cmd, 52), be_const_closure(Tasmota_remove_cmd_closure) },
{ be_const_key(set_power, -1), be_const_func(l_setpower) },
{ be_const_key(check_not_method, -1), be_const_closure(Tasmota_check_not_method_closure) },
{ be_const_key(run_cron, -1), be_const_closure(Tasmota_run_cron_closure) },
{ be_const_key(add_driver, -1), be_const_closure(Tasmota_add_driver_closure) },
{ be_const_key(chars_in_string, -1), be_const_closure(Tasmota_chars_in_string_closure) },
{ be_const_key(global, -1), be_const_var(1) },
{ be_const_key(web_send_decimal, -1), be_const_func(l_webSendDecimal) },
{ be_const_key(memory, 25), be_const_func(l_memory) },
{ be_const_key(time_str, 73), be_const_closure(Tasmota_time_str_closure) },
{ be_const_key(get_option, -1), be_const_func(l_getoption) },
{ be_const_key(wd, 17), be_const_var(2) },
{ be_const_key(_crons, 59), be_const_var(3) },
{ be_const_key(load, 58), be_const_closure(Tasmota_load_closure) },
{ be_const_key(add_cron, 29), be_const_closure(Tasmota_add_cron_closure) },
{ be_const_key(resp_cmnd_failed, -1), be_const_func(l_respCmndFailed) },
{ be_const_key(add_cmd, 20), be_const_closure(Tasmota_add_cmd_closure) },
{ be_const_key(exec_cmd, -1), be_const_closure(Tasmota_exec_cmd_closure) },
{ be_const_key(init, -1), be_const_closure(Tasmota_init_closure) },
{ be_const_key(add_fast_loop, 43), be_const_closure(Tasmota_add_fast_loop_closure) },
{ be_const_key(publish_result, -1), be_const_func(l_publish_result) },
{ be_const_key(wire2, -1), be_const_var(4) },
{ be_const_key(_settings_ptr, -1), be_const_comptr(&Settings) },
{ be_const_key(resp_cmnd_str, -1), be_const_func(l_respCmndStr) },
{ be_const_key(_global_def, 32), be_const_comptr(&be_tasmota_global_struct) },
{ be_const_key(exec_tele, 42), be_const_closure(Tasmota_exec_tele_closure) },
{ be_const_key(resp_cmnd_error, 75), be_const_func(l_respCmndError) },
{ be_const_key(cmd, -1), be_const_closure(Tasmota_cmd_closure) },
{ be_const_key(rtc, 4), be_const_func(l_rtc) },
{ be_const_key(gc, -1), be_const_closure(Tasmota_gc_closure) },
{ be_const_key(get_power, -1), be_const_func(l_getpower) },
{ be_const_key(log, -1), be_const_func(l_logInfo) },
{ be_const_key(scale_uint, 13), be_const_func(l_scaleuint) },
{ be_const_key(_rules, -1), be_const_var(5) },
{ be_const_key(_global_addr, -1), be_const_comptr(&TasmotaGlobal) },
{ be_const_key(strftime, -1), be_const_func(l_strftime) },
{ be_const_key(run_deferred, -1), be_const_closure(Tasmota_run_deferred_closure) },
{ be_const_key(web_send, -1), be_const_func(l_webSend) },
{ be_const_key(remove_timer, -1), be_const_closure(Tasmota_remove_timer_closure) },
{ be_const_key(find_key_i, 6), be_const_closure(Tasmota_find_key_i_closure) },
{ be_const_key(_settings_def, -1), be_const_comptr(&be_tasmota_settings_struct) },
{ be_const_key(fast_loop, 54), be_const_closure(Tasmota_fast_loop_closure) },
{ be_const_key(wire1, 23), be_const_var(6) },
{ be_const_key(_drivers, -1), be_const_var(7) },
{ be_const_key(response_append, 38), be_const_func(l_respAppend) },
{ be_const_key(exec_rules, 16), be_const_closure(Tasmota_exec_rules_closure) },
{ be_const_key(_ccmd, -1), be_const_var(8) },
{ be_const_key(get_free_heap, -1), be_const_func(l_getFreeHeap) },
{ be_const_key(resp_cmnd_done, -1), be_const_func(l_respCmndDone) },
{ be_const_key(gen_cb, -1), be_const_closure(Tasmota_gen_cb_closure) },
{ be_const_key(_cmd, 65), be_const_func(l_cmd) },
{ be_const_key(wifi, -1), be_const_func(l_wifi) },
{ be_const_key(hs2rgb, -1), be_const_closure(Tasmota_hs2rgb_closure) },
{ be_const_key(resolvecmnd, -1), be_const_func(l_resolveCmnd) },
{ be_const_key(get_light, -1), be_const_closure(Tasmota_get_light_closure) },
{ be_const_key(save, 21), be_const_func(l_save) },
{ be_const_key(remove_rule, 44), be_const_closure(Tasmota_remove_rule_closure) },
{ be_const_key(delay, -1), be_const_func(l_delay) },
{ be_const_key(remove_cron, -1), be_const_closure(Tasmota_remove_cron_closure) },
{ be_const_key(i2c_enabled, -1), be_const_func(l_i2cenabled) },
{ be_const_key(set_light, -1), be_const_closure(Tasmota_set_light_closure) },
{ be_const_key(time_reached, -1), be_const_func(l_timereached) },
{ be_const_key(publish, -1), be_const_func(l_publish) },
{ be_const_key(_debug_present, -1), be_const_var(9) },
{ be_const_key(settings, -1), be_const_var(10) },
{ be_const_key(kv, 48), be_const_closure(Tasmota_kv_closure) },
{ be_const_key(arch, 9), be_const_func(l_arch) },
{ be_const_key(event, -1), be_const_closure(Tasmota_event_closure) },
{ be_const_key(add_rule, -1), be_const_closure(Tasmota_add_rule_closure) },
{ be_const_key(read_sensors, -1), be_const_func(l_read_sensors) },
{ be_const_key(web_send, 33), be_const_func(l_webSend) },
{ be_const_key(add_driver, 21), be_const_closure(Tasmota_add_driver_closure) },
{ be_const_key(wd, 16), be_const_var(0) },
{ be_const_key(resp_cmnd_error, 25), be_const_func(l_respCmndError) },
{ be_const_key(publish, 71), be_const_func(l_publish) },
{ be_const_key(gen_cb, 0), be_const_closure(Tasmota_gen_cb_closure) },
{ be_const_key(_settings_ptr, -1), be_const_comptr(&Settings) },
{ be_const_key(try_rule, -1), be_const_closure(Tasmota_try_rule_closure) },
{ be_const_key(set_timer, -1), be_const_closure(Tasmota_set_timer_closure) },
{ be_const_key(time_dump, -1), be_const_func(l_time_dump) },
{ be_const_key(millis, 3), be_const_func(l_millis) },
{ be_const_key(yield, -1), be_const_func(l_yield) },
{ be_const_key(remove_driver, 84), be_const_closure(Tasmota_remove_driver_closure) },
{ be_const_key(_timers, 83), be_const_var(11) },
{ be_const_key(_fl, 12), be_const_var(12) },
{ be_const_key(cmd_res, -1), be_const_var(1) },
{ be_const_key(millis, 35), be_const_func(l_millis) },
{ be_const_key(chars_in_string, 82), be_const_closure(Tasmota_chars_in_string_closure) },
{ be_const_key(get_power, -1), be_const_func(l_getpower) },
{ be_const_key(set_light, 40), be_const_closure(Tasmota_set_light_closure) },
{ be_const_key(set_power, -1), be_const_func(l_setpower) },
{ be_const_key(fast_loop, -1), be_const_closure(Tasmota_fast_loop_closure) },
{ be_const_key(get_option, -1), be_const_func(l_getoption) },
{ be_const_key(add_cron, -1), be_const_closure(Tasmota_add_cron_closure) },
{ be_const_key(_settings_def, -1), be_const_comptr(&be_tasmota_settings_struct) },
{ be_const_key(init, 41), be_const_closure(Tasmota_init_closure) },
{ be_const_key(add_rule, 19), be_const_closure(Tasmota_add_rule_closure) },
{ be_const_key(resp_cmnd_failed, -1), be_const_func(l_respCmndFailed) },
{ be_const_key(exec_tele, -1), be_const_closure(Tasmota_exec_tele_closure) },
{ be_const_key(add_fast_loop, -1), be_const_closure(Tasmota_add_fast_loop_closure) },
{ be_const_key(_global_def, -1), be_const_comptr(&be_tasmota_global_struct) },
{ be_const_key(yield, 73), be_const_func(l_yield) },
{ be_const_key(next_cron, -1), be_const_closure(Tasmota_next_cron_closure) },
{ be_const_key(web_send_decimal, -1), be_const_func(l_webSendDecimal) },
{ be_const_key(time_reached, 11), be_const_func(l_timereached) },
{ be_const_key(delay, -1), be_const_func(l_delay) },
{ be_const_key(rtc, -1), be_const_func(l_rtc) },
{ be_const_key(wire2, -1), be_const_var(2) },
{ be_const_key(add_cmd, 75), be_const_closure(Tasmota_add_cmd_closure) },
{ be_const_key(exec_rules, 12), be_const_closure(Tasmota_exec_rules_closure) },
{ be_const_key(strptime, 74), be_const_func(l_strptime) },
{ be_const_key(wire_scan, -1), be_const_closure(Tasmota_wire_scan_closure) },
{ be_const_key(run_cron, 10), be_const_closure(Tasmota_run_cron_closure) },
{ be_const_key(get_light, 46), be_const_closure(Tasmota_get_light_closure) },
{ be_const_key(cmd, -1), be_const_closure(Tasmota_cmd_closure) },
{ be_const_key(remove_cmd, -1), be_const_closure(Tasmota_remove_cmd_closure) },
{ be_const_key(resp_cmnd_str, -1), be_const_func(l_respCmndStr) },
{ be_const_key(_fl, -1), be_const_var(3) },
{ be_const_key(i2c_enabled, -1), be_const_func(l_i2cenabled) },
{ be_const_key(global, -1), be_const_var(4) },
{ be_const_key(_debug_present, 39), be_const_var(5) },
{ be_const_key(run_deferred, 18), be_const_closure(Tasmota_run_deferred_closure) },
{ be_const_key(load, -1), be_const_closure(Tasmota_load_closure) },
{ be_const_key(get_switch, 56), be_const_func(l_getswitch) },
{ be_const_key(_ccmd, -1), be_const_var(6) },
{ be_const_key(kv, 14), be_const_closure(Tasmota_kv_closure) },
{ be_const_key(event, 22), be_const_closure(Tasmota_event_closure) },
{ be_const_key(get_free_heap, -1), be_const_func(l_getFreeHeap) },
{ be_const_key(_rules, 20), be_const_var(7) },
{ be_const_key(_timers, -1), be_const_var(8) },
{ be_const_key(remove_timer, 5), be_const_closure(Tasmota_remove_timer_closure) },
{ be_const_key(eth, -1), be_const_func(l_eth) },
{ be_const_key(arch, 65), be_const_func(l_arch) },
{ be_const_key(remove_driver, -1), be_const_closure(Tasmota_remove_driver_closure) },
{ be_const_key(response_append, -1), be_const_func(l_respAppend) },
{ be_const_key(wifi, -1), be_const_func(l_wifi) },
{ be_const_key(log, -1), be_const_func(l_logInfo) },
{ be_const_key(find_op, 78), be_const_closure(Tasmota_find_op_closure) },
{ be_const_key(hs2rgb, -1), be_const_closure(Tasmota_hs2rgb_closure) },
{ be_const_key(find_key_i, -1), be_const_closure(Tasmota_find_key_i_closure) },
{ be_const_key(_global_addr, -1), be_const_comptr(&TasmotaGlobal) },
{ be_const_key(save, -1), be_const_func(l_save) },
{ be_const_key(exec_cmd, 37), be_const_closure(Tasmota_exec_cmd_closure) },
{ be_const_key(remove_rule, -1), be_const_closure(Tasmota_remove_rule_closure) },
{ be_const_key(publish_result, -1), be_const_func(l_publish_result) },
{ be_const_key(settings, -1), be_const_var(9) },
{ be_const_key(time_str, -1), be_const_closure(Tasmota_time_str_closure) },
{ be_const_key(wire1, -1), be_const_var(10) },
{ be_const_key(_drivers, -1), be_const_var(11) },
{ be_const_key(scale_uint, 43), be_const_func(l_scaleuint) },
{ be_const_key(strftime, 9), be_const_func(l_strftime) },
{ be_const_key(_cmd, -1), be_const_func(l_cmd) },
{ be_const_key(check_not_method, -1), be_const_closure(Tasmota_check_not_method_closure) },
{ be_const_key(remove_cron, -1), be_const_closure(Tasmota_remove_cron_closure) },
{ be_const_key(resolvecmnd, 51), be_const_func(l_resolveCmnd) },
{ be_const_key(resp_cmnd, -1), be_const_func(l_respCmnd) },
{ be_const_key(get_switch, -1), be_const_func(l_getswitch) },
{ be_const_key(_crons, 63), be_const_var(12) },
{ be_const_key(memory, -1), be_const_func(l_memory) },
{ be_const_key(read_sensors, 54), be_const_func(l_read_sensors) },
};
static be_define_const_map(
be_class_tasmota_map,
85
86
);
BE_EXPORT_VARIABLE be_define_const_class(

View File

@ -2131,6 +2131,51 @@ be_local_closure(Tasmota_run_cron, /* name */
/*******************************************************************/
/********************************************************************
** Solidified function: next_cron
********************************************************************/
be_local_closure(Tasmota_next_cron, /* name */
be_nested_proto(
6, /* nstack */
2, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 5]) { /* constants */
/* K0 */ be_nested_str(_crons),
/* K1 */ be_const_int(0),
/* K2 */ be_nested_str(size),
/* K3 */ be_nested_str(id),
/* K4 */ be_nested_str(trig),
}),
&be_const_str_next_cron,
&be_const_str_solidified,
( &(const binstruction[16]) { /* code */
0x88080100, // 0000 GETMBR R2 R0 K0
0x780A000C, // 0001 JMPF R2 #000F
0x580C0001, // 0002 LDCONST R3 K1
0x8C100502, // 0003 GETMET R4 R2 K2
0x7C100200, // 0004 CALL R4 1
0x14100604, // 0005 LT R4 R3 R4
0x78120007, // 0006 JMPF R4 #000F
0x94100403, // 0007 GETIDX R4 R2 R3
0x88100903, // 0008 GETMBR R4 R4 K3
0x1C100801, // 0009 EQ R4 R4 R1
0x78120002, // 000A JMPF R4 #000E
0x94100403, // 000B GETIDX R4 R2 R3
0x88100904, // 000C GETMBR R4 R4 K4
0x80040800, // 000D RET 1 R4
0x7001FFF3, // 000E JMP #0003
0x80000000, // 000F RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: remove_cron
********************************************************************/
@ -2423,6 +2468,7 @@ class be_class_tasmota (scope: global, name: Tasmota) {
add_cron, closure(Tasmota_add_cron_closure)
run_cron, closure(Tasmota_run_cron_closure)
next_cron, closure(Tasmota_next_cron_closure)
remove_cron, closure(Tasmota_remove_cron_closure)
check_not_method, closure(Tasmota_check_not_method_closure)

View File

@ -330,6 +330,19 @@ class Tasmota
end
end
# get next timestamp for cron
def next_cron(id)
var crons = self._crons
if crons
var i=0
while i < crons.size()
if crons[i].id == id
return crons[i].trig
end
end
end
end
# Add command to list
def add_cmd(c,f)
self.check_not_method(f)