mirror of https://github.com/arendst/Tasmota.git
Small fixes to animate module (#20238)
This commit is contained in:
parent
c1f8ee5dbb
commit
d6bf19190f
|
@ -111,8 +111,7 @@ module animate (scope: global, strings: weak) {
|
|||
PALETTE_STANDARD_VAL, comptr(PALETTE_STANDARD_VAL)
|
||||
PALETTE_SATURATED_TAG, comptr(PALETTE_SATURATED_TAG)
|
||||
|
||||
(), class(be_class_Animate_core)
|
||||
core, class(be_class_Animate_core) // alias
|
||||
core, class(be_class_Animate_core)
|
||||
animator, class(be_class_Animate_animator)
|
||||
frame, class(be_class_Leds_frame)
|
||||
pulse, class(be_class_Animate_pulse)
|
||||
|
|
|
@ -22,8 +22,8 @@ class Animate_core
|
|||
static var FAST_LOOP_MIN = 20
|
||||
var fast_loop_next # next time-stamp for fast_loop
|
||||
# cb for animation
|
||||
var animate_object # object called at each tick
|
||||
var animate_method # method of object called at each tick
|
||||
var obj # object called at each tick
|
||||
var mth # method of object called at each tick
|
||||
# frame ojects
|
||||
var frame # Leds_frame frame object
|
||||
var layer # Leds_frame for layer on top of frame
|
||||
|
@ -101,8 +101,8 @@ class Animate_core
|
|||
end
|
||||
|
||||
def set_cb(obj, method)
|
||||
self.animate_object = obj
|
||||
self.animate_method = method
|
||||
self.obj = obj
|
||||
self.mth = method
|
||||
end
|
||||
|
||||
def fast_loop()
|
||||
|
@ -136,8 +136,8 @@ class Animate_core
|
|||
i += 1
|
||||
end
|
||||
# tirgger animate and display
|
||||
var obj = self.animate_object
|
||||
var mth = self.animate_method
|
||||
var obj = self.obj
|
||||
var mth = self.mth
|
||||
if (obj && mth)
|
||||
mth(obj)
|
||||
end
|
||||
|
|
|
@ -164,33 +164,6 @@ be_local_closure(Animate_core_animate, /* name */
|
|||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: get_bri
|
||||
********************************************************************/
|
||||
be_local_closure(Animate_core_get_bri, /* name */
|
||||
be_nested_proto(
|
||||
3, /* nstack */
|
||||
2, /* argc */
|
||||
2, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 1]) { /* constants */
|
||||
/* K0 */ be_nested_str_weak(bri),
|
||||
}),
|
||||
be_str_weak(get_bri),
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 2]) { /* code */
|
||||
0x88080100, // 0000 GETMBR R2 R0 K0
|
||||
0x80040400, // 0001 RET 1 R2
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: set_bri
|
||||
********************************************************************/
|
||||
|
@ -218,33 +191,6 @@ be_local_closure(Animate_core_set_bri, /* name */
|
|||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: set_back_color
|
||||
********************************************************************/
|
||||
be_local_closure(Animate_core_set_back_color, /* name */
|
||||
be_nested_proto(
|
||||
2, /* nstack */
|
||||
2, /* argc */
|
||||
2, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 1]) { /* constants */
|
||||
/* K0 */ be_nested_str_weak(back_color),
|
||||
}),
|
||||
be_str_weak(set_back_color),
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 2]) { /* code */
|
||||
0x90020001, // 0000 SETMBR R0 K0 R1
|
||||
0x80000000, // 0001 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: stop
|
||||
********************************************************************/
|
||||
|
@ -296,6 +242,33 @@ be_local_closure(Animate_core_stop, /* name */
|
|||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: set_back_color
|
||||
********************************************************************/
|
||||
be_local_closure(Animate_core_set_back_color, /* name */
|
||||
be_nested_proto(
|
||||
2, /* nstack */
|
||||
2, /* argc */
|
||||
2, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 1]) { /* constants */
|
||||
/* K0 */ be_nested_str_weak(back_color),
|
||||
}),
|
||||
be_str_weak(set_back_color),
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 2]) { /* code */
|
||||
0x90020001, // 0000 SETMBR R0 K0 R1
|
||||
0x80000000, // 0001 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: set_cb
|
||||
********************************************************************/
|
||||
|
@ -310,8 +283,8 @@ be_local_closure(Animate_core_set_cb, /* name */
|
|||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 2]) { /* constants */
|
||||
/* K0 */ be_nested_str_weak(animate_object),
|
||||
/* K1 */ be_nested_str_weak(animate_method),
|
||||
/* K0 */ be_nested_str_weak(obj),
|
||||
/* K1 */ be_nested_str_weak(mth),
|
||||
}),
|
||||
be_str_weak(set_cb),
|
||||
&be_const_str_solidified,
|
||||
|
@ -450,6 +423,33 @@ be_local_closure(Animate_core_add_painter, /* name */
|
|||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: get_bri
|
||||
********************************************************************/
|
||||
be_local_closure(Animate_core_get_bri, /* name */
|
||||
be_nested_proto(
|
||||
3, /* nstack */
|
||||
2, /* argc */
|
||||
2, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 1]) { /* constants */
|
||||
/* K0 */ be_nested_str_weak(bri),
|
||||
}),
|
||||
be_str_weak(get_bri),
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 2]) { /* code */
|
||||
0x88080100, // 0000 GETMBR R2 R0 K0
|
||||
0x80040400, // 0001 RET 1 R2
|
||||
})
|
||||
)
|
||||
);
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified function: fast_loop
|
||||
********************************************************************/
|
||||
|
@ -484,8 +484,8 @@ be_local_closure(Animate_core_fast_loop, /* name */
|
|||
/* K17 */ be_const_int(-16777216),
|
||||
/* K18 */ be_nested_str_weak(paint),
|
||||
/* K19 */ be_nested_str_weak(blend_pixels),
|
||||
/* K20 */ be_nested_str_weak(animate_object),
|
||||
/* K21 */ be_nested_str_weak(animate_method),
|
||||
/* K20 */ be_nested_str_weak(obj),
|
||||
/* K21 */ be_nested_str_weak(mth),
|
||||
/* K22 */ be_nested_str_weak(paste_pixels),
|
||||
/* K23 */ be_nested_str_weak(pixels_buffer),
|
||||
/* K24 */ be_nested_str_weak(bri),
|
||||
|
@ -644,31 +644,31 @@ be_local_class(Animate_core,
|
|||
NULL,
|
||||
be_nested_map(28,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_const_key_weak(bri, 23), be_const_var(2) },
|
||||
{ be_const_key_weak(bri, 8), be_const_var(2) },
|
||||
{ be_const_key_weak(remove, -1), be_const_closure(Animate_core_remove_closure) },
|
||||
{ be_const_key_weak(start, 21), be_const_closure(Animate_core_start_closure) },
|
||||
{ be_const_key_weak(start, 11), be_const_closure(Animate_core_start_closure) },
|
||||
{ be_const_key_weak(fast_loop, -1), be_const_closure(Animate_core_fast_loop_closure) },
|
||||
{ be_const_key_weak(add_animator, -1), be_const_closure(Animate_core_add_animator_closure) },
|
||||
{ be_const_key_weak(FAST_LOOP_MIN, 8), be_const_int(20) },
|
||||
{ be_const_key_weak(animate, -1), be_const_closure(Animate_core_animate_closure) },
|
||||
{ be_const_key_weak(FAST_LOOP_MIN, 9), be_const_int(20) },
|
||||
{ be_const_key_weak(obj, -1), be_const_var(8) },
|
||||
{ be_const_key_weak(pixel_count, -1), be_const_var(1) },
|
||||
{ be_const_key_weak(animate, -1), be_const_closure(Animate_core_animate_closure) },
|
||||
{ be_const_key_weak(animators, -1), be_const_var(4) },
|
||||
{ be_const_key_weak(back_color, 11), be_const_var(12) },
|
||||
{ be_const_key_weak(fast_loop_cb, 12), be_const_var(6) },
|
||||
{ be_const_key_weak(fast_loop_cb, -1), be_const_var(6) },
|
||||
{ be_const_key_weak(get_bri, 24), be_const_closure(Animate_core_get_bri_closure) },
|
||||
{ be_const_key_weak(back_color, 13), be_const_var(12) },
|
||||
{ be_const_key_weak(frame, -1), be_const_var(10) },
|
||||
{ be_const_key_weak(animate_object, -1), be_const_var(8) },
|
||||
{ be_const_key_weak(stop, -1), be_const_closure(Animate_core_stop_closure) },
|
||||
{ be_const_key_weak(set_cb, 23), be_const_closure(Animate_core_set_cb_closure) },
|
||||
{ be_const_key_weak(init, -1), be_const_closure(Animate_core_init_closure) },
|
||||
{ be_const_key_weak(set_cb, 13), be_const_closure(Animate_core_set_cb_closure) },
|
||||
{ be_const_key_weak(running, -1), be_const_var(3) },
|
||||
{ be_const_key_weak(strip, 15), be_const_var(0) },
|
||||
{ be_const_key_weak(running, 21), be_const_var(3) },
|
||||
{ be_const_key_weak(strip, 14), be_const_var(0) },
|
||||
{ be_const_key_weak(fast_loop_next, -1), be_const_var(7) },
|
||||
{ be_const_key_weak(set_back_color, 14), be_const_closure(Animate_core_set_back_color_closure) },
|
||||
{ be_const_key_weak(set_back_color, 15), be_const_closure(Animate_core_set_back_color_closure) },
|
||||
{ be_const_key_weak(add_painter, -1), be_const_closure(Animate_core_add_painter_closure) },
|
||||
{ be_const_key_weak(set_bri, 24), be_const_closure(Animate_core_set_bri_closure) },
|
||||
{ be_const_key_weak(layer, 9), be_const_var(11) },
|
||||
{ be_const_key_weak(animate_method, 6), be_const_var(9) },
|
||||
{ be_const_key_weak(get_bri, -1), be_const_closure(Animate_core_get_bri_closure) },
|
||||
{ be_const_key_weak(mth, -1), be_const_var(9) },
|
||||
{ be_const_key_weak(layer, 12), be_const_var(11) },
|
||||
{ be_const_key_weak(stop, -1), be_const_closure(Animate_core_stop_closure) },
|
||||
{ be_const_key_weak(set_bri, -1), be_const_closure(Animate_core_set_bri_closure) },
|
||||
{ be_const_key_weak(painters, -1), be_const_var(5) },
|
||||
{ be_const_key_weak(clear, 3), be_const_closure(Animate_core_clear_closure) },
|
||||
{ be_const_key_weak(add_background_animator, 2), be_const_closure(Animate_core_add_background_animator_closure) },
|
||||
|
|
|
@ -6,6 +6,6 @@ import animate
|
|||
|
||||
var duration = 10000
|
||||
var strip = Leds(5 * 5, gpio.pin(gpio.WS2812, 0))
|
||||
var anim = animate(strip)
|
||||
var anim = animate.core(strip)
|
||||
anim.add_background_animator(animate.palette(animate.PALETTE_RAINBOW_WHITE, duration))
|
||||
anim.start()
|
||||
|
|
|
@ -6,7 +6,7 @@ import animate
|
|||
|
||||
var duration = 10000
|
||||
var strip = Leds(5 * 5, gpio.pin(gpio.WS2812, 0))
|
||||
var anim = animate(strip)
|
||||
var anim = animate.core(strip)
|
||||
anim.set_back_color(0x2222AA)
|
||||
var pulse = animate.pulse(0xFF4444, 2, 1)
|
||||
var osc1 = animate.oscillator(-3, 26, 5000, animate.COSINE)
|
||||
|
|
Loading…
Reference in New Issue