So since that was meaningless if you can’t scroll on LCD already, I’ll try an example.
Now how you’re getting the string in the first place you didn’t say, it could be being typed in serial,Code:string var byte [16] ‘ because I assume it’s one line of a 2x16 display but you can change this character var byte ‘ the current character counter var byte ‘ a step counter and index lindex var byte ‘ a lookup table index
or already stored in eprom or something. I’ll go with a longer than 16 char message stored in lookup table,
and put it in a subroutine at the end of the program.
We need something to actually rotate the 16 char line buffer and drop the oldest byte off the endCode:lookuptable: ‘ get the next character from the table into the character buffer LOOKUP lindex,[“CHECK IT OUT A SCROLLING TEXT DEMO!!!”],character ‘ 0-36 length message (37 characters in Human talk) return
whenever a new character is shifted in. This goes in a subroutine also at the end of the program.
Then a main cycle is needed to index the lookup table, call the lookup and rotate routines andCode:' rotatearray: ‘ rotate line array for counter = 16 to 1 step - 1 string[counter] = string[counter-1] next counter string[0] = character ‘ insert new character byte at zero index return ‘
print the line to LCD. After the variable declarations and before the subroutines:
Largely untested so if someone has a simulation with LCD pls feel free to run itCode:lindex = 0 CLEARLCD ‘ it’s been a while since I looked at LCDOUT, but whatever two byte code to clear LCD and home. ' cycle: HOMELCD ‘ it’s been a while since I looked at LCDOUT, but whatever two byte code to home LCD cursor. ' gosub lookuptable lindex = lindex + 1 ‘ increment lookup index if lindex > 36 then ‘ limit lookup index to length of message lindex = 0 endif gosub rotatearray ‘ rotate line with new character at zero index for counter = 0 to 15 ‘ print the line to lcd LCDOUT string[counter] next counter pause 1000 ‘ delay to see one movement per second goto cycle ‘ do cycle forever![]()




Bookmarks