PDA

View Full Version : 5x5 display 16f648a



nomad
- 19th December 2007, 20:18
Saw a 5x5 display on you tube, daughter liked it so decided to make one.
there was no code for it, so here it is in PBP.



'************************************************* **
'* Christmas stocking stuffer for Andi from dad
'* 5x5 home made led display
'* pic 16F648A
'* December 2007
'* by: Nomad (DSobelman(at)hotmail(dot)com)
'************************************************* ***

' USE ALL CAPS for now, will add lower case or lower case conversion to caps later
' very limited character set for now (no time to add the rest right now)
' added space at beginning of data, project was skipping first character
data " ANDREA ROCKS # MERRY CHRISTMAS MUNCHKIN #"

@ DEVICE pic16F648A, INTRC_OSC_NOCLKOUT
'@ DEVICE pic16F648A, HS_OSC
' osc setting
@ DEVICE pic16F648A, WDT_OFF
' Watchdog Timer
@ DEVICE pic16F648A, PWRT_ON
' Power-On Timer
@ DEVICE pic16F648A, MCLR_OFF
' Master Clear Options (Internal)
@ DEVICE pic16F648A, BOD_OFF
' Brown-Out Detect
@ DEVICE pic16F648A, LVP_OFF
' Low-Voltage Programming
@ DEVICE pic16F648A, CPD_OFF
' code protect
@ DEVICE pic16F648A, PROTECT_OFF
'data protect

defines:
'define osc 20
DEFINE OSC 4

PORTB = 0 'turn off all
PORTA = 0
TRISB = 0 'all output
TRISA = 0
CMCON = 7 'disable comparators

Variables:

row var byte
col var byte[8] 'was originally going to do scrolling on 8x8 but didn't have a board
x var word 'how many random patterns in random sub
temp var word 'temp var for random HAS TO BE WORD (random doesn't work with byte)
rowx var byte[5] 'store constant for each row
char var byte ' index for lookup
lettermark var BYTE 'pointer to eeprom address
letter var byte 'temp for ascii convert
clear

constants: 'rows numbered 1-5, single each row out
rowx[1] = 1
rowx[2] = 2
rowx[3] = 4
rowx[4] = 8
rowx[5] = 16

start:
GOSUB READ_STRING 'READ EEPROM DATA
gosub get_char 'GET CHARACTER DATA
gosub display_run 'DISPLAY CHARACTER
gosub rand_disp 'SHOW RANDOM BLINKY STUFF (THEY LIKE BLINKY STUFF)
goto start 'DO IT AGAIN WITH NEXT LETTER OVER AND OVER

rand_disp: 'generate random noise on display
for x=1 to 5 'dispplay "x" random patterns (full 5x5(8x8) patterns)
random temp 'make random number
pauseus 50
PORTA = temp 'put out on porta (only uses low byte?)
random temp 'make row random number
pauseus 50
PORTB = temp 'put out on portb
pause 20 'how long to show pattern
next x 'next pattern
return

display_run: 'show characters
PORTA=0 'turn off all leds
PORTB=0
PAUSE 50 'forgot why this is here
for temp = 1 to 1000 'how many full character loops (how long to display character)
for row = 1 to 5 '5 loops, one for each row
porta = 0 'turn rows off (kill ghosting)
portb = col[row] 'put out row data for row(x)
PAUSEUS 100 'settle
porta = rowx[row] 'turn on row
pauseus 100 'settle
next row 'do again for each row to show full character
next temp 'show character again (refresh/scan/whatever you wish to call it)
return

read_string: 'read data (message) from eprom
lettermark = lettermark + 1 'go to next eeprom address
IF LETTERMARK > 255 THEN ' if at end hmmm don't think I need this anymore
LETTERMARK = 0 'was testing
ELSE
ENDIF
READ LETTERMARK, LETTER 'read byte from eprom, assign to letter
IF LETTER = $FF THEN 'check for end of message
LETTERMARK = 0 'if end, reset eeprom pointer, make a space character
LETTER = $20
ELSE
ENDIF
PAUSEUS 500
find_index: ' use lookdown to change ascii to a sequential index to keep lookup small
LOOKDOWN LETTER,["- #ABCDEFGHIJKLMNOPQRSTUVWXYZ"],CHAR
RETURN

get_char: ' get each of the row's data with index from converted ascii
LOOKUP char,[$00,$00,$0A,$0E,$1E,$0E,$1C,$1F,$1E,$1E,$11,$0E,$0 7,$09,$08,$11,$11,$0E,$0E,$0E,$1E,$0E,$1F,$00,$11, $11,$11,$11,$1F],col[1]
LOOKUP char,[$00,$00,$1B,$11,$09,$10,$0A,$10,$10,$10,$11,$04,$0 2,$0A,$08,$1B,$19,$11,$09,$11,$09,$10,$04,$0A,$11, $11,$0A,$11,$02],col[2]
LOOKUP char,[$1F,$00,$04,$1F,$0E,$10,$0A,$1E,$1C,$16,$1F,$04,$0 2,$0C,$08,$15,$15,$11,$0E,$15,$0E,$0E,$04,$0A,$0A, $15,$04,$1F,$04],col[3]
LOOKUP char,[$00,$00,$1B,$11,$09,$10,$0A,$10,$10,$12,$11,$04,$0 A,$0A,$08,$11,$13,$11,$08,$12,$0A,$01,$04,$0A,$04, $1B,$0A,$04,$08],col[4]
LOOKUP char,[$00,$00,$0A,$11,$1E,$0E,$1C,$1F,$10,$1E,$11,$0E,$0 E,$09,$0E,$11,$11,$0E,$08,$0D,$09,$0E,$04,$0E,$00, $11,$11,$04,$1F],col[5]
return
end


will have to extend the character set and add serial to change the message. but this was just for a quick toy, so I didn't do any of that.

skimask
- 19th December 2007, 21:27
If you add 2 more rows and make it a 5x7 display, I've got a set of lookup tables already made up for the complete ASCII character set, should plug right into what you've got going.
Originally, I used the character tables for a 122x32 graphic LCD, and now I'm using it on a 130x130 4K color Nokia knockoff LCD (in addition to a 16x2 LCD, all at the same time!).
I'll post them here when I get a chance...

GrandPa
- 20th December 2007, 02:22
Hi Skimask,

I would like to know where you are getting your Nokia color LCD from?

Thanks!


J-P

skimask
- 20th December 2007, 21:12
Hi Skimask,

I would like to know where you are getting your Nokia color LCD from?

Thanks!


J-P

Sparkfun for the first couple along with the breakout boards, eBay for the rest.
Got a few of the connectors from Mouser (I think, don't remember), going to send off and have a few breakout boards made for myself.

I've also got a rather LONG search set up on eBay that shows only the compatible phones which use that particular display and only those particular displays.

Copy the following into the search bar and hit enter:

nokia -6620 -6230 -6061 -3220 -73* -n9* -52* -77* -6500 -57* -53* -88* -6101 -6126 -6265 -6680 -e6* -6288 -n7* -6133 -8600 -6300 -6230i -6010 -5610 -9300 -3310 -5110 -8810 -n8* -3250 -5500 -6111 -6280 -8850 -6120 -3360 -6360 -6600 -3230 -8210 -e90 -n93 -e5* -1110 -8910

Took me awhile to figure out which ones work and which ones don't. And then there's the problem with the different controllers, Philips vs. Epson. Minor differences in programming. Try to do anything out of the ordinary, either one or the other won't work. I'm using the Epson command set right now, but can't get the scrolling to work, which leads me to believe I've got a Philips controller. Not sure what's going on, but I really don't care either, 'cause it works great in the basic modes.

skimask
- 20th December 2007, 21:16
I'll post them here when I get a chance...

And here they are, 3 lookup lines, split them up as you see fit. ASCII characters $0-$7E.
The first 32 are 'special characters', as indicated below.
All characters are in 5 byte groups, one byte per VERTICAL line on the display, 5x7 format. The bottom bit in each character is usually blank except for those characters which 'drop below the line'.


lookup5x7_0: '0-31
lookup alphachar , [ _
$80,$80,$80,$80,$80,$c0,$c0,$c0,$c0,$c0,$e0,$e0,$e 0,$e0,$e0,$f0,$f0,$f0,$f0,$f0,$f8,$f8,$f8,$f8,$f8, $fc,$fc,$fc,$fc,$fc,$fe,$fe,$fe,$fe,$fe,$ff,$ff,$f f,$ff,$ff,_ '0-7 1-8 lines
$fe,$83,$81,$83,$fe,$fe,$c3,$c1,$c3,$fe,$fe,$e3,$e 1,$e3,$fe,$fe,$f3,$f1,$f3,$fe,$fe,$fb,$f9,$fb,$fe, $fe,$ff,$fd,$ff,$fe,$fe,$ff,$ff,$ff,$fe,_ '8-14 battery charge levels
$ff,0,0,0,0,$ff,$ff,0,0,0,$ff,$ff,$ff,0,0,$ff,$ff, $ff,$ff,0,0,0,0,0,$ff,0,0,0,$ff,$ff,0,0,$ff,$ff,$f f,0,$ff,$ff,$ff,$ff,$ff,0,0,0,$ff,$ff,$ff,0,$ff,$f f,$81,$81,$81,$81,$81,_
$c3,$c3,$c3,$c3,$c3,$e7,$e7,$e7,$e7,$e7,$c0,$80,0, $1,$3,$f9,$f3,$e7,$cf,$9f,$3,$1,0,$80,$c0,$9f,$cf, $e7,$f3,$f9 ] , alphadata '15-31 block fillers of varying density
return

lookup5x7_1: '32-81
lookup alphachar , [ _
0,0,0,0,0,0,0,79,0,0,0,7,0,7,0,20,$7F,20,$7F,20,36 ,42,$7F,42,18,19,19,8,$64,98,54,73,85,34,80,0,5,3, 0,0,28,34,65,0,0,0,0,65,34,28,20,8,62,8,20,8,8,62, 8,8,0,80,48,0,0,_ '32-44
8,8,8,8,8,0,96,96,0,0,32,16,8,4,2,62,81,73,69,62,0 ,66,$7F,64,0,66,97,81,73,70,33,65,69,75,49,24,20,1 8,$7F,16,39,69,69,69,53,60,74,73,73,48,1,$71,9,5,3 ,_ '45-55
54,73,73,73,54,6,73,73,41,30,0,54,54,0,0,0,86,52,0 ,0,8,20,34,65,0,20,20,20,20,20,0,65,34,20,8,2,1,81 ,9,6,50,73,73,65,62,$7E,17,17,17,$7E,$7F,73,73,73, 54,_ '56-66
62,65,65,65,34,$7F,65,65,34,28,$7F,73,73,73,65,$7F ,9,9,9,1,62,65,73,73,$7A,$7F,8,8,8,$7F,0,65,$7F,65 ,0,32,64,65,63,1,$7F,8,20,34,65,$7F,64,64,64,64,$7 F,2,12,2,$7F,_ '67-77
$7F,4,8,16,$7F,62,65,65,65,62,$7F,9,9,9,6,62,65,81 ,33,94 ] , alphadata '78-81
return

lookup5x7_2: '82-126
Lookup alphachar , [ _
$7F,9,25,41,70,70,73,73,73,49,1,1,$7F,1,1,63,64,64 ,64,63,31,32,64,32,31,61,64,56,64,63,99,20,8,20,99 ,7,8,$70,8,7,97,81,73,69,67,$7F,65,65,0,0,2,4,8,16 ,32,_ '82-92
0,0,65,65,$7F,4,2,1,2,4,64,64,64,64,64,0,1,2,4,0,3 2,84,84,84,$78,$7F,72,68,68,56,56,68,68,68,32,56,6 8,68,72,$7F,56,84,84,84,24,8,$7E,9,1,2,$C,82,82,82 ,62,_ '93-103
$7F,8,4,4,$78,0,68,$7D,64,0,0,32,64,68,61,$7F,16,4 0,68,0,0,65,$7F,64,0,$7C,4,24,4,$78,$7C,8,4,4,$78, 56,68,68,68,56,$7C,20,20,20,8,8,20,20,24,$7C,$7C,8 ,4,4,8,_ '104-114
72,84,84,84,32,4,63,68,64,32,60,64,64,32,$7C,28,32 ,64,32,28,60,64,48,64,60,68,40,16,40,68,$C,80,80,8 0,60,68,$64,84,76,68,8,52,65,0,0,0,0,$7F,0,0,_ '115-124
0,0,65,52,8,0,8,4,8,4 ] , alphadata '125-126
return

nomad
- 24th December 2007, 07:59
Thanks some more to play with. lol. I was using mister e's picmulticalc to draw out the 5 rows for my display, worked nice. :)

skimask
- 26th December 2007, 05:03
Thanks some more to play with. lol. I was using mister e's picmulticalc to draw out the 5 rows for my display, worked nice. :)

I'm in the process of adding a whole load of extra 'characters', call them 'graphics' characters, little airplanes, cars, etc, sort of animations if you will, consecutive characters which will end up resembling things like that airplane flying by, car driving, slot machine graphics, stuff like that. They'll take up the rest of the ASCII set from 128-255, and if I run out of room, change the byte to a word, add a couple of if/then's, and go with it. I'll re-post the whole thing when I get done with it all.