SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.

What should I do with it?

You made it this far, quit before you break it!
1
7%
Add support for Linux!
3
20%
Connect 135 of those and build your own HTDV-ready OLED display!
5
33%
Plz tell me how 2 do that!!!111one
6
40%
By RasmusB
#17824
Just got my OLED from SparkFun, and now it's up and running on a PIC18F452, downloading images through RS-232 :)

Image

So now the only problem is what to do with it... I've also ordered some LiPo batteries, and I'm in the mood for building something portable! But what? I've glanced at enough MP3-players and such, does anyone have a suggestion for anything else? Home automation remote, GPS powered bicycle computer or _insert idea here_?

It doesen't have to be a commercially viable project, I just want to have something impressive to show off and say "I built this!" ;)
Last edited by RasmusB on Thu Aug 24, 2006 3:29 pm, edited 1 time in total.
By geekything
#17829
Build a Linux framebuffer/console driver for it and I'll be your best friend :-)

-marc
By bsodmike
#17848
That's pretty sweet. I've never worked with the 18Fs, apart from being native USB how simple was it to upload images and write data to the display?

Cheers,
Mike
By RasmusB
#17865
RasmusB wrote:Just got my OLED from SparkFun, and now it's up and running on a PIC18F452, downloading images through RS-232 :)
RS-232 is the protocol that the serial port on a PC uses. I just dump a image file in RAW format to the serial port, the PIC recieves it, does some bit shifting and draws it on the display. Really simple since RS-232 is handeled in hardware, you only need to set three registers.

The display is really simple to use once you have got it running. I run it in 8-bit 8080 mode. Basically I have just ported the sparkfun example init code to PIC ASM (with some modifications), nothing fancy at all.
User avatar
By ohararp
#18007
Would you mind posting your assembly code (with comments is always nice) since I am also using Pics this would be helpful.

For what it is worth it'd be really neat to have this display worth with my gps datalogger.
By RasmusB
#18023
Here it is; nothing fancy. The (few) comments are in swedish so I guess they aren't of much use to you.

But you should be able to figure this out easily if you have done PIC ASM before. All it does is:

- Init ports on the PIC
- Init display
- Init RS-232
- Wait for image data

The image data recieve loop waits until three bytes have been recieved, bitshifts every byte two steps and then sends the complete pixel. Set your terminal program to 8-bit mode, one stop bit, 19200 baud and no flow control.
Code: Select all
list p=p18f452
include "P18F452.INC"

ERRORLEVEL -203 ; suppress annoying column directive message
ERRORLEVEL -205 ; suppress annoying column directive message
ERRORLEVEL -207 ; suppress annoying column message 
ERRORLEVEL -302 ; suppress message because of page change

	CONFIG 	WDT = OFF
	CONFIG	OSC = HS
	CONFIG	OSCS = OFF
	CONFIG	PWRT = OFF
	CONFIG	BOR = OFF
	CONFIG	CCP2MUX = OFF
	CONFIG	STVR = OFF
	CONFIG	LVP = OFF
	CONFIG	DEBUG = OFF
	CONFIG	CP0 = OFF
	CONFIG	CP1 = OFF
	CONFIG	CP2 = OFF
	CONFIG	CP3 = OFF
	CONFIG	CPB = OFF
	CONFIG	CPD = OFF
	CONFIG	WRT0 = OFF
	CONFIG	WRT1 = OFF
	CONFIG	WRT2 = OFF
	CONFIG	WRT3 = OFF
	CONFIG	WRTB = OFF
	CONFIG	WRTC = OFF

cblock 0x00
	delayCounter1     
	delayCounter2
    delayCounter3
	byteCount
	Red
	Green
	Blue
endc

;Kommentarerna gäller bara för 8-bitars 8080-interface.
RST			equ		5			;Reset (då 0)
ERD			equ		2			;Read data (då 0)
RW			equ		1			;Write input (då 0)
D_C			equ		0			;Data / Command (Data 1, kommando 0)
lcdData		equ		PORTD		;8-bitars dataport
lcd			equ		PORTC		;Kontrollport


;constant	Addr_disp			=	B'01000100'

org		0x0000					; Begininning of Program EEPROM	
goto	main
;org		0x0008
;goto	ISR						;Interrupt Service Routine

main
	clrf	TRISC				;Port C blir en utgång
	clrf	TRISD				;Port D blir en utgång

	bsf		TRISC,7				;... utom ingången för serieporten (RX)

	movlw	d'64'
	movwf	SPBRG
	movlw	b'00000110'
	movwf	TXSTA
	movlw	b'10011000'
	movwf	RCSTA



	bsf		RCSTA,SPEN			;Enable serieport!

	clrf	lcdData				;Nollställ pinnarna...
	bcf		lcd,D_C				;Välj att skicka kommando
	bsf		lcd,ERD				;Vi vill inte läsa något...
	bcf		lcd,RW				;Vi vill inte skicka något heller...
	call	sendReset			;Men en reset vill vi minsann dra!
	
	movlw	0xa0
	call	sendC
	movlw	0xB4
	call	sendD
	movlw	0xa1
	call	sendC
	movlw	0x00
	call	sendD
	movlw	0xa6
	call	sendC
	movlw	0xad
	call	sendC
	movlw	0x8e
	call	sendD
	movlw	0xb0
	call	sendC
	movlw	0x05
	call	sendD
	movlw	0xb1
	call	sendC
	movlw	0x11
	call	sendD
	movlw	0xb3
	call	sendC
	movlw	0xf0
	call	sendD
	movlw	0xbb					;Pre-charge voltage
	call	sendC
	movlw	0x1c					;R
	call	sendD
	movlw	0x1c					;G
	call	sendD
	movlw	0x1c					;B
	call	sendD
	movlw	0xbe					;Set VCOMH
	call	sendC
	movlw	0x1f
	call	sendD
	movlw	0xc1					;Set contrast
	call	sendC
	movlw	0xaa					;R
	call	sendD
	movlw	0xb4					;G
	call	sendD
	movlw	0xc8					;B
	call	sendD
	movlw	0xc7
	call	sendC
	movlw	0x0f
	call	sendD
	movlw	0xca
	call	sendC
	movlw	0x7f
	call	sendD

	movlw	0x15
	call	sendC
	movlw	d'0'
	call	sendD
	movlw	d'127'
	call	sendD
	
	movlw	0x75
	call	sendC
	movlw	d'4'
	call	sendD
	movlw	d'131'
	call	sendD

	movlw	0xaf
	call	sendC				;display on
	call	delay120ms

;	movlw	0x8e				
;	call	sendC				;Clear window
;	movlw	d'0'
;	call	sendD
;	call	sendD
;	movlw	d'131'
;	call	sendD
;	call	sendD
;	call	delay120ms
	bcf		PIR1,RCIF

	movlw	d'3'
	movwf	byteCount

USARTloop
	btfss	PIR1,RCIF
	goto	USARTloop
	bcf		PIR1,RCIF
	movff	Blue,Red
	movff	Green,Blue
	movff	RCREG,Green
	decfsz	byteCount
	goto	USARTloop
	movlw	0x5c
	call	sendC
	rrncf	Green
	rrncf	Green
	movf	Green,0
	call	sendD
	rrncf	Blue
	rrncf	Blue
	movf	Blue,0
	call	sendD
	rrncf	Red
	rrncf	Red
	movf	Red,0
	call	sendD
	movlw	d'3'
	movwf	byteCount
goto	USARTloop


;SUBRUTINER---------------------------------------------

sendD
	bsf		lcd,D_C
	bcf		lcd,RW
	movwf	lcdData
;	call	delay1ms
	bsf		lcd,RW
return

sendC
	bcf		lcd,D_C
	bcf		lcd,RW
	movwf	lcdData
	bsf		lcd,RW
	bsf		lcd,D_C
return

sendReset
	bcf		lcd,RST
	call	delay120ms
	bsf		lcd,RST
return
	

delay1ms
	movlw   D'130'            
    movwf   delayCounter1     
    movlw   D'7'
    movwf   delayCounter2
delay1msLoop
    decfsz  delayCounter1,1
    goto    delay1msLoop
    decfsz  delayCounter2,1
    goto    delay1msLoop
return

delay120ms
	movlw   D'255'            
    movwf   delayCounter1     
    movlw   D'255'
    movwf   delayCounter2
    movlw   D'10'
    movwf   delayCounter3
delay120msLoop
    decfsz  delayCounter1,1
    goto    delay1msLoop
    decfsz  delayCounter2,1
    goto    delay1msLoop
	decfsz	delayCounter3,1
	goto	delay120msLoop
return

end