Python Forum
raspberry use scrolling text two lines together - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: raspberry use scrolling text two lines together (/thread-34839.html)



raspberry use scrolling text two lines together - fishbone - Sep-06-2021

Hello Everyone,

I connect the 16*2 lcd screen to my raspberry. I want to write two columns scrolling text on the lcd screen.

I use the below code for scrolling text. When I use this code on the two columns, start scrolling the first column after start scrolling the second column. How to synchronous scrolling two columns. I use delay class for time.sleep() but I didn't handle it. I also add the delay class below.


def long_string(display, text='', num_line=1, num_cols=16):
		""" 
		Parameters: (driver, string to print, number of line to print, number of columns of your display)
		Return: This function send to display your scrolling string.
		"""
		if len(text) > num_cols:
			display.text(text[:num_cols], num_line)
			time.sleep(0.3)
			for i in range(len(text) - num_cols + 1):
				text_to_print = text[i:i+num_cols]
				display.text(text_to_print, num_line)
				time.sleep(0.3)
			time.sleep(0.3)
		else:
			display.text(text, num_line)

def delay1(counter):
    start1 = time.time()

    while True:
        time.sleep(0.1)

        if time.time() - start1 > 1:
            start1 = time.time()
            counter = counter - 1



            if counter <= 0:
                break