Go Down

Topic: Nextion: Scrollbar Through Array List (Read 723 times) previous topic - next topic

jtbennett

I now have a fully functional scroll bar for a file list generated from an array. It's very ugly code, and the action is a little crusty since there's quite a number of calculations going on, but it's functional. I was able to recover some functional speed by returning a bunch of processes to the Nextion's HMI instead of going back and forth through the serial (stuff like visibility based on scroll position, refreshes after actions, etc).


PerryBebbington


Quote
I was able to recover some functional speed by returning a bunch of processes to the Nextion's HMI instead of going back and forth through the serial
Good! If you can do that you clearly understand what you are doing :)

DrBoo

I am replying to this because I implemented a scrollable file list on Nextion a few years ago, and it works very well. The files are read from an SD card attached to the Arduino. The HMI and TFT files are on the Github repository for anyone who wants to see how it's done.  The URL for that is Github for Nextion Scroller.
You can see it in action (running off an Arduino Micro) on this YouTube video.  I will be happy to help/explain if anyone has any problems with implementation.

jtbennett

Hi DrBoo - that link takes me to some sort of TV project - I'm interested in this list thing though, especially if it has nice smooth action, mine requires refreshes and calculations at every movement and since I'm running back and forth through the serial connection, it's a little slower than I'd like it to be.

I'm sure there must be a smarter way to send all the data needed over to the nextion in one go, but I'm just too tired to start over again  :'(

PerryBebbington


Quote
Mine requires refreshes and calculations at every movement and since I'm running back and forth through the serial connection, it's a little slower than I'd like it to be.
Here's a suggestion, I am not completely sure it will work and you'll have to play about with it to get it working.

Create several separate text boxes, one above the other, one for each line of text you want to scroll, so if you want to display 8 lines create 8 boxes.

Create 2 buttons, these should be hidden out of sight by making them small (1 pixel x 1 pixel) and with the colour to match the background.

Under 1 button put something like

Code: [Select]
t7.txt=t6.txt //Moves text 6 to text 7
t6.txt=t5.txt //Moves text 5 to text 6
etc...

To activate this send from the Arduino

Code: [Select]
click b0,1
click b0,0

Which clicks the button (you have to send click press and click release, try without and you'll see why)

Do the same for the other button but in the opposite order for scrolling the other way.

You then only have to send either the top or bottom line of text.

I think this should work, but you will have to play with it.

Go Up