As my GUI design is constantly changing, receiving a component ID when press event happens isn't very useful, as the component ID are changing.
I wanted to see a string that shows the new value of a dual state button after a press event on the serial line that looks likes a command, so I used the following code in the user code of the touch press event of my button:
cov bt0.val,bval.txt,0 printh 70 print "bt0.val=" print bval.txt printh ff ff ff
The result is the following:
0x70 0x62 0x74 0x30 0x2e 0x76 0x61 0x6c 0x3d 0x31 0xff 0xff 0xff
The first character, in accordance with the Nextion Instruction set, marks the start of string variable data, followed by the string "bt0.val=1" then the three terminating characters.
Unfortunately, there's no means for me to access the objname, so I have to identify it manually in my code, but I could modify the format if I wanted to simply send "bt0=1" or send a more traditional newline character instead of the three 0xff, but I'm trying to adhere to the communications protocol used by the Nextion.
For Itead, it would be nice, in the user code, if I could simply access the object name and refer to the object I'm coding for as "me". My code would then look like the following:
cov me.val,bval.txt,0 printh 70 print me.objname print ".val=" print bval.txt printh ff ff ff
The most efficient would be to have the option of a get command with the option of a string response:
In the example above, the second parameter specifies the response format (0 is numeric, 1 is string) The string option would return it in the following format:
cov t0.txt, j0.val, 0
THIS WILL NOT COMPILE!!! :-/
Take out the spaces after the two commas and it will.