Start a new topic

!HELP! How can i enter Integer from NEXTION and save it ?

Hi, i am new to forum. 


I have Nextion Touch Screen. On the screen i have numbers (as Button) from 0 to 10 and .(Dot) and OK button. All of them are Button. So what i want to do is enter any number from Nextion like 125.8 or 25 or 25896 etc, after i touch the OK button, number i entered should be equal to integer or double X. Like;


int X = ( The number entered from Nextion );


I parsed the coming datas. Because only changing part is the 5.th char of the data. 


Any suggestion. How can i handle this situtation ?


Thank you

Best Regards.


 

void setMsgChar()
{
 
 message = myNextion.listen();         // Listen serial communication
  if(message !=""){                     // If message is received 
    msg5 = message[5];                  // Get only the 5. char
    Serial.println(msg5);
  }
}

 All Code is here:


 

/* Adress Information
 * Motor1 (0,1) << X (1,1) << X^2 (1,2) << X^3 (1,3) << X^4 (1,4) << X^5 (1,5)
 * Motor2 (0,2) << X (2,1) << X^2 (2,2) << X^3 (2,3) << X^4 (2,4) << X^5 (2,5)
 * Motor3 (0,3) << X (3,1) << X^2 (3,2) << X^3 (3,3) << X^4 (3,4) << X^5 (3,5)
 * Motor4 (0,4) << X (4,1) << X^2 (4,2) << X^3 (4,3) << X^4 (4,4) << X^5 (4,5)
 * Motor5 (0,5) << X (5,1) << X^2 (5,2) << X^3 (5,3) << X^4 (5,4) << X^5 (5,5)
 */


#include <SoftwareSerial.h>
#include <Nextion.h>

SoftwareSerial nextion(2, 3);           // Nextion Tx to 3, Rx to 2
Nextion myNextion(nextion, 9600);       // Create a Nextion object named myNextion using the nextion serial port @ 9600bps

int x = 5;                              // Number that powered
int stp1,stp2,stp3,stp4,stp5;           // Steps Results
int i = 0;

String message;                         //the last message
char msg3, msg5;                        //the values parsed from a message
char messages[6];

void setup() {
  Serial.begin(9600);                   // Start serial communication 
  myNextion.init();                     // Initialize nextion
 
 

 
} 

void loop() {


 
 setMsgChar();       // Call the Function

}


void setMsgChar()
{
 
 message = myNextion.listen();         // Listen serial communication
  if(message !=""){                     // If message is received 
    msg5 = message[5];                  // Get only the 5. char
    Serial.println(msg5);
  }
}

 

ino
HMI

First, the Nextion is integer based and lacks floating point itself


Perhaps think of the user input data as text on the nextion which will allow the .(dot) as input and when pressing the OK button, have the code in the released event use the print command as in print t0.txt. Then process the incoming text


1 person likes this

Thank you Patrick. Good idea. 

Login or Signup to post a comment