The current implementation of CLCD or CVFD does not support hardware scrolling. However, the CUBLOC and CuNET interface is fast enough to scroll by redrawing the entire line. My code determines which piece of the text should be displayed and then outputs that part using the MID function.
This code is experimental and there are likely enhancements for flexibility and efficiency. However, it works well and is a good place to start!
- Code: Select all
' Character Display Scrolling Example
' Garrett Mace
' Comfile Technology 11/13/2006
' This code is provided as-is and is not intended for use in situations involving
' risk of injury to property or persons.
Const Device = CB290
Const DisplayWidth = 20 ' Set to the width of your display
Const ScrollDelay = 200 ' Adjust for desired scrolling speed
'Display initialization - must be changed to match your display
Set Display 2,0,0,32 'Set display to CLCD/CVFD
Cls 'Clear screen
Print &H1B, &H73 'Turn off cursor
Dim ScrollMessage As String * 40
Dim i As Byte
Dim MessageLength As Byte
ScrollMessage = "Now playing: CB290 Blues by The Comfiles"
MessageLength = Len(ScrollMessage)
' Main program loop
Do
Gosub Bounce ' Text scrolls to the end one direction, then scrolls the other way
'Gosub Marquee ' Text scrolls in from the right edge and scrolls completely off the screen
Loop
' Code to scroll in a bounce style
Bounce:
For i = 1 To MessageLength - DisplayWidth + 1
Locate 0,0
Print Mid(ScrollMessage,i,DisplayWidth)
Delay ScrollDelay
Next
Delay 5*ScrollDelay
For i = MessageLength - DisplayWidth To 1 Step -1
Locate 0,0
Print Mid(ScrollMessage,i,DisplayWidth)
Delay ScrollDelay
Next
Delay 5*ScrollDelay
Return
' Code to scroll in a marquee style
Marquee:
For i = 1 To DisplayWidth
Locate DisplayWidth-i,0
Print Left(ScrollMessage, i)
Delay ScrollDelay
Next
For i = 2 To MessageLength - (DisplayWidth - 1)
Locate 0,0
Print Mid(ScrollMessage,i,DisplayWidth)
Delay ScrollDelay
Next
For i = MessageLength - (DisplayWidth - 2) To MessageLength+1
Locate 0,0
Print Mid(ScrollMessage,i,MessageLength-i+1)
If (MessageLength-i) < (DisplayWidth)) Then Print " "
Delay ScrollDelay
Next
Return