To use the node in your project you should have the mendrig/nextion-lib 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
struct State
{
bool begun;
ConcatListView<char> view;
};
{{ GENERATED_CODE }}
void evaluate(Context ctx) {
if (!isInputDirty<input_DUMP>(ctx))
return;
State* state = getState(ctx);
if (!state->begun)
{
Serial2.begin(9600);
state->begun = true;
}
auto inValue = getValue<input_INSTR>(ctx);
Number zaehler;
Number byte;
;
// while (Serial2.available()) // bleibt hängen wenn nicht ausgelesen
if (Serial2.available())
{
zaehler += 1;
byte = Serial2.read();
}
// get the new byte:
//auto inChar = (char)Serial2.read();
// add it to the inputString:
//state->view = ConcatListView<char>(inputString, inChar);
// if the incoming character is a newline, set a flag so the main loop can
// do something about it:
/*
if (inChar == '\n')
{
stringComplete = true;
}
//
inputString = "Kommt was an \n";
}
*/
state->view = ConcatListView<char>(inValue, inValue);
inValue = XString(&state->view); // Zusammengebauten String in Variable schreiben
emitValue<output_RECIEVED>(ctx, inValue);
emitValue<output_ANZ>(ctx, zaehler);
emitValue<output_BIT>(ctx, byte);
emitValue<output_DONE>(ctx, true);
}