read-string

wayland/nextion/read-string

Read a text attribute of an object on the nextion display.
read-string
@/read-string
Read a text attribute of an object on the nextion display.
DEV@/nextion-serial
A nextion device.
CMDstring
Command. Specify object and attibute to be read. For example, t0.txt will read the text attribute of the object named t0.
UPDpulse
Update. Trigger read.
read-string
DEV
CMD
UPD
String
Done
Donepulse
Pulse on read.
Stringstring
String.
To use the node in your project you should have the wayland/nextion 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

node {
    CStringView view;
    char* cStringOut;

    void evaluate(Context ctx) {

        // The node responds only if there is an input pulse
        if (!isInputDirty<input_UPD>(ctx))
            return;

        // Get a pointer to the `EasyNex` class instance
        auto eznex = getValue<input_DEV>(ctx);
        auto xString = getValue<input_CMD>(ctx);

        int N=length(xString) + 1;
        char cString[N];
        for(int i=0;i<N;i++)
            cString[i]=0;
        dump(xString, cString);

        String str = eznex -> readStr(cString);
        int strLen = str.length() + 1;
        cStringOut = new char[strLen];

        str.toCharArray(cStringOut, strLen);

        view=CStringView(cStringOut);

        emitValue<output_String>(ctx, XString(&view));
        emitValue<output_Done>(ctx, 1);
    }

}