Outputs the word at the specified number "i" from the buffer.
get-word
@/get-word
Outputs the word at the specified number "i" from the buffer.
buffer1@/buffer1
inumber
triggerpulse
ERRpulse
donepulse
valnumber
buffer@/buffer1
To use the node in your project you should have the nazarijtipusak080/buffer1 library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.
C++ implementation
//-- int buffer1::get_word(i)
// Our constructor namespace should be: buffer1_ll__buffer1
struct State {
// not used
};
{{ GENERATED_CODE }}
void evaluate(Context ctx) {
if ( !isInputDirty<input_trigger>(ctx) ) return;
uint16_t i = static_cast<uint16_t> (getValue<input_i>(ctx));
auto _object = getValue<input_buffer1>(ctx); // buffer1
if ( ! _object->buffer ) {
//DEBUG_SERIAL.print(F("buffer1/"));DEBUG_SERIAL.print(F("get-word")); DEBUG_SERIAL.print(F(" saw unallocated buffer1\n")); // exception
}
else if ( i < 0 || (i * sizeof(uint16_t) >= _object->len) ) {
emitValue<output_ERR>(ctx, 1); // pulse
}
else {
auto _rez = reinterpret_cast <uint16_t *> ( _object->buffer )[ i ]; // int
emitValue<output_val>(ctx, _rez); // int
emitValue<output_done>(ctx, 1);
}
emitValue<output_buffer>(ctx, _object); // convenience
}