Start a new topic

A few questions and observations

New user here, been trying to get the 5" Nextion touch screen to work with the Arduino Uno. Here are some observations I have come across.

1) when sending the HMI files through the Arduino to the display, I have to connect the TX (pin 0 on Uno) to TX (on the display) and the RX (pin 1 on Uno) to RX (on the display).

2) when I load the Arduino, the display must be disconnected.

3) When the display and Arduino have their respective programs loaded then I must switch the RX and TX lines as follows : TX (pin 0 on Uno) to RX (on the display) and the RX (pin 1 on Uno) to TX (on the display).


That has been the only way I have been able to get the examples in the Arduino Nextion libraries to work. I don't know it this was mentioned in any of the documentation or not.


First Question. I am working with the CompDualStateButton sketch on the Uno and when I press the button on the display, I would like to change the back color ("bco") of the text box. I thought it would be similar to changing the text by typing

 

t0.bco = ("YELLOW")

 in the Arduino  but get the error :


CompDualStateButton_1.ino: In function 'void bt0PopCallback(void*)':
CompDualStateButton_1:57: error: 'class NexText' has no member named 'bco'
'class NexText' has no member named 'bco'


I have added the code to turn on and off the pin 13 LED on the Uno  but I would like to change the background (bco) and foreground (pco) colors of the text box on the screen depending on the button state. 


I would like to know if there is a detailed explanation on how the button libraries work. How the Next functions work to make it easier to program the Arduino to control the display. Make it easier to program buttons to turn things on and off and read in data to display on the screen.



The nexText object doesn't provide access to the background color.  I think you would have to use: 

sendCommand("t0.bco=YELLOW");
sendCommand("ref t0");

 or something like that to change the color.  Practice the commands in the Nextion Editor Debug screen.  The sendCommand function is better than using Serial.print().  It's declared in NexHardware.h and makes sure the proper closing sequence is added to the command.


The libraries handle the extra characters that get the Nextion screen to react to the Arduino, and also gather the input from the Nextion touchpad (or screen) into normal C++ variables.  Their documentation isn't very good yet.  I'm just getting my screen working after a few days of headaches.


1 person likes this

Thank you Spirko, that did the trick for me using my (Arduino Uno)!


Gene-


Login or Signup to post a comment