Help with simplifying Nextion text update messages..

I am developing a CAN bus testing kit and it has a small display that gives the user all relevant info on the CAN bus and also helps him to send two command signals via sliders.

For the most part I read through the tutorials by Perry Bebbington and following the methods to read the user interface events. Its a good tutorial and well written. ( Thanks to him )

In the screen below I need to update the Message field with about dozen different messages which vary based on the context - but all are fixed messages.

XMDCAN_GUI.PNG

Of course I can write as many fixed messages as below and just call each as required.

void HMI_link_message() {
  Serial1.print(F("t20.txt=\""));
  Serial1.print(F("Starting XMD02 CAN Link !"));
  Serial1.print(F("\""));
  Serial1.write(0xff);
  Serial1.write(0xff);
  Serial1.write(0xff);
}

But instead it would be good to have a generic function like,

void nextionMessage ( int txtFieldID, char message) {}

It then makes it simple to call this function with required arguments... I am trying but finding it difficult as i need to convert the arguments to string literals ?

Any help appreciated !!

XMDCAN_GUI.PNG

For the most part I read through the tutorials by Perry Bebbington and following the methods to read the user interface events. Its a good tutorial and well written. ( Thanks to him )

Than you :slight_smile:
I am on holiday using a mobile phone to reply and wth no access to my code on my PC at home.

My approach is to put the text into an array, for example days of the week:

Char days[7] [4] = {"Mon","Tue","Wed","The","Fri","Sat","Sun"};

Then use the first index to access the correct text.

Note that I still get confused between '' and "", whichever one I use it will be the other one.

Sorry, I forgot, look at the scrollable list example in part 4 of the tutorial; the additional features code. I think it has what you need, although you will have to adapt it.

@PerryBebbington

yes I am also considering the Scrolling display. But was there a HMI code for that ? Will anyway check again.

It would still be nice to have a generic function which takes the required arguments. Will need to work on it ... right now busy with non MCU work !!

The HMI code is there to demonstrate how to trigger HMI code to run, you don't need that bit. Look at how the messages are stored in the Arduino code and how the correct message is selected.