-
-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
myNex.readNumber() #2
Comments
Check that the number component that you ask for its value is on the current loaded page. number = myNex.readNumber("pageName.n0.val"); The folowing is from the Nextion Editor Guide
|
I made some changes to the .cpp file in order to have a return of 7777 at readNumber() function and for the case that Nextion hasn't sent the data we want. This is going to cover the case of asking to read a number from a page that is not loaded. You can try it and see if it covers your needs. |
Thanks |
And all component are set to global.(ntu,picture,...) |
I have try to change val of ntu. |
I have remove from Touch Release Event of picture(use for send command),the code: page page0. But always first time it give me the real value. |
Sorry that I miss it before. EasyNex myNex(Serial); and to the trigger3() function void trigger3(){
uint32_t number = 0;
number = myNex.readNumber("page2.ntu.val");
Serial.println(number);
} you call the Serial and you are sending a println for the number variable, I'm guessing that the Serial is connected on Nextion and if I'm guessing right then you send to Nextion an unknown command. void trigger3(){
uint32_t number = 0;
number = myNex.readNumber("page2.ntu.val");
//Serial.println(number);
myNex.writeNum("n22.val", number);
} Now you are going to see the number that is listed on |
Thanks for your help. uint32_t number = 0;
uint32_t lastnumber = 0;
void trigger3(){
number = myNex.readNumber("page2.ntu.val");
if(number != 7777){ // 7777 is the return value if the code fails to read the new value
lastnumber = number;
} else if(number == 7777){
number = lastnumber;
}
Serial.println(number);
} You think is correct with this? |
This is a way to confirm that the reading of the the value doesn't fail. |
|
Is possible to read a text from Text component in Nextion ? |
No, I haven't add this feature as I thing that the usage is almost unnecessary as a Display is most for display message and not to sent text to MCU, I tried hard to put as less functions as possible. |
but if someone need to send text, he can do it, using the custom protocol |
okok,thanks. And not possible with: |
This is from the example ChangePagesAndSendFloatValues it is for float but uint is the same String tempString = String(temperature, 1); // Convert the float value to String, in order to send it to t0 textbox on Nextion
myNex.writeStr("t0.txt", tempString); //Write the String value to t0 Textbox component |
Im going to add a case for this, on the write text example |
Thanks,it work. |
In my case i have a Variable in nextion(ntu).
ntu.val=489
In Arduino code:
uint32_t number = 0;
number = myNex.readNumber("ntu.val");
Serial.println(number);
But the output(Serial.println(number);) is "4294967066".
Not the real val(489).
The text was updated successfully, but these errors were encountered: