Read a numeric attribute of an object on the nextion display.
read-number
@/read-number
Read a numeric 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 va0.val will read the value attribute of the object named va0.
UPDpulse
Update. Trigger read.
Donepulse
Pulse on each attempt to read a numeric value.
Readpulse
Pulse on successful read of a numeric value.
NUMnumber
Number.
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 {
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);
uint32_t num = eznex -> readNumber(cString);
if (num != 777777) {
emitValue<output_NUM>(ctx, num);
emitValue<output_Read>(ctx, 1);
}
emitValue<output_Done>(ctx, 1);
}
}