# Sequencer

Przetwarzanie

Blok logiczny reprezentujący sekwencję

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

# Wejścia

IDSkrótNazwaTypDomyślnieOpis
forwardFwdDo przoduBOOLEANfalse
backwardBwdDo tyłuBOOLEANfalse
resetRstResetujBOOLEANfalse

# Wyjścia

IDSkrótNazwaTypDomyślnieOpis
offOffWyłączonyBOOLEANtrue
o1O1Wyjście #1BOOLEANfalse
o2O2Wyjście #2BOOLEANfalse
o3O3Wyjście #3BOOLEANfalse
o4O4Wyjście #4BOOLEANfalse
o5O5Wyjście #5BOOLEANfalse
o6O6Wyjście #6BOOLEANfalse
o7O7Wyjście #7BOOLEANfalse
o8O8Wyjście #8BOOLEANfalse

# Konfiguracja

IDNazwaTypDomyślnieJednostkaOpis
max_indexMaksymalny indeksNUMBER8

# Stan

IDNazwaTypDomyślnieJednostkaOpis
sequence_indexIndeks sekwencjiNUMBER0

# Kod źródłowy

Pokaż kod Volang
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)
}
Blok logiczny reprezentujący sekwencję