# Sequencer
Logic block representing a sequence
Sequencer
Fwd
Bwd
Rst
Off
O1
O2
O3
O4
O5
O6
O7
O8
# Inputs
| ID | Abbrev | Name | Type | Default | Description |
|---|---|---|---|---|---|
forward | Fwd | Forward | BOOLEAN | false | |
backward | Bwd | backward | BOOLEAN | false | |
reset | Rst | reset | BOOLEAN | false |
# Outputs
| ID | Abbrev | Name | Type | Default | Description |
|---|---|---|---|---|---|
off | Off | Off | BOOLEAN | true | |
o1 | O1 | Output #1 | BOOLEAN | false | |
o2 | O2 | Output #2 | BOOLEAN | false | |
o3 | O3 | Output #3 | BOOLEAN | false | |
o4 | O4 | Output #4 | BOOLEAN | false | |
o5 | O5 | Output #5 | BOOLEAN | false | |
o6 | O6 | Output #6 | BOOLEAN | false | |
o7 | O7 | Output #7 | BOOLEAN | false | |
o8 | O8 | Output #8 | BOOLEAN | false |
# Configuration
| ID | Name | Type | Default | Unit | Description |
|---|---|---|---|---|---|
max_index | Max index | NUMBER | 8 |
# State
| ID | Name | Type | Default | Unit | Description |
|---|---|---|---|---|---|
sequence_index | Sequence index | NUMBER | 0 |
# 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)
}
