Merge branch 'arendst:development' into development

This commit is contained in:
Scott James 2022-01-23 13:00:16 -05:00 committed by GitHub
commit 2cd510beb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 1015 additions and 923 deletions

View File

@ -9,6 +9,8 @@ All notable changes to this project will be documented in this file.
- ESP32 disable serial console when 3 (ESP32) or 2 (Other models) serial interfaces are requested (#14487)
- Support for BME688 with latest Bosch-Sensor-API library (#14513)
- Command ``SetOption44 1..100`` to set base tolerance percentage for matching incoming IR messages (default 25, max 100) (#14555)
- Command ``Json {<Tasmota commands>}`` to enable input of any command as JSON tokens (#14568)
- Rule variable %color% (#14572)
### Changed
- BME68x-Sensor-API library from v3.5.9 to v4.4.7

View File

@ -106,6 +106,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo
- Command ``WebTime <start_pos>,<end_pos>`` to show part of date and/or time in web gui based on "2017-03-07T11:08:02-07:00"
- Command ``SspmMap 2,1,..`` to map Sonoff SPM scanned module to physical module [#14281](https://github.com/arendst/Tasmota/issues/14281)
- Command ``SetOption44 1..100`` to set base tolerance percentage for matching incoming IR messages (default 25, max 100) [#14555](https://github.com/arendst/Tasmota/issues/14555)
- Command ``Json {<Tasmota commands>}`` to enable input of any command as JSON tokens [#14568](https://github.com/arendst/Tasmota/issues/14568)
- Commands for ESP32 ethernet configuration ``EthIpAddress``, ``EthGateway``, ``EthSubnetmask``, ``EthDnsServer1`` and ``EthDnsServer2`` [#14385](https://github.com/arendst/Tasmota/issues/14385)
- Support for Eastron SDM230 modBus energy meter [#13443](https://github.com/arendst/Tasmota/issues/13443)
- PWM Dimmer two button support [#13993](https://github.com/arendst/Tasmota/issues/13993)
@ -118,6 +119,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo
- Solax X1 modbus RTS support and offline status [#14305](https://github.com/arendst/Tasmota/issues/14305)
- Tasmota favicon to webbrowser tab [#14322](https://github.com/arendst/Tasmota/issues/14322)
- Support for BME688 with latest Bosch-Sensor-API library [#14513](https://github.com/arendst/Tasmota/issues/14513)
- Rule variable %color% [#14572](https://github.com/arendst/Tasmota/issues/14572)
- ESP32 single binary firmware [#14239](https://github.com/arendst/Tasmota/issues/14239)
- ESP32 disable serial console when 3 (ESP32) or 2 (Other models) serial interfaces are requested [#14487](https://github.com/arendst/Tasmota/issues/14487)
- ESP32 support for TuyaMcu

View File

@ -38,12 +38,6 @@ extern "C" {
.type = BE_NTVFUNC \
}
typedef const void* be_constptr;
#define be_const_ctype_func(_f, ...) { \
.v.nf = ((const void*) &(be_constptr[]) { _f, __VA_ARGS__ }),\
.type = BE_CTYPE_FUNC \
}
#define be_const_static_func(_func) { \
.v.nf = (_func), \
.type = BE_NTVFUNC | BE_FUNC_STATIC \
@ -260,12 +254,6 @@ const bntvmodule be_native_module(_module) = { \
BE_NTVFUNC \
}
#define be_const_ctype_func(_f, ...) { \
bvaldata(((const void*) \
&((const void *)[]) { (const void*) _f, __VA_ARGS__ })), \
BE_CTYPE_FUNC \
}
#define be_const_static_func(_func) { \
bvaldata(_func), \
BE_NTVFUNC | BE_FUNC_STATIC \

View File

@ -100,6 +100,7 @@ class coc_parser:
return r[0]
def parse_object(self):
self.text = re.sub("\s+//.*?$", "", self.text, flags=re.MULTILINE) # remove trailing comments
while True:
obj = self.parse_block()
self.objects.append(obj)

View File

@ -406,7 +406,7 @@ static void be_set_ctor_ptr(bvm *vm, void * ptr, const char *name) {
* CType handler for Berry
\*********************************************************************************************/
int be_call_ctype_func(bvm *vm, const void *definition) {
be_ctype_args* args = (be_ctype_args*) definition;
be_ctype_args_t* args = (be_ctype_args_t*) definition;
return be_call_c_func(vm, args->func, args->return_type, args->arg_type);
}

View File

@ -71,7 +71,7 @@ static bbool be_const_member_dual(bvm *vm, const be_const_member_t * definitions
}
case '>': // call to a ctype function
{
be_ctype_var_args* args = (be_ctype_var_args*) definitions[idx].value;
be_ctype_var_args_t* args = (be_ctype_var_args_t*) definitions[idx].value;
int ret = be_call_c_func(vm, args->func, args->return_type, NULL);
if ((ret == BE_OK) && !be_isnil(vm, -1)) {
return btrue;

View File

@ -3,38 +3,47 @@
#ifndef __BE_MAPPING__
#define __BE_MAPPING__
#ifdef __cplusplus
extern "C" {
#endif
#include "berry.h"
// include this header to force compilation fo this module
#define BE_MAX_CB 20 // max number of callbacks, each callback requires a distinct address
/*********************************************************************************************\
* Support for Berry int constants
* as virtual members
\*********************************************************************************************/
#ifdef __cplusplus
#define be_const_ctype_func(_f) { \
bvaldata((const void*) &ctype_func_def##_f), \
BE_CTYPE_FUNC \
}
#else // __cplusplus
typedef const void* be_constptr;
#define be_const_ctype_func(_f) { \
.v.nf = (const void*) &ctype_func_def##_f, \
.type = BE_CTYPE_FUNC \
}
#endif // __cplusplus
#define BE_FUNC_CTYPE_DECLARE(_name, _ret_arg, _in_arg) \
static const be_ctype_args_t ctype_func_def##_name = { (const void*) &_name, _ret_arg, _in_arg };
#define BE_VAR_CTYPE_DECLARE(_name, _ret_arg) \
static const be_ctype_var_args_t ctype_func_def##_name = { (const void*) &_name, _ret_arg };
#define be_cconst_int(_v) ((intptr_t)(_v))
#define be_cconst_string(_v) ((intptr_t)(_v))
#define be_cconst_ptr(_v) ((intptr_t)(_v))
#define be_cconst_func(_v) ((intptr_t)(_v))
#define be_cconst_ctype_func(_f, _r) ((intptr_t) &(be_ctype_var_args) { (const void*) _f, _r })
#define be_ctype(_name) ((intptr_t) &ctype_func_def##_name)
/* C arguments are coded as an array of 3 pointers */
typedef struct be_ctype_args {
void* func;
const char* return_type;
const char* arg_type;
} be_ctype_args;
/* ctype constant function as an array of 2 pointers: function and return type. arg_type is always NULL */
typedef struct be_ctype_var_args {
typedef struct be_ctype_args_t {
const void* func;
const char* return_type;
} be_ctype_var_args;
const char* arg_type;
} be_ctype_args_t;
/* ctype constant function as an array of 2 pointers: function and return type. arg_type is always NULL */
typedef struct be_ctype_var_args_t {
const void* func;
const char* return_type;
} be_ctype_var_args_t;
typedef struct be_const_member_t {
@ -45,9 +54,7 @@ typedef struct be_const_member_t {
// table of functions per class
typedef struct be_ntv_func_def_t {
const char * name;
const void * func;
const char * return_type;
const char * arg_type;
be_ctype_args_t args;
} be_ntv_func_def_t;
struct bclass;
@ -59,6 +66,17 @@ typedef struct be_ntv_class_def_t {
size_t size;
} be_ntv_class_def_t;
#ifdef __cplusplus
extern "C" {
#endif
/*********************************************************************************************\
* Support for Berry int constants
* as virtual members
\*********************************************************************************************/
void be_raisef(bvm *vm, const char *except, const char *msg, ...);
extern void be_map_insert_int(bvm *vm, const char *key, bint value);

File diff suppressed because it is too large Load Diff

View File

@ -27,112 +27,112 @@ static int lv_get_ver_res(void) {
/* `lv` methods */
const be_ntv_func_def_t lv_func[] = {
{ "clamp_height", (void*) &lv_clamp_height, "i", "iiii" },
{ "clamp_width", (void*) &lv_clamp_width, "i", "iiii" },
{ "color_black", (void*) &lv_color_black, "lv.lv_color", "" },
{ "color_brightness", (void*) &lv_color_brightness, "i", "(lv.lv_color)" },
{ "color_change_lightness", (void*) &lv_color_change_lightness, "lv.lv_color", "(lv.lv_color)i" },
{ "color_chroma_key", (void*) &lv_color_chroma_key, "lv.lv_color", "" },
{ "color_darken", (void*) &lv_color_darken, "lv.lv_color", "(lv.lv_color)i" },
{ "color_fill", (void*) &lv_color_fill, "", "(lv.lv_color)(lv.lv_color)i" },
{ "color_filter_dsc_init", (void*) &lv_color_filter_dsc_init, "", "(lv.lv_color_filter_dsc)^lv_color_filter_cb^" },
{ "color_hex", (void*) &lv_color_hex, "lv.lv_color", "i" },
{ "color_hex3", (void*) &lv_color_hex3, "lv.lv_color", "i" },
{ "color_hsv_to_rgb", (void*) &lv_color_hsv_to_rgb, "lv.lv_color", "iii" },
{ "color_lighten", (void*) &lv_color_lighten, "lv.lv_color", "(lv.lv_color)i" },
{ "color_make", (void*) &lv_color_make, "lv.lv_color", "iii" },
{ "color_mix", (void*) &lv_color_mix, "lv.lv_color", "(lv.lv_color)(lv.lv_color)i" },
{ "color_mix_premult", (void*) &lv_color_mix_premult, "lv.lv_color", "(lv.uint16)(lv.lv_color)i" },
{ "color_mix_with_alpha", (void*) &lv_color_mix_with_alpha, "", "(lv.lv_color)i(lv.lv_color)i(lv.lv_color)(lv.lv_opa)" },
{ "color_premult", (void*) &lv_color_premult, "", "(lv.lv_color)i(lv.uint16)" },
{ "color_rgb_to_hsv", (void*) &lv_color_rgb_to_hsv, "i", "iii" },
{ "color_to1", (void*) &lv_color_to1, "i", "(lv.lv_color)" },
{ "color_to16", (void*) &lv_color_to16, "i", "(lv.lv_color)" },
{ "color_to32", (void*) &lv_color_to32, "i", "(lv.lv_color)" },
{ "color_to8", (void*) &lv_color_to8, "i", "(lv.lv_color)" },
{ "color_to_hsv", (void*) &lv_color_to_hsv, "i", "(lv.lv_color)" },
{ "color_white", (void*) &lv_color_white, "lv.lv_color", "" },
{ "dpx", (void*) &lv_dpx, "i", "i" },
{ "draw_arc", (void*) &lv_draw_arc, "", "iiiii(lv.lv_area)(lv.lv_draw_arc_dsc)" },
{ "draw_arc_dsc_init", (void*) &lv_draw_arc_dsc_init, "", "(lv.lv_draw_arc_dsc)" },
{ "draw_arc_get_area", (void*) &lv_draw_arc_get_area, "", "iiiiiib(lv.lv_area)" },
{ "draw_img", (void*) &lv_draw_img, "", "(lv.lv_area)(lv.lv_area).(lv.lv_draw_img_dsc)" },
{ "draw_img_dsc_init", (void*) &lv_draw_img_dsc_init, "", "(lv.lv_draw_img_dsc)" },
{ "draw_label", (void*) &lv_draw_label, "", "(lv.lv_area)(lv.lv_area)(lv.lv_draw_label_dsc)s(lv.lv_draw_label_hint)" },
{ "draw_label_dsc_init", (void*) &lv_draw_label_dsc_init, "", "(lv.lv_draw_label_dsc)" },
{ "draw_letter", (void*) &lv_draw_letter, "", "(lv.lv_point)(lv.lv_area)(lv.lv_font)i(lv.lv_color)ii" },
{ "draw_line", (void*) &lv_draw_line, "", "(lv.lv_point)(lv.lv_point)(lv.lv_area)(lv.lv_draw_line_dsc)" },
{ "draw_line_dsc_init", (void*) &lv_draw_line_dsc_init, "", "(lv.lv_draw_line_dsc)" },
{ "draw_mask_add", (void*) &lv_draw_mask_add, "i", ".." },
{ "draw_mask_angle_init", (void*) &lv_draw_mask_angle_init, "", "(lv.lv_draw_mask_angle_param)iiii" },
{ "draw_mask_apply", (void*) &lv_draw_mask_apply, "i", "(lv.lv_opa)iii" },
{ "draw_mask_apply_ids", (void*) &lv_draw_mask_apply_ids, "i", "(lv.lv_opa)iii(lv.int16)i" },
{ "draw_mask_fade_init", (void*) &lv_draw_mask_fade_init, "", "(lv.lv_draw_mask_fade_param)(lv.lv_area)iiii" },
{ "draw_mask_free_param", (void*) &lv_draw_mask_free_param, "", "." },
{ "draw_mask_get_cnt", (void*) &lv_draw_mask_get_cnt, "i", "" },
{ "draw_mask_is_any", (void*) &lv_draw_mask_is_any, "b", "(lv.lv_area)" },
{ "draw_mask_line_angle_init", (void*) &lv_draw_mask_line_angle_init, "", "(lv.lv_draw_mask_line_param)iiii" },
{ "draw_mask_line_points_init", (void*) &lv_draw_mask_line_points_init, "", "(lv.lv_draw_mask_line_param)iiiii" },
{ "draw_mask_map_init", (void*) &lv_draw_mask_map_init, "", "(lv.lv_draw_mask_map_param)(lv.lv_area)(lv.lv_opa)" },
{ "draw_mask_radius_init", (void*) &lv_draw_mask_radius_init, "", "(lv.lv_draw_mask_radius_param)(lv.lv_area)ib" },
{ "draw_mask_remove_custom", (void*) &lv_draw_mask_remove_custom, ".", "." },
{ "draw_mask_remove_id", (void*) &lv_draw_mask_remove_id, ".", "i" },
{ "draw_polygon", (void*) &lv_draw_polygon, "", "(lv.lv_point_arr)i(lv.lv_area)(lv.lv_draw_rect_dsc)" },
{ "draw_rect", (void*) &lv_draw_rect, "", "(lv.lv_area)(lv.lv_area)(lv.lv_draw_rect_dsc)" },
{ "draw_rect_dsc_init", (void*) &lv_draw_rect_dsc_init, "", "(lv.lv_draw_rect_dsc)" },
{ "draw_triangle", (void*) &lv_draw_triangle, "", "(lv.lv_point_arr)(lv.lv_area)(lv.lv_draw_rect_dsc)" },
{ "event_register_id", (void*) &lv_event_register_id, "i", "" },
{ "event_send", (void*) &lv_event_send, "i", "(lv.lv_obj)i." },
{ "event_set_cover_res", (void*) &lv_event_set_cover_res, "", "(lv.lv_event)(lv.lv_cover_res)" },
{ "event_set_ext_draw_size", (void*) &lv_event_set_ext_draw_size, "", "(lv.lv_event)i" },
{ "flex_init", (void*) &lv_flex_init, "", "" },
{ "get_hor_res", (void*) &lv_get_hor_res, "i", "" },
{ "get_ts_calibration", (void*) &lv_get_ts_calibration, "lv.lv_ts_calibration", "" },
{ "get_ver_res", (void*) &lv_get_ver_res, "i", "" },
{ "grid_fr", (void*) &lv_grid_fr, "i", "i" },
{ "grid_init", (void*) &lv_grid_init, "", "" },
{ "group_get_default", (void*) &lv_group_get_default, "lv.lv_group", "" },
{ "img_src_get_type", (void*) &lv_img_src_get_type, "i", "." },
{ "indev_get_act", (void*) &lv_indev_get_act, "lv.lv_indev", "" },
{ "indev_get_obj_act", (void*) &lv_indev_get_obj_act, "lv.lv_obj", "" },
{ "indev_get_read_timer", (void*) &lv_indev_get_read_timer, "lv.lv_timer", "(lv.lv_disp)" },
{ "indev_read_timer_cb", (void*) &lv_indev_read_timer_cb, "", "(lv.lv_timer)" },
{ "is_initialized", (void*) &lv_is_initialized, "b", "" },
{ "layer_sys", (void*) &lv_layer_sys, "lv.lv_obj", "" },
{ "layer_top", (void*) &lv_layer_top, "lv.lv_obj", "" },
{ "layout_register", (void*) &lv_layout_register, "i", "^lv_layout_update_cb^." },
{ "obj_class_create_obj", (void*) &lv_obj_class_create_obj, "lv.lv_obj", "(lv._lv_obj_class)(lv.lv_obj)" },
{ "obj_del_anim_ready_cb", (void*) &lv_obj_del_anim_ready_cb, "", "(lv.lv_anim)" },
{ "obj_draw_dsc_init", (void*) &lv_obj_draw_dsc_init, "", "(lv.lv_obj_draw_part_dsc)(lv.lv_area)" },
{ "obj_draw_part_check_type", (void*) &lv_obj_draw_part_check_type, "b", "(lv.lv_obj_draw_part_dsc)(lv._lv_obj_class)i" },
{ "obj_enable_style_refresh", (void*) &lv_obj_enable_style_refresh, "", "b" },
{ "obj_event_base", (void*) &lv_obj_event_base, "i", "(lv.lv_obj_class)(lv.lv_event)" },
{ "obj_report_style_change", (void*) &lv_obj_report_style_change, "", "(lv.lv_style)" },
{ "obj_style_get_selector_part", (void*) &lv_obj_style_get_selector_part, "i", "i" },
{ "obj_style_get_selector_state", (void*) &lv_obj_style_get_selector_state, "i", "i" },
{ "palette_darken", (void*) &lv_palette_darken, "lv.lv_color", "ii" },
{ "palette_lighten", (void*) &lv_palette_lighten, "lv.lv_color", "ii" },
{ "palette_main", (void*) &lv_palette_main, "lv.lv_color", "i" },
{ "refr_now", (void*) &lv_refr_now, "", "(lv.lv_disp)" },
{ "scr_act", (void*) &lv_scr_act, "lv.lv_obj", "" },
{ "scr_load", (void*) &lv_scr_load, "", "(lv.lv_obj)" },
{ "scr_load_anim", (void*) &lv_scr_load_anim, "", "(lv.lv_obj)iiib" },
{ "task_handler", (void*) &lv_task_handler, "i", "" },
{ "theme_apply", (void*) &lv_theme_apply, "", "(lv.lv_obj)" },
{ "theme_default_get", (void*) &lv_theme_default_get, "lv.lv_theme", "" },
{ "theme_default_init", (void*) &lv_theme_default_init, "lv.lv_theme", "(lv.lv_disp)(lv.lv_color)(lv.lv_color)b(lv.lv_font)" },
{ "theme_default_is_inited", (void*) &lv_theme_default_is_inited, "b", "" },
{ "theme_get_color_primary", (void*) &lv_theme_get_color_primary, "lv.lv_color", "(lv.lv_obj)" },
{ "theme_get_color_secondary", (void*) &lv_theme_get_color_secondary, "lv.lv_color", "(lv.lv_obj)" },
{ "theme_get_font_large", (void*) &lv_theme_get_font_large, "lv.lv_font", "(lv.lv_obj)" },
{ "theme_get_font_normal", (void*) &lv_theme_get_font_normal, "lv.lv_font", "(lv.lv_obj)" },
{ "theme_get_font_small", (void*) &lv_theme_get_font_small, "lv.lv_font", "(lv.lv_obj)" },
{ "theme_get_from_obj", (void*) &lv_theme_get_from_obj, "lv.lv_theme", "(lv.lv_obj)" },
{ "theme_mono_init", (void*) &lv_theme_mono_init, "lv.lv_theme", "(lv.lv_disp)b(lv.lv_font)" },
{ "theme_openhasp_init", (void*) &lv_theme_openhasp_init, "lv.lv_theme", "(lv.lv_disp)(lv.lv_color)(lv.lv_color)b(lv.lv_font)" },
{ "theme_openhasp_is_inited", (void*) &lv_theme_openhasp_is_inited, "b", "" },
{ "theme_set_apply_cb", (void*) &lv_theme_set_apply_cb, "", "(lv.lv_theme)^lv_theme_apply_cb^" },
{ "theme_set_parent", (void*) &lv_theme_set_parent, "", "(lv.lv_theme)(lv.lv_theme)" },
{ "clamp_height", { (const void*) &lv_clamp_height, "i", "iiii" } },
{ "clamp_width", { (const void*) &lv_clamp_width, "i", "iiii" } },
{ "color_black", { (const void*) &lv_color_black, "lv.lv_color", "" } },
{ "color_brightness", { (const void*) &lv_color_brightness, "i", "(lv.lv_color)" } },
{ "color_change_lightness", { (const void*) &lv_color_change_lightness, "lv.lv_color", "(lv.lv_color)i" } },
{ "color_chroma_key", { (const void*) &lv_color_chroma_key, "lv.lv_color", "" } },
{ "color_darken", { (const void*) &lv_color_darken, "lv.lv_color", "(lv.lv_color)i" } },
{ "color_fill", { (const void*) &lv_color_fill, "", "(lv.lv_color)(lv.lv_color)i" } },
{ "color_filter_dsc_init", { (const void*) &lv_color_filter_dsc_init, "", "(lv.lv_color_filter_dsc)^lv_color_filter_cb^" } },
{ "color_hex", { (const void*) &lv_color_hex, "lv.lv_color", "i" } },
{ "color_hex3", { (const void*) &lv_color_hex3, "lv.lv_color", "i" } },
{ "color_hsv_to_rgb", { (const void*) &lv_color_hsv_to_rgb, "lv.lv_color", "iii" } },
{ "color_lighten", { (const void*) &lv_color_lighten, "lv.lv_color", "(lv.lv_color)i" } },
{ "color_make", { (const void*) &lv_color_make, "lv.lv_color", "iii" } },
{ "color_mix", { (const void*) &lv_color_mix, "lv.lv_color", "(lv.lv_color)(lv.lv_color)i" } },
{ "color_mix_premult", { (const void*) &lv_color_mix_premult, "lv.lv_color", "(lv.uint16)(lv.lv_color)i" } },
{ "color_mix_with_alpha", { (const void*) &lv_color_mix_with_alpha, "", "(lv.lv_color)i(lv.lv_color)i(lv.lv_color)(lv.lv_opa)" } },
{ "color_premult", { (const void*) &lv_color_premult, "", "(lv.lv_color)i(lv.uint16)" } },
{ "color_rgb_to_hsv", { (const void*) &lv_color_rgb_to_hsv, "i", "iii" } },
{ "color_to1", { (const void*) &lv_color_to1, "i", "(lv.lv_color)" } },
{ "color_to16", { (const void*) &lv_color_to16, "i", "(lv.lv_color)" } },
{ "color_to32", { (const void*) &lv_color_to32, "i", "(lv.lv_color)" } },
{ "color_to8", { (const void*) &lv_color_to8, "i", "(lv.lv_color)" } },
{ "color_to_hsv", { (const void*) &lv_color_to_hsv, "i", "(lv.lv_color)" } },
{ "color_white", { (const void*) &lv_color_white, "lv.lv_color", "" } },
{ "dpx", { (const void*) &lv_dpx, "i", "i" } },
{ "draw_arc", { (const void*) &lv_draw_arc, "", "iiiii(lv.lv_area)(lv.lv_draw_arc_dsc)" } },
{ "draw_arc_dsc_init", { (const void*) &lv_draw_arc_dsc_init, "", "(lv.lv_draw_arc_dsc)" } },
{ "draw_arc_get_area", { (const void*) &lv_draw_arc_get_area, "", "iiiiiib(lv.lv_area)" } },
{ "draw_img", { (const void*) &lv_draw_img, "", "(lv.lv_area)(lv.lv_area).(lv.lv_draw_img_dsc)" } },
{ "draw_img_dsc_init", { (const void*) &lv_draw_img_dsc_init, "", "(lv.lv_draw_img_dsc)" } },
{ "draw_label", { (const void*) &lv_draw_label, "", "(lv.lv_area)(lv.lv_area)(lv.lv_draw_label_dsc)s(lv.lv_draw_label_hint)" } },
{ "draw_label_dsc_init", { (const void*) &lv_draw_label_dsc_init, "", "(lv.lv_draw_label_dsc)" } },
{ "draw_letter", { (const void*) &lv_draw_letter, "", "(lv.lv_point)(lv.lv_area)(lv.lv_font)i(lv.lv_color)ii" } },
{ "draw_line", { (const void*) &lv_draw_line, "", "(lv.lv_point)(lv.lv_point)(lv.lv_area)(lv.lv_draw_line_dsc)" } },
{ "draw_line_dsc_init", { (const void*) &lv_draw_line_dsc_init, "", "(lv.lv_draw_line_dsc)" } },
{ "draw_mask_add", { (const void*) &lv_draw_mask_add, "i", ".." } },
{ "draw_mask_angle_init", { (const void*) &lv_draw_mask_angle_init, "", "(lv.lv_draw_mask_angle_param)iiii" } },
{ "draw_mask_apply", { (const void*) &lv_draw_mask_apply, "i", "(lv.lv_opa)iii" } },
{ "draw_mask_apply_ids", { (const void*) &lv_draw_mask_apply_ids, "i", "(lv.lv_opa)iii(lv.int16)i" } },
{ "draw_mask_fade_init", { (const void*) &lv_draw_mask_fade_init, "", "(lv.lv_draw_mask_fade_param)(lv.lv_area)iiii" } },
{ "draw_mask_free_param", { (const void*) &lv_draw_mask_free_param, "", "." } },
{ "draw_mask_get_cnt", { (const void*) &lv_draw_mask_get_cnt, "i", "" } },
{ "draw_mask_is_any", { (const void*) &lv_draw_mask_is_any, "b", "(lv.lv_area)" } },
{ "draw_mask_line_angle_init", { (const void*) &lv_draw_mask_line_angle_init, "", "(lv.lv_draw_mask_line_param)iiii" } },
{ "draw_mask_line_points_init", { (const void*) &lv_draw_mask_line_points_init, "", "(lv.lv_draw_mask_line_param)iiiii" } },
{ "draw_mask_map_init", { (const void*) &lv_draw_mask_map_init, "", "(lv.lv_draw_mask_map_param)(lv.lv_area)(lv.lv_opa)" } },
{ "draw_mask_radius_init", { (const void*) &lv_draw_mask_radius_init, "", "(lv.lv_draw_mask_radius_param)(lv.lv_area)ib" } },
{ "draw_mask_remove_custom", { (const void*) &lv_draw_mask_remove_custom, ".", "." } },
{ "draw_mask_remove_id", { (const void*) &lv_draw_mask_remove_id, ".", "i" } },
{ "draw_polygon", { (const void*) &lv_draw_polygon, "", "(lv.lv_point_arr)i(lv.lv_area)(lv.lv_draw_rect_dsc)" } },
{ "draw_rect", { (const void*) &lv_draw_rect, "", "(lv.lv_area)(lv.lv_area)(lv.lv_draw_rect_dsc)" } },
{ "draw_rect_dsc_init", { (const void*) &lv_draw_rect_dsc_init, "", "(lv.lv_draw_rect_dsc)" } },
{ "draw_triangle", { (const void*) &lv_draw_triangle, "", "(lv.lv_point_arr)(lv.lv_area)(lv.lv_draw_rect_dsc)" } },
{ "event_register_id", { (const void*) &lv_event_register_id, "i", "" } },
{ "event_send", { (const void*) &lv_event_send, "i", "(lv.lv_obj)i." } },
{ "event_set_cover_res", { (const void*) &lv_event_set_cover_res, "", "(lv.lv_event)(lv.lv_cover_res)" } },
{ "event_set_ext_draw_size", { (const void*) &lv_event_set_ext_draw_size, "", "(lv.lv_event)i" } },
{ "flex_init", { (const void*) &lv_flex_init, "", "" } },
{ "get_hor_res", { (const void*) &lv_get_hor_res, "i", "" } },
{ "get_ts_calibration", { (const void*) &lv_get_ts_calibration, "lv.lv_ts_calibration", "" } },
{ "get_ver_res", { (const void*) &lv_get_ver_res, "i", "" } },
{ "grid_fr", { (const void*) &lv_grid_fr, "i", "i" } },
{ "grid_init", { (const void*) &lv_grid_init, "", "" } },
{ "group_get_default", { (const void*) &lv_group_get_default, "lv.lv_group", "" } },
{ "img_src_get_type", { (const void*) &lv_img_src_get_type, "i", "." } },
{ "indev_get_act", { (const void*) &lv_indev_get_act, "lv.lv_indev", "" } },
{ "indev_get_obj_act", { (const void*) &lv_indev_get_obj_act, "lv.lv_obj", "" } },
{ "indev_get_read_timer", { (const void*) &lv_indev_get_read_timer, "lv.lv_timer", "(lv.lv_disp)" } },
{ "indev_read_timer_cb", { (const void*) &lv_indev_read_timer_cb, "", "(lv.lv_timer)" } },
{ "is_initialized", { (const void*) &lv_is_initialized, "b", "" } },
{ "layer_sys", { (const void*) &lv_layer_sys, "lv.lv_obj", "" } },
{ "layer_top", { (const void*) &lv_layer_top, "lv.lv_obj", "" } },
{ "layout_register", { (const void*) &lv_layout_register, "i", "^lv_layout_update_cb^." } },
{ "obj_class_create_obj", { (const void*) &lv_obj_class_create_obj, "lv.lv_obj", "(lv._lv_obj_class)(lv.lv_obj)" } },
{ "obj_del_anim_ready_cb", { (const void*) &lv_obj_del_anim_ready_cb, "", "(lv.lv_anim)" } },
{ "obj_draw_dsc_init", { (const void*) &lv_obj_draw_dsc_init, "", "(lv.lv_obj_draw_part_dsc)(lv.lv_area)" } },
{ "obj_draw_part_check_type", { (const void*) &lv_obj_draw_part_check_type, "b", "(lv.lv_obj_draw_part_dsc)(lv._lv_obj_class)i" } },
{ "obj_enable_style_refresh", { (const void*) &lv_obj_enable_style_refresh, "", "b" } },
{ "obj_event_base", { (const void*) &lv_obj_event_base, "i", "(lv.lv_obj_class)(lv.lv_event)" } },
{ "obj_report_style_change", { (const void*) &lv_obj_report_style_change, "", "(lv.lv_style)" } },
{ "obj_style_get_selector_part", { (const void*) &lv_obj_style_get_selector_part, "i", "i" } },
{ "obj_style_get_selector_state", { (const void*) &lv_obj_style_get_selector_state, "i", "i" } },
{ "palette_darken", { (const void*) &lv_palette_darken, "lv.lv_color", "ii" } },
{ "palette_lighten", { (const void*) &lv_palette_lighten, "lv.lv_color", "ii" } },
{ "palette_main", { (const void*) &lv_palette_main, "lv.lv_color", "i" } },
{ "refr_now", { (const void*) &lv_refr_now, "", "(lv.lv_disp)" } },
{ "scr_act", { (const void*) &lv_scr_act, "lv.lv_obj", "" } },
{ "scr_load", { (const void*) &lv_scr_load, "", "(lv.lv_obj)" } },
{ "scr_load_anim", { (const void*) &lv_scr_load_anim, "", "(lv.lv_obj)iiib" } },
{ "task_handler", { (const void*) &lv_task_handler, "i", "" } },
{ "theme_apply", { (const void*) &lv_theme_apply, "", "(lv.lv_obj)" } },
{ "theme_default_get", { (const void*) &lv_theme_default_get, "lv.lv_theme", "" } },
{ "theme_default_init", { (const void*) &lv_theme_default_init, "lv.lv_theme", "(lv.lv_disp)(lv.lv_color)(lv.lv_color)b(lv.lv_font)" } },
{ "theme_default_is_inited", { (const void*) &lv_theme_default_is_inited, "b", "" } },
{ "theme_get_color_primary", { (const void*) &lv_theme_get_color_primary, "lv.lv_color", "(lv.lv_obj)" } },
{ "theme_get_color_secondary", { (const void*) &lv_theme_get_color_secondary, "lv.lv_color", "(lv.lv_obj)" } },
{ "theme_get_font_large", { (const void*) &lv_theme_get_font_large, "lv.lv_font", "(lv.lv_obj)" } },
{ "theme_get_font_normal", { (const void*) &lv_theme_get_font_normal, "lv.lv_font", "(lv.lv_obj)" } },
{ "theme_get_font_small", { (const void*) &lv_theme_get_font_small, "lv.lv_font", "(lv.lv_obj)" } },
{ "theme_get_from_obj", { (const void*) &lv_theme_get_from_obj, "lv.lv_theme", "(lv.lv_obj)" } },
{ "theme_mono_init", { (const void*) &lv_theme_mono_init, "lv.lv_theme", "(lv.lv_disp)b(lv.lv_font)" } },
{ "theme_openhasp_init", { (const void*) &lv_theme_openhasp_init, "lv.lv_theme", "(lv.lv_disp)(lv.lv_color)(lv.lv_color)b(lv.lv_font)" } },
{ "theme_openhasp_is_inited", { (const void*) &lv_theme_openhasp_is_inited, "b", "" } },
{ "theme_set_apply_cb", { (const void*) &lv_theme_set_apply_cb, "", "(lv.lv_theme)^lv_theme_apply_cb^" } },
{ "theme_set_parent", { (const void*) &lv_theme_set_parent, "", "(lv.lv_theme)(lv.lv_theme)" } },
};
const size_t lv_func_size = sizeof(lv_func) / sizeof(lv_func[0]);

View File

@ -125,15 +125,15 @@ int lv_x_member(bvm *vm) {
// push native closure
be_pushntvclosure(vm, &lv_x_call_c, 3); // 3 upvals
be_pushcomptr(vm, method->func);
be_pushcomptr(vm, method->args.func);
be_setupval(vm, -2, 0);
be_pop(vm, 1);
be_pushstring(vm, method->return_type);
be_pushstring(vm, method->args.return_type);
be_setupval(vm, -2, 1);
be_pop(vm, 1);
be_pushstring(vm, method->arg_type);
be_pushstring(vm, method->args.arg_type);
be_setupval(vm, -2, 2);
be_pop(vm, 1);
@ -298,15 +298,15 @@ int lv0_member(bvm *vm) {
// push native closure
be_pushntvclosure(vm, &lv_x_call_c, 3); // 3 upvals
be_pushcomptr(vm, method->func);
be_pushcomptr(vm, method->args.func);
be_setupval(vm, -2, 0);
be_pop(vm, 1);
be_pushstring(vm, method->return_type);
be_pushstring(vm, method->args.return_type);
be_setupval(vm, -2, 1);
be_pop(vm, 1);
be_pushstring(vm, method->arg_type);
be_pushstring(vm, method->args.arg_type);
be_setupval(vm, -2, 2);
be_pop(vm, 1);

View File

@ -238,6 +238,7 @@ with open(lv_widgets_file) as f:
c_args = ""
args_raw = [ x.strip(" \t\n\r") for x in g.group(3).split(",") ] # split by comma and strip
# print(args_raw)
func_name = g.group(2)
for arg_raw in args_raw:
# Ex: 'const lv_obj_t * parent' -> 'const ', 'lv_obj_t', ' * ', 'parent', ''
# Ex: 'bool auto_fit' -> '', 'bool', ' ', 'auto_fit', ''
@ -264,10 +265,13 @@ with open(lv_widgets_file) as f:
c_args += ga_type
else:
if ga_type.endswith("_cb"):
# it's a callback type, we encode it differently
if ga_type not in lv_cb_types:
lv_cb_types.append(ga_type)
c_args += "^" + ga_type + "^"
if 'remove_' in func_name: # if the call is to remove the cb, just treat as an 'anything' parameter
c_args += "."
else:
# it's a callback type, we encode it differently
if ga_type not in lv_cb_types:
lv_cb_types.append(ga_type)
c_args += "^" + ga_type + "^"
else:
# we have a high-level type that we treat as a class name, enclose in parenthesis
c_args += "(" + "lv." + ga_type + ")"
@ -276,7 +280,6 @@ with open(lv_widgets_file) as f:
c_args += "[......]" # allow 6 additional parameters
# analyze function name and determine if it needs to be assigned to a specific class
func_name = g.group(2)
# Ex: func_name -> 'lv_obj_set_parent'
if func_name.startswith("_"): continue # skip low-level
if func_name.startswith("lv_debug_"): continue # skip debug
@ -375,7 +378,7 @@ for subtype, flv in lv.items():
pass
# c_ret_type = f"+lv_{subtype}"
else:
func_out[be_name] = f" {{ \"{be_name}\", (void*) &{orig_func_name}, \"{c_ret_type}\", { c_argc if c_argc else 'nullptr'} }},"
func_out[be_name] = f" {{ \"{be_name}\", {{ (const void*) &{orig_func_name}, \"{c_ret_type}\", { c_argc if c_argc else 'nullptr'} }} }},"
for be_name in sorted(func_out):
print(func_out[be_name])
@ -718,7 +721,7 @@ for f in lv0:
# if c_ret_type is an object, prefix with `lv.`
if len(c_ret_type) > 1: c_ret_type = "lv." + c_ret_type
func_out[be_name] = f" {{ \"{be_name}\", (void*) &{orig_func_name}, \"{c_ret_type}\", { c_argc if c_argc else 'nullptr'} }},"
func_out[be_name] = f" {{ \"{be_name}\", {{ (const void*) &{orig_func_name}, \"{c_ret_type}\", { c_argc if c_argc else 'nullptr'} }} }},"
for be_name in sorted(func_out):
print(func_out[be_name])

View File

@ -240,6 +240,7 @@
// Commands tasmota.ino
#define D_CMND_BACKLOG "Backlog"
#define D_CMND_JSON "Json"
#define D_CMND_DELAY "Delay"
#define D_CMND_NODELAY "NoDelay"
#define D_CMND_STATUS "Status"

View File

@ -42,7 +42,7 @@ const char kTasmotaCommands[] PROGMEM = "|" // No prefix
#endif // USE_DEVICE_GROUPS_SEND
D_CMND_DEVGROUP_SHARE "|" D_CMND_DEVGROUPSTATUS "|" D_CMND_DEVGROUP_TIE "|"
#endif // USE_DEVICE_GROUPS
D_CMND_SETSENSOR "|" D_CMND_SENSOR "|" D_CMND_DRIVER
D_CMND_SETSENSOR "|" D_CMND_SENSOR "|" D_CMND_DRIVER "|" D_CMND_JSON
#ifdef ESP32
"|Info|" D_CMND_TOUCH_CAL "|" D_CMND_TOUCH_THRES "|" D_CMND_TOUCH_NUM "|" D_CMND_CPU_FREQUENCY
#endif // ESP32
@ -74,7 +74,7 @@ void (* const TasmotaCommand[])(void) PROGMEM = {
#endif // USE_DEVICE_GROUPS_SEND
&CmndDevGroupShare, &CmndDevGroupStatus, &CmndDevGroupTie,
#endif // USE_DEVICE_GROUPS
&CmndSetSensor, &CmndSensor, &CmndDriver
&CmndSetSensor, &CmndSensor, &CmndDriver, &CmndJson
#ifdef ESP32
, &CmndInfo, &CmndTouchCal, &CmndTouchThres, &CmndTouchNum, &CmndCpuFrequency
#endif // ESP32
@ -391,6 +391,73 @@ void CmndBacklog(void) {
}
}
void CmndJson(void) {
// Json {"template":{"NAME":"Dummy","GPIO":[320,0,321],"FLAG":0,"BASE":18},"power":2,"HSBColor":"51,97,100","Channel":[100,85,3]}
//
// Escape lower level tokens and add quotes around it
// Input:
// {"template":{"NAME":"Dummy","GPIO":[320,0,321],"FLAG":0,"BASE":18},"power":2,"HSBColor":"51,97,100","Channel":[100,85,3]}
// Output (escaped subtokens):
// {"template":"{\"NAME\":\"Dummy\",\"GPIO\":[320,0,321],\"FLAG\":0,\"BASE\":18}","power":2,"HSBColor":"51,97,100","Channel":[100,85,3]}
uint32_t bracket = 0;
String data_buf("");
data_buf.reserve(XdrvMailbox.data_len); // We need at least the same amount of characters
for (uint32_t index = 0; index < XdrvMailbox.data_len; index++) {
char c = (char)XdrvMailbox.data[index];
if (c == '{') {
bracket++;
if (2 == bracket) { data_buf += '"'; } // Add start quote
}
if (bracket > 1) {
if (c == '\"') { data_buf += '\\'; } // Escape any quote within second level token
}
data_buf += c;
if (c == '}') {
bracket--;
if (1 == bracket) { data_buf += '"'; } // Add end quote
}
}
JsonParser parser((char*)data_buf.c_str());
JsonParserObject root = parser.getRootObject();
if (root) {
// Convert to backlog commands
// Input (escaped subtokens):
// {"template":"{\"NAME\":\"Dummy\",\"GPIO\":[320,0,321],\"FLAG\":0,\"BASE\":18}","power":2,"HSBColor":"51,97,100","Channel":[100,85,3]}
// Output:
// template {"NAME":"Dummy","GPIO":[320,0,321],"FLAG":0,"BASE":18};power 2;HSBColor 51,97,100;Channel1 100;Channel2 85;Channel3 3
String backlog; // We might need a larger string than XdrvMailbox.data_len accomodating decoded arrays
for (auto command_key : root) {
const char *command = command_key.getStr();
JsonParserToken parameters = command_key.getValue();
if (parameters.isArray()) {
JsonParserArray parameter_arr = parameters.getArray();
uint32_t index = 1;
for (auto value : parameter_arr) {
if (backlog.length()) { backlog += ";"; }
backlog += command;
backlog += index++;
backlog += " ";
backlog += value.getStr(); // Channel1 100;Channel2 85;Channel3 3
}
} else if (parameters.isObject()) { // Should have been escaped
// AddLog(LOG_LEVEL_DEBUG, PSTR("JSN: Object"));
} else {
if (backlog.length()) { backlog += ";"; }
backlog += command;
backlog += " ";
backlog += parameters.getStr(); // HSBColor 51,97,100
}
}
XdrvMailbox.data = (char*)backlog.c_str(); // Backlog commands
XdrvMailbox.data_len = 1; // Any data
XdrvMailbox.index = 0; // Backlog0 - no delay
CmndBacklog();
} else {
ResponseCmndChar(PSTR(D_JSON_EMPTY));
}
}
void CmndDelay(void)
{
if ((XdrvMailbox.payload >= (MIN_BACKLOG_DELAY / 100)) && (XdrvMailbox.payload <= 3600)) {

View File

@ -471,6 +471,12 @@ bool RulesRuleMatch(uint8_t rule_set, String &event, String &rule, bool stop_all
rule_param = String(SunMinutes(1));
}
#endif // USE_TIMERS and USE_SUNRISE
#if defined(USE_LIGHT)
char scolor[LIGHT_COLOR_SIZE];
if (rule_param.startsWith(F("%COLOR%"))) {
rule_param = LightGetColor(scolor);
}
#endif
// #ifdef USE_ZIGBEE
// if (rule_param.startsWith(F("%ZBDEVICE%"))) {
// snprintf_P(stemp, sizeof(stemp), PSTR("0x%04X"), Z_GetLastDevice());
@ -772,6 +778,10 @@ bool RuleSetProcess(uint8_t rule_set, String &event_saved)
RulesVarReplace(commands, F("%SUNRISE%"), String(SunMinutes(0)));
RulesVarReplace(commands, F("%SUNSET%"), String(SunMinutes(1)));
#endif // USE_TIMERS and USE_SUNRISE
#if defined(USE_LIGHT)
char scolor[LIGHT_COLOR_SIZE];
RulesVarReplace(commands, F("%COLOR%"), LightGetColor(scolor));
#endif
#ifdef USE_ZIGBEE
snprintf_P(stemp, sizeof(stemp), PSTR("0x%04X"), Z_GetLastDevice());
RulesVarReplace(commands, F("%ZBDEVICE%"), String(stemp));