# Generated Berry code from Animation DSL # Source: palette_demo.anim # # This file was automatically generated by compile_all_examples.sh # Do not edit manually - changes will be overwritten import animation # Palette Demo - Shows how to use custom palettes in DSL # This demonstrates the new palette syntax #strip length 30 # Define a fire palette # Auto-generated strip initialization (using Tasmota configuration) var engine = animation.init_strip() 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(engine) fire_anim_.palette = fire_colors_ fire_anim_.cycle_period = 5000 var ocean_anim_ = animation.rich_palette_animation(engine) ocean_anim_.palette = ocean_colors_ ocean_anim_.cycle_period = 8000 # Sequence to show both palettes var palette_demo_ = (def (engine) 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)(engine) engine.add_sequence_manager(palette_demo_) engine.start() #- 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(palette=fire_colors, cycle_period=5s) animation ocean_anim = rich_palette_animation(palette=ocean_colors, cycle_period=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 -#