Double Size numbers on LCD
Here is a piece of code that I would like to share.
Using a Parallax LCD, and the BOE, I am starting the code for my Scooter Speedometer display.
Comments and critiques welcome.
Thanks,
Phil
Using a Parallax LCD, and the BOE, I am starting the code for my Scooter Speedometer display.
Comments and critiques welcome.
Thanks,
Phil
' =========================================================================
'
' File...... ScooterLCD.BS2
' Purpose... LCD Control for Scooter program, using customer characters
' Author.... Philip L. Lutz
' E-mail.... phillutz@socal.rr.com
' Started... 18 NOV 2008
' Updated...
'
' {$STAMP BS2px}
' {$PBASIC 2.5}
'
' =========================================================================
' -----[noparse][[/noparse] Program Description ]---------------------------------------------
' Routines for handling an LCD.
'
' PrintDoubleSize prints custom characters spanning 2 columns and 2 rows
' Custom character defintions are stored in eeprom to make digits 0-9 as the 4 character blocks
' first digit, second digit
' 0,1 5,6
' 2,3 7,8
' -----[noparse][[/noparse] Revision History ]------------------------------------------------
#SELECT $STAMP
#CASE BS2, BS2E, BS2PE
T1200 CON 813
T2400 CON 396
T9600 CON 84
T19K2 CON 32
T38K4 CON 6
#CASE BS2SX, BS2P
T1200 CON 2063
T2400 CON 1021
T9600 CON 240
T19K2 CON 110
T38K4 CON 45
#CASE BS2PX
T1200 CON 3313
T2400 CON 1646
T9600 CON 396
T19K2 CON 188
T38K4 CON 84
#ENDSELECT
' -----[noparse][[/noparse] I/O Definitions ]-------------------------------------------------
LcdTx PIN 14 ' serial output to LCD
' -----[noparse][[/noparse] Constants ]-------------------------------------------------------
LcdBaud CON T9600
LcdBkSpc CON $08 ' move cursor left
LcdRt CON $09 ' move cursor right
LcdLF CON $0A ' move cursor down 1 line
LcdCls CON $0C ' clear LCD (use PAUSE 5 after)
LcdCR CON $0D ' move pos 0 of next line
LcdBLon CON $11 ' backlight on
LcdBLoff CON $12 ' backlight off
LcdOff CON $15 ' LCD off
LcdOn1 CON $16 ' LCD on; cursor off, blink off
LcdOn2 CON $17 ' LCD on; cursor off, blink on
LcdOn3 CON $18 ' LCD on; cursor on, blink off
LcdOn4 CON $19 ' LCD on; cursor on, blink on
LcdLine1 CON $80 ' move to line 1, column 0
LcdLine2 CON $94 ' move to line 2, column 0
LcdCC0 CON $F8 ' define custom char 0
LcdCC1 CON $F9 ' define custom char 1
LcdCC2 CON $FA ' define custom char 2
LcdCC3 CON $FB ' define custom char 3
LcdCC4 CON $FC ' define custom char 4
LcdCC5 CON $FD ' define custom char 5
LcdCC6 CON $FE ' define custom char 6
LcdCC7 CON $FF ' define custom char 7
' -----[noparse][[/noparse] EEPROM Data ]-----------------------------------------------------
' Define the number 0
CC0 DATA $07,$0F,$18,$18,$18,$18,$19,$19,
$1C,$1E,$03,$07,$0F,$0F,$13,$13,
$1E,$1C,$18,$18,$0F,$07,$00,$00,
$03,$03,$03,$03,$1E,$1C,$00,$00
' Define the number 1
CC1 DATA $01,$07,$07,$01,$01,$01,$01,$01,
$10,$10,$10,$10,$10,$10,$10,$10,
$01,$01,$01,$01,$07,$07,$00,$00,
$10,$10,$10,$10,$1C,$1C,$00,$00
' Define the number 2
CC2 DATA $07,$0F,$1C,$18,$00,$00,$00,$00,
$1C,$1E,$07,$03,$03,$07,$0E,$1C,
$01,$03,$07,$0E,$1F,$1F,$00,$00,
$18,$10,$00,$00,$1F,$1F,$00,$00
' Define the number 3
CC3 DATA $1F,$1F,$00,$00,$01,$01,$00,$00,
$1F,$1F,$0E,$1C,$18,$18,$1C,$0E,
$00,$00,$18,$1C,$0F,$07,$00,$00,
$07,$03,$03,$07,$1E,$1C,$00,$00
' Define the number 4
CC4 DATA $00,$00,$01,$03,$07,$0E,$1C,$18,
$0C,$1C,$1C,$1C,$0C,$0C,$0C,$0C,
$1F,$1F,$00,$00,$00,$00,$00,$00,
$1F,$1F,$0C,$0C,$0C,$0C,$00,$00
' Define the number 5
CC5 DATA $1F,$1F,$18,$18,$1F,$1F,$00,$00,
$1F,$1F,$00,$00,$1C,$1E,$07,$03,
$00,$00,$18,$1C,$0F,$07,$00,$00,
$03,$03,$03,$07,$1E,$1C,$00,$00
' Define the number 6
CC6 DATA $01,$03,$07,$0E,$1C,$18,$1F,$1F,
$1C,$1C,$00,$00,$00,$00,$1C,$1E,
$18,$18,$18,$1C,$0F,$07,$00,$00,
$07,$03,$03,$07,$1E,$1C,$00,$00
' Define the number 7
CC7 DATA $1F,$1F,$00,$00,$00,$00,$01,$03,
$1F,$1F,$03,$07,$0E,$1C,$18,$10,
$07,$06,$06,$06,$06,$06,$00,$00,
$00,$00,$00,$00,$00,$00,$00,$00
' Define the number 8
CC8 DATA $07,$0F,$1C,$18,$18,$1C,$0F,$0F,
$1C,$1E,$07,$03,$03,$07,$1E,$1E,
$1C,$18,$18,$1C,$0F,$07,$00,$00,
$07,$03,$03,$07,$1E,$1C,$00,$00
' Define the number 9
CC9 DATA $07,$0F,$1C,$18,$18,$1C,$0F,$07,
$1C,$1E,$07,$03,$03,$07,$1F,$1F,
$00,$00,$00,$00,$07,$07,$00,$00,
$03,$07,$0E,$1C,$18,$10,$00,$00
' -----[noparse][[/noparse] Variables ]-------------------------------------------------------
loop1 VAR Byte
loop2 VAR Byte
CustomDefn VAR Byte
pos VAR Bit
digit VAR Nib
workVal VAR Word
char VAR Byte
speed VAR Byte
' -----[noparse][[/noparse] Initialization ]--------------------------------------------------
Reset:
HIGH LcdTx ' setup serial output pin
PAUSE 5
Initialize_Lcd:
SEROUT LcdTx, LcdBaud, [noparse][[/noparse]LcdCls, LcdOn1 ,LcdBLon] ' Initialize LCD
PAUSE 5
' -----[noparse][[/noparse] Program Code ]----------------------------------------------------
Main:
FOR speed = 0 TO 99
GOSUB PrintDoubleSize
PAUSE 500
NEXT
PAUSE 1000
GOTO Main
PrintDoubleSize:
' split speed into separate digits
FOR pos = 0 TO 1 ' For each digit
IF pos = 0 THEN
digit = (Speed / 10)
ELSE
digit = (Speed // 10)
ENDIF
workVal = digit * 32 ' offset for the custom char definition in EEPROM
CustomDefn = pos * 4 ' offset for the custom char definition storage position
' Read/Define Cust Char 0+offset position value
FOR loop1 = 0 TO 3 ' for each custom character needed
SEROUT LcdTx, LcdBaud, [noparse][[/noparse]((LcdCC0+loop1)+CustomDefn)] ' Begin character defintion
FOR loop2 = 0 TO 7 ' 8 bytes, define 8 rows of pixels
READ (workVal + (loop1 * 8) + loop2), char ' Get byte
SEROUT LcdTx, LcdBaud, [noparse][[/noparse]char] ' Send it to the LCD
NEXT
NEXT
NEXT
SEROUT LcdTx, LcdBaud,[noparse][[/noparse](LcdLine1),0,1,4,5] ' Print top part of both digits
SEROUT LcdTx, LcdBaud,[noparse][[/noparse](LcdLine2),2,3,6,7] ' Print bottom part of both digits
RETURN
' ----------------------------------------------------

Comments
My teacher said I need 2 magnets that give a value of 1 and 0 (Obviously) so what he said was to attach a magnet to my wheel and an other on the hanger of my trucks. Then just put the basic stamp underneath my board hooking it up how it's supposed to but I'd like to see my speed after the run since going at high speeds on a longboard and looking at a number instead of looking on the road is dumb I was wondering can the basic stamp record and save data on the fly?
Thing's I'd like to know are like distance traveled, time, average speed, and speed for every second. I know that the basic stamp doesn't hold a lot of info and I don't want to run to a notebook and then look at it or do my run and then figure out I didn't have enough room to save it. I want it to display on a LCD so off the bat I know I need
(1) Basic Stamp
(2) Magnets
(2) Push buttons (To change the view from Time Distance and Speeds)
(1) Bread board
(1) LCD Display
And one last question can Basic Stamps preform under constant vibration and if I wipe out which I will is there any hope for it lasting or is it better to just get a Garmin Forerunner
Thanks.
They will pop a signal when metal is passed by them.
(used to read gear rotation)
Mount the Hall effect on wheel mount (needs to be close to the passing metal)
With programming, you should be able to do all of the items on your do list [noparse]:)[/noparse]
Buttons for toggling the display would be good, but you could also change the display on a cycle.
Show MPH for 5 seconds, then display Distance Travelled, then Time, thne back to mph....
You can protect the Stamp by mounting it in a box, rubber mounted (isolated) to take some of the shock.
Phil
and thanks for the help so far
I have seen other posts, "Data logging" that mention adding EEPROM to your system, thereby increasing the amount your can store.
You need to decide
1. what you want to store
2. how much space a that data sample will occupy
3. how many samples you want in a minute, 5 minutes...
You might sample 10 samples per second, once a second, or once every 5 seconds, it all depends on what you want to accomplish.
Phil
http://forums.parallax.com/showthread.php?p=766989
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
· -- Carl, nn5i@arrl.net
Are you writing to user-definable CGRAM, this is a "44780"-type LCD?