switch-heater-off

wayland/sgp40-air-quality-sensor/switch-heater-off

Turn off heater to lower curent consumption. Next measurement will automatically reactivate the heater.
switch-heater-off
@/switch-heater-off
Turn off heater to lower curent consumption. Next measurement will automatically reactivate the heater.
DEV@/sgp40-device
An SGP40 device.
UPDpulse
Update.
switch-heater-off
DEV
UPD
OK
OKpulse
Pulse if heater successfully switched off.
To use the node in your project you should have the wayland/sgp40-air-quality-sensor 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

#pragma XOD evaluate_on_pin disable
#pragma XOD evaluate_on_pin enable input_UPD

node {

    void evaluate(Context ctx) {
        // The node responds only if there is an input pulse
        if (!isInputDirty<input_UPD>(ctx))
            return;

        auto sensor = getValue<input_DEV>(ctx);

        // Attempt to switch off heater; if attempt fails emit error
        if (!sensor->heaterOff()) {
            raiseError(ctx);
            return;
        }

        emitValue<output_OK>(ctx, 1);
    }
}