hc-sr04-device

xod-dev/hc-sr04/hc-sr04-device

No description
hc-sr04-device
@/hc-sr04-device
TRIGport
Board port to which sensor’s `trig` pin is connected.
ECHOport
Board port to which sensor’s `echo` pin is connected.
hc-sr04-device
OUT
TRIG
ECHO
OUT@/hc-sr04-device
To use the node in your project you should have the xod-dev/hc-sr04 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 {
    meta {
        struct Device {
            static constexpr typeof_ECHO echoPort = constant_input_ECHO;
            static constexpr typeof_TRIG trigPort = constant_input_TRIG;
        };
        Device dev;
        using Type = Device*;
    }
    void evaluate(Context ctx) {
        pinMode(dev.trigPort, OUTPUT);
        pinMode(dev.echoPort, INPUT);
        emitValue<output_OUT>(ctx, &dev);
    }
}