To use the node in your project you should have the bradzilla84/serial-plotter 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/Bradzilla84/arduino-plotter"
// Include C++ library:
{{#global}}
#include "Plotter.h"
{{/global}}
struct State {
uint8_t mem[sizeof(Plotter)];
};
// Define our custom type as a pointer on the class instance.
using Type = Plotter*;
{{ GENERATED_CODE }}
void evaluate(Context ctx) {
// It should be evaluated only once on the first (setup) transaction
if (!isSettingUp())
return;
auto state = getState(ctx);
// Create a new object in the memory area reserved previously.
Type plot = new (state->mem) Plotter();
emitValue<output_DEV>(ctx, plot);
}