read-average

gabbapeople/hx711/read-average

Reads an average raw value from the HX711 device.
read-average
@/read-average
Reads an average raw value from the HX711 device.
DEV@/hx711-device
The HX711 device.
Nnumber
How many times to read. 10 by default.
DOpulse
Triggers a new reading.
read-average
DEV
N
DO
DEV'
VAL
DONE
DONEpulse
Pulses when the reading is done.
VALnumber
Raw average value.
DEV'@/hx711-device
The HX711 device.
To use the node in your project you should have the gabbapeople/hx711 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

node {
    void evaluate(Context ctx) {
        auto dev = getValue<input_DEV>(ctx);

        if (isSettingUp())
            emitValue<output_DEVU0027>(ctx, dev);

        if (!isInputDirty<input_DO>(ctx))
            return;

        uint8_t n = getValue<input_N>(ctx);
        long val = dev->read_average(n);

        emitValue<output_VAL>(ctx, val);
        emitValue<output_DONE>(ctx, 1);
    }
}