From d5ed1abf070a497e8b2e32415bdf21beb3723874 Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Sun, 10 Jul 2022 19:34:04 +0200 Subject: [PATCH] Berry add tasmota.remove_fast_loop() --- lib/libesp32/berry/generate/be_const_strtab.h | 1 + .../berry/generate/be_const_strtab_def.h | 5 +- .../generate/be_fixed_be_class_tasmota.h | 169 +++++++++--------- .../berry_tasmota/src/be_tasmota_lib.c | 42 +++++ .../berry_tasmota/src/embedded/Tasmota.be | 8 + 5 files changed, 139 insertions(+), 86 deletions(-) diff --git a/lib/libesp32/berry/generate/be_const_strtab.h b/lib/libesp32/berry/generate/be_const_strtab.h index 27596f14b..ebb7ae44e 100644 --- a/lib/libesp32/berry/generate/be_const_strtab.h +++ b/lib/libesp32/berry/generate/be_const_strtab.h @@ -673,6 +673,7 @@ extern const bcstring be_const_str_remove; extern const bcstring be_const_str_remove_cmd; extern const bcstring be_const_str_remove_cron; extern const bcstring be_const_str_remove_driver; +extern const bcstring be_const_str_remove_fast_loop; extern const bcstring be_const_str_remove_light; extern const bcstring be_const_str_remove_rule; extern const bcstring be_const_str_remove_timer; diff --git a/lib/libesp32/berry/generate/be_const_strtab_def.h b/lib/libesp32/berry/generate/be_const_strtab_def.h index 1122a3681..1ac8d0010 100644 --- a/lib/libesp32/berry/generate/be_const_strtab_def.h +++ b/lib/libesp32/berry/generate/be_const_strtab_def.h @@ -344,7 +344,7 @@ be_define_const_str(create_matrix, "create_matrix", 3528185923u, 0, 13, &be_cons be_define_const_str(create_segment, "create_segment", 3863522719u, 0, 14, NULL); be_define_const_str(ct, "ct", 1261010898u, 0, 2, &be_const_str_has_factory); be_define_const_str(ctor, "ctor", 375399343u, 0, 4, &be_const_str_math); -be_define_const_str(ctypes_bytes, "ctypes_bytes", 3879019703u, 0, 12, NULL); +be_define_const_str(ctypes_bytes, "ctypes_bytes", 3879019703u, 0, 12, &be_const_str_remove_fast_loop); be_define_const_str(ctypes_bytes_dyn, "ctypes_bytes_dyn", 915205307u, 0, 16, &be_const_str_energy_struct); be_define_const_str(dac_voltage, "dac_voltage", 1552257222u, 0, 11, &be_const_str_reverse_gamma10); be_define_const_str(data, "data", 3631407781u, 0, 4, &be_const_str_display); @@ -665,6 +665,7 @@ be_define_const_str(remove, "remove", 3683784189u, 0, 6, NULL); be_define_const_str(remove_cmd, "remove_cmd", 3832315702u, 0, 10, NULL); be_define_const_str(remove_cron, "remove_cron", 2914538962u, 0, 11, NULL); be_define_const_str(remove_driver, "remove_driver", 1030243768u, 0, 13, &be_const_str_settings); +be_define_const_str(remove_fast_loop, "remove_fast_loop", 3811152503u, 0, 16, NULL); be_define_const_str(remove_light, "remove_light", 1783624394u, 0, 12, &be_const_str_run); be_define_const_str(remove_rule, "remove_rule", 3456211328u, 0, 11, NULL); be_define_const_str(remove_timer, "remove_timer", 4141472215u, 0, 12, NULL); @@ -1896,6 +1897,6 @@ static const bstring* const m_string_table[] = { static const struct bconststrtab m_const_string_table = { .size = 432, - .count = 887, + .count = 888, .table = m_string_table }; diff --git a/lib/libesp32/berry/generate/be_fixed_be_class_tasmota.h b/lib/libesp32/berry/generate/be_fixed_be_class_tasmota.h index e3f76732d..bd54c6149 100644 --- a/lib/libesp32/berry/generate/be_fixed_be_class_tasmota.h +++ b/lib/libesp32/berry/generate/be_fixed_be_class_tasmota.h @@ -1,98 +1,99 @@ #include "be_constobj.h" static be_define_const_map_slots(be_class_tasmota_map) { + { be_const_key(run_deferred, -1), be_const_closure(Tasmota_run_deferred_closure) }, + { be_const_key(_drivers, 42), be_const_var(0) }, { be_const_key(gc, -1), be_const_closure(Tasmota_gc_closure) }, - { be_const_key(gen_cb, -1), be_const_closure(Tasmota_gen_cb_closure) }, - { be_const_key(yield, 20), be_const_func(l_yield) }, - { be_const_key(log, 21), be_const_func(l_logInfo) }, - { be_const_key(find_op, -1), be_const_closure(Tasmota_find_op_closure) }, - { be_const_key(i2c_enabled, -1), be_const_func(l_i2cenabled) }, - { be_const_key(response_append, -1), be_const_func(l_respAppend) }, - { be_const_key(web_send, -1), be_const_func(l_webSend) }, - { be_const_key(hs2rgb, -1), be_const_closure(Tasmota_hs2rgb_closure) }, - { be_const_key(resolvecmnd, 1), be_const_func(l_resolveCmnd) }, - { be_const_key(load, -1), be_const_closure(Tasmota_load_closure) }, - { be_const_key(_fl, -1), be_const_var(0) }, - { be_const_key(get_power, -1), be_const_func(l_getpower) }, - { be_const_key(add_rule, 32), be_const_closure(Tasmota_add_rule_closure) }, - { be_const_key(eth, 30), be_const_func(l_eth) }, - { be_const_key(time_dump, -1), be_const_func(l_time_dump) }, - { be_const_key(exec_rules, -1), be_const_closure(Tasmota_exec_rules_closure) }, - { be_const_key(chars_in_string, -1), be_const_closure(Tasmota_chars_in_string_closure) }, - { be_const_key(cmd, -1), be_const_closure(Tasmota_cmd_closure) }, - { be_const_key(_rules, -1), be_const_var(1) }, - { be_const_key(exec_tele, -1), be_const_closure(Tasmota_exec_tele_closure) }, - { be_const_key(get_option, -1), be_const_func(l_getoption) }, - { be_const_key(get_switches, 46), be_const_func(l_getswitch) }, - { be_const_key(global, -1), be_const_var(2) }, - { be_const_key(arch, -1), be_const_func(l_arch) }, - { be_const_key(wire1, -1), be_const_var(3) }, - { be_const_key(scale_uint, 15), be_const_func(l_scaleuint) }, - { be_const_key(millis, 8), be_const_func(l_millis) }, - { be_const_key(resp_cmnd_error, 64), be_const_func(l_respCmndError) }, - { be_const_key(publish, -1), be_const_func(l_publish) }, - { be_const_key(_settings_def, 75), be_const_comptr(&be_tasmota_settings_struct) }, - { be_const_key(init, -1), be_const_closure(Tasmota_init_closure) }, - { be_const_key(_settings_ptr, -1), be_const_comptr(&Settings) }, - { be_const_key(publish_rule, 57), be_const_func(l_publish_rule) }, - { be_const_key(remove_driver, 49), be_const_closure(Tasmota_remove_driver_closure) }, - { be_const_key(run_deferred, 25), be_const_closure(Tasmota_run_deferred_closure) }, - { be_const_key(read_sensors, 82), be_const_func(l_read_sensors) }, - { be_const_key(_timers, -1), be_const_var(4) }, - { be_const_key(set_light, -1), be_const_closure(Tasmota_set_light_closure) }, - { be_const_key(memory, 31), be_const_func(l_memory) }, - { be_const_key(wire_scan, -1), be_const_closure(Tasmota_wire_scan_closure) }, - { be_const_key(get_light, -1), be_const_closure(Tasmota_get_light_closure) }, - { be_const_key(_cmd, 76), be_const_func(l_cmd) }, - { be_const_key(exec_cmd, -1), be_const_closure(Tasmota_exec_cmd_closure) }, - { be_const_key(find_key_i, -1), be_const_closure(Tasmota_find_key_i_closure) }, - { be_const_key(wifi, -1), be_const_func(l_wifi) }, - { be_const_key(rtc, -1), be_const_func(l_rtc) }, - { be_const_key(time_str, -1), be_const_closure(Tasmota_time_str_closure) }, - { be_const_key(resp_cmnd, 17), be_const_func(l_respCmnd) }, - { be_const_key(add_cmd, -1), be_const_closure(Tasmota_add_cmd_closure) }, - { be_const_key(get_switch, -1), be_const_func(l_getswitch) }, - { be_const_key(save, -1), be_const_func(l_save) }, - { be_const_key(wire2, -1), be_const_var(5) }, - { be_const_key(run_cron, 0), be_const_closure(Tasmota_run_cron_closure) }, - { be_const_key(delay, -1), be_const_func(l_delay) }, - { be_const_key(set_timer, -1), be_const_closure(Tasmota_set_timer_closure) }, - { be_const_key(time_reached, -1), be_const_func(l_timereached) }, - { be_const_key(set_power, -1), be_const_func(l_setpower) }, - { be_const_key(_global_addr, -1), be_const_comptr(&TasmotaGlobal) }, - { be_const_key(_ccmd, -1), be_const_var(6) }, - { be_const_key(next_cron, 16), be_const_closure(Tasmota_next_cron_closure) }, - { be_const_key(cmd_res, -1), be_const_var(7) }, - { be_const_key(strftime, 80), be_const_func(l_strftime) }, - { be_const_key(event, -1), be_const_closure(Tasmota_event_closure) }, - { be_const_key(settings, -1), be_const_var(8) }, - { be_const_key(strptime, -1), be_const_func(l_strptime) }, - { be_const_key(resp_cmnd_done, 51), be_const_func(l_respCmndDone) }, + { be_const_key(strftime, -1), be_const_func(l_strftime) }, + { be_const_key(web_send_decimal, 49), be_const_func(l_webSendDecimal) }, + { be_const_key(yield, -1), be_const_func(l_yield) }, { be_const_key(remove_cmd, -1), be_const_closure(Tasmota_remove_cmd_closure) }, - { be_const_key(try_rule, -1), be_const_closure(Tasmota_try_rule_closure) }, - { be_const_key(resp_cmnd_str, 59), be_const_func(l_respCmndStr) }, - { be_const_key(_drivers, -1), be_const_var(9) }, - { be_const_key(_crons, 56), be_const_var(10) }, - { be_const_key(check_not_method, 62), be_const_closure(Tasmota_check_not_method_closure) }, - { be_const_key(remove_cron, 65), be_const_closure(Tasmota_remove_cron_closure) }, - { be_const_key(get_free_heap, -1), be_const_func(l_getFreeHeap) }, - { be_const_key(remove_timer, -1), be_const_closure(Tasmota_remove_timer_closure) }, - { be_const_key(resp_cmnd_failed, -1), be_const_func(l_respCmndFailed) }, - { be_const_key(add_driver, -1), be_const_closure(Tasmota_add_driver_closure) }, - { be_const_key(_debug_present, -1), be_const_var(11) }, - { be_const_key(wd, 14), be_const_var(12) }, - { be_const_key(_global_def, -1), be_const_comptr(&be_tasmota_global_struct) }, - { be_const_key(web_send_decimal, -1), be_const_func(l_webSendDecimal) }, - { be_const_key(publish_result, -1), be_const_func(l_publish_result) }, + { be_const_key(add_rule, -1), be_const_closure(Tasmota_add_rule_closure) }, + { be_const_key(find_op, 50), be_const_closure(Tasmota_find_op_closure) }, + { be_const_key(try_rule, 68), be_const_closure(Tasmota_try_rule_closure) }, + { be_const_key(cmd_res, -1), be_const_var(1) }, + { be_const_key(eth, -1), be_const_func(l_eth) }, + { be_const_key(time_dump, -1), be_const_func(l_time_dump) }, + { be_const_key(chars_in_string, -1), be_const_closure(Tasmota_chars_in_string_closure) }, + { be_const_key(global, 38), be_const_var(2) }, + { be_const_key(millis, 19), be_const_func(l_millis) }, + { be_const_key(settings, -1), be_const_var(3) }, { be_const_key(fast_loop, -1), be_const_closure(Tasmota_fast_loop_closure) }, + { be_const_key(set_light, -1), be_const_closure(Tasmota_set_light_closure) }, + { be_const_key(remove_fast_loop, -1), be_const_closure(Tasmota_remove_fast_loop_closure) }, + { be_const_key(get_switch, 13), be_const_func(l_getswitch) }, + { be_const_key(_debug_present, 58), be_const_var(4) }, + { be_const_key(_cmd, -1), be_const_func(l_cmd) }, + { be_const_key(remove_timer, 2), be_const_closure(Tasmota_remove_timer_closure) }, + { be_const_key(publish, -1), be_const_func(l_publish) }, + { be_const_key(arch, -1), be_const_func(l_arch) }, + { be_const_key(_settings_def, -1), be_const_comptr(&be_tasmota_settings_struct) }, + { be_const_key(add_driver, -1), be_const_closure(Tasmota_add_driver_closure) }, + { be_const_key(_timers, 11), be_const_var(5) }, { be_const_key(add_cron, -1), be_const_closure(Tasmota_add_cron_closure) }, - { be_const_key(add_fast_loop, -1), be_const_closure(Tasmota_add_fast_loop_closure) }, - { be_const_key(remove_rule, -1), be_const_closure(Tasmota_remove_rule_closure) }, + { be_const_key(scale_uint, -1), be_const_func(l_scaleuint) }, + { be_const_key(check_not_method, -1), be_const_closure(Tasmota_check_not_method_closure) }, + { be_const_key(web_send, 63), be_const_func(l_webSend) }, + { be_const_key(get_option, -1), be_const_func(l_getoption) }, + { be_const_key(time_str, -1), be_const_closure(Tasmota_time_str_closure) }, + { be_const_key(response_append, 26), be_const_func(l_respAppend) }, + { be_const_key(_fl, -1), be_const_var(6) }, + { be_const_key(get_free_heap, -1), be_const_func(l_getFreeHeap) }, + { be_const_key(_settings_ptr, -1), be_const_comptr(&Settings) }, + { be_const_key(exec_cmd, -1), be_const_closure(Tasmota_exec_cmd_closure) }, + { be_const_key(rtc, 18), be_const_func(l_rtc) }, + { be_const_key(read_sensors, 52), be_const_func(l_read_sensors) }, + { be_const_key(exec_tele, -1), be_const_closure(Tasmota_exec_tele_closure) }, + { be_const_key(_crons, 51), be_const_var(7) }, + { be_const_key(publish_result, 34), be_const_func(l_publish_result) }, + { be_const_key(hs2rgb, -1), be_const_closure(Tasmota_hs2rgb_closure) }, + { be_const_key(memory, -1), be_const_func(l_memory) }, + { be_const_key(wire1, -1), be_const_var(8) }, + { be_const_key(remove_driver, -1), be_const_closure(Tasmota_remove_driver_closure) }, + { be_const_key(get_light, -1), be_const_closure(Tasmota_get_light_closure) }, + { be_const_key(wifi, -1), be_const_func(l_wifi) }, + { be_const_key(run_cron, -1), be_const_closure(Tasmota_run_cron_closure) }, + { be_const_key(load, -1), be_const_closure(Tasmota_load_closure) }, + { be_const_key(wire_scan, 72), be_const_closure(Tasmota_wire_scan_closure) }, + { be_const_key(find_key_i, 76), be_const_closure(Tasmota_find_key_i_closure) }, + { be_const_key(resp_cmnd_error, -1), be_const_func(l_respCmndError) }, + { be_const_key(get_power, 69), be_const_func(l_getpower) }, + { be_const_key(_global_def, 56), be_const_comptr(&be_tasmota_global_struct) }, + { be_const_key(_ccmd, 60), be_const_var(9) }, + { be_const_key(cmd, 12), be_const_closure(Tasmota_cmd_closure) }, + { be_const_key(set_timer, -1), be_const_closure(Tasmota_set_timer_closure) }, + { be_const_key(resolvecmnd, 9), be_const_func(l_resolveCmnd) }, + { be_const_key(wire2, 5), be_const_var(10) }, + { be_const_key(get_switches, -1), be_const_func(l_getswitch) }, + { be_const_key(remove_rule, 53), be_const_closure(Tasmota_remove_rule_closure) }, + { be_const_key(next_cron, -1), be_const_closure(Tasmota_next_cron_closure) }, + { be_const_key(resp_cmnd, -1), be_const_func(l_respCmnd) }, + { be_const_key(publish_rule, -1), be_const_func(l_publish_rule) }, + { be_const_key(set_power, 70), be_const_func(l_setpower) }, + { be_const_key(strptime, -1), be_const_func(l_strptime) }, + { be_const_key(time_reached, -1), be_const_func(l_timereached) }, + { be_const_key(gen_cb, -1), be_const_closure(Tasmota_gen_cb_closure) }, + { be_const_key(delay, -1), be_const_func(l_delay) }, + { be_const_key(_rules, 33), be_const_var(11) }, + { be_const_key(resp_cmnd_failed, -1), be_const_func(l_respCmndFailed) }, + { be_const_key(init, -1), be_const_closure(Tasmota_init_closure) }, + { be_const_key(wd, -1), be_const_var(12) }, + { be_const_key(remove_cron, -1), be_const_closure(Tasmota_remove_cron_closure) }, + { be_const_key(log, -1), be_const_func(l_logInfo) }, + { be_const_key(add_cmd, -1), be_const_closure(Tasmota_add_cmd_closure) }, + { be_const_key(save, -1), be_const_func(l_save) }, + { be_const_key(_global_addr, 78), be_const_comptr(&TasmotaGlobal) }, + { be_const_key(add_fast_loop, 77), be_const_closure(Tasmota_add_fast_loop_closure) }, + { be_const_key(resp_cmnd_done, 47), be_const_func(l_respCmndDone) }, + { be_const_key(exec_rules, -1), be_const_closure(Tasmota_exec_rules_closure) }, + { be_const_key(i2c_enabled, -1), be_const_func(l_i2cenabled) }, + { be_const_key(resp_cmnd_str, 17), be_const_func(l_respCmndStr) }, + { be_const_key(event, -1), be_const_closure(Tasmota_event_closure) }, }; static be_define_const_map( be_class_tasmota_map, - 87 + 88 ); BE_EXPORT_VARIABLE be_define_const_class( diff --git a/lib/libesp32/berry_tasmota/src/be_tasmota_lib.c b/lib/libesp32/berry_tasmota/src/be_tasmota_lib.c index ea32d3c36..9a2091515 100644 --- a/lib/libesp32/berry_tasmota/src/be_tasmota_lib.c +++ b/lib/libesp32/berry_tasmota/src/be_tasmota_lib.c @@ -735,6 +735,47 @@ be_local_closure(Tasmota_add_fast_loop, /* name */ ); /*******************************************************************/ +/******************************************************************** +** Solidified function: remove_fast_loop +********************************************************************/ +be_local_closure(Tasmota_remove_fast_loop, /* 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[ 3]) { /* constants */ + /* K0 */ be_nested_str(_fl), + /* K1 */ be_nested_str(find), + /* K2 */ be_nested_str(remove), + }), + &be_const_str_remove_fast_loop, + &be_const_str_solidified, + ( &(const binstruction[15]) { /* code */ + 0x88080100, // 0000 GETMBR R2 R0 K0 + 0x740A0000, // 0001 JMPT R2 #0003 + 0x80000400, // 0002 RET 0 + 0x88080100, // 0003 GETMBR R2 R0 K0 + 0x8C080501, // 0004 GETMET R2 R2 K1 + 0x5C100200, // 0005 MOVE R4 R1 + 0x7C080400, // 0006 CALL R2 2 + 0x4C0C0000, // 0007 LDNIL R3 + 0x200C0403, // 0008 NE R3 R2 R3 + 0x780E0003, // 0009 JMPF R3 #000E + 0x880C0100, // 000A GETMBR R3 R0 K0 + 0x8C0C0702, // 000B GETMET R3 R3 K2 + 0x5C140400, // 000C MOVE R5 R2 + 0x7C0C0400, // 000D CALL R3 2 + 0x80000000, // 000E RET 0 + }) + ) +); +/*******************************************************************/ + /******************************************************************** ** Solidified function: event @@ -2621,6 +2662,7 @@ class be_class_tasmota (scope: global, name: Tasmota) { fast_loop, closure(Tasmota_fast_loop_closure) add_fast_loop, closure(Tasmota_add_fast_loop_closure) + remove_fast_loop, closure(Tasmota_remove_fast_loop_closure) cmd, closure(Tasmota_cmd_closure) chars_in_string, closure(Tasmota_chars_in_string_closure) find_key_i, closure(Tasmota_find_key_i_closure) diff --git a/lib/libesp32/berry_tasmota/src/embedded/Tasmota.be b/lib/libesp32/berry_tasmota/src/embedded/Tasmota.be index 119302e0f..9e825cbf6 100644 --- a/lib/libesp32/berry_tasmota/src/embedded/Tasmota.be +++ b/lib/libesp32/berry_tasmota/src/embedded/Tasmota.be @@ -628,6 +628,14 @@ class Tasmota self._fl.push(cl) end + def remove_fast_loop(cl) + if !self._fl return end + var idx = self._fl.find(cl) + if idx != nil + self._fl.remove(idx) + end + end + def event(event_type, cmd, idx, payload, raw) import introspect import string