Tasmota/lib/libesp32/berry_animation/anim_examples/compiled/palette_demo.be
2025-08-01 19:34:23 +02:00

86 lines
2.7 KiB
Plaintext

# Generated Berry code from Animation DSL
# Source: palette_demo.anim
# Generated automatically
#
# This file was automatically generated by compile_all_dsl_examples.sh
# Do not edit manually - changes will be overwritten
# Original DSL source:
# # Palette Demo - Shows how to use custom palettes in DSL
# # This demonstrates the new palette syntax
#
# strip length 30
#
# # Define a fire palette
# palette fire_colors = [
# (0, 0x000000), # Black
# (64, 0x800000), # Dark red
# (128, 0xFF0000), # Red
# (192, 0xFF8000), # Orange
# (255, 0xFFFF00) # Yellow
# ]
#
# # Define an ocean palette
# palette ocean_colors = [
# (0, 0x000080), # Navy blue
# (64, 0x0000FF), # Blue
# (128, 0x00FFFF), # Cyan
# (192, 0x00FF80), # Spring green
# (255, 0x008000) # Green
# ]
#
# # Create animations using the palettes
# animation fire_anim = rich_palette_animation(fire_colors, 5s)
#
# animation ocean_anim = rich_palette_animation(ocean_colors, 8s)
#
# # Sequence to show both palettes
# sequence palette_demo {
# play fire_anim for 10s
# wait 1s
# play ocean_anim for 10s
# wait 1s
# repeat 2 times:
# play fire_anim for 3s
# play ocean_anim for 3s
# }
#
# run palette_demo
import animation
# Palette Demo - Shows how to use custom palettes in DSL
# This demonstrates the new palette syntax
var strip = global.Leds(30)
var engine = animation.create_engine(strip)
# Define a fire palette
var fire_colors_ = bytes("00000000" "40800000" "80FF0000" "C0FF8000" "FFFFFF00")
# Define an ocean palette
var ocean_colors_ = bytes("00000080" "400000FF" "8000FFFF" "C000FF80" "FF008000")
# Create animations using the palettes
var fire_anim_ = animation.rich_palette_animation(animation.global('fire_colors_', 'fire_colors'), 5000)
var ocean_anim_ = animation.rich_palette_animation(animation.global('ocean_colors_', 'ocean_colors'), 8000)
# Sequence to show both palettes
def sequence_palette_demo()
var steps = []
steps.push(animation.create_play_step(animation.global('fire_anim_'), 10000))
steps.push(animation.create_wait_step(1000))
steps.push(animation.create_play_step(animation.global('ocean_anim_'), 10000))
steps.push(animation.create_wait_step(1000))
for repeat_i : 0..2-1
steps.push(animation.create_play_step(animation.global('fire_anim_'), 3000))
steps.push(animation.create_play_step(animation.global('ocean_anim_'), 3000))
end
var seq_manager = animation.SequenceManager(engine)
seq_manager.start_sequence(steps)
return seq_manager
end
# Start all animations/sequences
if global.contains('sequence_palette_demo')
var seq_manager = global.sequence_palette_demo()
engine.add_sequence_manager(seq_manager)
else
engine.add_animation(animation.global('palette_demo_'))
end
engine.start()