mp503-device

gabbapeople/mp503-air-quality-sensor/mp503-device

No description
mp503-device
@/mp503-device
PORTport
mp503-device
DEV
PORT
DEV@/mp503-device
To use the node in your project you should have the gabbapeople/mp503-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 require "https://github.com/Seeed-Studio/Grove_Air_quality_Sensor"

// clang-format off
{{#global}}
#include <Air_Quality_Sensor.h>
{{/global}}
// clang-format on

struct State {
    uint8_t mem[sizeof(AirQualitySensor)];
};

using Type = AirQualitySensor*;

// clang-format off
{{ GENERATED_CODE }}
// clang-format on

void evaluate(Context ctx) {
    if (!isSettingUp())
        return;

    auto state = getState(ctx);
    auto port = getValue<input_PORT>(ctx);

    Type sensor = new (state->mem) AirQualitySensor(port);

    if (!(sensor->init())) {
        raiseError(ctx);
        return;
    }

    emitValue<output_DEV>(ctx, sensor);
}