Start a new topic

getText Command Problem

Hi,


Display :



"page1_va1" is varrible, 


String = "1" 



Arduino : 


char x[1];  page1_va1.getText(x,1); byte a = atoi(x); x[0]='\0';


Serial.println(a);



Results:


136

136

136

136

....

....

....



WHY NOT 1 ?


max_txtl for variable has to be set


txt_maxl set is "1"

What is this for

   char x[1];                       // char array of one byte - no room to null terminate

   page1_va1.getText(x,1);   // get one char of getText - used wrong parameter

   byte a = atoi(x);            // convert start with first byte of x until null termination - overread

   x[0]='\0';                       // set x empty


??? 

This code defines an unknown  ... 




char x[10];      // define with enough space to null terminate

page1_va1.getText(&x);  // put contents of getText into space pointed to by parameter 

a = atoi(x);  // now convert until null termination (falls within space occupied by x)

x[0]='\0';     // set x to empty

Serial.println(a);



txt_maxl can never be set to "1" .. txt_maxl is a number not string.

txt_maxl is already number, no problem. Set is 1.


char x[10];  // define with enough space to null terminate


I entered char value [1] for minimum use memory. Because already incoming data will only be single character 0 or 1 or 2 or 3 etc... Is value 10 big? What is the minimum for one character?


page1_va1.getText(&x);  // put contents of getText into space pointed to by parameter 


It says parameter error. 


NexText.h:45:14: note: uint16_t NexText::getText(char*, uint16_t)

x is already to be used as an address, so try "page1_va1.getText(x, 1);" instead.

 

"page1_va1.getText(x, 1);"

Already I use it like that. Result is must 1, but it is 136.

136 is 0x88, the return code sent from the Nextion after it successfully has started. Are you sure you accidentally do not catch that?
Login or Signup to post a comment