@@ -22,7 +22,8 @@ ParameterizedObject (base class with parameter management and playable interface
2222│ ├── BeaconAnimation (pulse at specific position)
2323│ ├── CrenelPositionAnimation (crenel/square wave pattern)
2424│ ├── BreatheAnimation (breathing effect)
25- │ ├── PalettePatternAnimation (base for palette-based animations)
25+ │ ├── PaletteGradientAnimation (gradient patterns with palette colors)
26+ │ │ └── PaletteMeterAnimation (meter/bar patterns)
2627│ ├── CometAnimation (moving comet with tail)
2728│ ├── FireAnimation (realistic fire effect)
2829│ ├── TwinkleAnimation (twinkling stars effect)
@@ -243,11 +244,11 @@ Generates oscillating values using various waveforms. Inherits from `ValueProvid
243244| Parameter | Type | Default | Constraints | Description |
244245| -----------| ------| ---------| -------------| -------------|
245246| ` min_value ` | int | 0 | - | Minimum oscillation value |
246- | ` max_value ` | int | 100 | - | Maximum oscillation value |
247+ | ` max_value ` | int | 255 | - | Maximum oscillation value |
247248| ` duration ` | int | 1000 | min: 1 | Oscillation period in milliseconds |
248249| ` form ` | int | 1 | enum: [ 1,2,3,4,5,6,7,8,9] | Waveform type |
249- | ` phase ` | int | 0 | 0-100 | Phase shift percentage |
250- | ` duty_cycle ` | int | 50 | 0-100 | Duty cycle for square/triangle waves |
250+ | ` phase ` | int | 0 | 0-255 | Phase shift in 0-255 range (mapped to duration) |
251+ | ` duty_cycle ` | int | 127 | 0-255 | Duty cycle for square/triangle waves in 0-255 range |
251252
252253** Waveform Constants** :
253254- ` 1 ` (SAWTOOTH) - Linear ramp from min to max
@@ -301,6 +302,18 @@ The ClosureValueProvider includes built-in mathematical helper methods that can
301302- ** Cosine Behavior** : Matches oscillator COSINE waveform (starts at minimum, not maximum)
302303- ** Scale Function** : Uses ` tasmota.scale_int() ` for efficient integer scaling
303304
305+ #### Closure Signature
306+
307+ Closures used with ClosureValueProvider must follow this signature:
308+ ``` berry
309+ def closure_func(engine, param_name, time_ms)
310+ # engine: AnimationEngine reference
311+ # param_name: Name of the parameter being computed
312+ # time_ms: Current time in milliseconds
313+ return computed_value
314+ end
315+ ```
316+
304317#### Usage in Computed Values
305318
306319These methods are automatically available in DSL computed expressions:
@@ -1029,51 +1042,23 @@ animation strobe = wave_animation(
10291042
10301043
10311044
1032- ### PalettePatternAnimation
1045+ ### PaletteGradientAnimation
10331046
1034- Applies colors from a color provider to specific patterns using an efficient bytes() buffer . Inherits from ` Animation ` .
1047+ Creates shifting gradient patterns with palette colors . Inherits from ` Animation ` .
10351048
10361049| Parameter | Type | Default | Constraints | Description |
10371050| -----------| ------| ---------| -------------| -------------|
10381051| ` color_source ` | instance | nil | - | Color provider for pattern mapping |
1039- | ` pattern_func ` | function | nil | - | Function that generates pattern values (0-255) for each pixel |
1052+ | ` shift_period ` | int | 0 | min: 0 | Time for one complete shift cycle in ms (0 = static gradient) |
1053+ | ` spatial_period ` | int | 0 | min: 0 | Spatial period in pixels (0 = full strip length) |
1054+ | ` phase_shift ` | int | 0 | 0-255 | Phase shift in 0-255 range (mapped to spatial period) |
10401055| * (inherits all Animation parameters)* | | | | |
10411056
10421057** Implementation Details:**
10431058- Uses ` bytes() ` buffer for efficient storage of per-pixel values
1044- - Pattern function should return values in 0-255 range
10451059- Color source receives values in 0-255 range via ` get_color_for_value(value, time_ms) `
10461060- Buffer automatically resizes when strip length changes
1047-
1048- ** Factory** : ` animation.palette_pattern_animation(engine) `
1049-
1050- ### PaletteWaveAnimation
1051-
1052- Creates sine wave patterns with palette colors. Inherits from ` PalettePatternAnimation ` .
1053-
1054- | Parameter | Type | Default | Constraints | Description |
1055- | -----------| ------| ---------| -------------| -------------|
1056- | ` wave_period ` | int | 5000 | min: 1 | Wave animation period in ms |
1057- | ` wave_length ` | int | 10 | min: 1 | Wave length in pixels |
1058- | * (inherits all PalettePatternAnimation parameters)* | | | | |
1059-
1060- ** Pattern Generation:**
1061- - Generates sine wave values in 0-255 range using ` tasmota.sine_int() `
1062- - Wave position advances based on ` wave_period ` timing
1063- - Each pixel's value calculated as: ` sine_value = tasmota.scale_int(sine_int(angle), -4096, 4096, 0, 255) `
1064-
1065- ** Factory** : ` animation.palette_wave_animation(engine) `
1066-
1067- ### PaletteGradientAnimation
1068-
1069- Creates shifting gradient patterns with palette colors. Inherits from ` PalettePatternAnimation ` .
1070-
1071- | Parameter | Type | Default | Constraints | Description |
1072- | -----------| ------| ---------| -------------| -------------|
1073- | ` shift_period ` | int | 10000 | min: 0 | Time for one complete shift cycle in ms (0 = static gradient) |
1074- | ` spatial_period ` | int | 0 | min: 0 | Spatial period in pixels (0 = full strip length) |
1075- | ` phase_shift ` | int | 0 | 0-100 | Phase shift as percentage of spatial period |
1076- | * (inherits all PalettePatternAnimation parameters)* | | | | |
1061+ - Optimized LUT (Lookup Table) support for color providers
10771062
10781063** Pattern Generation:**
10791064- Generates linear gradient values in 0-255 range across the specified spatial period
@@ -1084,23 +1069,27 @@ Creates shifting gradient patterns with palette colors. Inherits from `PalettePa
10841069 - ` 0 ` : Gradient spans the full strip length (single gradient across entire strip)
10851070 - ` > 0 ` : Gradient repeats every N pixels
10861071- ** phase_shift** : Shifts the gradient pattern spatially by a percentage of the spatial period
1087- - Each pixel's value calculated as: ` value = tasmota.scale_uint(spatial_position, 0, spatial_period-1, 0, 255) `
1072+ - Each pixel's value calculated using optimized fixed-point arithmetic
10881073
10891074** Factory** : ` animation.palette_gradient_animation(engine) `
10901075
10911076### PaletteMeterAnimation
10921077
1093- Creates meter/bar patterns based on a value function. Inherits from ` PalettePatternAnimation ` .
1078+ Creates meter/bar patterns based on a value function. Inherits from ` PaletteGradientAnimation ` .
10941079
10951080| Parameter | Type | Default | Constraints | Description |
10961081| -----------| ------| ---------| -------------| -------------|
1097- | ` value_func ` | function | nil | - | Function that provides meter values (0-100 range) |
1098- | * (inherits all PalettePatternAnimation parameters)* | | | | |
1082+ | ` value_func ` | function | nil | - | Function that provides meter values (0-255 range) |
1083+ | * (inherits all PaletteGradientAnimation parameters)* | | | | |
10991084
11001085** Pattern Generation:**
1101- - Value function returns percentage (0-100) representing meter level
1086+ - Value function signature: ` value_func(engine, time_ms, self) ` where:
1087+ - ` engine ` : AnimationEngine reference
1088+ - ` time_ms ` : Elapsed time since animation start
1089+ - ` self ` : Reference to the animation instance
1090+ - Value function returns value in 0-255 range representing meter level
11021091- Pixels within meter range get value 255, others get value 0
1103- - Meter position calculated as: ` position = tasmota.scale_uint(value, 0, 100 , 0, strip_length) `
1092+ - Meter position calculated as: ` position = tasmota.scale_uint(value, 0, 255 , 0, strip_length) `
11041093
11051094** Factory** : ` animation.palette_meter_animation(engine) `
11061095
0 commit comments