Running line for lcd

Please help me, I need to make a running line on lcd.
Looks like a metro

I don’t see any existing libraries to handle this, but you can use gweimer/utils/sub-string to pull the part of string to display, then keep incrementing OFST to “scroll” through the text.
You’ll probably want to use ‘count’ node that gets incremented by ‘clock’ node to feed OFST. You’ll need additional code to reset count when you reach the end of the string. You could add additional code to handle loop scrolling instead of jumping to start of message when end of message is reached, but it would be easier just to add a copy of the 1st part of the message to the end of message. For example, if your display is 16 characters, you probably want a couple spaces at the end of the message, then repeat the 1st 15 characters of the message; now when it “jumps” at the end of message back to beginning of message, it will be a smooth scroll to show the 1st 16 characters. You can even automate this by storing the message to display, but using ‘concat’ node with storage + spaces + sub-string of storage to feed sub-string node that feeds lcd.

There’s probably a way to get length of string, but I’m supposed to be working now, so I just hard-coded the length of 39 in this example (36+3 spaces from middle concat input).

The num… node is number-to-i8 because sub-string uses bytes. The green nodes at the top are tweak-string & tweak-number nodes to allow changes. The green node at the bottom is a watch node to replace lcd to allow simulation. Code assume LCD will be 16-characters wide.

I added a string-length node to gweimer/utils

Since there are no checks for messages < 16 characters, weird things will happen for short messages.

Boy this got ugly fast. This adds tweak-number for length of LCD screen (16), and checks if string is short enough that it doesn’t need scrolling.


If it is a short string, just display it and disable clock so we don’t scroll.
If it is a long string, concat extra characters, and enable clock to scroll.
Reset count if we reach end of string or if string changes (pulse-on-change).
The single-block vertical wires are ‘jumper’ nodes to route wires around other nodes.

I’ve added some additional options & published it as gweimer/utils/text-scroll with an example node showing its usage.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.