Start a new topic

pictures do not appear

Forgive me if the question may be silly but :


In the HMI Nextion editor I put a picture.


I declare it in my arduino sketch in this way :


NexPicture p1 = NexPicture(0, 6, "p1");


and I can't see it on the display.

I made some attempts using

p1.getPic(6) or p1.setPic(6) without any success.

What am I doing wrong?


Thanks for any help


To give an idea I enclose 2 images.

One is regarding what I put in the editor and the other what I see on the display after that I compiled and loaded on it through the microSD card. 

display-01.jpg
(2.49 MB)

Please refer to the coding examples provided for comparison

In CompPicture,ino provided with the IteadLib Arduino Nextion Library

     [github link for CompPicture.ino]


Not only do you need to declare your picture in this type of format

   NexPicture p1 = NexPicture(0, 6, "p1");

But the parameters need to match your HMI design in the Editor

   NexPicture p1 = NexPicture(page_number, component_id, ".objname");  


From your pictures, your p1 is on page #1 in page1, I can not tell from pic what .id p1 has.

   clicking the p1 component in the editor would show the .id and .objname in Attributes pane.


Then once you have this properly defined your NexNumber p1

-  What is passed to .setValue and .getValue as parameter need be a uint32_t type

-  In the provided example, number is used for such declared and initialized as

  uint32_t number = 0;


Then using this number one can then set

   number=6;

   p1.setPic(number);

or one can get

   p1.getPic(&number);


Using p1.setPic(6)

 - the 6 is a constant and not defined as the required uint32_t type.


As a constant, the compiler will make a guess as to its type.

- this guess will usually result in an int type

- int type range will be dependent on the MCU and compiler used


Using p1.setPic((uint32_t)6); may work

  (I haven't tested this exact example to know for sure)

- This technique is known as type casting ... should work.

OK solved.

Thanks for your help.

Login or Signup to post a comment