mirror of https://github.com/arendst/Tasmota.git
Berry fix leds brightness (#20292)
This commit is contained in:
parent
4ac93a4d1a
commit
fbc827d11d
|
@ -24,8 +24,8 @@
|
|||
#include "be_constobj.h"
|
||||
#include "be_mapping.h"
|
||||
|
||||
#include "solidify/solidified_animate_0_core.h"
|
||||
#include "solidify/solidified_animate_1_animate_effects.h"
|
||||
#include "solidify/solidified_animate_1_core.h"
|
||||
#include "solidify/solidified_animate_2_animate_effects.h"
|
||||
#include "solidify/solidified_animate_9_module.h"
|
||||
|
||||
|
||||
|
@ -154,7 +154,6 @@ module animate (scope: global, strings: weak) {
|
|||
TRIANGLE, int(2)
|
||||
SQUARE, int(3)
|
||||
COSINE, int(4)
|
||||
SINE, int(5)
|
||||
LASTFORM, int(5)
|
||||
|
||||
PALETTE_STANDARD_TAG, comptr(PALETTE_STANDARD_TAG)
|
||||
|
@ -182,14 +181,14 @@ module animate (scope: global, strings: weak) {
|
|||
import animate
|
||||
var p, gradient
|
||||
p = animate.palette.ptr_to_palette(animate.PALETTE_STANDARD_TAG)
|
||||
assert(p == bytes('40FF000040FFA50040FFFF004000FF00400000FF40FF00FF40FFFFFF00FF0000'))
|
||||
assert(p == bytes('40FF000040FFA50040FFFF004000FF00400000FF40FF00FF40EE44A500FF0000'))
|
||||
gradient = animate.palette.to_css_gradient(p)
|
||||
assert(gradient == 'background:linear-gradient(to right,#FF0000 0.0%,#FFA500 14.3%,#FFFF00 28.6%,#00FF00 42.9%,#0000FF 57.1%,#FF00FF 71.4%,#FFFFFF 85.7%,#FF0000 100.0%);')
|
||||
assert(gradient == 'background:linear-gradient(to right,#FF0000 0.0%,#FFA500 14.3%,#FFFF00 28.6%,#00FF00 42.9%,#0000FF 57.1%,#FF00FF 71.4%,#EE44A5 85.7%,#FF0000 100.0%);')
|
||||
|
||||
p = animate.palette.ptr_to_palette(animate.PALETTE_STANDARD_VAL)
|
||||
assert(p == bytes('00FF000024FFA50049FFFF006E00FF00920000FFB7FF00FFDBFFFFFFFFFF0000'))
|
||||
assert(p == bytes('00FF00002AFFA50055FFFF007F00FF00AA0000FFD4FF00FFFFFF0000'))
|
||||
gradient = animate.palette.to_css_gradient(animate.PALETTE_STANDARD_VAL)
|
||||
assert(gradient == 'background:linear-gradient(to right,#FF0000 0.0%,#FFA500 14.1%,#FFFF00 28.6%,#00FF00 43.1%,#0000FF 57.3%,#FF00FF 71.8%,#FFFFFF 85.9%,#FF0000 100.0%);')
|
||||
assert(gradient == 'background:linear-gradient(to right,#FF0000 0.0%,#FFA500 16.5%,#FFFF00 33.3%,#00FF00 49.8%,#0000FF 66.7%,#FF00FF 83.1%,#FF0000 100.0%);')
|
||||
|
||||
|
||||
# unit tests
|
||||
|
@ -227,16 +226,6 @@ assert(o.animate(6000) == 1000)
|
|||
assert(o.animate(7000) == -1000)
|
||||
assert(o.animate(7100) == -1000)
|
||||
|
||||
o = animate.oscillator(-1000, 1000, 6000, animate.SINE)
|
||||
o.start(1000)
|
||||
assert(o.animate(1000) == 0)
|
||||
assert(o.animate(1500) == 500)
|
||||
assert(o.animate(2000) == 867)
|
||||
assert(o.animate(2500) == 1000)
|
||||
assert(o.animate(4000) == 0)
|
||||
assert(o.animate(5500) == -1000)
|
||||
assert(o.animate(7000) == 0)
|
||||
|
||||
o = animate.oscillator(-1000, 1000, 6000, animate.COSINE)
|
||||
o.start(1000)
|
||||
assert(o.animate(1000) == -1000)
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
# prepare for module `animate`
|
||||
|
||||
global.animate = module('animate')
|
|
@ -36,6 +36,7 @@ class Animate_core
|
|||
self.strip = strip
|
||||
if (bri == nil) bri = 50 end
|
||||
self.bri = bri # percentage of brightness 0..100
|
||||
self.set_strip_bri()
|
||||
self.running = false
|
||||
self.pixel_count = strip.pixel_count()
|
||||
self.animators = []
|
||||
|
@ -51,6 +52,10 @@ class Animate_core
|
|||
self.set_current()
|
||||
end
|
||||
|
||||
def set_strip_bri()
|
||||
self.strip.set_bri(tasmota.scale_uint(self.bri, 0, 100, 0, 255))
|
||||
end
|
||||
|
||||
# set this animate.core as the current animator for configuration
|
||||
def set_current()
|
||||
global._cur_anim = self # declare the current animate.core for painters and animators to register
|
||||
|
@ -129,6 +134,7 @@ class Animate_core
|
|||
|
||||
def set_bri(bri)
|
||||
self.bri = bri
|
||||
self.set_strip_bri()
|
||||
end
|
||||
def get_bri(bri)
|
||||
return self.bri
|
||||
|
@ -165,7 +171,10 @@ class Animate_core
|
|||
while i < size(self.painters)
|
||||
layer.fill_pixels(0xFF000000) # fill with transparent color
|
||||
if (self.painters[i].paint(layer))
|
||||
# print(f"frame0 {self.frame.tohex()}")
|
||||
# print(f"layer0 {self.layer.tohex()}")
|
||||
frame.blend_pixels(layer)
|
||||
# print(f"frame1 {self.frame.tohex()}")
|
||||
end
|
||||
i += 1
|
||||
end
|
||||
|
@ -177,7 +186,7 @@ class Animate_core
|
|||
end
|
||||
self.animate()
|
||||
# now display the frame
|
||||
self.frame.paste_pixels(self.strip.pixels_buffer(), self.bri, self.strip.gamma)
|
||||
self.frame.paste_pixels(self.strip.pixels_buffer(), self.strip.get_bri(), self.strip.get_gamma())
|
||||
self.strip.dirty()
|
||||
self.strip.show()
|
||||
end
|
||||
|
@ -192,3 +201,4 @@ class Animate_core
|
|||
tasmota.remove_fast_loop(self.fast_loop_cb)
|
||||
end
|
||||
end
|
||||
animate.core = global.Animate_core
|
|
@ -19,6 +19,7 @@ class Animate_painter
|
|||
end
|
||||
|
||||
end
|
||||
animate.painter = global.Animate_painter
|
||||
|
||||
##########################################################################################
|
||||
#
|
||||
|
@ -144,8 +145,8 @@ class Animate_pulse : Animate_painter
|
|||
|
||||
return true
|
||||
end
|
||||
|
||||
end
|
||||
animate.pulse = global.Animate_pulse
|
||||
|
||||
#
|
||||
# Unit tests
|
||||
|
@ -156,8 +157,8 @@ import animate
|
|||
var frame = animate.frame(10)
|
||||
assert(frame.tohex() == '00000000000000000000000000000000000000000000000000000000000000000000000000000000')
|
||||
|
||||
var pulse = Animate_pulse(0x00FF00, 3, 2)
|
||||
pulse.set_index(5)
|
||||
var pulse = animate.pulse(0x00FF00, 3, 2)
|
||||
pulse.set_pos(5)
|
||||
pulse.paint(frame)
|
||||
assert(frame.tohex() == '0000000000000000000000000055000000AA000000FF000000FF000000FF000000AA000000550000')
|
||||
|
|
@ -4,15 +4,6 @@
|
|||
# Animation framework
|
||||
#
|
||||
|
||||
animate = module("animate")
|
||||
|
||||
# for solidification
|
||||
class Leds_frame end
|
||||
|
||||
animate.("()") = Animate_core # make it available as `animate()`
|
||||
animate.frame = Leds_frame
|
||||
animate.pulse = Animate_pulse
|
||||
|
||||
#################################################################################
|
||||
# class Animate_palette
|
||||
#
|
||||
|
@ -85,7 +76,6 @@ animate.pulse = Animate_pulse
|
|||
# )
|
||||
# # animate.PALETTE_STANDARD = PALETTE_STANDARD
|
||||
|
||||
|
||||
#@ solidify:Animate_animator,weak
|
||||
class Animate_animator
|
||||
# timing information
|
||||
|
@ -134,6 +124,7 @@ class Animate_animator
|
|||
end
|
||||
|
||||
end
|
||||
animate.animator = Animate_animator
|
||||
|
||||
#@ solidify:Animate_palette,weak
|
||||
class Animate_palette : Animate_animator
|
||||
|
@ -408,7 +399,6 @@ animate.SAWTOOTH = 1
|
|||
animate.TRIANGLE = 2
|
||||
animate.SQUARE = 3
|
||||
animate.COSINE = 4
|
||||
animate.SINE = 5
|
||||
animate.LASTFOMR = 5 # identify last form
|
||||
|
||||
#@ solidify:Animate_oscillator,weak
|
||||
|
@ -471,7 +461,7 @@ class Animate_oscillator : Animate_animator
|
|||
var past = millis - self.origin
|
||||
if past < 0
|
||||
past = 0
|
||||
millis = self.originally
|
||||
millis = self.origin
|
||||
end
|
||||
var duration_ms = self.duration_ms
|
||||
var duration_ms_mid # mid point considering duty cycle
|
||||
|
@ -506,13 +496,10 @@ class Animate_oscillator : Animate_animator
|
|||
else
|
||||
value = b
|
||||
end
|
||||
elif (self.form == 4) #-COSINE-# || (self.form == 5) #-SINE-#
|
||||
elif (self.form == 4) #-COSINE-#
|
||||
# map timing to 0..32767
|
||||
var angle = tasmota.scale_int(past_with_phase, 0, duration_ms - 1, 0, 32767)
|
||||
if (self.form == 4) #-COSINE-#
|
||||
angle -= 8192
|
||||
end
|
||||
var x = tasmota.sine_int(angle) # -4096 .. 4096
|
||||
var x = tasmota.sine_int(angle - 8192) # -4096 .. 4096, dephase from cosine to sine
|
||||
value = tasmota.scale_int(x, -4096, 4096, a, b)
|
||||
end
|
||||
self.value = value
|
||||
|
@ -526,4 +513,4 @@ class Animate_oscillator : Animate_animator
|
|||
return value
|
||||
end
|
||||
end
|
||||
animate.oscillator = Animate_oscillator
|
||||
global.animate.oscillator = Animate_oscillator
|
||||
|
|
|
@ -27,6 +27,7 @@ class Leds_ntv end
|
|||
class Leds : Leds_ntv
|
||||
var gamma # if true, apply gamma (true is default)
|
||||
var leds # number of leds
|
||||
var bri # implicit brightness for this led strip (0..255, default is 50% = 127)
|
||||
# leds:int = number of leds of the strip
|
||||
# gpio:int (optional) = GPIO for NeoPixel. If not specified, takes the WS2812 gpio
|
||||
# typ:int (optional) = Type of LED, defaults to WS2812 RGB
|
||||
|
@ -34,6 +35,7 @@ class Leds : Leds_ntv
|
|||
def init(leds, gpio_phy, typ, rmt) # rmt is optional
|
||||
self.gamma = true # gamma is enabled by default, it should be disabled explicitly if needed
|
||||
self.leds = int(leds)
|
||||
self.bri = 127 # 50% brightness by default
|
||||
|
||||
# if no GPIO, abort
|
||||
if gpio_phy == nil
|
||||
|
@ -93,6 +95,16 @@ class Leds : Leds_ntv
|
|||
self.show()
|
||||
end
|
||||
|
||||
# set bri (0..255)
|
||||
def set_bri(bri)
|
||||
if (bri < 0) bri = 0 end
|
||||
if (bri > 255) bri = 255 end
|
||||
self.bri = bri
|
||||
end
|
||||
def get_bri()
|
||||
return self.bri
|
||||
end
|
||||
|
||||
def ctor(leds, gpio_phy, typ, rmt)
|
||||
if typ == nil
|
||||
typ = self.WS2812_GRB
|
||||
|
@ -136,14 +148,22 @@ class Leds : Leds_ntv
|
|||
return 0
|
||||
end
|
||||
def clear_to(col, bri)
|
||||
if (bri == nil) bri = self.bri end
|
||||
self.call_native(9, self.to_gamma(col, bri))
|
||||
end
|
||||
def set_pixel_color(idx, col, bri)
|
||||
if (bri == nil) bri = self.bri end
|
||||
self.call_native(10, idx, self.to_gamma(col, bri))
|
||||
end
|
||||
def get_pixel_color(idx)
|
||||
return self.call_native(11, idx)
|
||||
end
|
||||
def set_gamma(gamma)
|
||||
self.gamma = bool(gamma)
|
||||
end
|
||||
def get_gamma()
|
||||
return self.gamma
|
||||
end
|
||||
# def rotate_left(rot, first, last)
|
||||
# self.call_native(20, rot, first, last)
|
||||
# end
|
||||
|
@ -159,6 +179,7 @@ class Leds : Leds_ntv
|
|||
|
||||
# apply gamma and bri
|
||||
def to_gamma(rgb, bri)
|
||||
if (bri == nil) bri = self.bri end
|
||||
return self.apply_bri_gamma(rgb, bri, self.gamma)
|
||||
end
|
||||
|
||||
|
@ -216,6 +237,7 @@ class Leds : Leds_ntv
|
|||
return self.leds
|
||||
end
|
||||
def clear_to(col, bri)
|
||||
if (bri == nil) bri = self.bri end
|
||||
self.strip.call_native(9, self.strip.to_gamma(col, bri), self.offset, self.leds)
|
||||
# var i = 0
|
||||
# while i < self.leds
|
||||
|
@ -224,6 +246,7 @@ class Leds : Leds_ntv
|
|||
# end
|
||||
end
|
||||
def set_pixel_color(idx, col, bri)
|
||||
if (bri == nil) bri = self.bri end
|
||||
self.strip.set_pixel_color(idx + self.offset, col, bri)
|
||||
end
|
||||
def get_pixel_color(idx)
|
||||
|
@ -301,9 +324,11 @@ class Leds : Leds_ntv
|
|||
return self.offset
|
||||
end
|
||||
def clear_to(col, bri)
|
||||
if (bri == nil) bri = self.bri end
|
||||
self.strip.call_native(9, self.strip.to_gamma(col, bri), self.offset, self.w * self.h)
|
||||
end
|
||||
def set_pixel_color(idx, col, bri)
|
||||
if (bri == nil) bri = self.bri end
|
||||
self.strip.set_pixel_color(idx + self.offset, col, bri)
|
||||
end
|
||||
def get_pixel_color(idx)
|
||||
|
@ -328,6 +353,7 @@ class Leds : Leds_ntv
|
|||
end
|
||||
|
||||
def set_matrix_pixel_color(x, y, col, bri)
|
||||
if (bri == nil) bri = self.bri end
|
||||
if self.alternate && x % 2
|
||||
# reversed line
|
||||
self.strip.set_pixel_color(x * self.w + self.h - y - 1 + self.offset, col, bri)
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
/* Solidification of animate_0.h */
|
||||
/********************************************************************\
|
||||
* Generated code, don't edit *
|
||||
\********************************************************************/
|
||||
#include "be_constobj.h"
|
||||
/********************************************************************/
|
||||
/* End of solidification */
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,4 @@
|
|||
/* Solidification of animate_1_animate_effects.h */
|
||||
/* Solidification of animate_2_animate_effects.h */
|
||||
/********************************************************************\
|
||||
* Generated code, don't edit *
|
||||
\********************************************************************/
|
|
@ -1384,32 +1384,31 @@ be_local_closure(Animate_oscillator_animate, /* name */
|
|||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[21]) { /* constants */
|
||||
( &(const bvalue[20]) { /* constants */
|
||||
/* K0 */ be_nested_str_weak(duration_ms),
|
||||
/* K1 */ be_nested_str_weak(tasmota),
|
||||
/* K2 */ be_nested_str_weak(millis),
|
||||
/* K3 */ be_nested_str_weak(origin),
|
||||
/* K4 */ be_const_int(0),
|
||||
/* K5 */ be_nested_str_weak(originally),
|
||||
/* K6 */ be_nested_str_weak(scale_uint),
|
||||
/* K7 */ be_nested_str_weak(duty_cycle),
|
||||
/* K8 */ be_nested_str_weak(beat),
|
||||
/* K9 */ be_nested_str_weak(a),
|
||||
/* K10 */ be_nested_str_weak(b),
|
||||
/* K11 */ be_nested_str_weak(value),
|
||||
/* K12 */ be_nested_str_weak(phase),
|
||||
/* K13 */ be_nested_str_weak(form),
|
||||
/* K14 */ be_const_int(1),
|
||||
/* K15 */ be_nested_str_weak(scale_int),
|
||||
/* K16 */ be_const_int(2),
|
||||
/* K17 */ be_const_int(3),
|
||||
/* K18 */ be_nested_str_weak(sine_int),
|
||||
/* K19 */ be_nested_str_weak(obj),
|
||||
/* K20 */ be_nested_str_weak(mth),
|
||||
/* K5 */ be_nested_str_weak(scale_uint),
|
||||
/* K6 */ be_nested_str_weak(duty_cycle),
|
||||
/* K7 */ be_nested_str_weak(beat),
|
||||
/* K8 */ be_nested_str_weak(a),
|
||||
/* K9 */ be_nested_str_weak(b),
|
||||
/* K10 */ be_nested_str_weak(value),
|
||||
/* K11 */ be_nested_str_weak(phase),
|
||||
/* K12 */ be_nested_str_weak(form),
|
||||
/* K13 */ be_const_int(1),
|
||||
/* K14 */ be_nested_str_weak(scale_int),
|
||||
/* K15 */ be_const_int(2),
|
||||
/* K16 */ be_const_int(3),
|
||||
/* K17 */ be_nested_str_weak(sine_int),
|
||||
/* K18 */ be_nested_str_weak(obj),
|
||||
/* K19 */ be_nested_str_weak(mth),
|
||||
}),
|
||||
be_str_weak(animate),
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[150]) { /* code */
|
||||
( &(const binstruction[141]) { /* code */
|
||||
0x88080100, // 0000 GETMBR R2 R0 K0
|
||||
0x4C0C0000, // 0001 LDNIL R3
|
||||
0x1C080403, // 0002 EQ R2 R2 R3
|
||||
|
@ -1427,12 +1426,12 @@ be_local_closure(Animate_oscillator_animate, /* name */
|
|||
0x140C0504, // 000E LT R3 R2 K4
|
||||
0x780E0001, // 000F JMPF R3 #0012
|
||||
0x58080004, // 0010 LDCONST R2 K4
|
||||
0x88040105, // 0011 GETMBR R1 R0 K5
|
||||
0x88040103, // 0011 GETMBR R1 R0 K3
|
||||
0x880C0100, // 0012 GETMBR R3 R0 K0
|
||||
0x4C100000, // 0013 LDNIL R4
|
||||
0xB8160200, // 0014 GETNGBL R5 K1
|
||||
0x8C140B06, // 0015 GETMET R5 R5 K6
|
||||
0x881C0107, // 0016 GETMBR R7 R0 K7
|
||||
0x8C140B05, // 0015 GETMET R5 R5 K5
|
||||
0x881C0106, // 0016 GETMBR R7 R0 K6
|
||||
0x58200004, // 0017 LDCONST R8 K4
|
||||
0x54260063, // 0018 LDINT R9 100
|
||||
0x58280004, // 0019 LDCONST R10 K4
|
||||
|
@ -1447,18 +1446,18 @@ be_local_closure(Animate_oscillator_animate, /* name */
|
|||
0x00140A06, // 0022 ADD R5 R5 R6
|
||||
0x90020605, // 0023 SETMBR R0 K3 R5
|
||||
0x10080403, // 0024 MOD R2 R2 R3
|
||||
0x8C140108, // 0025 GETMET R5 R0 K8
|
||||
0x8C140107, // 0025 GETMET R5 R0 K7
|
||||
0x7C140200, // 0026 CALL R5 1
|
||||
0x88140109, // 0027 GETMBR R5 R0 K9
|
||||
0x8818010A, // 0028 GETMBR R6 R0 K10
|
||||
0x881C010B, // 0029 GETMBR R7 R0 K11
|
||||
0x88140108, // 0027 GETMBR R5 R0 K8
|
||||
0x88180109, // 0028 GETMBR R6 R0 K9
|
||||
0x881C010A, // 0029 GETMBR R7 R0 K10
|
||||
0x5C200400, // 002A MOVE R8 R2
|
||||
0x8824010C, // 002B GETMBR R9 R0 K12
|
||||
0x8824010B, // 002B GETMBR R9 R0 K11
|
||||
0x24241304, // 002C GT R9 R9 K4
|
||||
0x7826000B, // 002D JMPF R9 #003A
|
||||
0xB8260200, // 002E GETNGBL R9 K1
|
||||
0x8C241306, // 002F GETMET R9 R9 K6
|
||||
0x882C010C, // 0030 GETMBR R11 R0 K12
|
||||
0x8C241305, // 002F GETMET R9 R9 K5
|
||||
0x882C010B, // 0030 GETMBR R11 R0 K11
|
||||
0x58300004, // 0031 LDCONST R12 K4
|
||||
0x54360063, // 0032 LDINT R13 100
|
||||
0x58380004, // 0033 LDCONST R14 K4
|
||||
|
@ -1468,98 +1467,89 @@ be_local_closure(Animate_oscillator_animate, /* name */
|
|||
0x24241003, // 0037 GT R9 R8 R3
|
||||
0x78260000, // 0038 JMPF R9 #003A
|
||||
0x04201003, // 0039 SUB R8 R8 R3
|
||||
0x8824010D, // 003A GETMBR R9 R0 K13
|
||||
0x1C24130E, // 003B EQ R9 R9 K14
|
||||
0x8824010C, // 003A GETMBR R9 R0 K12
|
||||
0x1C24130D, // 003B EQ R9 R9 K13
|
||||
0x78260009, // 003C JMPF R9 #0047
|
||||
0xB8260200, // 003D GETNGBL R9 K1
|
||||
0x8C24130F, // 003E GETMET R9 R9 K15
|
||||
0x8C24130E, // 003E GETMET R9 R9 K14
|
||||
0x5C2C1000, // 003F MOVE R11 R8
|
||||
0x58300004, // 0040 LDCONST R12 K4
|
||||
0x0434070E, // 0041 SUB R13 R3 K14
|
||||
0x0434070D, // 0041 SUB R13 R3 K13
|
||||
0x5C380A00, // 0042 MOVE R14 R5
|
||||
0x5C3C0C00, // 0043 MOVE R15 R6
|
||||
0x7C240C00, // 0044 CALL R9 6
|
||||
0x5C1C1200, // 0045 MOVE R7 R9
|
||||
0x70020044, // 0046 JMP #008C
|
||||
0x8824010D, // 0047 GETMBR R9 R0 K13
|
||||
0x1C241310, // 0048 EQ R9 R9 K16
|
||||
0x7002003B, // 0046 JMP #0083
|
||||
0x8824010C, // 0047 GETMBR R9 R0 K12
|
||||
0x1C24130F, // 0048 EQ R9 R9 K15
|
||||
0x78260015, // 0049 JMPF R9 #0060
|
||||
0x14241004, // 004A LT R9 R8 R4
|
||||
0x78260009, // 004B JMPF R9 #0056
|
||||
0xB8260200, // 004C GETNGBL R9 K1
|
||||
0x8C24130F, // 004D GETMET R9 R9 K15
|
||||
0x8C24130E, // 004D GETMET R9 R9 K14
|
||||
0x5C2C1000, // 004E MOVE R11 R8
|
||||
0x58300004, // 004F LDCONST R12 K4
|
||||
0x0434090E, // 0050 SUB R13 R4 K14
|
||||
0x0434090D, // 0050 SUB R13 R4 K13
|
||||
0x5C380A00, // 0051 MOVE R14 R5
|
||||
0x5C3C0C00, // 0052 MOVE R15 R6
|
||||
0x7C240C00, // 0053 CALL R9 6
|
||||
0x5C1C1200, // 0054 MOVE R7 R9
|
||||
0x70020008, // 0055 JMP #005F
|
||||
0xB8260200, // 0056 GETNGBL R9 K1
|
||||
0x8C24130F, // 0057 GETMET R9 R9 K15
|
||||
0x8C24130E, // 0057 GETMET R9 R9 K14
|
||||
0x5C2C1000, // 0058 MOVE R11 R8
|
||||
0x5C300800, // 0059 MOVE R12 R4
|
||||
0x0434070E, // 005A SUB R13 R3 K14
|
||||
0x0434070D, // 005A SUB R13 R3 K13
|
||||
0x5C380C00, // 005B MOVE R14 R6
|
||||
0x5C3C0A00, // 005C MOVE R15 R5
|
||||
0x7C240C00, // 005D CALL R9 6
|
||||
0x5C1C1200, // 005E MOVE R7 R9
|
||||
0x7002002B, // 005F JMP #008C
|
||||
0x8824010D, // 0060 GETMBR R9 R0 K13
|
||||
0x1C241311, // 0061 EQ R9 R9 K17
|
||||
0x70020022, // 005F JMP #0083
|
||||
0x8824010C, // 0060 GETMBR R9 R0 K12
|
||||
0x1C241310, // 0061 EQ R9 R9 K16
|
||||
0x78260005, // 0062 JMPF R9 #0069
|
||||
0x14241004, // 0063 LT R9 R8 R4
|
||||
0x78260001, // 0064 JMPF R9 #0067
|
||||
0x5C1C0A00, // 0065 MOVE R7 R5
|
||||
0x70020000, // 0066 JMP #0068
|
||||
0x5C1C0C00, // 0067 MOVE R7 R6
|
||||
0x70020022, // 0068 JMP #008C
|
||||
0x8824010D, // 0069 GETMBR R9 R0 K13
|
||||
0x70020019, // 0068 JMP #0083
|
||||
0x8824010C, // 0069 GETMBR R9 R0 K12
|
||||
0x542A0003, // 006A LDINT R10 4
|
||||
0x1C24120A, // 006B EQ R9 R9 R10
|
||||
0x74260003, // 006C JMPT R9 #0071
|
||||
0x8824010D, // 006D GETMBR R9 R0 K13
|
||||
0x542A0004, // 006E LDINT R10 5
|
||||
0x1C24120A, // 006F EQ R9 R9 R10
|
||||
0x7826001A, // 0070 JMPF R9 #008C
|
||||
0xB8260200, // 0071 GETNGBL R9 K1
|
||||
0x8C24130F, // 0072 GETMET R9 R9 K15
|
||||
0x5C2C1000, // 0073 MOVE R11 R8
|
||||
0x58300004, // 0074 LDCONST R12 K4
|
||||
0x0434070E, // 0075 SUB R13 R3 K14
|
||||
0x58380004, // 0076 LDCONST R14 K4
|
||||
0x543E7FFE, // 0077 LDINT R15 32767
|
||||
0x7C240C00, // 0078 CALL R9 6
|
||||
0x8828010D, // 0079 GETMBR R10 R0 K13
|
||||
0x542E0003, // 007A LDINT R11 4
|
||||
0x1C28140B, // 007B EQ R10 R10 R11
|
||||
0x782A0001, // 007C JMPF R10 #007F
|
||||
0x542A1FFF, // 007D LDINT R10 8192
|
||||
0x0424120A, // 007E SUB R9 R9 R10
|
||||
0xB82A0200, // 007F GETNGBL R10 K1
|
||||
0x8C281512, // 0080 GETMET R10 R10 K18
|
||||
0x5C301200, // 0081 MOVE R12 R9
|
||||
0x7C280400, // 0082 CALL R10 2
|
||||
0xB82E0200, // 0083 GETNGBL R11 K1
|
||||
0x8C2C170F, // 0084 GETMET R11 R11 K15
|
||||
0x5C341400, // 0085 MOVE R13 R10
|
||||
0x5439EFFF, // 0086 LDINT R14 -4096
|
||||
0x543E0FFF, // 0087 LDINT R15 4096
|
||||
0x5C400A00, // 0088 MOVE R16 R5
|
||||
0x5C440C00, // 0089 MOVE R17 R6
|
||||
0x7C2C0C00, // 008A CALL R11 6
|
||||
0x5C1C1600, // 008B MOVE R7 R11
|
||||
0x90021607, // 008C SETMBR R0 K11 R7
|
||||
0x88240113, // 008D GETMBR R9 R0 K19
|
||||
0x88280114, // 008E GETMBR R10 R0 K20
|
||||
0x78260004, // 008F JMPF R9 #0095
|
||||
0x782A0003, // 0090 JMPF R10 #0095
|
||||
0x5C2C1400, // 0091 MOVE R11 R10
|
||||
0x5C301200, // 0092 MOVE R12 R9
|
||||
0x5C340E00, // 0093 MOVE R13 R7
|
||||
0x7C2C0400, // 0094 CALL R11 2
|
||||
0x80040E00, // 0095 RET 1 R7
|
||||
0x78260015, // 006C JMPF R9 #0083
|
||||
0xB8260200, // 006D GETNGBL R9 K1
|
||||
0x8C24130E, // 006E GETMET R9 R9 K14
|
||||
0x5C2C1000, // 006F MOVE R11 R8
|
||||
0x58300004, // 0070 LDCONST R12 K4
|
||||
0x0434070D, // 0071 SUB R13 R3 K13
|
||||
0x58380004, // 0072 LDCONST R14 K4
|
||||
0x543E7FFE, // 0073 LDINT R15 32767
|
||||
0x7C240C00, // 0074 CALL R9 6
|
||||
0xB82A0200, // 0075 GETNGBL R10 K1
|
||||
0x8C281511, // 0076 GETMET R10 R10 K17
|
||||
0x54321FFF, // 0077 LDINT R12 8192
|
||||
0x0430120C, // 0078 SUB R12 R9 R12
|
||||
0x7C280400, // 0079 CALL R10 2
|
||||
0xB82E0200, // 007A GETNGBL R11 K1
|
||||
0x8C2C170E, // 007B GETMET R11 R11 K14
|
||||
0x5C341400, // 007C MOVE R13 R10
|
||||
0x5439EFFF, // 007D LDINT R14 -4096
|
||||
0x543E0FFF, // 007E LDINT R15 4096
|
||||
0x5C400A00, // 007F MOVE R16 R5
|
||||
0x5C440C00, // 0080 MOVE R17 R6
|
||||
0x7C2C0C00, // 0081 CALL R11 6
|
||||
0x5C1C1600, // 0082 MOVE R7 R11
|
||||
0x90021407, // 0083 SETMBR R0 K10 R7
|
||||
0x88240112, // 0084 GETMBR R9 R0 K18
|
||||
0x88280113, // 0085 GETMBR R10 R0 K19
|
||||
0x78260004, // 0086 JMPF R9 #008C
|
||||
0x782A0003, // 0087 JMPF R10 #008C
|
||||
0x5C2C1400, // 0088 MOVE R11 R10
|
||||
0x5C301200, // 0089 MOVE R12 R9
|
||||
0x5C340E00, // 008A MOVE R13 R7
|
||||
0x7C2C0400, // 008B CALL R11 2
|
||||
0x80040E00, // 008C RET 1 R7
|
||||
})
|
||||
)
|
||||
);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -8,12 +8,13 @@ var duration = 10000
|
|||
var strip = Leds(5 * 5, gpio.pin(gpio.WS2812, 0))
|
||||
var anim = animate.core(strip)
|
||||
anim.set_back_color(0x2222AA)
|
||||
anim.set_bri(60) # set brightness to 40%
|
||||
var pulse = animate.pulse(0xFF4444, 2, 1)
|
||||
var osc1 = animate.oscillator(-3, 26, 5000, animate.COSINE)
|
||||
osc1.set_cb(pulse, pulse.set_pos)
|
||||
|
||||
# animate color of pulse
|
||||
var palette = animate.palette(animate.PALETTE_RAINBOW_WHITE, 30000)
|
||||
var palette = animate.palette(animate.PALETTE_STANDARD_VAL, 30000)
|
||||
palette.set_cb(pulse, pulse.set_color)
|
||||
|
||||
anim.start()
|
||||
|
|
|
@ -291,16 +291,16 @@ extern "C" {
|
|||
be_raise(vm, kTypeError, nullptr);
|
||||
}
|
||||
|
||||
static uint32_t ApplyBriGamma(uint32_t color_a /* 0xRRGGBB */, uint32_t bri /* 0..100 */, bool gamma) {
|
||||
static uint32_t ApplyBriGamma(uint32_t color_a /* 0xRRGGBB */, uint32_t bri /* 0..255 */, bool gamma) {
|
||||
if (bri == 0) { return 0x000000; } // if bri is zero, short-cut
|
||||
uint32_t r = (color_a >> 16) & 0xFF;
|
||||
uint32_t g = (color_a >> 8) & 0xFF;
|
||||
uint32_t b = (color_a ) & 0xFF;
|
||||
|
||||
if (bri < 100) { // apply bri
|
||||
r = changeUIntScale(bri, 0, 100, 0, r);
|
||||
g = changeUIntScale(bri, 0, 100, 0, g);
|
||||
b = changeUIntScale(bri, 0, 100, 0, b);
|
||||
if (bri < 255) { // apply bri
|
||||
r = changeUIntScale(bri, 0, 255, 0, r);
|
||||
g = changeUIntScale(bri, 0, 255, 0, g);
|
||||
b = changeUIntScale(bri, 0, 255, 0, b);
|
||||
}
|
||||
|
||||
if (gamma) { // apply gamma
|
||||
|
@ -312,23 +312,23 @@ extern "C" {
|
|||
return rgb;
|
||||
}
|
||||
|
||||
// Leds.apply_bri_gamma(color_rgb:int (0xRRGGBB) [bri:int (0..100), gamma:bool]) -> color:int (0xRRGGBB)
|
||||
// Leds.apply_bri_gamma(color_rgb:int (0xRRGGBB) [bri:int (0..255), gamma:bool]) -> color:int (0xRRGGBB)
|
||||
//
|
||||
int32_t be_leds_apply_bri_gamma(bvm *vm);
|
||||
int32_t be_leds_apply_bri_gamma(bvm *vm) {
|
||||
int32_t top = be_top(vm); // Get the number of arguments
|
||||
if (top >= 1 && be_isint(vm, 1)) {
|
||||
uint32_t color_a = be_toint(vm, 1);
|
||||
uint32_t bri = 100;
|
||||
uint32_t bri255 = 255;
|
||||
if (top >= 2 && be_isint(vm, 2)) {
|
||||
bri = be_toint(vm, 2);
|
||||
bri255 = be_toint(vm, 2);
|
||||
}
|
||||
bool gamma = false;
|
||||
if (top >= 3) {
|
||||
gamma = be_tobool(vm, 3);
|
||||
}
|
||||
|
||||
uint32_t rgb = ApplyBriGamma(color_a, bri, gamma);
|
||||
uint32_t rgb = ApplyBriGamma(color_a, bri255, gamma);
|
||||
|
||||
be_pushint(vm, rgb);
|
||||
be_return(vm);
|
||||
|
@ -453,9 +453,9 @@ extern "C" {
|
|||
size_t dest_len = 0;
|
||||
uint8_t * dest_buf = (uint8_t*) be_tobytes(vm, 2, &dest_len);
|
||||
|
||||
uint32_t bri = 100;
|
||||
uint32_t bri255 = 255;
|
||||
if (top >= 3 && be_isint(vm, 3)) {
|
||||
bri = be_toint(vm, 3);
|
||||
bri255 = be_toint(vm, 3);
|
||||
}
|
||||
bool gamma = false;
|
||||
if (top >= 4 && be_isbool(vm, 4)) {
|
||||
|
@ -466,7 +466,7 @@ extern "C" {
|
|||
if (pixels_count > dest_len / 3) { pixels_count = dest_len / 3; }
|
||||
if (pixels_count > 0) {
|
||||
for (size_t i = 0; i < pixels_count; i++) {
|
||||
uint32_t src_argb = ApplyBriGamma(src_buf[i], bri, gamma);
|
||||
uint32_t src_argb = ApplyBriGamma(src_buf[i], bri255, gamma);
|
||||
uint32_t src_r = (src_argb >> 16) & 0xFF;
|
||||
uint32_t src_g = (src_argb >> 8) & 0xFF;
|
||||
uint32_t src_b = (src_argb ) & 0xFF;
|
||||
|
|
Loading…
Reference in New Issue