Unofficial Nextion/TJC User Forum

Using xpic to Update page picture

Hi. I am using a Nextion Intelligent display. The display is 800 (horizontal) by 480 (vertical) pixels and I have an image with 1000 by 480 pixels. I use this image as the background image of the page. Automatically, the display uses only the first 800 horizontal pixels. I want to slide to the left and to the right the background image, dynamically. Since the difference between the image and the display size is 200 (1000-800), i can slide up to 200 pixels.

I achieve this by set sendxy to 1. When I press the display, the device sends an array, with the first byte being 0x67, 4 bytes to the coordinates and another byte to know if it is either a press or release.

At this time, I start polling tch0 (get tch0), and I finish polling when i receive the command 0x67 (with a release event). While polling, i send the command xpic, “xpic 0,0,800,480,dif,0,1\xFF\xFF\xFF”, with dif the number of pixels, between 0 and 200, the finger moved to the left or to the right. This value is used to move the image.

I achieve the results I want, but the problem relies with the objects present in the page. Every time the image is refreshed, all objects go behind, as the image changes to be at the topmost layer. Eventually, the objects updated after that, automatically appear, but not the ones without any kind of update.

This is a strange behavior since The Nextion Editor Guide - Nextion says page is always at the bottommost layer, besides the behavior isn’t visual appealing.

Have anyone had this problem?

Is there a work around?


You are right, a page (including its background picture attribute) is always the bottom layer. But drawing with GUI commands like xpic goes always to the top layer. Thus, the behavior you describe (components disappear behind your “manually” drawn picture) is normal and as expected.

Thanks for the reply.

I solved this issue implementing a work around. Every time I send the command xpic, I also refresh, immediately after, a property of each object.

This forum is in no way affiliated with NEXTION®, ITEAD STUDIO®, TJC®, or anyone else really. All product names, logos, and brands are property of their respective owners. All company, product, and service names used in this website are for identification purposes only. Use of these names, logos, and brands does not imply endorsement from the respective rights holder(s).