set-brightness

amperka/octoliner/set-brightness

Sets the IR LEDs brightness for all Octoliner sensors.
set-brightness
@/set-brightness
Sets the IR LEDs brightness for all Octoliner sensors.
IN@/octoliner-device
Bnumber
Brightness value in the range [0,1].
UPDpulse
Triggers a new set.
set-brightness
IN
OUT
B
UPD
OK
OKpulse
Fires if the set is done.
OUT@/octoliner-device
To use the node in your project you should have the amperka/octoliner 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

struct State {
    const uint8_t ledBrightnessPin = 9;
};

// clang-format off
{{ GENERATED_CODE }}
// clang-format on

void evaluate(Context ctx) {
    if (!isInputDirty<input_UPD>(ctx))
        return;

    auto state = getState(ctx);
    auto octoliner = getValue<input_IN>(ctx);

    uint8_t brightness = (uint8_t)(255 * getValue<input_B>(ctx));

    octoliner->analogWrite(state->ledBrightnessPin, brightness);

    emitValue<output_OUT>(ctx, octoliner);
    emitValue<output_OK>(ctx, 1);

}