Shop OBEX P1 Docs P2 Docs Learn Events
Need help with code — Parallax Forums

Need help with code

youngbillyoungbill Posts: 54
edited 2010-11-05 17:25 in BASIC Stamp
My code is for a 0 to 10 counter,using a max 7219 and stamp bs2.
'
[ I/O Definitions ]

DataIO PIN 2 ' MAX7219.1
Clock PIN 1 ' MAX7219.13
Load PIN 0 ' MAX7219.12

'
[ Constants ]

Decode CON $09 ' BCD Decode Register
Brite CON $0A ' Intensity Register
Scan CON $0B ' Scan Limit Register
ShutDn CON $0C ' Shutdown Register (1 = On)
Test CON $0F ' Display Test Mode
No CON 0

'
[ Variables ]
secs VAR Byte
index VAR Byte ' Loop Counter
seconds VAR Byte ' Seconds
d7219 VAR Byte ' Data For MAX7219
idxOdd VAR index.BIT0 ' Is Index Odd? (1 = Yes)

'
[ Initialization ]
init:
FOR index = 0 TO 9
LOOKUP index, [Scan, 1, Brite, 14, Decode, $FF, ShutDn, 1, test,$0000], d7219

SHIFTOUT DataIO, Clock, MSBFIRST, [d7219]
IF (idxOdd = No) THEN No_Load
PULSOUT Load, 5
No_Load:

NEXT
'
[ Program Code ]
DO
FOR secs = 0 TO 12
seconds.LOWNIB = secs DIG 0
seconds.HIGHNIB = secs DIG 1

GOSUB Show_Time
PAUSE 1000
NEXT
LOOP
'
[ Subroutines ]
Show_Time:
index = 1
d7219 = seconds.LOWNIB
GOSUB Show_Max_Time
index = 2
d7219 = seconds.HIGHNIB
Show_Max_Time:

SHIFTOUT DataIO, Clock, MSBFIRST, [index, d7219]
PULSOUT Load, 5
RETURN

My question is on intialization...each idem in list is stored in variable d7219.
How can it store it all in a byte size variable?
Q2 I only have ONE return command. How can it work,,,do the gosubs take turns on the samr RETURN command?
Q3 Is there a way to Blank leading Zeros? Thanks

Comments

  • Tracy AllenTracy Allen Posts: 6,662
    edited 2010-10-29 13:16
    -- On initialization, the items in the list are stored in d7219 in sequence, not at the same time. Is that the question?
    -- You need another GOSUB Show_Max_Time and a RETURN at the end of your Show_time subroutine.
    -- A program can blank leading zeros (and change them into spaces if desired). One way to do that is to define a flag bit that is zero until the first non-zero digit is encountered. Until that happens, the zero digits are skipped or printed as spaces.
  • youngbillyoungbill Posts: 54
    edited 2010-11-05 17:25
    -- On initialization, the items in the list are stored in d7219 in sequence, not at the same time. Is that the question?
    -- You need another GOSUB Show_Max_Time and a RETURN at the end of your Show_time subroutine.
    -- A program can blank leading zeros (and change them into spaces if desired). One way to do that is to define a flag bit that is zero until the first non-zero digit is encountered. Until that happens, the zero digits are skipped or printed as spaces.

    According to the app notes in parallax,,,sending a 15 will blank a digit,,,Can anyone explain,,,is this something to do with decode mode?
    Basicly how do i blank leading zeros,,,or if I send 15,,,to what address?Thanks for any replys
Sign In or Register to comment.