1

Topic: Edit field change detection

Having a lot of issues when using the Edit field specifically strings.  Trying to detect when there's a change in the edit field, but trying to manage this in the code is a mess at times.  I searched for examples and found one that makes perfect sense.  It had a flag when a valid change was made in the "edit field"..   However, to my knowledge this flag is not available in the present version of REMOTEXY.

Would appreciate any help in whether or not this flag is available ....

2

Re: Edit field change detection

The RemoteXY does not provide a data change flag. This is not always necessary. But it is very easy to implement. To check if the data has changed, you must keep a copy of the data.
For simple variables this is always easy. Here is some example code.

float copySetTemp = 0;
void loop () {
  if (RemoteXY.setTemp != copySetTemp ) {
    copySetTemp = RemoteXY.setTemp;
    
    // do something when data is changed

  }
}

For strings it's a bit more complicated, but the idea is the same. You have to keep a copy of the string and use some function to compare and copy the strings. An example of such a function is below

// The length of the copy must be the same as the original in the RemoteXY structure

char * copyMyString[11]; 

void loop () {
  if (strCompareAndCopy (copyMyString, RemoteXY.myString) == 0) { 
    
    // do something when data is changed

  }
}

uint8_t strCompareAndCopy (char* to, char* from) {
  uint8_t compare = 1;
  while (*from) {
    if (*to != *from) compare = 0;
    *to++ = *from++; 
  }
  if (*to) compare = 0;
  *to = *from;  // zero
  return compare;
}