Hello everyone! I' m sorry for my bad english but I 'll try to explain my problem with a 2,8" basic Nextion Display. I'm also using an Arduino Mega and my Nextion editor version is V0.47.
I've created a page (page 2 of my project) within two sliders and a double state botton all of them with the send component id box ticked.
I've created the arduino code following the instructions and all the components work. The problem cis that not always they work fine, I noticed sometime (maybe 50 %) the display does not send data to arduino in fact neither the serialdebug notice the change of state of the components but the touch works fine because the components always change state. I cannot understand if the problem is in the arduino code (maybe some delays) or is a dispay issue.
I also tried to delete the last one delay in the arduino code but in this case never work... very strange
Help me please!!! :)
Hi, I've looked through your code, and the first thing that causes concern is the large amount of work you are trying to do in loop() along with the delay(200) as you try to slow down the reads and Serial.prints to a manageable level.
A good guide to help you improve these poor coding practices is here.....
As a rough rule of thumb loop() should be running as fast as possible without any added delay(). The idea that work is polled for at reasonable intervals. When you understand that concept, then you can see how it is possible to catch most events from the Serial input.
Make some informed changes and I've no doubt things will improve Nextion side.
If you still have some minor issues later, we'll take another look after your revisions.
I will try!!!
thank you so much @indev2, you saved me a lot of time I guess.
well, I understand I was "overloading" the serial port.
I actually want to use the sendme command to avoid to send data continuously even when not necessary.
I've read the documentation about it.... this command send to arduino a code telling the page id, ok... but how arduino can read it?
Is there a standard procedure? maybe in the library? I could not find it, only found some customized codes in the forum. is it possible there is not a "standard" procedure to use this important command?
thanks again for your help
The Iteadlib library is an example.
In NexHardware.cpp we see the function nexLoop()
- it is within this function where the incoming chars are captured and decisions made on
Within the nexLoop() function is where the 0x65 touch is implemented
- it is an example of how to take 7 bytes and extract page, component id, and press/release
this is then sent off to the function iterate to compare against nex_listen_list
- if attachPush or attachPop is found, it will pass to proper function.
So the seven-byte 0x65 return data was implemented fully
The five-byte 0x66 return data was not, but one can use the 0x65 as a template.
I can not recall where, but I posted partial code for this already in forum.
Where you send this to, to track your current_page and trigger support is up to you
One issue I have found, to implement every Nextion possibility in a single library code
will start to consume more and more MCU sram. It somehow makes sense that not
everything was implemented in full as fewer and fewer MCUs would be able to use.
Hopefully this is enough of a base to get you rolling.
I was just typing up a reply to the effect that maybe you could help here.
Back to work today, I'm going to fix my problem... I think it s going to be easy with your help! Thank you so much!!! :)