diff --git a/lib/libesp32/berry_animation/docs/ANIMATION_CLASS_HIERARCHY.md b/lib/libesp32/berry_animation/docs/ANIMATION_CLASS_HIERARCHY.md index 00a2a5dc2..023e33284 100644 --- a/lib/libesp32/berry_animation/docs/ANIMATION_CLASS_HIERARCHY.md +++ b/lib/libesp32/berry_animation/docs/ANIMATION_CLASS_HIERARCHY.md @@ -184,7 +184,7 @@ The ClosureValueProvider includes built-in mathematical helper methods that can These methods are automatically available in DSL computed expressions: -```dsl +```berry # Example: Dynamic brightness based on strip position set strip_len = strip_length() animation pulse = pulsating_animation( @@ -224,7 +224,7 @@ Returns a single, static color. Inherits from `ColorProvider`. #### Usage Examples -```dsl +```berry # Using predefined colors color static_red = solid(color=red) color static_blue = solid(color=blue) @@ -254,7 +254,7 @@ Cycles through a custom list of colors with smooth transitions. Inherits from `C #### Usage Examples -```dsl +```berry # RGB cycle with smooth transitions color rgb_cycle = color_cycle( palette=[red, green, blue], @@ -305,7 +305,7 @@ Generates colors from predefined palettes with smooth transitions and profession #### Usage Examples -```dsl +```berry # Rainbow palette with smooth transitions color rainbow_colors = rich_palette( palette=PALETTE_RAINBOW, @@ -353,7 +353,7 @@ Creates breathing/pulsing color effects by modulating the brightness of a base c #### Usage Examples -```dsl +```berry # Natural breathing effect color breathing_red = breathe_color( base_color=red, @@ -480,7 +480,7 @@ Each sparkle follows a predictable lifecycle: #### Usage Examples -```dsl +```berry # Basic white starfield animation starfield = sparkle_animation( color=white, @@ -536,7 +536,7 @@ Creates physics-based bouncing effects with configurable gravity, damping, and m #### Usage Examples -```dsl +```berry # Bouncing ball effect with gravity animation ball = pulsating_animation(color=green, period=2s) animation bouncing_ball = bounce_animation( @@ -611,7 +611,7 @@ Adds random shake effects to patterns with configurable intensity, frequency, an #### Usage Examples -```dsl +```berry # Digital glitch effect animation base_pattern = gradient_animation(color=rainbow_cycle) animation glitch_effect = jitter_animation( @@ -665,7 +665,7 @@ Creates pseudo-random noise patterns with configurable scale, speed, and fractal #### Usage Examples -```dsl +```berry # Rainbow noise with medium detail animation rainbow_noise = noise_animation( scale=60, @@ -739,7 +739,7 @@ The plasma effect combines two sine waves with different frequencies to create i #### Usage Examples -```dsl +```berry # Classic rainbow plasma animation rainbow_plasma = plasma_animation( freq_x=32, @@ -835,7 +835,7 @@ The pulse consists of: #### Usage Examples -```dsl +```berry # Sharp pulse at center animation sharp_pulse = beacon_animation( color=red, @@ -869,7 +869,7 @@ run spotlight #### Common Use Cases **Spotlight Effects:** -```dsl +```berry # Moving spotlight with soft edges animation moving_spotlight = beacon_animation( color=white, @@ -881,7 +881,7 @@ moving_spotlight.pos = triangle(min_value=0, max_value=29, period=3s) ``` **Position Markers:** -```dsl +```berry # Sharp position marker animation position_marker = beacon_animation( color=red, @@ -892,7 +892,7 @@ animation position_marker = beacon_animation( ``` **Breathing Spots:** -```dsl +```berry # Breathing effect at specific position animation breathing_spot = beacon_animation( color=blue, @@ -960,7 +960,7 @@ The full period of the pattern is `pulse_size + low_size` pixels. #### Common Use Cases **Status Indicators:** -```dsl +```berry # Slow blinking pattern for status indication animation status_indicator = crenel_position_animation( color=green, @@ -970,7 +970,7 @@ animation status_indicator = crenel_position_animation( ``` **Rhythmic Effects:** -```dsl +```berry # Fast rhythmic pattern animation rhythm_pattern = crenel_position_animation( color=red, @@ -980,7 +980,7 @@ animation rhythm_pattern = crenel_position_animation( ``` **Decorative Borders:** -```dsl +```berry # Decorative border pattern color gold = 0xFFFFD700 animation border_pattern = crenel_position_animation( @@ -992,7 +992,7 @@ animation border_pattern = crenel_position_animation( ``` **Progress Indicators:** -```dsl +```berry # Progress bar with limited pulses animation progress_bar = crenel_position_animation( color=0xFF0080FF, @@ -1097,7 +1097,7 @@ Creates mathematical waveforms that can move along the LED strip. Perfect for rh #### Usage Examples -```dsl +```berry # Rainbow sine wave animation rainbow_wave = wave_animation( wave_type=0, @@ -1153,7 +1153,7 @@ Creates scrolling and translation effects by moving patterns horizontally across #### Usage Examples -```dsl +```berry # Scrolling text effect animation text_pattern = solid(color=white) animation scrolling_text = shift_animation( @@ -1197,7 +1197,7 @@ Creates size transformation effects with multiple animation modes including stat #### Usage Examples -```dsl +```berry # Breathing effect with oscillating scale animation base_pattern = gradient_animation(color=rainbow_cycle) animation breathing_effect = scale_animation( @@ -1271,7 +1271,7 @@ Motion effects are transformation animations that apply movement, scaling, and d Motion effects can be chained to create sophisticated transformations: -```dsl +```berry # Base animation animation base_pulse = pulsating_animation(color=blue, period=3s) diff --git a/lib/libesp32/berry_animation/docs/DSL_REFERENCE.md b/lib/libesp32/berry_animation/docs/DSL_REFERENCE.md index 55a3c989b..a09687895 100644 --- a/lib/libesp32/berry_animation/docs/DSL_REFERENCE.md +++ b/lib/libesp32/berry_animation/docs/DSL_REFERENCE.md @@ -10,7 +10,7 @@ The Animation DSL is a declarative language for defining LED strip animations. I Comments use the `#` character and extend to the end of the line: -```dsl +```berry # This is a full-line comment # strip length 30 # This is an inline comment (TEMPORARILY DISABLED) color red = #FF0000 # This is an inline comment @@ -22,7 +22,7 @@ Comments are preserved in the generated code and can appear anywhere in the DSL. A DSL program consists of statements that can appear in any order: -```dsl +```berry # Strip configuration is handled automatically # strip length 60 # TEMPORARILY DISABLED @@ -114,7 +114,7 @@ The following color names are predefined and cannot be redefined: ### Numbers -```dsl +```berry 42 # Integer 3.14 # Floating point -5 # Negative number @@ -124,7 +124,7 @@ The following color names are predefined and cannot be redefined: Time values require a unit suffix and are automatically converted to milliseconds: -```dsl +```berry 500ms # Milliseconds (stays 500) 2s # Seconds (converted to 2000ms) 1m # Minutes (converted to 60000ms) @@ -135,7 +135,7 @@ Time values require a unit suffix and are automatically converted to millisecond Percentages use the `%` suffix and are automatically converted to 0-255 range with possible over-shooting: -```dsl +```berry 0% # 0 percent (converted to 0) 50% # 50 percent (converted to 128) 100% # 100 percent (converted to 255) @@ -146,14 +146,14 @@ Percentages use the `%` suffix and are automatically converted to 0-255 range wi #### Hexadecimal Colors -```dsl +```berry 0xFF0000 # Red (RGB format) 0x80FF0000 # Semi-transparent red (ARGB format) ``` #### Named Colors -```dsl +```berry red # Predefined color name blue # Predefined color name transparent # Transparent color @@ -161,7 +161,7 @@ transparent # Transparent color ### Strings -```dsl +```berry "hello" # Double-quoted string 'world' # Single-quoted string ``` @@ -170,7 +170,7 @@ transparent # Transparent color Identifiers must start with a letter or underscore, followed by letters, digits, or underscores: -```dsl +```berry my_color # Valid identifier _private_var # Valid identifier Color123 # Valid identifier @@ -184,7 +184,7 @@ Color123 # Valid identifier ~~The `strip` statement configures the LED strip and must be the first statement if present:~~ -```dsl +```berry # strip length 60 # TEMPORARILY DISABLED ``` @@ -194,7 +194,7 @@ Color123 # Valid identifier The `set` keyword assigns static values or value providers to global variables: -```dsl +```berry set brightness = 200 # Static integer value set cycle_time = 5s # Static time value (converted to 5000ms) set opacity_level = 80% # Static percentage (converted to 204) @@ -211,7 +211,7 @@ set strip_len = strip_length() # Get current strip length The `color` keyword defines static colors or color providers: -```dsl +```berry # Static colors color red = 0xFF0000 # Static hex color color blue = 0x0000FF # Static hex color @@ -246,7 +246,7 @@ Palettes define color gradients using position-color pairs and support two encod Standard palettes use value positions from 0-255: -```dsl +```berry # Traditional syntax with commas palette fire_colors = [ (0, 0x000000), # Position 0: Black @@ -274,7 +274,7 @@ palette matrix_greens = [ Palettes can also use tick counts for timing-based transitions: -```dsl +```berry palette timed_colors = [ (10, 0xFF0000), # Red for 10 ticks (20, 0x00FF00), # Green for 20 ticks @@ -294,7 +294,7 @@ palette timed_colors = [ The `animation` keyword defines instances of animation classes (subclasses of Animation): -```dsl +```berry animation red_solid = solid(color=red) animation pulse_effect = pulsating_animation( @@ -319,7 +319,7 @@ animation comet_trail = comet_animation( Animation properties can be modified after creation: -```dsl +```berry animation pulse_red = pulsating_animation(color=red, period=2s) # Set properties @@ -348,7 +348,7 @@ pulse_red.opacity = strip_len * 4 # Scale with strip size The DSL supports computed values using arithmetic expressions with value providers and mathematical functions: -```dsl +```berry # Get strip dimensions set strip_len = strip_length() @@ -403,7 +403,7 @@ The following mathematical functions are available in computed parameters and ar | `cosine(angle)` | Returns cosine of angle | Angle in 0-255 range (0-360°) | Cosine value in -255 to 255 range | **Mathematical Function Examples:** -```dsl +```berry # Basic math functions set strip_len = strip_length() animation test = pulsating_animation(color=red, period=2s) @@ -445,7 +445,7 @@ When the DSL detects arithmetic expressions containing value providers, variable **User Functions in Computed Parameters:** User-defined functions can also be used in computed parameter expressions, providing powerful custom effects: -```dsl +```berry # Simple user function in computed parameter animation base = solid(color=blue) base.opacity = rand_demo() @@ -465,7 +465,7 @@ User functions are custom Berry functions that can be called from computed param - `rand_demo()` - Returns random values for demonstration purposes **Usage in Computed Parameters:** -```dsl +```berry # Simple user function animation.opacity = rand_demo() @@ -493,7 +493,7 @@ The following user functions are available by default (see [User Functions Guide Sequences orchestrate multiple animations with timing control: -```dsl +```berry sequence demo { play red_animation for 3s wait 1s @@ -511,21 +511,21 @@ sequence demo { #### Play Statement -```dsl +```berry play animation_name # Play indefinitely play animation_name for 5s # Play for specific duration ``` #### Wait Statement -```dsl +```berry wait 1s # Wait for 1 second wait 500ms # Wait for 500 milliseconds ``` #### Repeat Statement -```dsl +```berry repeat 5 times: play effect for 1s wait 500ms @@ -543,7 +543,7 @@ repeat 3 times: Execute animations or sequences: -```dsl +```berry run animation_name # Run an animation run sequence_name # Run a sequence ``` @@ -552,7 +552,7 @@ run sequence_name # Run a sequence ### Arithmetic Operators -```dsl +```berry + # Addition - # Subtraction (also unary minus) * # Multiplication @@ -562,7 +562,7 @@ run sequence_name # Run a sequence ### Comparison Operators -```dsl +```berry == # Equal to != # Not equal to < # Less than @@ -573,7 +573,7 @@ run sequence_name # Run a sequence ### Logical Operators -```dsl +```berry && # Logical AND || # Logical OR ! # Logical NOT @@ -581,7 +581,7 @@ run sequence_name # Run a sequence ### Assignment Operators -```dsl +```berry = # Simple assignment ``` @@ -589,7 +589,7 @@ run sequence_name # Run a sequence Functions use named parameter syntax with flexible formatting: -```dsl +```berry # Single line (commas required) function_name(param1=value1, param2=value2) @@ -608,7 +608,7 @@ function_name( ``` **Examples:** -```dsl +```berry # Traditional single-line syntax solid(color=red) pulsating_animation(color=blue, period=2s) @@ -629,7 +629,7 @@ comet_animation( ``` **Nested Function Calls:** -```dsl +```berry pulsating_animation( color=solid(color=red) period=smooth( @@ -643,7 +643,7 @@ pulsating_animation( **Mathematical Functions in Computed Parameters:** Mathematical functions can be used in computed parameter expressions and are automatically detected by the transpiler: -```dsl +```berry animation wave = pulsating_animation( color=blue period=2s @@ -682,7 +682,7 @@ Value providers create dynamic values that change over time: | `elastic` | Elastic easing with spring-like overshoot | | `bounce` | Bounce easing like a ball with decreasing amplitude | -```dsl +```berry # Direct oscillator usage triangle(min_value=0, max_value=255, period=2s) # Triangle wave smooth(min_value=50, max_value=200, period=3s) # Smooth cosine @@ -766,7 +766,7 @@ The DSL validates class and parameter existence during compilation, catching err ### Common Errors -```dsl +```berry # Invalid: Redefining predefined color color red = 0x800000 # Error: Cannot redefine 'red' @@ -886,12 +886,12 @@ newline = "\n" | "\r\n" ; The DSL supports flexible parameter syntax that makes multi-line function calls more readable: ### Traditional Syntax (Commas Required) -```dsl +```berry animation stream = comet_animation(color=red, tail_length=15, speed=1.5s, priority=10) ``` ### New Multi-Line Syntax (Commas Optional) -```dsl +```berry animation stream = comet_animation( color=red tail_length=15 @@ -901,7 +901,7 @@ animation stream = comet_animation( ``` ### Mixed Syntax (Both Supported) -```dsl +```berry animation stream = comet_animation( color=red, tail_length=15 speed=1.5s diff --git a/lib/libesp32/berry_animation/docs/DSL_TRANSPILATION.md b/lib/libesp32/berry_animation/docs/DSL_TRANSPILATION.md index 1aba70a9c..a840f96a1 100644 --- a/lib/libesp32/berry_animation/docs/DSL_TRANSPILATION.md +++ b/lib/libesp32/berry_animation/docs/DSL_TRANSPILATION.md @@ -102,7 +102,7 @@ The Animation DSL uses a declarative syntax with named parameters. All animation ### Basic Structure -```dsl +```berry # Optional strip configuration strip length 60 @@ -133,7 +133,7 @@ The DSL transpiler uses intelligent symbol resolution at compile time to optimiz When the DSL encounters an identifier (like `SINE` or `red`), it checks at transpile time whether the symbol exists in the `animation` module using Berry's introspection capabilities: -```dsl +```berry # If SINE exists in animation module animation wave = wave_animation(waveform=SINE) # Transpiles to: animation.SINE (direct access) @@ -168,7 +168,7 @@ animation solid_red = solid(color=custom_color) Property assignments also use the same resolution logic: -```dsl +```berry # Built-in symbol (if 'engine' existed in animation module) engine.brightness = 200 # Would transpile to: animation.engine.brightness = 200 @@ -200,7 +200,7 @@ end animation.register_user_function("sparkle", custom_sparkle) ``` -```dsl +```berry # Use in DSL - engine is automatically passed as first argument animation gold_sparkle = sparkle(#FFD700, 8, 500ms) animation blue_sparkle = sparkle(blue, 12, 300ms) @@ -215,7 +215,7 @@ For comprehensive examples and best practices, see the **[User Functions Guide]( Define event handlers that respond to triggers: -```dsl +```berry # Define animations for different states color normal = #000080 color alert = #FF0000 @@ -243,7 +243,7 @@ run normal_state DSL supports nested function calls for complex compositions: -```dsl +```berry # Nested calls in animation definitions (now supported) animation complex = pulsating_animation( source=shift_animation( @@ -280,7 +280,7 @@ end The DSL performs comprehensive validation during compilation: **Animation Factory Validation:** -```dsl +```berry # Error: Function doesn't exist animation bad = nonexistent_animation(color=red) # Transpiler error: "Animation factory function 'nonexistent_animation' does not exist" @@ -291,7 +291,7 @@ animation bad2 = math_function(value=10) ``` **Parameter Validation:** -```dsl +```berry # Error: Invalid parameter name animation pulse = pulsating_animation(invalid_param=123) # Transpiler error: "Parameter 'invalid_param' is not valid for pulsating_animation" @@ -302,7 +302,7 @@ animation comet = comet_animation(tail_length=-5) ``` **Color Provider Validation:** -```dsl +```berry # Error: Color provider doesn't exist color bad = nonexistent_color_provider(period=2s) # Transpiler error: "Color provider factory 'nonexistent_color_provider' does not exist" @@ -313,7 +313,7 @@ color bad2 = pulsating_animation(color=red) ``` **Reference Validation:** -```dsl +```berry # Error: Undefined color reference animation pulse = pulsating_animation(color=undefined_color) # Transpiler error: "Undefined reference: 'undefined_color'" @@ -428,7 +428,7 @@ webserver.on("/execute_dsl", web_execute_dsl) ## Best Practices 1. **Structure your DSL files**: - ```dsl + ```berry # Strip configuration first strip length 60 @@ -453,7 +453,7 @@ webserver.on("/execute_dsl", web_execute_dsl) ``` 2. **Use meaningful names**: - ```dsl + ```berry # Good color warning_red = #FF0000 animation door_alert = pulsating_animation(color=warning_red, period=500ms) @@ -464,7 +464,7 @@ webserver.on("/execute_dsl", web_execute_dsl) ``` 3. **Comment your DSL**: - ```dsl + ```berry # Security system colors color normal_blue = #000080 # Idle state color alert_red = #FF0000 # Alert state diff --git a/lib/libesp32/berry_animation/docs/EXAMPLES.md b/lib/libesp32/berry_animation/docs/EXAMPLES.md index cfb48b1fc..12580b1c5 100644 --- a/lib/libesp32/berry_animation/docs/EXAMPLES.md +++ b/lib/libesp32/berry_animation/docs/EXAMPLES.md @@ -5,21 +5,21 @@ Essential examples showcasing the Tasmota Berry Animation Framework using DSL sy ## Basic Animations ### 1. Solid Color -```dsl +```berry color red = 0xFF0000 animation red_solid = solid(color=red) run red_solid ``` ### 2. Pulsing Effect -```dsl +```berry color blue = 0x0000FF animation blue_pulse = pulsating_animation(color=blue, period=2s) run blue_pulse ``` ### 3. Moving Comet -```dsl +```berry color cyan = 0x00FFFF animation comet_trail = comet_animation(color=cyan, tail_length=8, speed=100ms, direction=1) run comet_trail @@ -28,7 +28,7 @@ run comet_trail ## Using Value Providers ### 4. Breathing Effect -```dsl +```berry set breathing = smooth(min_value=50, max_value=255, period=3s) color white = 0xFFFFFF animation breathing_white = solid(color=white) @@ -37,7 +37,7 @@ run breathing_white ``` ### 5. Color Cycling -```dsl +```berry color rainbow = rainbow_color_provider(period=5s) animation rainbow_cycle = solid(color=rainbow) run rainbow_cycle @@ -46,7 +46,7 @@ run rainbow_cycle ## Palette Animations ### 6. Fire Effect -```dsl +```berry palette fire_colors = [ (0, 0x000000), # Black (128, 0xFF0000), # Red @@ -61,7 +61,7 @@ run fire_effect ## Sequences ### 7. RGB Show -```dsl +```berry color red = 0xFF0000 color green = 0x00FF00 color blue = 0x0000FF @@ -79,7 +79,7 @@ run rgb_show ``` ### 8. Sunrise Sequence -```dsl +```berry color deep_blue = 0x000080 color orange = 0xFFA500 color yellow = 0xFFFF00 @@ -99,7 +99,7 @@ run sunrise_show ## User Functions in Computed Parameters ### 9. Simple User Function -```dsl +```berry # Simple user function in computed parameter animation random_base = solid(color=blue, priority=10) random_base.opacity = rand_demo() @@ -107,7 +107,7 @@ run random_base ``` ### 10. User Function with Math Operations -```dsl +```berry # Mix user functions with mathematical functions animation random_bounded = solid( color=purple @@ -118,7 +118,7 @@ run random_bounded ``` ### 11. User Function in Arithmetic Expression -```dsl +```berry # Use user function in arithmetic expressions animation random_variation = solid( color=cyan @@ -133,7 +133,7 @@ See `anim_examples/user_functions_demo.anim` for a complete working example. ## Advanced Examples ### 13. Dynamic Position -```dsl +```berry strip length 60 set moving_position = smooth(min_value=5, max_value=55, period=4s) @@ -149,7 +149,7 @@ run moving_pulse ``` ### 14. Multi-Layer Effect -```dsl +```berry # Base layer - slow breathing set breathing = smooth(min_value=100, max_value=255, period=4s) color base_blue = 0x000080 @@ -171,7 +171,7 @@ run layered_effect ## Tips for Creating Animations ### Start Simple -```dsl +```berry # Begin with basic colors and effects color my_color = 0xFF0000 animation simple = solid(color=my_color) @@ -179,7 +179,7 @@ run simple ``` ### Use Meaningful Names -```dsl +```berry # Good - descriptive names color sunset_orange = 0xFF8C00 animation evening_glow = pulsating_animation(color=sunset_orange, period=4s) diff --git a/lib/libesp32/berry_animation/docs/OSCILLATION_PATTERNS.md b/lib/libesp32/berry_animation/docs/OSCILLATION_PATTERNS.md index e447fb829..29fbd3252 100644 --- a/lib/libesp32/berry_animation/docs/OSCILLATION_PATTERNS.md +++ b/lib/libesp32/berry_animation/docs/OSCILLATION_PATTERNS.md @@ -21,7 +21,7 @@ These waveform constants can be used with `oscillator_value`: ## DSL Usage ### With Oscillator Value Provider -```dsl +```berry # Basic oscillator with different waveform types set breathing = oscillator_value(min_value=50, max_value=255, duration=3000, form=COSINE) set pulsing = ease_in(min_value=0, max_value=255, duration=2000) @@ -29,7 +29,7 @@ set bouncing = oscillator_value(min_value=10, max_value=240, duration=4000, form ``` ### Using Alias Functions -```dsl +```berry # These are equivalent to oscillator_value with specific forms set smooth_fade = smooth(min_value=50, max_value=255, duration=3000) # form=COSINE set sine_wave = sine(min_value=50, max_value=255, duration=3000) # form=SINE @@ -38,7 +38,7 @@ set triangle_wave = triangle(min_value=10, max_value=240, duration=4000) # form ``` ### In Animations -```dsl +```berry color blue = 0x0000FF set breathing = smooth(min_value=100, max_value=255, duration=4000) @@ -66,7 +66,7 @@ Value +------+------+----> Time ``` -```dsl +```berry set linear_brightness = linear(min_value=0, max_value=255, duration=2000) ``` @@ -75,7 +75,7 @@ set linear_brightness = linear(min_value=0, max_value=255, duration=2000) - **Natural feeling** transitions - **Best for**: Breathing effects, gentle fades -```dsl +```berry set breathing_effect = smooth(min_value=50, max_value=255, duration=3000) ``` @@ -99,7 +99,7 @@ Value +--------------------+----> Time ``` -```dsl +```berry set wave_motion = sine(min_value=0, max_value=255, duration=2000) ``` @@ -121,7 +121,7 @@ Value +-------------+----> Time ``` -```dsl +```berry set bounce_position = triangle(min_value=5, max_value=55, duration=2000) ``` @@ -142,7 +142,7 @@ Value +-+-------------+----> Time ``` -```dsl +```berry set strobe_effect = square(min_value=0, max_value=255, duration=500, duty_cycle=25) ``` @@ -151,7 +151,7 @@ set strobe_effect = square(min_value=0, max_value=255, duration=500, duty_cycle= - **Smooth acceleration** curve - **Best for**: Starting animations, building intensity -```dsl +```berry set accelerating = ease_in(min_value=0, max_value=255, duration=3000) ``` @@ -160,7 +160,7 @@ set accelerating = ease_in(min_value=0, max_value=255, duration=3000) - **Smooth deceleration** curve - **Best for**: Ending animations, gentle stops -```dsl +```berry set decelerating = ease_out(min_value=255, max_value=0, duration=3000) ``` @@ -179,7 +179,7 @@ For a cycle from 0 to 100 over 2000ms: ## Common Patterns ### Breathing Effect -```dsl +```berry color soft_white = 0xC0C0C0 set breathing = smooth(min_value=80, max_value=255, duration=4000) @@ -189,7 +189,7 @@ run breathing_light ``` ### Position Sweep -```dsl +```berry strip length 60 color red = 0xFF0000 set sweeping_position = linear(min_value=0, max_value=59, duration=3000) @@ -204,7 +204,7 @@ run position_sweep ``` ### Wave Motion -```dsl +```berry color purple = 0x8000FF set wave_brightness = sine(min_value=50, max_value=255, duration=2500) @@ -214,7 +214,7 @@ run wave_effect ``` ### Bouncing Effect -```dsl +```berry color green = 0x00FF00 set bounce_size = triangle(min_value=1, max_value=8, duration=1000) @@ -228,7 +228,7 @@ run bouncing_pulse ``` ### Accelerating Fade -```dsl +```berry color blue = 0x0000FF set fade_in = ease_in(min_value=0, max_value=255, duration=5000) @@ -238,7 +238,7 @@ run accelerating_fade ``` ### Strobe Effect -```dsl +```berry color white = 0xFFFFFF set strobe_pattern = square(min_value=0, max_value=255, duration=200, duty_cycle=10) diff --git a/lib/libesp32/berry_animation/docs/QUICK_START.md b/lib/libesp32/berry_animation/docs/QUICK_START.md index 9982fcf19..fef28ff44 100644 --- a/lib/libesp32/berry_animation/docs/QUICK_START.md +++ b/lib/libesp32/berry_animation/docs/QUICK_START.md @@ -11,7 +11,7 @@ Get up and running with the Berry Animation Framework in 5 minutes using the DSL Create a simple pulsing red light: -```dsl +```berry # Define colors color red = #FF0000 @@ -26,7 +26,7 @@ run pulse_red Create smooth color transitions: -```dsl +```berry # Use predefined rainbow palette animation rainbow_cycle = rich_palette( palette=PALETTE_RAINBOW, @@ -41,7 +41,7 @@ run rainbow_cycle Create your own color palettes: -```dsl +```berry # Define a sunset palette palette sunset = [ (0, #191970), # Midnight blue @@ -65,7 +65,7 @@ run sunset_glow Create complex shows with sequences: -```dsl +```berry animation red_pulse = pulsating_animation(color=red, period=2s) animation green_pulse = pulsating_animation(color=green, period=2s) animation blue_pulse = pulsating_animation(color=blue, period=2s) @@ -90,7 +90,7 @@ run rgb_show Add movement and variation to your animations: -```dsl +```berry # Breathing effect with smooth oscillation animation breathing = pulsating_animation( color=blue, @@ -119,7 +119,7 @@ run breathing ## Common Patterns ### Fire Effect -```dsl +```berry animation fire = rich_palette( palette=PALETTE_FIRE, cycle_period=2s, @@ -130,7 +130,7 @@ run fire ``` ### Ocean Waves -```dsl +```berry animation ocean = rich_palette( palette=PALETTE_OCEAN, cycle_period=6s, @@ -177,7 +177,7 @@ end animation.register_user_function("sparkle", my_sparkle) ``` -```dsl +```berry # Use in DSL - engine is automatically passed animation gold_sparkles = sparkle(#FFD700, 8, 500ms) run gold_sparkles diff --git a/lib/libesp32/berry_animation/docs/TROUBLESHOOTING.md b/lib/libesp32/berry_animation/docs/TROUBLESHOOTING.md index d4fe9bec7..86801780b 100644 --- a/lib/libesp32/berry_animation/docs/TROUBLESHOOTING.md +++ b/lib/libesp32/berry_animation/docs/TROUBLESHOOTING.md @@ -81,7 +81,7 @@ end **Common Solutions:** 1. **Missing Strip Declaration:** - ```dsl + ```berry # Add explicit strip length if needed strip length 30 @@ -91,7 +91,7 @@ end ``` 2. **Animation Not Executed:** - ```dsl + ```berry # Make sure you have a 'run' statement color red = 0xFF0000 animation red_anim = solid(color=red) @@ -99,7 +99,7 @@ end ``` 3. **Strip Auto-Detection Issues:** - ```dsl + ```berry # Force strip length if auto-detection fails strip length 30 # Must be first statement @@ -115,7 +115,7 @@ end **Common Issues:** 1. **Missing Alpha Channel:** - ```dsl + ```berry # Note: 0xFF0000 is valid RGB format (alpha defaults to 0xFF) color red = 0xFF0000 # RGB format (alpha=255 assumed) @@ -125,7 +125,7 @@ end ``` 2. **Color Format Confusion:** - ```dsl + ```berry # ARGB format: 0xAARRGGBB color red = 0xFFFF0000 # Alpha=FF, Red=FF, Green=00, Blue=00 color green = 0xFF00FF00 # Alpha=FF, Red=00, Green=FF, Blue=00 @@ -133,7 +133,7 @@ end ``` 3. **Brightness Issues:** - ```dsl + ```berry # Use opacity parameter or property assignment animation red_anim = solid(color=red, opacity=255) # Full brightness @@ -154,14 +154,14 @@ end **Solutions:** 1. **Check Time Units:** - ```dsl + ```berry # DSL uses time units (converted to milliseconds) animation pulse_anim = pulsating_animation(color=red, period=2s) # 2 seconds animation fast_pulse = pulsating_animation(color=blue, period=500ms) # 0.5 seconds ``` 2. **Adjust Periods:** - ```dsl + ```berry # Too fast - increase period animation slow_pulse = pulsating_animation(color=red, period=5s) # 5 seconds @@ -170,7 +170,7 @@ end ``` 3. **Performance Limitations:** - ```dsl + ```berry # Use sequences instead of multiple simultaneous animations sequence optimized_show { play animation1 for 3s @@ -204,7 +204,7 @@ end **Common DSL Errors:** 1. **Undefined Colors:** - ```dsl + ```berry # Wrong - color not defined animation red_anim = solid(color=red) @@ -214,7 +214,7 @@ end ``` 2. **Invalid Color Format:** - ```dsl + ```berry # Wrong - # prefix not supported (conflicts with comments) color red = #FF0000 @@ -223,7 +223,7 @@ end ``` 3. **Missing Time Units:** - ```dsl + ```berry # Wrong - no time unit animation pulse_anim = pulsating_animation(color=red, period=2000) @@ -232,7 +232,7 @@ end ``` 4. **Reserved Name Conflicts:** - ```dsl + ```berry # Wrong - 'red' is a predefined color color red = 0x800000 @@ -241,7 +241,7 @@ end ``` 5. **Invalid Parameter Names:** - ```dsl + ```berry # Wrong - invalid parameter name animation pulse_anim = pulsating_animation(color=red, invalid_param=123) # Error: "Parameter 'invalid_param' is not valid for pulsating_animation" @@ -251,7 +251,7 @@ end ``` 6. **Parameter Constraint Violations:** - ```dsl + ```berry # Wrong - negative period not allowed animation bad_pulse = pulsating_animation(color=red, period=-2s) # Error: "Parameter 'period' value -2000 violates constraint: min=1" @@ -272,7 +272,7 @@ end **Common Issues:** 1. **Strip Not Initialized:** - ```dsl + ```berry # Add strip declaration if needed strip length 30 @@ -282,7 +282,7 @@ end ``` 2. **Sequence Issues:** - ```dsl + ```berry # Make sure animations are defined before sequences color red = 0xFF0000 animation red_anim = solid(color=red) # Define first @@ -295,7 +295,7 @@ end ``` 3. **Undefined References:** - ```dsl + ```berry # Wrong - using undefined animation in sequence sequence bad_demo { play undefined_animation for 3s @@ -321,7 +321,7 @@ end **Solutions:** 1. **Use Sequences Instead of Multiple Animations:** - ```dsl + ```berry # Good - sequential playback sequence smooth_show { play animation1 for 3s @@ -337,7 +337,7 @@ end ``` 2. **Increase Animation Periods:** - ```dsl + ```berry # Smooth - longer periods animation smooth_pulse = pulsating_animation(color=red, period=3s) @@ -346,7 +346,7 @@ end ``` 3. **Optimize Value Providers:** - ```dsl + ```berry # Efficient - reuse providers set breathing = smooth(min_value=50, max_value=255, period=2s) @@ -374,7 +374,7 @@ end ``` 2. **Limit Palette Size:** - ```dsl + ```berry # Good - reasonable palette size palette simple_fire = [ (0, #000000), @@ -389,7 +389,7 @@ end ``` 3. **Use Sequences Instead of Simultaneous Animations:** - ```dsl + ```berry # Memory efficient - sequential playback sequence show { play animation1 for 5s @@ -637,7 +637,7 @@ When asking for help, include: - ESP32 with 5V/2A power supply **Code:** -```dsl +```berry color red = 0xFF0000 animation red_anim = solid(color=red) run red_anim @@ -708,21 +708,21 @@ This format helps identify issues quickly and provide targeted solutions. ## Quick Reference: Common DSL Patterns ### Basic Animation -```dsl +```berry color red = 0xFF0000 animation red_solid = solid(color=red) run red_solid ``` ### Animation with Parameters -```dsl +```berry color blue = 0x0000FF animation blue_pulse = pulsating_animation(color=blue, period=2s, opacity=200) run blue_pulse ``` ### Using Value Providers -```dsl +```berry set breathing = smooth(min_value=50, max_value=255, period=3s) color green = 0x00FF00 animation breathing_green = solid(color=green) @@ -731,7 +731,7 @@ run breathing_green ``` ### Sequences -```dsl +```berry color red = 0xFF0000 color blue = 0x0000FF @@ -747,7 +747,7 @@ run demo ``` ### Multiple Strip Lengths -```dsl +```berry strip length 60 # Must be first statement color rainbow = rainbow_color_provider(period=5s) diff --git a/lib/libesp32/berry_animation/docs/USER_FUNCTIONS.md b/lib/libesp32/berry_animation/docs/USER_FUNCTIONS.md index 545b0394a..ad7e8c62e 100644 --- a/lib/libesp32/berry_animation/docs/USER_FUNCTIONS.md +++ b/lib/libesp32/berry_animation/docs/USER_FUNCTIONS.md @@ -32,7 +32,7 @@ animation.register_user_function("breathing", my_breathing) Call your function just like built-in animations: -```dsl +```berry # Use your custom function animation calm = breathing(blue, 4s) animation energetic = breathing(red, 1s) @@ -60,7 +60,7 @@ end animation.register_user_function("bright", solid_bright) ``` -```dsl +```berry animation bright_red = bright(red, 80%) animation dim_blue = bright(blue, 30%) ``` @@ -82,7 +82,7 @@ end animation.register_user_function("fire", custom_fire) ``` -```dsl +```berry animation campfire = fire(200, 2s) animation torch = fire(255, 500ms) ``` @@ -101,7 +101,7 @@ end animation.register_user_function("sparkles", sparkles) ``` -```dsl +```berry animation stars = sparkles(white, 12, 300ms) animation fairy_dust = sparkles(#FFD700, 8, 500ms) ``` @@ -121,7 +121,7 @@ end animation.register_user_function("pulse_at", pulse_at) ``` -```dsl +```berry animation left_pulse = pulse_at(green, 5, 3, 2s) animation right_pulse = pulse_at(blue, 25, 3, 2s) ``` @@ -174,7 +174,7 @@ animation.register_user_function("strobe", warning_strobe) animation.register_user_function("alert", gentle_alert) ``` -```dsl +```berry animation emergency = strobe() animation notification = alert() animation custom_police = police(500ms) @@ -299,7 +299,7 @@ User functions can be used in computed parameter expressions alongside mathemati ### Simple User Function in Computed Parameter -```dsl +```berry # Simple user function call in property assignment animation base = solid(color=blue, priority=10) base.opacity = rand_demo() # User function as computed parameter @@ -307,7 +307,7 @@ base.opacity = rand_demo() # User function as computed parameter ### User Functions with Mathematical Operations -```dsl +```berry # Get strip length for calculations set strip_len = strip_length() @@ -321,7 +321,7 @@ animation dynamic_solid = solid( ### User Functions in Complex Expressions -```dsl +```berry # Use user function in arithmetic expressions animation random_effect = solid( color=cyan @@ -340,7 +340,7 @@ When you use user functions in computed parameters: 4. **Mixed Operations**: User functions work seamlessly with mathematical functions and arithmetic **Generated Code Example:** -```dsl +```berry # DSL code animation.opacity = max(100, breathing(red, 2000)) ``` @@ -436,7 +436,7 @@ end ### How the DSL Transpiler Works When you write DSL like this: -```dsl +```berry animation my_anim = my_function(arg1, arg2) ```