mpl3115a2-i2c-barometric-ensor

hanguru7/mpl3115a2-i2c-barometric-ensor/mpl3115a2-i2c-barometric-ensor

No description
mpl3115a2-i2c-barometric-ensor
@/mpl3115a2-i2c-barometric-ensor
INITpulse
mpl3115a2-i2c-barometric-ensor
INIT
PRE
ALT
TMP
TMPnumber
ALTnumber
PREnumber
To use the node in your project you should have the hanguru7/mpl3115a2-i2c-barometric-ensor 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/adafruit/Adafruit_MPL3115A2_Library"
{{#global}}
#include <Wire.h>
#include <Adafruit_MPL3115A2.h>
{{/global}}

struct State {
    uint8_t mem[sizeof(Adafruit_MPL3115A2)];
};
using Type = Adafruit_MPL3115A2*;

{{ GENERATED_CODE }}
//@@@
void evaluate(Context ctx) {
    if (isSettingUp()) {
    auto state = getState(ctx);
    Type mpl = new (state->mem) Adafruit_MPL3115A2();
    mpl->begin();        
    }
    
    if (isInputDirty<input_INIT>(ctx)){
        auto state = getState(ctx);
        auto mpl = reinterpret_cast<Adafruit_MPL3115A2*>(state->mem);
        emitValue<output_PRE>(ctx, mpl->getPressure());
        emitValue<output_ALT>(ctx, mpl->getAltitude());
        emitValue<output_TMP>(ctx, mpl->getTemperature()); 
       
    }
       
}