105 lines
3.1 KiB
Plaintext
105 lines
3.1 KiB
Plaintext
# Generated Berry code from Animation DSL
|
|
# Source: police_lights.anim
|
|
#
|
|
# This file was automatically generated by compile_all_examples.sh
|
|
# Do not edit manually - changes will be overwritten
|
|
|
|
import animation
|
|
|
|
# Police Lights - Red and blue alternating flashes
|
|
# Emergency vehicle style lighting
|
|
#strip length 60
|
|
# Define zones for left and right halves
|
|
# Auto-generated strip initialization (using Tasmota configuration)
|
|
var engine = animation.init_strip()
|
|
|
|
var half_length_ = 30
|
|
# Left side red flashing
|
|
var left_red_ = animation.beacon_animation(engine)
|
|
left_red_.color = 0xFFFF0000 # Bright red
|
|
left_red_.pos = 15 # center of left half
|
|
left_red_.beacon_size = 15 # half the strip
|
|
left_red_.slew_size = 2 # sharp edges
|
|
left_red_.priority = 10
|
|
left_red_.opacity = (def (engine)
|
|
var provider = animation.square(engine)
|
|
provider.min_value = 0
|
|
provider.max_value = 255
|
|
provider.duration = 400
|
|
provider.duty_cycle = 50
|
|
return provider
|
|
end)(engine) # 50% duty cycle
|
|
# Right side blue flashing (opposite phase)
|
|
var right_blue_ = animation.beacon_animation(engine)
|
|
right_blue_.color = 0xFF0000FF # Bright blue
|
|
right_blue_.pos = 45 # center of right half
|
|
right_blue_.beacon_size = 15 # half the strip
|
|
right_blue_.slew_size = 2 # sharp edges
|
|
right_blue_.priority = 10
|
|
right_blue_.opacity = (def (engine)
|
|
var provider = animation.square(engine)
|
|
provider.min_value = 255
|
|
provider.max_value = 0
|
|
provider.duration = 400
|
|
provider.duty_cycle = 50
|
|
return provider
|
|
end)(engine) # Opposite phase
|
|
# Add white strobe overlay occasionally
|
|
var white_strobe_ = animation.solid(engine)
|
|
white_strobe_.color = 0xFFFFFFFF
|
|
white_strobe_.opacity = (def (engine)
|
|
var provider = animation.square(engine)
|
|
provider.min_value = 0
|
|
provider.max_value = 255
|
|
provider.duration = 100
|
|
provider.duty_cycle = 5
|
|
return provider
|
|
end)(engine) # Quick bright flashes
|
|
white_strobe_.priority = 20
|
|
# Start all animations
|
|
engine.add_animation(left_red_)
|
|
engine.add_animation(right_blue_)
|
|
engine.add_animation(white_strobe_)
|
|
engine.start()
|
|
|
|
|
|
#- Original DSL source:
|
|
# Police Lights - Red and blue alternating flashes
|
|
# Emergency vehicle style lighting
|
|
|
|
#strip length 60
|
|
|
|
# Define zones for left and right halves
|
|
set half_length = 30
|
|
|
|
# Left side red flashing
|
|
animation left_red = beacon_animation(
|
|
color=0xFF0000 # Bright red
|
|
pos=15 # center of left half
|
|
beacon_size=15 # half the strip
|
|
slew_size=2 # sharp edges
|
|
)
|
|
left_red.priority = 10
|
|
left_red.opacity = square(min_value=0, max_value=255, duration=400ms, duty_cycle=50) # 50% duty cycle
|
|
|
|
# Right side blue flashing (opposite phase)
|
|
animation right_blue = beacon_animation(
|
|
color=0x0000FF # Bright blue
|
|
pos=45 # center of right half
|
|
beacon_size=15 # half the strip
|
|
slew_size=2 # sharp edges
|
|
)
|
|
right_blue.priority = 10
|
|
right_blue.opacity = square(min_value=255, max_value=0, duration=400ms, duty_cycle=50) # Opposite phase
|
|
|
|
# Add white strobe overlay occasionally
|
|
animation white_strobe = solid(color=0xFFFFFF)
|
|
white_strobe.opacity = square(min_value=0, max_value=255, duration=100ms, duty_cycle=5) # Quick bright flashes
|
|
white_strobe.priority = 20
|
|
|
|
# Start all animations
|
|
run left_red
|
|
run right_blue
|
|
run white_strobe
|
|
-#
|