get-address

wayland/ds18b20/get-address

Get address of DS18B20 device at specified index (IDX).
get-address
@/get-address
Get address of DS18B20 device at specified index (IDX).
DEV@/ds18b20-devices
One or more DS18B20 temperature sensors on a single one-wire bus.
IDXnumber
Index of device on bus. Choose 0 for first device on bus.
UPDpulse
Update.
get-address
ADDR
DONE
DEV
IDX
UPD
DONEpulse
Pulse on read of address.
ADDRstring
Address of DS18B20 device.
To use the node in your project you should have the wayland/ds18b20 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 {
    char str[32];
    CStringView view = CStringView(str);

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

        auto sensors = getValue<input_DEV>(ctx);
        uint8_t idx = getValue<input_IDX>(ctx);
        
        DeviceAddress devAddr;
        sensors->getAddress(devAddr, idx);

        sprintf(str, "%02Xh-%02Xh-%02Xh-%02Xh-%02Xh-%02Xh-%02Xh-%02Xh",
                devAddr[0], devAddr[1], devAddr[2], devAddr[3],
                devAddr[4], devAddr[5], devAddr[6], devAddr[7]);

        emitValue<output_ADDR>(ctx, XString(&view));        
        
        emitValue<output_DONE>(ctx, 1);
    }
}