Code:
'****************************************************************
'* Name : BigNums.BAS *
'* Author : Scott Edwards, adapted by Darrel Taylor *
'* Notice : Copyright (c) *
'* : All Rights Reserved *
'* Date : 2/20/07 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************
;Initialize your hardware first
'BIGNUMS.BS2 (Display four 1" digits on 4x20 display)
' Connect the serial input of a Backpack-equipped 4x20 display to
' BS2 pin P0 and run this program. The program will define a set
' of symbols that allow it to display 4-line-tall numerals on the
' LCD. To incorporate this capability into your own programs, just
' substitute your code for the demo loop. When you want to display
' a value (0-9999) in big numerals, write it to dispVal, then
' gosub bigLCD.
I con 254 ' Instruction prefix.
ClrLCD con 1 ' Clear-LCD instruction.
N96N con $4054 ' 9600 baud, inverted, no parity.
cgRAM con 64 ' Address 0 of CG RAM.
EEptr var word ' Pointer into EEPROM.
pat var EEptr ' Alias for EEptr.
dispVal var word ' Value to be displayed as big digits.
temp var byte ' Temporary byte variable.
decade var word
nbl var byte ' Index into number-pattern tables.
digit var byte ' Current digit to display
line var byte ' LCD line
LCDOUT I,ClrLCD
PAUSE 500
' ====This section may be omitted with newer (post July 96)
' ====4x20 Serial LCD modules. Cut from here...============== >>>
bitPat0 DATA 0,0,0,1,3,7,15,31 ' Left-right up-ramp shape.
bitPat1 DATA 0,0,0,16,24,28,30,31 ' Right-left " "
bitPat2 DATA 31,15,7,3,1,0,0,0 ' Left-right down ramp.
bitPat3 DATA 31,30,28,24,16,0,0,0 ' Right-left " "
bitPat4 DATA 0,0,0,0,31,31,31,31 ' Lower block.
bitPat5 DATA 31,31,31,31,0,0,0,0 ' Upper block.
bitPat6 DATA 31,31,31,31,31,31,31,31 ' Full block.
bitPat7 DATA 0,0,0,0,0,0,0,0 ' Full blank
' <<<...to here. ===============================================
;low 0 ' Make the serial output low
;pause 1000 ' Let the LCD wake up.
' ====This section may be omitted with newer (post July 96)
' ====4x20 Serial LCD modules. Cut from here...============= >>>
;serout 0,N96N,[I,cgRAM] ' Enter CG RAM.
LCDOUT I,cgRAM
for EEptr = 0 to 63 ' Write the bit patterns
Read EEptr,temp ' to the LCD.
; serout 0,N96N,[temp]
lcdout temp
next
' <<<...to here. ===============================================
;serout 0,N96N,[I,ClrLCD] ' Clear the LCD.
LCDOUT I, ClrLCD
pause 1
' ========================================================================
' Demo Loop: Show dispVal in Big Numerals, Increment, Loop
' ========================================================================
again:
gosub bigLCD
dispVal = dispVal + 1
pause 500
goto again
' ========================================================================
' Subroutine Displaying Large Numbers
' ========================================================================
bigLCD:
for line = 0 to 3
decade = 1000
lookup line,[128,192,148,212],temp
; serout 0,N96N,[I,temp]
LCDOUT I, temp
for digit = 3 to 0 step -1
nbl = dispVal dig digit
gosub getPattern
if dispVal = 0 and digit = 0 then skip0
if dispVal < decade then blankIt
skip0:
; serout 0,N96N,[pat.nib3,pat.nib2,pat.nib1,pat.nib0]
LCDOUT pat.Highbyte>>4, pat.Highbyte&$0F, pat.LowByte>>4, pat.Lowbyte&$0F
goto cont
blankIt:
; serout 0,N96N,[" "]
lcdout " "
cont:
if digit = 0 then skip1
; serout 0,N96N,[32]
LCDOUT 32
skip1:
decade = decade/10
next
next
return
' Subroutines Defining Big-Character Patterns
' ========================================================================
getPattern:
branch line,[first,second,third,fourth]
' 0 1 2 3 4 5 6 7 8 9
' --- --- --- --- --- --- --- --- --- ---
first:
lookup2 nbl,[$0551,$7067,$0551,$0551,$6776,$6555,$0557,$2556,$0551,$0551],pat
return
second:
lookup2 nbl,[$6776,$7767,$7743,$7743,$6776,$2441,$6041,$7703,$2443,$6776],pat
return
third:
lookup2 nbl,[$6776,$7767,$0577,$7751,$2556,$7776,$6776,$7767,$0551,$2536],pat
return
fourth:
lookup2 nbl,[$2443,$7464,$6444,$2443,$7776,$2443,$2443,$7767,$2443,$7443],pat
return
I very sincerely hope it has not gotten corrupted sometime after I saved it. As always I offer all statements to be opinions and not necessarly facts.
Code:
'****************************************************************
'* Name : Big_Num.BAS *
'* Author : *
'* Notice : Copyright (c) 2007 *
'* : All Rights Reserved *
'* Date : 1/3/07 *
'* Version : 1.0 *
'* Notes :Mister_e's big numbers for 16F877a *
'* : *
'****************************************************************
DEFINE LOADER_USED 1
Define OSC 4
DEFINE LCD_DREG PORTD ' LCD data port
DEFINE LCD_DBIT 4 ' LCD data starting bit 0 or 4
DEFINE LCD_RSREG PORTD ' LCD register select port
DEFINE LCD_RSBIT 2 ' LCD register select bit
DEFINE LCD_EREG PORTD ' LCD enable port
DEFINE LCD_EBIT 3 ' LCD enable bit
DEFINE LCD_BITS 4 ' LCD bus size 4 or 8
DEFINE LCD_LINES 4 ' Number lines on LCD
DEFINE LCD_COMMANDUS 2000 ' Command delay time in us
DEFINE LCD_DATAUS 50 ' Data delay time in us
Clr CON 1
Comm con $FE
EOL con $FC
Dx con $14
Line var byte[4]
line[0]=$80
line[1]=$C0
line[2]=$94
line[3]=$D4
Zero data 5,0,0,4,EOL
data $FF,Comm,Dx,Comm,Dx,$FF,EOL
data $FF,Comm,Dx,Comm,Dx,$FF,EOL
data 2,1,1,3,EOL
data 5
One data Comm,Dx,5,$ff,EOL
data Comm,Dx,Comm,Dx,$ff,EOL
data Comm,Dx,Comm,Dx,$ff,EOL
data Comm,Dx,Comm,Dx,$ff,EOL
data 5;3
Two data 0,0,0,4,EOL
data Comm,Dx,Comm,Dx,Comm,Dx,$ff,EOL
data 5,0,0,0,EOL
data $ff,1,1,1,EOL
data 5
Three data 0,0,0,4,EOL
data Comm,Dx,Comm,Dx,Comm,Dx,$ff,EOL
data Comm,Dx,0,0,$ff,EOL
data 1,1,1,3,EOL
data 5
Four data $ff,Comm,Dx,Comm,Dx,$FF,EOL
data $ff,Comm,Dx,Comm,Dx,$ff,EOL
data 0,0,0,$ff,EOL
data Comm,Dx,Comm,Dx,Comm,Dx,$ff,EOL
data 5
Five data $FF,0,0,0,EOL
data $ff,EOL
data 0,0,0,4,EOL
data 1,1,1,3,EOL
data 5
Six data 5,0,0,EOL
data $ff,EOL
data $ff,0,0,4,EOL
data 2,1,1,3,EOL
data 5
Seven data 0,0,0,4,EOL
data Comm,Dx,Comm,Dx,comm,dx,$ff,EOL
data Comm,Dx,Comm,Dx,comm,dx,$ff,EOL
data Comm,Dx,Comm,Dx,Comm,Dx,$ff,EOL
data 5
Eight data 5,0,0,4,EOL
data 2,1,1,3,EOL
data 5,0,0,4,EOL
data 2,1,1,3,EOL
data 5
Nine data 5,0,0,4,EOL
data 2,1,1,$ff,EOL
data Comm,Dx, Comm,Dx,Comm,Dx,$ff,EOL
data Comm,Dx,1,1,3,EOL
data 5
Punto data EOL
data EOL
data EOL
data 7,EOL
data 2
offset var byte
index var byte
Char var byte
ActualLine var byte
CounterA var word
CounterB var byte
Number var byte
Pattern var word[11]
pattern[0]=zero
pattern[1]=one
Pattern[2]=two
pattern[3]=three
pattern[4]=four
Pattern[5]=Five
Pattern[6]=Six
Pattern[7]=Seven
pattern[8]=eight
pattern[9]=Nine
pattern[10]=Punto
pause 500
DumpCustChar:
index=0
repeat
lookup index,[Comm,64,31,31,31,31,0,0,0,0,_ ; Cust Char #0
Comm,72,0,0,0,0,31,31,31,31,_ ; Cust Char #1
Comm,80,31,31,31,15,7,3,1,0,_ ; Cust Char #2
Comm,88,31,31,31,30,28,24,16,0,_ ; Cust Char #3
Comm,96,0,16,24,28,30,31,31,31,_ ; Cust Char #4
Comm,104,0,1,3,7,15,31,31,31,_ ; Cust Char #5
Comm,112,31,31,31,31,31,31,31,31,_ ; Cust Char #6
Comm,120,0,0,0,14,31,31,31,14],char; Cust Char #7
lcdout char
index=index+1
until index=80
Main:
countera=0
repeat
offset=0
lcdout comm,clr
counterb=3
repeat
number=countera dig counterb
gosub displaynumber
counterb=counterb-1
until counterb=255
pause 10
countera=countera+1
until countera=10000
goto main
DisplayNumber:
actualline=0
index=0
lcdout comm,line[0]+offset
Loop:
read pattern[number]+index,char
if char!=eol then
if actualline<4 then
lcdout char
else
offset=offset+char
Goto GetOut
endif
else
actualline=actualline+1
if actualline<4 then lcdout comm,line[actualline]+offset
endif
index=index+1
goto loop
GetOut:
RETURN
Again I failed to save the URL.
Bookmarks