TolentinoCotesta

Nextion

Feb 20th, 2021
894
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define NXT_BUF_SIZE              128
  2. #define NXT_MSG_END               0xFF,0xFF,0xFF
  3.  
  4. uint8_t setNumeric(const char* field,long value){
  5.     char sendBuf[NXT_BUF_SIZE];
  6.     snprintf( sendBuf, NXT_BUF_SIZE, "%s.val=%lu%c%c%c", field, value, NXT_MSG_END);
  7.     return Serial.print(sendBuf);
  8. }
  9.  
  10.  
  11. uint8_t setString(const char* field, const char* value){
  12.     char sendBuf[NXT_BUF_SIZE];    
  13.     snprintf( sendBuf, NXT_BUF_SIZE, "%s.txt=\"%s\"%c%c%c", field, value, NXT_MSG_END);
  14.     return  Serial.print(sendBuf);
  15. }
  16.  
  17.  
  18. uint8_t setFloat(const char* field, long value, uint8_t intSize = 0, uint8_t frctSize = 0){
  19.     char sendBuf[NXT_BUF_SIZE];
  20.     snprintf( sendBuf, NXT_BUF_SIZE, "%s.val=%ld%c%c%c", field, value, NXT_MSG_END);
  21.     return  Serial.print(sendBuf);
  22. }
  23.  
  24. uint8_t setButtonClick(const char* field){
  25.     char sendBuf[NXT_BUF_SIZE];
  26.     snprintf( sendBuf, NXT_BUF_SIZE, "click %s,1%c%c%c", field, NXT_MSG_END);
  27.     return  Serial.print(sendBuf);
  28. }
  29.  
  30.  
  31. uint8_t setProperty(const char* prop, uint16_t value){
  32.     char sendBuf[NXT_BUF_SIZE];  
  33.     snprintf(sendBuf, NXT_BUF_SIZE, "%s=%u%c%c%c", prop, value, NXT_MSG_END);
  34.     return  Serial.print(sendBuf);
  35. }
  36.  
  37.  
  38. uint8_t addWavePoint(uint8_t waveId,uint8_t ch, uint8_t value){
  39.     char sendBuf[NXT_BUF_SIZE];      
  40.     snprintf(sendBuf, NXT_BUF_SIZE, "add %u,%u,%u%c%c%c", waveId, ch, value, NXT_MSG_END);
  41.     return  Serial.print(sendBuf);
  42. }
RAW Paste Data