SX/B convert word for 7-seg display
OK, I've got a few of HITT's 4digit 7-segment displays. In preparation for the eventual arrival of my DS2760
I played around with the code to take a number stored in 2 bytes and display it on the 7 segment display.
I really dont need to worry at this point about numbers above about 480, but this allows up to 999 to be displayed.
I do a normal conversion on the lower byte, and then treat the hi byte as a 256 adder. So if the hi byte
contains 2, I add 512 to the low byte in the convert process.
works fine. I have it setup with a pause 100 and it counts up to 999 and then rolls over to 000 and counts
up again.
Is there a much more efficient way of dealing with this? I am not overly concerned about efficiency·because what I am building
is not _that_ time critical. But would like to know if the code is a reasonable way to do this, or what.
·all vars are BYTES and are set to 0 to start
thanks!· (OK... edited for the umpteenth time.. this time I think I've got the correct version uploaded)
Paul...
Post Edited (Dunnsept) : 5/1/2006 3:54:24 PM GMT
I played around with the code to take a number stored in 2 bytes and display it on the 7 segment display.
I really dont need to worry at this point about numbers above about 480, but this allows up to 999 to be displayed.
I do a normal conversion on the lower byte, and then treat the hi byte as a 256 adder. So if the hi byte
contains 2, I add 512 to the low byte in the convert process.
works fine. I have it setup with a pause 100 and it counts up to 999 and then rolls over to 000 and counts
up again.
Is there a much more efficient way of dealing with this? I am not overly concerned about efficiency·because what I am building
is not _that_ time critical. But would like to know if the code is a reasonable way to do this, or what.
·all vars are BYTES and are set to 0 to start
numLO = 0 numHI = 0 Main: convert numLO displayvalue blank,huns,tens,ones pause 100 inc numLO if numHI = 3 then if numLO = 231 then numHI = 0 numLO = 0 endif endif if numLO = 255 then if numHI < 4 then inc numHI numLO = 0 endif endif GOTO Main convert: huns = numLO / 100 temp1 = numLO // 100 tens = temp1 / 10 ones = temp1 // 10 if numHI > 0 then for cnt = 1 to numHI if ones > 3 then inc tens ones = ones -4 else ones = ones + 6 endif if tens > 4 then inc huns tens = tens -5 else tens = tens + 5 endif if huns > 7 then huns = 0 else huns = huns + 2 endif next endif return
thanks!· (OK... edited for the umpteenth time.. this time I think I've got the correct version uploaded)
Paul...
Post Edited (Dunnsept) : 5/1/2006 3:54:24 PM GMT
Comments