bicycle rear light

sample animation for elektra simulator

This animation uses 4 threads: 1 for launch and 1 for each LED ring. Full-on and side-mounted LEDS on the Elektra LED development board provide a wide viewing angle for this animation.

 Loading animation...

Glowscript:

// DEVICE (modify with care)

 

    // Elektra simulator

    device: name = 'simulator-elektra-20'

    device: type = 'sim'

    device: tickIntervalMillisecs = '50'     // increase to reduce CPU load.

    device: protocolVersion = '1.0'

    device: ledCount = '20'

    device: ramSpaceBytes = '25000'          // set an animation size limit in memory.

    device: romSpaceBytes = '200000'         // set an animation size limit on disk.

 

// DEFINES (modify as needed)

 

    // LED defines:

    define: innerLeds = '[1-4]'    // alias for inner-ring leds.

    define: outerLeds = '[5-12]'

    define: edgeLeds = '[13-20]'

    define: allLeds = '[1-20]'

 

    // Color defines:

    define: red = '(12,0,0,1)'

    define: green = '(0,12,0,1)'

    define: blue = '(0,0,12,1)'

    define: turquoise = '(0,10,10,1)'

    define: yellow = '(10,10,0,1)'

    define: white = '(4,4,4,1)'

    define: orange = '(30,10,0,1)'

    define: purple = '(10,0,10,1)'

    define: off = '(0,0,0,1)'

 

// CODE

 

// Simultaneously launches 3 functions then exits.

@start                             // mandatory entry-point function name.

    callAsync: @strobeInnerRing    // launch function asynchronously.

    callAsync: @pulseOuterRing     // launch function asynchronously.

    callAsync: @strobeEdgeRing     // launch function asynchronously.

 

// Continuously runs inner-ring light strobe. Each loop cycle has a 1-second duration.

@strobeInnerRing

    here: start_tag                     // set bookmark.

    glowImmediate: innerLeds red        // set led(s) to red.

    call: @flashInnerRing (repeat=5)    // synchronously call function 5 times.

    pause: 500ms                        // pause for 500 milliseconds.

    goto: start_tag                     // loop back to bookmark.

 

// Flashes inner-ring LED(s) once then exits.

@flashInnerRing

    pause: 50ms                    // pause for 50 milliseconds.

    glowImmediate: innerLeds off   // turn led(s) off.

    pause: 50ms

    glowImmediate: innerLeds red   // set led(s) to red.

 

// Pulses outer-ring LED(s) in a continuous loop. Each loop cycle has a 1-second duration.

@pulseOuterRing

    here: start_tag                          // set bookmark.

    glowRamp: outerLeds off to red in 500ms  // gradually brighten led(s) to red.

    glowRamp: outerLeds red to off in 500ms  // set led(s) to red then fade off.

    goto: start_tag                          // loop back to bookmark.

 

// Continuously runs edge-ring light strobe. Each loop cycle has a 1-second duration.

@strobeEdgeRing

    here: start_tag                     // set bookmark.

    glowImmediate: edgeLeds red         // set led(s) to red.

    pause: 500ms                        // pause for 500 milliseconds.

    call: @flashEdgeRing (repeat=5)     // synchronously call function 5 times.

    goto: start_tag                     // loop back to bookmark.

 

// Flashes edge-ring LED(s) once then exits.

@flashEdgeRing

    pause: 50ms                         // pause for 50 milliseconds.

    glowImmediate: edgeLeds off         // turn led(s) off.

    pause: 50ms                         // pause for 50 milliseconds.

    glowImmediate: edgeLeds red         // set led(s) to red.