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
{{#global}}
//auto val = 0;
//char TXTtitle[64];
//char TXTlabel[64];
{{/global}}
struct State {
uint8_t val = 0;
char TXTtitle[32];
char TXTlabel[32];
};
{{ GENERATED_CODE }}
void evaluate(Context ctx) {
// The node responds only if there is an input pulse
if (!isInputDirty<input_INIT>(ctx)){
return;}
auto state = getState(ctx);
state->val = getValue<input_Val>(ctx);
// It should be evaluated only once on the first (setup) transaction
if (isSettingUp()){
auto Plotter = getValue<input_IN>(ctx);
auto title = getValue<input_Title>(ctx);
int points = getValue<input_Points>(ctx);
auto label = getValue<input_Label>(ctx);
auto state = getState(ctx);
// static char TXTtitle[64];
// static char TXTlabel[64];
dump(title, state->TXTtitle);
dump(label, state->TXTlabel);
Plotter->Begin(); // start plotter
Plotter->AddTimeGraph( (state->TXTtitle), (points), (state->TXTlabel), (state->val) ); // add any graphs you want
}
auto Plotter = getValue<input_IN>(ctx);
Plotter->Plot(); // plot all current data
// delay (5);
// Pulse that module initialized successfully
emitValue<output_OK>(ctx, 1);
}