# Generated Berry code from Animation DSL # Source: police_lights.anim # Generated automatically # # This file was automatically generated by compile_all_dsl_examples.sh # Do not edit manually - changes will be overwritten # 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 = pulse_position_animation( # 0xFF0000, # Bright red # 15, # center of left half # 15, # half the strip # 2 # sharp edges # ) # left_red.priority = 10 # left_red.opacity = square(0, 255, 400ms, 50) # 50% duty cycle # # # Right side blue flashing (opposite phase) # animation right_blue = pulse_position_animation( # 0x0000FF, # Bright blue # 45, # center of right half # 15, # half the strip # 2 # sharp edges # ) # right_blue.priority = 10 # right_blue.opacity = square(255, 0, 400ms, 50) # Opposite phase # # # Add white strobe overlay occasionally # animation white_strobe = solid(0xFFFFFF) # white_strobe.opacity = square(0, 255, 100ms, 5) # Quick bright flashes # white_strobe.priority = 20 # # # Start all animations # run left_red # run right_blue # run white_strobe import animation # Police Lights - Red and blue alternating flashes # Emergency vehicle style lighting var strip = global.Leds(60) var engine = animation.create_engine(strip) # Define zones for left and right halves var half_length_ = 30 # Left side red flashing var left_red_ = animation.pulse_position_animation(0xFFFF0000, 15, 15, 2) animation.global('left_red_').priority = 10 animation.global('left_red_').opacity = animation.square(0, 255, 400, 50) # 50% duty cycle # Right side blue flashing (opposite phase) var right_blue_ = animation.pulse_position_animation(0xFF0000FF, 45, 15, 2) animation.global('right_blue_').priority = 10 animation.global('right_blue_').opacity = animation.square(255, 0, 400, 50) # Opposite phase # Add white strobe overlay occasionally var white_strobe_ = animation.solid(0xFFFFFFFF) animation.global('white_strobe_').opacity = animation.square(0, 255, 100, 5) # Quick bright flashes animation.global('white_strobe_').priority = 20 # Start all animations # Start all animations/sequences if global.contains('sequence_left_red') var seq_manager = global.sequence_left_red() engine.add_sequence_manager(seq_manager) else engine.add_animation(animation.global('left_red_')) end if global.contains('sequence_right_blue') var seq_manager = global.sequence_right_blue() engine.add_sequence_manager(seq_manager) else engine.add_animation(animation.global('right_blue_')) end if global.contains('sequence_white_strobe') var seq_manager = global.sequence_white_strobe() engine.add_sequence_manager(seq_manager) else engine.add_animation(animation.global('white_strobe_')) end engine.start()