Skip to content

Instantly share code, notes, and snippets.

@fabiovila
Created May 30, 2018 00:33
Show Gist options
  • Save fabiovila/9842bee7a92538329175b240e4b65f77 to your computer and use it in GitHub Desktop.
Save fabiovila/9842bee7a92538329175b240e4b65f77 to your computer and use it in GitHub Desktop.
Send and set object values in Nextion LCDs on Arduino or general Serials
// Usage:
// setObj ("OBJECT.PROPS", "VALUE");
// obj - name and propertie of object
// txt - value
// example:
// setObj("t0.txt", "Test");
// Warning: Your IDE (as Arduino) is very likely that be UTF-8 wich causes the LCD don't renders the exact string that you pass to setObj
void setObj( char *obj, char *txt ){
Serial.write(0xFF); Serial.write(0xFF); Serial.write(0xFF); // Usefull when Serial connected to LCD is the same of Debug (my case in NODEMCU)
for (;*obj != 0; obj++) Serial.write(*obj);
Serial.write(0x3D);Serial.write(0x22); // ="
for (;*txt != 0; txt++) Serial.write(*txt);
Serial.write(0x22); // "
Serial.write(0xFF); Serial.write(0xFF); Serial.write(0xFF);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment