Hey everyone! I have a Nextion screen 7' connected with an arduino Mega 2560 and I wanna communicate them by a serial portI; I've tried many libraries but the don't work fine or they are too simple for my application.
There are many examples in this forum where u change of pages or text and I was wonder how can I can do the same with pictures.
Also I've been reading the forum and I found the EasyNextionLibrary by Seithan: link http://https://forum.arduino.cc/index.php?topic=676240.0 In the TriggerCode, there is an application very similar what I've been looking for and I made this one but it didn't work eather.
#include "EasyNextionLibrary.h" // Include EasyNextionLibrary
#include "trigger.h"
EasyNex myNex(Serial1); // Create an object of EasyNex class with the name < myNex >
// Set as parameter the Serial you are going to use
void setup(){
myNex.begin(9600); // Begin the object with a baud rate of 9600
// If no parameter was given in the begin(), the default baud rate of 9600 will be used
}
void loop(){
myNex.writeNum("p3.pic", 10); // Set picture 1 as background picture for p3
delay (5000);
myNex.writeNum("p3.pic", 9); // Set picture 1 as background picture for p3
delay (5000);
}
Could u give me any suggestion? Commentary?
Thank u people! So nice to be part of this community
I can't comment on EasyNextionLibrary by Seithan, he does things in a different way to me.
I'd have to do some investigation to give you a proper answer but have a look at Instruction Set - Nextion and look for 11. Vis, I think that's what you need. You need both images to be on the page then you select which one to show. I think. Can't exactly remember.
If you try it out and don't succeed then please create a simple HMI file with 2 images on one page and your best attempt at switching between them, put them in a zip file and upload to this discussion then I'll have a closer look.
As far as I can remember you can't associate an image with a page by codes from the serial port, they have to be already associated with the page, then you use vis to show and hide them.
To be clear, I don't mean as a background image, I mean have picture object on the page, even if it has to be the same size as the whole page. Also have a look at cropped images, see part 4 of my tutorial, there is an example in there of how to use them.