# Sequencer

Process

Logic block representing a sequence

Sequencer
Fwd
Bwd
Rst
Off
O1
O2
O3
O4
O5
O6
O7
O8

# Inputs

IDAbbrevNameTypeDefaultDescription
forwardFwdForwardBOOLEANfalse
backwardBwdbackwardBOOLEANfalse
resetRstresetBOOLEANfalse

# Outputs

IDAbbrevNameTypeDefaultDescription
offOffOffBOOLEANtrue
o1O1Output #1BOOLEANfalse
o2O2Output #2BOOLEANfalse
o3O3Output #3BOOLEANfalse
o4O4Output #4BOOLEANfalse
o5O5Output #5BOOLEANfalse
o6O6Output #6BOOLEANfalse
o7O7Output #7BOOLEANfalse
o8O8Output #8BOOLEANfalse

# Configuration

IDNameTypeDefaultUnitDescription
max_indexMax indexNUMBER8

# State

IDNameTypeDefaultUnitDescription
sequence_indexSequence indexNUMBER0

# Source Code

View Volang source
outputs_count = 8
value = input::value()
// react only on a falling edge / after the pulse
if (value == true) {
    return
}

fn reset_all(count) {
    i = 1
    while (i <= count) {
        output::set(str::fmt("o{}", i), false)
        i += 1
    }
    output::set("off", false)
}

fn move(index, steps) {
    max_index = config::get("max_index")
    new_index = index + steps
    if (new_index > max_index) {
        new_index = 0
    } else if (new_index < 0) {
        new_index = max_index
    }

    state::set("sequence_index", new_index)
    return new_index
}

channel = input::channel()
index = state::get("sequence_index")

new_index = index

if (channel == "reset") {
    new_index = move(index, -index)
}

if (channel == "forward") {
    new_index = move(index, 1)
}

if (channel == "backward") {
    new_index = move(index, -1)
}

reset_all(outputs_count)
if (new_index == 0) {
    output::set("off", true)
} else {
    output::set(str::fmt("o{}", new_index), true)
}
Logic block representing a sequence