mirror of https://github.com/arendst/Tasmota.git
LVGL fixes and examples
This commit is contained in:
parent
cd228d2f84
commit
749d30a14f
|
@ -45,8 +45,8 @@ const lvbe_call_c_t lv_func[] = {
|
|||
{ "draw_mask_angle_init", (void*) &lv_draw_mask_angle_init, "", "(lv_draw_mask_angle_param)iiii" },
|
||||
{ "draw_mask_fade_init", (void*) &lv_draw_mask_fade_init, "", "(lv_draw_mask_fade_param)(lv_area)iiii" },
|
||||
{ "draw_mask_get_cnt", (void*) &lv_draw_mask_get_cnt, "i", "" },
|
||||
{ "draw_mask_line_angle_init", (void*) &lv_draw_mask_line_angle_init, "", "(lv_draw_mask_line_param)iii(lv_draw_mask_line_side)" },
|
||||
{ "draw_mask_line_points_init", (void*) &lv_draw_mask_line_points_init, "", "(lv_draw_mask_line_param)iiii(lv_draw_mask_line_side)" },
|
||||
{ "draw_mask_line_angle_init", (void*) &lv_draw_mask_line_angle_init, "", "(lv_draw_mask_line_param)iiii" },
|
||||
{ "draw_mask_line_points_init", (void*) &lv_draw_mask_line_points_init, "", "(lv_draw_mask_line_param)iiiii" },
|
||||
{ "draw_mask_map_init", (void*) &lv_draw_mask_map_init, "", "(lv_draw_mask_map_param)(lv_area)(lv_opa)" },
|
||||
{ "draw_mask_radius_init", (void*) &lv_draw_mask_radius_init, "", "(lv_draw_mask_radius_param)(lv_area)ib" },
|
||||
{ "draw_mask_remove_custom", (void*) &lv_draw_mask_remove_custom, ".", "." },
|
||||
|
@ -63,6 +63,7 @@ const lvbe_call_c_t lv_func[] = {
|
|||
{ "get_ver_res", (void*) &lv_get_ver_res, "i", "" },
|
||||
{ "layer_sys", (void*) &lv_layer_sys, "lv_obj", "" },
|
||||
{ "layer_top", (void*) &lv_layer_top, "lv_obj", "" },
|
||||
{ "refr_now", (void*) &lv_refr_now, "", "" },
|
||||
{ "scr_act", (void*) &lv_scr_act, "lv_obj", "" },
|
||||
{ "scr_load", (void*) &lv_scr_load, "", "(lv_obj)" },
|
||||
{ "scr_load_anim", (void*) &lv_scr_load_anim, "", "(lv_obj)(lv_scr_load_anim)iib" },
|
||||
|
@ -171,6 +172,13 @@ const be_constint_t lv0_constants[] = {
|
|||
{ "CPICKER_TYPE_DISC", LV_CPICKER_TYPE_DISC },
|
||||
{ "CPICKER_TYPE_RECT", LV_CPICKER_TYPE_RECT },
|
||||
{ "CYAN", 65535 },
|
||||
{ "DESIGN_COVER_CHK", LV_DESIGN_COVER_CHK },
|
||||
{ "DESIGN_DRAW_MAIN", LV_DESIGN_DRAW_MAIN },
|
||||
{ "DESIGN_DRAW_POST", LV_DESIGN_DRAW_POST },
|
||||
{ "DESIGN_RES_COVER", LV_DESIGN_RES_COVER },
|
||||
{ "DESIGN_RES_MASKED", LV_DESIGN_RES_MASKED },
|
||||
{ "DESIGN_RES_NOT_COVER", LV_DESIGN_RES_NOT_COVER },
|
||||
{ "DESIGN_RES_OK", LV_DESIGN_RES_OK },
|
||||
{ "DISP_ROT_180", LV_DISP_ROT_180 },
|
||||
{ "DISP_ROT_270", LV_DISP_ROT_270 },
|
||||
{ "DISP_ROT_90", LV_DISP_ROT_90 },
|
||||
|
@ -257,6 +265,21 @@ const be_constint_t lv0_constants[] = {
|
|||
{ "GRAD_DIR_VER", LV_GRAD_DIR_VER },
|
||||
{ "GRAY", 8421504 },
|
||||
{ "GREEN", 32768 },
|
||||
{ "IMG_CF_ALPHA_1BIT", LV_IMG_CF_ALPHA_1BIT },
|
||||
{ "IMG_CF_ALPHA_2BIT", LV_IMG_CF_ALPHA_2BIT },
|
||||
{ "IMG_CF_ALPHA_4BIT", LV_IMG_CF_ALPHA_4BIT },
|
||||
{ "IMG_CF_ALPHA_8BIT", LV_IMG_CF_ALPHA_8BIT },
|
||||
{ "IMG_CF_INDEXED_1BIT", LV_IMG_CF_INDEXED_1BIT },
|
||||
{ "IMG_CF_INDEXED_2BIT", LV_IMG_CF_INDEXED_2BIT },
|
||||
{ "IMG_CF_INDEXED_4BIT", LV_IMG_CF_INDEXED_4BIT },
|
||||
{ "IMG_CF_INDEXED_8BIT", LV_IMG_CF_INDEXED_8BIT },
|
||||
{ "IMG_CF_RAW", LV_IMG_CF_RAW },
|
||||
{ "IMG_CF_RAW_ALPHA", LV_IMG_CF_RAW_ALPHA },
|
||||
{ "IMG_CF_RAW_CHROMA_KEYED", LV_IMG_CF_RAW_CHROMA_KEYED },
|
||||
{ "IMG_CF_TRUE_COLOR", LV_IMG_CF_TRUE_COLOR },
|
||||
{ "IMG_CF_TRUE_COLOR_ALPHA", LV_IMG_CF_TRUE_COLOR_ALPHA },
|
||||
{ "IMG_CF_TRUE_COLOR_CHROMA_KEYED", LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED },
|
||||
{ "IMG_CF_UNKNOWN", LV_IMG_CF_UNKNOWN },
|
||||
{ "INDEV_STATE_PR", LV_INDEV_STATE_PR },
|
||||
{ "INDEV_STATE_REL", LV_INDEV_STATE_REL },
|
||||
{ "KEYBOARD_MODE_NUM", LV_KEYBOARD_MODE_NUM },
|
||||
|
@ -345,6 +368,7 @@ const be_constint_t lv0_constants[] = {
|
|||
{ "PROTECT_POS", LV_PROTECT_POS },
|
||||
{ "PROTECT_PRESS_LOST", LV_PROTECT_PRESS_LOST },
|
||||
{ "PURPLE", 8388736 },
|
||||
{ "RADIUS_CIRCLE", 32767 },
|
||||
{ "RED", 16711680 },
|
||||
{ "ROLLER_MODE_INFINITE", LV_ROLLER_MODE_INFINITE },
|
||||
{ "ROLLER_MODE_NORMAL", LV_ROLLER_MODE_NORMAL },
|
||||
|
|
|
@ -852,6 +852,7 @@ extern int lvbe_msgbox_get_btnmatrix(bvm *vm);
|
|||
|
||||
/* `lv_objmask` external functions definitions */
|
||||
extern int lvbe_objmask_create(bvm *vm);
|
||||
extern int lvbe_objmask_add_mask(bvm *vm);
|
||||
extern int lvbe_objmask_update_mask(bvm *vm);
|
||||
extern int lvbe_objmask_remove_mask(bvm *vm);
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@
|
|||
* expanded if the number of free is less than BE_STACK_FREE_MIN.
|
||||
* Default: 10
|
||||
**/
|
||||
#define BE_STACK_FREE_MIN 10
|
||||
#define BE_STACK_FREE_MIN 25
|
||||
|
||||
/* Macro: BE_STACK_FREE_MIN
|
||||
* The short string will hold the hash value when the value is
|
||||
|
|
|
@ -29,7 +29,7 @@ const char* be_vtype2str(bvalue *v)
|
|||
case BE_MAP: return "map";
|
||||
case BE_INSTANCE: return "instance";
|
||||
case BE_MODULE: return "module";
|
||||
case BE_INDEX: return "index";
|
||||
case BE_INDEX: return "var";
|
||||
default: return "invalid type";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1255,7 +1255,7 @@ static void class_static_assignment_expr(bparser *parser, bexpdesc *e, bstring *
|
|||
static void classstatic_stmt(bparser *parser, bclass *c, bexpdesc *e)
|
||||
{
|
||||
bstring *name;
|
||||
/* 'static' ID {',' ID} */
|
||||
/* 'static' ID ['=' expr] {',' ID ['=' expr] } */
|
||||
scan_next_token(parser); /* skip 'static' */
|
||||
if (match_id(parser, name) != NULL) {
|
||||
check_class_attr(parser, c, name);
|
||||
|
|
|
@ -43,10 +43,10 @@ static void m_solidify_bvalue(bvm *vm, bvalue * value)
|
|||
logfmt("be_const_bool(%i)", var_tobool(value));
|
||||
break;
|
||||
case BE_INT:
|
||||
logfmt("be_const_int(%lli)", var_toint(value));
|
||||
logfmt("be_const_int(%i)", var_toint(value));
|
||||
break;
|
||||
case BE_INDEX:
|
||||
logfmt("be_const_index(%lli)", var_toint(value));
|
||||
logfmt("be_const_index(%i)", var_toint(value));
|
||||
break;
|
||||
case BE_REAL:
|
||||
#if BE_USE_SINGLE_FLOAT
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
#- LVGL Examples
|
||||
-
|
||||
- drawing example #1 from https://docs.lvgl.io/latest/en/html/overview/drawing.html
|
||||
--#
|
||||
lv.start()
|
||||
|
||||
lv.scr_act().set_style_local_bg_color(lv.OBJ_PART_MAIN, lv.STATE_DEFAULT, lv_color(0xFF3333))
|
||||
|
||||
om = lv_objmask(lv.scr_act())
|
||||
om.set_size(200, 200)
|
||||
om.align(0, lv.ALIGN_CENTER, 0, 0)
|
||||
label = lv_label(om)
|
||||
label.set_long_mode(lv.LABEL_LONG_BREAK)
|
||||
label.set_align(lv.LABEL_ALIGN_CENTER)
|
||||
label.set_width(180)
|
||||
label.set_text("This label will be masked out. See how it works.")
|
||||
label.align(0, lv.ALIGN_IN_TOP_MID, 0, 20)
|
||||
|
||||
cont = lv_cont(om)
|
||||
cont.set_size(180, 100)
|
||||
cont.set_drag(true)
|
||||
cont.align(0, lv.ALIGN_IN_BOTTOM_MID, 0, -10)
|
||||
|
||||
btn = lv_btn(cont)
|
||||
btn.align(0, lv.ALIGN_CENTER, 0, 0)
|
||||
btn.set_style_local_value_str(lv.OBJ_PART_MAIN, lv.STATE_DEFAULT, "Button")
|
||||
|
||||
lv.refr_now()
|
||||
tasmota.delay(1000)
|
||||
|
||||
a=lv_area()
|
||||
r1 = lv_draw_mask_radius_param()
|
||||
|
||||
a.x1 = 10
|
||||
a.y1 = 10
|
||||
a.x2 = 190
|
||||
a.y2 = 190
|
||||
lv.draw_mask_radius_init(r1, a, lv.RADIUS_CIRCLE, false)
|
||||
om.add_mask(r1)
|
||||
|
||||
lv.refr_now()
|
||||
tasmota.delay(1000)
|
||||
|
||||
a.x1 = 100
|
||||
a.y1 = 100
|
||||
a.x2 = 150
|
||||
a.y2 = 150
|
||||
lv.draw_mask_radius_init(r1, a, lv.RADIUS_CIRCLE, true)
|
||||
om.add_mask(r1)
|
||||
|
||||
lv.refr_now()
|
||||
tasmota.delay(1000)
|
||||
|
||||
l1 = lv_draw_mask_line_param()
|
||||
lv.draw_mask_line_points_init(l1, 0, 0, 100, 200, lv.DRAW_MASK_LINE_SIDE_TOP)
|
||||
om.add_mask(l1)
|
||||
|
||||
lv.refr_now()
|
||||
tasmota.delay(1000)
|
||||
|
||||
f1= lv_draw_mask_fade_param()
|
||||
a.x1 = 100
|
||||
a.y1 = 0
|
||||
a.x2 = 200
|
||||
a.y2 = 200
|
||||
lv.draw_mask_fade_init(f1, a, lv.OPA_TRANSP, 0, lv.OPA_COVER, 150)
|
||||
om.add_mask(f1)
|
|
@ -0,0 +1,58 @@
|
|||
#- LVGL Examples
|
||||
-
|
||||
- drawing example #2 from https://docs.lvgl.io/latest/en/html/overview/drawing.html
|
||||
--#
|
||||
lv.start()
|
||||
|
||||
lv.scr_act().set_style_local_bg_color(lv.OBJ_PART_MAIN, lv.STATE_DEFAULT, lv_color(0xAAAAAA))
|
||||
|
||||
MASK_WIDTH=100
|
||||
MASK_HEIGHT=50
|
||||
|
||||
# Create the mask of a text by drawing it to a canvas
|
||||
mask_map = bytes()
|
||||
mask_map.resize(MASK_WIDTH * MASK_HEIGHT * 4)
|
||||
|
||||
# Create a "8 bit alpha" canvas and clear it
|
||||
canvas = lv_canvas(lv.scr_act())
|
||||
canvas.set_buffer(mask_map, MASK_WIDTH, MASK_HEIGHT, lv.IMG_CF_ALPHA_8BIT)
|
||||
canvas.fill_bg(lv_color(lv.BLACK), lv.OPA_TRANSP)
|
||||
canvas.fill_bg(lv_color(lv.BLACK), lv.OPA_50)
|
||||
|
||||
# Draw a label to the canvas. The result "image" will be used as mask
|
||||
label_dsc = lv_draw_label_dsc()
|
||||
lv.draw_label_dsc_init(label_dsc)
|
||||
label_dsc.color = lv_color(lv.WHITE)
|
||||
canvas.draw_text(5, 5, MASK_WIDTH, label_dsc, "Text with gradient", lv.LABEL_ALIGN_CENTER)
|
||||
|
||||
# The mask is read, the canvas is not required anymore
|
||||
canvas.del()
|
||||
|
||||
# Create an object mask which will use the created mask
|
||||
om = lv_objmask(lv.scr_act())
|
||||
om.set_size(MASK_WIDTH, MASK_HEIGHT)
|
||||
om.align(0, lv.ALIGN_CENTER, 0, 0)
|
||||
|
||||
# Add the created mask map to the object mask
|
||||
m = lv_draw_mask_map_param()
|
||||
a = lv_area()
|
||||
a.x1 = 0
|
||||
a.y1 = 0
|
||||
a.x2 = MASK_WIDTH - 1
|
||||
a.y2 = MASK_HEIGHT - 1
|
||||
lv.draw_mask_map_init(m, a, mask_map)
|
||||
om.add_mask(m)
|
||||
|
||||
# Create a style with gradient
|
||||
style_bg = lv_style()
|
||||
style_bg.set_bg_opa(lv.STATE_DEFAULT, lv.OPA_COVER)
|
||||
style_bg.set_bg_color(lv.STATE_DEFAULT, lv_color(lv.RED))
|
||||
style_bg.set_bg_grad_color(lv.STATE_DEFAULT, lv_color(lv.BLUE))
|
||||
style_bg.set_bg_grad_dir(lv.STATE_DEFAULT, lv.GRAD_DIR_HOR)
|
||||
|
||||
# Create and object with the gradient style on the object mask.
|
||||
# The text will be masked from the gradient
|
||||
bg = lv_obj(om)
|
||||
bg.reset_style_list(lv.OBJ_PART_MAIN)
|
||||
bg.add_style(lv.OBJ_PART_MAIN, style_bg)
|
||||
bg.set_size(MASK_WIDTH, MASK_HEIGHT)
|
|
@ -0,0 +1,65 @@
|
|||
#- LVGL Examples
|
||||
-
|
||||
- drawing example #1 from https://docs.lvgl.io/latest/en/html/overview/drawing.html
|
||||
--#
|
||||
|
||||
lv.start()
|
||||
|
||||
def max(a,b) if a > b return a else return b end end
|
||||
|
||||
class lv_signal_bars : lv_obj
|
||||
var ancestor_design # previous design_cb
|
||||
var percentage
|
||||
|
||||
def init(parent, copy)
|
||||
# init parent object
|
||||
super(self, lv_obj).init(parent, copy)
|
||||
# keep a copy of
|
||||
self.ancestor_design = self.get_design_cb()
|
||||
self.set_design_cb(self.my_design_cb)
|
||||
# own values
|
||||
self.percentage = 100
|
||||
# set default style
|
||||
self.set_style_local_bg_opa(lv.OBJ_PART_MAIN, lv.STATE_DEFAULT, lv.OPA_TRANSP)
|
||||
end
|
||||
|
||||
def my_design_cb(area, mode)
|
||||
# the model is that we have 4 bars and inter-bar (1/4 of width)
|
||||
var height = self.get_height()
|
||||
var width = self.get_width()
|
||||
|
||||
var inter_bar = max(width / 15, 1)
|
||||
var bar = max((width - inter_bar * 3) / 4, 1)
|
||||
var bar_offset = bar / 2
|
||||
|
||||
if mode == lv.DESIGN_COVER_CHK
|
||||
#- Return false if the object is not covers the clip_area area -#
|
||||
return self.ancestor_design.call(self, area, mode)
|
||||
|
||||
elif mode == lv.DESIGN_DRAW_MAIN
|
||||
self.ancestor_design.call(self, area, mode)
|
||||
var line_dsc = lv_draw_line_dsc()
|
||||
lv.draw_line_dsc_init(line_dsc)
|
||||
|
||||
line_dsc.round_start = 1
|
||||
line_dsc.round_end = 1
|
||||
line_dsc.width = bar
|
||||
line_dsc.color = 0xF0F
|
||||
var p1 = lv_point()
|
||||
var p2 = lv_point()
|
||||
|
||||
for i:0..3
|
||||
p1.y = height - 1 - bar_offset
|
||||
p1.x = i * (bar + inter_bar) + bar_offset
|
||||
p2.y = ((3 - i) * (height - bar)) / 4 + bar_offset
|
||||
p2.x = p1.x
|
||||
lv.draw_line(p1, p2, area, line_dsc)
|
||||
end
|
||||
#elif mode == lv.DESIGN_DRAW_POST # we don't want a frame around this object
|
||||
#self.ancestor_design.call(self, area, mode)
|
||||
end
|
||||
return lv.DESIGN_RES_OK
|
||||
end
|
||||
end
|
||||
|
||||
bars = lv_signal_bars(lv.scr_act())
|
|
@ -160,6 +160,7 @@ class Partition_info
|
|||
end
|
||||
|
||||
def tostring()
|
||||
import string
|
||||
var type_s = ""
|
||||
var subtype_s = ""
|
||||
if self.type == 0 type_s = "app"
|
||||
|
|
|
@ -13,15 +13,15 @@ extern "C" {
|
|||
#if BE_LV_WIDGET_IMG
|
||||
const lvbe_call_c_t lv_img_func[] = {
|
||||
{ "buf_free", (void*) &lv_img_buf_free, "", "(lv_img_dsc)" },
|
||||
{ "buf_get_img_size", (void*) &lv_img_buf_get_img_size, "i", "ii(lv_img_cf)" },
|
||||
{ "buf_get_img_size", (void*) &lv_img_buf_get_img_size, "i", "iii" },
|
||||
{ "buf_get_px_alpha", (void*) &lv_img_buf_get_px_alpha, "i", "(lv_img_dsc)ii" },
|
||||
{ "buf_get_px_color", (void*) &lv_img_buf_get_px_color, "lv_color", "(lv_img_dsc)ii(lv_color)" },
|
||||
{ "buf_set_palette", (void*) &lv_img_buf_set_palette, "", "(lv_img_dsc)i(lv_color)" },
|
||||
{ "buf_set_px_alpha", (void*) &lv_img_buf_set_px_alpha, "", "(lv_img_dsc)iii" },
|
||||
{ "buf_set_px_color", (void*) &lv_img_buf_set_px_color, "", "(lv_img_dsc)ii(lv_color)" },
|
||||
{ "cf_get_px_size", (void*) &lv_img_cf_get_px_size, "i", "(lv_img_cf)" },
|
||||
{ "cf_has_alpha", (void*) &lv_img_cf_has_alpha, "b", "(lv_img_cf)" },
|
||||
{ "cf_is_chroma_keyed", (void*) &lv_img_cf_is_chroma_keyed, "b", "(lv_img_cf)" },
|
||||
{ "cf_get_px_size", (void*) &lv_img_cf_get_px_size, "i", "i" },
|
||||
{ "cf_has_alpha", (void*) &lv_img_cf_has_alpha, "b", "i" },
|
||||
{ "cf_is_chroma_keyed", (void*) &lv_img_cf_is_chroma_keyed, "b", "i" },
|
||||
{ "create", (void*) &lv_img_create, "+lv_img", "(lv_obj)(lv_obj)" },
|
||||
{ "get_angle", (void*) &lv_img_get_angle, "i", "(lv_obj)" },
|
||||
{ "get_antialias", (void*) &lv_img_get_antialias, "b", "(lv_obj)" },
|
||||
|
@ -612,7 +612,7 @@ const lvbe_call_c_t lv_canvas_func[] = {
|
|||
{ "draw_text", (void*) &lv_canvas_draw_text, "", "(lv_obj)iii(lv_draw_label_dsc)si" },
|
||||
{ "fill_bg", (void*) &lv_canvas_fill_bg, "", "(lv_obj)(lv_color)i" },
|
||||
{ "get_px", (void*) &lv_canvas_get_px, "lv_color", "(lv_obj)ii" },
|
||||
{ "set_buffer", (void*) &lv_canvas_set_buffer, "", "(lv_obj).ii(lv_img_cf)" },
|
||||
{ "set_buffer", (void*) &lv_canvas_set_buffer, "", "(lv_obj).iii" },
|
||||
{ "set_palette", (void*) &lv_canvas_set_palette, "", "(lv_obj)i(lv_color)" },
|
||||
{ "set_px", (void*) &lv_canvas_set_px, "", "(lv_obj)ii(lv_color)" },
|
||||
{ "transform", (void*) &lv_canvas_transform, "", "(lv_obj)(lv_img_dsc)iiiiiib" },
|
||||
|
@ -927,9 +927,10 @@ const lvbe_call_c_t lv_msgbox_func[] = {
|
|||
/* `lv_objmask` methods */
|
||||
#if BE_LV_WIDGET_OBJMASK
|
||||
const lvbe_call_c_t lv_objmask_func[] = {
|
||||
{ "add_mask", (void*) &lv_objmask_add_mask, ".", "(lv_obj)." },
|
||||
{ "create", (void*) &lv_objmask_create, "+lv_objmask", "(lv_obj)(lv_obj)" },
|
||||
{ "remove_mask", (void*) &lv_objmask_remove_mask, "", "(lv_obj)(lv_objmask_mask)" },
|
||||
{ "update_mask", (void*) &lv_objmask_update_mask, "", "(lv_obj)(lv_objmask_mask)." },
|
||||
{ "remove_mask", (void*) &lv_objmask_remove_mask, "", "(lv_obj)." },
|
||||
{ "update_mask", (void*) &lv_objmask_update_mask, "", "(lv_obj).." },
|
||||
};
|
||||
#endif // BE_LV_WIDGET_OBJMASK
|
||||
|
||||
|
|
|
@ -209,6 +209,7 @@ extern "C" {
|
|||
extern "C" {
|
||||
|
||||
typedef int32_t (*berry_callback_t)(int32_t v0, int32_t v1, int32_t v2, int32_t v3);
|
||||
extern void BerryDumpErrorAndClear(bvm *vm, bool berry_console);
|
||||
|
||||
int32_t call_berry_cb(int32_t num, int32_t v0, int32_t v1, int32_t v2, int32_t v3) {
|
||||
// call berry cb dispatcher
|
||||
|
@ -227,7 +228,11 @@ extern "C" {
|
|||
be_pushint(berry.vm, v2);
|
||||
be_pushint(berry.vm, v3);
|
||||
|
||||
be_pcall(berry.vm, 6); // 5 arguments
|
||||
ret = be_pcall(berry.vm, 6); // 5 arguments
|
||||
if (ret != 0) {
|
||||
BerryDumpErrorAndClear(berry.vm, false); // log in Tasmota console only
|
||||
return 0;
|
||||
}
|
||||
be_pop(berry.vm, 6);
|
||||
|
||||
if (be_isint(berry.vm, -1) || be_isnil(berry.vm, -1)) { // sanity check
|
||||
|
@ -381,8 +386,12 @@ int32_t lvbe_callback_x(uint32_t n, struct _lv_obj_t * obj, int32_t v1, int32_t
|
|||
be_pushint(berry.vm, v2);
|
||||
be_pushint(berry.vm, v3);
|
||||
be_pushint(berry.vm, v4);
|
||||
be_pcall(berry.vm, 6);
|
||||
int32_t ret = be_toint(berry.vm, -7);
|
||||
int32_t ret = be_pcall(berry.vm, 6);
|
||||
if (ret != 0) {
|
||||
BerryDumpErrorAndClear(berry.vm, false); // log in Tasmota console only
|
||||
return 0;
|
||||
}
|
||||
ret = be_toint(berry.vm, -7);
|
||||
be_pop(berry.vm, 7);
|
||||
// berry_log_P(">>>: Callback called out %d ret=%i", n, ret);
|
||||
return ret;
|
||||
|
|
|
@ -226,8 +226,8 @@ extern void lv_ex_get_started_1(void);
|
|||
// - a callback, only 6 callbacks supported 0..5
|
||||
// - '&1' callback 1
|
||||
//
|
||||
void be_check_arg_type(bvm *vm, int32_t argc, const char * arg_type, int32_t p[5]);
|
||||
void be_check_arg_type(bvm *vm, int32_t argc, const char * arg_type, int32_t p[5]) {
|
||||
void be_check_arg_type(bvm *vm, int32_t argc, const char * arg_type, int32_t p[8]);
|
||||
void be_check_arg_type(bvm *vm, int32_t argc, const char * arg_type, int32_t p[8]) {
|
||||
bool arg_type_check = (arg_type != nullptr); // is type checking activated
|
||||
int32_t arg_idx = 0; // position in arg_type string
|
||||
char type_short_name[32];
|
||||
|
@ -278,7 +278,8 @@ void be_check_arg_type(bvm *vm, int32_t argc, const char * arg_type, int32_t p[5
|
|||
}
|
||||
}
|
||||
|
||||
typedef int32_t (*fn_any_callable)(int32_t p0, int32_t p1, int32_t p2, int32_t p3, int32_t p4);
|
||||
typedef int32_t (*fn_any_callable)(int32_t p0, int32_t p1, int32_t p2, int32_t p3,
|
||||
int32_t p4, int32_t p5, int32_t p6, int32_t p7);
|
||||
extern "C" {
|
||||
|
||||
void lv_init_set_member(bvm *vm, int index, void * ptr);
|
||||
|
@ -303,7 +304,7 @@ extern "C" {
|
|||
if ((int32_t)obj2 == -1) { // special semantics if second ptr is -1, then just encapsulate
|
||||
obj = obj1;
|
||||
} else { // otherwise call the LVGL creator
|
||||
obj = (lv_obj_t*) (*f)((int32_t)obj1, (int32_t)obj2, 0, 0, 0);
|
||||
obj = (lv_obj_t*) (*f)((int32_t)obj1, (int32_t)obj2, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
lv_init_set_member(vm, 1, obj);
|
||||
be_return_nil(vm);
|
||||
|
@ -379,7 +380,7 @@ extern "C" {
|
|||
}
|
||||
|
||||
int be_call_c_func(bvm *vm, void * func, const char * return_type, const char * arg_type) {
|
||||
int32_t p[5] = {0,0,0,0,0};
|
||||
int32_t p[8] = {0,0,0,0,0,0,0,0};
|
||||
int32_t argc = be_top(vm); // Get the number of arguments
|
||||
|
||||
// check if we call a constructor
|
||||
|
@ -391,7 +392,7 @@ extern "C" {
|
|||
fn_any_callable f = (fn_any_callable) func;
|
||||
be_check_arg_type(vm, argc, arg_type, p);
|
||||
// berry_log_C(">> be_call_c_func(%p) - %p,%p,%p,%p,%p - %s", f, p[0], p[1], p[2], p[3], p[4], return_type ? return_type : "NULL");
|
||||
int32_t ret = (*f)(p[0], p[1], p[2], p[3], p[4]);
|
||||
int32_t ret = (*f)(p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
|
||||
// AddLog(LOG_LEVEL_INFO, ">> be_call_c_func, ret = %p", ret);
|
||||
if ((return_type == nullptr) || (strlen(return_type) == 0)) { be_return_nil(vm); } // does not return
|
||||
else if (strlen(return_type) == 1) {
|
||||
|
|
|
@ -39,6 +39,8 @@ return_types = {
|
|||
"const char *": "s",
|
||||
"lv_obj_user_data_t": "i",
|
||||
|
||||
"lv_objmask_mask_t *": ".",
|
||||
|
||||
"lv_coord_t": "i",
|
||||
"lv_res_t": "i",
|
||||
"lv_style_int_t": "i",
|
||||
|
@ -78,6 +80,8 @@ return_types = {
|
|||
"lv_indev_type_t": "i",
|
||||
"lv_event_t": "i",
|
||||
"lv_signal_t": "i",
|
||||
"lv_img_cf_t": "i",
|
||||
"lv_draw_mask_line_side_t": "i",
|
||||
|
||||
# "lv_signal_cb_t": "c",
|
||||
# "lv_design_cb_t": "c",
|
||||
|
|
|
@ -18,6 +18,7 @@ NAVY=0x000080
|
|||
MAGENTA=0xFF00FF
|
||||
PURPLE=0x800080
|
||||
|
||||
LV_RADIUS_CIRCLE=0x7FFF
|
||||
//
|
||||
LV_SCR_LOAD_ANIM_NONE
|
||||
LV_SCR_LOAD_ANIM_OVER_LEFT
|
||||
|
@ -633,3 +634,36 @@ LV_DRAW_MASK_LINE_SIDE_LEFT
|
|||
LV_DRAW_MASK_LINE_SIDE_RIGHT
|
||||
LV_DRAW_MASK_LINE_SIDE_TOP
|
||||
LV_DRAW_MASK_LINE_SIDE_BOTTOM
|
||||
|
||||
// LV IMG
|
||||
|
||||
LV_IMG_CF_UNKNOWN
|
||||
|
||||
LV_IMG_CF_RAW
|
||||
LV_IMG_CF_RAW_ALPHA
|
||||
LV_IMG_CF_RAW_CHROMA_KEYED
|
||||
|
||||
LV_IMG_CF_TRUE_COLOR
|
||||
LV_IMG_CF_TRUE_COLOR_ALPHA
|
||||
LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED
|
||||
|
||||
LV_IMG_CF_INDEXED_1BIT
|
||||
LV_IMG_CF_INDEXED_2BIT
|
||||
LV_IMG_CF_INDEXED_4BIT
|
||||
LV_IMG_CF_INDEXED_8BIT
|
||||
|
||||
LV_IMG_CF_ALPHA_1BIT
|
||||
LV_IMG_CF_ALPHA_2BIT
|
||||
LV_IMG_CF_ALPHA_4BIT
|
||||
LV_IMG_CF_ALPHA_8BIT
|
||||
|
||||
// Design modes
|
||||
|
||||
LV_DESIGN_DRAW_MAIN
|
||||
LV_DESIGN_DRAW_POST
|
||||
LV_DESIGN_COVER_CHK
|
||||
|
||||
LV_DESIGN_RES_OK
|
||||
LV_DESIGN_RES_COVER
|
||||
LV_DESIGN_RES_NOT_COVER
|
||||
LV_DESIGN_RES_MASKED
|
||||
|
|
|
@ -1241,3 +1241,9 @@ uint32_t lv_img_buf_get_img_size(lv_coord_t w, lv_coord_t h, lv_img_cf_t cf);
|
|||
// void lv_img_cache_set_size(uint16_t new_slot_num);
|
||||
// void lv_img_cache_invalidate_src(const void * src);
|
||||
|
||||
|
||||
// ======================================================================
|
||||
// Artificial
|
||||
// ======================================================================
|
||||
|
||||
void lv_refr_now(void);
|
||||
|
|
Loading…
Reference in New Issue