Rolling message on an OLED screen?

Hello there, I have bought myself myself a new OLED screen ( I know they have no difference in signals compared to the traditional LCD) ANd it works great! Already I have done many text things to impress my friends and I even did a counter that every time you clicked the button the number on the screen went up. I like think displaying informarmation on the screen is very good and when I first got it working a I got a feeling of happiness! :D

Any way I have always wanted my name to scroll across the screen with out doing a repeated pattern that would use a lot of cod up and get very confusin like this:

Code:
(08M Chip)
serout B.7,N2400,(254,128)
serout 0,n2400,("Trevor")
serout 0,n2400,("254,1")
serout 0,n2400,(" Trevor")
serout 0,n2400,("254,1")
serout 0,n2400,("  Trevor")
serout 0,n2400,("254,1")
serout 0,n2400,("   Trevor")
serout 0,n2400,("254,1")
serout 0,n2400,("    Trevor")
serout 0,n2400,("254,1")
serout 0,n2400,("     Trevor")
serout 0,n2400,("254,1")
serout 0,n2400,("      Trevor")
serout 0,n2400,("254,1")
serout 0,n2400,("        Trevor")
etc

I have seen it because some one has displayed a code to me before but I had no idea how it worked and used a totally different set up to me :/ Would it be at all possible if some one could give me the out line of what to do. I have hunch that I could make the x-coordinate of the screen a variable and + 1 each cycle and display that but that's only a guess and I do not know how I could interface that within my circuit. It is no rush I will be doing a lot of work tomorrow with picaxe (even though I still don't have a project yet :S)
Thanks again every one and see you soon x :)
 

westaust55

Moderator
It is just a case of applying the correct commands to shift the display to scroll the characters.

Some commands covered in the AXE033/133 datasheets:
254,1 clears the screen
254,16 move the cursor left
254,20 move the cursor right

Some other commends which can be found by reading the Hitachi HD44780 controller datasheet:

254,24 shift (scroll) the display left
254,28 shift (scroll) the display right

Then you could have a single string with a few spaces to the left and right of the text and scroll the message back and forth.
 

hippy

Ex-Staff (retired)
Westaust55 has the simple solution but there is another more 'brute force' method which can also be useful for example if you were creating an LCD display for a music player and needed -

"Album : <album name>"

Where you wanted only <album name> to scroll if too long to fit on the screen. Consider what you currently have ...

Code:
serout 0,n2400,("254,1")
serout 0,n2400,("     Trevor")
serout 0,n2400,("254,1")
serout 0,n2400,("      Trevor")
serout 0,n2400,("254,1")
serout 0,n2400,("        Trevor")
If you analyse the above; then what is the thing which creates a scrolling name ? The number of spaces before the name is written - If the number of spaces increases the name scrolls to the right, if it decreases it scrolls to the left.

So from that we can create a program that puts up a variable number of spaces -

Code:
Do
  For b0 = 0 To 15
    SerOut 0, N2400, ( 254, 1 )
    Gosub AddSpaces
    SerOut 0, N2400, ( "Trevor" )
  Next
Loop

AddSpaces:
  If b0 > 0 Then
    For b1 = 1 To b0
      SerOut 0, N2400, ( " " )
    Next
  End If
  Return
You can also remove the flicker by not clearing the screen (254,1), but moving the cursor to the first position (254,$80) and letting the display overwrite the previous.

You'll see some characters left behind; how would you get rid of them ? Overwrite with more spaces after the name is written.
 
Thanks very much :p I understand how that works aswell! :D I even edited a little and I will now advance from here. I have no clue what to build though :S
 

Paix

Senior Member
What we all build Trevor, another capability . . . it explains away the bits box too. Have fun, a real need will come along sooner or later and then you will have the capabilitiy to fall back on. :)
 

Ttocs

New Member
I'm new at all this and after playing around with trying to get a smooth scrolling message on the Axe 133Y 16x2 Serial OLED Display here is what I got. I'm sure it can be stream lined and fixed up, but the method might help others.

Code:
;Axe 133Y 16x2 Serial OLED Display on pin c.1
;18m2 PicAxe
;Scrolling Message Left on Lines 1 and 2

pause 1500	;Allow display splash screen

serout c.1, n2400, (254,1) ;clear display
pause 30	;must pause after clear

serout c.1, n2400, (254,150)	;Starting posistion on line 1
serout c.1, n2400, ("Dang!      ")


SerOut c.1, N2400, ( 254, 208 )		;Starting posistion on line 2
serout c.1, n2400, ("Temperature Error")	;Message to Scroll

main:
  b20 = b20 + 1	;counter to flag reset when message has scrolled off the display
  if b20 = 32 then
  	SerOut c.1, N2400, ( 254, 2 )			;reset display to start over
  	pause 50
  	SerOut c.1, N2400, ( 254, 208 )		;Starting posistion on line 2
  	serout c.1, n2400, ("Temperature Error   ");Message to Scroll	
  	b20 = 0						;reset counter
  endif
    	serout c.1, n2400, (254,24)			;Shift (scroll) the display left 
    	pause 150						;Scrolling Speed

goto main

;NOTE: Counter value is dependant on length of longest message
 

Memran

Member
Having the screen cleared before each update will cause some blinking.

The following code is untested but should give you some ideas:

Code:
serout 0,n2400,(254,1) 'clear
pause 500
serout 0,n2400,(254,128,"Trevor") 'output starting at left of first line
pause 100
for b0 = 128 to 137
    serout 0,n2400,(254,b0," Trevor") 'output starting at b0 (note the leading space)
    pause 100
next b0
My thinking behind this is that you do not need to clear anything except the character to the left of your name, so we only need to print a single space in front of it.
A similar thing could be done if you want to scroll left, by using a trailing space.
 
Last edited:

Memran

Member
This will make "Rob" bounce left and right on the top line of my 20 x 4 OLED.

Code:
#picaxe 08m2
#com 3
#no_data

pause 1000
hi2csetup i2cmaster, %10100000, i2cslow, i2cbyte

hi2cout 0,(254,1)
pause 1000
	
do
	for b0 = 128 to 144
		hi2cout 0,(254,b0," Rob")
		pause 100
	next b0
	
	for b0 = 144 to 128 step -1
		hi2cout 0,(254,b0,"Rob ")
		pause 100
	next b0
loop
The above code is using OLED via i2c, but just replace hi2cout 0,() with serout B.0,n2400,()
 

Bill.b

Senior Member
I'll add my bit as well.

This is for a christmas sign and moves the message in from the right and disapears out the left.

Code:
#picaxe 08M2

symbol baud 	= N2400_16
symbol OLED		= c.2		'Serial output to display

setfreq m16
pause 5000
serout OLED,Baud,(254,1)		'Clear screen
pause 30

main:
	 
	serout OLED,Baud,(254,128)	'first message to line
 	serout OLED,Baud,(" WELCOME TO THE")
	serout OLED,Baud,(254,192)
	For b0 = 34 To 0 STEP -1
 		  SerOut OLED,Baud,( 254, 172 )  'second line message scrolled
  		  Gosub AddSpaces
  		  SerOut OLED,Baud,( "BEAR'S AMUSMENT PARK           " )
 	Next B0 
	PAUSE 5000
	serout OLED,Baud,(254,1)	'second message displayed
	PAUSE 3000
	serout OLED,Baud,(254,128)
	serout OLED,Baud,("MERRY CHRISTMAS")
	serout OLED,Baud,(254,192)
	serout OLED,Baud,("    TO ALL     ")
	PAUSE 12000
	serout OLED,Baud,(254,1)	'Clear screen
	PAUSE 3000
	serout OLED,Baud,(254,128)	'third message
	serout OLED,Baud,("  DONATE TO THE")
	PAUSE 10
	For b0 = 32 To 0 STEP -1
   		SerOut OLED,Baud,( 254, 175 )  'scroll second line
    		Gosub AddSpaces
    		SerOut OLED,Baud,( "RESCUE HELICOPTOR         " )
	Next B0 
	PAUSE 5000
	serout OLED,Baud,(254,1)	'Clear screen
 	PAUSE 3000
 	
 		serout OLED,Baud,(254,128)
 	serout OLED,Baud,("CAROL AND BILL'S")
	PAUSE 10
	SerOut OLED,Baud,( 254, 192 )
     	SerOut OLED,Baud,( "CHRISTMAS LIGHTS" )
     	PAUSE 12000
     	serout OLED,Baud,(254,1)
 	PAUSE 3000
    	serout OLED,Baud,(254,128)
 	serout OLED,Baud,(" VOTE FOR US AT")
	PAUSE 10
 	For b0 = 42 To 0 STEP -1
   		SerOut OLED,Baud,( 254, 166 )
    		Gosub AddSpaces
    		SerOut OLED,Baud,( "www.santaswharehouse.com.au         " )
  	Next B0 
	PAUSE 5000
	serout OLED,Baud,(254,1)
 	PAUSE 3000
 	goto main
	
AddSpaces:			'routine to add spaces before message

  	If b0 > 0 Then
   		For b1 = 1 To B0
      		SerOut OLED,Baud, ( " " )
      		PAUSE 50
    		Next B1
  	End If
  	return
Bill
 
Top