To use the node in your project you should have the gst/eeprom-read-write-uint16bit 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/dancojocaru2000/ArduinoEEPROM"
{{#global}}
#include <EEPROM.h>
{{/global}}
struct State {
uint16_t cache = 0;
};
{{ GENERATED_CODE }}
void evaluate(Context ctx) {
auto state = getState(ctx);
if (isInputDirty<input_UPD>(ctx)) {
auto addr = getValue<input_ADDR>(ctx);
uint16_t addresse = addr;
auto result = EEPROM.read(addresse);
byte lowbyte = result;
addresse = addresse +1;
result = EEPROM.read(addresse);
byte highbyte = result;
state->cache = ((lowbyte << 0) & 0x00FF) + ((highbyte << 8) & 0xFF00);
emitValue<output_OK>(ctx, true);
}
emitValue<output_VAL>(ctx, state->cache);
}
/*This function will read a 2 byte integer from the eeprom at the specified address and address + 1
*/