Scrolling OLED display

russbow

Senior Member
I want to show two display screens of data on a 4x20 OLED display. The running of the two sub-routines is no problem within the main code.

I thought it would be nice for the first screen to "scroll off" and the second to "scroll on". I had no success with scroll on, but this code gives a nice scroll off

Code:
#picaxe08m2

symbol LCD=c.0

serout Lcd,N2400,(254,1)	'Clear screen
pause 500

''''''''''''''''''''''''''''''''''''''''''''''

do
	gosub dis1	'Screen one
	serout LCD,N2400,(254,2)	'Turn off scroll
	gosub dis2	'Screen two
	serout LCD,N2400,(254,2)	'Turn off scroll
loop

'''''''''''''''''''''''''''''''''''''''''''''''

dis1:

	serout LCD,N2400,(254,128,"Screen one")
	serout LCD,N2400,(254,192,"abcdefghijk")

	pause 5000

		for b0=1 to 16		'Scroll
			serout Lcd,N2400,(254,28)
			pause 100
		next b0

	
	'pause 500

return

''''''''''''''''''''''''''''''''''''''''''''''''''''

dis2:

	serout LCD,N2400,(254,128,"SCREEN TWO")
	serout LCD,N2400,(254,192,"0123456789 ")
pause 5000

	for b0=1 to 16
		serout Lcd,N2400,(254,28)
		pause 100
	next b0

	
	'pause 500

return

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
For testing, I am using a 2x16 screen.

Three questions I would like help with.

1 Is there a better way of doing it?

2. Is there a danger of line one overflowing to line 3 on the scroll on a 4 line display.

3 Why is it that when I move the display unit to another project with a static display, the darn thing scrolls. Reprogramming this picaxe does not stop the scroll. How do I "unscroll" the oled.

Thanks R.
 

Bill.b

Senior Member
Hi russbow I used this code to scroll one line of a 16 * 2 OLED display
have not tryed it on a 4 * 20.

The message scolls from right to left on ond off the screen

Hope this is of some help.

code for christmas diplay.
Code:
#picaxe 08M2

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

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

main:
	
	serout OLED,Baud,(254,128)
 	serout OLED,Baud,(" WELCOME TO THE")
	serout OLED,Baud,(254,192)
	For b0 = 34 To 0 STEP -1
 		  SerOut OLED,Baud,( 254, 172 )
  		  Gosub AddSpaces
  		  SerOut OLED,Baud,( "BEAR'S AMUSMENT PARK           " )
 	Next B0 
	PAUSE 5000
	serout OLED,Baud,(254,1)
	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)
	PAUSE 3000
	serout OLED,Baud,(254,128)
	serout OLED,Baud,("  DONATE TO THE")
	PAUSE 10
	For b0 = 32 To 0 STEP -1
   		SerOut OLED,Baud,( 254, 175 )
    		Gosub AddSpaces
    		SerOut OLED,Baud,( "RESCUE HELICOPTOR         " )
	Next B0 
	PAUSE 5000
	serout OLED,Baud,(254,1)
 	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:

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

boriz

Senior Member
Not read your code. But scrolling is easy. Just create a string longer than your display, then only display part of the the string.

Like if you have a 20 character display, create a 45 character string and only display characters B1 to B1+20, then advance B1.
 

hippy

Technical Support
Staff member
1 Is there a better way of doing it?
See how boriz describes above.

2. Is there a danger of line one overflowing to line 3 on the scroll on a 4 line display.
Yes.

3 Why is it that when I move the display unit to another project with a static display, the darn thing scrolls. Reprogramming this picaxe does not stop the scroll. How do I "unscroll" the oled.
OLED don't have internal EEPROM but draw such little current that they can retain their settings for a while when unplugged. Check that you are reinitialising the display completely, including turning scrolling off.
 

russbow

Senior Member
1. Some nice pointers to develop. Thank you both.

2. As expected. A bit of careful formatting should get round that.

3. :mad: :eek: When, as you are playing around, you alter the original code to include scrolling ( and save it ), no amount of re-programming will stop it happening !!!
 

hippy

Technical Support
Staff member
3. :mad: :eek: When, as you are playing around, you alter the original code to include scrolling ( and save it ), no amount of re-programming will stop it happening !!!
Not sure what you are 'doing wrong' but it works for me.

Take the Sample "AXE133 Serail OLED.bas" driver. Set "#define use_OLED" and "#define use_welcome", edit the start of 'msg:' routine ...

Code:
msg:
b1=0
Do
  Pause 1000
  b1 = b1 // "z" + 1 Min "A"  
  pinsB = b1
  pulsout enable,1
Loop
Download and run and you should see "ABCD..." being added to the display, eventually overwriting earlier data.

In OLED initialisation change -

let pinsB = %00000110 ; Entry Mode, ID=1, SH=0

To

let pinsB = %00000111 ; Entry Mode, ID=1, SH=1

Download and run again and ( after 10 seconds or so of nothing ) characters should scroll in from the right.

Edit back to -

let pinsB = %00000110 ; Entry Mode, ID=1, SH=0

Download and run again and the scrolling no longer happens.
 
Last edited:

russbow

Senior Member
Thanks Hippy, yet a further insight into the 18m2 program. I find it very useful.

Point 3 in my previous post - as usual not making myself clear. The issue was ( I thought ) the display continuing to scroll in another project. I then found I had put a scroll routine in this project, and then saved it.. Re-programming of course just re-inforced the "The Fault". :eek: :eek:

Thanks, R.
 
Top