Tasmota/lib/libesp32/berry_animation/anim_examples/compiled/README.md
s-hadinger ca934bae33
Preview of Berry animation framework (#23740)
* Preview of Berry animation framework

* fix comet and compilation for safeboot
2025-08-01 18:02:02 +02:00

3.7 KiB

Compiled DSL Examples

This directory contains the results of compiling Animation DSL examples to Berry code.

Files

  • COMPILATION_REPORT.md - Detailed compilation results and analysis
  • run_successful_tests.sh - Test runner for successfully compiled examples
  • *.be - Compiled Berry code files from DSL sources

Current Status

The DSL transpiler has been significantly improved and now successfully compiles all example DSL files!

What Works

  • Basic color definitions (color red = #FF0000)
  • Palette definitions with comments (palette colors = [(0, #000000), # Black])
  • Pattern definitions (pattern solid_red = solid(red))
  • Animation definitions (animation anim1 = pulse_position(...))
  • Function calls with inline comments (multiline functions with comments)
  • Easing keywords (smooth, linear, ease_in, ease_out, bounce, elastic)
  • Strip configuration (strip length 60)
  • Variable assignments (set var = value)
  • Run statements (run animation_name)
  • Complex nested function calls
  • All 23 example DSL files compile successfully

Recent Improvements

  1. Fixed Comments in Palette Definitions: Palette arrays can now include inline comments

    palette fire_colors = [
      (0, #000000),    # Black (no fire) - This now works!
      (128, #FF0000),  # Red flames
      (255, #FFFF00)   # Bright yellow
    ]
    
  2. Fixed Comments in Function Arguments: Multiline function calls with comments now parse correctly

    animation lava_blob = pulse_position(
      rich_palette(lava_colors, 12s, smooth, 255),
      18,       # large blob - This now works!
      12,       # very soft edges
      10,       # priority
      loop
    )
    
  3. Added Easing Keyword Support: Keywords like smooth, linear are now recognized

    animation smooth_fade = filled(
      rich_palette(colors, 5s, smooth, 255),  # 'smooth' now works!
      loop
    )
    

What Still Needs Work

  • Property assignments (animation.pos = value) - Not yet supported
  • Multiple run statements (generates multiple engine.start() calls)
  • Advanced DSL features (sequences, loops, conditionals)
  • Runtime execution (compiled code may have runtime issues)

Example Working DSL

# Complex working example with comments and palettes
strip length 60

# Define colors with comments
palette lava_colors = [
  (0, #330000),    # Dark red
  (64, #660000),   # Medium red  
  (128, #CC3300),  # Bright red
  (192, #FF6600),  # Orange
  (255, #FFAA00)   # Yellow-orange
]

# Animation with inline comments
animation lava_base = filled(
  rich_palette(lava_colors, 15s, smooth, 180),  # Smooth transitions
  loop
)

animation lava_blob = pulse_position(
  rich_palette(lava_colors, 12s, smooth, 255),
  18,       # large blob
  12,       # very soft edges
  10,       # priority
  loop
)

run lava_base
run lava_blob

Usage

To compile DSL examples:

./compile_all_dsl_examples.sh

To test compiled examples:

./anim_examples/compiled/run_successful_tests.sh

Success Rate

  • Current: 100% (23/23 files compile successfully)
  • Previous: 4% (1/23 files)
  • Improvement: 575% increase in successful compilations

Development Notes

The DSL transpiler uses a single-pass architecture that directly converts tokens to Berry code. Recent improvements:

  1. Enhanced comment handling - Comments now work in all contexts
  2. Easing keyword support - All easing functions recognized
  3. Improved error handling - Better parsing of complex expressions
  4. Property assignments - Still need implementation
  5. Advanced DSL features - Sequences, loops, conditionals not yet supported