Errors with ITEADLIB_Nextion

Sigh - looks like I spoke too soon. I added

#include <ITEADLIB_Nextion.h>

and now it doesn’t compile again.

In file included from /src/weatherlcd1.cpp:17:0:
lib/SparkFun_Photon_Weather_Shield_Library/src/SparkFun_Photon_Weather_Shield_Library.h:66:0: warning: "_BV" redefined [enabled by default]
 #define _BV(bit) (1 << (bit))
 ^
In file included from ./inc/application.h:92:0,
                 from lib/ITEADLIB_Nextion/src/Nextion.h:25,
                 from lib/ITEADLIB_Nextion/src/ITEADLIB_Nextion.h:19,
                 from /src/weatherlcd1.cpp:2:
../wiring/inc/spark_wiring_arduino.h:131:0: note: this is the location of the previous definition
 #define _BV(x)  (((uint32_t)1) << (x))
 ^
/src/weatherlcd1.cpp: In function 'void printLCD()':
/src/weatherlcd1.cpp:990:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     else
                      ^
/src/weatherlcd1.cpp:992:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
         Serial.println("connection failed");
                      ^
/src/weatherlcd1.cpp:1000:21: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 //---------------------------------------------------------------
                     ^
/src/weatherlcd1.cpp:1013:23: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 float bar = (float) ((int) (baroTemp * 10 + 0.5) / 10) ;  // Round to 1/10th
                       ^
/src/weatherlcd1.cpp:1018:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
  // Date and time display is called in lcdPrintWind
                      ^
/src/weatherlcd1.cpp:1026:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
        Wifi.setText ("x") ;
                         ^
/src/weatherlcd1.cpp:1034:28: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     setCursor (7,6) ;
                            ^
/src/weatherlcd1.cpp:1040:32: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
  //   Serial1.write (0x7A) ;
                                ^
/src/weatherlcd1.cpp:1049:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
        lcd.print (" ") ;  // clear out the symbol from it earlier position
                         ^
/src/weatherlcd1.cpp:1060:20: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
        lcd.print(res);
                    ^
/src/weatherlcd1.cpp:1118:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
  //   lcd.println(soilMoisture);
                      ^
/src/weatherlcd1.cpp:1120:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
  //   delay(100);
                      ^
/src/weatherlcd1.cpp:1126:26: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
  //   delay(100);
                          ^
/src/weatherlcd1.cpp:1131:26: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     //delay(100);
                          ^
/src/weatherlcd1.cpp:1136:26: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     delay (100) ;
                          ^
/src/weatherlcd1.cpp:1139:26: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     setCursor (18,11) ;
                          ^
/src/weatherlcd1.cpp:1142:26: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 //    lcd.println(" mb");
                          ^
/src/weatherlcd1.cpp:1145:26: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     
                          ^
/src/weatherlcd1.cpp:1149:26: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
        lcd.print ("+") ;  // rising pressure
                          ^
/src/weatherlcd1.cpp:1152:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     lcd.print (P0 - P2) ; // show the change
                         ^
/src/weatherlcd1.cpp:1156:26: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
        case (1):
                          ^
/src/weatherlcd1.cpp:1160:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
          {
                         ^
/src/weatherlcd1.cpp:1165:26: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
        break ;
                          ^
/src/weatherlcd1.cpp:1177:30: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
        break ; 
                              ^
/src/weatherlcd1.cpp:1179:30: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
          {
                              ^
/src/weatherlcd1.cpp:1193:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
          }
                        ^
/src/weatherlcd1.cpp:1198:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       delay (100) ;
                      ^
/src/weatherlcd1.cpp:1205:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       if (n < 0)  // for some reason -n % 60 isn't working so we have to
                      ^
/src/weatherlcd1.cpp:1209:20: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       if (presHour[minute] - presHour[n] < -0.025)
                    ^
/src/weatherlcd1.cpp:1217:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     
                           ^
/src/weatherlcd1.cpp:1220:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     lcd.print(dailyrainin);  // This is set in the rainIRQ routine
                           ^
/src/weatherlcd1.cpp:1223:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     setCursor (16,13) ;  // x,y ie. col, row
                           ^
/src/weatherlcd1.cpp:1226:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     ftoa (snowin, res, 1) ;  // This is set in fn. snowDepth
                           ^
/src/weatherlcd1.cpp:1229:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
        lcd.print (" ") ; // erase any leftover digits from prev. no.
                           ^
/src/weatherlcd1.cpp:1232:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 //    lcd.print(" in.");
                           ^
/src/weatherlcd1.cpp:1235:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     if (bat < 10)
                           ^
/src/weatherlcd1.cpp:1238:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     lcd.print (res) ;
                           ^
/src/weatherlcd1.cpp:1241:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     delay (100) ;
                           ^
/src/weatherlcd1.cpp:981:5: warning: unused variable 'foo' [-Wunused-variable]
         {
     ^
/src/weatherlcd1.cpp:982:7: warning: unused variable 'bar' [-Wunused-variable]
             Serial.println("Bad request");
       ^
/src/weatherlcd1.cpp: In function 'void lcdPrintWind()':
/src/weatherlcd1.cpp:1264:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
        break ;
                        ^
/src/weatherlcd1.cpp:1267:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
        break ;
                        ^
/src/weatherlcd1.cpp:1270:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
        break ;
                        ^
/src/weatherlcd1.cpp:1273:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       }
                        ^
/src/weatherlcd1.cpp:1276:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 
                        ^
/src/weatherlcd1.cpp:1279:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 {
                        ^
/src/weatherlcd1.cpp:1282:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
  //   delay(100);
                        ^
/src/weatherlcd1.cpp:1285:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     delay (100) ;
                        ^
/src/weatherlcd1.cpp:1288:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     delay(100);
                        ^
/src/weatherlcd1.cpp:1291:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     setCursor (7,3) ;
                        ^
/src/weatherlcd1.cpp:1294:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       case 0:
                        ^
/src/weatherlcd1.cpp:1297:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       case 1:
                        ^
/src/weatherlcd1.cpp:1300:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       case 2:
                        ^
/src/weatherlcd1.cpp:1303:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       case 3:
                        ^
/src/weatherlcd1.cpp:1306:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       case 4:
                        ^
/src/weatherlcd1.cpp:1309:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       case 5:
                         ^
/src/weatherlcd1.cpp:1318:28: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       case 8:
                            ^
/src/weatherlcd1.cpp:1336:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       case 14:
                         ^
/src/weatherlcd1.cpp: In function 'void initDisplay()':
/src/weatherlcd1.cpp:1562:23: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     h=winterSunrise.sun_Hour();
                       ^
/src/weatherlcd1.cpp:1566:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     lcd.print ("SR: ") ;
                        ^
/src/weatherlcd1.cpp:1570:29: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     lcd.print(m);
                             ^
/src/weatherlcd1.cpp:1574:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
   t = (daylightSavings? winterSunrise.Set(Time.month(),Time.day()) : winterSunrise.Set(Time.month(),Time.day())); // (month,day) - january=1
                        ^
/src/weatherlcd1.cpp:1578:23: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     m=winterSunrise.sun_Minute();
                       ^
/src/weatherlcd1.cpp:1582:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     lcd.print(":");
                           ^
/src/weatherlcd1.cpp:1586:29: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
   }
                             ^
/src/weatherlcd1.cpp:1590:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     lcdPrintForecast () ;
                        ^
/src/weatherlcd1.cpp:1593:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     lcd.print("Wind: ");
                      ^
/src/weatherlcd1.cpp:1595:20: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     setCursor (18,3) ;
                    ^
/src/weatherlcd1.cpp:1599:23: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     
                       ^
/src/weatherlcd1.cpp:1601:21: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     lcd.print("Peak:       ");
                     ^
/src/weatherlcd1.cpp: In function 'void lcdPrintSRSS()':
/src/weatherlcd1.cpp:1661:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     // Get request
                      ^
/src/weatherlcd1.cpp:1664:19: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
  //   Serial.println(response.status);
                   ^
/src/weatherlcd1.cpp:1666:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
  //   Serial.print("Application>\tHTTP Response Body: ");
                      ^
/src/weatherlcd1.cpp:1683:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
  //   Serial.println (ms) ;
                           ^
/src/weatherlcd1.cpp:1686:19: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
  //   Serial.println (mn) ;
                   ^
/src/weatherlcd1.cpp:1688:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     hn = hn + tzoffset ;   // Time zone correction for GMT.
                      ^
/src/weatherlcd1.cpp:1690:23: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
        hn = hn + 12 ; // Correct for hours betwen 00 and 04
                       ^
/src/weatherlcd1.cpp:1694:31: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     delay (100) ;
                               ^
/src/weatherlcd1.cpp: In function 'void lcdPrintForecastOld()':
/src/weatherlcd1.cpp:1726:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
        lcd.print (response.status) ;
                        ^
/src/weatherlcd1.cpp:1756:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     delay (100) ;
                        ^
/src/weatherlcd1.cpp:1708:12: warning: unused variable 'mn' [-Wunused-variable]
     
            ^
/src/weatherlcd1.cpp: In function 'void lcdPrintForecast()':
/src/weatherlcd1.cpp:1792:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 
                        ^
/src/weatherlcd1.cpp:1831:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
  //  Example of what this returns:
                        ^
/src/weatherlcd1.cpp:1776:12: warning: unused variable 'mn' [-Wunused-variable]
       hn = hs.indexOf (",") ;
            ^
/src/weatherlcd1.cpp: In function 'void BTcheck()':
/src/weatherlcd1.cpp:1959:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     d = max (77.4 - d, 0) ;
                      ^
/src/weatherlcd1.cpp:1961:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
    //  Serial.println (d) ;
                        ^
lib/HttpClient/src/HttpClient.cpp: In member function 'void HttpClient::request(http_request_t&, http_response_t&, http_header_t*, const char*)':
lib/HttpClient/src/HttpClient.cpp:176:19: warning: unused variable 'firstRead' [-Wunused-variable]
     unsigned long firstRead = millis();
                   ^
In file included from lib/SparkFun_Photon_Weather_Shield_Library/src/SparkFun_Photon_Weather_Shield_Library.cpp:46:0:
lib/SparkFun_Photon_Weather_Shield_Library/src/SparkFun_Photon_Weather_Shield_Library.h:66:0: warning: "_BV" redefined [enabled by default]
 #define _BV(bit) (1 << (bit))
 ^
In file included from ./inc/application.h:92:0,
                 from lib/SparkFun_Photon_Weather_Shield_Library/src/SparkFun_Photon_Weather_Shield_Library.h:46,
                 from lib/SparkFun_Photon_Weather_Shield_Library/src/SparkFun_Photon_Weather_Shield_Library.cpp:46:
../wiring/inc/spark_wiring_arduino.h:131:0: note: this is the location of the previous definition
 #define _BV(x)  (((uint32_t)1) << (x))
 ^
lib/SparkFun_Photon_Weather_Shield_Library/src/SparkFun_Photon_Weather_Shield_Library.cpp: In member function 'float Weather::readPressure()':
lib/SparkFun_Photon_Weather_Shield_Library/src/SparkFun_Photon_Weather_Shield_Library.cpp:320:22: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
  if(IIC_Read(STATUS) & (1<<2) == 0) toggleOneShot(); //Toggle the OST bit causing the sensor to immediately take another reading
                      ^
lib/SparkFun_Photon_Weather_Shield_Library/src/SparkFun_Photon_Weather_Shield_Library.cpp:324:25: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
  while(IIC_Read(STATUS) & (1<<2) == 0)
                         ^
lib/SparkFun_Photon_Weather_Shield_Library/src/SparkFun_Photon_Weather_Shield_Library.cpp: In member function 'float Weather::readBaroTemp()':
lib/SparkFun_Photon_Weather_Shield_Library/src/SparkFun_Photon_Weather_Shield_Library.cpp:360:22: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
  if(IIC_Read(STATUS) & (1<<1) == 0) toggleOneShot(); //Toggle the OST bit causing the sensor to immediately take another reading
                      ^
lib/Sunrise/src/Sunrise.cpp: In member function 'int Sunrise::Compute(unsigned char, unsigned char, int)':
lib/Sunrise/src/Sunrise.cpp:101:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
../../../build/target/user/platform-6/libuser.a(NexHardware.o): In function `sendCommand(char const*)':
lib/ITEADLIB_Nextion/src/NexHardware.cpp:189: undefined reference to `nexSerial'
../../../build/target/user/platform-6/libuser.a(NexHardware.o): In function `recvRetCommandFinished(unsigned long)':
lib/ITEADLIB_Nextion/src/NexHardware.cpp:260: undefined reference to `nexSerial'
collect2: error: ld returned 1 exit status
make: *** [5a06c856af75cf897ab96327fb06fcf1056fbbdb72661ec4fdb666ab9e11.elf] Error 1

You need to look in the samples how to use the lib.

All the samples feature a line

USARTSerial& nexSerial = Serial1;

This is required to allow to use other serial ports too.

That’s odd. I just checked the CompText example at https://github.com/ScruffR/ITEADLIB_Nextion_dev/blob/master/firmware/examples/CompText/CompText.ino and don’t see that line there. Am I looking in the wrong place?

I have a much smaller test program that sends data to the Nextion without that line and this works OK:

// This #include statement was automatically added by the Particle IDE.
#include <SparkFun_Serial_Graphic_LCD.h>

// This #include statement was automatically added by the Particle IDE.
#include <HttpClient.h>

// This #include statement was automatically added by the Particle IDE.
#include <ITEADLIB_Nextion.h>
// #pragma SPARK_NO_PREPROCESSOR
#include "application.h"

void lcdPrintForecast () ;

// NX8048K070_011R  Display is 800x480

HttpClient http;

// Headers currently need to be set at init, useful for API keys etc.
http_header_t headers[] =
  {
    //  { "Content-Type", "application/json" },
    //  { "Accept" , "application/json" },
    { "Accept" , "*/*"},
    { NULL, NULL } // NOTE: Always terminate headers will NULL
  } ;

http_request_t request;
http_response_t response;

// NexText t0 ;

void setup(void)
{
    RGB.brightness(10) ;  // dial down the RGB LED (0-255)
    nexInit();
    dbSerialPrintln("setup done");
    setBaudrate(115200);
    
    drawPic(0, 0, 0);
    // Declare a text object [page id:0,component id:1, component name: "t0"]. 
 //   NexText t0 = NexText(0,2,"t0");

 //   t0.setText("Hello world");

    Serial.begin(9600);
    Serial.println();
    delay (500) ;
     //   clearScreen(0x0000);
  //  Serial1.write("cls 0\0xFF\0xFF\0xFF");
  //  Serial1.write("cls 0\0xFF\0xFF\0xFF");
    // Set screen brightness (range = 0-100)
 //   Serial1.write("DIM=20\0xFF\0xFF\0xFF");
  //  clearScreen(49) ;

    setCurrentBrightness (10) ;

}
 
int x;
int y;
// Name is quotes must match name in Nex. editor exactly!

NexText Date = NexText(0,1,"Date");
NexText TempF = NexText(0,2,"TempF");
NexText Forecast = NexText(0,46,"Forecast");
//  setBackColor (49) ;

// lcdPrintForecast () ; <-- throws an error here


void loop(void)
{
 //   cropPic(320-x, y + 25, 50, 50, 1);
 //   x += 4;
 //   x %= 320;
 //   y += 3;
 //   y %= 215;
    //    Serial1.write("cls \0xFF\0xFF\0xFF");
/*    drawText(0, 0, 320, 25, NexCENTER, NexCENTER, 0, 0xFFFF, 0xAAAA, NexSOLID, "Particle rocks!");
    drawLine(5, 5, 50, 30, 0xF800);
    fillRect(250, 25, 50, 25, 0x7E00);
    drawRect(20, 105, 50, 25, 0x01FF);
    drawCircle(160, 120, 30, 0xF9FF); */
 //   t0.setText("Hello world\0");
 //   NexText Date = NexText(0,1,"Date");
 //   Serial1.println(Time.timeStr());
    Date.setText (Time.timeStr()) ; 
  //  TempF.setText ("7\0xF8\0") ; // Hex B0 is the degree sign
    TempF.setText ("7\xB0") ;
    lcdPrintForecast () ;
    // Pass-thru for downloading HMI files directly 
    // from Nextion editor
 /*   while(Serial.available())
    {
        Serial1.write(Serial.read());
    }

    while(Serial1.available())
    {
        Serial.write(Serial1.read());
    } */
    delay(60000); 
}

void lcdPrintForecast ()
  {
  // Grab the one word 12 hr. forecast from myweathrr2.com
  // This is a replacement for worldweatheronline.com which is no longer free (and their
  // forecasts are always wrong anyway))
  // If this doesn't work, try:
  //    https://api.forecast.io/forecast/2c5dcada35783fe8bbf4981de33de1ea/43.1547222,-77.6158333?exclude=currently,minutely,hourly,alerts,flags
  // Other sites that look good:
  //    https://darksky.net/dev/docs/forecast
  //    http://openweathermap.org/api
  // Use tryExtractString to help parsing.
  
   int hn, mn, n ;
   String s, hs, ms ;

   request.hostname = "www.myweather2.com" ;
   request.port = 80;
   request.path = "/developer/forecast.ashx?uac=C-xxxxxxx&output=json&query=14618" ;
    
    // The library also supports sending a body with your request:
    //request.body = "{\"key\":\"value\"}";

    // Get request
    http.get(request, response, headers);
 //  Serial.print("Application>\tResponse status: ");
 //   Serial.println(response.status);
//   setCursor (1,15) ; // Col. 1, line 15
    delay (100) ;
//   lcd.print ("12 h: ") ;
    delay (100) ;
   if (response.status == 200)
     {
 //   Serial.print("Application>\tHTTP Response Body: ");
 //   Serial.println(response.body);
      s = response.body ;
 //   Serial.print ("s=") ;
 //  Example of what this returns:
 // { "weather": { "curren_weather": [ {"humidity": "72", "pressure": "1004", "temp": "0", "temp_unit": "c", "weather_code": "71", "weather_text": "Light Snow",  "wind": [ {"dir": "NW", "speed": "12", "wind_unit": "kph" } ] } ],  "forecast": [ {"date": "2016-11-20",  "day": [ {"weather_code": "38", "weather_text": "Blowing snow", ...
    
      n = s.indexOf ("forecast") ;
 //   Serial.print ("forecast found at =") ;
 //   Serial.println (n) ;
    
      hs = s.substring (n+22, n+110) ;
 //   Serial.print ("hs=") ;
 //   Serial.println (hs) ;
    
      hn = hs.indexOf ("weather_text") ;
 //   Serial.print ("hn=") ;
 //   Serial.println (hn) ;
    
      ms = hs.substring (hn + 16, hn + 48) ;
 //  Serial.print ("ms=") ;
 //  Serial.println (ms) ;
   
      n = ms.indexOf ("\"") ;
 //   Serial.print ("Quote found at =") ;
 //   Serial.println (n) ;
    
      hs = ms.substring (0, n) ;
 //   Serial.print ("hs=") ;
 //   Serial.println (hs) ;
    
//      Serial1.print (String(hs)) ; // Note lcd.print throws an error here.
      Forecast.setText (String(hs)) ;
     } // end if
   else
     {
//      lcd.print ("Err ") ;  // didn't get a response from the server
//      lcd.print (response.status) ;
     }
  // delay (100) ;
  } // end lcdPrintForecast

Are there any scoping issues here? Does if matter if I define Nextion objects inside Setup, outside, or if I call Nextion functions from within other functions? I tried the following at the end of Setup :

  #include <ITEADLIB_Nextion.h>

   NexInit () ;  
   USARTSerial& nexSerial = Serial1;
   NexText Date = NexText(0,1,"Date");
   Date.setText (Time.timeStr()) ; 

and got this:

In file included from /src/weatherlcd1.cpp:17:0:
lib/SparkFun_Photon_Weather_Shield_Library/src/SparkFun_Photon_Weather_Shield_Library.h:66:0: warning: "_BV" redefined [enabled by default]
 #define _BV(bit) (1 << (bit))
 ^
In file included from ./inc/application.h:92:0,
                 from lib/ITEADLIB_Nextion/src/Nextion.h:25,
                 from lib/ITEADLIB_Nextion/src/ITEADLIB_Nextion.h:19,
                 from /src/weatherlcd1.cpp:2:
../wiring/inc/spark_wiring_arduino.h:131:0: note: this is the location of the previous definition
 #define _BV(x)  (((uint32_t)1) << (x))
 ^
/src/weatherlcd1.cpp: In function 'void setup()':
/src/weatherlcd1.cpp:468:17: warning: unused variable 'nexSerial' [-Wunused-variable]
     seconds = 0;
                 ^
/src/weatherlcd1.cpp: In function 'void printLCD()':
/src/weatherlcd1.cpp:1001:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     else
                      ^
/src/weatherlcd1.cpp:1003:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
         Serial.println("connection failed");
                      ^
/src/weatherlcd1.cpp:1012:21: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 void printLCD()
                     ^
/src/weatherlcd1.cpp:1025:23: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
    // baroTemp = floor (baroTemp * 10 + 0.5) / 10 ;
                       ^
/src/weatherlcd1.cpp:1030:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     setCursor (18,2) ;  // line 2, col. 18
                      ^
/src/weatherlcd1.cpp:1038:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 
                         ^
/src/weatherlcd1.cpp:1046:28: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     setCursor (7,6) ;
                            ^
/src/weatherlcd1.cpp:1052:32: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
  //   Serial1.write (0x7A) ;
                                ^
/src/weatherlcd1.cpp:1061:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
        lcd.print (" ") ;  // clear out the symbol from it earlier position
                         ^
/src/weatherlcd1.cpp:1072:20: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
        lcd.print(res);
                    ^
/src/weatherlcd1.cpp:1130:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
  //   lcd.println(soilMoisture);
                      ^
/src/weatherlcd1.cpp:1132:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
  //   delay(100);
                      ^
/src/weatherlcd1.cpp:1138:26: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
  //   delay(100);
                          ^
/src/weatherlcd1.cpp:1143:26: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     //delay(100);
                          ^
/src/weatherlcd1.cpp:1148:26: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     delay (100) ;
                          ^
/src/weatherlcd1.cpp:1151:26: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     setCursor (18,11) ;
                          ^
/src/weatherlcd1.cpp:1154:26: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 //    lcd.println(" mb");
                          ^
/src/weatherlcd1.cpp:1157:26: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     
                          ^
/src/weatherlcd1.cpp:1161:26: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
        lcd.print ("+") ;  // rising pressure
                          ^
/src/weatherlcd1.cpp:1164:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     lcd.print (P0 - P2) ; // show the change
                         ^
/src/weatherlcd1.cpp:1168:26: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
        case (1):
                          ^
/src/weatherlcd1.cpp:1172:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
          {
                         ^
/src/weatherlcd1.cpp:1177:26: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
        break ;
                          ^
/src/weatherlcd1.cpp:1189:30: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
        break ; 
                              ^
/src/weatherlcd1.cpp:1191:30: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
          {
                              ^
/src/weatherlcd1.cpp:1205:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
          }
                        ^
/src/weatherlcd1.cpp:1210:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       delay (100) ;
                      ^
/src/weatherlcd1.cpp:1217:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       if (n < 0)  // for some reason -n % 60 isn't working so we have to
                      ^
/src/weatherlcd1.cpp:1221:20: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       if (presHour[minute] - presHour[n] < -0.025)
                    ^
/src/weatherlcd1.cpp:1229:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     
                           ^
/src/weatherlcd1.cpp:1232:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     lcd.print(dailyrainin);  // This is set in the rainIRQ routine
                           ^
/src/weatherlcd1.cpp:1235:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     setCursor (16,13) ;  // x,y ie. col, row
                           ^
/src/weatherlcd1.cpp:1238:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     ftoa (snowin, res, 1) ;  // This is set in fn. snowDepth
                           ^
/src/weatherlcd1.cpp:1241:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
        lcd.print (" ") ; // erase any leftover digits from prev. no.
                           ^
/src/weatherlcd1.cpp:1244:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 //    lcd.print(" in.");
                           ^
/src/weatherlcd1.cpp:1247:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     if (bat < 10)
                           ^
/src/weatherlcd1.cpp:1250:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     lcd.print (res) ;
                           ^
/src/weatherlcd1.cpp:1253:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     delay (100) ;
                           ^
/src/weatherlcd1.cpp:992:5: warning: unused variable 'foo' [-Wunused-variable]
         {
     ^
/src/weatherlcd1.cpp:993:7: warning: unused variable 'bar' [-Wunused-variable]
             Serial.println("Bad request");
       ^
/src/weatherlcd1.cpp: In function 'void lcdPrintWind()':
/src/weatherlcd1.cpp:1276:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
        break ;
                        ^
/src/weatherlcd1.cpp:1279:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
        break ;
                        ^
/src/weatherlcd1.cpp:1282:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
        break ;
                        ^
/src/weatherlcd1.cpp:1285:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       }
                        ^
/src/weatherlcd1.cpp:1288:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 
                        ^
/src/weatherlcd1.cpp:1291:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 {
                        ^
/src/weatherlcd1.cpp:1294:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
  //   delay(100);
                        ^
/src/weatherlcd1.cpp:1297:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     delay (100) ;
                        ^
/src/weatherlcd1.cpp:1300:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     delay(100);
                        ^
/src/weatherlcd1.cpp:1303:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     setCursor (7,3) ;
                        ^
/src/weatherlcd1.cpp:1306:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       case 0:
                        ^
/src/weatherlcd1.cpp:1309:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       case 1:
                        ^
/src/weatherlcd1.cpp:1312:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       case 2:
                        ^
/src/weatherlcd1.cpp:1315:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       case 3:
                        ^
/src/weatherlcd1.cpp:1318:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       case 4:
                        ^
/src/weatherlcd1.cpp:1321:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       case 5:
                         ^
/src/weatherlcd1.cpp:1330:28: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       case 8:
                            ^
/src/weatherlcd1.cpp:1348:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       case 14:
                         ^
/src/weatherlcd1.cpp: In function 'void initDisplay()':
/src/weatherlcd1.cpp:1574:23: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     h=winterSunrise.sun_Hour();
                       ^
/src/weatherlcd1.cpp:1578:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     lcd.print ("SR: ") ;
                        ^
/src/weatherlcd1.cpp:1582:29: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     lcd.print(m);
                             ^
/src/weatherlcd1.cpp:1586:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
   t = (daylightSavings? winterSunrise.Set(Time.month(),Time.day()) : winterSunrise.Set(Time.month(),Time.day())); // (month,day) - january=1
                        ^
/src/weatherlcd1.cpp:1590:23: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     m=winterSunrise.sun_Minute();
                       ^
/src/weatherlcd1.cpp:1594:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     lcd.print(":");
                           ^
/src/weatherlcd1.cpp:1598:29: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
   }
                             ^
/src/weatherlcd1.cpp:1602:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     lcdPrintForecast () ;
                        ^
/src/weatherlcd1.cpp:1605:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     lcd.print("Wind: ");
                      ^
/src/weatherlcd1.cpp:1607:20: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     setCursor (18,3) ;
                    ^
/src/weatherlcd1.cpp:1611:23: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     
                       ^
/src/weatherlcd1.cpp:1613:21: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     lcd.print("Peak:       ");
                     ^
/src/weatherlcd1.cpp: In function 'void lcdPrintSRSS()':
/src/weatherlcd1.cpp:1673:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     // Get request
                      ^
/src/weatherlcd1.cpp:1676:19: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
  //   Serial.println(response.status);
                   ^
/src/weatherlcd1.cpp:1678:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
  //   Serial.print("Application>\tHTTP Response Body: ");
                      ^
/src/weatherlcd1.cpp:1695:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
  //   Serial.println (ms) ;
                           ^
/src/weatherlcd1.cpp:1698:19: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
  //   Serial.println (mn) ;
                   ^
/src/weatherlcd1.cpp:1700:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     hn = hn + tzoffset ;   // Time zone correction for GMT.
                      ^
/src/weatherlcd1.cpp:1702:23: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
        hn = hn + 12 ; // Correct for hours betwen 00 and 04
                       ^
/src/weatherlcd1.cpp:1706:31: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     delay (100) ;
                               ^
/src/weatherlcd1.cpp: In function 'void lcdPrintForecastOld()':
/src/weatherlcd1.cpp:1738:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
        lcd.print (response.status) ;
                        ^
/src/weatherlcd1.cpp:1768:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     delay (100) ;
                        ^
/src/weatherlcd1.cpp:1720:12: warning: unused variable 'mn' [-Wunused-variable]
     
            ^
/src/weatherlcd1.cpp: In function 'void lcdPrintForecast()':
/src/weatherlcd1.cpp:1804:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 
                        ^
/src/weatherlcd1.cpp:1843:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
  //  Example of what this returns:
                        ^
/src/weatherlcd1.cpp:1788:12: warning: unused variable 'mn' [-Wunused-variable]
       hn = hs.indexOf (",") ;
            ^
/src/weatherlcd1.cpp: In function 'void BTcheck()':
/src/weatherlcd1.cpp:1971:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     d = max (77.4 - d, 0) ;
                      ^
/src/weatherlcd1.cpp:1973:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
    //  Serial.println (d) ;
                        ^
lib/HttpClient/src/HttpClient.cpp: In member function 'void HttpClient::request(http_request_t&, http_response_t&, http_header_t*, const char*)':
lib/HttpClient/src/HttpClient.cpp:176:19: warning: unused variable 'firstRead' [-Wunused-variable]
     unsigned long firstRead = millis();
                   ^
In file included from lib/SparkFun_Photon_Weather_Shield_Library/src/SparkFun_Photon_Weather_Shield_Library.cpp:46:0:
lib/SparkFun_Photon_Weather_Shield_Library/src/SparkFun_Photon_Weather_Shield_Library.h:66:0: warning: "_BV" redefined [enabled by default]
 #define _BV(bit) (1 << (bit))
 ^
In file included from ./inc/application.h:92:0,
                 from lib/SparkFun_Photon_Weather_Shield_Library/src/SparkFun_Photon_Weather_Shield_Library.h:46,
                 from lib/SparkFun_Photon_Weather_Shield_Library/src/SparkFun_Photon_Weather_Shield_Library.cpp:46:
../wiring/inc/spark_wiring_arduino.h:131:0: note: this is the location of the previous definition
 #define _BV(x)  (((uint32_t)1) << (x))
 ^
lib/SparkFun_Photon_Weather_Shield_Library/src/SparkFun_Photon_Weather_Shield_Library.cpp: In member function 'float Weather::readPressure()':
lib/SparkFun_Photon_Weather_Shield_Library/src/SparkFun_Photon_Weather_Shield_Library.cpp:320:22: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
  if(IIC_Read(STATUS) & (1<<2) == 0) toggleOneShot(); //Toggle the OST bit causing the sensor to immediately take another reading
                      ^
lib/SparkFun_Photon_Weather_Shield_Library/src/SparkFun_Photon_Weather_Shield_Library.cpp:324:25: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
  while(IIC_Read(STATUS) & (1<<2) == 0)
                         ^
lib/SparkFun_Photon_Weather_Shield_Library/src/SparkFun_Photon_Weather_Shield_Library.cpp: In member function 'float Weather::readBaroTemp()':
lib/SparkFun_Photon_Weather_Shield_Library/src/SparkFun_Photon_Weather_Shield_Library.cpp:360:22: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
  if(IIC_Read(STATUS) & (1<<1) == 0) toggleOneShot(); //Toggle the OST bit causing the sensor to immediately take another reading
                      ^
lib/Sunrise/src/Sunrise.cpp: In member function 'int Sunrise::Compute(unsigned char, unsigned char, int)':
lib/Sunrise/src/Sunrise.cpp:101:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
../../../build/target/user/platform-6/libuser.a(NexHardware.o): In function `sendCommand(char const*)':
lib/ITEADLIB_Nextion/src/NexHardware.cpp:189: undefined reference to `nexSerial'
../../../build/target/user/platform-6/libuser.a(NexHardware.o): In function `recvRetCommandFinished(unsigned long)':
lib/ITEADLIB_Nextion/src/NexHardware.cpp:260: undefined reference to `nexSerial'
../../../build/target/user/platform-6/libuser.a(NexHardware.o): In function `nexInit(unsigned long)':
lib/ITEADLIB_Nextion/src/NexHardware.cpp:276: undefined reference to `nexSerial'
collect2: error: ld returned 1 exit status
make: *** [bcbe213f234192e62050ed11452d1800bafb62c3756dd1158912d1df5587.elf] Error 1

Bottom line: the same code that works in the small program doesn’t want to compile in the large program.

The link you posted gets you to my work-in-progress rewrite of the library that wraps up the original ITEAD library into a more object oriented manner, which would allow to select an alternative interface in the NexDisplay() constructor and would not need that line.
And your test program must be using a previous version of the published lib that didn’t allow for alternative interfaces.

But the currently published library could be found here

Now to the code

  #include <ITEADLIB_Nextion.h>

   NexInit () ;                        // <-- this is a function that needs to be called from `setup()`
   USARTSerial& nexSerial = Serial1;   // <-- this needs to be global - as you can see in the correct sample
   NexText Date = NexText(0,1,"Date"); // <-- this needs to be global - as you can see in the correct sample
   Date.setText (Time.timeStr()) ;

Unlike the “official” examples, I’d call the component constructors like this

NexText Date(0,1,"Date");

To save some memory and execution time.

And if you want to react to component events you’ll need to populate a NexTouch list and regularly call nexLoop()

NexTouch *nex_listen_list[] = 
{ &Date
, NULL
};

void loop() {
  nexLoop(nex_listen_list);
}

BTW, I’ve split off these last few posts as they don’t relate to the original question of the other thread.

1 Like

That’s odd too. Moving that USARTserial line from where I had it after the Setup section to right below the include statement at the top of the file the way you have it instantly fixed everything. It now compiles cleanly one again, with the Nextion code included. I swear I don’t understand any of this. Thanks once again. I owe you another one.

1 Like

That’s good to know too. I’ve changed my constructors per your advice. Thanks also for the touch example. Eventually I might add something like a max/min reset button, or perhaps the ability to choose weather from other stations. I’m slowly but surely getting this conversion from Sparkfun to Nextion display working, entirely thanks to your help.

1 Like

I have a graph (“Waveform”) in my Nextion program. What I want to do is plot the barometric pressure at the rate of one point per hour.

The Nextion Editor assigned id of my waveform object is 15. Could someone please tell me why the following test code does nothing? The code compiles fine, the waveform box is there on the screen, but nothing appears inside it. The channel 0 foreground color is set to the default value of 64495 (kind of a salmon color). The background color is black. Width = 300, height = 68.

I’d ask this in the Itead forum but I’m afraid of getting my head bitten off over there (again).

x = 50 ;
y = 1 ;
    void loop(void)
    {
        if (x > 253)
           y = -1 ;
        if (x < 2)
           y = 1 ;
        x = x + y ;
        Serial1.write("add 15, 0, ") ;  //add data x to channel 0 of the Waveform component with ID number 15
        Serial1.write(x) ; 
        Serial1.write("\xFF\xFF\xFF") ; 
        delay(200); 
    }

Giving commands like
add 15,0,50
individually from the Nextion debugger does work though.

Update:

I realized that in the example above I had forgotten the line
USARTSerial& nexSerial = Serial1;
right after the Nextion include. But once I added that, now the program won’t compile. Includes:

// This #include statement was automatically added by the Particle IDE.
#include <HttpClient.h>

// This #include statement was automatically added by the Particle IDE.
// #include <SparkFun_Serial_Graphic_LCD.h>

// This #include statement was automatically added by the Particle IDE.
// #include <HttpClient.h>

// This #include statement was automatically added by the Particle IDE.

#include "application.h"

#include <ITEADLIB_Nextion.h>
USARTSerial& nexSerial = Serial1;
// #pragma SPARK_NO_PREPROCESSOR


#define NEX true // Compile for Nextion LCD output

int x = 1 ;
int y = 1 ;

This gives:

In file included from ./inc/application.h:43:0,
                 from lib/HttpClient/src/HttpClient.h:4,
                 from /src/nextiontest1.cpp:2:
../wiring/inc/spark_wiring_usartserial.h:103:39: error: invalid pure specifier (only '= 0' is allowed) before '(' token
 #define Serial1 __fetch_global_Serial1()
                                       ^/src/nextiontest1.cpp:15:26: note: in expansion of macro 'Serial1'
 void setup(void);
                          ^
../wiring/inc/spark_wiring_usartserial.h:103:40: error: function 'USARTSerial& __fetch_global_Serial1()' is initialized like a variable
 #define Serial1 __fetch_global_Serial1()
                                        ^/src/nextiontest1.cpp:15:26: note: in expansion of macro 'Serial1'
 void setup(void);
                          ^
/src/nextiontest1.cpp: In function 'void lcdPrintForecast()':
/src/nextiontest1.cpp:142:12: warning: unused variable 'mn' [-Wunused-variable]
   //    https://darksky.net/dev/docs/forecast
            ^
make[1]: *** [../build/target/user/platform-6src/nextiontest1.o] Error 1
make: *** [user] Error 2

Solution:

Never mind, I figured it out. I removed the USARTSerial line and removed the blanks from the set command.

Serial1.write("add 15,0,") ;  //add data 30 to channel 0 of the Waveform component which ID number is 15
Serial1.write(x) ; 
Serial1.write("\xFF\xFF\xFF") ; 

And x has to be converted to a string before sending it to the display.

Now it works. Go figure.

Other things to know about the waveform object:

It does no scaling. Your y dimension is zero to the height of the graph in pixels. Values outside that range are clipped to the upper or lower edge of the graph.

The default drawing direction is left to right, which IMAO is simply wrong. Maybe it makes sense in China, but not elsewhere. If you want your graph to behave like a chart recorder, you need to switch this to right to left in the waveform’s properties in the Nextion Editor.

Even then, there’s a bug in this feature. If you select R to L, it still begins filling from the left edge and moves L to R until it gets to the right edge. Only then does it begin flowing R to L. I’ve reported this to Itead. They’ll probably tell me it’s a feature, not a bug and that I’m an idiot. I don’t really care. It’s still wrong.

I have a Text object on my 7" display with a width of 781 and a height of 58. The “isbr” (wordwrap) field is set to True (1). The font is 16 pt. Helvetica. There should be plenty of room there for at least 300 characters. But it appears the largest number I can type into the “txt_maxl” field in the Editor is 254. Anything above that reverts to 254.

Rather than subjecting myself to the usual abuse from Patrick Martin over on the Itead forum again, I’m hoping maybe the wonderful and awesome @ScruffR can tell me how to fix this problem. Is this just some arbitrary Nextion hardwired limit or is there some obscure switch somewhere that needs to be set to get more than 254 characters in a text field.

I guess that’s an internal limit of their firmware as 254 does sound very much like a 1byte length field for the buffer (256 - terminator - some control field)
But if you only need to display longer tests, but won’t need to manipulate it later on you could use the draw text functions that just display the text as graphic.

Hmm, I didn’t think of that. Thanks for the suggestion. I assume you mean the “xstr” command. Unfortunatey, the Nextion documentation is silent on how big a string can be there either. And I guess I’d have to give a “fill” command to erase the text box the next time I want to write something different there. I suppose there’s one way to find out :slight_smile: