79 lines
2.5 KiB
Plaintext
79 lines
2.5 KiB
Plaintext
# Generated Berry code from Animation DSL
|
|
# Source: cylon_generic.anim
|
|
#
|
|
# This file was automatically generated by compile_all_examples.sh
|
|
# Do not edit manually - changes will be overwritten
|
|
|
|
import animation
|
|
|
|
# Cylon Red Eye
|
|
# Automatically adapts to the length of the strip
|
|
# Template animation class: cylon
|
|
class cylon_animation : animation.engine_proxy
|
|
static var PARAMS = animation.enc_params({
|
|
"eye_color": {"type": "color"},
|
|
"back_color": {"type": "color"},
|
|
"period": {"type": "time"}
|
|
})
|
|
|
|
# Template setup method - overrides engine_proxy placeholder
|
|
def setup_template()
|
|
var engine = self # using 'self' as a proxy to engine object (instead of 'self.engine')
|
|
|
|
var strip_len_ = animation.strip_length(engine)
|
|
var eye_animation_ = animation.beacon(engine)
|
|
eye_animation_.color = animation.create_closure_value(engine, def (engine) return self.eye_color end)
|
|
eye_animation_.back_color = animation.create_closure_value(engine, def (engine) return self.back_color end)
|
|
eye_animation_.pos = (def (engine)
|
|
var provider = animation.cosine_osc(engine)
|
|
provider.min_value = (-1)
|
|
provider.max_value = animation.create_closure_value(engine, def (engine) return animation.resolve(strip_len_) - 2 end)
|
|
provider.duration = animation.create_closure_value(engine, def (engine) return self.period end)
|
|
return provider
|
|
end)(engine)
|
|
eye_animation_.beacon_size = 3 # small 3 pixels eye
|
|
eye_animation_.slew_size = 2 # with 2 pixel shading around
|
|
eye_animation_.priority = 5
|
|
self.add(eye_animation_)
|
|
end
|
|
end
|
|
|
|
# Auto-generated strip initialization (using Tasmota configuration)
|
|
var engine = animation.init_strip()
|
|
|
|
var cylon_red_ = cylon_animation(engine)
|
|
cylon_red_.eye_color = 0xFFFF0000
|
|
cylon_red_.back_color = 0x00000000
|
|
cylon_red_.period = 3000
|
|
engine.add(cylon_red_)
|
|
engine.run()
|
|
|
|
|
|
#- Original DSL source:
|
|
# Cylon Red Eye
|
|
# Automatically adapts to the length of the strip
|
|
|
|
template animation cylon {
|
|
param eye_color type color
|
|
param back_color type color
|
|
param period type time
|
|
|
|
set strip_len = strip_length()
|
|
|
|
animation eye_animation = beacon(
|
|
color = eye_color
|
|
back_color = back_color
|
|
pos = cosine_osc(min_value = -1, max_value = strip_len - 2, duration = period)
|
|
beacon_size = 3 # small 3 pixels eye
|
|
slew_size = 2 # with 2 pixel shading around
|
|
priority = 5
|
|
)
|
|
|
|
run eye_animation
|
|
}
|
|
|
|
animation cylon_red = cylon(eye_color = red, back_color = transparent, period = 3s)
|
|
run cylon_red
|
|
|
|
-#
|