# String latch
Captures a string input value on a pulse and holds it internally. The captured value is sent to the output on trigger or optionally on capture.
String latch
V
C
T
R
V
# Inputs
| ID | Abbrev | Name | Type | Default | Description |
|---|---|---|---|---|---|
value | V | Value | STRING | | The string input value available for capture. |
capture | C | Capture | BOOLEAN | false | Pulse input. Rising edge latches the current input value internally. If 'Trigger on capture' is enabled, also sends the value to the output. |
trigger | T | Trigger | BOOLEAN | false | Pulse input. Rising edge sends the captured value to the output, even if the output already holds the same value. |
reset | R | Reset | BOOLEAN | false | Pulse input. Rising edge resets the output and captured value to the configured default value. Dominant input. |
# Outputs
| ID | Abbrev | Name | Type | Default | Description |
|---|---|---|---|---|---|
value | V | Value | STRING | | The latched string value. Updated on trigger, on capture when auto-trigger is enabled, or on reset. |
# Configuration
| ID | Name | Type | Default | Unit | Description |
|---|---|---|---|---|---|
default_value | Default value | STRING | | The value restored to the output and captured state on reset. Details: Required | |
trigger_on_capture | Trigger on capture | BOOLEAN | true | When enabled, capturing a value also immediately sends it to the output. When disabled, capture only stores the value internally until an explicit trigger. |
# State
| ID | Name | Type | Default | Unit | Description |
|---|---|---|---|---|---|
captured_value | Captured value | STRING | | Holds the internally captured string value. | |
prev_capture | Previous capture state | BOOLEAN | false | Stores the previous state of the capture input to detect rising edges. | |
prev_trigger | Previous trigger state | BOOLEAN | false | Stores the previous state of the trigger input to detect rising edges. | |
prev_reset | Previous reset state | BOOLEAN | false | Stores the previous state of the reset input to detect rising edges. |
# Source Code
View Volang source
channel = input::channel()
value = input::value()
// Handle "reset" input first (dominant input)
if (channel == "reset") {
prev_reset = state::get("prev_reset")
if (value and !prev_reset) {
// Rising edge on reset - restore default value
default_value = config::get("default_value")
state::set("captured_value", default_value)
output::set("value", default_value)
}
state::set("prev_reset", value)
return
}
// Handle "trigger" input
if (channel == "trigger") {
prev_trigger = state::get("prev_trigger")
if (value and !prev_trigger) {
// Rising edge on trigger - send captured value to output
output::set("value", state::get("captured_value"))
}
state::set("prev_trigger", value)
return
}
// Handle "capture" input
if (channel == "capture") {
prev_capture = state::get("prev_capture")
if (value and !prev_capture) {
// Rising edge on capture - latch current input value internally
captured = input::get("value")
state::set("captured_value", captured)
// Optionally send to output immediately
if (config::get("trigger_on_capture")) {
output::set("value", captured)
}
}
state::set("prev_capture", value)
return
}
// "value" input changes are ignored - output holds until next capture, trigger, or reset
