set-sensitivity

amperka/octoliner/set-sensitivity

Sets the senitivity of IR photodetectors for all Octoliner sensors.
set-sensitivity
@/set-sensitivity
Sets the senitivity of IR photodetectors for all Octoliner sensors.
IN@/octoliner-device
SENSnumber
Sensitivity value in the range [0,1].
UPDpulse
Triggers a new set.
set-sensitivity
IN
OUT
SENS
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 sensePin = 0;
};

// 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 sensitivity = (uint8_t)(255 * getValue<input_SENS>(ctx));

    octoliner->analogWrite(state->sensePin, sensitivity);

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

}